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