summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Client/CoreClient.cpp8
-rw-r--r--Swiften/Client/CoreClient.h3
-rw-r--r--Swiften/TLS/CertificateFactory.cpp14
-rw-r--r--Swiften/TLS/CertificateFactory.h18
-rw-r--r--Swiften/TLS/OpenSSL/OpenSSLCertificateFactory.h19
-rw-r--r--Swiften/TLS/PlatformTLSContextFactory.cpp37
-rw-r--r--Swiften/TLS/PlatformTLSContextFactory.h23
-rw-r--r--Swiften/TLS/PlatformTLSFactories.cpp39
-rw-r--r--Swiften/TLS/PlatformTLSFactories.h25
-rw-r--r--Swiften/TLS/SConscript3
10 files changed, 123 insertions, 66 deletions
diff --git a/Swiften/Client/CoreClient.cpp b/Swiften/Client/CoreClient.cpp
index 7bde017..2c3ab35 100644
--- a/Swiften/Client/CoreClient.cpp
+++ b/Swiften/Client/CoreClient.cpp
@@ -11,7 +11,7 @@
#include "Swiften/Network/MainBoostIOServiceThread.h"
#include "Swiften/Network/BoostIOServiceThread.h"
#include "Swiften/Client/ClientSession.h"
-#include "Swiften/TLS/PlatformTLSContextFactory.h"
+#include "Swiften/TLS/PlatformTLSFactories.h"
#include "Swiften/TLS/CertificateVerificationError.h"
#include "Swiften/Network/Connector.h"
#include "Swiften/Network/BoostConnectionFactory.h"
@@ -34,14 +34,14 @@ CoreClient::CoreClient(EventLoop* eventLoop, const JID& jid, const String& passw
iqRouter_ = new IQRouter(stanzaChannel_);
connectionFactory_ = new BoostConnectionFactory(&MainBoostIOServiceThread::getInstance().getIOService(), eventLoop);
timerFactory_ = new BoostTimerFactory(&MainBoostIOServiceThread::getInstance().getIOService(), eventLoop);
- tlsContextFactory_ = new PlatformTLSContextFactory();
+ tlsFactories = new PlatformTLSFactories();
}
CoreClient::~CoreClient() {
if (session_ || connection_) {
std::cerr << "Warning: Client not disconnected properly" << std::endl;
}
- delete tlsContextFactory_;
+ delete tlsFactories;
delete timerFactory_;
delete connectionFactory_;
delete iqRouter_;
@@ -82,7 +82,7 @@ void CoreClient::handleConnectorFinished(boost::shared_ptr<Connection> connectio
connection_ = connection;
assert(!sessionStream_);
- sessionStream_ = boost::shared_ptr<BasicSessionStream>(new BasicSessionStream(ClientStreamType, connection_, &payloadParserFactories_, &payloadSerializers_, tlsContextFactory_, timerFactory_));
+ sessionStream_ = boost::shared_ptr<BasicSessionStream>(new BasicSessionStream(ClientStreamType, connection_, &payloadParserFactories_, &payloadSerializers_, tlsFactories->getTLSContextFactory(), timerFactory_));
if (!certificate_.isEmpty()) {
sessionStream_->setTLSCertificate(PKCS12Certificate(certificate_, password_));
}
diff --git a/Swiften/Client/CoreClient.h b/Swiften/Client/CoreClient.h
index 780201d..211f84f 100644
--- a/Swiften/Client/CoreClient.h
+++ b/Swiften/Client/CoreClient.h
@@ -32,6 +32,7 @@ namespace Swift {
class ClientSession;
class BasicSessionStream;
class EventLoop;
+ class PlatformTLSFactories;
class CertificateTrustChecker;
/**
@@ -201,7 +202,7 @@ namespace Swift {
Connector::ref connector_;
ConnectionFactory* connectionFactory_;
TimerFactory* timerFactory_;
- TLSContextFactory* tlsContextFactory_;
+ PlatformTLSFactories* tlsFactories;
FullPayloadParserFactoryCollection payloadParserFactories_;
FullPayloadSerializerCollection payloadSerializers_;
boost::shared_ptr<Connection> connection_;
diff --git a/Swiften/TLS/CertificateFactory.cpp b/Swiften/TLS/CertificateFactory.cpp
new file mode 100644
index 0000000..b2edaf4
--- /dev/null
+++ b/Swiften/TLS/CertificateFactory.cpp
@@ -0,0 +1,14 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include "Swiften/TLS/CertificateFactory.h"
+
+namespace Swift {
+
+CertificateFactory::~CertificateFactory() {
+}
+
+}
diff --git a/Swiften/TLS/CertificateFactory.h b/Swiften/TLS/CertificateFactory.h
new file mode 100644
index 0000000..90eca58
--- /dev/null
+++ b/Swiften/TLS/CertificateFactory.h
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include "Swiften/TLS/Certificate.h"
+
+namespace Swift {
+ class CertificateFactory {
+ public:
+ virtual ~CertificateFactory();
+
+ virtual Certificate::ref createCertificateFromDER(const ByteArray& der) = 0;
+ };
+}
diff --git a/Swiften/TLS/OpenSSL/OpenSSLCertificateFactory.h b/Swiften/TLS/OpenSSL/OpenSSLCertificateFactory.h
new file mode 100644
index 0000000..cd4982e
--- /dev/null
+++ b/Swiften/TLS/OpenSSL/OpenSSLCertificateFactory.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include "Swiften/TLS/CertificateFactory.h"
+#include "Swiften/TLS/OpenSSL/OpenSSLCertificate.h"
+
+namespace Swift {
+ class OpenSSLCertificateFactory : public CertificateFactory {
+ public:
+ virtual Certificate::ref createCertificateFromDER(const ByteArray& der) {
+ return Certificate::ref(new OpenSSLCertificate(der));
+ }
+ };
+}
diff --git a/Swiften/TLS/PlatformTLSContextFactory.cpp b/Swiften/TLS/PlatformTLSContextFactory.cpp
deleted file mode 100644
index d9fc0fb..0000000
--- a/Swiften/TLS/PlatformTLSContextFactory.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2010 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#include "Swiften/TLS/PlatformTLSContextFactory.h"
-
-#include <cstring>
-#include <cassert>
-
-#ifdef HAVE_OPENSSL
-#include "Swiften/TLS/OpenSSL/OpenSSLContextFactory.h"
-#endif
-
-namespace Swift {
-
-PlatformTLSContextFactory::PlatformTLSContextFactory() : factory(NULL) {
-#ifdef HAVE_OPENSSL
- factory = new OpenSSLContextFactory();
-#endif
-}
-
-PlatformTLSContextFactory::~PlatformTLSContextFactory() {
- delete factory;
-}
-
-bool PlatformTLSContextFactory::canCreate() const {
- return factory;
-}
-
-TLSContext* PlatformTLSContextFactory::createTLSContext() {
- assert(canCreate());
- return factory->createTLSContext();
-}
-
-}
diff --git a/Swiften/TLS/PlatformTLSContextFactory.h b/Swiften/TLS/PlatformTLSContextFactory.h
deleted file mode 100644
index 4464e8b..0000000
--- a/Swiften/TLS/PlatformTLSContextFactory.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2010 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#pragma once
-
-#include "Swiften/TLS/TLSContextFactory.h"
-
-namespace Swift {
- class PlatformTLSContextFactory : public TLSContextFactory {
- public:
- PlatformTLSContextFactory();
- ~PlatformTLSContextFactory();
-
- bool canCreate() const;
- virtual TLSContext* createTLSContext();
-
- private:
- TLSContextFactory* factory;
- };
-}
diff --git a/Swiften/TLS/PlatformTLSFactories.cpp b/Swiften/TLS/PlatformTLSFactories.cpp
new file mode 100644
index 0000000..e642758
--- /dev/null
+++ b/Swiften/TLS/PlatformTLSFactories.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include "Swiften/TLS/PlatformTLSFactories.h"
+
+#include <cstring>
+#include <cassert>
+
+#ifdef HAVE_OPENSSL
+#include "Swiften/TLS/OpenSSL/OpenSSLContextFactory.h"
+#include "Swiften/TLS/OpenSSL/OpenSSLCertificateFactory.h"
+#endif
+
+namespace Swift {
+
+PlatformTLSFactories::PlatformTLSFactories() : contextFactory(NULL), certificateFactory(NULL) {
+#ifdef HAVE_OPENSSL
+ contextFactory = new OpenSSLContextFactory();
+ certificateFactory = new OpenSSLCertificateFactory();
+#endif
+}
+
+PlatformTLSFactories::~PlatformTLSFactories() {
+ delete contextFactory;
+ delete certificateFactory;
+}
+
+TLSContextFactory* PlatformTLSFactories::getTLSContextFactory() const {
+ return contextFactory;
+}
+
+CertificateFactory* PlatformTLSFactories::getCertificateFactory() const {
+ return certificateFactory;
+}
+
+}
diff --git a/Swiften/TLS/PlatformTLSFactories.h b/Swiften/TLS/PlatformTLSFactories.h
new file mode 100644
index 0000000..605db31
--- /dev/null
+++ b/Swiften/TLS/PlatformTLSFactories.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+namespace Swift {
+ class TLSContextFactory;
+ class CertificateFactory;
+
+ class PlatformTLSFactories {
+ public:
+ PlatformTLSFactories();
+ ~PlatformTLSFactories();
+
+ TLSContextFactory* getTLSContextFactory() const;
+ CertificateFactory* getCertificateFactory() const;
+
+ private:
+ TLSContextFactory* contextFactory;
+ CertificateFactory* certificateFactory;
+ };
+}
diff --git a/Swiften/TLS/SConscript b/Swiften/TLS/SConscript
index 7408e72..f83e383 100644
--- a/Swiften/TLS/SConscript
+++ b/Swiften/TLS/SConscript
@@ -2,6 +2,7 @@ Import("swiften_env")
objects = swiften_env.StaticObject([
"Certificate.cpp",
+ "CertificateFactory.cpp",
"CertificateTrustChecker.cpp",
"TLSContext.cpp",
"TLSContextFactory.cpp",
@@ -17,7 +18,7 @@ if myenv.get("HAVE_OPENSSL", 0) :
])
myenv.Append(CPPDEFINES = "HAVE_OPENSSL")
-objects += myenv.StaticObject(["PlatformTLSContextFactory.cpp"])
+objects += myenv.StaticObject(["PlatformTLSFactories.cpp"])