IBR-DTNSuite  0.12
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.") : SecurityException(what)
51  {};
52 
53  virtual ~KeyMissingException() throw() {};
54  };
55 
60  static SecurityManager& getInstance();
61 
67  void sign(dtn::data::Bundle &bundle) const throw (KeyMissingException);
68  void auth(dtn::data::Bundle &bundle) const throw (KeyMissingException);
69 
75  void verify(dtn::data::Bundle &bundle) const throw (VerificationFailedException);
76  void verifyBAB(dtn::data::Bundle &bundle) const throw (VerificationFailedException);
77  void verifyPIB(dtn::data::Bundle &bundle) const throw (VerificationFailedException);
78 
86  void fastverify(const dtn::data::Bundle &bundle) const throw (VerificationFailedException);
87 
93  void decrypt(dtn::data::Bundle &bundle) const throw (DecryptException, KeyMissingException);
94 
101  void encrypt(dtn::data::Bundle &bundle) const throw (EncryptException, KeyMissingException);
102 
103  protected:
108  SecurityManager();
109 
110  virtual ~SecurityManager();
111 
112  private:
113  bool _accept_only_bab;
114  bool _accept_only_pib;
115  };
116  }
117 }
118 
119 #endif /* _SECURITY_MANAGER_H_ */