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 #ifndef INCLUDED_XMLSECURITY_INC_DIGITALSIGNATURESDIALOG_HXX 21 #define INCLUDED_XMLSECURITY_INC_DIGITALSIGNATURESDIALOG_HXX 22 23 #include <vcl/weld.hxx> 24 #include <com/sun/star/beans/PropertyValue.hpp> 25 26 #include "documentsignaturehelper.hxx" 27 #include "xmlsignaturehelper.hxx" 28 #include "documentsignaturemanager.hxx" 29 30 #include <vector> 31 32 namespace com { 33 namespace sun { 34 namespace star { 35 namespace lang { 36 class XMultiServiceFactory; } 37 namespace io { 38 class XStream; } 39 namespace embed { 40 class XStorage; } 41 namespace xml { namespace dom { 42 class XDocumentBuilder; } } 43 }}} 44 45 46 class HeaderBar; 47 48 class DigitalSignaturesDialog : public weld::GenericDialogController 49 { 50 private: 51 DocumentSignatureManager maSignatureManager; 52 bool mbVerifySignatures; 53 bool mbSignaturesChanged; 54 55 OUString const m_sODFVersion; 56 //Signals if the document contains already a document signature. This is only 57 //important when we are signing macros and if the value is true. 58 bool const m_bHasDocumentSignature; 59 bool m_bWarningShowSignMacro; 60 61 bool m_bAdESCompliant; 62 63 std::unique_ptr<weld::Label> m_xHintDocFT; 64 std::unique_ptr<weld::Label> m_xHintBasicFT; 65 std::unique_ptr<weld::Label> m_xHintPackageFT; 66 std::unique_ptr<weld::TreeView> m_xSignaturesLB; 67 std::unique_ptr<weld::Image> m_xSigsValidImg; 68 std::unique_ptr<weld::Label> m_xSigsValidFI; 69 std::unique_ptr<weld::Image> m_xSigsInvalidImg; 70 std::unique_ptr<weld::Label> m_xSigsInvalidFI; 71 std::unique_ptr<weld::Image> m_xSigsNotvalidatedImg; 72 std::unique_ptr<weld::Label> m_xSigsNotvalidatedFI; 73 std::unique_ptr<weld::Image> m_xSigsOldSignatureImg; 74 std::unique_ptr<weld::Label> m_xSigsOldSignatureFI; 75 std::unique_ptr<weld::CheckButton> m_xAdESCompliantCB; 76 std::unique_ptr<weld::Button> m_xViewBtn; 77 std::unique_ptr<weld::Button> m_xAddBtn; 78 std::unique_ptr<weld::Button> m_xRemoveBtn; 79 std::unique_ptr<weld::Button> m_xStartCertMgrBtn; 80 std::unique_ptr<weld::Button> m_xCloseBtn; 81 82 DECL_LINK(AdESCompliantCheckBoxHdl, weld::ToggleButton&, void); 83 DECL_LINK(ViewButtonHdl, weld::Button&, void); 84 DECL_LINK(AddButtonHdl, weld::Button&, void); 85 DECL_LINK(RemoveButtonHdl, weld::Button&, void); 86 DECL_LINK(SignatureHighlightHdl, weld::TreeView&, void); 87 DECL_LINK(SignatureSelectHdl, weld::TreeView&, bool); 88 DECL_LINK(StartVerifySignatureHdl, LinkParamNone*, bool); 89 DECL_LINK(OKButtonHdl, weld::Button&, void); 90 DECL_LINK(CertMgrButtonHdl, weld::Button&, void); 91 92 void ImplGetSignatureInformations(bool bUseTempStream, bool bCacheLastSignature); 93 void ImplFillSignaturesBox(); 94 void ImplShowSignaturesDetails(); 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 108 public: 109 DigitalSignaturesDialog(weld::Window* pParent, const css::uno::Reference< 110 css::uno::XComponentContext >& rxCtx, DocumentSignatureMode eMode, 111 bool bReadOnly, const 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 short run() override; 123 124 // Did signatures change? SignaturesChanged() const125 bool SignaturesChanged() const { return mbSignaturesChanged; } 126 }; 127 128 #endif // INCLUDED_XMLSECURITY_INC_DIGITALSIGNATURESDIALOG_HXX 129 130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 131