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