diff options
Diffstat (limited to 'xmlsecurity')
-rw-r--r-- | xmlsecurity/source/component/documentdigitalsignatures.cxx | 130 | ||||
-rw-r--r-- | xmlsecurity/source/component/documentdigitalsignatures.hxx | 119 | ||||
-rw-r--r-- | xmlsecurity/source/component/registerservices.cxx | 11 | ||||
-rw-r--r-- | xmlsecurity/util/xmlsecurity.component | 3 |
4 files changed, 111 insertions, 152 deletions
diff --git a/xmlsecurity/source/component/documentdigitalsignatures.cxx b/xmlsecurity/source/component/documentdigitalsignatures.cxx index dd7de2c3bafe..af32a2433760 100644 --- a/xmlsecurity/source/component/documentdigitalsignatures.cxx +++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx @@ -17,7 +17,6 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include "documentdigitalsignatures.hxx" #include <resourcemanager.hxx> #include <digitalsignaturesdialog.hxx> @@ -47,10 +46,110 @@ #include <comphelper/sequence.hxx> #include <cppuhelper/supportsservice.hxx> #include <com/sun/star/lang/IllegalArgumentException.hpp> +#include <com/sun/star/security/XDocumentDigitalSignatures.hpp> using namespace css; using namespace css::uno; +class DocumentDigitalSignatures + : public cppu::WeakImplHelper<css::security::XDocumentDigitalSignatures, + css::lang::XInitialization, css::lang::XServiceInfo> +{ +private: + css::uno::Reference<css::uno::XComponentContext> mxCtx; + /// will be set by XInitialization. If not we assume true. false means an earlier version (whatever that means, + /// this is a string, not a boolean). + /// Note that the code talks about "ODF version" even if this class is also used to sign OOXML. + OUString m_sODFVersion; + /// The number of arguments which were passed in XInitialization::initialize + int m_nArgumentsCount; + /// Indicates if the document already contains a document signature + bool m_bHasDocumentSignature; + + /// @throws css::uno::RuntimeException + bool ImplViewSignatures(const css::uno::Reference<css::embed::XStorage>& rxStorage, + const css::uno::Reference<css::io::XStream>& xSignStream, + DocumentSignatureMode eMode, bool bReadOnly); + /// @throws css::uno::RuntimeException + void ImplViewSignatures(const css::uno::Reference<css::embed::XStorage>& rxStorage, + const css::uno::Reference<css::io::XInputStream>& xSignStream, + DocumentSignatureMode eMode, bool bReadOnly); + /// @throws css::uno::RuntimeException + css::uno::Sequence<css::security::DocumentSignatureInformation> + ImplVerifySignatures(const css::uno::Reference<css::embed::XStorage>& rxStorage, + const ::com::sun::star::uno::Reference<css::io::XInputStream>& xSignStream, + DocumentSignatureMode eMode); + + css::uno::Sequence<css::uno::Reference<css::security::XCertificate>> + chooseCertificatesImpl(std::map<OUString, OUString>& rProperties, const UserAction eAction); + +public: + explicit DocumentDigitalSignatures( + const css::uno::Reference<css::uno::XComponentContext>& rxCtx); + + //XInitialization + void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& aArguments) override; + + OUString SAL_CALL getImplementationName() override; + + sal_Bool SAL_CALL supportsService(OUString const& ServiceName) override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + + // XDocumentDigitalSignatures + sal_Bool SAL_CALL + signDocumentContent(const css::uno::Reference<css::embed::XStorage>& xStorage, + const css::uno::Reference<css::io::XStream>& xSignStream) override; + css::uno::Sequence<css::security::DocumentSignatureInformation> + SAL_CALL verifyDocumentContentSignatures( + const css::uno::Reference<css::embed::XStorage>& xStorage, + const css::uno::Reference<css::io::XInputStream>& xSignInStream) override; + void SAL_CALL showDocumentContentSignatures( + const css::uno::Reference<css::embed::XStorage>& xStorage, + const css::uno::Reference<css::io::XInputStream>& xSignInStream) override; + OUString SAL_CALL getDocumentContentSignatureDefaultStreamName() override; + sal_Bool SAL_CALL + signScriptingContent(const css::uno::Reference<css::embed::XStorage>& xStorage, + const css::uno::Reference<css::io::XStream>& xSignStream) override; + css::uno::Sequence<css::security::DocumentSignatureInformation> + SAL_CALL verifyScriptingContentSignatures( + const css::uno::Reference<css::embed::XStorage>& xStorage, + const css::uno::Reference<css::io::XInputStream>& xSignInStream) override; + void SAL_CALL showScriptingContentSignatures( + const css::uno::Reference<css::embed::XStorage>& xStorage, + const css::uno::Reference<css::io::XInputStream>& xSignInStream) override; + OUString SAL_CALL getScriptingContentSignatureDefaultStreamName() override; + sal_Bool SAL_CALL + signPackage(const css::uno::Reference<css::embed::XStorage>& Storage, + const css::uno::Reference<css::io::XStream>& xSignStream) override; + css::uno::Sequence<css::security::DocumentSignatureInformation> + SAL_CALL verifyPackageSignatures( + const css::uno::Reference<css::embed::XStorage>& Storage, + const css::uno::Reference<css::io::XInputStream>& xSignInStream) override; + void SAL_CALL + showPackageSignatures(const css::uno::Reference<css::embed::XStorage>& xStorage, + const css::uno::Reference<css::io::XInputStream>& xSignInStream) override; + OUString SAL_CALL getPackageSignatureDefaultStreamName() override; + void SAL_CALL + showCertificate(const css::uno::Reference<css::security::XCertificate>& Certificate) override; + void SAL_CALL manageTrustedSources() override; + sal_Bool SAL_CALL + isAuthorTrusted(const css::uno::Reference<css::security::XCertificate>& Author) override; + sal_Bool SAL_CALL isLocationTrusted(const OUString& Location) override; + void SAL_CALL addAuthorToTrustedSources( + const css::uno::Reference<css::security::XCertificate>& Author) override; + void SAL_CALL addLocationToTrustedSources(const OUString& Location) override; + + css::uno::Reference<css::security::XCertificate> + SAL_CALL chooseCertificate(OUString& rDescription) override; + css::uno::Reference<css::security::XCertificate> + SAL_CALL chooseSigningCertificate(OUString& rDescription) override; + css::uno::Sequence<css::uno::Reference<css::security::XCertificate>> + SAL_CALL chooseEncryptionCertificate() override; + css::uno::Reference<css::security::XCertificate> SAL_CALL chooseCertificateWithProps( + css::uno::Sequence<::com::sun::star::beans::PropertyValue>& Properties) override; +}; + DocumentDigitalSignatures::DocumentDigitalSignatures( const Reference< XComponentContext >& rxCtx ): mxCtx(rxCtx), m_sODFVersion(ODFVER_012_TEXT), @@ -59,10 +158,6 @@ DocumentDigitalSignatures::DocumentDigitalSignatures( const Reference< XComponen { } -DocumentDigitalSignatures::~DocumentDigitalSignatures() -{ -} - void DocumentDigitalSignatures::initialize( const Sequence< Any >& aArguments) { if (aArguments.getLength() > 2) @@ -95,7 +190,7 @@ void DocumentDigitalSignatures::initialize( const Sequence< Any >& aArguments) OUString DocumentDigitalSignatures::getImplementationName() { - return GetImplementationName(); + return OUString("com.sun.star.security.DocumentDigitalSignatures"); } sal_Bool DocumentDigitalSignatures::supportsService( @@ -107,7 +202,8 @@ sal_Bool DocumentDigitalSignatures::supportsService( css::uno::Sequence<OUString> DocumentDigitalSignatures::getSupportedServiceNames() { - return GetSupportedServiceNames(); + Sequence<OUString> aRet{ "com.sun.star.security.DocumentDigitalSignatures" }; + return aRet; } sal_Bool DocumentDigitalSignatures::signDocumentContent( @@ -560,22 +656,12 @@ void DocumentDigitalSignatures::addLocationToTrustedSources( const OUString& Loc aSecOpt.SetSecureURLs( aSecURLs ); } -OUString DocumentDigitalSignatures::GetImplementationName() -{ - return OUString( "com.sun.star.security.DocumentDigitalSignatures" ); -} - -Sequence< OUString > DocumentDigitalSignatures::GetSupportedServiceNames() -{ - Sequence<OUString> aRet { "com.sun.star.security.DocumentDigitalSignatures" }; - return aRet; -} - - -Reference< XInterface > DocumentDigitalSignatures_CreateInstance( - const Reference< XComponentContext >& rCtx) +extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface* +com_sun_star_security_DocumentDigitalSignatures_get_implementation( + uno::XComponentContext* pCtx, uno::Sequence<uno::Any> const& /*rSeq*/) { - return static_cast<cppu::OWeakObject*>(new DocumentDigitalSignatures( rCtx )); + return cppu::acquire( + new DocumentDigitalSignatures(uno::Reference<uno::XComponentContext>(pCtx))); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmlsecurity/source/component/documentdigitalsignatures.hxx b/xmlsecurity/source/component/documentdigitalsignatures.hxx deleted file mode 100644 index 4bb8de8ebf6d..000000000000 --- a/xmlsecurity/source/component/documentdigitalsignatures.hxx +++ /dev/null @@ -1,119 +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_COMPONENT_DOCUMENTDIGITALSIGNATURES_HXX -#define INCLUDED_XMLSECURITY_SOURCE_COMPONENT_DOCUMENTDIGITALSIGNATURES_HXX - -#include <cppuhelper/implbase.hxx> - -#include <com/sun/star/lang/XInitialization.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/security/XDocumentDigitalSignatures.hpp> -#include <com/sun/star/io/XStream.hpp> -#include <com/sun/star/io/XInputStream.hpp> -#include <com/sun/star/uno/Sequence.hxx> -#include <certificatechooser.hxx> -#include <documentsignaturehelper.hxx> - -namespace com { namespace sun { namespace star { - - namespace uno { - class XComponentContext; - } -}}} - -class DocumentDigitalSignatures : public cppu::WeakImplHelper -< - css::security::XDocumentDigitalSignatures, - css::lang::XInitialization, - css::lang::XServiceInfo -> -{ -private: - css::uno::Reference< css::uno::XComponentContext > mxCtx; - // will be set by XInitialization. If not we assume true. false means an earlier version (whatever that means, - // this is a string, not a boolean). - // Note that the code talks about "ODF version" even if this class is also used to sign OOXML. - OUString m_sODFVersion; - //The number of arguments which were passed in XInitialization::initialize - int m_nArgumentsCount; - //Indicates if the document already contains a document signature - bool m_bHasDocumentSignature; - - /// @throws css::uno::RuntimeException - bool ImplViewSignatures( const css::uno::Reference< css::embed::XStorage >& rxStorage, const css::uno::Reference< css::io::XStream >& xSignStream, DocumentSignatureMode eMode, bool bReadOnly ); - /// @throws css::uno::RuntimeException - void ImplViewSignatures( const css::uno::Reference< css::embed::XStorage >& rxStorage, const css::uno::Reference< css::io::XInputStream >& xSignStream, DocumentSignatureMode eMode, bool bReadOnly ); - /// @throws css::uno::RuntimeException - css::uno::Sequence< css::security::DocumentSignatureInformation > ImplVerifySignatures( const css::uno::Reference< css::embed::XStorage >& rxStorage, const ::com::sun::star::uno::Reference< css::io::XInputStream >& xSignStream, DocumentSignatureMode eMode ); - - css::uno::Sequence< css::uno::Reference< css::security::XCertificate > > chooseCertificatesImpl(std::map<OUString, OUString>& rProperties, const UserAction eAction); - -public: - explicit DocumentDigitalSignatures( const css::uno::Reference< css::uno::XComponentContext>& rxCtx ); - virtual ~DocumentDigitalSignatures() override; - - // for service registration... - /// @throws css::uno::RuntimeException - static OUString GetImplementationName(); - /// @throws css::uno::RuntimeException - static css::uno::Sequence < OUString > GetSupportedServiceNames(); - - //XInitialization - void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; - - OUString SAL_CALL getImplementationName() override; - - sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override; - - css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; - - // XDocumentDigitalSignatures - sal_Bool SAL_CALL signDocumentContent( const css::uno::Reference< css::embed::XStorage >& xStorage, const css::uno::Reference< css::io::XStream >& xSignStream ) override; - css::uno::Sequence< css::security::DocumentSignatureInformation > SAL_CALL verifyDocumentContentSignatures( const css::uno::Reference< css::embed::XStorage >& xStorage, const css::uno::Reference< css::io::XInputStream >& xSignInStream ) override; - void SAL_CALL showDocumentContentSignatures( const css::uno::Reference< css::embed::XStorage >& xStorage, const css::uno::Reference< css::io::XInputStream >& xSignInStream ) override; - OUString SAL_CALL getDocumentContentSignatureDefaultStreamName( ) override; - sal_Bool SAL_CALL signScriptingContent( const css::uno::Reference< css::embed::XStorage >& xStorage, const css::uno::Reference< css::io::XStream >& xSignStream ) override; - css::uno::Sequence< css::security::DocumentSignatureInformation > SAL_CALL verifyScriptingContentSignatures( const css::uno::Reference< css::embed::XStorage >& xStorage, const css::uno::Reference< css::io::XInputStream >& xSignInStream ) override; - void SAL_CALL showScriptingContentSignatures( const css::uno::Reference< css::embed::XStorage >& xStorage, const css::uno::Reference< css::io::XInputStream >& xSignInStream ) override; - OUString SAL_CALL getScriptingContentSignatureDefaultStreamName( ) override; - sal_Bool SAL_CALL signPackage( const css::uno::Reference< css::embed::XStorage >& Storage, const css::uno::Reference< css::io::XStream >& xSignStream ) override; - css::uno::Sequence< css::security::DocumentSignatureInformation > SAL_CALL verifyPackageSignatures( const css::uno::Reference< css::embed::XStorage >& Storage, const css::uno::Reference< css::io::XInputStream >& xSignInStream ) override; - void SAL_CALL showPackageSignatures( const css::uno::Reference< css::embed::XStorage >& xStorage, const css::uno::Reference< css::io::XInputStream >& xSignInStream ) override; - OUString SAL_CALL getPackageSignatureDefaultStreamName( ) override; - void SAL_CALL showCertificate( const css::uno::Reference< css::security::XCertificate >& Certificate ) override; - void SAL_CALL manageTrustedSources( ) override; - sal_Bool SAL_CALL isAuthorTrusted( const css::uno::Reference< css::security::XCertificate >& Author ) override; - sal_Bool SAL_CALL isLocationTrusted( const OUString& Location ) override; - void SAL_CALL addAuthorToTrustedSources( const css::uno::Reference< css::security::XCertificate >& Author ) override; - void SAL_CALL addLocationToTrustedSources( const OUString& Location ) override; - - css::uno::Reference< css::security::XCertificate > SAL_CALL chooseCertificate(OUString& rDescription) override; - css::uno::Reference< css::security::XCertificate > SAL_CALL chooseSigningCertificate(OUString& rDescription) override; - css::uno::Sequence<css::uno::Reference< css::security::XCertificate > > SAL_CALL chooseEncryptionCertificate() override; - css::uno::Reference< css::security::XCertificate > SAL_CALL chooseCertificateWithProps(css::uno::Sequence<::com::sun::star::beans::PropertyValue>& Properties) override; -}; - -/// @throws css::uno::Exception -css::uno::Reference< css::uno::XInterface > DocumentDigitalSignatures_CreateInstance( - const css::uno::Reference< css::uno::XComponentContext >& rCtx); - -#endif // INCLUDED_XMLSECURITY_SOURCE_COMPONENT_DOCUMENTDIGITALSIGNATURES_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmlsecurity/source/component/registerservices.cxx b/xmlsecurity/source/component/registerservices.cxx index 1ee0290f22b2..9c0c91d7d015 100644 --- a/xmlsecurity/source/component/registerservices.cxx +++ b/xmlsecurity/source/component/registerservices.cxx @@ -22,7 +22,6 @@ #include <cppuhelper/factory.hxx> -#include "documentdigitalsignatures.hxx" #include "certificatecontainer.hxx" using namespace ::com::sun::star; @@ -38,15 +37,7 @@ SAL_DLLPUBLIC_EXPORT void* xmlsecurity_component_getFactory( const sal_Char * pI //Decryptor OUString implName = OUString::createFromAscii( pImplName ); - if ( pServiceManager && implName == DocumentDigitalSignatures::GetImplementationName() ) - { - // DocumentDigitalSignatures - xFactory = cppu::createSingleComponentFactory( - DocumentDigitalSignatures_CreateInstance, - OUString::createFromAscii( pImplName ), - DocumentDigitalSignatures::GetSupportedServiceNames() ); - } - else if ( pServiceManager && implName == CertificateContainer::impl_getStaticImplementationName() ) + if (pServiceManager && implName == CertificateContainer::impl_getStaticImplementationName()) { // CertificateContainer xFactory = cppu::createOneInstanceFactory( diff --git a/xmlsecurity/util/xmlsecurity.component b/xmlsecurity/util/xmlsecurity.component index ce19281af5b6..383572bff403 100644 --- a/xmlsecurity/util/xmlsecurity.component +++ b/xmlsecurity/util/xmlsecurity.component @@ -22,7 +22,8 @@ <implementation name="com.sun.star.security.CertificateContainer"> <service name="com.sun.star.security.CertificateContainer"/> </implementation> - <implementation name="com.sun.star.security.DocumentDigitalSignatures"> + <implementation name="com.sun.star.security.DocumentDigitalSignatures" + constructor="com_sun_star_security_DocumentDigitalSignatures_get_implementation"> <service name="com.sun.star.security.DocumentDigitalSignatures"/> </implementation> </component> |