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_CERTIFICATEVIEWER_HXX
25 #define _XMLSECURITY_CERTIFICATEVIEWER_HXX
26 
27 #include <vcl/fixed.hxx>
28 #include <vcl/button.hxx>
29 #include <vcl/lstbox.hxx>
30 #include <vcl/tabdlg.hxx>
31 #include <vcl/tabctrl.hxx>
32 #include <vcl/tabpage.hxx>
33 #include <svtools/stdctrl.hxx>
34 #include <svx/simptabl.hxx>
35 #include <svtools/svmedit.hxx>
36 
37 namespace com {
38 namespace sun {
39 namespace star {
40 namespace security {
41     class XCertificate; }
42 namespace xml { namespace crypto {
43     class XSecurityEnvironment; }}
44 }}}
45 
46 namespace css = com::sun::star;
47 namespace cssu = com::sun::star::uno;
48 namespace dcss = ::com::sun::star;
49 
50 class CertificateViewer : public TabDialog
51 {
52 private:
53 	friend class CertificateViewerGeneralTP;
54 	friend class CertificateViewerDetailsTP;
55 	friend class CertificateViewerCertPathTP;
56 
57 	TabControl			maTabCtrl;
58 	OKButton			maOkBtn;
59 	HelpButton			maHelpBtn;
60 
61 	sal_Bool				mbCheckForPrivateKey;
62 
63 	cssu::Reference< dcss::xml::crypto::XSecurityEnvironment > mxSecurityEnvironment;
64 	cssu::Reference< dcss::security::XCertificate > mxCert;
65 public:
66 		CertificateViewer( Window* pParent, const cssu::Reference< dcss::xml::crypto::XSecurityEnvironment >& rxSecurityEnvironment, const cssu::Reference< dcss::security::XCertificate >& rXCert, sal_Bool bCheckForPrivateKey );
67 	virtual				~CertificateViewer();
68 };
69 
70 
71 class CertificateViewerTP : public TabPage
72 {
73 protected:
74 	CertificateViewer*	mpDlg;
75 public:
76 	CertificateViewerTP( Window* _pParent, const ResId& _rResId, CertificateViewer* _pDlg );
77 	inline void			SetTabDlg( CertificateViewer* pTabDlg );
78 };
79 
SetTabDlg(CertificateViewer * _pTabDlg)80 inline void CertificateViewerTP::SetTabDlg( CertificateViewer* _pTabDlg )
81 {
82 	mpDlg = _pTabDlg;
83 }
84 
85 
86 class CertificateViewerGeneralTP : public CertificateViewerTP
87 {
88 private:
89 	Window				maFrameWin;
90 	FixedImage			maCertImg;
91 	FixedInfo			maCertInfoFI;
92 	FixedLine			maSep1FL;
93 	FixedInfo			maHintNotTrustedFI;
94 	FixedLine			maSep2FL;
95 	FixedInfo			maIssuedToLabelFI;
96 	FixedInfo			maIssuedToFI;
97 	FixedInfo			maIssuedByLabelFI;
98 	FixedInfo			maIssuedByFI;
99     FixedInfo           maValidDateFI;
100 	FixedImage			maKeyImg;
101 	FixedInfo			maHintCorrespPrivKeyFI;
102 public:
103 						CertificateViewerGeneralTP( Window* pParent, CertificateViewer* _pDlg );
104 
105 	virtual void		ActivatePage();
106 };
107 
108 
109 class CertificateViewerDetailsTP : public CertificateViewerTP
110 {
111 private:
112     SvxSimpleTable      maElementsLB;   // PB 2006/02/02 #i48648 now SvHeaderTabListBox
113 	MultiLineEdit		maElementML;
114 	Font				maStdFont;
115 	Font				maFixedWidthFont;
116 
117 	DECL_LINK(			ElementSelectHdl, void* );
118 	void				Clear( void );
119 	void				InsertElement( const String& _rField, const String& _rValue,
120 										const String& _rDetails, bool _bFixedWidthFont = false );
121 public:
122 						CertificateViewerDetailsTP( Window* pParent, CertificateViewer* _pDlg );
123 	virtual				~CertificateViewerDetailsTP();
124 
125 	virtual void		ActivatePage();
126 };
127 
128 
129 class CertificateViewerCertPathTP : public CertificateViewerTP
130 {
131 private:
132 	FixedText			maCertPathFT;
133 	SvTreeListBox		maCertPathLB;
134     PushButton          maViewCertPB;
135 	FixedText			maCertStatusFT;
136 	MultiLineEdit		maCertStatusML;
137 
138     CertificateViewer*  mpParent;
139     bool                mbFirstActivateDone;
140     Image               maCertImage;
141     Image               maCertNotValidatedImage;
142     String              msCertOK;
143     String              msCertNotValidated;
144 
145 	DECL_LINK(			ViewCertHdl, void* );
146 	DECL_LINK(			CertSelectHdl, void* );
147 	void				Clear( void );
148 	SvLBoxEntry*		InsertCert( SvLBoxEntry* _pParent, const String& _rName,
149                                     cssu::Reference< dcss::security::XCertificate > rxCert,
150                                     bool bValid);
151 
152 public:
153 						CertificateViewerCertPathTP( Window* pParent, CertificateViewer* _pDlg );
154 	virtual				~CertificateViewerCertPathTP();
155 
156 	virtual void		ActivatePage();
157 };
158 
159 
160 #endif // _XMLSECURITY_CERTIFICATEVIEWER_HXX
161 
162