Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / xmlsecurity / inc / digitalsignaturesdialog.hxx
blob9f488bb91c9f62c02a90bc3814d4cce098b9f0d6
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_DIGITALSIGNATURESDIALOG_HXX
21 #define INCLUDED_XMLSECURITY_INC_DIGITALSIGNATURESDIALOG_HXX
23 #include <vcl/dialog.hxx>
24 #include <vcl/fixed.hxx>
25 #include <vcl/button.hxx>
26 #include <svtools/simptabl.hxx>
27 #include <com/sun/star/beans/PropertyValue.hpp>
29 #include <documentsignaturehelper.hxx>
30 #include <xmlsignaturehelper.hxx>
31 #include <documentsignaturemanager.hxx>
33 #include <vector>
35 namespace com {
36 namespace sun {
37 namespace star {
38 namespace lang {
39 class XMultiServiceFactory; }
40 namespace io {
41 class XStream; }
42 namespace embed {
43 class XStorage; }
44 namespace xml { namespace dom {
45 class XDocumentBuilder; } }
46 }}}
49 class HeaderBar;
51 class DigitalSignaturesDialog : public ModalDialog
53 private:
54 css::uno::Reference< css::uno::XComponentContext >& mxCtx;
56 DocumentSignatureManager maSignatureManager;
57 bool mbVerifySignatures;
58 bool mbSignaturesChanged;
60 VclPtr<FixedText> m_pHintDocFT;
61 VclPtr<FixedText> m_pHintBasicFT;
62 VclPtr<FixedText> m_pHintPackageFT;
63 VclPtr<SvSimpleTable> m_pSignaturesLB;
64 VclPtr<FixedImage> m_pSigsValidImg;
65 VclPtr<FixedText> m_pSigsValidFI;
66 VclPtr<FixedImage> m_pSigsInvalidImg;
67 VclPtr<FixedText> m_pSigsInvalidFI;
68 VclPtr<FixedImage> m_pSigsNotvalidatedImg;
69 VclPtr<FixedText> m_pSigsNotvalidatedFI;
70 VclPtr<FixedImage> m_pSigsOldSignatureImg;
71 VclPtr<FixedText> m_pSigsOldSignatureFI;
73 VclPtr<CheckBox> m_pAdESCompliantCB;
75 VclPtr<PushButton> m_pViewBtn;
76 VclPtr<PushButton> m_pAddBtn;
77 VclPtr<PushButton> m_pRemoveBtn;
78 VclPtr<PushButton> m_pStartCertMgrBtn;
80 VclPtr<CloseButton> m_pCloseBtn;
82 OUString m_sODFVersion;
83 //Signals if the document contains already a document signature. This is only
84 //important when we are signing macros and if the value is true.
85 bool m_bHasDocumentSignature;
86 bool m_bWarningShowSignMacro;
88 bool m_bAdESCompliant;
90 DECL_LINK(AdESCompliantCheckBoxHdl, CheckBox&, void);
91 DECL_LINK(ViewButtonHdl, Button*, void);
92 DECL_LINK(AddButtonHdl, Button*, void);
93 DECL_LINK(RemoveButtonHdl, Button*, void);
94 DECL_LINK(SignatureHighlightHdl, SvTreeListBox*, void );
95 DECL_LINK(SignatureSelectHdl, SvTreeListBox*, bool );
96 DECL_LINK(StartVerifySignatureHdl, LinkParamNone*, bool );
97 DECL_LINK(OKButtonHdl, Button*, void );
98 DECL_STATIC_LINK(DigitalSignaturesDialog, CertMgrButtonHdl, Button*, void );
100 void ImplGetSignatureInformations(bool bUseTempStream, bool bCacheLastSignature);
101 void ImplFillSignaturesBox();
102 void ImplShowSignaturesDetails();
104 css::uno::Reference<css::security::XCertificate> getCertificate(const SignatureInformation& rInfo);
105 css::uno::Reference<css::xml::crypto::XSecurityEnvironment> getSecurityEnvironmentForCertificate(
106 const css::uno::Reference<css::security::XCertificate>& xCert);
108 //Checks if adding is allowed.
109 //See the spec at specs/www/appwide/security/Electronic_Signatures_and_Security.sxw
110 //(6.6.2)Behaviour with regard to ODF 1.2
111 bool canAdd();
112 bool canRemove();
114 bool canAddRemove();
116 public:
117 DigitalSignaturesDialog( vcl::Window* pParent, css::uno::Reference<
118 css::uno::XComponentContext >& rxCtx, DocumentSignatureMode eMode,
119 bool bReadOnly, const OUString& sODFVersion, bool bHasDocumentSignature);
120 virtual ~DigitalSignaturesDialog() override;
121 virtual void dispose() override;
123 // Initialize the dialog and the security environment, returns TRUE on success
124 bool Init();
126 // Set the storage which should be signed or verified
127 void SetStorage( const css::uno::Reference < css::embed::XStorage >& rxStore );
128 void SetSignatureStream( const css::uno::Reference < css::io::XStream >& rxStream );
130 // Execute the dialog...
131 short Execute() override;
133 // Did signatures change?
134 bool SignaturesChanged() const { return mbSignaturesChanged; }
137 #endif // INCLUDED_XMLSECURITY_INC_DIGITALSIGNATURESDIALOG_HXX
139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */