IBR-DTNSuite
0.8
|
00001 /* 00002 * SecurityCertificateManager.h 00003 * 00004 * Created on: Apr 2, 2011 00005 * Author: roettger 00006 */ 00007 00008 #ifndef SECURITYCERTIFICATEMANAGER_H_ 00009 #define SECURITYCERTIFICATEMANAGER_H_ 00010 00011 #include "core/Event.h" 00012 #include "Component.h" 00013 00014 #include <ibrcommon/data/File.h> 00015 #include <ibrcommon/thread/Mutex.h> 00016 00017 #include <ibrdtn/data/EID.h> 00018 00019 #include <openssl/ssl.h> 00020 #include <string> 00021 00022 namespace dtn { 00023 00024 namespace security { 00025 00029 class CertificateManagerInitEvent : public dtn::core::Event{ 00030 public: 00031 virtual ~CertificateManagerInitEvent(); 00032 00033 /* from Event */ 00034 virtual const std::string getName() const; 00035 virtual std::string toString() const; 00036 00037 static const std::string className; 00038 00045 static void raise(X509 * certificate, EVP_PKEY * privateKey, const ibrcommon::File &trustedCAPath); 00046 00047 X509 * const certificate; 00048 EVP_PKEY * const privateKey; 00049 const ibrcommon::File trustedCAPath; 00050 00051 private: 00052 CertificateManagerInitEvent(X509 * certificate, EVP_PKEY * privateKey, const ibrcommon::File &trustedCAPath); 00053 }; 00054 00058 class SecurityCertificateManager : public dtn::daemon::Component { 00059 public: 00060 SecurityCertificateManager(); 00061 virtual ~SecurityCertificateManager(); 00062 00063 //void addChainCertificate(ibrcommon::File &certificate); 00070 static bool validateSubject(X509 *certificate, const dtn::data::EID &eid); 00071 00076 bool isInitialized(); 00077 00083 X509 *getCert(); 00089 EVP_PKEY *getPrivateKey(); 00094 ibrcommon::File getTrustedCAPath() const; 00095 00096 /* functions from Component */ 00097 virtual void initialize(); 00098 virtual void startup(); 00099 virtual void terminate(); 00100 virtual const std::string getName() const; 00101 00102 private: 00103 ibrcommon::Mutex _initialization_lock; 00104 bool _initialized; 00105 00106 X509 *_cert; 00107 EVP_PKEY *_privateKey; 00108 ibrcommon::File _trustedCAPath; 00109 }; 00110 00111 } 00112 00113 } 00114 00115 #endif /* SECURITYCERTIFICATEMANAGER_H_ */