vpnengine/ikev1lib/src/ikev1trans.cpp
branchRCL_3
changeset 49 5960d2d03390
parent 46 29c8f9bc68e1
--- a/vpnengine/ikev1lib/src/ikev1trans.cpp	Wed Sep 15 13:20:54 2010 +0300
+++ b/vpnengine/ikev1lib/src/ikev1trans.cpp	Wed Oct 13 15:42:16 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -36,17 +36,11 @@
 #include "ikev1crack.h"
 #include "ikev1isakmpstream.h"
 #include "ikev1crypto.h"
-#include "credentialcache.h"
-
 
 const TUint8  XAUTH_VID_DATA[8] = {0x09, 0x00, 0x26, 0x89, 0xdf, 0xd6, 0xb7, 0x12};
 const TUint8  CISCO_UNITY_VID_DATA[16] = {0x12, 0xf5, 0xf2, 0x8c, 0x45, 0x71, 0x68, 0xa9,
                                           0x70, 0x2d, 0x9f, 0xe2, 0x74, 0xcc, 0x01, 0x00};
                                           
-const TInt KCredentialTypeUnknown = 0;
-const TInt KCredentialTypeNew     = 1;
-const TInt KCredentialTypeCached  = 2;
-
                                           
 CTransNegotiation::CTransNegotiation( TInt aGranularity,
                                       TBool aUseXauth,
@@ -99,9 +93,8 @@
     delete iInternalAddr;
     delete iDialog;
     delete iDialogInfo;
-	delete iUserName;
-	delete iCache;
-
+	delete iUserName; 	
+            
     for ( TInt i = 0; i < Count(); i++ )
     {
         delete At(i);
@@ -121,7 +114,8 @@
     {
         User::Leave(KErrArgument);   
     }
-    
+       
+    DEBUG_LOG(_L("Transaction exchange object constructed"));  
     if ( !iUseXauth ) 
     {
        iXauthCompleted = ETrue;
@@ -132,14 +126,7 @@
        if ( !iUseCfgMode ) 
            iCfgModeCompleted = ETrue;
        DEBUG_LOG(_L("Starting to Wait XAUTH request"));  
-    }
-
-    if( EFalse != iPluginSession->IkeData().iUseCache )
-    {
-        iCache = CCredentialCache::NewL( iDebug );
-    }
-
-    DEBUG_LOG(_L("Transaction exchange object constructed"));  
+    }    
 }
 
 /**-------------------------------------------------------------------
@@ -296,12 +283,7 @@
   	      iUserName = HBufC8::New(aDialogInfo->iUsername->Length() + 16); // 16 bytes space for padding
 		  if ( iUserName ) {
 		     iUserName->Des().Copy(aDialogInfo->iUsername->Des()); 
-		  }
-		  
-		  if( iCache && KCredentialTypeNew == iCredentialType )
-		  {
-		      iCache->SetUserName( *aDialogInfo->iUsername );
-		  }
+		  } 	   
        }
 
        if ( aDialogInfo->iSecret ) {
@@ -326,12 +308,9 @@
                   break;
 
               default:
-                  if( iCache && KCredentialTypeNew == iCredentialType )
-                  {
-                      iCache->SetSecret( *aDialogInfo->iSecret );
-                  }
                   break;
-          }
+                   
+          }   
           AddAttributeData(attr_ptr, AttrType, aDialogInfo->iSecret->Length(),
                           (TUint8*)aDialogInfo->iSecret->Ptr());           
        }
@@ -821,7 +800,9 @@
             //
             //  User name/Password authentication required
             //
-			GetCredentialsL();
+			iDialog     = CIkev1Dialog::NewL(iPluginSession, iPluginSession->DialogAnchor(), iDebug);			
+            iDialogInfo = new(ELeave) CAuthDialogInfo(iPluginSession, XAUTH_DIALOG_ID, iNegotiation->SAId(), iCurrExchange->iMessageId);
+            iDialog->GetAsyncUNPWDialogL(iDialogInfo, (MIkeDialogComplete*)this);          
             break;
 
         case ( (1 << (ATTR_USER_NAME - ATTR_XAUTH_TYPE)) | (1 << (ATTR_PASSCODE - ATTR_XAUTH_TYPE))):
@@ -830,7 +811,7 @@
             //
             iDialog     = CIkev1Dialog::NewL(iPluginSession, iPluginSession->DialogAnchor(), iDebug);
             iDialogInfo = new(ELeave) CAuthDialogInfo(iPluginSession, XAUTH_DIALOG_ID, iNegotiation->SAId(), iCurrExchange->iMessageId);
-            iDialog->GetAsyncSecureidDialogL(iDialogInfo, static_cast<MIkeDialogComplete*>(this));          
+            iDialog->GetAsyncSecureidDialogL(iDialogInfo, (MIkeDialogComplete*)this);          
             break;
 
         case ( (1 << (ATTR_USER_NAME - ATTR_XAUTH_TYPE)) | (1 << (ATTR_NEXT_PIN - ATTR_XAUTH_TYPE))):
@@ -839,7 +820,7 @@
             //
 			iDialog     = CIkev1Dialog::NewL(iPluginSession, iPluginSession->DialogAnchor(), iDebug);			
 			iDialogInfo = new(ELeave) CAuthDialogInfo(iPluginSession, XAUTH_DIALOG_ID, iNegotiation->SAId(), iCurrExchange->iMessageId);
-            iDialog->GetAsyncSecureNextPinDialogL(iDialogInfo, static_cast<MIkeDialogComplete*>(this));
+            iDialog->GetAsyncSecureNextPinDialogL(iDialogInfo, (MIkeDialogComplete*)this);
             break;
 
         case ( (1 << (ATTR_CHALLENGE - ATTR_XAUTH_TYPE)) ):
@@ -850,7 +831,7 @@
 			{
 				iDialog     = CIkev1Dialog::NewL(iPluginSession, iPluginSession->DialogAnchor(), iDebug);			
 				iDialogInfo = new(ELeave) CAuthDialogInfo(iPluginSession, XAUTH_DIALOG_ID, iNegotiation->SAId(), iCurrExchange->iMessageId);
-                iDialog->GetAsyncRespDialog(challenge, iDialogInfo, static_cast<MIkeDialogComplete*>(this));
+                iDialog->GetAsyncRespDialog(challenge, iDialogInfo, (MIkeDialogComplete*)this);
             }   
             break;
 
@@ -860,6 +841,7 @@
     }   
     
     return status;
+
 }
 
 /**-------------------------------------------------------------------
@@ -874,13 +856,12 @@
     TBuf8<16> attributes;    
     TInt      status = TRANSACTION_CONTINUE;
     TInt16    attr_status;
-
+    
     while ( aLth > 0 ) {
         
         aLth = aLth - aAttr->Size();
         if ( aLth < 0 ) {
            DEBUG_LOG(_L("XAUTH SET ERROR (Length mismatch in the attibutes)"));
-           iCredentialType = KCredentialTypeUnknown;
            return TRANSACTION_FAILED;
         }
 
@@ -920,19 +901,14 @@
        if ( status == TRANSACTION_SUCCESS ) {
           DEBUG_LOG(_L("XAUTH authentication succeeded!"));
           iXauthCompleted = ETrue;
-
-          if( iCache && KCredentialTypeNew == iCredentialType )
-          {
-              iCache->Store( iPluginSession->VpnIapId() );
-          }
-
 		  if ( iUserName ) {
+		     //
     		 // Cache user name into user name file
+			 //
 		     CIkev1Dialog* Dialog = CIkev1Dialog::NewL(iPluginSession, iPluginSession->DialogAnchor(), iDebug);
              CleanupStack::PushL(Dialog);
 			 TInt err(KErrNone);
 			 TRAP(err, Dialog->StoreUserNameL(iUserName->Des()));
-			 
 #ifdef _DEBUG			 
 			 if (err == KErrNone)
 			     DEBUG_LOG(_L("User Name caching succeeded"));
@@ -942,16 +918,13 @@
 		  }	   
        }            
        else {
-          if( iCache )
-          {
-              iCache->Clear(); 
-          }
           DEBUG_LOG(_L("XAUTH authentication failed!"));
+	   // Dialog object shall be delete in Dialog->RunL when dialog completed				  
+          CIkev1Dialog* Dialog  = CIkev1Dialog::NewL(iPluginSession, iPluginSession->DialogAnchor(), iDebug);		  
+          Dialog->ShowErrorDialogL(TVpnNoteDialog::EKmdAuthenticationFailed, NULL, NULL);
        }
     }
-
-    iCredentialType = KCredentialTypeUnknown;
-
+    
     return status;
 }
 
@@ -1007,6 +980,7 @@
  *--------------------------------------------------------------------*/
 TInt CTransNegotiation::BuildConfigRequestL()
 {
+
     TBuf8<16> attributes;
     
     TUint32  message_id = iNegotiation->RandomMessageId();
@@ -1024,6 +998,8 @@
     DEBUG_LOG(_L("CONFIG-MODE started, request xmitted!")); 
 
     return TRANSACTION_CONTINUE;
+
+    
 }
 
 /**-------------------------------------------------------------------
@@ -1138,8 +1114,8 @@
 //
 // The implementation for class MIkeDialogComplete virtual function
 //
-TInt CTransNegotiation::DialogCompleteL(
-    TAny* aUserInfo, HBufC8* aUsername, HBufC8* aSecret)
+TInt CTransNegotiation::DialogCompleteL(CIkev1Dialog* /*aDialog*/, TAny* aUserInfo,
+								        HBufC8* aUsername, HBufC8* aSecret, HBufC8* aDomain)
 {
 /*---------------------------------------------------------------------------
  *  
@@ -1153,66 +1129,20 @@
  *-------------------------------------------------------------------------*/
 	TUint32 obj_id = 1;
 	CAuthDialogInfo* info = (CAuthDialogInfo*)aUserInfo;
-	DEBUG_LOG1(_L("CTransNegotiation::DialogCompleteL(), aUserInfo=%x"), aUserInfo);
+	DEBUG_LOG1(_L("CIKECRACKNegotiation::DialogCompleteL(), aUserInfo =  %x"), aUserInfo);
 
 	if ( info )
 	{
 		obj_id = info->GetObjId();
-		info->iNegotiation = iNegotiation;
 		DEBUG_LOG1(_L("Preparing to call AuthDialogCompletedL(), ObjId = %x"), obj_id);
 		if ( obj_id == XAUTH_DIALOG_ID )
 		{
-			info->SetUserName( aUsername );
-			info->SetSecret( aSecret );
+			info->iUsername = aUsername;
+			info->iSecret   = aSecret;
+			info->iDomain   = aDomain;
 			obj_id = info->PluginSession()->AuthDialogCompletedL(info);
-		}
+		}   
 	}
 
 	return obj_id;
 }
-
-
-void CTransNegotiation::GetCredentialsL()
-{
-    DEBUG_LOG( _L( "CTransNegotiation::GetCredentialsL" ) );
-
-    TInt ret = KErrNotFound;
-
-    delete iDialogInfo;  iDialogInfo = NULL;
-
-    iDialogInfo = new (ELeave) CAuthDialogInfo(
-        iPluginSession,
-        XAUTH_DIALOG_ID,
-        iNegotiation->SAId(),
-        iCurrExchange->iMessageId );
-
-    if( iCache && KCredentialTypeUnknown == iCredentialType )
-    {
-        ret = iCache->GetCredentials(
-            iPluginSession->VpnIapId(),
-            iDialogInfo->iUsername,
-            iDialogInfo->iSecret
-        );
-    }
-
-    if( KErrNone == ret )
-    {
-        iCredentialType = KCredentialTypeCached;
-        iDialogInfo->iNegotiation = iNegotiation;
-        TUint32 id = iPluginSession->AuthDialogCompletedL( iDialogInfo );
-    }
-    else
-    {
-        iCredentialType = KCredentialTypeNew;
-
-        delete iDialog;  iDialog = NULL;
-
-        iDialog = CIkev1Dialog::NewL(
-            iPluginSession, iPluginSession->DialogAnchor(), iDebug );
-
-        iDialog->GetAsyncUNPWDialogL( iDialogInfo, static_cast<MIkeDialogComplete*>(this) );
-    }
-}
-
-
-/***/