IBR-DTNSuite  0.8
daemon/src/security/TLSStreamComponent.cpp
Go to the documentation of this file.
00001 /*
00002  * TLSStreamComponent.cpp
00003  *
00004  *  Created on: Apr 2, 2011
00005  *      Author: roettger
00006  */
00007 
00008 #include "security/TLSStreamComponent.h"
00009 
00010 #include <ibrcommon/thread/MutexLock.h>
00011 #include <ibrcommon/Logger.h>
00012 #include <ibrcommon/net/TLSStream.h>
00013 #include "SecurityCertificateManager.h"
00014 #include "Configuration.h"
00015 
00016 namespace dtn
00017 {
00018         namespace security
00019         {
00020                 TLSStreamComponent::TLSStreamComponent()
00021                 {
00022                 }
00023 
00024                 TLSStreamComponent::~TLSStreamComponent()
00025                 {
00026                 }
00027 
00028                 void
00029                 TLSStreamComponent::raiseEvent(const dtn::core::Event *evt)
00030                 {
00031                         if(evt->getName() == CertificateManagerInitEvent::className)
00032                         {
00033                                 try {
00034                                         const CertificateManagerInitEvent *event = dynamic_cast<const CertificateManagerInitEvent*>(evt);
00035                                         if (event)
00036                                         {
00037                                                 ibrcommon::TLSStream::init(event->certificate, event->privateKey, event->trustedCAPath, !dtn::daemon::Configuration::getInstance().getSecurity().TLSEncryptionDisabled());
00038                                         }
00039                                 } catch(const ibrcommon::Exception&) { }
00040                         }
00041                 }
00042 
00043                 /* functions from Component */
00044                 void
00045                 TLSStreamComponent::initialize()
00046                 {
00047                         bindEvent(CertificateManagerInitEvent::className);
00048                 }
00049 
00050                 void
00051                 TLSStreamComponent::startup()
00052                 {
00053                         /* nothing to do */
00054                 }
00055 
00056                 void
00057                 TLSStreamComponent::terminate()
00058                 {
00059                         unbindEvent(CertificateManagerInitEvent::className);
00060                 }
00061 
00062                 const std::string
00063                 TLSStreamComponent::getName() const
00064                 {
00065                         return "TLSStreamComponent";
00066                 }
00067         }
00068 }