Kaydet (Commit) 48d3ff5c authored tarafından Miklos Vajna's avatar Miklos Vajna

xmlsecurity nss: create XMLSignature instances with a constructor

Change-Id: Ic2968a1eda7517ba4cfb67d0cf68fb7de1ac1935
Reviewed-on: https://gerrit.libreoffice.org/49685Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst 9efd288b
......@@ -19,7 +19,6 @@
#include <sal/config.h>
#include <rtl/uuid.h>
#include "xmlsignature_nssimpl.hxx"
#include <xmlsec/xmldocumentwrapper_xmlsecimpl.hxx>
#include <xmlsec/xmlelementwrapper_xmlsecimpl.hxx>
......@@ -31,7 +30,9 @@
#include "xmlsecuritycontext_nssimpl.hxx"
#include <xmlsec-wrapper.h>
#include <com/sun/star/xml/crypto/XXMLSignature.hpp>
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<xml::crypto::XXMLSignature, lang::XServiceInfo>
{
public:
explicit XMLSignature_NssImpl();
//Methods from XXMLSignature
virtual uno::Reference<xml::crypto::XXMLSignatureTemplate> SAL_CALL
generate(const uno::Reference<xml::crypto::XXMLSignatureTemplate>& aTemplate,
const uno::Reference<xml::crypto::XSecurityEnvironment>& aEnvironment) override;
virtual uno::Reference<xml::crypto::XXMLSignatureTemplate> SAL_CALL
validate(const uno::Reference<xml::crypto::XXMLSignatureTemplate>& aTemplate,
const uno::Reference<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 uno::Sequence<OUString> 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<OUString> 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<uno::Any> const& /*rSeq*/)
{
return cppu::acquire(new XMLSignature_NssImpl);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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 <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/xml/crypto/XXMLSignature.hpp>
#include <com/sun/star/xml/crypto/XXMLSignatureTemplate.hpp>
#include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
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: */
......@@ -25,7 +25,6 @@
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include "seinitializer_nssimpl.hxx"
#include "xmlsignature_nssimpl.hxx"
#include "xmlsecuritycontext_nssimpl.hxx"
#include <xsec_xmlsec.hxx>
#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 ) ) ;
......
......@@ -38,7 +38,8 @@
<implementation name="com.sun.star.xml.security.bridge.xmlsec.XMLSecurityContext_NssImpl">
<service name="com.sun.star.xml.crypto.XMLSecurityContext"/>
</implementation>
<implementation name="com.sun.star.xml.security.bridge.xmlsec.XMLSignature_NssImpl">
<implementation name="com.sun.star.xml.crypto.XMLSignature"
constructor="com_sun_star_xml_crypto_XMLSignature_get_implementation">
<service name="com.sun.star.xml.crypto.XMLSignature"/>
</implementation>
</component>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment