LCOV - code coverage report
Current view: top level - xmlsecurity/source/dialogs - certificateviewer.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 279 0.4 %
Date: 2015-06-13 12:38:46 Functions: 2 39 5.1 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <xmlsecurity/certificateviewer.hxx>
      21             : #include <com/sun/star/security/XCertificate.hpp>
      22             : 
      23             : #include <com/sun/star/security/CertificateCharacters.hpp>
      24             : #include <com/sun/star/xml/crypto/XSecurityEnvironment.hpp>
      25             : #include <com/sun/star/security/CertificateValidity.hpp>
      26             : 
      27             : #include <unotools/localedatawrapper.hxx>
      28             : #include <unotools/datetime.hxx>
      29             : #include <svtools/treelistentry.hxx>
      30             : 
      31             : #include "dialogs.hrc"
      32             : #include "resourcemanager.hxx"
      33             : 
      34             : #include <vcl/settings.hxx>
      35             : 
      36             : using namespace ::com::sun::star;
      37             : using namespace ::com::sun::star::uno;
      38             : 
      39           0 : CertificateViewer::CertificateViewer(
      40             :         vcl::Window* _pParent,
      41             :         const css::uno::Reference< css::xml::crypto::XSecurityEnvironment >& _rxSecurityEnvironment,
      42             :         const css::uno::Reference< css::security::XCertificate >& _rXCert, bool bCheckForPrivateKey )
      43           0 :     : TabDialog(_pParent, "ViewCertDialog", "xmlsec/ui/viewcertdialog.ui" )
      44             : {
      45           0 :     get(mpTabCtrl, "tabcontrol");
      46             : 
      47           0 :     mbCheckForPrivateKey = bCheckForPrivateKey;
      48             : 
      49           0 :     mxSecurityEnvironment = _rxSecurityEnvironment;
      50           0 :     mxCert = _rXCert;
      51             : 
      52           0 :     mnGeneralId = mpTabCtrl->GetPageId("general");
      53           0 :     mnDetailsId = mpTabCtrl->GetPageId("details");
      54           0 :     mnPathId = mpTabCtrl->GetPageId("path");
      55             : 
      56           0 :     mpTabCtrl->SetTabPage(mnGeneralId, VclPtr<CertificateViewerGeneralTP>::Create( mpTabCtrl, this));
      57           0 :     mpTabCtrl->SetTabPage(mnDetailsId, VclPtr<CertificateViewerDetailsTP>::Create( mpTabCtrl, this));
      58           0 :     mpTabCtrl->SetTabPage(mnPathId, VclPtr<CertificateViewerCertPathTP>::Create( mpTabCtrl, this));
      59           0 :     mpTabCtrl->SetCurPageId(mnGeneralId);
      60           0 : }
      61             : 
      62           0 : CertificateViewer::~CertificateViewer()
      63             : {
      64           0 :     disposeOnce();
      65           0 : }
      66             : 
      67           0 : void CertificateViewer::dispose()
      68             : {
      69           0 :     mpTabCtrl->GetTabPage(mnGeneralId)->disposeOnce();
      70           0 :     mpTabCtrl->GetTabPage(mnDetailsId)->disposeOnce();
      71           0 :     mpTabCtrl->GetTabPage(mnPathId)->disposeOnce();
      72           0 :     mpTabCtrl.clear();
      73           0 :     TabDialog::dispose();
      74           0 : }
      75             : 
      76           0 : CertificateViewerTP::CertificateViewerTP( vcl::Window* _pParent, const OString& rID,
      77             :     const OUString& rUIXMLDescription, CertificateViewer* _pDlg )
      78             :     : TabPage(_pParent, rID, rUIXMLDescription)
      79           0 :     , mpDlg(_pDlg)
      80             : {
      81           0 : }
      82             : 
      83           0 : CertificateViewerTP::~CertificateViewerTP()
      84             : {
      85           0 :     disposeOnce();
      86           0 : }
      87             : 
      88           0 : void CertificateViewerTP::dispose()
      89             : {
      90           0 :     mpDlg.clear();
      91           0 :     TabPage::dispose();
      92           0 : }
      93             : 
      94             : 
      95           0 : CertificateViewerGeneralTP::CertificateViewerGeneralTP( vcl::Window* _pParent, CertificateViewer* _pDlg )
      96           0 :     :CertificateViewerTP    ( _pParent, "CertGeneral", "xmlsec/ui/certgeneral.ui", _pDlg )
      97             : {
      98           0 :     get( m_pCertImg, "certimage" );
      99           0 :     get( m_pHintNotTrustedFI, "hintnotrust" );
     100           0 :     get( m_pIssuedToFI, "issued_to_value" );
     101           0 :     get( m_pIssuedByFI, "issued_by_value" );
     102           0 :     get( m_pValidFromDateFI, "valid_from_value" );
     103           0 :     get( m_pValidToDateFI, "valid_to_value" );
     104           0 :     get( m_pKeyImg, "keyimage" );
     105           0 :     get( m_pHintCorrespPrivKeyFI, "privatekey" );
     106             : 
     107             :     //Verify the certificate
     108           0 :     sal_Int32 certStatus = mpDlg->mxSecurityEnvironment->verifyCertificate(mpDlg->mxCert,
     109           0 :          Sequence<Reference<css::security::XCertificate> >());
     110             : 
     111           0 :     bool bCertValid = certStatus == css::security::CertificateValidity::VALID;
     112             : 
     113           0 :     if ( !bCertValid )
     114             :     {
     115             :         m_pCertImg->SetImage(
     116           0 :             Image( XMLSEC_RES( IMG_STATE_NOT_VALIDATED ) ) );
     117           0 :         m_pHintNotTrustedFI->SetText( XMLSEC_RES( STR_CERTIFICATE_NOT_VALIDATED ) );
     118             :     }
     119             : 
     120             :     // insert data
     121           0 :     css::uno::Reference< css::security::XCertificate > xCert = mpDlg->mxCert;
     122             : 
     123           0 :     m_pIssuedToFI->SetText( XmlSec::GetContentPart( xCert->getSubjectName() ) );
     124           0 :     m_pIssuedByFI->SetText( XmlSec::GetContentPart( xCert->getIssuerName() ) );
     125             : 
     126           0 :     DateTime aDateTimeStart( DateTime::EMPTY );
     127           0 :     DateTime aDateTimeEnd( DateTime::EMPTY );
     128           0 :     utl::typeConvert( xCert->getNotValidBefore(), aDateTimeStart );
     129           0 :     utl::typeConvert( xCert->getNotValidAfter(), aDateTimeEnd );
     130             : 
     131           0 :     OUString sValidFromDate = GetSettings().GetUILocaleDataWrapper().getDate( aDateTimeStart.GetDate() );
     132           0 :     OUString sValidToDate = GetSettings().GetUILocaleDataWrapper().getDate( aDateTimeEnd.GetDate() );
     133             : 
     134           0 :     m_pValidFromDateFI->SetText(sValidFromDate);
     135           0 :     m_pValidToDateFI->SetText(sValidToDate);
     136             : 
     137             :     // Check if we have the private key...
     138           0 :     bool bHasPrivateKey = false;
     139             :     // #i41270# Check only if we have that certificate in our security environment
     140           0 :     if ( _pDlg->mbCheckForPrivateKey )
     141             :     {
     142           0 :         long nCertificateCharacters = _pDlg->mxSecurityEnvironment->getCertificateCharacters( xCert );
     143           0 :         bHasPrivateKey = ( nCertificateCharacters & security::CertificateCharacters::HAS_PRIVATE_KEY );
     144             :     }
     145           0 :     if ( !bHasPrivateKey )
     146             :     {
     147           0 :         m_pKeyImg->Hide();
     148           0 :         m_pHintCorrespPrivKeyFI->Hide();
     149           0 :     }
     150           0 : }
     151             : 
     152           0 : CertificateViewerGeneralTP::~CertificateViewerGeneralTP()
     153             : {
     154           0 :     disposeOnce();
     155           0 : }
     156             : 
     157           0 : void CertificateViewerGeneralTP::dispose()
     158             : {
     159           0 :     m_pCertImg.clear();
     160           0 :     m_pHintNotTrustedFI.clear();
     161           0 :     m_pIssuedToFI.clear();
     162           0 :     m_pIssuedByFI.clear();
     163           0 :     m_pValidFromDateFI.clear();
     164           0 :     m_pValidToDateFI.clear();
     165           0 :     m_pKeyImg.clear();
     166           0 :     m_pHintCorrespPrivKeyFI.clear();
     167           0 :     CertificateViewerTP::dispose();
     168           0 : }
     169             : 
     170           0 : void CertificateViewerGeneralTP::ActivatePage()
     171             : {
     172             : 
     173           0 : }
     174             : 
     175             : 
     176           0 : struct Details_UserDatat
     177             : {
     178             :     OUString        maTxt;
     179             :     bool            mbFixedWidthFont;
     180             : 
     181             :     inline          Details_UserDatat( const OUString& _rTxt, bool _bFixedWidthFont );
     182             : };
     183             : 
     184           0 : inline Details_UserDatat::Details_UserDatat( const OUString& _rTxt, bool _bFixedWidthFont )
     185             :     :maTxt              ( _rTxt )
     186           0 :     ,mbFixedWidthFont   ( _bFixedWidthFont )
     187             : {
     188           0 : }
     189             : 
     190             : 
     191           0 : void CertificateViewerDetailsTP::Clear()
     192             : {
     193           0 :     m_pValueDetails->SetText( OUString() );
     194           0 :     sal_uLong           i = 0;
     195           0 :     SvTreeListEntry*    pEntry = m_pElementsLB->GetEntry( i );
     196           0 :     while( pEntry )
     197             :     {
     198           0 :         delete static_cast<Details_UserDatat*>(pEntry->GetUserData());
     199           0 :         ++i;
     200           0 :         pEntry = m_pElementsLB->GetEntry( i );
     201             :     }
     202             : 
     203           0 :     m_pElementsLB->Clear();
     204           0 : }
     205             : 
     206           0 : void CertificateViewerDetailsTP::InsertElement( const OUString& _rField, const OUString& _rValue,
     207             :                                                 const OUString& _rDetails, bool _bFixedWidthFont )
     208             : {
     209           0 :     SvTreeListEntry*    pEntry = m_pElementsLB->InsertEntry( _rField );
     210           0 :     m_pElementsLB->SetEntryText( _rValue, pEntry, 1 );
     211           0 :     pEntry->SetUserData( static_cast<void*>(new Details_UserDatat( _rDetails, _bFixedWidthFont )) );
     212           0 : }
     213             : 
     214           0 : CertificateViewerDetailsTP::CertificateViewerDetailsTP( vcl::Window* _pParent, CertificateViewer* _pDlg )
     215             :     :CertificateViewerTP    ( _pParent, "CertDetails", "xmlsec/ui/certdetails.ui", _pDlg  )
     216           0 :     ,m_aFixedWidthFont( OutputDevice::GetDefaultFont( DefaultFontType::UI_FIXED, LANGUAGE_DONTKNOW, GetDefaultFontFlags::OnlyOne, this ) )
     217             : {
     218           0 :     get( m_pValueDetails, "valuedetails" );
     219           0 :     get( m_pElementsLBContainer, "tablecontainer" );
     220           0 :     m_pElementsLB = VclPtr<SvSimpleTable>::Create( *m_pElementsLBContainer );
     221             : 
     222           0 :     m_aStdFont = m_pValueDetails->GetControlFont();
     223           0 :     WinBits nStyle = m_pElementsLB->GetStyle();
     224           0 :     nStyle &= ~WB_HSCROLL;
     225           0 :     m_pElementsLB->SetStyle( nStyle );
     226             : 
     227           0 :     m_aFixedWidthFont.SetHeight( m_aStdFont.GetHeight() );
     228             : 
     229             :     static long nTabs[] = { 2, 0, 30*CS_LB_WIDTH/100 };
     230           0 :     m_pElementsLB->SetTabs( &nTabs[ 0 ] );
     231           0 :     m_pElementsLB->InsertHeaderEntry( XMLSEC_RES( STR_HEADERBAR ) );
     232             : 
     233             :     // fill list box
     234           0 :     Reference< security::XCertificate > xCert = mpDlg->mxCert;
     235           0 :     sal_uInt16                  nLineBreak = 16;
     236           0 :     const char*             pHexSep = " ";
     237           0 :     OUString                aLBEntry;
     238           0 :     OUString                aDetails;
     239             :     // Certificate Versions are reported wrong (#i35107#) - 0 == "V1", 1 == "V2", ..., n = "V(n+1)"
     240           0 :     aLBEntry = "V" + OUString::number( xCert->getVersion() + 1 );
     241           0 :     InsertElement( XMLSEC_RES( STR_VERSION ), aLBEntry, aLBEntry );
     242           0 :     Sequence< sal_Int8 >    aSeq = xCert->getSerialNumber();
     243           0 :     aLBEntry = XmlSec::GetHexString( aSeq, pHexSep );
     244           0 :     aDetails = XmlSec::GetHexString( aSeq, pHexSep, nLineBreak );
     245           0 :     InsertElement( XMLSEC_RES( STR_SERIALNUM ), aLBEntry, aDetails, true );
     246             : 
     247             :     std::pair< OUString, OUString> pairIssuer =
     248           0 :         XmlSec::GetDNForCertDetailsView(xCert->getIssuerName());
     249           0 :     aLBEntry = pairIssuer.first;
     250           0 :     aDetails = pairIssuer.second;
     251           0 :     InsertElement( XMLSEC_RES( STR_ISSUER ), aLBEntry, aDetails );
     252             : 
     253           0 :     DateTime aDateTime( DateTime::EMPTY );
     254           0 :     utl::typeConvert( xCert->getNotValidBefore(), aDateTime );
     255           0 :     aLBEntry = GetSettings().GetUILocaleDataWrapper().getDate( aDateTime.GetDate() );
     256           0 :     aLBEntry += " ";
     257           0 :     aLBEntry += GetSettings().GetUILocaleDataWrapper().getTime( aDateTime.GetTime() );
     258           0 :     InsertElement( XMLSEC_RES( STR_VALIDFROM ), aLBEntry, aLBEntry  );
     259           0 :     utl::typeConvert( xCert->getNotValidAfter(), aDateTime );
     260           0 :     aLBEntry = GetSettings().GetUILocaleDataWrapper().getDate( aDateTime.GetDate() );
     261           0 :     aLBEntry += " ";
     262           0 :     aLBEntry += GetSettings().GetUILocaleDataWrapper().getTime( aDateTime.GetTime() );
     263           0 :     InsertElement( XMLSEC_RES( STR_VALIDTO ), aLBEntry, aLBEntry );
     264             : 
     265             :     std::pair< OUString, OUString > pairSubject =
     266           0 :         XmlSec::GetDNForCertDetailsView(xCert->getSubjectName());
     267           0 :     aLBEntry = pairSubject.first;
     268           0 :     aDetails = pairSubject.second;
     269           0 :     InsertElement( XMLSEC_RES( STR_SUBJECT ), aLBEntry, aDetails );
     270             : 
     271           0 :     aLBEntry = aDetails = xCert->getSubjectPublicKeyAlgorithm();
     272           0 :     InsertElement( XMLSEC_RES( STR_SUBJECT_PUBKEY_ALGO ), aLBEntry, aDetails );
     273           0 :     aSeq = xCert->getSubjectPublicKeyValue();
     274           0 :     aLBEntry = XmlSec::GetHexString( aSeq, pHexSep );
     275           0 :     aDetails = XmlSec::GetHexString( aSeq, pHexSep, nLineBreak );
     276           0 :     InsertElement( XMLSEC_RES( STR_SUBJECT_PUBKEY_VAL ), aLBEntry, aDetails, true );
     277             : 
     278           0 :     aLBEntry = aDetails = xCert->getSignatureAlgorithm();
     279           0 :     InsertElement( XMLSEC_RES( STR_SIGNATURE_ALGO ), aLBEntry, aDetails );
     280             : 
     281           0 :     aSeq = xCert->getSHA1Thumbprint();
     282           0 :     aLBEntry = XmlSec::GetHexString( aSeq, pHexSep );
     283           0 :     aDetails = XmlSec::GetHexString( aSeq, pHexSep, nLineBreak );
     284           0 :     InsertElement( XMLSEC_RES( STR_THUMBPRINT_SHA1 ), aLBEntry, aDetails, true );
     285             : 
     286           0 :     aSeq = xCert->getMD5Thumbprint();
     287           0 :     aLBEntry = XmlSec::GetHexString( aSeq, pHexSep );
     288           0 :     aDetails = XmlSec::GetHexString( aSeq, pHexSep, nLineBreak );
     289           0 :     InsertElement( XMLSEC_RES( STR_THUMBPRINT_MD5 ), aLBEntry, aDetails, true );
     290             : 
     291           0 :     m_pElementsLB->SetSelectHdl( LINK( this, CertificateViewerDetailsTP, ElementSelectHdl ) );
     292           0 : }
     293             : 
     294           0 : CertificateViewerDetailsTP::~CertificateViewerDetailsTP()
     295             : {
     296           0 :     disposeOnce();
     297           0 : }
     298             : 
     299           0 : void CertificateViewerDetailsTP::dispose()
     300             : {
     301           0 :     Clear();
     302           0 :     m_pElementsLB.disposeAndClear();
     303           0 :     m_pElementsLBContainer.clear();
     304           0 :     m_pValueDetails.clear();
     305           0 :     CertificateViewerTP::dispose();
     306           0 : }
     307             : 
     308           0 : void CertificateViewerDetailsTP::ActivatePage()
     309             : {
     310           0 : }
     311             : 
     312           0 : IMPL_LINK_NOARG(CertificateViewerDetailsTP, ElementSelectHdl)
     313             : {
     314           0 :     SvTreeListEntry*    pEntry = m_pElementsLB->FirstSelected();
     315           0 :     OUString        aElementText;
     316             :     bool            bFixedWidthFont;
     317           0 :     if( pEntry )
     318             :     {
     319           0 :         const Details_UserDatat*    p = static_cast<Details_UserDatat*>(pEntry->GetUserData());
     320           0 :         aElementText = p->maTxt;
     321           0 :         bFixedWidthFont = p->mbFixedWidthFont;
     322             :     }
     323             :     else
     324           0 :         bFixedWidthFont = false;
     325             : 
     326           0 :     m_pValueDetails->SetFont( bFixedWidthFont? m_aFixedWidthFont : m_aStdFont );
     327           0 :     m_pValueDetails->SetControlFont( bFixedWidthFont? m_aFixedWidthFont : m_aStdFont );
     328           0 :     m_pValueDetails->SetText( aElementText );
     329             : 
     330           0 :     return 0;
     331             : }
     332             : 
     333           0 : struct CertPath_UserData
     334             : {
     335             :     css::uno::Reference< css::security::XCertificate > mxCert;
     336             :     OUString                                        maStatus;
     337             :     bool mbValid;
     338             : 
     339           0 :     CertPath_UserData( css::uno::Reference< css::security::XCertificate > xCert, bool bValid):
     340             :         mxCert(xCert),
     341           0 :         mbValid(bValid)
     342             :     {
     343           0 :     }
     344             : };
     345             : 
     346             : 
     347           0 : CertificateViewerCertPathTP::CertificateViewerCertPathTP( vcl::Window* _pParent, CertificateViewer* _pDlg )
     348             :     : CertificateViewerTP(_pParent, "CertPage", "xmlsec/ui/certpage.ui", _pDlg)
     349             :     , mpParent(_pDlg)
     350           0 :     , mbFirstActivateDone(false)
     351             : {
     352           0 :     get(mpCertPathLB, "signatures");
     353           0 :     get(mpViewCertPB, "viewcert");
     354           0 :     get(mpCertStatusML, "status");
     355             : 
     356           0 :     msCertOK = get<FixedText>("certok")->GetText();
     357           0 :     msCertNotValidated = get<FixedText>("certnotok")->GetText();
     358           0 :     maCertImage = get<FixedImage>("imgok")->GetImage();
     359           0 :     maCertNotValidatedImage = get<FixedImage>("imgnotok")->GetImage();
     360             : 
     361           0 :     Size aControlSize(LogicToPixel(Size(251, 45), MAP_APPFONT));
     362           0 :     mpCertPathLB->set_width_request(aControlSize.Width());
     363           0 :     mpCertPathLB->set_height_request(aControlSize.Height());
     364           0 :     mpCertStatusML->set_width_request(aControlSize.Width());
     365           0 :     mpCertStatusML->set_height_request(aControlSize.Height());
     366             : 
     367           0 :     mpCertPathLB->SetNodeDefaultImages();
     368           0 :     mpCertPathLB->SetSublistOpenWithLeftRight();
     369           0 :     mpCertPathLB->SetSelectHdl( LINK( this, CertificateViewerCertPathTP, CertSelectHdl ) );
     370           0 :     mpViewCertPB->SetClickHdl( LINK( this, CertificateViewerCertPathTP, ViewCertHdl ) );
     371           0 : }
     372             : 
     373           0 : CertificateViewerCertPathTP::~CertificateViewerCertPathTP()
     374             : {
     375           0 :     disposeOnce();
     376           0 : }
     377             : 
     378           0 : void CertificateViewerCertPathTP::dispose()
     379             : {
     380           0 :     Clear();
     381           0 :     mpCertPathLB.clear();
     382           0 :     mpViewCertPB.clear();
     383           0 :     mpCertStatusML.clear();
     384           0 :     mpParent.clear();
     385           0 :     CertificateViewerTP::dispose();
     386           0 : }
     387             : 
     388           0 : void CertificateViewerCertPathTP::ActivatePage()
     389             : {
     390           0 :     if ( !mbFirstActivateDone )
     391             :     {
     392           0 :         mbFirstActivateDone = true;
     393             :         Sequence< Reference< security::XCertificate > > aCertPath =
     394           0 :             mpParent->mxSecurityEnvironment->buildCertificatePath( mpParent->mxCert );
     395           0 :         const Reference< security::XCertificate >* pCertPath = aCertPath.getConstArray();
     396             : 
     397           0 :         sal_Int32 i, nCnt = aCertPath.getLength();
     398           0 :         SvTreeListEntry* pParent = NULL;
     399           0 :         for( i = nCnt; i; )
     400             :         {
     401           0 :             const Reference< security::XCertificate > rCert = pCertPath[ --i ];
     402           0 :             OUString sName = XmlSec::GetContentPart( rCert->getSubjectName() );
     403             :             //Verify the certificate
     404           0 :             sal_Int32 certStatus = mpDlg->mxSecurityEnvironment->verifyCertificate(rCert,
     405           0 :                  Sequence<Reference<css::security::XCertificate> >());
     406           0 :             bool bCertValid = certStatus == css::security::CertificateValidity::VALID;
     407           0 :             pParent = InsertCert( pParent, sName, rCert, bCertValid);
     408           0 :         }
     409             : 
     410           0 :         mpCertPathLB->Select( pParent );
     411           0 :         mpViewCertPB->Disable(); // Own certificate selected
     412             : 
     413           0 :         while( pParent )
     414             :         {
     415           0 :             mpCertPathLB->Expand( pParent );
     416           0 :             pParent = mpCertPathLB->GetParent( pParent );
     417             :         }
     418             : 
     419           0 :         CertSelectHdl( NULL );
     420             :     }
     421           0 : }
     422             : 
     423           0 : IMPL_LINK_NOARG(CertificateViewerCertPathTP, ViewCertHdl)
     424             : {
     425           0 :     SvTreeListEntry* pEntry = mpCertPathLB->FirstSelected();
     426           0 :     if( pEntry )
     427             :     {
     428             :         ScopedVclPtrInstance< CertificateViewer > aViewer(
     429           0 :                 this, mpDlg->mxSecurityEnvironment,
     430           0 :                 static_cast<CertPath_UserData*>(pEntry->GetUserData())->mxCert,
     431           0 :                 false );
     432           0 :         aViewer->Execute();
     433             :     }
     434             : 
     435           0 :     return 0;
     436             : }
     437             : 
     438           0 : IMPL_LINK_NOARG(CertificateViewerCertPathTP, CertSelectHdl)
     439             : {
     440           0 :     OUString sStatus;
     441           0 :     SvTreeListEntry* pEntry = mpCertPathLB->FirstSelected();
     442           0 :     if( pEntry )
     443             :     {
     444           0 :         CertPath_UserData* pData = static_cast<CertPath_UserData*>(pEntry->GetUserData());
     445           0 :         if ( pData )
     446           0 :             sStatus = pData->mbValid ? msCertOK : msCertNotValidated;
     447             :     }
     448             : 
     449           0 :     mpCertStatusML->SetText( sStatus );
     450           0 :     mpViewCertPB->Enable( pEntry && ( pEntry != mpCertPathLB->Last() ) );
     451           0 :     return 0;
     452             : }
     453             : 
     454           0 : void CertificateViewerCertPathTP::Clear()
     455             : {
     456           0 :     mpCertStatusML->SetText( OUString() );
     457           0 :     sal_uLong           i = 0;
     458           0 :     SvTreeListEntry*    pEntry = mpCertPathLB->GetEntry( i );
     459           0 :     while( pEntry )
     460             :     {
     461           0 :         delete static_cast<CertPath_UserData*>(pEntry->GetUserData());
     462           0 :         ++i;
     463           0 :         pEntry = mpCertPathLB->GetEntry( i );
     464             :     }
     465             : 
     466           0 :     mpCertPathLB->Clear();
     467           0 : }
     468             : 
     469           0 : SvTreeListEntry* CertificateViewerCertPathTP::InsertCert(
     470             :     SvTreeListEntry* _pParent, const OUString& _rName, css::uno::Reference< css::security::XCertificate > rxCert,
     471             :     bool bValid)
     472             : {
     473           0 :     Image aImage = bValid ? maCertImage : maCertNotValidatedImage;
     474           0 :     SvTreeListEntry* pEntry = mpCertPathLB->InsertEntry( _rName, aImage, aImage, _pParent );
     475           0 :     pEntry->SetUserData( static_cast<void*>(new CertPath_UserData( rxCert, bValid )) );
     476             : 
     477           0 :     return pEntry;
     478         114 : }
     479             : 
     480             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11