pkiutilities/CTSecurityDialogs/NotifSrc/CTSecurityDialogsAO.cpp
branchRCL_3
changeset 22 03674e5abf46
parent 21 09b1ac925e3f
equal deleted inserted replaced
21:09b1ac925e3f 22:03674e5abf46
    17 
    17 
    18 
    18 
    19 // INCLUDE FILES
    19 // INCLUDE FILES
    20 #include "CTSecurityDialogsAO.h"
    20 #include "CTSecurityDialogsAO.h"
    21 #include "CTSecurityDialogNotifier.h"
    21 #include "CTSecurityDialogNotifier.h"
    22 //#include "CTPinQueryDialog.h"
    22 #include "CTPinQueryDialog.h"
    23 //#include "CTSignTextDialog.h"
    23 #include "CTSignTextDialog.h"
    24 //#include "CTSelectCertificateDialog.h"
    24 #include "CTSelectCertificateDialog.h"
    25 //#include "CTQueryDialog.h"
    25 #include "CTQueryDialog.h"
    26 //#include "CTPinPinQueryDialog.h"
    26 #include "CTPinPinQueryDialog.h"
    27 #include "CTUntrustedCertQuery.h"
    27 #include "CTNoTrustQuery.h"
    28 //#include "CTInvalidCertNote.h"
    28 #include "CTInvalidCertNote.h"
    29 #include <PKIDlg.h>
    29 #include <PKIDlg.h>
    30 #include <badesca.h>
    30 #include <badesca.h>
    31 #include <StringLoader.h>
    31 #include <StringLoader.h>
    32 //#include <aknnotewrappers.h>
    32 #include <aknnotewrappers.h>
    33 #include <unifiedcertstore.h>
    33 #include <unifiedcertstore.h>
    34 #include <unifiedkeystore.h>
    34 #include <unifiedkeystore.h>
    35 #include <mctkeystore.h>
    35 #include <mctkeystore.h>
    36 #include <cctcertinfo.h>
    36 #include <cctcertinfo.h>
    37 #include <DocumentHandler.h>
    37 #include <DocumentHandler.h>
    38 #include <apmstd.h>
    38 #include <apmstd.h>
    39 #include <DigSigningNote.h>
    39 #include <DigSigningNote.h>
    40 //#include <certmanui.rsg>
    40 #include <certmanui.rsg>
    41 #include <X509CertNameParser.h>
    41 #include <X509CertNameParser.h>
    42 #include <x509cert.h>
    42 #include <x509cert.h>
    43 #include <x500dn.h>
    43 #include <x500dn.h>
    44 #include <hash.h>
    44 #include <hash.h>
    45 #include <x509certext.h>
    45 #include <x509certext.h>
    46 #include <TrustedSitesStore.h>
    46 #include <TrustedSitesStore.h>
    47 #include <mctwritablecertstore.h>
    47 #include <mctwritablecertstore.h>
    48 #include <eikenv.h>                         // CEikonEnv
    48 #include <coreapplicationuisdomainpskeys.h>			// KCoreAppUIsAutolockStatus
    49 #include <AknUtils.h>                       // AknTextUtils
       
    50 
       
    51 #include "SecQueryUi.h"                   // needed for password dialog
       
    52 
       
    53 #include <hbdevicemessageboxsymbian.h>    // needed for Note dialogs    
       
    54 #include <hbdevicenotificationdialogsymbian.h>
       
    55 
    49 
    56 // LOCAL CONSTANTS AND MACROS
    50 // LOCAL CONSTANTS AND MACROS
    57 const TInt KCertArrayGranularity = 3;
    51 const TInt KCertArrayGranularity = 3;
    58 const TInt KMaxLengthTextDetailsBody = 5000;
    52 const TInt KMaxLengthTextDetailsBody = 5000;
    59 // CertLabel, Issuer, Owner max visible length
    53 // CertLabel, Issuer, Owner max visible length
    60 const TInt KMaxLengthTextCertLabelVisible = 200;
    54 const TInt KMaxLengthTextCertLabelVisible = 200;
    61 // "dd/mm/yyyy0"
    55 // "dd/mm/yyyy0"
    62 const TInt KMaxLengthTextDateString = 20;
    56 const TInt KMaxLengthTextDateString = 20;
       
    57 // HH0
       
    58 const TInt KMaxLengthTextSerialNumberFormatting = 3;
    63 // Maximum length of a certificate
    59 // Maximum length of a certificate
    64 const TInt KMaxCertificateLength = 5000;
    60 const TInt KMaxCertificateLength = 5000;
    65 
    61 
    66 // Maximum length of key store password
    62 // Maximum length of key store password
    67 const TInt KMaxKeystorePwLength = 6;
    63 const TInt KMaxKeystorePwLength = 6;
    68 
    64 
    69 const TInt KMinImportKeyPwLen = 1;
    65 const TInt KMinImportKeyPwLen = 1;
    70 
    66 
    71 const TInt KMaxCommonNameLength = 64;
    67 const TInt KMaxCNLength = 64;
    72 
    68 
       
    69 _LIT(KCertManUIDetailsViewHexFormat, "%02X");
       
    70 
       
    71 const TInt KFileCertStoreUid( 0x101F501A );
       
    72 const TInt KWIMCertStoreUid ( 0x101F79D9 );
    73 const TUid KTrustedServerTokenUid = { 0x101FB66F };
    73 const TUid KTrustedServerTokenUid = { 0x101FB66F };
    74 const TUid KDeviceCertStoreTokenUid = { 0x101FB668 };
    74 const TUid KDeviceCertStoreTokenUid = { 0x101FB668 };
    75 
    75 
    76 _LIT( KBlockSeparator, " " );
    76 _LIT( KBlockSeparator, " " );
    77 _LIT( KEnter, "\n" );
    77 _LIT( KEnter, "\n" );
    81 _LIT( KKeyStoreImportKeyLabel, "Passphrase of the imported key file" );
    81 _LIT( KKeyStoreImportKeyLabel, "Passphrase of the imported key file" );
    82 _LIT( KKeyStoreExportKeyLabel, "Passphrase of the exported key file" );
    82 _LIT( KKeyStoreExportKeyLabel, "Passphrase of the exported key file" );
    83 _LIT( KPKCS12TokenLabel, "PKCS12");
    83 _LIT( KPKCS12TokenLabel, "PKCS12");
    84 
    84 
    85 
    85 
    86 // TODO: replace with OST tracing
    86 // ============================ LOCAL FUNCTIONS ===============================
    87 #ifdef _DEBUG
    87 
    88 #include <e32debug.h>
    88 TInt AlgorithmNameResourceId( TAlgorithmId aAlgorithmId )
    89 #define TRACE(x)        RDebug::Printf(x)
    89     {
    90 #define TRACE1(x,y)     RDebug::Printf(x,y)
    90     TInt resourceId = 0;
    91 #else
    91     switch( aAlgorithmId )
    92 #define TRACE(x)
    92         {
    93 #define TRACE1(x,y)
    93         case ERSA:
    94 #endif
    94             resourceId = R_TEXT_RESOURCE_DETAILS_VIEW_ALGORITHM_RSA;
       
    95             break;
       
    96         case EDSA:
       
    97             resourceId = R_TEXT_RESOURCE_DETAILS_VIEW_ALGORITHM_DSA;
       
    98             break;
       
    99         case EDH:
       
   100             resourceId = R_TEXT_RESOURCE_DETAILS_VIEW_ALGORITHM_DH;
       
   101             break;
       
   102         case EMD2:
       
   103             resourceId = R_TEXT_RESOURCE_DETAILS_VIEW_ALGORITHM_MD2;
       
   104             break;
       
   105         case EMD5:
       
   106             resourceId = R_TEXT_RESOURCE_DETAILS_VIEW_ALGORITHM_MD5;
       
   107             break;
       
   108         case ESHA1:
       
   109             resourceId = R_TEXT_RESOURCE_DETAILS_VIEW_ALGORITHM_SHA1;
       
   110             break;
       
   111         case ESHA224:
       
   112         case ESHA256:
       
   113         case ESHA384:
       
   114         case ESHA512:
       
   115             resourceId = R_TEXT_RESOURCE_DETAILS_VIEW_ALGORITHM_SHA2;
       
   116             break;
       
   117         default:
       
   118             resourceId = R_TEXT_RESOURCE_DETAILS_VIEW_UNKNOWN;
       
   119             break;
       
   120         }
       
   121     return resourceId;
       
   122     }
    95 
   123 
    96 
   124 
    97 // ============================ MEMBER FUNCTIONS ===============================
   125 // ============================ MEMBER FUNCTIONS ===============================
    98 
   126 
    99 // -----------------------------------------------------------------------------
   127 // -----------------------------------------------------------------------------
   117 // -----------------------------------------------------------------------------
   145 // -----------------------------------------------------------------------------
   118 //
   146 //
   119 void CCTSecurityDialogsAO::ConstructL()
   147 void CCTSecurityDialogsAO::ConstructL()
   120     {
   148     {
   121     iDeleted = EFalse;
   149     iDeleted = EFalse;
       
   150 
       
   151     iQueryDialog = NULL;
       
   152     iQueryDialogDeleted = ETrue;
   122     }
   153     }
   123 
   154 
   124 // -----------------------------------------------------------------------------
   155 // -----------------------------------------------------------------------------
   125 // CCTSecurityDialogsAO::NewL
   156 // CCTSecurityDialogsAO::NewL
   126 // Two-phased constructor.
   157 // Two-phased constructor.
   192     iRetry = *reinterpret_cast<const TInt *>( aBuffer.Ptr() ) & EPINValueIncorrect;
   223     iRetry = *reinterpret_cast<const TInt *>( aBuffer.Ptr() ) & EPINValueIncorrect;
   193     iReplySlot = aReplySlot;
   224     iReplySlot = aReplySlot;
   194     iMessagePtr = aMessage;
   225     iMessagePtr = aMessage;
   195 
   226 
   196     WIMSECURITYDIALOGS_WRITE_FORMAT( "CCTSecurityDialogsAO::StartLD iOperation=%d", iOperation );
   227     WIMSECURITYDIALOGS_WRITE_FORMAT( "CCTSecurityDialogsAO::StartLD iOperation=%d", iOperation );
   197     TRACE1( "CCTSecurityDialogsAO::StartLD iOperation=%d", iOperation );
       
   198 
   228 
   199     MapTlsProviderOperation( iOperation );
   229     MapTlsProviderOperation( iOperation );
   200 
   230 
   201     switch ( iOperation )
   231     switch ( iOperation )
   202         {
   232         {
   273             TPtrC8 pinLabelPtr = aBuffer.Mid( sizeof(TInt) + 1 );
   303             TPtrC8 pinLabelPtr = aBuffer.Mid( sizeof(TInt) + 1 );
   274             TPINLabel pinLabel;
   304             TPINLabel pinLabel;
   275             pinLabel.Copy( pinLabelPtr );
   305             pinLabel.Copy( pinLabelPtr );
   276             HBufC* text = iNotifier->LoadResourceStringLC( iOperation, pinLabel );
   306             HBufC* text = iNotifier->LoadResourceStringLC( iOperation, pinLabel );
   277 
   307 
   278             // TODO
   308             CCTSignTextDialog::RunDlgLD( R_WIM_UNBLOCK_INFO_DIALOG, *text, iStatus, iRetValue );
   279             //CCTSignTextDialog::RunDlgLD( R_WIM_UNBLOCK_INFO_DIALOG, *text, iStatus, iRetValue );
       
   280             User::Leave( KErrGeneral );
       
   281 
       
   282             CleanupStack::PopAndDestroy( text );
   309             CleanupStack::PopAndDestroy( text );
   283             iStatus = KRequestPending;
   310             iStatus = KRequestPending;
   284             SetActive();
   311             SetActive();
   285             break;
   312             break;
   286             }
   313             }
   350 // CCTSecurityDialogsAO::DoHandleServerAuthFailL(const TDesC8& aBuffer)
   377 // CCTSecurityDialogsAO::DoHandleServerAuthFailL(const TDesC8& aBuffer)
   351 // -----------------------------------------------------------------------------
   378 // -----------------------------------------------------------------------------
   352 //
   379 //
   353 void CCTSecurityDialogsAO::DoHandleServerAuthFailL( const TDesC8& aBuffer )
   380 void CCTSecurityDialogsAO::DoHandleServerAuthFailL( const TDesC8& aBuffer )
   354     {
   381     {
   355     TRACE( "CCTSecurityDialogsAO::DoHandleServerAuthFailL" );
       
   356 
       
   357     CServerAuthenticationFailureInput* srvAuthFail =
   382     CServerAuthenticationFailureInput* srvAuthFail =
   358         CServerAuthenticationFailureInput::NewLC( aBuffer );
   383         CServerAuthenticationFailureInput::NewLC( aBuffer );
   359     TPtrC8 cert;
   384     TPtrC8 cert;
   360     TPtrC8 serverName;
   385     TPtrC8 serverName;
   361 
   386 
   364     iAuthFailReason = srvAuthFail->FailureReason();
   389     iAuthFailReason = srvAuthFail->FailureReason();
   365     CleanupStack::PopAndDestroy( srvAuthFail );
   390     CleanupStack::PopAndDestroy( srvAuthFail );
   366 
   391 
   367     iServerName = HBufC::NewL( serverName.Length() );
   392     iServerName = HBufC::NewL( serverName.Length() );
   368     iServerName->Des().Copy( serverName );
   393     iServerName->Des().Copy( serverName );
       
   394 
       
   395     HBufC* cn = NULL;
   369     iCertLabel = NULL;
   396     iCertLabel = NULL;
   370 
       
   371     // Site will be checked later. For now it is not trusted
   397     // Site will be checked later. For now it is not trusted
   372     iTrustedSite = EFalse;
   398     iTrustedSite = EFalse;
   373 
   399 
       
   400 
   374     CX509Certificate* serverCert = CX509Certificate::NewLC( cert );
   401     CX509Certificate* serverCert = CX509Certificate::NewLC( cert );
       
   402     // Retrieve subject name
   375     const CX500DistinguishedName& dName = serverCert->SubjectName();
   403     const CX500DistinguishedName& dName = serverCert->SubjectName();
   376 
   404     // Retrieve CN
   377     HBufC* commonName = dName.ExtractFieldL( KX520CommonName );
   405     cn = dName.ExtractFieldL( KX520CommonName );
   378     CleanupStack::PushL( commonName );
   406     if ( cn != NULL )
   379     if( commonName != NULL )
   407         {
   380         {
   408         // commonName exist in the certificate.
   381         // Check the length of CN. RFC 3280 states
   409         // Check the length of CN. RFC 3280 states
   382         // that max length of CN is 64.
   410         // that max length of CN is 64.
   383         if( commonName->Length() <= KMaxCommonNameLength )
   411         if ( cn->Length() <= KMaxCNLength )
   384             {
   412             {
   385             iCertLabel = HBufC::NewL( commonName->Length() );
   413             iCertLabel = HBufC::NewL( cn->Length() );
   386             iCertLabel->Des().Append( commonName->Des() );
   414             iCertLabel->Des().Append( cn->Des() );
   387             }
   415             }
   388         }
   416         }
   389     CleanupStack::PopAndDestroy( commonName );
   417 
   390 
   418     if ( iCertLabel == NULL )
   391     if( iCertLabel == NULL )
   419         {
   392         {
   420         // No or invalid commonName. Use domain name as label
   393         // No or invalid commonName. Use domain name as label.
       
   394         iCertLabel = HBufC::NewL( iServerName->Length() );
   421         iCertLabel = HBufC::NewL( iServerName->Length() );
   395         iCertLabel->Des().Append( iServerName->Des() );
   422         iCertLabel->Des().Append( iServerName->Des() );
   396         }
   423         }
   397 
   424 
   398     CleanupStack::PopAndDestroy( serverCert );
   425     CleanupStack::PopAndDestroy( serverCert );
   507         }
   534         }
   508     switch( iOperation )
   535     switch( iOperation )
   509         {
   536         {
   510         case EUserAuthenticationText:
   537         case EUserAuthenticationText:
   511             {
   538             {
   512             // TODO
   539             CCTSignTextDialog::RunDlgLD( R_WIM_USERAUTHTEXT_DIALOG,
   513             //CCTSignTextDialog::RunDlgLD( R_WIM_USERAUTHTEXT_DIALOG,
   540                 *textToSign, iStatus, iRetValue );
   514             //    *textToSign, iStatus, iRetValue );
       
   515             User::Leave( KErrGeneral );
       
   516             break;
   541             break;
   517             }
   542             }
   518         case EUserAuthentication:
   543         case EUserAuthentication:
   519             {
   544             {
   520             DoHandleMessageL( EUserAuthentication, KNullDesC, KNullDesC, 1, KMaxTInt );
       
   521             break;
   545             break;
   522             }
   546             }
   523         case ESignText:
   547         case ESignText:
   524             {
   548             {
   525             // TODO
   549             CCTSignTextDialog::RunDlgLD( R_WIM_SIGNTEXT_DIALOG,*textToSign, iStatus, iRetValue );
   526             //CCTSignTextDialog::RunDlgLD( R_WIM_SIGNTEXT_DIALOG,*textToSign, iStatus, iRetValue );
       
   527             User::Leave( KErrGeneral );
       
   528             break;
   550             break;
   529             }
   551             }
   530         default:
   552         default:
   531             {
   553             {
   532             __ASSERT_DEBUG( EFalse,
   554             __ASSERT_DEBUG( EFalse,
   574 void CCTSecurityDialogsAO::DoHandlePinOperationL()
   596 void CCTSecurityDialogsAO::DoHandlePinOperationL()
   575     {
   597     {
   576     if ( iRetry ) // Is this new try?
   598     if ( iRetry ) // Is this new try?
   577       {
   599       {
   578         // Previous attempt was failed
   600         // Previous attempt was failed
   579         // incorrect pin code
       
   580         DoHandleMessageL( EErrorPinCodeIncorrect, KNullDesC, KNullDesC, 0, 0 );
   601         DoHandleMessageL( EErrorPinCodeIncorrect, KNullDesC, KNullDesC, 0, 0 );
   581       }
   602       }
   582     // Ask the PIN code or PUK code
   603     // Ask the PIN code or PUK code
   583     if ( iPIN.iPINLabel == KKeyStoreEnterPwLabel )
   604     if ( iPIN.iPINLabel == KKeyStoreEnterPwLabel )
   584         {
   605         {
   585         HBufC* header = StringLoader::LoadLC(
   606         HBufC* header = StringLoader::LoadLC(
   586             R_QTN_CM_HEADING_PHONE_KEYSTORE, CEikonEnv::Static() );
   607             R_QTN_CM_HEADING_PHONE_KEYSTORE, CEikonEnv::Static() );
   587 		iPIN.iMinLength = KMaxKeystorePwLength;
   608         iPIN.iMinLength = KMaxKeystorePwLength;
   588         DoHandleMessageL( EEnterKeyStorePw, KNullDesC, *header,
   609         DoHandleMessageL( EEnterKeyStorePw, KNullDesC, *header,
   589             iPIN.iMinLength, iPIN.iMaxLength );
   610             iPIN.iMinLength, iPIN.iMaxLength );
   590         iMultiLineDlgType = EEnterNewKeyStorePw;
   611         iMultiLineDlgType = EEnterNewKeyStorePw;
   591         CleanupStack::PopAndDestroy( header );
   612         CleanupStack::PopAndDestroy( header );
   592         RunL();
       
   593 
       
   594         }
   613         }
   595     else if ( iPIN.iPINLabel == KKeyStoreImportKeyLabel )
   614     else if ( iPIN.iPINLabel == KKeyStoreImportKeyLabel )
   596         {
   615         {
   597         iPIN.iMinLength = KMaxKeystorePwLength;
   616         iPIN.iMinLength = KMaxKeystorePwLength;
   598         DoHandleMessageL( EImportKeyPw, KNullDesC, KNullDesC,
   617         DoHandleMessageL( EImportKeyPw, KNullDesC, KNullDesC,
   605         iNextStep = EVerifyPINs;
   624         iNextStep = EVerifyPINs;
   606         }
   625         }
   607     else if ( iPIN.iPINLabel == KKeyStoreCreatePwLabel )
   626     else if ( iPIN.iPINLabel == KKeyStoreCreatePwLabel )
   608         {
   627         {
   609         iPIN.iMinLength = KMaxKeystorePwLength;
   628         iPIN.iMinLength = KMaxKeystorePwLength;
   610         ShowInformationNoteL(R_QTN_CM_CREATING_KEYSTORE);
   629         DoHandleMessageL( EInfoPwCreating, KNullDesC, KNullDesC, 0, 0 );
   611         DoHandleMultilinePinQueryL( EEnterNewKeyStorePw );
   630         DoHandleMultilinePinQueryL( EEnterNewKeyStorePw );
   612         iNextStep = EVerifyPINs;
   631         iNextStep = EVerifyPINs;
   613         }
   632         }
   614     else if ( iPIN.iTokenLabel == KPKCS12TokenLabel )
   633     else if ( iPIN.iTokenLabel == KPKCS12TokenLabel )
   615         {
   634         {
   630 
   649 
   631 // -----------------------------------------------------------------------------
   650 // -----------------------------------------------------------------------------
   632 // CCTSecurityDialogsAO::DoHandleMultilinePinQueryL()
   651 // CCTSecurityDialogsAO::DoHandleMultilinePinQueryL()
   633 // -----------------------------------------------------------------------------
   652 // -----------------------------------------------------------------------------
   634 //
   653 //
   635 void CCTSecurityDialogsAO::DoHandleMultilinePinQueryL( const TInt& /*aDlgType*/ )
   654 void CCTSecurityDialogsAO::DoHandleMultilinePinQueryL( const TInt& aDlgType )
   636     {
   655     {
   637     // TODO
       
   638 #if 0
       
   639     iMultiLineDlgType = aDlgType;
   656     iMultiLineDlgType = aDlgType;
   640     HBufC* dlgText1 = NULL;
   657     HBufC* dlgText1 = NULL;
   641     HBufC* dlgText2 = NULL;
   658     HBufC* dlgText2 = NULL;
   642     CCTPinPinQueryDialog* dlg = NULL;
   659     CCTPinPinQueryDialog* dlg = NULL;
   643     TDialogType dlgType = ( TDialogType )aDlgType;
   660     TDialogType dlgType = ( TDialogType )aDlgType;
   644     if ( EEnterNewKeyStorePw == dlgType )
   661     if ( EEnterNewKeyStorePw == dlgType )
   645         {
   662         {
   646 /*
       
   647         dlgText1 = iNotifier->LoadResourceStringLC( dlgType, KNullDesC );
       
   648         dlgText2 = iNotifier->LoadResourceStringLC( EVerifyKeyStorePw, KNullDesC );
       
   649         dlg = CCTPinPinQueryDialog::NewL( *dlgText1, *dlgText2, iPINValue2,
       
   650             iPINValueVerify, iPIN.iMinLength, iPIN.iMaxLength, iRetValue );16:19:13.812 xti1:MCU_ASCII_PRINTF; channel:0xE0; msg:*PlatSec* ERROR - Capability check failed - Process #tlstest[e8dc94b1]0001 was checked by Thread c32exe.exe[101f7989]0001::ESock_IP and was found to be missing the capabilities: NetworkControl .
       
   651 
       
   652         dlg->RunDlgLD( iStatus, R_WIM_PWPW_QUERY_DIALOG );
       
   653         CleanupStack::PopAndDestroy( 2, dlgText1 ); // dlgText1, dlgText2
       
   654 */
       
   655         dlgText1 =  StringLoader::LoadLC( R_QTN_SN_NEW_PHONE_KEYSTORE );
       
   656         dlgText2 = StringLoader::LoadLC( R_QTN_WIM_VERIFY_PIN );
       
   657         HBufC* message = HBufC::NewLC( KMaxLengthTextCertLabelVisible );
       
   658         message->Des().Append(dlgText1->Des());
       
   659         message->Des().Append(_L("|"));
       
   660         message->Des().Append(dlgText2->Des());
       
   661         CSecQueryUi* SecQueryUi = CSecQueryUi::NewL();
       
   662         TInt queryAccepted = SecQueryUi->SecQueryDialog(message->Des(), iPINValueVerify,
       
   663                                                     iPIN.iMinLength,iPIN.iMaxLength,
       
   664                                                     ESecUiAlphaSupported |
       
   665                                                     ESecUiCancelSupported |
       
   666                                                     ESecUiSecretSupported |
       
   667                                                     ESecUiEmergencyNotSupported);
       
   668         iRetValue=(queryAccepted==KErrNone);
       
   669         if(iRetValue)
       
   670             iPINValue2.Copy(iPINValueVerify); // dialog already does not OK with different pin codes
       
   671         delete SecQueryUi;
       
   672         SecQueryUi=NULL;
       
   673         CleanupStack::PopAndDestroy( message );
       
   674         CleanupStack::PopAndDestroy( dlgText2 );
       
   675         CleanupStack::PopAndDestroy( dlgText1 );
       
   676         RunL(); // had to call it this way
       
   677         }
       
   678     else if ( EExportKeyPw == dlgType )
       
   679         {
       
   680         dlgText1 = iNotifier->LoadResourceStringLC( dlgType, KNullDesC );
   663         dlgText1 = iNotifier->LoadResourceStringLC( dlgType, KNullDesC );
   681         dlgText2 = iNotifier->LoadResourceStringLC( EVerifyKeyStorePw, KNullDesC );
   664         dlgText2 = iNotifier->LoadResourceStringLC( EVerifyKeyStorePw, KNullDesC );
   682         dlg = CCTPinPinQueryDialog::NewL( *dlgText1, *dlgText2, iPINValue2,
   665         dlg = CCTPinPinQueryDialog::NewL( *dlgText1, *dlgText2, iPINValue2,
   683             iPINValueVerify, iPIN.iMinLength, iPIN.iMaxLength, iRetValue );
   666             iPINValueVerify, iPIN.iMinLength, iPIN.iMaxLength, iRetValue );
   684         dlg->RunDlgLD( iStatus, R_WIM_PWPW_QUERY_DIALOG );
   667         dlg->RunDlgLD( iStatus, R_WIM_PWPW_QUERY_DIALOG );
   685         CleanupStack::PopAndDestroy( 2, dlgText1 ); // dlgText1, dlgText2
   668         CleanupStack::PopAndDestroy( 2, dlgText1 ); // dlgText1, dlgText2
   686         }
   669         }
       
   670     else if ( EExportKeyPw == dlgType )
       
   671         {
       
   672         dlgText1 = iNotifier->LoadResourceStringLC( dlgType, KNullDesC );
       
   673         dlgText2 = iNotifier->LoadResourceStringLC( EVerifyKeyStorePw, KNullDesC );
       
   674         dlg = CCTPinPinQueryDialog::NewL( *dlgText1, *dlgText2, iPINValue2,
       
   675             iPINValueVerify, iPIN.iMinLength, iPIN.iMaxLength, iRetValue );
       
   676         dlg->RunDlgLD( iStatus, R_WIM_PWPW_QUERY_DIALOG );
       
   677         CleanupStack::PopAndDestroy( 2, dlgText1 ); // dlgText1, dlgText2
       
   678         }
   687     else // Enter new PIN
   679     else // Enter new PIN
   688         {
   680         {
   689         dlgText1 = iNotifier->LoadResourceStringLC( dlgType, iPIN.iPINLabel );
   681         dlgText1 = iNotifier->LoadResourceStringLC( dlgType, iPIN.iPINLabel );
   690         dlgText2 = iNotifier->LoadResourceStringLC( EVerifyPinNR, iPIN.iPINLabel );
   682         dlgText2 = iNotifier->LoadResourceStringLC( EVerifyPinNR, iPIN.iPINLabel );
   691         dlg = CCTPinPinQueryDialog::NewL( *dlgText1, *dlgText2, iPINValue2,
   683         dlg = CCTPinPinQueryDialog::NewL( *dlgText1, *dlgText2, iPINValue2,
   692             iPINValueVerify, iPIN.iMinLength, iPIN.iMaxLength, iRetValue );
   684             iPINValueVerify, iPIN.iMinLength, iPIN.iMaxLength, iRetValue );
   693         dlg->RunDlgLD( iStatus, R_WIM_PINPIN_QUERY_DIALOG );
   685         dlg->RunDlgLD( iStatus, R_WIM_PINPIN_QUERY_DIALOG );
   694         CleanupStack::PopAndDestroy( 2, dlgText1 ); // dlgText1, dlgText2
   686         CleanupStack::PopAndDestroy( 2, dlgText1 ); // dlgText1, dlgText2
   695         }
   687         }
   696 #endif
       
   697     User::Leave( KErrGeneral );
       
   698     }
   688     }
   699 
   689 
   700 // -----------------------------------------------------------------------------
   690 // -----------------------------------------------------------------------------
   701 // CCTSecurityDialogsAO::DoHandleMessageL()
   691 // CCTSecurityDialogsAO::DoHandleMessageL()
   702 // -----------------------------------------------------------------------------
   692 // -----------------------------------------------------------------------------
   712 
   702 
   713   HBufC* dlgText = iNotifier->LoadResourceStringLC( dlgType, aDynamicText, aPinQueryHeading );
   703   HBufC* dlgText = iNotifier->LoadResourceStringLC( dlgType, aDynamicText, aPinQueryHeading );
   714 
   704 
   715   TDialogTypeItem item = iNotifier->GetDialogTypeItem( dlgType );
   705   TDialogTypeItem item = iNotifier->GetDialogTypeItem( dlgType );
   716 
   706 
   717   //CAknResourceNoteDialog* dlg = NULL;
   707   CAknResourceNoteDialog* dlg = NULL;
   718 
   708 
   719   TInt resource = 0;
   709   TInt resource = 0;
   720 
   710 
   721   switch ( item.iNoteType )
   711   switch ( item.iNoteType )
   722         {
   712         {
   723         case EInfoNote:
   713         case EInfoNote:
   724             {
   714             {
   725             // TODO
   715             dlg = new ( ELeave ) CAknInformationNote( ETrue );
   726             //dlg = new ( ELeave ) CAknInformationNote( ETrue );
       
   727             User::Leave( KErrGeneral );
       
   728             break;
   716             break;
   729             }
   717             }
   730 
   718 
   731         case EErrorNote:
   719         case EErrorNote:
   732             {
   720             {
   733             // TODO
   721             dlg = new ( ELeave ) CAknErrorNote( ETrue );
   734             //dlg = new ( ELeave ) CAknErrorNote( ETrue );
       
   735             User::Leave( KErrGeneral );
       
   736             break;
   722             break;
   737             }
   723             }
   738         case EConfirmationNote:
   724         case EConfirmationNote:
   739             {
   725             {
   740             // TODO
   726             dlg = new ( ELeave ) CAknConfirmationNote( ETrue );
   741             //dlg = new ( ELeave ) CAknConfirmationNote( ETrue );
       
   742             User::Leave( KErrGeneral );
       
   743             break;
   727             break;
   744             }
   728             }
   745         case EInfoDialog:
   729         case EInfoDialog:
   746             {
   730             {
   747             // TODO
       
   748             /*
       
   749             CCTQueryDialog::RunDlgLD( iStatus,
   731             CCTQueryDialog::RunDlgLD( iStatus,
   750                                         iRetValue,
   732                                         iRetValue,
   751                                         *dlgText, item.iSoftKeyResource,
   733                                         *dlgText, item.iSoftKeyResource,
   752                                         ECTInfoDialog );
   734                                         ECTInfoDialog );
   753             iStatus = KRequestPending;
   735             iStatus = KRequestPending;
   754             SetActive();
   736             SetActive();
   755             */
       
   756             User::Leave( KErrGeneral );
       
   757             break;
   737             break;
   758             }
   738             }
   759         case EEnterPwPwDialog:
   739         case EEnterPwPwDialog:
   760             {
   740             {
   761             // TODO
       
   762             /*
       
   763             CCTPinPinQueryDialog* dialog =
   741             CCTPinPinQueryDialog* dialog =
   764                 CCTPinPinQueryDialog::NewL( *dlgText, *dlgText,
   742                 CCTPinPinQueryDialog::NewL( *dlgText, *dlgText,
   765                 iPINValue2, iPINValueVerify, aMinLength, aMaxLength, iRetValue );
   743                 iPINValue2, iPINValueVerify, aMinLength, aMaxLength, iRetValue );
   766             dialog->RunDlgLD( iStatus, R_WIM_PWPW_QUERY_DIALOG );
   744             dialog->RunDlgLD( iStatus, R_WIM_PWPW_QUERY_DIALOG );
   767             */
       
   768             User::Leave( KErrGeneral );
       
   769             break;
   745             break;
   770             }
   746             }
   771         case EEnterPinPinCodeDialog:
   747         case EEnterPinPinCodeDialog:
   772             {
   748             {
   773             // TODO
       
   774             /*
       
   775             CCTPinPinQueryDialog* dialog =
   749             CCTPinPinQueryDialog* dialog =
   776                 CCTPinPinQueryDialog::NewL( *dlgText, *dlgText,
   750                 CCTPinPinQueryDialog::NewL( *dlgText, *dlgText,
   777                 iPINValue2, iPINValueVerify, aMinLength, aMaxLength, iRetValue );
   751                 iPINValue2, iPINValueVerify, aMinLength, aMaxLength, iRetValue );
   778             dialog->RunDlgLD( iStatus, R_WIM_PINPIN_QUERY_DIALOG );
   752             dialog->RunDlgLD( iStatus, R_WIM_PINPIN_QUERY_DIALOG );
   779             */
       
   780             User::Leave( KErrGeneral );
       
   781             break;
   753             break;
   782             }
   754             }
   783         case EEnterPwDialog:
   755         case EEnterPwDialog:
   784         case EEnterPinNRCodeDialog:
   756         case EEnterPinNRCodeDialog:
   785         case EVerifyPinNRCodeDialog:
   757         case EVerifyPinNRCodeDialog:
   819                 default:
   791                 default:
   820                     {
   792                     {
   821                     User::Panic(_L("CSecDlgNotifier"), 0);
   793                     User::Panic(_L("CSecDlgNotifier"), 0);
   822                     }
   794                     }
   823                 }
   795                 }
   824                //iPinQueryDialogDeleted = EFalse;
   796                iPinQueryDialogDeleted = EFalse;
   825                if(aDlgType!=EEnterKeyStorePw) {
   797                 CCTPinQueryDialog::RunDlgLD( iStatus,
   826                    // TODO
   798                                         *dlgText,
   827                    /*
   799                                         *pinValue,
   828                    CCTPinQueryDialog::RunDlgLD( iStatus,
   800                                         aMinLength,
   829                                             *dlgText,
   801                                         aMaxLength,
   830                                             *pinValue,
   802                                         iRetValue,
   831                                             aMinLength,
   803                                         resource,
   832                                             aMaxLength,
   804                                         iPinQueryDialog,
   833                                             iRetValue,
   805                                         iPinQueryDialogDeleted );
   834                                             resource,
       
   835                                             iPinQueryDialog,
       
   836                                             iPinQueryDialogDeleted );
       
   837                     */
       
   838                    User::Leave( KErrGeneral );
       
   839                    resource = resource;     // avoids compiler warning
       
   840                    break;
       
   841                }
       
   842                else
       
   843                {
       
   844                 iPIN.iMinLength = KMaxKeystorePwLength;
       
   845                 CSecQueryUi* SecQueryUi = CSecQueryUi::NewL();
       
   846                 HBufC* header =StringLoader::LoadLC( R_QTN_SN_ENTER_PHONE_KEYSTORE);
       
   847                 TInt queryAccepted = SecQueryUi->SecQueryDialog(header->Des(), *pinValue,
       
   848                                                         aMinLength,aMaxLength,
       
   849                                                         ESecUiAlphaSupported |
       
   850                                                         ESecUiCancelSupported |
       
   851                                                         ESecUiSecretSupported |
       
   852                                                         ESecUiEmergencyNotSupported);
       
   853                 delete SecQueryUi;
       
   854                 SecQueryUi=NULL;
       
   855                 iRetValue=(queryAccepted==KErrNone);
       
   856                 CleanupStack::PopAndDestroy( header );
       
   857                 break;
   806                 break;
   858                }
       
   859             }
   807             }
   860     default:
   808     default:
   861             {
   809             {
   862             break;
   810             break;
   863             }
   811             }
   864 
   812 
   865       }
   813       }
   866   // TODO
   814 
   867   /*
   815   if ( dlg )
   868   if ( dlg && aDlgType!=EEnterKeyStorePw)
       
   869       {
   816       {
   870 
       
   871       dlg->ExecuteLD( *dlgText );
   817       dlg->ExecuteLD( *dlgText );
   872       dlg = NULL;
   818       dlg = NULL;
   873       }
   819       }
   874       */
       
   875   User::Leave( KErrGeneral );
       
   876 
   820 
   877     CleanupStack::PopAndDestroy( dlgText ); // dlgText
   821     CleanupStack::PopAndDestroy( dlgText ); // dlgText
   878     }
   822     }
   879 
   823 
   880 // -----------------------------------------------------------------------------
   824 // -----------------------------------------------------------------------------
   895 // (other items were commented in a header).
   839 // (other items were commented in a header).
   896 // -----------------------------------------------------------------------------
   840 // -----------------------------------------------------------------------------
   897 //
   841 //
   898 void CCTSecurityDialogsAO::InitCertStoreL()
   842 void CCTSecurityDialogsAO::InitCertStoreL()
   899     {
   843     {
   900     TRACE( "CCTSecurityDialogsAO::InitCertStoreL" );
       
   901 
       
   902     switch(iOperation)
   844     switch(iOperation)
   903         {
   845         {
   904         case ESignText:
   846         case ESignText:
   905         case EUserAuthenticationText:
   847         case EUserAuthenticationText:
   906         case EUserAuthentication:
   848         case EUserAuthentication:
  1032 //
   974 //
  1033 void CCTSecurityDialogsAO::RunL()
   975 void CCTSecurityDialogsAO::RunL()
  1034     {
   976     {
  1035     WIMSECURITYDIALOGS_WRITE_FORMAT( "CCTSecurityDialogsAO::RunL, iStatus %d", iStatus.Int() );
   977     WIMSECURITYDIALOGS_WRITE_FORMAT( "CCTSecurityDialogsAO::RunL, iStatus %d", iStatus.Int() );
  1036     WIMSECURITYDIALOGS_WRITE_FORMAT( "  iNextStep %d", iNextStep );
   978     WIMSECURITYDIALOGS_WRITE_FORMAT( "  iNextStep %d", iNextStep );
  1037     TRACE1( "CCTSecurityDialogsAO::RunL, iStatus.Int()=%d", iStatus.Int() );
   979 
  1038 
   980     if ( iStatus != KErrNone )
  1039     if( iStatus != KErrNone )
       
  1040         {
   981         {
  1041         User::Leave( iStatus.Int() );
   982         User::Leave( iStatus.Int() );
  1042         }
   983         } // if
  1043 
   984 
  1044     TRACE1( "CCTSecurityDialogsAO::RunL, iNextStep=%d", iNextStep );
   985     switch ( iNextStep )
  1045     switch( iNextStep )
       
  1046       {
   986       {
  1047       case EOperationCompleted:
   987       case EOperationCompleted:
  1048         {
   988         {
  1049         WIMSECURITYDIALOGS_WRITE( "EOperationCompleted" );
   989         WIMSECURITYDIALOGS_WRITE( "EOperationCompleted" );
  1050         HandleResponseAndCompleteL();
   990         HandleResponseAndCompleteL();
  1051         break;
   991         break;
  1052         }
   992         }
  1053 
       
  1054       case ECheckServerCerts:
   993       case ECheckServerCerts:
  1055         {
   994         {
  1056         WIMSECURITYDIALOGS_WRITE( "ECheckServerCerts" );
   995         WIMSECURITYDIALOGS_WRITE( "ECheckServerCerts" );
  1057 
   996 
  1058         TBool foundCert( EFalse );
   997         TBool foundCert( EFalse );
  1059 
   998 
  1060         if( iServerCerts.Count() )
   999         if ( iServerCerts.Count() )
  1061             {
  1000             {
  1062             // Found certificates in the trusted site certificate storage.
  1001             // Found certificates in the trusted site certificate storage.
  1063             // Compare them with the one received from TlsProvider
  1002             // Compare them with the one received from TlsProvider
  1064             iCertPtr.Set( iCertBuf->Des() );
  1003             iCertPtr.Set( iCertBuf->Des() );
  1065             CX509Certificate* serverCert = CX509Certificate::NewLC( iCertPtr );
  1004             CX509Certificate* serverCert = CX509Certificate::NewLC( iCertPtr );
  1066 
  1005 
  1067             for( TInt i = 0; i < iServerCerts.Count(); i++ )
  1006             for (TInt i=0; i<iServerCerts.Count(); i++ )
  1068                 {
  1007                 {
  1069                 TPtr8 certPtr( iServerCerts[i]->Des() );
  1008                 TPtr8 certPtr( iServerCerts[i]->Des() );
       
  1009 
  1070                 CX509Certificate* cert = CX509Certificate::NewLC( certPtr );
  1010                 CX509Certificate* cert = CX509Certificate::NewLC( certPtr );
  1071                 if( cert->Fingerprint() == serverCert->Fingerprint() )
  1011 
       
  1012                 // Compare fingerprints
       
  1013                 if ( cert->Fingerprint() == serverCert->Fingerprint() )
  1072                     {
  1014                     {
       
  1015                     // Fingerprints match
  1073                     foundCert = ETrue;
  1016                     foundCert = ETrue;
  1074                     }
  1017                     }
  1075                 CleanupStack::PopAndDestroy( cert );
  1018                 CleanupStack::PopAndDestroy( cert );
  1076                 }
  1019                 }
  1077 
       
  1078              CleanupStack::PopAndDestroy( serverCert );
  1020              CleanupStack::PopAndDestroy( serverCert );
  1079 
  1021              if ( foundCert )
  1080              if( foundCert )
       
  1081                 {
  1022                 {
  1082                 // Found matching certificate. Complete the operation
  1023                 // Found matching certificate. Complete the operation
  1083                 iRetValue = EServerCertAcceptedPermanently;
  1024                 iRetValue = EServerCertAcceptedPermanently;
  1084                 iNextStep = EOperationCompleted;
  1025                 iNextStep = EOperationCompleted;
  1085                 HandleResponseAndCompleteL();
  1026                 HandleResponseAndCompleteL();
  1086                 }
  1027                 }
  1087             }
  1028             }
  1088 
  1029 
  1089         if ( !foundCert )
  1030             if ( !foundCert )
  1090             {
  1031                 {
  1091             // Couldn't find matching certificate. Prompt user
  1032                 // Couldn't find matching certificate. Prompt user
  1092             ShowNoTrustDialogL();
  1033                 ShowNoTrustDialogL();
  1093             }
  1034                 }
       
  1035 
  1094         break;
  1036         break;
  1095         }
  1037         }
  1096 
       
  1097       case EProcessTrustedSite:
  1038       case EProcessTrustedSite:
  1098         {
  1039         {
  1099         WIMSECURITYDIALOGS_WRITE( "EProcessTrustedSite" );
  1040         WIMSECURITYDIALOGS_WRITE( "EProcessTrustedSite" );
  1100         TRACE( "CCTSecurityDialogsAO::RunL, EProcessTrustedSite" );
       
  1101 
       
  1102         TInt count = iCertStore->WritableCertStoreCount();
  1041         TInt count = iCertStore->WritableCertStoreCount();
  1103         for( TInt i = 0; i < count; i++ )
  1042         for ( TInt i = 0; i < count; i++ )
  1104             {
  1043             {
  1105             MCTWritableCertStore *certstore = &iCertStore->WritableCertStore( i );
  1044             MCTWritableCertStore *certstore = &iCertStore->WritableCertStore( i );
  1106             MCTToken& token = certstore->Token();
  1045             MCTToken& token = certstore->Token();
  1107             TUid tokenuid = token.Handle().iTokenTypeUid;
  1046             TUid tokenuid = token.Handle().iTokenTypeUid;
  1108             if( tokenuid == KTrustedServerTokenUid )
  1047             if ( tokenuid == KTrustedServerTokenUid )
  1109                 {
  1048                 {
  1110                 iTrustedSiteCertStore = certstore;
  1049                 iTrustedSiteCertStore = certstore;
  1111                 }
  1050                 }
  1112             }
  1051             }
  1113 
  1052 
  1115         CleanupStack::PushL( trustedSitesStore );
  1054         CleanupStack::PushL( trustedSitesStore );
  1116 
  1055 
  1117         // Find out whether or not site associated with certificate is trusted
  1056         // Find out whether or not site associated with certificate is trusted
  1118         iTrustedSite = trustedSitesStore->IsTrustedSiteL( *iCertBuf, *iServerName );
  1057         iTrustedSite = trustedSitesStore->IsTrustedSiteL( *iCertBuf, *iServerName );
  1119 
  1058 
  1120         if( iTrustedSite )
  1059         if ( iTrustedSite )
  1121             {
  1060             {
  1122             TBool allowOutOfDate = trustedSitesStore->IsOutOfDateAllowedL(*iCertBuf, *iServerName);
  1061             TBool allowOutOfDate = trustedSitesStore->IsOutOfDateAllowedL(*iCertBuf, *iServerName);
  1123 
  1062 
  1124             if( !allowOutOfDate )
  1063             if (!allowOutOfDate)
  1125                 {
  1064                 {
  1126                 CX509Certificate* cert = CX509Certificate::NewLC( iCertBuf->Des() );
  1065                 CX509Certificate* cert = CX509Certificate::NewLC( iCertBuf->Des() );
  1127 
  1066 
  1128                 const CValidityPeriod& validityPeriod = cert->ValidityPeriod();
  1067                 const CValidityPeriod& validityPeriod = cert->ValidityPeriod();
  1129                 const TTime& startValue = validityPeriod.Start();
  1068                 const TTime& startValue = validityPeriod.Start();
  1140                 CleanupStack::PopAndDestroy( cert );
  1079                 CleanupStack::PopAndDestroy( cert );
  1141                 }
  1080                 }
  1142             }
  1081             }
  1143         CleanupStack::PopAndDestroy( trustedSitesStore );
  1082         CleanupStack::PopAndDestroy( trustedSitesStore );
  1144 
  1083 
  1145         if( iTrustedSite )
  1084         if ( iTrustedSite )
  1146             {
  1085             {
  1147             // Site is trusted. Next step is to check that server
  1086             // Site is trusted. Next step is to check that server
  1148             // certificate is in the trusted site certificate storage
  1087             // certificate is in the trusted site certificate storage
  1149             iNextStep = ERetrieveServerCerts;
  1088             iNextStep = ERetrieveServerCerts;
  1150             iStatus = KRequestPending;
  1089             iStatus = KRequestPending;
  1207             TRequestStatus* status = &iStatus;
  1146             TRequestStatus* status = &iStatus;
  1208             User::RequestComplete( status, KErrNone );
  1147             User::RequestComplete( status, KErrNone );
  1209             }
  1148             }
  1210         break;
  1149         break;
  1211         }
  1150         }
  1212 
       
  1213       case EAddTrustedSite:
  1151       case EAddTrustedSite:
  1214           {
  1152           {
  1215           TRACE( "CCTSecurityDialogsAO::RunL, EAddTrustedSite" );
  1153           if ( iStatus.Int() == KErrNone )
  1216           if( iStatus.Int() == KErrNone )
       
  1217               {
  1154               {
  1218               //Added server certificate succesfully
  1155               //Added server certificate succesfully
  1219               CTrustSitesStore* trustedSitesStore = CTrustSitesStore::NewL();
  1156               CTrustSitesStore* trustedSitesStore = CTrustSitesStore::NewL();
  1220               CleanupStack::PushL( trustedSitesStore );
  1157               CleanupStack::PushL( trustedSitesStore );
  1221 
  1158 
  1222               TInt status = trustedSitesStore->AddL( *iCertBuf, *iServerName );
  1159               TInt status = trustedSitesStore->AddL( *iCertBuf, *iServerName );
  1223 
  1160 
  1224               CleanupStack::PopAndDestroy( trustedSitesStore );
  1161               CleanupStack::PopAndDestroy( trustedSitesStore );
  1225               if( status  == KErrNone )
  1162               if ( status  == KErrNone )
  1226                   {
  1163                   {
  1227                   iRetValue = EServerCertAcceptedPermanently;
  1164                   iRetValue = EServerCertAcceptedPermanently;
  1228                   }
  1165                   }
  1229               else
  1166               else
  1230                   {
  1167                   {
  1235               HandleResponseAndCompleteL();
  1172               HandleResponseAndCompleteL();
  1236               }
  1173               }
  1237           else
  1174           else
  1238               {
  1175               {
  1239               //Adding server certificate failed
  1176               //Adding server certificate failed
  1240               // TODO: unreached code?
       
  1241               iNextStep = EOperationCompleted;
  1177               iNextStep = EOperationCompleted;
  1242               iRetValue = EServerCertNotAccepted;
  1178               iRetValue = EServerCertNotAccepted;
  1243               HandleResponseAndCompleteL();
  1179               HandleResponseAndCompleteL();
  1244               }
  1180               }
  1245           break;
  1181               break;
  1246           }
  1182           }
  1247 
  1183 
  1248       case ESaveServerCert:
  1184       case ESaveServerCert:
  1249           {
  1185           {
  1250           WIMSECURITYDIALOGS_WRITE( "ESaveServerCert" );
  1186           WIMSECURITYDIALOGS_WRITE( "ESaveServerCert" );
  1251           TRACE( "CCTSecurityDialogsAO::RunL, ESaveServerCert" );
       
  1252           DoHandleSaveServerCertL();
  1187           DoHandleSaveServerCertL();
  1253           break;
  1188           break;
  1254           }
  1189           }
  1255 
       
  1256       case EServerCertCheckUserResp:
  1190       case EServerCertCheckUserResp:
  1257           {
  1191           {
  1258           WIMSECURITYDIALOGS_WRITE( "EServerCertCheckUserResp" );
  1192           WIMSECURITYDIALOGS_WRITE( "EServerCertCheckUserResp" );
  1259           TRACE( "CCTSecurityDialogsAO::RunL, EServerCertCheckUserResp" );
  1193           if ( iRetValue == EServerCertAcceptedPermanently )
  1260           if( iRetValue == EServerCertAcceptedPermanently )
       
  1261               {
  1194               {
  1262               // User accepted to select certificate permanently.
  1195               // User accepted to select certificate permanently.
  1263               // First add server certificate
  1196               // First add server certificate
  1264               iNextStep = ESaveServerCert;
  1197               iNextStep = ESaveServerCert;
  1265               iStatus = KRequestPending;
  1198               iStatus = KRequestPending;
  1272               // User declined or temporarily accepted server certificate
  1205               // User declined or temporarily accepted server certificate
  1273               HandleResponseAndCompleteL();
  1206               HandleResponseAndCompleteL();
  1274               }
  1207               }
  1275           break;
  1208           break;
  1276           }
  1209           }
  1277 
       
  1278       case EOperationSignTextShown:
  1210       case EOperationSignTextShown:
  1279           {
  1211           {
  1280           if ( iRetValue || iOperation == EUserAuthentication )
  1212           if ( iRetValue || iOperation == EUserAuthentication )
  1281               {
  1213               {
  1282               iNextStep = EOperationInitCertStore;
  1214               iNextStep = EOperationInitCertStore;
  1289           SetActive();
  1221           SetActive();
  1290           TRequestStatus* status = &iStatus;
  1222           TRequestStatus* status = &iStatus;
  1291           User::RequestComplete( status, KErrNone );
  1223           User::RequestComplete( status, KErrNone );
  1292           break;
  1224           break;
  1293           }
  1225           }
  1294 
       
  1295       case EOperationInitCertStore:
  1226       case EOperationInitCertStore:
  1296           {
  1227           {
  1297           TInt err = KErrNone;
  1228           TInt err = KErrNone;
  1298           err = iFs.Connect();
  1229           err = iFs.Connect();
  1299           if( err != KErrNone && err != KErrAlreadyExists )
  1230           if( err != KErrNone && err != KErrAlreadyExists )
  1307           iStatus = KRequestPending;
  1238           iStatus = KRequestPending;
  1308           SetActive();
  1239           SetActive();
  1309           iNextStep = EOperationRetrieveCertInfos;
  1240           iNextStep = EOperationRetrieveCertInfos;
  1310           break;
  1241           break;
  1311           }
  1242           }
  1312 
       
  1313       case EOperationRetrieveCertInfos:
  1243       case EOperationRetrieveCertInfos:
  1314           {
  1244           {
  1315           if ( iCertInfo )
  1245           if ( iCertInfo )
  1316               {
  1246               {
  1317               iCertArray->AppendL( iCertInfo->Label() );
  1247               iCertArray->AppendL( iCertInfo->Label() );
  1343               TRequestStatus* status = &iStatus;
  1273               TRequestStatus* status = &iStatus;
  1344               User::RequestComplete( status, KErrNone );
  1274               User::RequestComplete( status, KErrNone );
  1345               }
  1275               }
  1346           break;
  1276           break;
  1347           }
  1277           }
  1348 
       
  1349       case EOperationSelectCert:
  1278       case EOperationSelectCert:
  1350           {
  1279           {
  1351           DoHandleSelectCertificateL();
  1280           DoHandleSelectCertificateL();
  1352           break;
  1281           break;
  1353           }
  1282           }
  1354 
       
  1355       case EGetCertInfo:
  1283       case EGetCertInfo:
  1356           {
  1284           {
  1357           iStatus = KRequestPending;
  1285           iStatus = KRequestPending;
  1358           iCertInfo = NULL;
  1286           iCertInfo = NULL;
  1359           iCertStore->GetCert( iCertInfo, iTokenHandle, iStatus );
  1287           iCertStore->GetCert( iCertInfo, iTokenHandle, iStatus );
  1360           iNextStep = EGetCertificate;
  1288           iNextStep = EGetCertificate;
  1361           SetActive();
  1289           SetActive();
  1362           break;
  1290           break;
  1363           }
  1291           }
  1364 
       
  1365       case EGetCertificate:
  1292       case EGetCertificate:
  1366           {
  1293           {
  1367           iStatus = KRequestPending;
  1294           iStatus = KRequestPending;
  1368           if ( iCertInfo )
  1295           if ( iCertInfo )
  1369               {
  1296               {
  1379               User::RequestComplete( status, KErrNone );
  1306               User::RequestComplete( status, KErrNone );
  1380               }
  1307               }
  1381           iNextStep = EInitKeyStore;
  1308           iNextStep = EInitKeyStore;
  1382           break;
  1309           break;
  1383           }
  1310           }
  1384 
       
  1385       case EInitKeyStore:
  1311       case EInitKeyStore:
  1386           {
  1312           {
  1387           InitKeyStoreL();
  1313           InitKeyStoreL();
  1388           iNextStep = EGetKeyInfos;
  1314           iNextStep = EGetKeyInfos;
  1389           break;
  1315           break;
  1390           }
  1316           }
  1391 
       
  1392       case EGetKeyInfos:
  1317       case EGetKeyInfos:
  1393           {
  1318           {
  1394           GetKeyInfosL();
  1319           GetKeyInfosL();
  1395           iNextStep = EShowCertDialog;
  1320           iNextStep = EShowCertDialog;
  1396           break;
  1321           break;
  1397           }
  1322           }
  1398 
       
  1399       case EGetKeyInfoByHandle:
  1323       case EGetKeyInfoByHandle:
  1400           {
  1324           {
  1401           GetKeyInfoByHandleL();
  1325           GetKeyInfoByHandleL();
  1402           iNextStep = EShowCSRDialog;
  1326           iNextStep = EShowCSRDialog;
  1403           break;
  1327           break;
  1404           }
  1328           }
  1405 
       
  1406       case EShowCSRDialog:
  1329       case EShowCSRDialog:
  1407           {
  1330           {
  1408           ShowCSRDialogL();
  1331           ShowCSRDialogL();
  1409           iNextStep = EOperationCompleted;
  1332           iNextStep = EOperationCompleted;
  1410           break;
  1333           break;
  1411           }
  1334           }
  1412 
       
  1413       case EShowCertDialog:
  1335       case EShowCertDialog:
  1414           {
  1336           {
  1415           ShowCertDialogL();
  1337           ShowCertDialogL();
  1416           iNextStep = EOperationCompleted;
  1338           iNextStep = EOperationCompleted;
  1417           break;
  1339           break;
  1418           }
  1340           }
  1419 
       
  1420       /////////////
  1341       /////////////
  1421       // PIN steps
  1342       // PIN steps
  1422       /////////////
  1343       /////////////
  1423       case EEnterNewPIN:
  1344       case EEnterNewPIN:
  1424           {
  1345           {
  1457               iPINValue2 = KNullDesC;
  1378               iPINValue2 = KNullDesC;
  1458               HandleResponseAndCompleteL();
  1379               HandleResponseAndCompleteL();
  1459               }
  1380               }
  1460           break;
  1381           break;
  1461           }
  1382           }
  1462 
       
  1463       case EVerifyPINs:
  1383       case EVerifyPINs:
  1464           {
  1384           {
  1465           VerifyPinsL();
  1385           VerifyPinsL();
  1466           break;
  1386           break;
  1467           }
  1387           }
  1468 
       
  1469       default:
  1388       default:
  1470           {
  1389           {
  1471           User::Panic( _L("CTestSecDlgNotifier"), 0 );
  1390           User::Panic( _L("CTestSecDlgNotifier"), 0 );
  1472           }
  1391           }
  1473       }
  1392       }
  1537 
  1456 
  1538     if ( !foundDevCert )
  1457     if ( !foundDevCert )
  1539         {
  1458         {
  1540         // No certificate from Device Certificate Store. Prompt user
  1459         // No certificate from Device Certificate Store. Prompt user
  1541         // for certificate selection
  1460         // for certificate selection
  1542     /*
       
  1543         CCTSelectCertificateDialog::RunDlgLD(
  1461         CCTSelectCertificateDialog::RunDlgLD(
  1544             iCertArray, iCertHandleList, iTokenHandle,
  1462             iCertArray, iCertHandleList, iTokenHandle,
  1545             iStatus, iRetValue ); // Takes ownerhip of array
  1463             iStatus, iRetValue ); // Takes ownerhip of array
  1546 
  1464 
  1547         iNextStep = EOperationCompleted;
  1465         iNextStep = EOperationCompleted;
  1548         iStatus = KRequestPending;
  1466         iStatus = KRequestPending;
  1549         SetActive();
  1467         SetActive();
  1550     */
       
  1551         User::Leave( KErrGeneral );     // TODO: to be implemented
       
  1552         }
  1468         }
  1553     }
  1469     }
  1554 
  1470 
  1555 // -----------------------------------------------------------------------------
  1471 // -----------------------------------------------------------------------------
  1556 // CCTSecurityDialogsAO::ShowNoTrustDialogL()
  1472 // CCTSecurityDialogsAO::ShowNoTrustDialogL()
  1557 // -----------------------------------------------------------------------------
  1473 // -----------------------------------------------------------------------------
  1558 //
  1474 //
  1559 void CCTSecurityDialogsAO::ShowNoTrustDialogL()
  1475 void CCTSecurityDialogsAO::ShowNoTrustDialogL()
  1560     {
  1476     {
  1561     TRACE( "CCTSecurityDialogsAO::ShowNoTrustDialogL, begin" );
  1477     // Cannot display untrusted certificate dialog if device is locked. Untrusted
  1562 
  1478     // certificate dialog would be displayed on top of possible lock code query.
  1563     // If trusted site certstore open has failed, then it is not possible to save
  1479     TInt value = 0;
  1564     // the host name for permanent use. Hence, choice for permanent accept is not
  1480     TInt err = RProperty::Get( KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, value );
  1565     // displayed if trusted site certstore open has failed. Other restrictions for
  1481     if( !err && value != EAutolockOff )
  1566     // permanent accept are defined in device dialog (UntrustedCertificateWidget).
  1482         {
  1567     TBool isTrustedSiteCertStoreOpened = ( iTrustedSiteCertStore != NULL );
  1483         iRetValue = EServerCertNotAccepted;
  1568     CCTUntrustedCertQuery *untrustedCertDlg = CCTUntrustedCertQuery::NewLC(
  1484         iStatus = KRequestPending;
  1569             iAuthFailReason, *iCertBuf, *iServerName, isTrustedSiteCertStoreOpened );
  1485         TRequestStatus* status( &iStatus );
  1570 
  1486         User::RequestComplete( status, KErrNone );
  1571     CCTUntrustedCertQuery::TResponse response = CCTUntrustedCertQuery::EQueryRejected;
  1487         }
  1572     untrustedCertDlg->ShowQueryAndWaitForResponseL( response );
  1488     else
  1573     switch( response )
  1489         {
  1574         {
  1490         CX509Certificate* cert = CX509Certificate::NewLC( iCertBuf->Des() );
  1575         case CCTUntrustedCertQuery::EQueryAccepted:
  1491         TInt dialogResourceId = R_WIM_NO_TRUST_QUERY_UNTRUSTED;
  1576             iRetValue = EServerCertAcceptedTemporarily;
  1492         TInt promptResourceId = R_QTN_ICS_SSL_CONF_Q_ACCEPT_UNTRUSTED;
  1577             break;
  1493         TBool showPermAccept = ETrue;
  1578         case CCTUntrustedCertQuery::EQueryAcceptedPermanently:
  1494 
  1579             // TODO: show confirmation note, qtn_httpsec_query_perm_accept_text
  1495         if( iAuthFailReason == ESignatureInvalid || iAuthFailReason == ECertificateRevoked )
  1580             // "Connection to site %U will be made in future without any warnings. Continue?""
  1496             {
  1581             iRetValue = EServerCertAcceptedPermanently;
  1497             // Invalid or revoked certificate
  1582             break;
  1498             CCTInvalidCertificateNote* note =
  1583         case CCTUntrustedCertQuery::EQueryRejected:
  1499                 new( ELeave ) CCTInvalidCertificateNote( *this, iStatus );
  1584         default:
  1500             note->ExecuteLD( R_WIM_INVALID_CERTIFICATE_INFORMATION_NOTE );
  1585             iRetValue = EServerCertNotAccepted;
  1501             iRetValue = EServerCertNotAccepted;
  1586             break;
  1502 
  1587         }
  1503             // CCTNoTrustQuery below self-completes this active object. It is necessary to
  1588     CleanupStack::PopAndDestroy( untrustedCertDlg );
  1504             // complete it here too, in order to run the next step EServerCertCheckUserResp.
  1589     TRACE1( "CCTSecurityDialogsAO::ShowNoTrustDialogL, iRetValue=%d", iRetValue );
  1505             iStatus = KRequestPending;
       
  1506             TRequestStatus* status( &iStatus );
       
  1507             User::RequestComplete( status, KErrNone );
       
  1508             }
       
  1509         else
       
  1510             {
       
  1511             if( iAuthFailReason == EValidatedOK || iAuthFailReason == EDateOutOfRange )
       
  1512                 {
       
  1513                 // Trusted certificate, but problems with CN or date
       
  1514 
       
  1515                 // Retrieve subject name
       
  1516                 const CX500DistinguishedName& dName = cert->SubjectName();
       
  1517 
       
  1518                 // Retrieve common name
       
  1519                 HBufC* cn = dName.ExtractFieldL( KX520CommonName );
       
  1520 
       
  1521                 // Check common name first and then date
       
  1522                 if( !cn )
       
  1523                     {
       
  1524                     // Couldn't retrieve CN from certificate
       
  1525                     dialogResourceId = R_WIM_NO_TRUST_QUERY_UNTRUSTED;
       
  1526                     promptResourceId = R_QTN_ICS_SSL_CONF_Q_ACCEPT_UNTRUSTED;
       
  1527                     }
       
  1528                 else if( iServerName->Des() != cn->Des() )
       
  1529                     {
       
  1530                     // Domain name doesn't match with CN
       
  1531                     dialogResourceId = R_WIM_NO_TRUST_QUERY_SITE;
       
  1532                     promptResourceId = R_QTN_ICS_SSL_CONF_Q_ACCEPT_SITE;
       
  1533                     }
       
  1534                 else if( iAuthFailReason == EDateOutOfRange )
       
  1535                     {
       
  1536                     // Certificate is out of date
       
  1537                     dialogResourceId = R_WIM_NO_TRUST_QUERY_OOD;
       
  1538                     promptResourceId = R_QTN_ICS_SSL_CONF_Q_ACCEPT_OOD;
       
  1539                     showPermAccept = EFalse;
       
  1540                     }
       
  1541                 else
       
  1542                     {
       
  1543                     // Otherwise show general untrusted note
       
  1544                     dialogResourceId = R_WIM_NO_TRUST_QUERY_UNTRUSTED;
       
  1545                     promptResourceId = R_QTN_ICS_SSL_CONF_Q_ACCEPT_UNTRUSTED;
       
  1546                     }
       
  1547                 }
       
  1548             else
       
  1549                 {
       
  1550                 // Untrusted certificate
       
  1551                 dialogResourceId = R_WIM_NO_TRUST_QUERY_UNTRUSTED;
       
  1552                 promptResourceId = R_QTN_ICS_SSL_CONF_Q_ACCEPT_UNTRUSTED;
       
  1553                 }
       
  1554 
       
  1555             // No "Accept Permanently" option if certificate is out of date, or
       
  1556             // if domain name is not defined, or if trusted site store failed to
       
  1557             // open (and it's not possible to save the server certificate).
       
  1558             const CValidityPeriod& validityPeriod = cert->ValidityPeriod();
       
  1559             const TTime& startValue = validityPeriod.Start();
       
  1560             const TTime& finishValue = validityPeriod.Finish();
       
  1561             TTime current;
       
  1562             current.UniversalTime();
       
  1563 
       
  1564             if( (( startValue > current ) || ( finishValue < current )) ||
       
  1565                     ( iServerName->Des().Length() == 0 ) ||
       
  1566                     ( !iTrustedSiteCertStore ) )
       
  1567                 {
       
  1568                 showPermAccept = EFalse;
       
  1569                 }
       
  1570 
       
  1571             // CCTNoTrustQuery completes iStatus asynchronously when ready. Note that
       
  1572             // it happens after ExecuteLD() and also this function have returned.
       
  1573             iStatus = KRequestPending;
       
  1574 
       
  1575             iQueryDialog = new( ELeave ) CCTNoTrustQuery( *this, iRetValue, iStatus,
       
  1576                     iServerName, showPermAccept, iQueryDialogDeleted );
       
  1577             HBufC* prompt = StringLoader::LoadLC( promptResourceId, *iServerName );
       
  1578 
       
  1579             iQueryDialog->ExecuteLD( dialogResourceId, *prompt );
       
  1580 
       
  1581             CleanupStack::PopAndDestroy( prompt );
       
  1582             }
       
  1583 
       
  1584         CleanupStack::PopAndDestroy( cert );
       
  1585         }
  1590 
  1586 
  1591     iNextStep = EServerCertCheckUserResp;
  1587     iNextStep = EServerCertCheckUserResp;
  1592     iStatus = KRequestPending;
       
  1593     TRequestStatus* status = &iStatus;
       
  1594     User::RequestComplete( status, KErrNone );
       
  1595     SetActive();
  1588     SetActive();
  1596     }
  1589     }
  1597 
  1590 
  1598 // -----------------------------------------------------------------------------
  1591 // -----------------------------------------------------------------------------
  1599 // CCTSecurityDialogsAO::ShowCSRDialogL()
  1592 // CCTSecurityDialogsAO::ShowCSRDialogL()
  1606 
  1599 
  1607     DetailsResourceL( messagePtr, R_QTN_SN_CERT_SIGN_EXPLANATION );
  1600     DetailsResourceL( messagePtr, R_QTN_SN_CERT_SIGN_EXPLANATION );
  1608 
  1601 
  1609     messagePtr.Append( KEnter );
  1602     messagePtr.Append( KEnter );
  1610 
  1603 
  1611     //DetailsFieldDynamicL( messagePtr, *iText,
  1604     DetailsFieldDynamicL( messagePtr, *iText,
  1612     //    R_TEXT_RESOURCE_DETAILS_VIEW_SUBJECT,
  1605         R_TEXT_RESOURCE_DETAILS_VIEW_SUBJECT,
  1613     //    R_TEXT_RESOURCE_VIEW_NO_SUBJECT_DETAILS );
  1606         R_TEXT_RESOURCE_VIEW_NO_SUBJECT_DETAILS );
  1614 
  1607 
  1615     AddKeyUsageL( messagePtr, iKeyInfo );
  1608     AddKeyUsageL( messagePtr, iKeyInfo );
  1616     AddKeyAlgorithmL( messagePtr, iKeyInfo );
  1609     AddKeyAlgorithmL( messagePtr, iKeyInfo );
  1617     AddKeySizeL( messagePtr, iKeyInfo );
  1610     AddKeySizeL( messagePtr, iKeyInfo );
  1618     AddKeyLocationL( messagePtr, iKeyInfo );
  1611     AddKeyLocationL( messagePtr, iKeyInfo );
  1619 
  1612 
  1620     // TODO
  1613     CCTSignTextDialog::RunDlgLD( R_WIM_CSR_DIALOG, *message, iStatus, iRetValue );
  1621     //CCTSignTextDialog::RunDlgLD( R_WIM_CSR_DIALOG, *message, iStatus, iRetValue );
       
  1622     User::Leave( KErrGeneral );
       
  1623     CleanupStack::PopAndDestroy( message );
  1614     CleanupStack::PopAndDestroy( message );
  1624 
  1615 
  1625     iStatus = KRequestPending;
  1616     iStatus = KRequestPending;
  1626     SetActive();
  1617     SetActive();
  1627     }
  1618     }
  1678         default:
  1669         default:
  1679             {
  1670             {
  1680             User::Panic(_L("CTestSecDlgNotifier"), 0);
  1671             User::Panic(_L("CTestSecDlgNotifier"), 0);
  1681             }
  1672             }
  1682         }
  1673         }
  1683     // TODO
  1674     CCTSignTextDialog::RunDlgLD( resource, *message, iStatus, iRetValue );
  1684     //CCTSignTextDialog::RunDlgLD( resource, *message, iStatus, iRetValue );
       
  1685     User::Leave( KErrGeneral );
       
  1686     resource = resource;     // avoids compiler warning
       
  1687     CleanupStack::PopAndDestroy( message );
  1675     CleanupStack::PopAndDestroy( message );
  1688 
  1676 
  1689     iStatus = KRequestPending;
  1677     iStatus = KRequestPending;
  1690     SetActive();
  1678     SetActive();
  1691     }
  1679     }
  1696 // Appends strings from both resources and CertManAPI to one
  1684 // Appends strings from both resources and CertManAPI to one
  1697 // message body text and displays it.
  1685 // message body text and displays it.
  1698 // ---------------------------------------------------------
  1686 // ---------------------------------------------------------
  1699 //
  1687 //
  1700 HBufC* CCTSecurityDialogsAO::MessageQueryCertDetailsL(
  1688 HBufC* CCTSecurityDialogsAO::MessageQueryCertDetailsL(
  1701     const TDesC8& /*aCert*/,
  1689     const TDesC8& aCert,
  1702     const CCTCertInfo* /*aCertInfo*/,
  1690     const CCTCertInfo* aCertInfo,
  1703     TCertificateFormat /*aCertFormat*/,
  1691     TCertificateFormat aCertFormat,
  1704     const CCTKeyInfo* /*aKeyInfo*/)
  1692     const CCTKeyInfo* aKeyInfo)
  1705     {
  1693     {
  1706     // Create message buffer
  1694     // Create message buffer
  1707     HBufC* message = HBufC::NewLC( KMaxLengthTextDetailsBody );
  1695     HBufC* message = HBufC::NewLC( KMaxLengthTextDetailsBody );
  1708 /*
       
  1709     TPtr messagePtr = message->Des();
  1696     TPtr messagePtr = message->Des();
  1710     // Label
  1697     // Label
  1711     if ( aCertInfo )
  1698     if ( aCertInfo )
  1712         {
  1699         {
  1713         DetailsFieldDynamicL( messagePtr, aCertInfo->Label(),
  1700         DetailsFieldDynamicL( messagePtr, aCertInfo->Label(),
  1765         default:
  1752         default:
  1766             {
  1753             {
  1767             User::Leave( KErrNotSupported );
  1754             User::Leave( KErrNotSupported );
  1768             }
  1755             }
  1769         }
  1756         }
  1770 */
  1757 
  1771     CleanupStack::Pop( message );
  1758     CleanupStack::Pop( message );
  1772     return message;
  1759     return message;
  1773     }
  1760     }
  1774 
  1761 
  1775 // -----------------------------------------------------------------------------
  1762 // -----------------------------------------------------------------------------
  1776 // CCTSecurityDialogsAO::AddIssuerAndSubjectL(...)
  1763 // CCTSecurityDialogsAO::AddIssuerAndSubjectL(...)
  1777 // -----------------------------------------------------------------------------
  1764 // -----------------------------------------------------------------------------
  1778 //
  1765 //
  1779 void CCTSecurityDialogsAO::AddSiteL( TDes& /*aMessage*/ )
  1766 void CCTSecurityDialogsAO::AddSiteL( TDes& aMessage )
  1780     {
  1767     {
  1781 /*
       
  1782     if ( iServerName )
  1768     if ( iServerName )
  1783         {
  1769         {
  1784         DetailsFieldDynamicL( aMessage, iServerName->Des(),
  1770         DetailsFieldDynamicL( aMessage, iServerName->Des(),
  1785             R_QTN_CM_SITE,
  1771             R_QTN_CM_SITE,
  1786             R_TEXT_RESOURCE_DETAILS_VIEW_NOT_DEFINED );
  1772             R_TEXT_RESOURCE_DETAILS_VIEW_NOT_DEFINED );
  1787         }
  1773         }
  1788 */
       
  1789     }
  1774     }
  1790 
  1775 
  1791 // -----------------------------------------------------------------------------
  1776 // -----------------------------------------------------------------------------
  1792 // CCTSecurityDialogsAO::AddIssuerAndSubjectL(...)
  1777 // CCTSecurityDialogsAO::AddIssuerAndSubjectL(...)
  1793 // -----------------------------------------------------------------------------
  1778 // -----------------------------------------------------------------------------
  1794 //
  1779 //
  1795 void CCTSecurityDialogsAO::AddIssuerAndSubjectL( TDes& /*aMessage*/, const CX509Certificate& /*aCert*/ )
  1780 void CCTSecurityDialogsAO::AddIssuerAndSubjectL( TDes& aMessage, const CX509Certificate& aCert )
  1796     {
  1781     {
  1797 /*
       
  1798     HBufC* issuer = NULL;
  1782     HBufC* issuer = NULL;
  1799     HBufC* owner = NULL;
  1783     HBufC* owner = NULL;
  1800     X509CertNameParser::SubjectFullNameL( aCert, owner );
  1784     X509CertNameParser::SubjectFullNameL( aCert, owner );
  1801     CleanupStack::PushL( owner );
  1785     CleanupStack::PushL( owner );
  1802     X509CertNameParser::IssuerFullNameL( aCert, issuer );
  1786     X509CertNameParser::IssuerFullNameL( aCert, issuer );
  1810     // certificate subject
  1794     // certificate subject
  1811     DetailsFieldDynamicL( aMessage, owner->Des(),
  1795     DetailsFieldDynamicL( aMessage, owner->Des(),
  1812         R_TEXT_RESOURCE_DETAILS_VIEW_SUBJECT,
  1796         R_TEXT_RESOURCE_DETAILS_VIEW_SUBJECT,
  1813         R_TEXT_RESOURCE_VIEW_NO_SUBJECT_DETAILS );
  1797         R_TEXT_RESOURCE_VIEW_NO_SUBJECT_DETAILS );
  1814     CleanupStack::PopAndDestroy( owner );   //owner
  1798     CleanupStack::PopAndDestroy( owner );   //owner
  1815 */
       
  1816     }
  1799     }
  1817 
  1800 
  1818 // -----------------------------------------------------------------------------
  1801 // -----------------------------------------------------------------------------
  1819 // CCTSecurityDialogsAO::AddKeySizeL(...)
  1802 // CCTSecurityDialogsAO::AddKeySizeL(...)
  1820 // -----------------------------------------------------------------------------
  1803 // -----------------------------------------------------------------------------
  1821 //
  1804 //
  1822 void CCTSecurityDialogsAO::AddKeySizeL( TDes& /*aMessage*/, const CCTKeyInfo* /*aKeyInfo*/ )
  1805 void CCTSecurityDialogsAO::AddKeySizeL( TDes& aMessage, const CCTKeyInfo* aKeyInfo )
  1823     {
  1806     {
  1824 /*
       
  1825     TUint keySize = aKeyInfo->Size();
  1807     TUint keySize = aKeyInfo->Size();
  1826 
  1808 
  1827     TBuf<KMaxLengthTextDateString> sizeBuf;
  1809     TBuf<KMaxLengthTextDateString> sizeBuf;
  1828     if ( 0 < keySize )
  1810     if ( 0 < keySize )
  1829         {
  1811         {
  1833     DetailsFieldDynamicL( aMessage, sizeBuf,
  1815     DetailsFieldDynamicL( aMessage, sizeBuf,
  1834         R_QTN_SN_KEY_LENGTH_LABEL,
  1816         R_QTN_SN_KEY_LENGTH_LABEL,
  1835         R_TEXT_RESOURCE_DETAILS_VIEW_NOT_DEFINED );
  1817         R_TEXT_RESOURCE_DETAILS_VIEW_NOT_DEFINED );
  1836 
  1818 
  1837     aMessage.Append( KEnterEnter );
  1819     aMessage.Append( KEnterEnter );
  1838 */
       
  1839     }
  1820     }
  1840 
  1821 
  1841 // -----------------------------------------------------------------------------
  1822 // -----------------------------------------------------------------------------
  1842 // CCTSecurityDialogsAO::AddKeyUsageL(...)
  1823 // CCTSecurityDialogsAO::AddKeyUsageL(...)
  1843 // -----------------------------------------------------------------------------
  1824 // -----------------------------------------------------------------------------
  1844 //
  1825 //
  1845 void CCTSecurityDialogsAO::AddKeyUsageL( TDes& /*aMessage*/, const CCTKeyInfo* /*aKeyInfo*/ )
  1826 void CCTSecurityDialogsAO::AddKeyUsageL( TDes& aMessage, const CCTKeyInfo* aKeyInfo )
  1846     {
  1827     {
  1847 /*
       
  1848     if ( aKeyInfo != NULL )
  1828     if ( aKeyInfo != NULL )
  1849         {
  1829         {
  1850         TKeyUsagePKCS15 keyUsage = aKeyInfo->Usage();
  1830         TKeyUsagePKCS15 keyUsage = aKeyInfo->Usage();
  1851 
  1831 
  1852         TInt usage = 0;
  1832         TInt usage = 0;
  1865                 break;
  1845                 break;
  1866             }
  1846             }
  1867         DetailsFieldResourceL( aMessage,
  1847         DetailsFieldResourceL( aMessage,
  1868             R_TEXT_RESOURCE_DETAILS_VIEW_KEY_USAGE, usage);
  1848             R_TEXT_RESOURCE_DETAILS_VIEW_KEY_USAGE, usage);
  1869         }
  1849         }
  1870 */
       
  1871     }
  1850     }
  1872 
  1851 
  1873 // -----------------------------------------------------------------------------
  1852 // -----------------------------------------------------------------------------
  1874 // CCTSecurityDialogsAO::AddKeyUsageL(...)
  1853 // CCTSecurityDialogsAO::AddKeyUsageL(...)
  1875 // -----------------------------------------------------------------------------
  1854 // -----------------------------------------------------------------------------
  1876 //
  1855 //
  1877 void CCTSecurityDialogsAO::AddKeyUsageL( TDes& /*aMessage*/, const CX509Certificate& /*aCert*/ )
  1856 void CCTSecurityDialogsAO::AddKeyUsageL( TDes& aMessage, const CX509Certificate& aCert )
  1878     {
  1857     {
  1879 /*
       
  1880   TKeyUsageX509 x509Usage = EX509UsageNone;
  1858   TKeyUsageX509 x509Usage = EX509UsageNone;
  1881   TKeyUsagePKCS15 pkcs15KeyUsage = EPKCS15UsageNone;
  1859   TKeyUsagePKCS15 pkcs15KeyUsage = EPKCS15UsageNone;
  1882   const CX509CertExtension* ext = aCert.Extension(KKeyUsage);
  1860   const CX509CertExtension* ext = aCert.Extension(KKeyUsage);
  1883   if ( ext )
  1861   if ( ext )
  1884       {
  1862       {
  1947           }
  1925           }
  1948 
  1926 
  1949       }
  1927       }
  1950    DetailsFieldResourceL( aMessage,
  1928    DetailsFieldResourceL( aMessage,
  1951           R_TEXT_RESOURCE_DETAILS_VIEW_KEY_USAGE, usage );
  1929           R_TEXT_RESOURCE_DETAILS_VIEW_KEY_USAGE, usage );
  1952 */
       
  1953    }
  1930    }
  1954 
  1931 
  1955 // -----------------------------------------------------------------------------
  1932 // -----------------------------------------------------------------------------
  1956 // CCTSecurityDialogsAO::AddKeyAlgorithmL(...)
  1933 // CCTSecurityDialogsAO::AddKeyAlgorithmL(...)
  1957 // -----------------------------------------------------------------------------
  1934 // -----------------------------------------------------------------------------
  1958 //
  1935 //
  1959 void CCTSecurityDialogsAO::AddKeyAlgorithmL( TDes& /*aMessage*/, const CCTKeyInfo* /*aKeyInfo*/ )
  1936 void CCTSecurityDialogsAO::AddKeyAlgorithmL( TDes& aMessage, const CCTKeyInfo* aKeyInfo )
  1960     {
  1937     {
  1961 /*
       
  1962     TInt algRes = 0;
  1938     TInt algRes = 0;
  1963     switch( aKeyInfo->Algorithm())
  1939     switch( aKeyInfo->Algorithm())
  1964         {
  1940         {
  1965         case CKeyInfoBase::ERSA:
  1941         case CKeyInfoBase::ERSA:
  1966             {
  1942             {
  1987             algRes = R_TEXT_RESOURCE_DETAILS_VIEW_UNKNOWN;
  1963             algRes = R_TEXT_RESOURCE_DETAILS_VIEW_UNKNOWN;
  1988             }
  1964             }
  1989         }
  1965         }
  1990     DetailsFieldResourceL( aMessage,
  1966     DetailsFieldResourceL( aMessage,
  1991             R_TEXT_RESOURCE_DETAILS_VIEW_ALGORITHM, algRes);
  1967             R_TEXT_RESOURCE_DETAILS_VIEW_ALGORITHM, algRes);
  1992 */
       
  1993     }
  1968     }
  1994 
  1969 
  1995 // -----------------------------------------------------------------------------
  1970 // -----------------------------------------------------------------------------
  1996 // CCTSecurityDialogsAO::AddCertLocationL(...)
  1971 // CCTSecurityDialogsAO::AddCertLocationL(...)
  1997 // -----------------------------------------------------------------------------
  1972 // -----------------------------------------------------------------------------
  2022 //                                               TUid* aLocUid)
  1997 //                                               TUid* aLocUid)
  2023 // Adds certificate/private key's location info to certificate details
  1998 // Adds certificate/private key's location info to certificate details
  2024 // ---------------------------------------------------------
  1999 // ---------------------------------------------------------
  2025 //
  2000 //
  2026 void CCTSecurityDialogsAO::AddLocationInfoL(
  2001 void CCTSecurityDialogsAO::AddLocationInfoL(
  2027     TDes& /*aMessage*/, TUid /*aUid*/, TBool /*aCertificate*/ )
  2002     TDes& aMessage, TUid aUid, TBool aCertificate )
  2028     {
  2003     {
  2029 /*
       
  2030     TInt location = 0;
  2004     TInt location = 0;
  2031     TInt locationRes =0;
  2005     TInt locationRes =0;
  2032 
  2006 
  2033     switch ( aUid.iUid )
  2007     switch ( aUid.iUid )
  2034         {
  2008         {
  2065         {
  2039         {
  2066         locationRes = R_TEXT_RESOURCE_DETAILS_VIEW_PRIVATE_KEY_LOCATION;
  2040         locationRes = R_TEXT_RESOURCE_DETAILS_VIEW_PRIVATE_KEY_LOCATION;
  2067         }
  2041         }
  2068 
  2042 
  2069     DetailsFieldResourceL( aMessage, locationRes, location );
  2043     DetailsFieldResourceL( aMessage, locationRes, location );
  2070 */
       
  2071     }
  2044     }
  2072 
  2045 
  2073 // -----------------------------------------------------------------------------
  2046 // -----------------------------------------------------------------------------
  2074 // CCTSecurityDialogsAO::AddValidityPeriodL(...)
  2047 // CCTSecurityDialogsAO::AddValidityPeriodL(...)
  2075 // -----------------------------------------------------------------------------
  2048 // -----------------------------------------------------------------------------
  2077 void CCTSecurityDialogsAO::AddValidityPeriodL(
  2050 void CCTSecurityDialogsAO::AddValidityPeriodL(
  2078     TDes& aMessage, const CX509Certificate& aCert )
  2051     TDes& aMessage, const CX509Certificate& aCert )
  2079     {
  2052     {
  2080     TLocale locale;
  2053     TLocale locale;
  2081     TTimeIntervalSeconds offSet = locale.UniversalTimeOffset();
  2054     TTimeIntervalSeconds offSet = locale.UniversalTimeOffset();
  2082     //DetailsResourceL( aMessage, R_TEXT_RESOURCE_DETAILS_VIEW_VALID_FROM );
  2055     DetailsResourceL( aMessage, R_TEXT_RESOURCE_DETAILS_VIEW_VALID_FROM );
  2083     const CValidityPeriod& validityPeriod = aCert.ValidityPeriod();
  2056     const CValidityPeriod& validityPeriod = aCert.ValidityPeriod();
  2084     TTime startValue = validityPeriod.Start();
  2057     TTime startValue = validityPeriod.Start();
  2085     startValue += offSet;
  2058     startValue += offSet;
  2086     TBuf<KMaxLengthTextDateString> startString;
  2059     TBuf<KMaxLengthTextDateString> startString;
  2087     // read format string from AVKON resource
  2060     // read format string from AVKON resource
  2092     AknTextUtils::DisplayTextLanguageSpecificNumberConversion( startString );
  2065     AknTextUtils::DisplayTextLanguageSpecificNumberConversion( startString );
  2093     CleanupStack::PopAndDestroy(); // dateFormatString
  2066     CleanupStack::PopAndDestroy(); // dateFormatString
  2094     aMessage.Append( startString );
  2067     aMessage.Append( startString );
  2095     aMessage.Append( KEnterEnter );
  2068     aMessage.Append( KEnterEnter );
  2096 
  2069 
  2097     //DetailsResourceL( aMessage, R_TEXT_RESOURCE_DETAILS_VIEW_VALID_UNTIL );
  2070     DetailsResourceL( aMessage, R_TEXT_RESOURCE_DETAILS_VIEW_VALID_UNTIL );
  2098     TTime finishValue = validityPeriod.Finish();
  2071     TTime finishValue = validityPeriod.Finish();
  2099     finishValue += offSet;
  2072     finishValue += offSet;
  2100     TBuf<KMaxLengthTextDateString> finishString;
  2073     TBuf<KMaxLengthTextDateString> finishString;
  2101     // read format string from AVKON resource
  2074     // read format string from AVKON resource
  2102     dateFormatString = CEikonEnv::Static()->AllocReadResourceLC(
  2075     dateFormatString = CEikonEnv::Static()->AllocReadResourceLC(
  2111 
  2084 
  2112 // -----------------------------------------------------------------------------
  2085 // -----------------------------------------------------------------------------
  2113 // CCTSecurityDialogsAO::AddCertFormatL(...)
  2086 // CCTSecurityDialogsAO::AddCertFormatL(...)
  2114 // -----------------------------------------------------------------------------
  2087 // -----------------------------------------------------------------------------
  2115 //
  2088 //
  2116 void CCTSecurityDialogsAO::AddCertFormatL( TDes& /*aMessage*/, TCertificateFormat aCertFormat)
  2089 void CCTSecurityDialogsAO::AddCertFormatL( TDes& aMessage, TCertificateFormat aCertFormat)
  2117     {
  2090     {
  2118     //TInt fieldType = 0;
  2091     TInt fieldType = 0;
  2119     switch ( aCertFormat )
  2092     switch ( aCertFormat )
  2120         {
  2093         {
  2121         case EX509CertificateUrl:
  2094         case EX509CertificateUrl:
  2122         case EX509Certificate:
  2095         case EX509Certificate:
  2123             {
  2096             {
  2124             //fieldType = R_TEXT_RESOURCE_DETAILS_VIEW_CERT_FORMAT_X509;
  2097             fieldType = R_TEXT_RESOURCE_DETAILS_VIEW_CERT_FORMAT_X509;
  2125             break;
  2098             break;
  2126             }
  2099             }
  2127         default:
  2100         default:
  2128             {
  2101             {
  2129             //fieldType = R_TEXT_RESOURCE_DETAILS_VIEW_NOT_DEFINED;
  2102             fieldType = R_TEXT_RESOURCE_DETAILS_VIEW_NOT_DEFINED;
  2130             break;
  2103             break;
  2131             }
  2104             }
  2132         }
  2105         }
  2133     //DetailsFieldResourceL( aMessage,
  2106     DetailsFieldResourceL( aMessage,
  2134     //    R_TEXT_RESOURCE_DETAILS_VIEW_CERT_FORMAT, fieldType );
  2107         R_TEXT_RESOURCE_DETAILS_VIEW_CERT_FORMAT, fieldType );
  2135     }
  2108     }
  2136 
  2109 
  2137 // -----------------------------------------------------------------------------
  2110 // -----------------------------------------------------------------------------
  2138 // CCTSecurityDialogsAO::AddCertAlgorithmsL(...)
  2111 // CCTSecurityDialogsAO::AddCertAlgorithmsL(...)
  2139 // -----------------------------------------------------------------------------
  2112 // -----------------------------------------------------------------------------
  2140 //
  2113 //
  2141 void CCTSecurityDialogsAO::AddCertAlgorithmsL( TDes& /*aMessage*/, const CX509Certificate& /*aCert*/ )
  2114 void CCTSecurityDialogsAO::AddCertAlgorithmsL( TDes& aMessage, const CX509Certificate& aCert )
  2142     {
  2115     {
  2143 /*
       
  2144     TInt fieldType = 0;
  2116     TInt fieldType = 0;
  2145     TInt fieldType2 = 0;
  2117     TInt fieldType2 = 0;
       
  2118 
  2146     // digest algorithm
  2119     // digest algorithm
  2147     TAlgorithmId algorithmId =
  2120     TAlgorithmId algorithmId = aCert.SigningAlgorithm().DigestAlgorithm().Algorithm();
  2148         aCert.SigningAlgorithm().DigestAlgorithm().Algorithm();
  2121     fieldType = AlgorithmNameResourceId( algorithmId );
  2149     switch ( algorithmId )
       
  2150         {
       
  2151         case EMD2:
       
  2152             {
       
  2153             fieldType = R_TEXT_RESOURCE_DETAILS_VIEW_ALGORITHM_MD2;
       
  2154             break;
       
  2155             }
       
  2156         case EMD5:
       
  2157             {
       
  2158             fieldType = R_TEXT_RESOURCE_DETAILS_VIEW_ALGORITHM_MD5;
       
  2159             break;
       
  2160             }
       
  2161         case ESHA1:
       
  2162             {
       
  2163             fieldType = R_TEXT_RESOURCE_DETAILS_VIEW_ALGORITHM_SHA1;
       
  2164             break;
       
  2165             }
       
  2166         default:
       
  2167             {
       
  2168             fieldType = R_TEXT_RESOURCE_DETAILS_VIEW_UNKNOWN;
       
  2169             break;
       
  2170             }
       
  2171         }
       
  2172 
  2122 
  2173     // public-key algorithm
  2123     // public-key algorithm
  2174     algorithmId =
  2124     algorithmId = aCert.SigningAlgorithm().AsymmetricAlgorithm().Algorithm();
  2175         aCert.SigningAlgorithm().AsymmetricAlgorithm().Algorithm();
  2125     fieldType2 = AlgorithmNameResourceId( algorithmId );
  2176     switch ( algorithmId )
       
  2177         {
       
  2178         case ERSA:
       
  2179             {
       
  2180             fieldType2 = R_TEXT_RESOURCE_DETAILS_VIEW_ALGORITHM_RSA;
       
  2181             break;
       
  2182             }
       
  2183         case EDSA:
       
  2184             {
       
  2185             fieldType2 = R_TEXT_RESOURCE_DETAILS_VIEW_ALGORITHM_DSA;
       
  2186             break;
       
  2187             }
       
  2188         case EDH:
       
  2189             {
       
  2190             fieldType2 = R_TEXT_RESOURCE_DETAILS_VIEW_ALGORITHM_DH;
       
  2191             break;
       
  2192             }
       
  2193         default:
       
  2194             {
       
  2195             fieldType2 = R_TEXT_RESOURCE_DETAILS_VIEW_UNKNOWN;
       
  2196             }
       
  2197         }
       
  2198 
  2126 
  2199     // If other algorithm is unknown
  2127     // If other algorithm is unknown
  2200     if ( fieldType == R_TEXT_RESOURCE_DETAILS_VIEW_UNKNOWN ||
  2128     if( fieldType == R_TEXT_RESOURCE_DETAILS_VIEW_UNKNOWN ||
  2201         fieldType2 == R_TEXT_RESOURCE_DETAILS_VIEW_UNKNOWN )
  2129         fieldType2 == R_TEXT_RESOURCE_DETAILS_VIEW_UNKNOWN )
  2202         {
  2130         {
  2203         DetailsFieldResourceL( aMessage,
  2131         DetailsFieldResourceL( aMessage,
  2204         R_TEXT_RESOURCE_DETAILS_VIEW_ALGORITHM, R_TEXT_RESOURCE_DETAILS_VIEW_UNKNOWN );
  2132         R_TEXT_RESOURCE_DETAILS_VIEW_ALGORITHM, R_TEXT_RESOURCE_DETAILS_VIEW_UNKNOWN );
  2205         }
  2133         }
  2212         stringHolder = StringLoader::LoadLC( fieldType2 );
  2140         stringHolder = StringLoader::LoadLC( fieldType2 );
  2213         aMessage.Append( stringHolder->Des() );
  2141         aMessage.Append( stringHolder->Des() );
  2214         CleanupStack::PopAndDestroy();  // stringHolder
  2142         CleanupStack::PopAndDestroy();  // stringHolder
  2215         aMessage.Append( KEnterEnter );
  2143         aMessage.Append( KEnterEnter );
  2216         }
  2144         }
  2217 */
       
  2218     }
  2145     }
  2219 
  2146 
  2220 // -----------------------------------------------------------------------------
  2147 // -----------------------------------------------------------------------------
  2221 // CCTSecurityDialogsAO::AddCertSerialNumberL(...)
  2148 // CCTSecurityDialogsAO::AddCertSerialNumberL(...)
  2222 // -----------------------------------------------------------------------------
  2149 // -----------------------------------------------------------------------------
  2223 //
  2150 //
  2224 void CCTSecurityDialogsAO::AddCertSerialNumberL( TDes& /*aMessage*/, const CX509Certificate& /*aCert*/ )
  2151 void CCTSecurityDialogsAO::AddCertSerialNumberL( TDes& aMessage, const CX509Certificate& aCert )
  2225     {
  2152     {
  2226 /*
       
  2227     // certificate serial number
  2153     // certificate serial number
  2228     DetailsResourceL( aMessage, R_TEXT_RESOURCE_DETAILS_VIEW_SERIAL_NUMBER );
  2154     DetailsResourceL( aMessage, R_TEXT_RESOURCE_DETAILS_VIEW_SERIAL_NUMBER );
  2229     TPtrC8 serialNumber = aCert.SerialNumber();
  2155     TPtrC8 serialNumber = aCert.SerialNumber();
  2230     TBuf<KMaxLengthTextSerialNumberFormatting> buf2;
  2156     TBuf<KMaxLengthTextSerialNumberFormatting> buf2;
  2231 
  2157 
  2234        buf2.Format( KCertManUIDetailsViewHexFormat, serialNumber[i] );
  2160        buf2.Format( KCertManUIDetailsViewHexFormat, serialNumber[i] );
  2235        aMessage.Append( buf2 );
  2161        aMessage.Append( buf2 );
  2236        }
  2162        }
  2237 
  2163 
  2238     aMessage.Append( KEnterEnter );
  2164     aMessage.Append( KEnterEnter );
  2239 */
       
  2240     }
  2165     }
  2241 
  2166 
  2242 // -----------------------------------------------------------------------------
  2167 // -----------------------------------------------------------------------------
  2243 // CCTSecurityDialogsAO::AddCertFingerprintsL(...)
  2168 // CCTSecurityDialogsAO::AddCertFingerprintsL(...)
  2244 // -----------------------------------------------------------------------------
  2169 // -----------------------------------------------------------------------------
  2245 //
  2170 //
  2246 void CCTSecurityDialogsAO::AddCertFingerprintsL( TDes& /*aMessage*/, const CX509Certificate& /*aCert*/ )
  2171 void CCTSecurityDialogsAO::AddCertFingerprintsL( TDes& aMessage, const CX509Certificate& aCert )
  2247     {
  2172     {
  2248 /*
       
  2249      // certificate fingerprint SHA-1
  2173      // certificate fingerprint SHA-1
  2250     DetailsResourceL( aMessage, R_TEXT_RESOURCE_DETAILS_VIEW_FINGERPRINT );
  2174     DetailsResourceL( aMessage, R_TEXT_RESOURCE_DETAILS_VIEW_FINGERPRINT );
  2251 
  2175 
  2252     TPtrC8 sha1_fingerprint = aCert.Fingerprint();
  2176     TPtrC8 sha1_fingerprint = aCert.Fingerprint();
  2253     DevideToBlocks( sha1_fingerprint, aMessage );
  2177     DevideToBlocks( sha1_fingerprint, aMessage );
  2261     CleanupStack::PushL( md5 );
  2185     CleanupStack::PushL( md5 );
  2262     TBuf8<20> fingerprint = md5->Hash( aCert.Encoding() );
  2186     TBuf8<20> fingerprint = md5->Hash( aCert.Encoding() );
  2263     CleanupStack::PopAndDestroy( md5 );
  2187     CleanupStack::PopAndDestroy( md5 );
  2264 
  2188 
  2265     DevideToBlocks( fingerprint, aMessage );
  2189     DevideToBlocks( fingerprint, aMessage );
  2266 */
       
  2267     }
  2190     }
  2268 
  2191 
  2269 // ---------------------------------------------------------
  2192 // ---------------------------------------------------------
  2270 // CCTSecurityDialogsAO::DevideToBlocks
  2193 // CCTSecurityDialogsAO::DevideToBlocks
  2271 // ---------------------------------------------------------
  2194 // ---------------------------------------------------------
  2395                 pinValueBufPtr = iPINValue1;
  2318                 pinValueBufPtr = iPINValue1;
  2396                 }
  2319                 }
  2397             iMessagePtr.WriteL( iReplySlot, pinValueBufPtr );
  2320             iMessagePtr.WriteL( iReplySlot, pinValueBufPtr );
  2398             break;
  2321             break;
  2399             }
  2322             }
  2400 
       
  2401         case EChangePIN:
  2323         case EChangePIN:
  2402         case EUnblockPIN:
  2324         case EUnblockPIN:
  2403             {
  2325             {
  2404             TTwoPINOutput twoPINOutput;
  2326             TTwoPINOutput twoPINOutput;
  2405             twoPINOutput.iPINValueToCheck = iPINValue1;
  2327             twoPINOutput.iPINValueToCheck = iPINValue1;
  2406             twoPINOutput.iNewPINValue = iPINValue2;
  2328             twoPINOutput.iNewPINValue = iPINValue2;
  2407             TTwoPINOutputBuf twoPINOutputBuf( twoPINOutput );
  2329             TTwoPINOutputBuf twoPINOutputBuf( twoPINOutput );
  2408             iMessagePtr.WriteL( iReplySlot, twoPINOutputBuf );
  2330             iMessagePtr.WriteL( iReplySlot, twoPINOutputBuf );
  2409             break;
  2331             break;
  2410             }
  2332             }
  2411 
       
  2412         case ESignText: // flow thru
  2333         case ESignText: // flow thru
  2413         case EUserAuthenticationText: // flow thru
  2334         case EUserAuthenticationText: // flow thru
  2414         case EUserAuthentication:
  2335         case EUserAuthentication:
  2415             {
  2336             {
  2416             TCTTokenObjectHandleBuf tokenObjectHandleBuf( iTokenHandle );
  2337             TCTTokenObjectHandleBuf tokenObjectHandleBuf( iTokenHandle );
  2417             iMessagePtr.WriteL( iReplySlot, tokenObjectHandleBuf );
  2338             iMessagePtr.WriteL( iReplySlot, tokenObjectHandleBuf );
  2418             break;
  2339             break;
  2419             }
  2340             }
  2420 
       
  2421         case EServerAuthenticationFailure:
  2341         case EServerAuthenticationFailure:
  2422             {
  2342             {
  2423             TServerAuthenticationFailureDialogResult result = EStop;
  2343             TServerAuthenticationFailureDialogResult result = EStop;
  2424 
  2344 
  2425             if( iRetValue != EServerCertAcceptedPermanently )
  2345             if ( iRetValue != EServerCertAcceptedPermanently )
  2426                 {
  2346                 {
  2427                 if( iRetValue == EServerCertAcceptedTemporarily )
  2347                 if ( iRetValue == EServerCertAcceptedTemporarily )
  2428                     {
  2348                     {
  2429                     result = EContinue;
  2349                     result = EContinue;
  2430                     }
  2350                     }
  2431                 else
  2351                 else
  2432                     {
  2352                     {
  2443             iMessagePtr.WriteL( iReplySlot, output );
  2363             iMessagePtr.WriteL( iReplySlot, output );
  2444             iMessagePtr.Complete( KErrNone );
  2364             iMessagePtr.Complete( KErrNone );
  2445 
  2365 
  2446             break;
  2366             break;
  2447             }
  2367             }
  2448 
       
  2449         case EPINBlocked:
  2368         case EPINBlocked:
  2450         case EUnblockPINInClear:
  2369         case EUnblockPINInClear:
  2451             {
  2370             {
  2452             User::Leave( KErrNotSupported );
  2371             User::Leave( KErrNotSupported );
  2453             break;
  2372             break;
  2454             }
  2373             }
  2455 
       
  2456         case ECreateCSR:
  2374         case ECreateCSR:
  2457         case ECertDetails:
  2375         case ECertDetails:
  2458         case ESaveCert:
  2376         case ESaveCert:
  2459         case EDeleteCert:
  2377         case EDeleteCert:
  2460         case ESaveReceipt:
  2378         case ESaveReceipt:
  2466         case MDigSigningNote::ENoSecurityModule:
  2384         case MDigSigningNote::ENoSecurityModule:
  2467         case MDigSigningNote::EInternalError:
  2385         case MDigSigningNote::EInternalError:
  2468             {
  2386             {
  2469             break; // Complete is enough
  2387             break; // Complete is enough
  2470             }
  2388             }
  2471 
       
  2472         default:
  2389         default:
  2473             User::Panic( _L("CTestSecDlgNotifier"), 0 );
  2390             User::Panic( _L("CTestSecDlgNotifier"), 0 );
  2474         }
  2391         }
  2475 
  2392 
  2476     if( iOperation != EServerAuthenticationFailure )
  2393     if( iOperation != EServerAuthenticationFailure )
  2514 // -----------------------------------------------------------------------------
  2431 // -----------------------------------------------------------------------------
  2515 //
  2432 //
  2516 void CCTSecurityDialogsAO::DoCancel()
  2433 void CCTSecurityDialogsAO::DoCancel()
  2517     {
  2434     {
  2518     WIMSECURITYDIALOGS_WRITE( "CCTSecurityDialogsAO::DoCancel" );
  2435     WIMSECURITYDIALOGS_WRITE( "CCTSecurityDialogsAO::DoCancel" );
  2519     /*
  2436 
  2520     if( !iPinQueryDialogDeleted )
  2437     // Note that iQueryDialog may point to already deleted memory.
       
  2438     // Dialogs need to set and reset iQueryDialogDeleted flag to
       
  2439     // allow deleting the dialog from CCTSecurityDialogsAO.
       
  2440     if( !iQueryDialogDeleted )
       
  2441         {
       
  2442         delete iQueryDialog;
       
  2443         iQueryDialogDeleted = ETrue;
       
  2444         }
       
  2445     iQueryDialog = NULL;
       
  2446 
       
  2447     if ( !iPinQueryDialogDeleted )
  2521         {
  2448         {
  2522         delete iPinQueryDialog;
  2449         delete iPinQueryDialog;
  2523         iPinQueryDialogDeleted = ETrue;
  2450         iPinQueryDialogDeleted = ETrue;
  2524         }
  2451         }
  2525     iPinQueryDialog = NULL;
  2452     iPinQueryDialog = NULL;
  2526     */
       
  2527 
  2453 
  2528     // Complete message if it has not been completed earlier.
  2454     // Complete message if it has not been completed earlier.
  2529     if( !iMessagePtr.IsNull() )
  2455     if( !iMessagePtr.IsNull() )
  2530         {
  2456         {
  2531         iMessagePtr.Complete( KErrCancel );
  2457         iMessagePtr.Complete( KErrCancel );
  2549 // CCTSecurityDialogsAO::DoHandleSaveServerCertL()
  2475 // CCTSecurityDialogsAO::DoHandleSaveServerCertL()
  2550 // -----------------------------------------------------------------------------
  2476 // -----------------------------------------------------------------------------
  2551 //
  2477 //
  2552 void CCTSecurityDialogsAO::DoHandleSaveServerCertL()
  2478 void CCTSecurityDialogsAO::DoHandleSaveServerCertL()
  2553     {
  2479     {
  2554     TRACE( "CCTSecurityDialogsAO::DoHandleSaveServerCertL" );
       
  2555 
       
  2556     if ( iTrustedSiteCertStore )
  2480     if ( iTrustedSiteCertStore )
  2557         {
  2481         {
  2558         iTrustedSiteCertStore->Add( *iCertLabel, EX509Certificate,
  2482         iTrustedSiteCertStore->Add( *iCertLabel, EX509Certificate,
  2559             EPeerCertificate, NULL, NULL, *iCertBuf, iStatus );
  2483                                 EPeerCertificate, NULL, NULL, *iCertBuf, iStatus );
  2560 
  2484 
  2561         // Next step is to update trust site db
  2485         // Next step is to update trust site db
  2562         iNextStep = EAddTrustedSite;
  2486         iNextStep = EAddTrustedSite;
  2563         iStatus = KRequestPending;
  2487         iStatus = KRequestPending;
  2564         SetActive();
  2488         SetActive();
  2585         default:
  2509         default:
  2586             break;
  2510             break;
  2587         }
  2511         }
  2588     }
  2512     }
  2589 
  2513 
  2590 void CCTSecurityDialogsAO::ShowInformationNoteL( TInt aResourceID ) const
       
  2591     {
       
  2592     HBufC* buffer = CEikonEnv::Static()->AllocReadResourceLC( aResourceID );
       
  2593     CHbDeviceMessageBoxSymbian* iMessageBox = CHbDeviceMessageBoxSymbian::NewL(CHbDeviceMessageBoxSymbian::EInformation);
       
  2594     CleanupStack::PushL(iMessageBox);
       
  2595     iMessageBox->SetTextL(buffer->Des());
       
  2596     iMessageBox->SetTimeout(6000);
       
  2597     iMessageBox->ExecL();
       
  2598     CleanupStack::PopAndDestroy(iMessageBox);
       
  2599     CleanupStack::PopAndDestroy( buffer );
       
  2600     }