[Libreoffice-commits] core.git: xmlsecurity/source xmlsecurity/util

Miklos Vajna vmiklos at collabora.co.uk
Fri Apr 13 06:39:56 UTC 2018


 xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.cxx |   54 ++++++++++------
 xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.hxx |   10 --
 xmlsecurity/source/xmlsec/nss/xsec_nss.cxx              |   10 --
 xmlsecurity/util/xsec_xmlsec.component                  |    6 +
 4 files changed, 43 insertions(+), 37 deletions(-)

New commits:
commit 08ac81ccb5ef2397c0073f186fcf5bb2cc528b83
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Apr 12 22:01:06 2018 +0200

    xmlsecurity nss: create SEInitializer instances with a constructor
    
    And split NSSInitializer and SEInitializer into two implementations,
    they are not the same on Windows, so it simplifies things if they're
    also split on other platforms.
    
    Change-Id: Ifc0ea7e35e804232ee492b7eea9c25662c9b499e
    Reviewed-on: https://gerrit.libreoffice.org/52801
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.cxx
index 19e92fc2113b..58fa45acf4b6 100644
--- a/xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.cxx
+++ b/xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.cxx
@@ -108,37 +108,57 @@ void SAL_CALL SEInitializer_NssImpl::freeSecurityContext( const uno::Reference<
     //NSS_Shutdown();
 }
 
-OUString SEInitializer_NssImpl_getImplementationName ()
+/* XServiceInfo */
+OUString SAL_CALL SEInitializer_NssImpl::getImplementationName(  )
+{
+    return OUString("com.sun.star.xml.crypto.SEInitializer");
+}
+sal_Bool SAL_CALL SEInitializer_NssImpl::supportsService( const OUString& rServiceName )
+{
+    return cppu::supportsService( this, rServiceName );
+}
+uno::Sequence< OUString > SAL_CALL SEInitializer_NssImpl::getSupportedServiceNames(  )
 {
-    return OUString ("com.sun.star.xml.security.bridge.xmlsec.SEInitializer_NssImpl" );
+    uno::Sequence<OUString> seqServiceNames{ "com.sun.star.xml.crypto.SEInitializer" };
+    return seqServiceNames;
 }
 
-uno::Sequence< OUString > SEInitializer_NssImpl_getSupportedServiceNames(  )
+class NSSInitializer_NssImpl : public SEInitializer_NssImpl
+{
+public:
+    explicit NSSInitializer_NssImpl(const uno::Reference<uno::XComponentContext>& xContext);
+    OUString SAL_CALL getImplementationName() override;
+    uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
+};
+
+NSSInitializer_NssImpl::NSSInitializer_NssImpl(const uno::Reference<uno::XComponentContext>& xContext)
+    : SEInitializer_NssImpl(xContext)
 {
-    uno::Sequence < OUString > aRet(2);
-    OUString* pArray = aRet.getArray();
-    pArray[0] =  "com.sun.star.xml.crypto.SEInitializer";
-    pArray[1] =  NSS_SERVICE_NAME;
-    return aRet;
 }
 
-uno::Reference< uno::XInterface > SEInitializer_NssImpl_createInstance( const uno::Reference< lang::XMultiServiceFactory > & rxMSF)
+OUString NSSInitializer_NssImpl::getImplementationName()
 {
-    return static_cast<cppu::OWeakObject*>(new SEInitializer_NssImpl(comphelper::getComponentContext(rxMSF)));
+    return OUString("com.sun.star.xml.crypto.NSSInitializer");
 }
 
-/* XServiceInfo */
-OUString SAL_CALL SEInitializer_NssImpl::getImplementationName(  )
+uno::Sequence<OUString> SAL_CALL NSSInitializer_NssImpl::getSupportedServiceNames()
 {
-    return SEInitializer_NssImpl_getImplementationName();
+    uno::Sequence<OUString> seqServiceNames{ "com.sun.star.xml.crypto.NSSInitializer" };
+    return seqServiceNames;
 }
-sal_Bool SAL_CALL SEInitializer_NssImpl::supportsService( const OUString& rServiceName )
+
+extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
+com_sun_star_xml_crypto_NSSInitializer_get_implementation(
+    uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
 {
-    return cppu::supportsService( this, rServiceName );
+    return cppu::acquire(new NSSInitializer_NssImpl(pCtx));
 }
-uno::Sequence< OUString > SAL_CALL SEInitializer_NssImpl::getSupportedServiceNames(  )
+
+extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
+com_sun_star_xml_crypto_SEInitializer_get_implementation(
+    uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/)
 {
-    return SEInitializer_NssImpl_getSupportedServiceNames();
+    return cppu::acquire(new SEInitializer_NssImpl(pCtx));
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.hxx b/xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.hxx
index 03485e199408..7eda9a259677 100644
--- a/xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.hxx
+++ b/xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.hxx
@@ -54,16 +54,6 @@ public:
     virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(  ) override;
 };
 
-/// @throws css::uno::RuntimeException
-OUString SEInitializer_NssImpl_getImplementationName();
-
-/// @throws css::uno::RuntimeException
-css::uno::Sequence< OUString > SEInitializer_NssImpl_getSupportedServiceNames(  );
-
-/// @throws css::uno::Exception
-css::uno::Reference< css::uno::XInterface >
-SEInitializer_NssImpl_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory > & rxMSF);
-
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/source/xmlsec/nss/xsec_nss.cxx b/xmlsecurity/source/xmlsec/nss/xsec_nss.cxx
index db23623aada9..5fa73e2abd3e 100644
--- a/xmlsecurity/source/xmlsec/nss/xsec_nss.cxx
+++ b/xmlsecurity/source/xmlsec/nss/xsec_nss.cxx
@@ -42,15 +42,7 @@ void* nss_component_getFactory( const sal_Char* pImplName , void* pServiceManage
 
     if( pImplName != nullptr && pServiceManager != nullptr )
     {
-#ifdef XMLSEC_CRYPTO_NSS
-        if( SEInitializer_NssImpl_getImplementationName().equalsAscii( pImplName ) )
-        {
-            xFactory.set( createSingleFactory(
-                static_cast< XMultiServiceFactory * >( pServiceManager ),
-                OUString::createFromAscii( pImplName ),
-                SEInitializer_NssImpl_createInstance, SEInitializer_NssImpl_getSupportedServiceNames() ) );
-        }
-#else
+#ifndef XMLSEC_CRYPTO_NSS
         if( ONSSInitializer_getImplementationName().equalsAscii( pImplName ) )
         {
             xFactory.set( createSingleFactory(
diff --git a/xmlsecurity/util/xsec_xmlsec.component b/xmlsecurity/util/xsec_xmlsec.component
index 00cedec72aac..6ea539f9ee0f 100644
--- a/xmlsecurity/util/xsec_xmlsec.component
+++ b/xmlsecurity/util/xsec_xmlsec.component
@@ -19,8 +19,12 @@
 
 <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
     prefix="xsec_xmlsec" xmlns="http://openoffice.org/2010/uno-components">
-  <implementation name="com.sun.star.xml.security.bridge.xmlsec.SEInitializer_NssImpl">
+  <implementation name="com.sun.star.xml.crypto.NSSInitializer"
+    constructor="com_sun_star_xml_crypto_NSSInitializer_get_implementation">
     <service name="com.sun.star.xml.crypto.NSSInitializer"/>
+  </implementation>
+  <implementation name="com.sun.star.xml.crypto.SEInitializer"
+    constructor="com_sun_star_xml_crypto_SEInitializer_get_implementation">
     <service name="com.sun.star.xml.crypto.SEInitializer"/>
   </implementation>
   <implementation name="com.sun.star.xml.security.SEInitializer_Gpg">


More information about the Libreoffice-commits mailing list