diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-04-25 21:21:23 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-04-26 08:37:22 +0200 |
commit | f6e49f8f206a7b2f0691824be06a120174ae83d9 (patch) | |
tree | 227bbed0d4495c95471ec28e11e2335ffd376df6 | |
parent | ebd7dbb6e758ccf8f00cc6f631e78134d8b9f7bc (diff) |
xmlsecurity mscrypto: create SEInitializer instances with a constructor
Allows getting rid of the xsec_mscrypt / xsec_nss factory constructs.
Change-Id: Idcc3351f7cc3b37a65e6f78018f062439e48bc3d
Reviewed-on: https://gerrit.libreoffice.org/53463
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r-- | xmlsecurity/Library_xsec_xmlsec.mk | 2 | ||||
-rw-r--r-- | xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx | 50 | ||||
-rw-r--r-- | xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.hxx | 10 | ||||
-rw-r--r-- | xmlsecurity/source/xmlsec/mscrypt/xsec_mscrypt.cxx | 61 | ||||
-rw-r--r-- | xmlsecurity/source/xmlsec/nss/nssinitializer.cxx | 33 | ||||
-rw-r--r-- | xmlsecurity/source/xmlsec/nss/nssinitializer.hxx | 10 | ||||
-rw-r--r-- | xmlsecurity/source/xmlsec/nss/xsec_nss.cxx | 66 | ||||
-rw-r--r-- | xmlsecurity/source/xmlsec/xsec_xmlsec.cxx | 14 | ||||
-rw-r--r-- | xmlsecurity/source/xmlsec/xsec_xmlsec.hxx | 37 | ||||
-rw-r--r-- | xmlsecurity/util/xsec_xmlsec.windows.component | 6 |
10 files changed, 38 insertions, 251 deletions
diff --git a/xmlsecurity/Library_xsec_xmlsec.mk b/xmlsecurity/Library_xsec_xmlsec.mk index e312834ed4e8..846b89800a5a 100644 --- a/xmlsecurity/Library_xsec_xmlsec.mk +++ b/xmlsecurity/Library_xsec_xmlsec.mk @@ -73,7 +73,6 @@ $(eval $(call gb_Library_add_exception_objects,xsec_xmlsec,\ xmlsecurity/source/xmlsec/nss/ciphercontext \ xmlsecurity/source/xmlsec/nss/digestcontext \ xmlsecurity/source/xmlsec/nss/nssinitializer \ - xmlsecurity/source/xmlsec/nss/xsec_nss \ )) ifeq ($(ENABLE_GPGMEPP),TRUE) @@ -113,7 +112,6 @@ $(eval $(call gb_Library_add_exception_objects,xsec_xmlsec,\ xmlsecurity/source/xmlsec/mscrypt/x509certificate_mscryptimpl \ xmlsecurity/source/xmlsec/mscrypt/xmlsecuritycontext_mscryptimpl \ xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl \ - xmlsecurity/source/xmlsec/mscrypt/xsec_mscrypt \ )) else diff --git a/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx index 41af74678a57..b741f5f3353f 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.cxx @@ -30,12 +30,12 @@ #include <cppuhelper/supportsservice.hxx> #include <o3tl/char16_t2wchar_t.hxx> -namespace cssu = com::sun::star::uno; +using namespace com::sun::star; namespace cssl = com::sun::star::lang; namespace cssxc = com::sun::star::xml::crypto; SEInitializer_MSCryptImpl::SEInitializer_MSCryptImpl( - const cssu::Reference< cssu::XComponentContext > &rxContext) + const uno::Reference< uno::XComponentContext > &rxContext) :mxContext( rxContext ) { } @@ -45,7 +45,7 @@ SEInitializer_MSCryptImpl::~SEInitializer_MSCryptImpl() } /* XSEInitializer */ -cssu::Reference< cssxc::XXMLSecurityContext > SAL_CALL +uno::Reference< cssxc::XXMLSecurityContext > SAL_CALL SEInitializer_MSCryptImpl::createSecurityContext( const OUString& sCertDB ) { @@ -74,10 +74,10 @@ cssu::Reference< cssxc::XXMLSecurityContext > SAL_CALL try { /* Build Security Environment */ - cssu::Reference< cssxc::XSecurityEnvironment > xSecEnv = cssxc::SecurityEnvironment::create( mxContext ); + uno::Reference< cssxc::XSecurityEnvironment > xSecEnv = cssxc::SecurityEnvironment::create( mxContext ); /* Setup key slot and certDb */ - cssu::Reference< cssl::XUnoTunnel > xSecEnvTunnel( xSecEnv, cssu::UNO_QUERY_THROW ); + uno::Reference< cssl::XUnoTunnel > xSecEnvTunnel( xSecEnv, uno::UNO_QUERY_THROW ); SecurityEnvironment_MSCryptImpl* pSecEnv = reinterpret_cast<SecurityEnvironment_MSCryptImpl*>(xSecEnvTunnel->getSomething( SecurityEnvironment_MSCryptImpl::getUnoTunnelId() )); if( pSecEnv == nullptr ) { @@ -101,12 +101,12 @@ cssu::Reference< cssxc::XXMLSecurityContext > SAL_CALL } /* Build XML Security Context */ - cssu::Reference< cssxc::XXMLSecurityContext > xSecCtx = cssxc::XMLSecurityContext::create( mxContext ); + uno::Reference< cssxc::XXMLSecurityContext > xSecCtx = cssxc::XMLSecurityContext::create( mxContext ); xSecCtx->setDefaultSecurityEnvironmentIndex(xSecCtx->addSecurityEnvironment( xSecEnv )) ; return xSecCtx; } - catch( cssu::Exception& ) + catch( uno::Exception& ) { if( n_hStoreHandle != nullptr ) { @@ -118,15 +118,15 @@ cssu::Reference< cssxc::XXMLSecurityContext > SAL_CALL } } -void SAL_CALL SEInitializer_MSCryptImpl::freeSecurityContext( const cssu::Reference< cssxc::XXMLSecurityContext >&) +void SAL_CALL SEInitializer_MSCryptImpl::freeSecurityContext( const uno::Reference< cssxc::XXMLSecurityContext >&) { /* - cssu::Reference< cssxc::XSecurityEnvironment > xSecEnv + uno::Reference< cssxc::XSecurityEnvironment > xSecEnv = securityContext->getSecurityEnvironment(); if( xSecEnv.is() ) { - cssu::Reference< cssl::XUnoTunnel > xEnvTunnel( xSecEnv , cssu::UNO_QUERY ) ; + uno::Reference< cssl::XUnoTunnel > xEnvTunnel( xSecEnv , uno::UNO_QUERY ) ; if( xEnvTunnel.is() ) { SecurityEnvironment_MSCryptImpl* pSecEnv = ( SecurityEnvironment_MSCryptImpl* )xEnvTunnel->getSomething( SecurityEnvironment_MSCryptImpl::getUnoTunnelId() ) ; @@ -147,26 +147,10 @@ void SAL_CALL SEInitializer_MSCryptImpl::freeSecurityContext( const cssu::Refere xmlSecMSCryptoAppShutdown() ; } -OUString SEInitializer_MSCryptImpl_getImplementationName() -{ - return OUString( "com.sun.star.xml.security.bridge.xmlsec.SEInitializer_MSCryptImpl" ); -} - -cssu::Sequence< OUString > SEInitializer_MSCryptImpl_getSupportedServiceNames() -{ - cssu::Sequence<OUString> aRet { "com.sun.star.xml.crypto.SEInitializer" }; - return aRet; -} - -cssu::Reference< cssu::XInterface > SEInitializer_MSCryptImpl_createInstance( const cssu::Reference< cssl::XMultiServiceFactory > & rSMgr) -{ - return static_cast<cppu::OWeakObject*>(new SEInitializer_MSCryptImpl( comphelper::getComponentContext(rSMgr) )); -} - /* XServiceInfo */ OUString SAL_CALL SEInitializer_MSCryptImpl::getImplementationName() { - return SEInitializer_MSCryptImpl_getImplementationName(); + return OUString("com.sun.star.xml.crypto.SEInitializer"); } sal_Bool SAL_CALL SEInitializer_MSCryptImpl::supportsService( const OUString& rServiceName ) @@ -174,9 +158,17 @@ sal_Bool SAL_CALL SEInitializer_MSCryptImpl::supportsService( const OUString& rS return cppu::supportsService( this, rServiceName ); } -cssu::Sequence< OUString > SAL_CALL SEInitializer_MSCryptImpl::getSupportedServiceNames() +uno::Sequence< OUString > SAL_CALL SEInitializer_MSCryptImpl::getSupportedServiceNames() +{ + uno::Sequence<OUString> aRet { "com.sun.star.xml.crypto.SEInitializer" }; + return aRet; +} + +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_MSCryptImpl_getSupportedServiceNames(); + return cppu::acquire(new SEInitializer_MSCryptImpl(pCtx)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.hxx b/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.hxx index dc80446404ee..145124a97550 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.hxx +++ b/xmlsecurity/source/xmlsec/mscrypt/seinitializer_mscryptimpl.hxx @@ -69,16 +69,6 @@ public: virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; }; -/// @throws css::uno::RuntimeException -OUString SEInitializer_MSCryptImpl_getImplementationName(); - -/// @throws css::uno::RuntimeException -css::uno::Sequence< OUString > SEInitializer_MSCryptImpl_getSupportedServiceNames( ); - -/// @throws css::uno::Exception -css::uno::Reference< css::uno::XInterface > -SEInitializer_MSCryptImpl_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory > & rSMgr); - #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmlsecurity/source/xmlsec/mscrypt/xsec_mscrypt.cxx b/xmlsecurity/source/xmlsec/mscrypt/xsec_mscrypt.cxx deleted file mode 100644 index 647c62b608a3..000000000000 --- a/xmlsecurity/source/xmlsec/mscrypt/xsec_mscrypt.cxx +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include <sal/config.h> - -#include <osl/thread.h> -#include <cppuhelper/factory.hxx> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> - -#include "seinitializer_mscryptimpl.hxx" - -using namespace ::cppu; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::registry; - -extern "C" -{ - -void* mscrypt_component_getFactory( const sal_Char* pImplName , void* pServiceManager , void* /*pRegistryKey*/ ) -{ - void* pRet = nullptr; - Reference< XSingleServiceFactory > xFactory ; - - if( pImplName != nullptr && pServiceManager != nullptr ) { - if( SEInitializer_MSCryptImpl_getImplementationName().equalsAscii( pImplName ) ) { - xFactory.set( createSingleFactory( - static_cast< XMultiServiceFactory * >( pServiceManager ), - OUString::createFromAscii( pImplName ), - SEInitializer_MSCryptImpl_createInstance, SEInitializer_MSCryptImpl_getSupportedServiceNames() ) ); - } - } - - if( xFactory.is() ) { - xFactory->acquire() ; - pRet = xFactory.get() ; - } - - return pRet ; -} - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmlsecurity/source/xmlsec/nss/nssinitializer.cxx b/xmlsecurity/source/xmlsec/nss/nssinitializer.cxx index 15b85566e201..2a9aaab057bb 100644 --- a/xmlsecurity/source/xmlsec/nss/nssinitializer.cxx +++ b/xmlsecurity/source/xmlsec/nss/nssinitializer.cxx @@ -59,8 +59,6 @@ namespace cssl = css::lang; using namespace com::sun::star; -#define IMPLEMENTATION_NAME "com.sun.star.xml.security.bridge.xmlsec.NSSInitializer_NssImpl" - #define ROOT_CERTS "Root Certs for OpenOffice.org" extern "C" void nsscrypto_finalize(); @@ -463,27 +461,10 @@ css::uno::Reference< css::xml::crypto::XCipherContext > SAL_CALL ONSSInitializer return xResult; } -OUString ONSSInitializer_getImplementationName () -{ - - return OUString ( IMPLEMENTATION_NAME ); -} - -cssu::Sequence< OUString > ONSSInitializer_getSupportedServiceNames( ) -{ - cssu::Sequence<OUString> aRet { NSS_SERVICE_NAME }; - return aRet; -} - -cssu::Reference< cssu::XInterface > ONSSInitializer_createInstance( const cssu::Reference< cssl::XMultiServiceFactory > & rSMgr) -{ - return static_cast<cppu::OWeakObject*>(new ONSSInitializer( comphelper::getComponentContext(rSMgr) )); -} - /* XServiceInfo */ OUString SAL_CALL ONSSInitializer::getImplementationName() { - return ONSSInitializer_getImplementationName(); + return OUString("com.sun.star.xml.crypto.NSSInitializer"); } sal_Bool SAL_CALL ONSSInitializer::supportsService( const OUString& rServiceName ) @@ -493,7 +474,17 @@ sal_Bool SAL_CALL ONSSInitializer::supportsService( const OUString& rServiceName cssu::Sequence< OUString > SAL_CALL ONSSInitializer::getSupportedServiceNames( ) { - return ONSSInitializer_getSupportedServiceNames(); + cssu::Sequence<OUString> aRet { NSS_SERVICE_NAME }; + return aRet; } +#ifndef XMLSEC_CRYPTO_NSS +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::acquire(new ONSSInitializer(pCtx)); +} +#endif + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmlsecurity/source/xmlsec/nss/nssinitializer.hxx b/xmlsecurity/source/xmlsec/nss/nssinitializer.hxx index c018f5af4bb6..28a4ffd2af1d 100644 --- a/xmlsecurity/source/xmlsec/nss/nssinitializer.hxx +++ b/xmlsecurity/source/xmlsec/nss/nssinitializer.hxx @@ -60,16 +60,6 @@ public: virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; }; -/// @throws css::uno::RuntimeException -OUString ONSSInitializer_getImplementationName(); - -/// @throws css::uno::RuntimeException -css::uno::Sequence< OUString > ONSSInitializer_getSupportedServiceNames(); - -/// @throws css::uno::Exception -css::uno::Reference< css::uno::XInterface > -ONSSInitializer_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory > & rSMgr ); - #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 deleted file mode 100644 index 5fa73e2abd3e..000000000000 --- a/xmlsecurity/source/xmlsec/nss/xsec_nss.cxx +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include <sal/config.h> - -#include <osl/thread.h> -#include <cppuhelper/factory.hxx> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> - -#include "seinitializer_nssimpl.hxx" -#include <xsec_xmlsec.hxx> - -using namespace ::cppu; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::registry; - -extern "C" -{ - -void* nss_component_getFactory( const sal_Char* pImplName , void* pServiceManager , void* /*pRegistryKey*/ ) -{ - void* pRet = nullptr; - Reference< XSingleServiceFactory > xFactory ; - - if( pImplName != nullptr && pServiceManager != nullptr ) - { -#ifndef XMLSEC_CRYPTO_NSS - if( ONSSInitializer_getImplementationName().equalsAscii( pImplName ) ) - { - xFactory.set( createSingleFactory( - static_cast< XMultiServiceFactory * >( pServiceManager ), - OUString::createFromAscii( pImplName ), - ONSSInitializer_createInstance, ONSSInitializer_getSupportedServiceNames() ) ); - } -#endif - } - - if( xFactory.is() ) { - xFactory->acquire() ; - pRet = xFactory.get() ; - } - - return pRet ; -} - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmlsecurity/source/xmlsec/xsec_xmlsec.cxx b/xmlsecurity/source/xmlsec/xsec_xmlsec.cxx index fe36fc3a5bd7..038af38f6726 100644 --- a/xmlsecurity/source/xmlsec/xsec_xmlsec.cxx +++ b/xmlsecurity/source/xmlsec/xsec_xmlsec.cxx @@ -22,8 +22,6 @@ #include <cppuhelper/factory.hxx> -#include "xsec_xmlsec.hxx" - #include <config_gpgme.h> #if HAVE_FEATURE_GPGME # include <gpg/xmlsignature_gpgimpl.hxx> @@ -37,7 +35,7 @@ using namespace ::com::sun::star::lang; extern "C" { -SAL_DLLPUBLIC_EXPORT void* xsec_xmlsec_component_getFactory( const sal_Char* pImplName , void* pServiceManager , void* pRegistryKey ) +SAL_DLLPUBLIC_EXPORT void* xsec_xmlsec_component_getFactory( const sal_Char* pImplName , void* pServiceManager , void* /*pRegistryKey*/ ) { void* pRet = nullptr; Reference< XInterface > xFactory ; @@ -58,16 +56,6 @@ SAL_DLLPUBLIC_EXPORT void* xsec_xmlsec_component_getFactory( const sal_Char* pIm if( xFactory.is() ) { xFactory->acquire() ; pRet = xFactory.get() ; - } else { - pRet = nss_component_getFactory( pImplName, pServiceManager, pRegistryKey ) ; - if( pRet != nullptr ) - return pRet ; - -#if defined( XMLSEC_CRYPTO_MSCRYPTO ) - pRet = mscrypt_component_getFactory( pImplName, pServiceManager, pRegistryKey ) ; - if( pRet != nullptr ) - return pRet ; -#endif } return pRet ; diff --git a/xmlsecurity/source/xmlsec/xsec_xmlsec.hxx b/xmlsecurity/source/xmlsec/xsec_xmlsec.hxx deleted file mode 100644 index 5ecdf4e9de68..000000000000 --- a/xmlsecurity/source/xmlsec/xsec_xmlsec.hxx +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_XMLSECURITY_SOURCE_XMLSEC_XSEC_XMLSEC_HXX -#define INCLUDED_XMLSECURITY_SOURCE_XMLSEC_XSEC_XMLSEC_HXX - -#include <sal/config.h> - -extern "C" { - -void* nss_component_getFactory( const sal_Char*, void*, void* ); - -#if defined( XMLSEC_CRYPTO_MSCRYPTO ) -void* mscrypt_component_getFactory( const sal_Char*, void*, void* ); -#endif - -} - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmlsecurity/util/xsec_xmlsec.windows.component b/xmlsecurity/util/xsec_xmlsec.windows.component index a9f94f8b3960..6ea539f9ee0f 100644 --- a/xmlsecurity/util/xsec_xmlsec.windows.component +++ b/xmlsecurity/util/xsec_xmlsec.windows.component @@ -19,10 +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.NSSInitializer_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.security.bridge.xmlsec.SEInitializer_MSCryptImpl"> + <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"> |