summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/TLS')
-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
8 files changed, 117 insertions, 61 deletions
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"])