From a2e53070ca807e1974c462d9ae8f7098990c9356 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 21 Feb 2018 22:15:05 +0100 Subject: xmlsecurity mscrypt: create XMLSignature instances with a constructor Change-Id: Ie30885226d1ede4293adc888e587d6111343f5af Reviewed-on: https://gerrit.libreoffice.org/50144 Tested-by: Jenkins Reviewed-by: Miklos Vajna --- .../xmlsec/mscrypt/xmlsignature_mscryptimpl.cxx | 58 +++++++++------ .../xmlsec/mscrypt/xmlsignature_mscryptimpl.hxx | 83 ---------------------- xmlsecurity/source/xmlsec/mscrypt/xsec_mscrypt.cxx | 5 +- xmlsecurity/util/xsec_xmlsec.windows.component | 3 +- 4 files changed, 41 insertions(+), 108 deletions(-) delete mode 100644 xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.hxx (limited to 'xmlsecurity') diff --git a/xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.cxx index 3213f9e9e2e6..f7ade4e54161 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.cxx @@ -21,8 +21,8 @@ #include #include +#include -#include "xmlsignature_mscryptimpl.hxx" #include "securityenvironment_mscryptimpl.hxx" #include @@ -32,6 +32,7 @@ #include +using namespace ::com::sun::star; using namespace ::com::sun::star::uno ; using namespace ::com::sun::star::lang ; using ::com::sun::star::lang::XMultiServiceFactory ; @@ -45,7 +46,36 @@ using ::com::sun::star::xml::crypto::XXMLSignatureTemplate ; using ::com::sun::star::xml::crypto::XXMLSecurityContext ; using ::com::sun::star::xml::crypto::XUriBinding ; -XMLSignature_MSCryptImpl::XMLSignature_MSCryptImpl( const Reference< XMultiServiceFactory >& aFactory ) : m_xServiceManager( aFactory ) { +class XMLSignature_MSCryptImpl : public ::cppu::WeakImplHelper< + css::xml::crypto::XXMLSignature , + css::lang::XServiceInfo > +{ + public: + explicit XMLSignature_MSCryptImpl(); + virtual ~XMLSignature_MSCryptImpl() override; + + //Methods from XXMLSignature + virtual css::uno::Reference< css::xml::crypto::XXMLSignatureTemplate > SAL_CALL generate( + const css::uno::Reference< css::xml::crypto::XXMLSignatureTemplate >& aTemplate , + const css::uno::Reference< css::xml::crypto::XSecurityEnvironment >& aEnvironment + ) override; + + virtual css::uno::Reference< css::xml::crypto::XXMLSignatureTemplate > SAL_CALL validate( + const css::uno::Reference< css::xml::crypto::XXMLSignatureTemplate >& aTemplate , + const css::uno::Reference< css::xml::crypto::XXMLSecurityContext >& aContext + ) override; + + //Methods from XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + + virtual sal_Bool SAL_CALL supportsService( + const OUString& ServiceName + ) override; + + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; +} ; + +XMLSignature_MSCryptImpl::XMLSignature_MSCryptImpl() { } XMLSignature_MSCryptImpl::~XMLSignature_MSCryptImpl() { @@ -251,7 +281,7 @@ SAL_CALL XMLSignature_MSCryptImpl::validate( /* XServiceInfo */ OUString SAL_CALL XMLSignature_MSCryptImpl::getImplementationName() { - return impl_getImplementationName() ; + return OUString("com.sun.star.xml.crypto.XMLSignature"); } /* XServiceInfo */ @@ -267,27 +297,15 @@ sal_Bool SAL_CALL XMLSignature_MSCryptImpl::supportsService( const OUString& ser /* XServiceInfo */ Sequence< OUString > SAL_CALL XMLSignature_MSCryptImpl::getSupportedServiceNames() { - return impl_getSupportedServiceNames() ; -} - -//Helper for XServiceInfo -Sequence< OUString > XMLSignature_MSCryptImpl::impl_getSupportedServiceNames() { - ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ; Sequence seqServiceNames { "com.sun.star.xml.crypto.XMLSignature" }; return seqServiceNames ; } -OUString XMLSignature_MSCryptImpl::impl_getImplementationName() { - return OUString("com.sun.star.xml.security.bridge.xmlsec.XMLSignature_MSCryptImpl") ; -} - -//Helper for registry -Reference< XInterface > SAL_CALL XMLSignature_MSCryptImpl::impl_createInstance( const Reference< XMultiServiceFactory >& aServiceManager ) { - return Reference< XInterface >( *new XMLSignature_MSCryptImpl( aServiceManager ) ) ; -} - -Reference< XSingleServiceFactory > XMLSignature_MSCryptImpl::impl_createFactory( const Reference< XMultiServiceFactory >& aServiceManager ) { - return ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName() , impl_createInstance , impl_getSupportedServiceNames() ) ; +extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface* +com_sun_star_xml_crypto_XMLSignature_get_implementation(uno::XComponentContext* /*pCtx*/, + uno::Sequence const& /*rSeq*/) +{ + return cppu::acquire(new XMLSignature_MSCryptImpl); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.hxx b/xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.hxx deleted file mode 100644 index a5cb5c6398a7..000000000000 --- a/xmlsecurity/source/xmlsec/mscrypt/xmlsignature_mscryptimpl.hxx +++ /dev/null @@ -1,83 +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_MSCRYPT_XMLSIGNATURE_MSCRYPTIMPL_HXX -#define INCLUDED_XMLSECURITY_SOURCE_XMLSEC_MSCRYPT_XMLSIGNATURE_MSCRYPTIMPL_HXX - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -class XMLSignature_MSCryptImpl : public ::cppu::WeakImplHelper< - css::xml::crypto::XXMLSignature , - css::lang::XServiceInfo > -{ - private: - css::uno::Reference< css::lang::XMultiServiceFactory > m_xServiceManager ; - - public: - explicit XMLSignature_MSCryptImpl(const css::uno::Reference& rFactory); - virtual ~XMLSignature_MSCryptImpl() override; - - //Methods from XXMLSignature - virtual css::uno::Reference< css::xml::crypto::XXMLSignatureTemplate > SAL_CALL generate( - const css::uno::Reference< css::xml::crypto::XXMLSignatureTemplate >& aTemplate , - const css::uno::Reference< css::xml::crypto::XSecurityEnvironment >& aEnvironment - ) override; - - virtual css::uno::Reference< css::xml::crypto::XXMLSignatureTemplate > SAL_CALL validate( - const css::uno::Reference< css::xml::crypto::XXMLSignatureTemplate >& aTemplate , - const css::uno::Reference< css::xml::crypto::XXMLSecurityContext >& aContext - ) override; - - //Methods from XServiceInfo - virtual OUString SAL_CALL getImplementationName() override; - - virtual sal_Bool SAL_CALL supportsService( - const OUString& ServiceName - ) override; - - virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; - - //Helper for XServiceInfo - static css::uno::Sequence< OUString > impl_getSupportedServiceNames() ; - - /// @throws css::uno::RuntimeException - static OUString impl_getImplementationName() ; - - //Helper for registry - /// @throws css::uno::RuntimeException - static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& aServiceManager ) ; - - static css::uno::Reference< css::lang::XSingleServiceFactory > impl_createFactory( const css::uno::Reference< css::lang::XMultiServiceFactory >& aServiceManager ) ; -} ; - -#endif // INCLUDED_XMLSECURITY_SOURCE_XMLSEC_MSCRYPT_XMLSIGNATURE_MSCRYPTIMPL_HXX - -/* 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 index e55569c7ef4f..0661ed8594d7 100644 --- a/xmlsecurity/source/xmlsec/mscrypt/xsec_mscrypt.cxx +++ b/xmlsecurity/source/xmlsec/mscrypt/xsec_mscrypt.cxx @@ -25,7 +25,6 @@ #include #include "seinitializer_mscryptimpl.hxx" -#include "xmlsignature_mscryptimpl.hxx" #include "xmlsecuritycontext_mscryptimpl.hxx" #include "securityenvironment_mscryptimpl.hxx" @@ -43,9 +42,7 @@ void* mscrypt_component_getFactory( const sal_Char* pImplName , void* pServiceMa Reference< XSingleServiceFactory > xFactory ; if( pImplName != nullptr && pServiceManager != nullptr ) { - if( XMLSignature_MSCryptImpl::impl_getImplementationName().equalsAscii( pImplName ) ) { - xFactory = XMLSignature_MSCryptImpl::impl_createFactory( static_cast< XMultiServiceFactory* >( pServiceManager ) ) ; - } else if( XMLSecurityContext_MSCryptImpl::impl_getImplementationName().equalsAscii( pImplName ) ) { + if( XMLSecurityContext_MSCryptImpl::impl_getImplementationName().equalsAscii( pImplName ) ) { xFactory = XMLSecurityContext_MSCryptImpl::impl_createFactory( static_cast< XMultiServiceFactory* >( pServiceManager ) ) ; } else if( SecurityEnvironment_MSCryptImpl::impl_getImplementationName().equalsAscii( pImplName ) ) { xFactory = SecurityEnvironment_MSCryptImpl::impl_createFactory( static_cast< XMultiServiceFactory* >( pServiceManager ) ) ; diff --git a/xmlsecurity/util/xsec_xmlsec.windows.component b/xmlsecurity/util/xsec_xmlsec.windows.component index fc7df19b1b9e..7b6840c53521 100644 --- a/xmlsecurity/util/xsec_xmlsec.windows.component +++ b/xmlsecurity/util/xsec_xmlsec.windows.component @@ -37,7 +37,8 @@ - + -- cgit v1.2.3