vpnengine/ikev1lib/src/ikev1crack.cpp
branchRCL_3
changeset 49 5960d2d03390
parent 46 29c8f9bc68e1
equal deleted inserted replaced
46:29c8f9bc68e1 49:5960d2d03390
    22 #include "ikev1timeout.h"
    22 #include "ikev1timeout.h"
    23 #include "ikev1negotiation.h"
    23 #include "ikev1negotiation.h"
    24 #include "ikev1payload.h"
    24 #include "ikev1payload.h"
    25 #include "ikev1isakmpstream.h"
    25 #include "ikev1isakmpstream.h"
    26 #include "ikepolparser.h"
    26 #include "ikepolparser.h"
    27 
       
    28 
       
    29 CAuthDialogInfo::~CAuthDialogInfo()
       
    30 {
       
    31     delete iUsername;
       
    32     delete iSecret;
       
    33 }
       
    34 
       
    35 
       
    36 void CAuthDialogInfo::SetUserName( HBufC8* aUserName )
       
    37 {
       
    38     delete iUsername;
       
    39     iUsername = aUserName;
       
    40 }
       
    41 
       
    42 
       
    43 void CAuthDialogInfo::SetSecret( HBufC8* aSecret )
       
    44 {
       
    45     delete iSecret;
       
    46     iSecret = aSecret;
       
    47 }
       
    48 
    27 
    49 
    28 
    50 //
    29 //
    51 // Class that implements IKE CRACK authentication method
    30 // Class that implements IKE CRACK authentication method
    52 //
    31 //
   190  *  and send message it to gateway.
   169  *  and send message it to gateway.
   191  *  
   170  *  
   192  *-------------------------------------------------------------------------*/
   171  *-------------------------------------------------------------------------*/
   193     if ( iState & WAITING_USER_RSP ) 
   172     if ( iState & WAITING_USER_RSP ) 
   194     {    
   173     {    
   195        iState &= ~(WAITING_USER_RSP);
   174        iState &= ~(WAITING_USER_RSP + SECURID_NEXT_PIN_MODE);
   196        delete iDialog;  /* delete dialog object */
   175        delete iDialog;  /* delete dialog object */
   197        iDialog = NULL;
   176        iDialog = NULL;
   198        
   177        
   199        TUint16 attr1 = 0;
   178        TUint16 attr1 = 0;
   200        TUint16 attr2 = 0; 
   179        TUint16 attr2 = 0; 
   209         *
   188         *
   210         *--------------------------------------------------------*/
   189         *--------------------------------------------------------*/
   211        switch ( iLAMType ) 
   190        switch ( iLAMType ) 
   212        {    
   191        {    
   213            case CRACK_PASSWORD:
   192            case CRACK_PASSWORD:
   214                
       
   215                if (iNegotiation->iHostData->iSoftToken && (iPluginSession->SoftToken() != NULL))
       
   216                    {
       
   217                    HBufC8* password = NULL;
       
   218                    TInt err;
       
   219                    if (iState & SECURID_NEXT_PIN_MODE)
       
   220                        {
       
   221                        iState &= ~(SECURID_NEXT_PIN_MODE);
       
   222                        err = iPluginSession->SoftToken()->CodeL(*aDialogInfo->iSecret, password, ETrue);
       
   223                        }
       
   224                    else
       
   225                        err = iPluginSession->SoftToken()->CodeL(*aDialogInfo->iSecret, password);
       
   226                    if (KErrNone != err)
       
   227                        {
       
   228                        DEBUG_LOG(_L("Failed to get OTP from SoftToken!"));
       
   229                        delete aDialogInfo;  /* release dialog info object */
       
   230                        iDialogInfo = NULL;  /* reset dialog info pointer  */
       
   231                        return CRACK_FAILED;
       
   232                        }
       
   233                    else
       
   234                        {
       
   235                        aDialogInfo->SetSecret(password);
       
   236                        }
       
   237                    }
       
   238                    
       
   239                /*--------------------------------------------------
   193                /*--------------------------------------------------
   240                 *  Possible attributes: User name, Secret, Domain
   194                 *  Possible attributes: User name, Secret, Domain
   241                 *-------------------------------------------------*/
   195                 *-------------------------------------------------*/
   242                 attr1 = CRACK_T_USERNAME;
   196                 attr1 = CRACK_T_USERNAME;
   243                 bfr1  = aDialogInfo->iUsername;
   197                 bfr1  = aDialogInfo->iUsername;
   299     iNegotiation->iRetryNum = 0;
   253     iNegotiation->iRetryNum = 0;
   300                   
   254                   
   301     switch ( iLAMType ) 
   255     switch ( iLAMType ) 
   302     {
   256     {
   303         case CRACK_PASSWORD:
   257         case CRACK_PASSWORD:
   304             /*--------------------------------------------------
       
   305              * Request User name and pin from user
       
   306              *-------------------------------------------------*/
       
   307              if (iNegotiation->iHostData->iSoftToken && (iPluginSession->SoftToken() != NULL))
       
   308                  iDialog->GetAsyncSecureidPinDialogL(iDialogInfo, static_cast<MIkeDialogComplete*>(this));
       
   309              /*--------------------------------------------------
   258              /*--------------------------------------------------
   310               * Request User name and password (domain) from user
   259               * Request User name and password (domain) from user
   311               *-------------------------------------------------*/
   260               *-------------------------------------------------*/
   312              else
   261              iDialog->GetAsyncUNPWDialogL(iDialogInfo, (MIkeDialogComplete*)this);
   313                  iDialog->GetAsyncUNPWDialogL(iDialogInfo, static_cast<MIkeDialogComplete*>(this));
       
   314              break;
   262              break;
   315 
   263 
   316         default:     
   264         default:     
   317              status = CRACK_FAILED;
   265              status = CRACK_FAILED;
   318              break;
   266              break;
   568 }
   516 }
   569 
   517 
   570 //
   518 //
   571 // The implementation for class MIkeDialogComplete virtual function
   519 // The implementation for class MIkeDialogComplete virtual function
   572 //
   520 //
   573 TInt CIKECRACKNegotiation::DialogCompleteL(
   521 TInt CIKECRACKNegotiation::DialogCompleteL(CIkev1Dialog* /*aDialog*/, TAny* aUserInfo,
   574     TAny* aUserInfo, HBufC8* aUsername, HBufC8* aSecret)
   522                                             HBufC8* aUsername, HBufC8* aSecret, HBufC8* aDomain)
   575 {
   523 {
   576 /*---------------------------------------------------------------------------
   524 /*---------------------------------------------------------------------------
   577  *  
   525  *  
   578  *  A response received from client user (through asynchronous dialog)
   526  *  A response received from client user (through asynchronous dialog)
   579  *  This method is introduced as a TUserCallback for CGetIKEPassword dialog
   527  *  This method is introduced as a TUserCallback for CGetIKEPassword dialog
   582  *  Store credential buffers to CAuthDialogInfo object and call engine
   530  *  Store credential buffers to CAuthDialogInfo object and call engine
   583  *  entry  
   531  *  entry  
   584  *  
   532  *  
   585  *-------------------------------------------------------------------------*/
   533  *-------------------------------------------------------------------------*/
   586     TUint32 obj_id = 1;
   534     TUint32 obj_id = 1;
   587     CAuthDialogInfo* info = static_cast<CAuthDialogInfo*>(aUserInfo);
   535     CAuthDialogInfo* info = (CAuthDialogInfo*)aUserInfo;
   588 	DEBUG_LOG1(_L("CIKECRACKNegotiation::DialogCompleteL(), aUserInfo =  %x"), aUserInfo);
   536 	DEBUG_LOG1(_L("CIKECRACKNegotiation::DialogCompleteL(), aUserInfo =  %x"), aUserInfo);
   589 			
   537 			
   590     if ( info )
   538     if ( info )
   591 	{
   539 	{
   592        obj_id = info->GetObjId();
   540        obj_id = info->GetObjId();
   593        info->iNegotiation = iNegotiation;
       
   594 	   DEBUG_LOG1(_L("Preparing to call AuthDialogCompletedL(), ObjId = %x"), obj_id);
   541 	   DEBUG_LOG1(_L("Preparing to call AuthDialogCompletedL(), ObjId = %x"), obj_id);
   595        if ( obj_id == DIALOG_INFO_ID )
   542        if ( obj_id == DIALOG_INFO_ID )
   596 	   {
   543 	   {
   597           info->SetUserName( aUsername );
   544           info->iUsername = aUsername;
   598           info->SetSecret( aSecret );
   545           info->iSecret   = aSecret;
       
   546           info->iDomain   = aDomain;
   599           obj_id = info->PluginSession()->AuthDialogCompletedL(info);
   547           obj_id = info->PluginSession()->AuthDialogCompletedL(info);
   600        }
   548        }   
   601     }
   549     }
   602 
   550 
   603     return obj_id;
   551     return obj_id;
   604 }
   552 }
       
   553 
       
   554