1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_XMLSECURITY_SOURCE_COMPONENT_DOCUMENTDIGITALSIGNATURES_HXX
21 #define INCLUDED_XMLSECURITY_SOURCE_COMPONENT_DOCUMENTDIGITALSIGNATURES_HXX
23 #include <cppuhelper/implbase.hxx>
25 #include <com/sun/star/lang/XInitialization.hpp>
26 #include <com/sun/star/lang/XServiceInfo.hpp>
27 #include <com/sun/star/security/XDocumentDigitalSignatures.hpp>
28 #include <com/sun/star/io/XStream.hpp>
29 #include <com/sun/star/io/XInputStream.hpp>
30 #include <com/sun/star/uno/Sequence.hxx>
31 #include <certificatechooser.hxx>
32 #include <documentsignaturehelper.hxx>
34 namespace com
{ namespace sun
{ namespace star
{
37 class XComponentContext
;
41 class DocumentDigitalSignatures
: public cppu::WeakImplHelper
43 css::security::XDocumentDigitalSignatures
,
44 css::lang::XInitialization
,
45 css::lang::XServiceInfo
49 css::uno::Reference
< css::uno::XComponentContext
> mxCtx
;
50 // will be set by XInitialization. If not we assume true. false means an earlier version (whatever that means,
51 // this is a string, not a boolean).
52 // Note that the code talks about "ODF version" even if this class is also used to sign OOXML.
53 OUString m_sODFVersion
;
54 //The number of arguments which were passed in XInitialization::initialize
55 int m_nArgumentsCount
;
56 //Indicates if the document already contains a document signature
57 bool m_bHasDocumentSignature
;
59 /// @throws css::uno::RuntimeException
60 bool ImplViewSignatures( const css::uno::Reference
< css::embed::XStorage
>& rxStorage
, const css::uno::Reference
< css::io::XStream
>& xSignStream
, DocumentSignatureMode eMode
, bool bReadOnly
);
61 /// @throws css::uno::RuntimeException
62 void ImplViewSignatures( const css::uno::Reference
< css::embed::XStorage
>& rxStorage
, const css::uno::Reference
< css::io::XInputStream
>& xSignStream
, DocumentSignatureMode eMode
, bool bReadOnly
);
63 /// @throws css::uno::RuntimeException
64 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
);
66 css::uno::Sequence
< css::uno::Reference
< css::security::XCertificate
> > chooseCertificatesImpl(std::map
<OUString
, OUString
>& rProperties
, const UserAction eAction
);
69 explicit DocumentDigitalSignatures( const css::uno::Reference
< css::uno::XComponentContext
>& rxCtx
);
70 virtual ~DocumentDigitalSignatures() override
;
72 // for service registration...
73 /// @throws css::uno::RuntimeException
74 static OUString
GetImplementationName();
75 /// @throws css::uno::RuntimeException
76 static css::uno::Sequence
< OUString
> GetSupportedServiceNames();
79 void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) override
;
81 OUString SAL_CALL
getImplementationName() override
;
83 sal_Bool SAL_CALL
supportsService(OUString
const & ServiceName
) override
;
85 css::uno::Sequence
<OUString
> SAL_CALL
getSupportedServiceNames() override
;
87 // XDocumentDigitalSignatures
88 sal_Bool SAL_CALL
signDocumentContent( const css::uno::Reference
< css::embed::XStorage
>& xStorage
, const css::uno::Reference
< css::io::XStream
>& xSignStream
) override
;
89 sal_Bool SAL_CALL
signDocumentContentWithCertificate(
90 const css::uno::Reference
<css::embed::XStorage
>& Storage
,
91 const css::uno::Reference
<css::io::XStream
>& xSignStream
,
92 const css::uno::Reference
<css::security::XCertificate
>& xCertificate
,
93 const OUString
& rSignatureLineId
) override
;
94 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
;
95 void SAL_CALL
showDocumentContentSignatures( const css::uno::Reference
< css::embed::XStorage
>& xStorage
, const css::uno::Reference
< css::io::XInputStream
>& xSignInStream
) override
;
96 OUString SAL_CALL
getDocumentContentSignatureDefaultStreamName( ) override
;
97 sal_Bool SAL_CALL
signScriptingContent( const css::uno::Reference
< css::embed::XStorage
>& xStorage
, const css::uno::Reference
< css::io::XStream
>& xSignStream
) override
;
98 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
;
99 void SAL_CALL
showScriptingContentSignatures( const css::uno::Reference
< css::embed::XStorage
>& xStorage
, const css::uno::Reference
< css::io::XInputStream
>& xSignInStream
) override
;
100 OUString SAL_CALL
getScriptingContentSignatureDefaultStreamName( ) override
;
101 sal_Bool SAL_CALL
signPackage( const css::uno::Reference
< css::embed::XStorage
>& Storage
, const css::uno::Reference
< css::io::XStream
>& xSignStream
) override
;
102 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
;
103 void SAL_CALL
showPackageSignatures( const css::uno::Reference
< css::embed::XStorage
>& xStorage
, const css::uno::Reference
< css::io::XInputStream
>& xSignInStream
) override
;
104 OUString SAL_CALL
getPackageSignatureDefaultStreamName( ) override
;
105 void SAL_CALL
showCertificate( const css::uno::Reference
< css::security::XCertificate
>& Certificate
) override
;
106 void SAL_CALL
manageTrustedSources( ) override
;
107 sal_Bool SAL_CALL
isAuthorTrusted( const css::uno::Reference
< css::security::XCertificate
>& Author
) override
;
108 sal_Bool SAL_CALL
isLocationTrusted( const OUString
& Location
) override
;
109 void SAL_CALL
addAuthorToTrustedSources( const css::uno::Reference
< css::security::XCertificate
>& Author
) override
;
110 void SAL_CALL
addLocationToTrustedSources( const OUString
& Location
) override
;
112 css::uno::Reference
< css::security::XCertificate
> SAL_CALL
chooseCertificate(OUString
& rDescription
) override
;
113 css::uno::Reference
< css::security::XCertificate
> SAL_CALL
chooseSigningCertificate(OUString
& rDescription
) override
;
114 css::uno::Sequence
<css::uno::Reference
< css::security::XCertificate
> > SAL_CALL
chooseEncryptionCertificate() override
;
115 css::uno::Reference
< css::security::XCertificate
> SAL_CALL
chooseCertificateWithProps(css::uno::Sequence
<::com::sun::star::beans::PropertyValue
>& Properties
) override
;
117 sal_Bool SAL_CALL
signDocumentWithCertificate(
118 css::uno::Reference
<css::security::XCertificate
> const & xCertificate
,
119 css::uno::Reference
<css::embed::XStorage
> const & xStoragexStorage
,
120 css::uno::Reference
<css::io::XStream
> const & xStream
) override
;
123 /// @throws css::uno::Exception
124 css::uno::Reference
< css::uno::XInterface
> SAL_CALL
DocumentDigitalSignatures_CreateInstance(
125 const css::uno::Reference
< css::uno::XComponentContext
>& rCtx
);
127 #endif // INCLUDED_XMLSECURITY_SOURCE_COMPONENT_DOCUMENTDIGITALSIGNATURES_HXX
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */