IBR-DTNSuite  0.8
daemon/src/security/SecurityManager.h
Go to the documentation of this file.
00001 #ifndef _SECURITY_MANAGER_H_
00002 #define _SECURITY_MANAGER_H_
00003 
00004 #include "Configuration.h"
00005 #include <ibrdtn/data/EID.h>
00006 #include <ibrdtn/data/Bundle.h>
00007 #include <ibrdtn/security/BundleAuthenticationBlock.h>
00008 #include <ibrdtn/security/PayloadIntegrityBlock.h>
00009 #include <ibrdtn/security/PayloadConfidentialBlock.h>
00010 #include <ibrdtn/security/ExtensionSecurityBlock.h>
00011 #include <map>
00012 
00013 namespace dtn
00014 {
00015         namespace security
00016         {
00023                 class SecurityManager
00024                 {
00025                         public:
00026                                 class KeyMissingException : public ibrcommon::Exception
00027                                 {
00028                                 public:
00029                                         KeyMissingException(std::string what = "Key for this operation is not available.") : ibrcommon::Exception(what)
00030                                         {};
00031 
00032                                         virtual ~KeyMissingException() throw() {};
00033                                 };
00034 
00035                                 class EncryptException : public ibrcommon::Exception
00036                                 {
00037                                 public:
00038                                         EncryptException(std::string what = "Encryption failed.") : ibrcommon::Exception(what)
00039                                         {};
00040 
00041                                         virtual ~EncryptException() throw() {};
00042                                 };
00043 
00044                                 class DecryptException : public ibrcommon::Exception
00045                                 {
00046                                 public:
00047                                         DecryptException(std::string what = "Decryption failed.") : ibrcommon::Exception(what)
00048                                         {};
00049 
00050                                         virtual ~DecryptException() throw() {};
00051                                 };
00052 
00053                                 class VerificationFailedException : public ibrcommon::Exception
00054                                 {
00055                                 public:
00056                                         VerificationFailedException(std::string what = "Verification failed.") : ibrcommon::Exception(what)
00057                                         {};
00058 
00059                                         virtual ~VerificationFailedException() throw() {};
00060                                 };
00061 
00066                                 static SecurityManager& getInstance();
00067 
00073                                 void sign(dtn::data::Bundle &bundle) const throw (KeyMissingException);
00074                                 void auth(dtn::data::Bundle &bundle) const throw (KeyMissingException);
00075 
00081                                 void prefetchKey(const dtn::data::EID &eid);
00082 
00088                                 void verify(dtn::data::Bundle &bundle) const throw (VerificationFailedException);
00089                                 void verifyBAB(dtn::data::Bundle &bundle) const throw (VerificationFailedException);
00090                                 void verifyPIB(dtn::data::Bundle &bundle) const throw (VerificationFailedException);
00091 
00099                                 void fastverify(const dtn::data::Bundle &bundle) const throw (VerificationFailedException);
00100 
00106                                 void decrypt(dtn::data::Bundle &bundle) const throw (DecryptException, KeyMissingException);
00107 
00114                                 void encrypt(dtn::data::Bundle &bundle) const throw (EncryptException, KeyMissingException);
00115 
00116                         protected:
00121                                 SecurityManager();
00122 
00123                                 virtual ~SecurityManager();
00124 
00125                         private:
00126                                 bool _accept_only_bab;
00127                                 bool _accept_only_pib;
00128                 };
00129         }
00130 }
00131 
00132 #endif /* _SECURITY_MANAGER_H_ */