summaryrefslogtreecommitdiff
path: root/xmlsecurity
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-02-28 21:47:52 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-03-01 10:06:43 +0100
commit7ef644e7e5a91935ce4fd15c40cf9e8338e49ca4 (patch)
tree0c6f5b0ec23288cf9d4af531083b635068f154d3 /xmlsecurity
parentb312c10a787b34fdc0252d0651c00edb3855d657 (diff)
xmlsecurity mscrypt: create XMLSecurityContext instances with a constructor
Change-Id: If535e153e587448232bf1451fa159d976e61be37 Reviewed-on: https://gerrit.libreoffice.org/50534 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'xmlsecurity')
-rw-r--r--xmlsecurity/source/xmlsec/mscrypt/xmlsecuritycontext_mscryptimpl.cxx83
-rw-r--r--xmlsecurity/source/xmlsec/mscrypt/xmlsecuritycontext_mscryptimpl.hxx95
-rw-r--r--xmlsecurity/source/xmlsec/mscrypt/xsec_mscrypt.cxx5
-rw-r--r--xmlsecurity/util/xsec_xmlsec.windows.component3
4 files changed, 58 insertions, 128 deletions
diff --git a/xmlsecurity/source/xmlsec/mscrypt/xmlsecuritycontext_mscryptimpl.cxx b/xmlsecurity/source/xmlsec/mscrypt/xmlsecuritycontext_mscryptimpl.cxx
index 925da9eba35c..1e479623ec0e 100644
--- a/xmlsecurity/source/xmlsec/mscrypt/xmlsecuritycontext_mscryptimpl.cxx
+++ b/xmlsecurity/source/xmlsec/mscrypt/xmlsecuritycontext_mscryptimpl.cxx
@@ -18,15 +18,15 @@
*/
#include <sal/config.h>
+#include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
#include "securityenvironment_mscryptimpl.hxx"
-#include "xmlsecuritycontext_mscryptimpl.hxx"
#include <xmlsec/xmlstreamio.hxx>
#include "akmngr.hxx"
#include <xmlsec-wrapper.h>
-using namespace ::com::sun::star::uno ;
+using namespace ::com::sun::star;
using namespace ::com::sun::star::lang ;
using ::com::sun::star::lang::XMultiServiceFactory ;
using ::com::sun::star::lang::XSingleServiceFactory ;
@@ -34,6 +34,48 @@ using ::com::sun::star::lang::XSingleServiceFactory ;
using ::com::sun::star::xml::crypto::XSecurityEnvironment ;
using ::com::sun::star::xml::crypto::XXMLSecurityContext ;
+class XMLSecurityContext_MSCryptImpl : public ::cppu::WeakImplHelper<
+ css::xml::crypto::XXMLSecurityContext ,
+ css::lang::XServiceInfo >
+{
+ private:
+ //xmlSecKeysMngrPtr m_pKeysMngr ;
+ css::uno::Reference< css::xml::crypto::XSecurityEnvironment > m_xSecurityEnvironment ;
+
+ public:
+ XMLSecurityContext_MSCryptImpl();
+ virtual ~XMLSecurityContext_MSCryptImpl() override;
+
+ //Methods from XXMLSecurityContext
+ virtual sal_Int32 SAL_CALL addSecurityEnvironment(
+ const css::uno::Reference< css::xml::crypto::XSecurityEnvironment >& aSecurityEnvironment
+ ) override;
+
+ virtual ::sal_Int32 SAL_CALL getSecurityEnvironmentNumber( ) override;
+
+ virtual css::uno::Reference<
+ css::xml::crypto::XSecurityEnvironment > SAL_CALL
+ getSecurityEnvironmentByIndex( ::sal_Int32 index ) override;
+
+ virtual css::uno::Reference<
+ css::xml::crypto::XSecurityEnvironment > SAL_CALL
+ getSecurityEnvironment( ) override;
+
+ virtual ::sal_Int32 SAL_CALL getDefaultSecurityEnvironmentIndex( ) override;
+
+ virtual void SAL_CALL setDefaultSecurityEnvironmentIndex( sal_Int32 nDefaultEnvIndex ) 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;
+};
+
XMLSecurityContext_MSCryptImpl::XMLSecurityContext_MSCryptImpl()
://m_pKeysMngr( NULL ) ,
m_xSecurityEnvironment( nullptr )
@@ -49,7 +91,7 @@ sal_Int32 SAL_CALL XMLSecurityContext_MSCryptImpl::addSecurityEnvironment(
{
if( !aSecurityEnvironment.is() )
{
- throw RuntimeException() ;
+ throw uno::RuntimeException() ;
}
m_xSecurityEnvironment = aSecurityEnvironment;
@@ -68,7 +110,7 @@ css::uno::Reference< css::xml::crypto::XSecurityEnvironment > SAL_CALL
{
if (index != 0)
{
- throw RuntimeException() ;
+ throw uno::RuntimeException() ;
}
return m_xSecurityEnvironment;
}
@@ -91,12 +133,12 @@ void SAL_CALL XMLSecurityContext_MSCryptImpl::setDefaultSecurityEnvironmentIndex
/* XServiceInfo */
OUString SAL_CALL XMLSecurityContext_MSCryptImpl::getImplementationName() {
- return impl_getImplementationName() ;
+ return OUString("com.sun.star.xml.crypto.XMLSecurityContext") ;
}
/* XServiceInfo */
sal_Bool SAL_CALL XMLSecurityContext_MSCryptImpl::supportsService( const OUString& serviceName) {
- Sequence< OUString > seqServiceNames = getSupportedServiceNames() ;
+ uno::Sequence< OUString > seqServiceNames = getSupportedServiceNames() ;
const OUString* pArray = seqServiceNames.getConstArray() ;
for( sal_Int32 i = 0 ; i < seqServiceNames.getLength() ; i ++ ) {
if( *( pArray + i ) == serviceName )
@@ -106,31 +148,16 @@ sal_Bool SAL_CALL XMLSecurityContext_MSCryptImpl::supportsService( const OUStrin
}
/* XServiceInfo */
-Sequence< OUString > SAL_CALL XMLSecurityContext_MSCryptImpl::getSupportedServiceNames() {
- return impl_getSupportedServiceNames() ;
-}
-
-//Helper for XServiceInfo
-Sequence< OUString > XMLSecurityContext_MSCryptImpl::impl_getSupportedServiceNames() {
- ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ) ;
- Sequence<OUString> seqServiceNames { "com.sun.star.xml.crypto.XMLSecurityContext" };
+uno::Sequence< OUString > SAL_CALL XMLSecurityContext_MSCryptImpl::getSupportedServiceNames() {
+ uno::Sequence<OUString> seqServiceNames { "com.sun.star.xml.crypto.XMLSecurityContext" };
return seqServiceNames ;
}
-OUString XMLSecurityContext_MSCryptImpl::impl_getImplementationName() {
- return OUString("com.sun.star.xml.security.bridge.xmlsec.XMLSecurityContext_MSCryptImpl") ;
-}
-
-//Helper for registry
-Reference< XInterface > SAL_CALL XMLSecurityContext_MSCryptImpl::impl_createInstance( const Reference< XMultiServiceFactory >& ) {
- return Reference< XInterface >( *new XMLSecurityContext_MSCryptImpl ) ;
-}
-
-Reference< XSingleServiceFactory > XMLSecurityContext_MSCryptImpl::impl_createFactory( const Reference< XMultiServiceFactory >& aServiceManager ) {
- //Reference< XSingleServiceFactory > xFactory ;
- //xFactory = ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName , impl_createInstance , impl_getSupportedServiceNames ) ;
- //return xFactory ;
- return ::cppu::createSingleFactory( aServiceManager , impl_getImplementationName() , impl_createInstance , impl_getSupportedServiceNames() ) ;
+extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface*
+com_sun_star_xml_crypto_XMLSecurityContext_get_implementation(
+ uno::XComponentContext* /*pCtx*/, uno::Sequence<uno::Any> const& /*rSeq*/)
+{
+ return cppu::acquire(new XMLSecurityContext_MSCryptImpl);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmlsecurity/source/xmlsec/mscrypt/xmlsecuritycontext_mscryptimpl.hxx b/xmlsecurity/source/xmlsec/mscrypt/xmlsecuritycontext_mscryptimpl.hxx
deleted file mode 100644
index 3f9bc3c40ba7..000000000000
--- a/xmlsecurity/source/xmlsec/mscrypt/xmlsecuritycontext_mscryptimpl.hxx
+++ /dev/null
@@ -1,95 +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_XMLSECURITYCONTEXT_MSCRYPTIMPL_HXX
-#define INCLUDED_XMLSECURITY_SOURCE_XMLSEC_MSCRYPT_XMLSECURITYCONTEXT_MSCRYPTIMPL_HXX
-
-#include <sal/config.h>
-#include <rtl/ustring.hxx>
-#include <cppuhelper/factory.hxx>
-#include <cppuhelper/implbase.hxx>
-#include <com/sun/star/uno/Exception.hpp>
-
-#include <com/sun/star/uno/Reference.hxx>
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/lang/XUnoTunnel.hpp>
-#include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
-#include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
-
-
-class XMLSecurityContext_MSCryptImpl : public ::cppu::WeakImplHelper<
- css::xml::crypto::XXMLSecurityContext ,
- css::lang::XServiceInfo >
-{
- private:
- //xmlSecKeysMngrPtr m_pKeysMngr ;
- css::uno::Reference< css::xml::crypto::XSecurityEnvironment > m_xSecurityEnvironment ;
-
- public:
- XMLSecurityContext_MSCryptImpl();
- virtual ~XMLSecurityContext_MSCryptImpl() override;
-
- //Methods from XXMLSecurityContext
- virtual sal_Int32 SAL_CALL addSecurityEnvironment(
- const css::uno::Reference< css::xml::crypto::XSecurityEnvironment >& aSecurityEnvironment
- ) override;
-
- virtual ::sal_Int32 SAL_CALL getSecurityEnvironmentNumber( ) override;
-
- virtual css::uno::Reference<
- css::xml::crypto::XSecurityEnvironment > SAL_CALL
- getSecurityEnvironmentByIndex( ::sal_Int32 index ) override;
-
- virtual css::uno::Reference<
- css::xml::crypto::XSecurityEnvironment > SAL_CALL
- getSecurityEnvironment( ) override;
-
- virtual ::sal_Int32 SAL_CALL getDefaultSecurityEnvironmentIndex( ) override;
-
- virtual void SAL_CALL setDefaultSecurityEnvironmentIndex( sal_Int32 nDefaultEnvIndex ) 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_XMLSECURITYCONTEXT_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 0661ed8594d7..b4dd43ece9d6 100644
--- a/xmlsecurity/source/xmlsec/mscrypt/xsec_mscrypt.cxx
+++ b/xmlsecurity/source/xmlsec/mscrypt/xsec_mscrypt.cxx
@@ -25,7 +25,6 @@
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include "seinitializer_mscryptimpl.hxx"
-#include "xmlsecuritycontext_mscryptimpl.hxx"
#include "securityenvironment_mscryptimpl.hxx"
using namespace ::cppu;
@@ -42,9 +41,7 @@ void* mscrypt_component_getFactory( const sal_Char* pImplName , void* pServiceMa
Reference< XSingleServiceFactory > xFactory ;
if( pImplName != nullptr && pServiceManager != nullptr ) {
- if( XMLSecurityContext_MSCryptImpl::impl_getImplementationName().equalsAscii( pImplName ) ) {
- xFactory = XMLSecurityContext_MSCryptImpl::impl_createFactory( static_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
- } else if( SecurityEnvironment_MSCryptImpl::impl_getImplementationName().equalsAscii( pImplName ) ) {
+ if( SecurityEnvironment_MSCryptImpl::impl_getImplementationName().equalsAscii( pImplName ) ) {
xFactory = SecurityEnvironment_MSCryptImpl::impl_createFactory( static_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
} else if( SEInitializer_MSCryptImpl_getImplementationName().equalsAscii( pImplName ) ) {
xFactory.set( createSingleFactory(
diff --git a/xmlsecurity/util/xsec_xmlsec.windows.component b/xmlsecurity/util/xsec_xmlsec.windows.component
index f79bfbc114e9..6280adf0e5a8 100644
--- a/xmlsecurity/util/xsec_xmlsec.windows.component
+++ b/xmlsecurity/util/xsec_xmlsec.windows.component
@@ -37,7 +37,8 @@
<implementation name="com.sun.star.xml.security.bridge.xmlsec.XMLElementWrapper_XmlSecImpl">
<service name="com.sun.star.xml.wrapper.XMLElementWrapper"/>
</implementation>
- <implementation name="com.sun.star.xml.security.bridge.xmlsec.XMLSecurityContext_MSCryptImpl">
+ <implementation name="com.sun.star.xml.crypto.XMLSecurityContext"
+ constructor="com_sun_star_xml_crypto_XMLSecurityContext_get_implementation">
<service name="com.sun.star.xml.crypto.XMLSecurityContext"/>
</implementation>
<implementation name="com.sun.star.xml.crypto.XMLSignature"