summaryrefslogtreecommitdiff
path: root/cpp/src/IceSSL/PluginI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/IceSSL/PluginI.cpp')
-rwxr-xr-x[-rw-r--r--]cpp/src/IceSSL/PluginI.cpp127
1 files changed, 118 insertions, 9 deletions
diff --git a/cpp/src/IceSSL/PluginI.cpp b/cpp/src/IceSSL/PluginI.cpp
index 83651a04211..1dcb535cce8 100644..100755
--- a/cpp/src/IceSSL/PluginI.cpp
+++ b/cpp/src/IceSSL/PluginI.cpp
@@ -15,6 +15,7 @@
#include <Ice/ProtocolPluginFacade.h>
#include <Ice/ProtocolInstance.h>
#include <Ice/LocalException.h>
+#include <Ice/RegisterPlugins.h>
using namespace std;
using namespace Ice;
@@ -23,21 +24,16 @@ using namespace IceSSL;
//
// Plug-in factory function.
//
-extern "C"
-{
-
-ICE_SSL_API Ice::Plugin*
+extern "C" ICESSL_API Ice::Plugin*
createIceSSL(const CommunicatorPtr& communicator, const string& /*name*/, const StringSeq& /*args*/)
{
return new PluginI(communicator);
}
-}
-
namespace Ice
{
-ICE_SSL_API void
+ICESSL_API void
registerIceSSL(bool loadOnInitialize)
{
Ice::registerPluginFactory("IceSSL", createIceSSL, loadOnInitialize);
@@ -45,6 +41,38 @@ registerIceSSL(bool loadOnInitialize)
}
+#ifndef ICE_CPP11_MAPPING
+IceSSL::CertificateVerifier::~CertificateVerifier()
+{
+ // Out of line to avoid weak vtable
+}
+
+IceSSL::PasswordPrompt::~PasswordPrompt()
+{
+ // Out of line to avoid weak vtable
+}
+#endif
+
+
+IceSSL::NativeConnectionInfo::~NativeConnectionInfo()
+{
+ // Out of line to avoid weak vtable
+}
+
+IceSSL::Plugin::~Plugin()
+{
+ // Out of line to avoid weak vtable
+}
+
+//
+// Objective-C function to allow Objective-C programs to register plugin.
+//
+extern "C" ICESSL_API void
+ICEregisterIceSSL(bool loadOnInitialize)
+{
+ Ice::registerIceSSL(loadOnInitialize);
+}
+
//
// Plugin implementation.
//
@@ -54,6 +82,8 @@ IceSSL::PluginI::PluginI(const Ice::CommunicatorPtr& com)
_engine = new SecureTransportEngine(com);
#elif defined(ICE_USE_SCHANNEL)
_engine = new SChannelEngine(com);
+#elif defined(ICE_OS_UWP)
+ _engine = new UWPEngine(com);
#else
_engine = new OpenSSLEngine(com);
#endif
@@ -63,8 +93,31 @@ IceSSL::PluginI::PluginI(const Ice::CommunicatorPtr& com)
// than in initialize, because the communicator may need to
// interpret proxies before the plug-in is fully initialized.
//
- IceInternal::EndpointFactoryPtr sslFactory = new EndpointFactoryI(new Instance(_engine, EndpointType, "ssl"));
- IceInternal::getProtocolPluginFacade(com)->addEndpointFactory(sslFactory);
+ IceInternal::ProtocolPluginFacadePtr pluginFacade = IceInternal::getProtocolPluginFacade(com);
+
+ // SSL based on TCP
+ IceInternal::EndpointFactoryPtr tcp = pluginFacade->getEndpointFactory(TCPEndpointType);
+ if(tcp)
+ {
+ InstancePtr instance = new Instance(_engine, SSLEndpointType, "ssl");
+ pluginFacade->addEndpointFactory(new EndpointFactoryI(instance, tcp->clone(instance, 0)));
+ }
+
+ // SSL based on Bluetooth
+ IceInternal::EndpointFactoryPtr bluetooth = pluginFacade->getEndpointFactory(BTEndpointType);
+ if(bluetooth)
+ {
+ InstancePtr instance = new Instance(_engine, BTSEndpointType, "bts");
+ pluginFacade->addEndpointFactory(new EndpointFactoryI(instance, bluetooth->clone(instance, 0)));
+ }
+
+ // SSL based on iAP
+ IceInternal::EndpointFactoryPtr iap = pluginFacade->getEndpointFactory(iAPEndpointType);
+ if(iap)
+ {
+ InstancePtr instance = new Instance(_engine, iAPSEndpointType, "iaps");
+ pluginFacade->addEndpointFactory(new EndpointFactoryI(instance, iap->clone(instance, 0)));
+ }
}
void
@@ -80,17 +133,73 @@ IceSSL::PluginI::destroy()
_engine = 0;
}
+string
+IceSSL::PluginI::getEngineName() const
+{
+#if defined(ICE_USE_SECURE_TRANSPORT)
+ return "SecureTransportEngine";
+#elif defined(ICE_USE_SCHANNEL)
+ return "SChannelEngine";
+#elif defined(ICE_OS_UWP)
+ return "UWPEngine";
+#else
+ ostringstream os;
+ os << "OpenSSLEngine@" << SSLeay_version(SSLEAY_VERSION);
+ return os.str();
+#endif
+}
+
+Ice::Long
+IceSSL::PluginI::getEngineVersion() const
+{
+#if defined(ICE_USE_OPENSSL)
+ return SSLeay();
+#else
+ return 0;
+#endif
+}
+
+#ifdef ICE_CPP11_MAPPING
+void
+IceSSL::PluginI::setCertificateVerifier(std::function<bool(const std::shared_ptr<NativeConnectionInfo>&)> verifier)
+{
+ if(verifier)
+ {
+ _engine->setCertificateVerifier(make_shared<CertificateVerifier>(std::move(verifier)));
+ }
+ else
+ {
+ _engine->setCertificateVerifier(nullptr);
+ }
+}
+#else
void
IceSSL::PluginI::setCertificateVerifier(const CertificateVerifierPtr& verifier)
{
_engine->setCertificateVerifier(verifier);
}
+#endif
+#ifdef ICE_CPP11_MAPPING
+void
+IceSSL::PluginI::setPasswordPrompt(std::function<std::string()> prompt)
+{
+ if(prompt)
+ {
+ _engine->setPasswordPrompt(make_shared<PasswordPrompt>(std::move(prompt)));
+ }
+ else
+ {
+ _engine->setPasswordPrompt(nullptr);
+ }
+}
+#else
void
IceSSL::PluginI::setPasswordPrompt(const PasswordPromptPtr& prompt)
{
_engine->setPasswordPrompt(prompt);
}
+#endif
#ifdef ICE_USE_OPENSSL
void