LibreOffice Module xmlsecurity (master) 1
documentsignaturemanager.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include "xmlsecuritydllapi.h"
23
24#include <memory>
25
26#include <svl/sigstruct.hxx>
29
30#include <com/sun/star/xml/crypto/XSEInitializer.hpp>
31#include <unotools/tempfile.hxx>
32
33namespace com::sun::star
34{
35namespace beans
36{
37struct PropertyValue;
38}
39namespace embed
40{
41class XStorage;
42}
43namespace frame
44{
45class XModel;
46}
47namespace graphic
48{
49class XGraphic;
50}
51namespace uno
52{
53class XComponentContext;
54}
55}
57
60{
61private:
62 css::uno::Reference<css::uno::XComponentContext> mxContext;
63 css::uno::Reference<css::embed::XStorage> mxStore;
65 std::unique_ptr<PDFSignatureHelper> mpPDFSignatureHelper;
68 css::uno::Sequence<css::uno::Sequence<css::beans::PropertyValue>> m_manifest;
69 css::uno::Reference<css::io::XStream> mxSignatureStream;
70 css::uno::Reference<css::frame::XModel> mxModel;
73 css::uno::Reference<css::embed::XStorage> mxTempSignatureStorage;
74 css::uno::Reference<css::xml::crypto::XSEInitializer> mxSEInitializer;
75 css::uno::Reference<css::xml::crypto::XXMLSecurityContext> mxSecurityContext;
76 css::uno::Reference<css::xml::crypto::XSEInitializer> mxGpgSEInitializer;
77 css::uno::Reference<css::xml::crypto::XXMLSecurityContext> mxGpgSecurityContext;
78
79public:
80 DocumentSignatureManager(const css::uno::Reference<css::uno::XComponentContext>& xContext,
83
88 bool isXML(std::u16string_view rURI);
89 bool readManifest();
90
91 SignatureStreamHelper ImplOpenSignatureStream(sal_Int32 nStreamOpenMode, bool bTempStream);
93 bool add(const css::uno::Reference<css::security::XCertificate>& xCert,
94 const css::uno::Reference<css::xml::crypto::XXMLSecurityContext>& xSecurityContext,
95 const OUString& rDescription, sal_Int32& nSecurityId, bool bAdESCompliant,
96 const OUString& rSignatureLineId = OUString(),
97 const css::uno::Reference<css::graphic::XGraphic>& xValidGraphic
98 = css::uno::Reference<css::graphic::XGraphic>(),
99 const css::uno::Reference<css::graphic::XGraphic>& xInvalidGraphic
100 = css::uno::Reference<css::graphic::XGraphic>());
102 void remove(sal_uInt16 nPosition);
104 void read(bool bUseTempStream, bool bCacheLastSignature = true);
106 void write(bool bXAdESCompliantIfODF);
108 PDFSignatureHelper& getPDFSignatureHelper();
109#if 0
110 // Checks if the document is a kind where it is relevant to distinguish between using XAdES or not
111 bool IsXAdESRelevant();
112#endif
114 bool init();
116 css::uno::Reference<css::xml::crypto::XSecurityEnvironment> getSecurityEnvironment();
117 css::uno::Reference<css::xml::crypto::XSecurityEnvironment> getGpgSecurityEnvironment();
118 css::uno::Reference<css::xml::crypto::XXMLSecurityContext> const& getSecurityContext() const;
119 css::uno::Reference<css::xml::crypto::XXMLSecurityContext> const& getGpgSecurityContext() const;
120 void setStore(const css::uno::Reference<css::embed::XStorage>& xStore) { mxStore = xStore; }
121 XMLSignatureHelper& getSignatureHelper() { return maSignatureHelper; }
122 bool hasPDFSignatureHelper() const { return bool(mpPDFSignatureHelper); }
123 void setSignatureStream(const css::uno::Reference<css::io::XStream>& xSignatureStream)
124 {
125 mxSignatureStream = xSignatureStream;
126 }
127 void setModel(const css::uno::Reference<css::frame::XModel>& xModel);
128 const css::uno::Reference<css::embed::XStorage>& getStore() const { return mxStore; }
129 DocumentSignatureMode getSignatureMode() const { return meSignatureMode; }
131 {
132 return maCurrentSignatureInformations;
133 }
134};
135
136/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
FILE * init(int, char **)
Manages signatures (addition, removal), used by DigitalSignaturesDialog.
DocumentSignatureMode getSignatureMode() const
css::uno::Reference< css::xml::crypto::XXMLSecurityContext > mxSecurityContext
rtl::Reference< utl::TempFileFastService > mxTempSignatureStream
css::uno::Reference< css::xml::crypto::XXMLSecurityContext > mxGpgSecurityContext
SignatureInformations & getCurrentSignatureInformations()
void setSignatureStream(const css::uno::Reference< css::io::XStream > &xSignatureStream)
std::unique_ptr< PDFSignatureHelper > mpPDFSignatureHelper
css::uno::Reference< css::uno::XComponentContext > mxContext
css::uno::Reference< css::embed::XStorage > mxTempSignatureStorage
Storage containing all OOXML signatures, unused for ODF.
XMLSignatureHelper & getSignatureHelper()
void setStore(const css::uno::Reference< css::embed::XStorage > &xStore)
css::uno::Reference< css::io::XStream > mxSignatureStream
SignatureInformations maCurrentSignatureInformations
css::uno::Reference< css::frame::XModel > mxModel
css::uno::Reference< css::xml::crypto::XSEInitializer > mxSEInitializer
const css::uno::Reference< css::embed::XStorage > & getStore() const
css::uno::Reference< css::embed::XStorage > mxStore
DocumentSignatureMode const meSignatureMode
css::uno::Reference< css::xml::crypto::XSEInitializer > mxGpgSEInitializer
css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > m_manifest
Handles signatures of a PDF file.
OUStringBuffer & remove(OUStringBuffer &rIn, sal_Unicode c)
::std::vector< SignatureInformation > SignatureInformations
#define XMLSECURITY_DLLPUBLIC