1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_xmlsecurity.hxx"
30 
31 #include <xmlsecurity/warnings.hxx>
32 #include <xmlsecurity/certificateviewer.hxx>
33 #include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
34 #include <comphelper/sequence.hxx>
35 
36 // MM : added for password exception
37 #include <vcl/msgbox.hxx>
38 #include <com/sun/star/security/NoPasswordException.hpp>
39 using namespace ::com::sun::star::security;
40 
41 
42 #include "dialogs.hrc"
43 #include "resourcemanager.hxx"
44 
45 /* HACK: disable some warnings for MS-C */
46 #ifdef _MSC_VER
47 #pragma warning (disable : 4355)	// 4355: this used in initializer-list
48 #endif
49 
50 using namespace ::com::sun::star;
51 using namespace ::com::sun::star;
52 
53 
54 MacroWarning::MacroWarning( Window* _pParent, uno::Reference< dcss::xml::crypto::XSecurityEnvironment >& _rxSecurityEnvironment, cssu::Reference< dcss::security::XCertificate >& _rxCert )
55 	:ModalDialog		( _pParent, XMLSEC_RES( RID_XMLSECTP_MACROWARN ) )
56 	,maDocNameFI		( this, ResId( FI_DOCNAME ) )
57 	,maDescr1aFI		( this, ResId( FI_DESCR1A ) )
58 	,maDescr1bFI		( this, ResId( FI_DESCR1B ) )
59 	,maSignsFI			( this, ResId( FI_SIGNS ) )
60 	,maViewSignsBtn		( this, ResId( PB_VIEWSIGNS ) )
61 	,maDescr2FI			( this, ResId( FI_DESCR2 ) )
62 	,maAlwaysTrustCB	( this, ResId( CB_ALWAYSTRUST ) )
63 	,maBottomSepFL		( this, ResId( FL_BOTTOM_SEP ) )
64 	,maEnableBtn		( this, ResId( PB_DISABLE ) )
65 	,maDisableBtn		( this, ResId( PB_DISABLE ) )
66 	,maHelpBtn			( this, ResId( BTN_HELP ) )
67 	,mbSignedMode		( true )
68 {
69 	FreeResource();
70 
71 	mxSecurityEnvironment = _rxSecurityEnvironment;
72 	mxCert = _rxCert;
73 
74 	// hide unused parts
75 	maDescr1bFI.Hide();
76 
77 	maViewSignsBtn.SetClickHdl( LINK( this, MacroWarning, ViewSignsBtnHdl ) );
78 	maEnableBtn.SetClickHdl( LINK( this, MacroWarning, EnableBtnHdl ) );
79 //	maDisableBtn.SetClickHdl( LINK( this, MacroWarning, DisableBtnHdl ) );
80 
81 	if( mxCert.is() )
82         maSignsFI.SetText( XmlSec::GetContentPart( mxCert->getSubjectName() ) );
83 	else
84 		// nothing to view!
85 		maViewSignsBtn.Disable();
86 }
87 
88 MacroWarning::MacroWarning( Window* _pParent )
89 	:ModalDialog		( _pParent, XMLSEC_RES( RID_XMLSECTP_MACROWARN ) )
90 	,maDocNameFI		( this, ResId( FI_DOCNAME ) )
91 	,maDescr1aFI		( this, ResId( FI_DESCR1A ) )
92 	,maDescr1bFI		( this, ResId( FI_DESCR1B ) )
93 	,maSignsFI			( this, ResId( FI_SIGNS ) )
94 	,maViewSignsBtn		( this, ResId( PB_VIEWSIGNS ) )
95 	,maDescr2FI			( this, ResId( FI_DESCR2 ) )
96 	,maAlwaysTrustCB	( this, ResId( CB_ALWAYSTRUST ) )
97 	,maBottomSepFL		( this, ResId( FL_BOTTOM_SEP ) )
98 	,maEnableBtn		( this, ResId( PB_DISABLE ) )
99 	,maDisableBtn		( this, ResId( PB_DISABLE ) )
100 	,maHelpBtn			( this, ResId( BTN_HELP ) )
101 	,mbSignedMode		( false )
102 {
103 	FreeResource();
104 
105 	// hide unused parts
106 	maDescr1aFI.Hide();
107 	maSignsFI.Hide();
108 	maViewSignsBtn.Hide();
109 	maAlwaysTrustCB.Hide();
110 	maDescr2FI.Hide();
111 
112 	// move hint up to position of signer list
113 	maDescr1bFI.SetPosPixel( maSignsFI.GetPosPixel() );
114 }
115 
116 MacroWarning::~MacroWarning()
117 {
118 }
119 
120 IMPL_LINK( MacroWarning, ViewSignsBtnHdl, void*, EMPTYARG )
121 {
122 	DBG_ASSERT( mxCert.is(), "*MacroWarning::ViewSignsBtnHdl(): no certificate set!" );
123 
124 	CertificateViewer	aViewer( this, mxSecurityEnvironment, mxCert );
125 	aViewer.Execute();
126 
127     return 0;
128 }
129 
130 IMPL_LINK( MacroWarning, EnableBtnHdl, void*, EMPTYARG )
131 {
132 	if( mbSignedMode && maAlwaysTrustCB.IsChecked() )
133 	{	// insert path into trusted path list
134 
135 	}
136 
137 	EndDialog( RET_OK );
138     return 0;
139 }
140 
141 /*IMPL_LINK( MacroWarning, DisableBtnHdl, void*, EMPTYARG )
142 {
143     return 0;
144 }*/
145 
146