IBR-DTNSuite  0.10
SecurityCertificateManager.h
Go to the documentation of this file.
1 /*
2  * SecurityCertificateManager.h
3  *
4  * Copyright (C) 2011 IBR, TU Braunschweig
5  *
6  * Written-by: Stephen Roettger <roettger@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 SECURITYCERTIFICATEMANAGER_H_
23 #define SECURITYCERTIFICATEMANAGER_H_
24 
25 #include "Configuration.h"
26 #include "core/Event.h"
27 #include "Component.h"
28 
29 #include <ibrcommon/data/File.h>
30 #include <ibrcommon/thread/Mutex.h>
31 
32 #include <ibrdtn/data/EID.h>
33 
34 #include <openssl/ssl.h>
35 #include <string>
36 
37 namespace dtn
38 {
39  namespace security
40  {
42  {
43  public:
44  SecurityCertificateException(std::string what = "verification failed") : ibrcommon::Exception(what)
45  {};
46 
47  virtual ~SecurityCertificateException() throw() {};
48  };
49 
54  public:
55  static const std::string TAG;
56 
59 
63  virtual void onConfigurationChanged(const dtn::daemon::Configuration &conf) throw ();
64 
71  static void validateSubject(X509 *certificate, const std::string &cn) throw (SecurityCertificateException);
72 
77  bool isInitialized();
78 
84  const X509 *getCert() const;
90  const EVP_PKEY *getPrivateKey() const;
95  const ibrcommon::File& getTrustedCAPath() const;
96 
97  /* functions from Component */
98  virtual void initialize() throw ();
99  virtual void startup() throw ();
100  virtual void terminate() throw ();
101  virtual const std::string getName() const;
102 
103  private:
104  ibrcommon::Mutex _initialization_lock;
105  bool _initialized;
106 
107  X509 *_cert;
108  EVP_PKEY *_privateKey;
109  ibrcommon::File _trustedCAPath;
110  };
111  }
112 }
113 
114 #endif /* SECURITYCERTIFICATEMANAGER_H_ */