Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / xmlsecurity / inc / documentsignaturemanager.hxx
blobf88820f03803eba38dcb23f0511fbcc2e7e4c4f7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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_INC_DOCUMENTSIGNATUREMANAGER_HXX
21 #define INCLUDED_XMLSECURITY_INC_DOCUMENTSIGNATUREMANAGER_HXX
23 #include "xmlsecuritydllapi.h"
25 #include <memory>
27 #include <svl/sigstruct.hxx>
28 #include "xmlsignaturehelper.hxx"
29 #include <com/sun/star/uno/XComponentContext.hpp>
30 #include <com/sun/star/embed/XStorage.hpp>
31 #include <com/sun/star/graphic/XGraphic.hpp>
32 #include "documentsignaturehelper.hxx"
33 #include <com/sun/star/beans/PropertyValue.hpp>
35 class PDFSignatureHelper;
37 /// Manages signatures (addition, removal), used by DigitalSignaturesDialog.
38 class XMLSECURITY_DLLPUBLIC DocumentSignatureManager
40 public:
41 css::uno::Reference<css::uno::XComponentContext> mxContext;
42 css::uno::Reference<css::embed::XStorage> mxStore;
43 XMLSignatureHelper maSignatureHelper;
44 std::unique_ptr<PDFSignatureHelper> mpPDFSignatureHelper;
45 SignatureInformations maCurrentSignatureInformations;
46 DocumentSignatureMode meSignatureMode;
47 css::uno::Sequence<css::uno::Sequence<css::beans::PropertyValue>> m_manifest;
48 css::uno::Reference<css::io::XStream> mxSignatureStream;
49 css::uno::Reference<css::io::XStream> mxTempSignatureStream;
50 /// Storage containing all OOXML signatures, unused for ODF.
51 css::uno::Reference<css::embed::XStorage> mxTempSignatureStorage;
52 css::uno::Reference<css::xml::crypto::XSEInitializer> mxSEInitializer;
53 css::uno::Reference<css::xml::crypto::XXMLSecurityContext> mxSecurityContext;
54 css::uno::Reference<css::xml::crypto::XSEInitializer> mxGpgSEInitializer;
55 css::uno::Reference<css::xml::crypto::XXMLSecurityContext> mxGpgSecurityContext;
57 DocumentSignatureManager(const css::uno::Reference<css::uno::XComponentContext>& xContext,
58 DocumentSignatureMode eMode);
59 ~DocumentSignatureManager();
60 /**
61 * Checks if a particular stream is a valid xml stream. Those are treated
62 * differently when they are signed (c14n transformation)
64 bool isXML(const OUString& rURI);
65 SignatureStreamHelper ImplOpenSignatureStream(sal_Int32 nStreamOpenMode, bool bTempStream);
66 /// Add a new signature, using xCert as a signing certificate, and rDescription as description.
67 bool add(const css::uno::Reference<css::security::XCertificate>& xCert,
68 const css::uno::Reference<css::xml::crypto::XXMLSecurityContext>& xSecurityContext,
69 const OUString& rDescription, sal_Int32& nSecurityId, bool bAdESCompliant,
70 const OUString& rSignatureLineId = OUString(),
71 const css::uno::Reference<css::graphic::XGraphic> xValidGraphic
72 = css::uno::Reference<css::graphic::XGraphic>(),
73 const css::uno::Reference<css::graphic::XGraphic> xInvalidGraphic
74 = css::uno::Reference<css::graphic::XGraphic>());
75 /// Remove signature at nPosition.
76 void remove(sal_uInt16 nPosition);
77 /// Read signatures from either a temp stream or the real storage.
78 void read(bool bUseTempStream, bool bCacheLastSignature = true);
79 /// Write signatures back to the persistent storage.
80 void write(bool bXAdESCompliantIfODF);
81 /// Lazy creation of PDF helper.
82 PDFSignatureHelper& getPDFSignatureHelper();
83 #if 0
84 // Checks if the document is a kind where it is relevant to distinguish between using XAdES or not
85 bool IsXAdESRelevant();
86 #endif
87 /// Attempts to initialize the platform-specific crypto.
88 bool init();
89 /// Get the security environment.
90 css::uno::Reference<css::xml::crypto::XSecurityEnvironment> getSecurityEnvironment();
91 css::uno::Reference<css::xml::crypto::XSecurityEnvironment> getGpgSecurityEnvironment();
92 css::uno::Reference<css::xml::crypto::XXMLSecurityContext> const& getSecurityContext();
93 css::uno::Reference<css::xml::crypto::XXMLSecurityContext> const& getGpgSecurityContext();
96 #endif // INCLUDED_XMLSECURITY_INC_DOCUMENTSIGNATUREMANAGER_HXX
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */