Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / xmlsecurity / inc / documentsignaturehelper.hxx
bloba8f3cb1f5d409dad863ff898704dc12b4ef9a7b4
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_DOCUMENTSIGNATUREHELPER_HXX
21 #define INCLUDED_XMLSECURITY_INC_DOCUMENTSIGNATUREHELPER_HXX
23 #include <com/sun/star/uno/Reference.h>
24 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
25 #include <rtl/ustring.hxx>
26 #include "sigstruct.hxx"
27 #include "xmlsecurity/xmlsecuritydllapi.h"
29 #include <vector>
31 namespace com {
32 namespace sun {
33 namespace star {
34 namespace io {
35 class XStream; }
36 namespace embed {
37 class XStorage; }
38 }}}
40 enum class DocumentSignatureMode
42 Content,
43 Macros,
44 Package
47 enum class DocumentSignatureAlgorithm
49 OOo2,
50 OOo3_0,
51 OOo3_2
54 struct SignatureStreamHelper
56 css::uno::Reference < css::embed::XStorage > xSignatureStorage;
57 css::uno::Reference < css::io::XStream > xSignatureStream;
58 /// If this is embed::StorageFormats::OFOPXML, then it's expected that xSignatureStream is an empty reference.
59 sal_Int32 nStorageFormat;
61 SignatureStreamHelper()
62 : nStorageFormat(0)
67 namespace DocumentSignatureHelper
69 SignatureStreamHelper OpenSignatureStream(
70 const css::uno::Reference < css::embed::XStorage >& rxStore, sal_Int32 nOpenMode,
71 DocumentSignatureMode eDocSigMode );
73 std::vector< OUString > CreateElementList(
74 const css::uno::Reference < css::embed::XStorage >& rxStore,
75 DocumentSignatureMode eMode,
76 const DocumentSignatureAlgorithm mode);
78 bool isODFPre_1_2(const OUString & sODFVersion);
79 bool isOOo3_2_Signature(const SignatureInformation & sigInfo);
81 DocumentSignatureAlgorithm getDocumentAlgorithm(
82 const OUString & sODFVersion, const SignatureInformation & sigInfo);
84 bool CanSignWithGPG(const css::uno::Reference < css::embed::XStorage >& rxStore,
85 const OUString& sOdfVersion);
87 bool checkIfAllFilesAreSigned( const ::std::vector< OUString > & sElementList,
88 const SignatureInformation & sigInfo, const DocumentSignatureAlgorithm alg);
90 bool equalsReferenceUriManifestPath(
91 const OUString & rUri, const OUString & rPath);
93 OUString GetDocumentContentSignatureDefaultStreamName();
94 OUString GetScriptingContentSignatureDefaultStreamName();
95 OUString GetPackageSignatureDefaultStreamName();
97 /// In case the storage is OOXML, prepend a leading '/' and append content type to the element URIs.
98 void AppendContentTypes(const css::uno::Reference<css::embed::XStorage>& xStorage, std::vector<OUString>& rElements);
100 void writeDigestMethod(
101 const css::uno::Reference<css::xml::sax::XDocumentHandler>& xDocumentHandler);
102 void writeSignedProperties(
103 const css::uno::Reference<css::xml::sax::XDocumentHandler>& xDocumentHandler,
104 const SignatureInformation& signatureInfo,
105 const OUString& sDate);
108 #endif // INCLUDED_XMLSECURITY_INC_DOCUMENTSIGNATUREHELPER_HXX
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */