1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: certificateviewer.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmlsecurity.hxx"
33 #include <xmlsecurity/certificateviewer.hxx>
34 #include <com/sun/star/security/XCertificate.hpp>
36 #include <com/sun/star/security/CertificateCharacters.hpp>
37 #include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
38 #include <com/sun/star/security/CertificateValidity.hpp>
40 #include <unotools/localedatawrapper.hxx>
41 #include <unotools/datetime.hxx>
43 #include "dialogs.hrc"
44 #include "resourcemanager.hxx"
46 /* HACK: disable some warnings for MS-C */
48 #pragma warning (disable : 4355) // 4355: this used in initializer-list
51 using namespace ::com::sun::star
;
52 using namespace ::com::sun::star::uno
;
53 namespace css
= ::com::sun::star
;
58 void ShrinkToFit( FixedImage
& _rImage
);
59 void AdjustPosAndSize( Control
& _rCtrl
, Point
& _rStartIn_EndOut
, long _nXOffset
= 0 );
61 void ShrinkToFit( FixedImage
& _rImg
)
63 _rImg
.SetSizePixel( _rImg
.GetImage().GetSizePixel() );
66 void AdjustPosAndSize( Control
& _rCtrl
, Point
& _rStartIn_EndOut
, long _nOffs
)
68 _rCtrl
.SetPosPixel( _rStartIn_EndOut
);
69 _rStartIn_EndOut
.X() += XmlSec::ShrinkToFitWidth( _rCtrl
, _nOffs
);
73 CertificateViewer::CertificateViewer(
75 const cssu::Reference
< dcss::xml::crypto::XSecurityEnvironment
>& _rxSecurityEnvironment
,
76 const cssu::Reference
< dcss::security::XCertificate
>& _rXCert
, BOOL bCheckForPrivateKey
)
77 :TabDialog ( _pParent
, XMLSEC_RES( RID_XMLSECDLG_CERTVIEWER
) )
78 ,maTabCtrl ( this, XMLSEC_RES( 1 ) )
79 ,maOkBtn ( this, XMLSEC_RES( BTN_OK
) )
80 ,maHelpBtn ( this, XMLSEC_RES( BTN_HELP
) )
84 mbCheckForPrivateKey
= bCheckForPrivateKey
;
86 mxSecurityEnvironment
= _rxSecurityEnvironment
;
89 maTabCtrl
.SetTabPage( RID_XMLSECTP_GENERAL
, new CertificateViewerGeneralTP( &maTabCtrl
, this ) );
90 maTabCtrl
.SetTabPage( RID_XMLSECTP_DETAILS
, new CertificateViewerDetailsTP( &maTabCtrl
, this ) );
91 maTabCtrl
.SetTabPage( RID_XMLSECTP_CERTPATH
, new CertificateViewerCertPathTP( &maTabCtrl
, this ) );
92 maTabCtrl
.SetCurPageId( RID_XMLSECTP_GENERAL
);
95 CertificateViewer::~CertificateViewer()
97 delete maTabCtrl
.GetTabPage( RID_XMLSECTP_CERTPATH
);
98 delete maTabCtrl
.GetTabPage( RID_XMLSECTP_DETAILS
);
99 delete maTabCtrl
.GetTabPage( RID_XMLSECTP_GENERAL
);
102 CertificateViewerTP::CertificateViewerTP( Window
* _pParent
, const ResId
& _rResId
, CertificateViewer
* _pDlg
)
103 :TabPage ( _pParent
, _rResId
)
109 CertificateViewerGeneralTP::CertificateViewerGeneralTP( Window
* _pParent
, CertificateViewer
* _pDlg
)
110 :CertificateViewerTP ( _pParent
, XMLSEC_RES( RID_XMLSECTP_GENERAL
), _pDlg
)
111 ,maFrameWin ( this, XMLSEC_RES( WIN_FRAME
) )
112 ,maCertImg ( this, XMLSEC_RES( IMG_CERT
) )
113 ,maCertInfoFI ( this, XMLSEC_RES( FI_CERTINFO
) )
114 ,maSep1FL ( this, XMLSEC_RES( FL_SEP1
) )
115 ,maHintNotTrustedFI ( this, XMLSEC_RES( FI_HINTNOTTRUST
) )
116 ,maSep2FL ( this, XMLSEC_RES( FL_SEP2
) )
117 ,maIssuedToLabelFI ( this, XMLSEC_RES( FI_ISSTOLABEL
) )
118 ,maIssuedToFI ( this, XMLSEC_RES( FI_ISSTO
) )
119 ,maIssuedByLabelFI ( this, XMLSEC_RES( FI_ISSBYLABEL
) )
120 ,maIssuedByFI ( this, XMLSEC_RES( FI_ISSBY
) )
121 ,maValidDateFI ( this, XMLSEC_RES( FI_VALIDDATE
) )
122 ,maKeyImg ( this, XMLSEC_RES( IMG_KEY
) )
123 ,maHintCorrespPrivKeyFI ( this, XMLSEC_RES( FI_CORRPRIVKEY
) )
125 if ( GetSettings().GetStyleSettings().GetWindowColor().IsDark() )
126 maKeyImg
.SetImage( Image( XMLSEC_RES( IMG_KEY_HC
) ) );
128 //Verify the certificate
129 sal_Int32 certStatus
= mpDlg
->mxSecurityEnvironment
->verifyCertificate(mpDlg
->mxCert
,
130 Sequence
<Reference
<css::security::XCertificate
> >());
131 //We currently have two status
132 //These errors are alloweds
133 sal_Int32 validCertErrors
= css::security::CertificateValidity::VALID
134 | css::security::CertificateValidity::UNKNOWN_REVOKATION
;
136 //Build a mask to filter out the allowed errors
137 sal_Int32 mask
= ~validCertErrors
;
138 // "subtract" the allowed error flags from the result
139 sal_Int32 certErrors
= certStatus
& mask
;
140 bool bCertValid
= certErrors
> 0 ? false : true;
142 bool bIsDark
= ( GetSettings().GetStyleSettings().GetWindowColor().IsDark() != FALSE
);
146 Image( XMLSEC_RES( bIsDark
? IMG_STATE_NOT_VALIDATED_HC
: IMG_STATE_NOT_VALIDATED
) ) );
147 maHintNotTrustedFI
.SetText( String( XMLSEC_RES( STR_CERTIFICATE_NOT_VALIDATED
) ) );
150 maCertImg
.SetImage( Image( XMLSEC_RES( IMG_STATE_CERIFICATED_HC
) ) );
154 Wallpaper
aBack( GetSettings().GetStyleSettings().GetWindowColor() );
155 maFrameWin
.SetBackground( aBack
);
156 maCertImg
.SetBackground( aBack
);
157 maCertInfoFI
.SetBackground( aBack
);
158 maSep1FL
.SetBackground( aBack
);
159 maHintNotTrustedFI
.SetBackground( aBack
);
160 maSep2FL
.SetBackground( aBack
);
161 maIssuedToLabelFI
.SetBackground( aBack
);
162 maIssuedToFI
.SetBackground( aBack
);
163 maIssuedByLabelFI
.SetBackground( aBack
);
164 maIssuedByFI
.SetBackground( aBack
);
165 maValidDateFI
.SetBackground( aBack
);
166 maKeyImg
.SetBackground( aBack
);
167 maHintCorrespPrivKeyFI
.SetBackground( aBack
);
170 Font
aFnt( maCertInfoFI
.GetFont() );
171 aFnt
.SetWeight( WEIGHT_BOLD
);
172 maCertInfoFI
.SetFont( aFnt
);
173 maHintNotTrustedFI
.SetFont( aFnt
);
174 maIssuedToLabelFI
.SetFont( aFnt
);
175 maIssuedByLabelFI
.SetFont( aFnt
);
176 maValidDateFI
.SetFont( aFnt
);
179 cssu::Reference
< dcss::security::XCertificate
> xCert
= mpDlg
->mxCert
;
181 maIssuedToFI
.SetText( XmlSec::GetContentPart( xCert
->getSubjectName() ) );
182 maIssuedByFI
.SetText( XmlSec::GetContentPart( xCert
->getIssuerName() ) );
184 // dynamic length because of the different languages
185 long nWidth1
= maIssuedToLabelFI
.GetTextWidth( maIssuedToLabelFI
.GetText() );
186 long nWidth2
= maIssuedByLabelFI
.GetTextWidth( maIssuedByLabelFI
.GetText() );
187 long nNewWidth
= Max( nWidth1
, nWidth2
) + 5;
188 Size aNewSize
= maIssuedToLabelFI
.GetSizePixel();
189 aNewSize
.Width() = nNewWidth
;
190 maIssuedToLabelFI
.SetSizePixel( aNewSize
);
191 maIssuedByLabelFI
.SetSizePixel( aNewSize
);
192 long nNewX
= maIssuedToLabelFI
.GetPosPixel().X() + nNewWidth
+ 1;
193 Point aNewPos
= maIssuedToFI
.GetPosPixel();
195 maIssuedToFI
.SetPosPixel( aNewPos
);
196 aNewPos
= maIssuedByFI
.GetPosPixel();
198 maIssuedByFI
.SetPosPixel( aNewPos
);
199 nNewWidth
= maValidDateFI
.GetSizePixel().Width() - nNewX
;
200 aNewSize
= maIssuedToFI
.GetSizePixel();
201 aNewSize
.Width() = nNewWidth
;
202 maIssuedToFI
.SetSizePixel( aNewSize
);
203 maIssuedByFI
.SetSizePixel( aNewSize
);
205 DateTime aDateTimeStart
;
206 DateTime aDateTimeEnd
;
207 utl::typeConvert( xCert
->getNotValidBefore(), aDateTimeStart
);
208 utl::typeConvert( xCert
->getNotValidAfter(), aDateTimeEnd
);
209 String sText
= maValidDateFI
.GetText();
210 sText
.SearchAndReplace( String::CreateFromAscii( "%SDATE%" ),
211 GetSettings().GetUILocaleDataWrapper().getDate( aDateTimeStart
.GetDate() ) );
212 sText
.SearchAndReplace( String::CreateFromAscii( "%EDATE%" ),
213 GetSettings().GetUILocaleDataWrapper().getDate( aDateTimeEnd
.GetDate() ) );
214 maValidDateFI
.SetText( sText
);
216 // adjust position of fixed text depending on image sizes
217 ShrinkToFit( maCertImg
);
218 ShrinkToFit( maKeyImg
);
219 XmlSec::AlignAfterImage( maCertImg
, maCertInfoFI
, 12 );
220 XmlSec::AlignAfterImage( maKeyImg
, maHintCorrespPrivKeyFI
, 12 );
222 // Check if we have the private key...
223 BOOL bHasPrivateKey
= FALSE
;
224 // #i41270# Check only if we have that certificate in our security environment
225 if ( _pDlg
->mbCheckForPrivateKey
)
227 long nCertificateCharacters
= _pDlg
->mxSecurityEnvironment
->getCertificateCharacters( xCert
);
228 bHasPrivateKey
= ( nCertificateCharacters
& security::CertificateCharacters::HAS_PRIVATE_KEY
) ? TRUE
: FALSE
;
230 if ( !bHasPrivateKey
)
233 maHintCorrespPrivKeyFI
.Hide();
237 void CertificateViewerGeneralTP::ActivatePage()
243 struct Details_UserDatat
246 bool mbFixedWidthFont
;
248 inline Details_UserDatat( const String
& _rTxt
, bool _bFixedWidthFont
);
251 inline Details_UserDatat::Details_UserDatat( const String
& _rTxt
, bool _bFixedWidthFont
)
253 ,mbFixedWidthFont ( _bFixedWidthFont
)
258 void CertificateViewerDetailsTP::Clear( void )
260 maElementML
.SetText( String() );
262 SvLBoxEntry
* pEntry
= maElementsLB
.GetEntry( i
);
265 delete ( Details_UserDatat
* ) pEntry
->GetUserData();
267 pEntry
= maElementsLB
.GetEntry( i
);
270 maElementsLB
.Clear();
273 void CertificateViewerDetailsTP::InsertElement( const String
& _rField
, const String
& _rValue
,
274 const String
& _rDetails
, bool _bFixedWidthFont
)
276 SvLBoxEntry
* pEntry
= maElementsLB
.InsertEntry( _rField
);
277 maElementsLB
.SetEntryText( _rValue
, pEntry
, 1 );
278 pEntry
->SetUserData( ( void* ) new Details_UserDatat( _rDetails
, _bFixedWidthFont
) );
281 CertificateViewerDetailsTP::CertificateViewerDetailsTP( Window
* _pParent
, CertificateViewer
* _pDlg
)
282 :CertificateViewerTP ( _pParent
, XMLSEC_RES( RID_XMLSECTP_DETAILS
), _pDlg
)
283 ,maElementsLB ( this, XMLSEC_RES( LB_ELEMENTS
) )
284 ,maElementML ( this, XMLSEC_RES( ML_ELEMENT
) )
285 ,maStdFont ( maElementML
.GetControlFont() )
286 ,maFixedWidthFont ( OutputDevice::GetDefaultFont( DEFAULTFONT_UI_FIXED
, LANGUAGE_DONTKNOW
, DEFAULTFONT_FLAGS_ONLYONE
, this ) )
288 WinBits nStyle
= maElementsLB
.GetStyle();
289 nStyle
&= ~WB_HSCROLL
;
290 maElementsLB
.SetStyle( nStyle
);
292 maFixedWidthFont
.SetHeight( maStdFont
.GetHeight() );
294 static long nTabs
[] = { 2, 0, 30*CS_LB_WIDTH
/100 };
295 maElementsLB
.SetTabs( &nTabs
[ 0 ] );
296 maElementsLB
.InsertHeaderEntry( String( XMLSEC_RES( STR_HEADERBAR
) ) );
299 Reference
< security::XCertificate
> xCert
= mpDlg
->mxCert
;
300 UINT16 nLineBreak
= 16;
301 const char* pHexSep
= " ";
304 // --> PB 2004-10-11 #i35107# - 0 == "V1", 1 == "V2", ..., n = "V(n+1)"
305 aLBEntry
= String::CreateFromAscii( "V" );
306 aLBEntry
+= String::CreateFromInt32( xCert
->getVersion() + 1 );
308 InsertElement( String( XMLSEC_RES( STR_VERSION
) ), aLBEntry
, aLBEntry
);
309 Sequence
< sal_Int8
> aSeq
= xCert
->getSerialNumber();
310 aLBEntry
= XmlSec::GetHexString( aSeq
, pHexSep
);
311 aDetails
= XmlSec::GetHexString( aSeq
, pHexSep
, nLineBreak
);
312 InsertElement( String( XMLSEC_RES( STR_SERIALNUM
) ), aLBEntry
, aDetails
, true );
314 std::pair
< ::rtl::OUString
, ::rtl::OUString
> pairIssuer
=
315 XmlSec::GetDNForCertDetailsView(xCert
->getIssuerName());
316 aLBEntry
= pairIssuer
.first
;
317 aDetails
= pairIssuer
.second
;
318 InsertElement( String( XMLSEC_RES( STR_ISSUER
) ), aLBEntry
, aDetails
);
320 aSeq = xCert->getIssuerUniqueID();
321 aLBEntry = XmlSec::GetHexString( aSeq, pHexSep );
322 aDetails = XmlSec::GetHexString( aSeq, pHexSep, nLineBreak );
323 InsertElement( String( XMLSEC_RES( STR_ISSUER_ID ) ), aLBEntry, aDetails, true );
327 utl::typeConvert( xCert
->getNotValidBefore(), aDateTime
);
328 aLBEntry
= GetSettings().GetUILocaleDataWrapper().getDate( aDateTime
.GetDate() );
329 aLBEntry
+= String::CreateFromAscii( " " );
330 aLBEntry
+= GetSettings().GetUILocaleDataWrapper().getTime( aDateTime
.GetTime() );
331 InsertElement( String( XMLSEC_RES( STR_VALIDFROM
) ), aLBEntry
, aLBEntry
);
332 utl::typeConvert( xCert
->getNotValidAfter(), aDateTime
);
333 aLBEntry
= GetSettings().GetUILocaleDataWrapper().getDate( aDateTime
.GetDate() );
334 aLBEntry
+= String::CreateFromAscii( " " );
335 aLBEntry
+= GetSettings().GetUILocaleDataWrapper().getTime( aDateTime
.GetTime() );
336 InsertElement( String( XMLSEC_RES( STR_VALIDTO
) ), aLBEntry
, aLBEntry
);
338 std::pair
< ::rtl::OUString
, ::rtl::OUString
> pairSubject
=
339 XmlSec::GetDNForCertDetailsView(xCert
->getSubjectName());
340 aLBEntry
= pairSubject
.first
;
341 aDetails
= pairSubject
.second
;
342 InsertElement( String( XMLSEC_RES( STR_SUBJECT
) ), aLBEntry
, aDetails
);
344 aSeq = xCert->getSubjectUniqueID();
345 aLBEntry = XmlSec::GetHexString( aSeq, pHexSep );
346 aDetails = XmlSec::GetHexString( aSeq, pHexSep, nLineBreak );
347 InsertElement( String( XMLSEC_RES( STR_SUBJECT_ID ) ), aLBEntry, aDetails, true );
349 aLBEntry
= aDetails
= xCert
->getSubjectPublicKeyAlgorithm();
350 InsertElement( String( XMLSEC_RES( STR_SUBJECT_PUBKEY_ALGO
) ), aLBEntry
, aDetails
);
351 aSeq
= xCert
->getSubjectPublicKeyValue();
352 aLBEntry
= XmlSec::GetHexString( aSeq
, pHexSep
);
353 aDetails
= XmlSec::GetHexString( aSeq
, pHexSep
, nLineBreak
);
354 InsertElement( String( XMLSEC_RES( STR_SUBJECT_PUBKEY_VAL
) ), aLBEntry
, aDetails
, true );
356 aLBEntry
= aDetails
= xCert
->getSignatureAlgorithm();
357 InsertElement( String( XMLSEC_RES( STR_SIGNATURE_ALGO
) ), aLBEntry
, aDetails
);
359 aSeq
= xCert
->getSHA1Thumbprint();
360 aLBEntry
= XmlSec::GetHexString( aSeq
, pHexSep
);
361 aDetails
= XmlSec::GetHexString( aSeq
, pHexSep
, nLineBreak
);
362 InsertElement( String( XMLSEC_RES( STR_THUMBPRINT_SHA1
) ), aLBEntry
, aDetails
, true );
364 aSeq
= xCert
->getMD5Thumbprint();
365 aLBEntry
= XmlSec::GetHexString( aSeq
, pHexSep
);
366 aDetails
= XmlSec::GetHexString( aSeq
, pHexSep
, nLineBreak
);
367 InsertElement( String( XMLSEC_RES( STR_THUMBPRINT_MD5
) ), aLBEntry
, aDetails
, true );
371 maElementsLB
.SetSelectHdl( LINK( this, CertificateViewerDetailsTP
, ElementSelectHdl
) );
374 CertificateViewerDetailsTP::~CertificateViewerDetailsTP()
379 void CertificateViewerDetailsTP::ActivatePage()
383 IMPL_LINK( CertificateViewerDetailsTP
, ElementSelectHdl
, void*, EMPTYARG
)
385 SvLBoxEntry
* pEntry
= maElementsLB
.FirstSelected();
387 bool bFixedWidthFont
;
390 const Details_UserDatat
* p
= ( Details_UserDatat
* ) pEntry
->GetUserData();
391 aElementText
= p
->maTxt
;
392 bFixedWidthFont
= p
->mbFixedWidthFont
;
395 bFixedWidthFont
= false;
397 maElementML
.SetFont( bFixedWidthFont
? maFixedWidthFont
: maStdFont
);
398 maElementML
.SetControlFont( bFixedWidthFont
? maFixedWidthFont
: maStdFont
);
399 maElementML
.SetText( aElementText
);
404 struct CertPath_UserData
406 cssu::Reference
< dcss::security::XCertificate
> mxCert
;
410 CertPath_UserData( cssu::Reference
< dcss::security::XCertificate
> xCert
, bool bValid
):
418 CertificateViewerCertPathTP::CertificateViewerCertPathTP( Window
* _pParent
, CertificateViewer
* _pDlg
)
419 :CertificateViewerTP ( _pParent
, XMLSEC_RES( RID_XMLSECTP_CERTPATH
), _pDlg
)
420 ,maCertPathFT ( this, XMLSEC_RES( FT_CERTPATH
) )
421 ,maCertPathLB ( this, XMLSEC_RES( LB_SIGNATURES
) )
422 ,maViewCertPB ( this, XMLSEC_RES( BTN_VIEWCERT
) )
423 ,maCertStatusFT ( this, XMLSEC_RES( FT_CERTSTATUS
) )
424 ,maCertStatusML ( this, XMLSEC_RES( ML_CERTSTATUS
) )
426 ,mbFirstActivateDone ( false )
427 ,maCertImage ( XMLSEC_RES( IMG_CERT_SMALL
) )
428 ,maCertNotValidatedImage( XMLSEC_RES( IMG_CERT_NOTVALIDATED_SMALL
) )
429 ,msCertOK ( XMLSEC_RES( STR_PATH_CERT_OK
) )
430 ,msCertNotValidated ( XMLSEC_RES( STR_PATH_CERT_NOT_VALIDATED
) )
433 if ( GetSettings().GetStyleSettings().GetWindowColor().IsDark() )
435 maCertImage
= Image( XMLSEC_RES( IMG_CERT_SMALL_HC
) );
436 maCertNotValidatedImage
= Image( XMLSEC_RES( IMG_CERT_NOTVALIDATED_SMALL_HC
) );
441 maCertPathLB
.SetNodeDefaultImages();
442 maCertPathLB
.SetSublistOpenWithLeftRight();
443 maCertPathLB
.SetSelectHdl( LINK( this, CertificateViewerCertPathTP
, CertSelectHdl
) );
444 maViewCertPB
.SetClickHdl( LINK( this, CertificateViewerCertPathTP
, ViewCertHdl
) );
446 // check if buttontext is to wide
447 const long nOffset
= 10;
448 String sText
= maViewCertPB
.GetText();
449 long nTxtW
= maViewCertPB
.GetTextWidth( sText
);
450 if ( sText
.Search( '~' ) == STRING_NOTFOUND
)
452 long nBtnW
= maViewCertPB
.GetSizePixel().Width();
455 // broaden the button
456 long nDelta
= nTxtW
- nBtnW
;
457 Size aNewSize
= maViewCertPB
.GetSizePixel();
458 aNewSize
.Width() += nDelta
;
459 maViewCertPB
.SetSizePixel( aNewSize
);
460 // and give it a new position
461 Point aNewPos
= maViewCertPB
.GetPosPixel();
462 aNewPos
.X() -= nDelta
;
463 maViewCertPB
.SetPosPixel( aNewPos
);
467 CertificateViewerCertPathTP::~CertificateViewerCertPathTP()
472 void CertificateViewerCertPathTP::ActivatePage()
474 if ( !mbFirstActivateDone
)
476 mbFirstActivateDone
= true;
477 Sequence
< Reference
< security::XCertificate
> > aCertPath
=
478 mpParent
->mxSecurityEnvironment
->buildCertificatePath( mpParent
->mxCert
);
479 const Reference
< security::XCertificate
>* pCertPath
= aCertPath
.getConstArray();
482 sal_Int32 i
, nCnt
= aCertPath
.getLength();
483 SvLBoxEntry
* pParent
= NULL
;
486 const Reference
< security::XCertificate
> rCert
= pCertPath
[ --i
];
487 String sName
= XmlSec::GetContentPart( rCert
->getSubjectName() );
488 //Verify the certificate
489 sal_Int32 certStatus
= mpDlg
->mxSecurityEnvironment
->verifyCertificate(rCert
,
490 Sequence
<Reference
<css::security::XCertificate
> >());
491 //We currently have two status
492 //These errors are alloweds
493 sal_Int32 validCertErrors
= css::security::CertificateValidity::VALID
494 | css::security::CertificateValidity::UNKNOWN_REVOKATION
;
496 //Build a mask to filter out the allowed errors
497 sal_Int32 mask
= ~validCertErrors
;
498 // "subtract" the allowed error flags from the result
499 sal_Int32 certErrors
= certStatus
& mask
;
500 bool bCertValid
= certErrors
> 0 ? false : true;
501 pParent
= InsertCert( pParent
, sName
, rCert
, bCertValid
);
504 maCertPathLB
.Select( pParent
);
505 maViewCertPB
.Disable(); // Own certificate selected
509 maCertPathLB
.Expand( pParent
);
510 pParent
= maCertPathLB
.GetParent( pParent
);
513 CertSelectHdl( NULL
);
517 IMPL_LINK( CertificateViewerCertPathTP
, ViewCertHdl
, void*, EMPTYARG
)
519 SvLBoxEntry
* pEntry
= maCertPathLB
.FirstSelected();
522 CertificateViewer
aViewer( this, mpDlg
->mxSecurityEnvironment
, ((CertPath_UserData
*)pEntry
->GetUserData())->mxCert
, FALSE
);
529 IMPL_LINK( CertificateViewerCertPathTP
, CertSelectHdl
, void*, EMPTYARG
)
532 SvLBoxEntry
* pEntry
= maCertPathLB
.FirstSelected();
535 CertPath_UserData
* pData
= (CertPath_UserData
*) pEntry
->GetUserData();
537 sStatus
= pData
->mbValid
? msCertOK
: msCertNotValidated
;
540 maCertStatusML
.SetText( sStatus
);
541 maViewCertPB
.Enable( pEntry
&& ( pEntry
!= maCertPathLB
.Last() ) );
545 void CertificateViewerCertPathTP::Clear( void )
547 maCertStatusML
.SetText( String() );
549 SvLBoxEntry
* pEntry
= maCertPathLB
.GetEntry( i
);
552 delete ( CertPath_UserData
* ) pEntry
->GetUserData();
554 pEntry
= maCertPathLB
.GetEntry( i
);
557 maCertPathLB
.Clear();
560 SvLBoxEntry
* CertificateViewerCertPathTP::InsertCert(
561 SvLBoxEntry
* _pParent
, const String
& _rName
, cssu::Reference
< dcss::security::XCertificate
> rxCert
,
564 Image aImage
= bValid
? maCertImage
: maCertNotValidatedImage
;
565 SvLBoxEntry
* pEntry
= maCertPathLB
.InsertEntry( _rName
, aImage
, aImage
, _pParent
);
566 pEntry
->SetUserData( ( void* ) new CertPath_UserData( rxCert
, bValid
) );