From 48d3ff5c498f8f186d4ee72871af379010403442 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 13 Feb 2018 22:09:40 +0100 Subject: xmlsecurity nss: create XMLSignature instances with a constructor Change-Id: Ic2968a1eda7517ba4cfb67d0cf68fb7de1ac1935 Reviewed-on: https://gerrit.libreoffice.org/49685 Tested-by: Jenkins Reviewed-by: Miklos Vajna --- .../source/xmlsec/nss/xmlsignature_nssimpl.cxx | 53 ++++++++------ .../source/xmlsec/nss/xmlsignature_nssimpl.hxx | 80 ---------------------- xmlsecurity/source/xmlsec/nss/xsec_nss.cxx | 5 -- xmlsecurity/util/xsec_xmlsec.component | 3 +- 4 files changed, 33 insertions(+), 108 deletions(-) delete mode 100644 xmlsecurity/source/xmlsec/nss/xmlsignature_nssimpl.hxx (limited to 'xmlsecurity') diff --git a/xmlsecurity/source/xmlsec/nss/xmlsignature_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/xmlsignature_nssimpl.cxx index 3389fd149086..5eef5e80ae28 100644 --- a/xmlsecurity/source/xmlsec/nss/xmlsignature_nssimpl.cxx +++ b/xmlsecurity/source/xmlsec/nss/xmlsignature_nssimpl.cxx @@ -19,7 +19,6 @@ #include #include -#include "xmlsignature_nssimpl.hxx" #include #include @@ -31,7 +30,9 @@ #include "xmlsecuritycontext_nssimpl.hxx" #include +#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,10 +46,30 @@ using ::com::sun::star::xml::crypto::XXMLSignatureTemplate ; using ::com::sun::star::xml::crypto::XXMLSecurityContext ; using ::com::sun::star::xml::crypto::XUriBinding ; -XMLSignature_NssImpl::XMLSignature_NssImpl() { -} +class XMLSignature_NssImpl + : public ::cppu::WeakImplHelper +{ +public: + explicit XMLSignature_NssImpl(); + + //Methods from XXMLSignature + virtual uno::Reference SAL_CALL + generate(const uno::Reference& aTemplate, + const uno::Reference& aEnvironment) override; + + virtual uno::Reference SAL_CALL + validate(const uno::Reference& aTemplate, + const uno::Reference& aContext) override; + + //Methods from XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + + virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; + + virtual uno::Sequence SAL_CALL getSupportedServiceNames() override; +}; -XMLSignature_NssImpl::~XMLSignature_NssImpl() { +XMLSignature_NssImpl::XMLSignature_NssImpl() { } /* XXMLSignature */ @@ -267,7 +288,7 @@ SAL_CALL XMLSignature_NssImpl::validate( /* XServiceInfo */ OUString SAL_CALL XMLSignature_NssImpl::getImplementationName() { - return impl_getImplementationName() ; + return OUString("com.sun.star.xml.crypto.XMLSignature"); } /* XServiceInfo */ @@ -283,27 +304,15 @@ sal_Bool SAL_CALL XMLSignature_NssImpl::supportsService( const OUString& service /* XServiceInfo */ Sequence< OUString > SAL_CALL XMLSignature_NssImpl::getSupportedServiceNames() { - return impl_getSupportedServiceNames() ; -} - -//Helper for XServiceInfo -Sequence< OUString > XMLSignature_NssImpl::impl_getSupportedServiceNames() { - ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ; Sequence seqServiceNames { "com.sun.star.xml.crypto.XMLSignature" }; return seqServiceNames ; } -OUString XMLSignature_NssImpl::impl_getImplementationName() { - return OUString("com.sun.star.xml.security.bridge.xmlsec.XMLSignature_NssImpl") ; -} - -//Helper for registry -Reference< XInterface > SAL_CALL XMLSignature_NssImpl::impl_createInstance( const Reference< XMultiServiceFactory >& ) { - return Reference< XInterface >( *new XMLSignature_NssImpl ) ; -} - -Reference< XSingleServiceFactory > XMLSignature_NssImpl::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_NssImpl); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmlsecurity/source/xmlsec/nss/xmlsignature_nssimpl.hxx b/xmlsecurity/source/xmlsec/nss/xmlsignature_nssimpl.hxx deleted file mode 100644 index 92f50d9acb26..000000000000 --- a/xmlsecurity/source/xmlsec/nss/xmlsignature_nssimpl.hxx +++ /dev/null @@ -1,80 +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_NSS_XMLSIGNATURE_NSSIMPL_HXX -#define INCLUDED_XMLSECURITY_SOURCE_XMLSEC_NSS_XMLSIGNATURE_NSSIMPL_HXX - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -class XMLSignature_NssImpl : public ::cppu::WeakImplHelper< - css::xml::crypto::XXMLSignature , - css::lang::XServiceInfo > -{ - public: - explicit XMLSignature_NssImpl(); - virtual ~XMLSignature_NssImpl() 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_NSS_XMLSIGNATURE_NSSIMPL_HXX - -/* 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 1776c8f86af7..99582c3bf593 100644 --- a/xmlsecurity/source/xmlsec/nss/xsec_nss.cxx +++ b/xmlsecurity/source/xmlsec/nss/xsec_nss.cxx @@ -25,7 +25,6 @@ #include #include "seinitializer_nssimpl.hxx" -#include "xmlsignature_nssimpl.hxx" #include "xmlsecuritycontext_nssimpl.hxx" #include #include "securityenvironment_nssimpl.hxx" @@ -53,10 +52,6 @@ void* nss_component_getFactory( const sal_Char* pImplName , void* pServiceManage OUString::createFromAscii( pImplName ), SEInitializer_NssImpl_createInstance, SEInitializer_NssImpl_getSupportedServiceNames() ) ); } - else if( XMLSignature_NssImpl::impl_getImplementationName().equalsAscii( pImplName ) ) - { - xFactory = XMLSignature_NssImpl::impl_createFactory( static_cast< XMultiServiceFactory* >( pServiceManager ) ) ; - } else if( XMLSecurityContext_NssImpl::impl_getImplementationName().equalsAscii( pImplName ) ) { xFactory = XMLSecurityContext_NssImpl::impl_createFactory( static_cast< XMultiServiceFactory* >( pServiceManager ) ) ; diff --git a/xmlsecurity/util/xsec_xmlsec.component b/xmlsecurity/util/xsec_xmlsec.component index 3b6df511fed5..7282c0efb67e 100644 --- a/xmlsecurity/util/xsec_xmlsec.component +++ b/xmlsecurity/util/xsec_xmlsec.component @@ -38,7 +38,8 @@ - + -- cgit