xref: /AOO41X/main/xmlsecurity/source/dialogs/warnings.cxx (revision 06b3ce531745799678cf4bb887ef37436d81238b)
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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_xmlsecurity.hxx"
26 
27 #include <xmlsecurity/warnings.hxx>
28 #include <xmlsecurity/certificateviewer.hxx>
29 #include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
30 #include <comphelper/sequence.hxx>
31 
32 // MM : added for password exception
33 #include <vcl/msgbox.hxx>
34 #include <com/sun/star/security/NoPasswordException.hpp>
35 using namespace ::com::sun::star::security;
36 
37 
38 #include "dialogs.hrc"
39 #include "resourcemanager.hxx"
40 
41 /* HACK: disable some warnings for MS-C */
42 #ifdef _MSC_VER
43 #pragma warning (disable : 4355)    // 4355: this used in initializer-list
44 #endif
45 
46 using namespace ::com::sun::star;
47 using namespace ::com::sun::star;
48 
49 
MacroWarning(Window * _pParent,uno::Reference<dcss::xml::crypto::XSecurityEnvironment> & _rxSecurityEnvironment,cssu::Reference<dcss::security::XCertificate> & _rxCert)50 MacroWarning::MacroWarning( Window* _pParent, uno::Reference< dcss::xml::crypto::XSecurityEnvironment >& _rxSecurityEnvironment, cssu::Reference< dcss::security::XCertificate >& _rxCert )
51     :ModalDialog        ( _pParent, XMLSEC_RES( RID_XMLSECTP_MACROWARN ) )
52     ,maDocNameFI        ( this, ResId( FI_DOCNAME ) )
53     ,maDescr1aFI        ( this, ResId( FI_DESCR1A ) )
54     ,maDescr1bFI        ( this, ResId( FI_DESCR1B ) )
55     ,maSignsFI          ( this, ResId( FI_SIGNS ) )
56     ,maViewSignsBtn     ( this, ResId( PB_VIEWSIGNS ) )
57     ,maDescr2FI         ( this, ResId( FI_DESCR2 ) )
58     ,maAlwaysTrustCB    ( this, ResId( CB_ALWAYSTRUST ) )
59     ,maBottomSepFL      ( this, ResId( FL_BOTTOM_SEP ) )
60     ,maEnableBtn        ( this, ResId( PB_DISABLE ) )
61     ,maDisableBtn       ( this, ResId( PB_DISABLE ) )
62     ,maHelpBtn          ( this, ResId( BTN_HELP ) )
63     ,mbSignedMode       ( true )
64 {
65     FreeResource();
66 
67     mxSecurityEnvironment = _rxSecurityEnvironment;
68     mxCert = _rxCert;
69 
70     // hide unused parts
71     maDescr1bFI.Hide();
72 
73     maViewSignsBtn.SetClickHdl( LINK( this, MacroWarning, ViewSignsBtnHdl ) );
74     maEnableBtn.SetClickHdl( LINK( this, MacroWarning, EnableBtnHdl ) );
75 //  maDisableBtn.SetClickHdl( LINK( this, MacroWarning, DisableBtnHdl ) );
76 
77     if( mxCert.is() )
78         maSignsFI.SetText( XmlSec::GetContentPart( mxCert->getSubjectName() ) );
79     else
80         // nothing to view!
81         maViewSignsBtn.Disable();
82 }
83 
MacroWarning(Window * _pParent)84 MacroWarning::MacroWarning( Window* _pParent )
85     :ModalDialog        ( _pParent, XMLSEC_RES( RID_XMLSECTP_MACROWARN ) )
86     ,maDocNameFI        ( this, ResId( FI_DOCNAME ) )
87     ,maDescr1aFI        ( this, ResId( FI_DESCR1A ) )
88     ,maDescr1bFI        ( this, ResId( FI_DESCR1B ) )
89     ,maSignsFI          ( this, ResId( FI_SIGNS ) )
90     ,maViewSignsBtn     ( this, ResId( PB_VIEWSIGNS ) )
91     ,maDescr2FI         ( this, ResId( FI_DESCR2 ) )
92     ,maAlwaysTrustCB    ( this, ResId( CB_ALWAYSTRUST ) )
93     ,maBottomSepFL      ( this, ResId( FL_BOTTOM_SEP ) )
94     ,maEnableBtn        ( this, ResId( PB_DISABLE ) )
95     ,maDisableBtn       ( this, ResId( PB_DISABLE ) )
96     ,maHelpBtn          ( this, ResId( BTN_HELP ) )
97     ,mbSignedMode       ( false )
98 {
99     FreeResource();
100 
101     // hide unused parts
102     maDescr1aFI.Hide();
103     maSignsFI.Hide();
104     maViewSignsBtn.Hide();
105     maAlwaysTrustCB.Hide();
106     maDescr2FI.Hide();
107 
108     // move hint up to position of signer list
109     maDescr1bFI.SetPosPixel( maSignsFI.GetPosPixel() );
110 }
111 
~MacroWarning()112 MacroWarning::~MacroWarning()
113 {
114 }
115 
IMPL_LINK(MacroWarning,ViewSignsBtnHdl,void *,EMPTYARG)116 IMPL_LINK( MacroWarning, ViewSignsBtnHdl, void*, EMPTYARG )
117 {
118     DBG_ASSERT( mxCert.is(), "*MacroWarning::ViewSignsBtnHdl(): no certificate set!" );
119 
120     CertificateViewer   aViewer( this, mxSecurityEnvironment, mxCert );
121     aViewer.Execute();
122 
123     return 0;
124 }
125 
IMPL_LINK(MacroWarning,EnableBtnHdl,void *,EMPTYARG)126 IMPL_LINK( MacroWarning, EnableBtnHdl, void*, EMPTYARG )
127 {
128     if( mbSignedMode && maAlwaysTrustCB.IsChecked() )
129     {   // insert path into trusted path list
130 
131     }
132 
133     EndDialog( RET_OK );
134     return 0;
135 }
136 
137 /*IMPL_LINK( MacroWarning, DisableBtnHdl, void*, EMPTYARG )
138 {
139     return 0;
140 }*/
141 
142