LibreOffice Module xmlsecurity (master) 1
digitalsignaturesdialog.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 <vcl/weld.hxx>
23#include <com/sun/star/beans/PropertyValue.hpp>
24
28
29#include <vector>
30
31namespace com::sun::star {
32 namespace lang { class XMultiServiceFactory; }
33 namespace io { class XStream; }
34 namespace embed { class XStorage; }
35 namespace xml::dom { class XDocumentBuilder; }
36}
37
38
39class HeaderBar;
41
43{
44private:
48
49 OUString const m_sODFVersion;
50 //Signals if the document contains already a document signature. This is only
51 //important when we are signing macros and if the value is true.
54
56
57 std::unique_ptr<weld::Label> m_xHintDocFT;
58 std::unique_ptr<weld::Label> m_xHintBasicFT;
59 std::unique_ptr<weld::Label> m_xHintPackageFT;
60 std::unique_ptr<weld::TreeView> m_xSignaturesLB;
61 std::unique_ptr<weld::Image> m_xSigsValidImg;
62 std::unique_ptr<weld::Label> m_xSigsValidFI;
63 std::unique_ptr<weld::Image> m_xSigsInvalidImg;
64 std::unique_ptr<weld::Label> m_xSigsInvalidFI;
65 std::unique_ptr<weld::Image> m_xSigsNotvalidatedImg;
66 std::unique_ptr<weld::Label> m_xSigsNotvalidatedFI;
67 std::unique_ptr<weld::Image> m_xSigsOldSignatureImg;
68 std::unique_ptr<weld::Label> m_xSigsOldSignatureFI;
69 std::unique_ptr<weld::CheckButton> m_xAdESCompliantCB;
70 std::unique_ptr<weld::Button> m_xViewBtn;
71 std::unique_ptr<weld::Button> m_xAddBtn;
72 std::unique_ptr<weld::Button> m_xRemoveBtn;
73 std::unique_ptr<weld::Button> m_xStartCertMgrBtn;
74 std::unique_ptr<weld::Button> m_xCloseBtn;
75
76 std::shared_ptr<CertificateViewer> m_xViewer;
77 std::shared_ptr<weld::MessageDialog> m_xInfoBox;
78
79 DECL_LINK(AdESCompliantCheckBoxHdl, weld::Toggleable&, void);
80 DECL_LINK(ViewButtonHdl, weld::Button&, void);
81 DECL_LINK(AddButtonHdl, weld::Button&, void);
82 DECL_LINK(RemoveButtonHdl, weld::Button&, void);
83 DECL_LINK(SignatureHighlightHdl, weld::TreeView&, void);
84 DECL_LINK(SignatureSelectHdl, weld::TreeView&, bool);
85 DECL_LINK(StartVerifySignatureHdl, LinkParamNone*, bool);
86 DECL_LINK(OKButtonHdl, weld::Button&, void);
87 DECL_LINK(CertMgrButtonHdl, weld::Button&, void);
88
89 void ImplGetSignatureInformations(bool bUseTempStream, bool bCacheLastSignature);
93 void GetCertificateManager(OUString& aPath, OUString& sExecutable, OUString& sFoundGUIServer);
94 bool GetPathAllOS(OUString& aPath);
95
96 css::uno::Reference<css::security::XCertificate> getCertificate(const SignatureInformation& rInfo);
97 css::uno::Reference<css::xml::crypto::XSecurityEnvironment> getSecurityEnvironmentForCertificate(
98 const css::uno::Reference<css::security::XCertificate>& xCert);
99
100 //Checks if adding is allowed.
101 //See the spec at specs/www/appwide/security/Electronic_Signatures_and_Security.sxw
102 //(6.6.2)Behaviour with regard to ODF 1.2
103 bool canAdd();
104 bool canRemove();
105
106 bool canAddRemove();
107
108public:
109 DigitalSignaturesDialog(weld::Window* pParent, const css::uno::Reference<
110 css::uno::XComponentContext >& rxCtx, DocumentSignatureMode eMode,
111 bool bReadOnly, OUString sODFVersion, bool bHasDocumentSignature);
112 virtual ~DigitalSignaturesDialog() override;
113
114 // Initialize the dialog and the security environment, returns TRUE on success
115 bool Init();
116
117 // Set the storage which should be signed or verified
118 void SetStorage( const css::uno::Reference < css::embed::XStorage >& rxStore );
119 void SetSignatureStream( const css::uno::Reference < css::io::XStream >& rxStream );
120
121 // Execute the dialog...
122 void beforeRun();
123 short run() override;
124
125 // Did signatures change?
126 bool SignaturesChanged() const { return mbSignaturesChanged; }
127};
128
129/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< weld::TreeView > m_xSignaturesLB
DECL_LINK(AddButtonHdl, weld::Button &, void)
std::unique_ptr< weld::Button > m_xCloseBtn
DECL_LINK(SignatureHighlightHdl, weld::TreeView &, void)
std::unique_ptr< weld::Label > m_xHintDocFT
std::unique_ptr< weld::Label > m_xSigsInvalidFI
DECL_LINK(StartVerifySignatureHdl, LinkParamNone *, bool)
DECL_LINK(RemoveButtonHdl, weld::Button &, void)
std::unique_ptr< weld::Button > m_xRemoveBtn
DECL_LINK(AdESCompliantCheckBoxHdl, weld::Toggleable &, void)
std::shared_ptr< weld::MessageDialog > m_xInfoBox
std::shared_ptr< CertificateViewer > m_xViewer
DigitalSignaturesDialog(weld::Window *pParent, const css::uno::Reference< css::uno::XComponentContext > &rxCtx, DocumentSignatureMode eMode, bool bReadOnly, OUString sODFVersion, bool bHasDocumentSignature)
std::unique_ptr< weld::CheckButton > m_xAdESCompliantCB
std::unique_ptr< weld::Label > m_xSigsValidFI
std::unique_ptr< weld::Label > m_xHintBasicFT
css::uno::Reference< css::security::XCertificate > getCertificate(const SignatureInformation &rInfo)
std::unique_ptr< weld::Label > m_xHintPackageFT
DECL_LINK(OKButtonHdl, weld::Button &, void)
DECL_LINK(ViewButtonHdl, weld::Button &, void)
DECL_LINK(SignatureSelectHdl, weld::TreeView &, bool)
std::unique_ptr< weld::Image > m_xSigsInvalidImg
void GetCertificateManager(OUString &aPath, OUString &sExecutable, OUString &sFoundGUIServer)
virtual ~DigitalSignaturesDialog() override
bool GetPathAllOS(OUString &aPath)
std::unique_ptr< weld::Image > m_xSigsValidImg
void SetStorage(const css::uno::Reference< css::embed::XStorage > &rxStore)
std::unique_ptr< weld::Image > m_xSigsNotvalidatedImg
std::unique_ptr< weld::Image > m_xSigsOldSignatureImg
void ImplGetSignatureInformations(bool bUseTempStream, bool bCacheLastSignature)
void SetSignatureStream(const css::uno::Reference< css::io::XStream > &rxStream)
DECL_LINK(CertMgrButtonHdl, weld::Button &, void)
std::unique_ptr< weld::Button > m_xViewBtn
DocumentSignatureManager maSignatureManager
std::unique_ptr< weld::Label > m_xSigsNotvalidatedFI
std::unique_ptr< weld::Button > m_xAddBtn
std::unique_ptr< weld::Button > m_xStartCertMgrBtn
std::unique_ptr< weld::Label > m_xSigsOldSignatureFI
css::uno::Reference< css::xml::crypto::XSecurityEnvironment > getSecurityEnvironmentForCertificate(const css::uno::Reference< css::security::XCertificate > &xCert)
Manages signatures (addition, removal), used by DigitalSignaturesDialog.