xref: /AOO41X/main/xmlsecurity/inc/xmlsecurity/digitalsignaturesdialog.hxx (revision ec61c6ed669d81c7df08233ccc38d0040f129ece)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _XMLSECURITY_DIGITALSIGNATURESDIALOG_HXX
25 #define _XMLSECURITY_DIGITALSIGNATURESDIALOG_HXX
26 
27 #include <vcl/dialog.hxx>
28 #include <vcl/fixed.hxx>
29 #include <vcl/button.hxx>
30 #include <svtools/stdctrl.hxx>
31 #include <svx/simptabl.hxx>
32 #include <com/sun/star/beans/PropertyValue.hpp>
33 
34 #include <xmlsecurity/documentsignaturehelper.hxx>
35 #include <xmlsecurity/xmlsignaturehelper.hxx>
36 
37 
38 #ifndef _STLP_VECTOR
39 #include <vector>
40 #endif
41 
42 namespace com {
43 namespace sun {
44 namespace star {
45 namespace lang {
46     class XMultiServiceFactory; }
47 namespace io {
48     class XStream; }
49 namespace embed {
50     class XStorage; }
51 namespace xml { namespace dom {
52     class XDocumentBuilder; } }
53 }}}
54 
55 namespace css = com::sun::star;
56 namespace cssu = com::sun::star::uno;
57 
58 class HeaderBar;
59 
60 class DigitalSignaturesDialog : public ModalDialog
61 {
62 private:
63     cssu::Reference< cssu::XComponentContext >& mxCtx;
64     XMLSignatureHelper      maSignatureHelper;
65 
66     css::uno::Reference < css::embed::XStorage > mxStore;
67     css::uno::Reference < css::io::XStream > mxSignatureStream;
68     css::uno::Reference < css::io::XStream > mxTempSignatureStream;
69     SignatureInformations   maCurrentSignatureInformations;
70     bool                    mbVerifySignatures;
71     bool                    mbSignaturesChanged;
72     DocumentSignatureMode   meSignatureMode;
73     css::uno::Sequence < css::uno::Sequence < css::beans::PropertyValue > > m_manifest;
74 
75     FixedText           maHintDocFT;
76     FixedText           maHintBasicFT;
77     FixedText           maHintPackageFT;
78     SvxSimpleTable      maSignaturesLB; // PB 2006/02/02 #i48648 now SvHeaderTabListBox
79     FixedImage          maSigsValidImg;
80     FixedInfo           maSigsValidFI;
81     FixedImage          maSigsInvalidImg;
82     FixedInfo           maSigsInvalidFI;
83     FixedImage          maSigsNotvalidatedImg;
84     FixedInfo           maSigsNotvalidatedFI;
85     FixedInfo           maSigsOldSignatureFI;
86 
87     PushButton          maViewBtn;
88     PushButton          maAddBtn;
89     PushButton          maRemoveBtn;
90 
91     FixedLine           maBottomSepFL;
92     OKButton            maOKBtn;
93     HelpButton          maHelpBtn;
94 
95     ::rtl::OUString m_sODFVersion;
96     //Signals if the document contains already a document signature. This is only
97     //importent when we are signing macros and if the value is true.
98     bool m_bHasDocumentSignature;
99     bool m_bWarningShowSignMacro;
100 
101     DECL_LINK(          ViewButtonHdl, Button* );
102     DECL_LINK(          AddButtonHdl, Button* );
103     DECL_LINK(          RemoveButtonHdl, Button* );
104     DECL_LINK(          SignatureHighlightHdl, void* );
105     DECL_LINK(          SignatureSelectHdl, void* );
106     DECL_LINK(          StartVerifySignatureHdl, void* );
107     DECL_LINK(          OKButtonHdl, void* );
108 
109     void                ImplGetSignatureInformations(bool bUseTempStream);
110     void                ImplFillSignaturesBox();
111     void                ImplShowSignaturesDetails();
112     SignatureStreamHelper ImplOpenSignatureStream( sal_Int32 eStreamMode, bool bTempStream );
113 
114     //Checks if adding is allowed.
115     //See the spec at specs/www/appwide/security/Electronic_Signatures_and_Security.sxw
116     //(6.6.2)Behaviour with regard to ODF 1.2
117     bool canAdd();
118     bool canRemove();
119 
120     //Checks if a particular stream is a valid xml stream. Those are treated differently
121     //when they are signed (c14n transformation)
122     bool isXML(const ::rtl::OUString& rURI );
123     bool canAddRemove();
124 
125 public:
126     DigitalSignaturesDialog( Window* pParent, cssu::Reference<
127         cssu::XComponentContext >& rxCtx, DocumentSignatureMode eMode,
128         sal_Bool bReadOnly, const ::rtl::OUString& sODFVersion, bool bHasDocumentSignature);
129     ~DigitalSignaturesDialog();
130 
131     // Initialize the dialog and the security environment, returns TRUE on success
132     sal_Bool    Init();
133 
134             // Set the storage which should be signed or verified
135     void    SetStorage( const cssu::Reference < css::embed::XStorage >& rxStore );
136     void    SetSignatureStream( const cssu::Reference < css::io::XStream >& rxStream );
137 
138                 // Execute the dialog...
139     short       Execute();
140 
141                 // Did signatures change?
SignaturesChanged() const142     sal_Bool    SignaturesChanged() const { return mbSignaturesChanged; }
143 };
144 
145 #endif // _XMLSECURITY_DIGITALSIGNATURESDIALOG_HXX
146 
147