| 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 | */ |
| 10 | |
| 11 | #pragma once |
| 12 | |
| 13 | #include "xmlsecuritydllapi.h" |
| 14 | |
| 15 | #include <svl/sigstruct.hxx> |
| 16 | |
| 17 | namespace com::sun::star |
| 18 | { |
| 19 | namespace frame |
| 20 | { |
| 21 | class XModel; |
| 22 | } |
| 23 | namespace io |
| 24 | { |
| 25 | class XInputStream; |
| 26 | } |
| 27 | namespace security |
| 28 | { |
| 29 | struct DocumentSignatureInformation; |
| 30 | } |
| 31 | namespace xml::crypto |
| 32 | { |
| 33 | class XSecurityEnvironment; |
| 34 | } |
| 35 | } |
| 36 | namespace svl::crypto |
| 37 | { |
| 38 | class SigningContext; |
| 39 | } |
| 40 | class SvStream; |
| 41 | |
| 42 | /// Handles signatures of a PDF file. |
| 43 | class XMLSECURITY_DLLPUBLIC PDFSignatureHelper |
| 44 | { |
| 45 | SignatureInformations m_aSignatureInfos; |
| 46 | |
| 47 | svl::crypto::SigningContext* m_pSigningContext = nullptr; |
| 48 | OUString m_aDescription; |
| 49 | |
| 50 | public: |
| 51 | PDFSignatureHelper(); |
| 52 | bool ReadAndVerifySignature(const css::uno::Reference<css::io::XInputStream>& xInputStream); |
| 53 | bool ReadAndVerifySignatureSvStream(SvStream& rStream); |
| 54 | css::uno::Sequence<css::security::DocumentSignatureInformation> |
| 55 | GetDocumentSignatureInformations( |
| 56 | const css::uno::Reference<css::xml::crypto::XSecurityEnvironment>& xSecEnv) const; |
| 57 | SignatureInformations const& GetSignatureInformations() const; |
| 58 | |
| 59 | /// Return the ID of the next created signature. |
| 60 | sal_Int32 GetNewSecurityId() const; |
| 61 | /// Certificate to be used next time signing is performed. |
| 62 | void SetX509Certificate(svl::crypto::SigningContext& rSigningContext); |
| 63 | /// Comment / reason to be used next time signing is performed. |
| 64 | void SetDescription(const OUString& rDescription); |
| 65 | /// Append a new signature at the end of xInputStream. |
| 66 | bool Sign(const css::uno::Reference<css::frame::XModel>& xModel, |
| 67 | const css::uno::Reference<css::io::XInputStream>& xInputStream, bool bAdES); |
| 68 | /// Remove the signature at nPosition (and all dependent signatures) from xInputStream. |
| 69 | static bool RemoveSignature(const css::uno::Reference<css::io::XInputStream>& xInputStream, |
| 70 | sal_uInt16 nPosition); |
| 71 | }; |
| 72 | |
| 73 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |