IBR-DTNSuite  0.10
SecurityManager.h
Go to the documentation of this file.
1 /*
2  * SecurityManager.h
3  *
4  * Copyright (C) 2011 IBR, TU Braunschweig
5  *
6  * Written-by: Johannes Morgenroth <morgenroth@ibr.cs.tu-bs.de>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21 
22 #ifndef _SECURITY_MANAGER_H_
23 #define _SECURITY_MANAGER_H_
24 
25 #include "Configuration.h"
26 #include <ibrdtn/data/EID.h>
27 #include <ibrdtn/data/Bundle.h>
32 #include <map>
33 
34 namespace dtn
35 {
36  namespace security
37  {
45  {
46  public:
48  {
49  public:
50  KeyMissingException(std::string what = "Key for this operation is not available.") : ibrcommon::Exception(what)
51  {};
52 
53  virtual ~KeyMissingException() throw() {};
54  };
55 
57  {
58  public:
59  EncryptException(std::string what = "Encryption failed.") : ibrcommon::Exception(what)
60  {};
61 
62  virtual ~EncryptException() throw() {};
63  };
64 
66  {
67  public:
68  DecryptException(std::string what = "Decryption failed.") : ibrcommon::Exception(what)
69  {};
70 
71  virtual ~DecryptException() throw() {};
72  };
73 
75  {
76  public:
77  VerificationFailedException(std::string what = "Verification failed.") : ibrcommon::Exception(what)
78  {};
79 
80  virtual ~VerificationFailedException() throw() {};
81  };
82 
87  static SecurityManager& getInstance();
88 
94  void sign(dtn::data::Bundle &bundle) const throw (KeyMissingException);
95  void auth(dtn::data::Bundle &bundle) const throw (KeyMissingException);
96 
102  void verify(dtn::data::Bundle &bundle) const throw (VerificationFailedException);
103  void verifyBAB(dtn::data::Bundle &bundle) const throw (VerificationFailedException);
104  void verifyPIB(dtn::data::Bundle &bundle) const throw (VerificationFailedException);
105 
113  void fastverify(const dtn::data::Bundle &bundle) const throw (VerificationFailedException);
114 
120  void decrypt(dtn::data::Bundle &bundle) const throw (DecryptException, KeyMissingException);
121 
128  void encrypt(dtn::data::Bundle &bundle) const throw (EncryptException, KeyMissingException);
129 
130  protected:
135  SecurityManager();
136 
137  virtual ~SecurityManager();
138 
139  private:
140  bool _accept_only_bab;
141  bool _accept_only_pib;
142  };
143  }
144 }
145 
146 #endif /* _SECURITY_MANAGER_H_ */