Revision: 201035 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 15 Sep 2010 13:20:54 +0300
branchRCL_3
changeset 46 29c8f9bc68e1
parent 44 735de8341ce4
child 49 5960d2d03390
Revision: 201035 Kit: 201036
group/vpnclient_version_update.flm
vpnc_plat/vpnapi/group/bld.inf
vpnc_plat/vpnapi/inc/softtokenpluginif.h
vpnc_plat/vpnapi/inc/softtokenpluginif.inl
vpnengine/ikepolparser/inc/ikepolparser.h
vpnengine/ikepolparser/src/ikepolparser.cpp
vpnengine/ikev1lib/group/ikev1lib.mmp
vpnengine/ikev1lib/inc/ikev1crack.h
vpnengine/ikev1lib/inc/ikev1dialog.h
vpnengine/ikev1lib/inc/ikev1negotiation.h
vpnengine/ikev1lib/inc/ikev1plugin.h
vpnengine/ikev1lib/inc/ikev1pluginsession.h
vpnengine/ikev1lib/src/ikev1crack.cpp
vpnengine/ikev1lib/src/ikev1dialog.cpp
vpnengine/ikev1lib/src/ikev1negotiation.cpp
vpnengine/ikev1lib/src/ikev1plugin.cpp
vpnengine/ikev1lib/src/ikev1pluginsession.cpp
vpnengine/ikev1lib/src/ikev1trans.cpp
vpnengine/vpncommon/inc/vpnnotifierdefs.h
vpnengine/vpnmanager/inc/policyimporter.h
vpnengine/vpnmanager/src/policyimporter.cpp
vpnengine/vpnmanager/src/vpnapiservant.cpp
vpnui/vpndialogmanager/group/vpndialogmanager.mmp
vpnui/vpndialogmanager/inc/vpndialogshower.h
vpnui/vpndialogmanager/src/vpndialogmanager.cpp
vpnui/vpndialogmanager/src/vpndialogshower.cpp
vpnui/vpnecomnotifier/data/vpnecomnotifier.rss
vpnui/vpnecomnotifier/loc/vpnnotifier.loc
vpnui/vpnmanagementui/inc/vpnmanagementuiview.h
vpnui/vpnmanagementui/src/vpnmanagementuiview.cpp
vpnui/vpnmanagementui/src/vpnuiloader.cpp
--- a/group/vpnclient_version_update.flm	Tue Sep 14 23:16:15 2010 +0300
+++ b/group/vpnclient_version_update.flm	Wed Sep 15 13:20:54 2010 +0300
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# Copyright (c) 2009-2010 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"
@@ -22,9 +22,8 @@
 # The file destinations  relative to EPOCROOT
 # ============================================================================
 
-
 define updateversion
-$(GUARD):=1
+$(GUARD_VPNVU):=1
 
 BITMAP:: $(EXTENSION_ROOT)/$(VU_TOOL)
 	$(call startrule,vpnclient_version_update,FORCESUCCESS) \
@@ -32,7 +31,6 @@
 	$(call endrule,vpnclient_version_update)
 endef
 
-ifeq ($($(GUARD)),)
+ifeq ($($(GUARD_VPNVU)),)
 $(eval -$(updateversion))
 endif
-
--- a/vpnc_plat/vpnapi/group/bld.inf	Tue Sep 14 23:16:15 2010 +0300
+++ b/vpnc_plat/vpnapi/group/bld.inf	Wed Sep 15 13:20:54 2010 +0300
@@ -24,3 +24,6 @@
   ../inc/vpnapidefs.h             MW_LAYER_PLATFORM_EXPORT_PATH(vpnapidefs.h)
   ../inc/vpnapi.h                 MW_LAYER_PLATFORM_EXPORT_PATH(vpnapi.h)
   ../inc/vpnsipobserverpskeys.h   MW_LAYER_PLATFORM_EXPORT_PATH(vpnsipobserverpskeys.h)
+  ../inc/softtokenpluginif.h      MW_LAYER_PLATFORM_EXPORT_PATH(softtokenpluginif.h)
+  ../inc/softtokenpluginif.inl    MW_LAYER_PLATFORM_EXPORT_PATH(softtokenpluginif.inl)
+  
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vpnc_plat/vpnapi/inc/softtokenpluginif.h	Wed Sep 15 13:20:54 2010 +0300
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2010 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Soft Token plugin interface.
+* 
+*/
+
+#ifndef __SOFTTOKENPLUGIN_H
+#define __SOFTTOKENPLUGIN_H
+
+#include <e32base.h>
+#include <ecom/ecom.h>
+ 
+const TUid KCSoftTokenImplUid = {0x20031614};
+/**
+ *  Soft Token plugin interface.
+ *
+ *  Soft Token plugin interface provides functionality for generating OTPs
+ *  (One Time Passwords).
+ *
+ */
+
+class CSoftTokenPluginIf : public CBase
+    {
+    public:
+        /**
+         * Instantiates an object of this type .
+         */
+        static CSoftTokenPluginIf* NewL();
+        /**
+         * Destructor.
+         */
+        virtual ~CSoftTokenPluginIf();
+        /**
+         * Checks if default token is found.
+         * @return True if there is a token available.
+         */
+        virtual TBool DefaultFoundL() = 0;
+        /**
+         * Gets code from default token.
+         * @param aPin PIN of token.
+         * @param aOTP One Time Password.
+         * @param aNextCode True if next code is requested.
+         * @return KErrNone if the OTP received or a system-wide error code.
+         */
+        virtual TInt CodeL(const TDesC8& aPin, HBufC8*& aOTP, TBool aNextCode = EFalse) = 0;
+        
+    private:
+        TUid iDtor_ID_Key;
+    };
+
+#include "softtokenpluginif.inl"
+
+#endif // __SOFTTOKENPLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vpnc_plat/vpnapi/inc/softtokenpluginif.inl	Wed Sep 15 13:20:54 2010 +0300
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2010 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Soft Token plugin interface inline.
+* 
+*/
+
+#ifndef __SOFTTOKENPLUGIN_INL__
+#define __SOFTTOKENPLUGIN_INL__
+
+_LIT8(KDefaultImplementation,"*");
+_LIT8(KDefaultPluginImpl,"softtokenplugin"); // default_data = "softtokenplugin";
+
+inline CSoftTokenPluginIf::~CSoftTokenPluginIf()
+	{
+	// Destroy any instance variables and then
+	// inform the framework that this specific 
+	// instance of the interface has been destroyed.
+	REComSession::DestroyedImplementation(iDtor_ID_Key);
+	}
+
+inline CSoftTokenPluginIf* CSoftTokenPluginIf::NewL()
+	{
+         return REINTERPRET_CAST(CSoftTokenPluginIf*, 
+                REComSession::CreateImplementationL(KCSoftTokenImplUid, 
+                _FOFF(CSoftTokenPluginIf,iDtor_ID_Key)));
+        }
+#endif // __SOFTTOKENPLUGIN_INL__
--- a/vpnengine/ikepolparser/inc/ikepolparser.h	Tue Sep 14 23:16:15 2010 +0300
+++ b/vpnengine/ikepolparser/inc/ikepolparser.h	Wed Sep 15 13:20:54 2010 +0300
@@ -291,7 +291,8 @@
     TOwnCertInfo iOwnCert;
     TCertInfo iPrivKey;
     TCertInfo iPeerCert;
-    TBool     iUseCache;  // Use credential cache
+    TBool     iUseCache;   // Use credential cache
+    TBool     iSoftToken;  // Use soft token
 };
 
 
--- a/vpnengine/ikepolparser/src/ikepolparser.cpp	Tue Sep 14 23:16:15 2010 +0300
+++ b/vpnengine/ikepolparser/src/ikepolparser.cpp	Wed Sep 15 13:20:54 2010 +0300
@@ -170,7 +170,7 @@
             CleanupStack::Pop(ca_copy);
             }
         }
-        
+    iSoftToken = aData->iSoftToken;   
     iUseCache = aData->iUseCache;
     }
 
@@ -735,6 +735,13 @@
             if (token.CompareF(_L("True"))==0)
                 aConf->iUseCache = ETrue;
         }
+        else if (token.CompareF(_L("TOKEN_TYPE:"))==0)   //CompareF ignores case
+        {
+            aConf->iSoftToken = EFalse;          
+            token.Set(NextToken());
+            if (token.CompareF(_L("SOFT"))==0)
+                aConf->iSoftToken = ETrue;
+        }
     }
 	if ( err == KErrNone )
 		errCA=CheckPolicy(aConf);
@@ -1125,6 +1132,15 @@
     if (err != KErrNone)
         return err;
 
+    line.Copy(_L8("TOKEN_TYPE: "));
+    if (aConf->iSoftToken)
+        line.Append(_L("SOFT\n"));
+    else
+        line.Append(_L("HARD\n"));
+    err = BufferAppend(aPolBfr, line);
+    if (err != KErrNone)
+        return err;
+		
     if ( aConf->iCRACKLAMUserName )
 	{
 		line.Copy(_L8("CRACK_LAM_USERNAME: "));
--- a/vpnengine/ikev1lib/group/ikev1lib.mmp	Tue Sep 14 23:16:15 2010 +0300
+++ b/vpnengine/ikev1lib/group/ikev1lib.mmp	Wed Sep 15 13:20:54 2010 +0300
@@ -72,3 +72,4 @@
 LIBRARY     ikesocket.lib
 LIBRARY     random.lib
 LIBRARY     ikeutils.lib
+LIBRARY     ecom.lib
--- a/vpnengine/ikev1lib/inc/ikev1crack.h	Tue Sep 14 23:16:15 2010 +0300
+++ b/vpnengine/ikev1lib/inc/ikev1crack.h	Wed Sep 15 13:20:54 2010 +0300
@@ -50,6 +50,7 @@
  *---------------------------------------------------------------------------*/
 #define DIALOG_INFO_ID        0xfedcba98
 #define XAUTH_DIALOG_ID       0x76543210
+#define ERROR_DIALOG_ID       0x87654321
 
 class CIkev1Negotiation;
 class TNotificationISAKMP;
@@ -78,7 +79,7 @@
     CIkev1PluginSession* iPluginSession;  // Plugin session pointer  
     TUint32              iSAId;       // SA id of CIkev1Negotiation
     TUint32              iMsgId;      // Transaction exchange message ID
-    
+
 public: 
     /**
      * Username from UI dialog or cache.
@@ -91,6 +92,13 @@
      * Own.
      */    
     HBufC8* iSecret;
+    
+    /**
+     * Negotiation pointer
+     * Not own.
+     */    
+    CIkev1Negotiation*   iNegotiation;
+
     };
 
 
--- a/vpnengine/ikev1lib/inc/ikev1dialog.h	Tue Sep 14 23:16:15 2010 +0300
+++ b/vpnengine/ikev1lib/inc/ikev1dialog.h	Wed Sep 15 13:20:54 2010 +0300
@@ -76,6 +76,7 @@
 
     void GetAsyncUNPWDialogL(TAny *aUserInfo, MIkeDialogComplete* aCallback);
     void GetAsyncUNAMEDialog(TAny *aUserInfo, MIkeDialogComplete* aCallback);    
+    void GetAsyncSecureidPinDialogL(TAny *aUserInfo, MIkeDialogComplete*  aCallback);
     void GetAsyncSecureidDialogL(TAny *aUserInfo, MIkeDialogComplete*  aCallback);
     void GetAsyncSecureNextPinDialogL(TAny *aUserInfo, MIkeDialogComplete* aCallback);    
     void GetAsyncRespDialog(TPtr8 aChallenge, TAny *aUserInfo, MIkeDialogComplete* aCallback);
--- a/vpnengine/ikev1lib/inc/ikev1negotiation.h	Tue Sep 14 23:16:15 2010 +0300
+++ b/vpnengine/ikev1lib/inc/ikev1negotiation.h	Wed Sep 15 13:20:54 2010 +0300
@@ -155,6 +155,7 @@
 	inline TUint32 SAId() {return iSAId;}			
 	TIkev1IsakmpStream* SaveIkeMsgBfr(TIkev1IsakmpStream* aMsg);
     void AuthDialogCompletedL(CAuthDialogInfo *aUserInfo);
+    void ErrDialogCompletedL();
 	TInt32 RandomMessageId();
 	void SendDeleteL(TUint8 aProtocol, TUint32 aIpsecSPI = 0);   //Send a Delete payload for the negotiation
 	void SendKeepAliveMsgL(TIkev1SAData* aSa);
--- a/vpnengine/ikev1lib/inc/ikev1plugin.h	Tue Sep 14 23:16:15 2010 +0300
+++ b/vpnengine/ikev1lib/inc/ikev1plugin.h	Wed Sep 15 13:20:54 2010 +0300
@@ -19,6 +19,7 @@
 #define C_IKEV1PLUGIN_H
 
 #include <e32base.h>
+#include <softtokenpluginif.h>
 
 #include "ikepluginif.h"
 #include "pfkeysocketif.h"
@@ -90,7 +91,11 @@
      * Returns event logger interface.
      */
     MKmdEventLoggerIf& EventLogger();
-    
+
+    /** 
+      * Returns SoftToken interface.
+      */
+    CSoftTokenPluginIf* SoftToken();
 	
 // Methods to build and send PFKEY API primitives to IPsec
     
@@ -170,6 +175,13 @@
      * Not own.
      */
 	MIkeDebug&                      iDebug;
+
+    /**
+     * SoftToken plugin.
+     * Own.
+     */
+    CSoftTokenPluginIf* iSoftToken;
+
     };
 
 
--- a/vpnengine/ikev1lib/inc/ikev1pluginsession.h	Tue Sep 14 23:16:15 2010 +0300
+++ b/vpnengine/ikev1lib/inc/ikev1pluginsession.h	Wed Sep 15 13:20:54 2010 +0300
@@ -20,6 +20,7 @@
 #define C_IKEV1PLUGINSESSION_H
 
 #include <in_sock.h>
+#include <softtokenpluginif.h>
 
 #include "vpnmandefs.h"
 #include "ikemsgheader.h"
@@ -273,6 +274,13 @@
      * @return Error value
      */
     TInt AuthDialogCompletedL( CAuthDialogInfo* aUserInfo );  
+
+    /**
+     * Handles completion of error dialog processing.
+     * @param aUserInfo User info
+     * @return Error value
+     */
+    TInt ErrDialogCompletedL( CAuthDialogInfo* aUserInfo );  
     
     /**
      * Handles change of internal address.
@@ -341,7 +349,13 @@
      * @return Eveng logger interface
      */
     MKmdEventLoggerIf& EventLogger();
-    
+
+    /**
+     * Returns SoftToken interface.
+     * @return SoftToken interface
+     */
+    CSoftTokenPluginIf* SoftToken();
+
     /**
      * Returns internal address (NULL if does not exist).
      * @return Internal address. Ownership transferred.
--- a/vpnengine/ikev1lib/src/ikev1crack.cpp	Tue Sep 14 23:16:15 2010 +0300
+++ b/vpnengine/ikev1lib/src/ikev1crack.cpp	Wed Sep 15 13:20:54 2010 +0300
@@ -192,7 +192,7 @@
  *-------------------------------------------------------------------------*/
     if ( iState & WAITING_USER_RSP ) 
     {    
-       iState &= ~(WAITING_USER_RSP + SECURID_NEXT_PIN_MODE);
+       iState &= ~(WAITING_USER_RSP);
        delete iDialog;  /* delete dialog object */
        iDialog = NULL;
        
@@ -211,6 +211,31 @@
        switch ( iLAMType ) 
        {    
            case CRACK_PASSWORD:
+               
+               if (iNegotiation->iHostData->iSoftToken && (iPluginSession->SoftToken() != NULL))
+                   {
+                   HBufC8* password = NULL;
+                   TInt err;
+                   if (iState & SECURID_NEXT_PIN_MODE)
+                       {
+                       iState &= ~(SECURID_NEXT_PIN_MODE);
+                       err = iPluginSession->SoftToken()->CodeL(*aDialogInfo->iSecret, password, ETrue);
+                       }
+                   else
+                       err = iPluginSession->SoftToken()->CodeL(*aDialogInfo->iSecret, password);
+                   if (KErrNone != err)
+                       {
+                       DEBUG_LOG(_L("Failed to get OTP from SoftToken!"));
+                       delete aDialogInfo;  /* release dialog info object */
+                       iDialogInfo = NULL;  /* reset dialog info pointer  */
+                       return CRACK_FAILED;
+                       }
+                   else
+                       {
+                       aDialogInfo->SetSecret(password);
+                       }
+                   }
+                   
                /*--------------------------------------------------
                 *  Possible attributes: User name, Secret, Domain
                 *-------------------------------------------------*/
@@ -276,10 +301,16 @@
     switch ( iLAMType ) 
     {
         case CRACK_PASSWORD:
+            /*--------------------------------------------------
+             * Request User name and pin from user
+             *-------------------------------------------------*/
+             if (iNegotiation->iHostData->iSoftToken && (iPluginSession->SoftToken() != NULL))
+                 iDialog->GetAsyncSecureidPinDialogL(iDialogInfo, static_cast<MIkeDialogComplete*>(this));
              /*--------------------------------------------------
               * Request User name and password (domain) from user
               *-------------------------------------------------*/
-             iDialog->GetAsyncUNPWDialogL(iDialogInfo, (MIkeDialogComplete*)this);
+             else
+                 iDialog->GetAsyncUNPWDialogL(iDialogInfo, static_cast<MIkeDialogComplete*>(this));
              break;
 
         default:     
@@ -553,12 +584,13 @@
  *  
  *-------------------------------------------------------------------------*/
     TUint32 obj_id = 1;
-    CAuthDialogInfo* info = (CAuthDialogInfo*)aUserInfo;
+    CAuthDialogInfo* info = static_cast<CAuthDialogInfo*>(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 == DIALOG_INFO_ID )
 	   {
--- a/vpnengine/ikev1lib/src/ikev1dialog.cpp	Tue Sep 14 23:16:15 2010 +0300
+++ b/vpnengine/ikev1lib/src/ikev1dialog.cpp	Wed Sep 15 13:20:54 2010 +0300
@@ -270,23 +270,43 @@
 
 /*--------------------------------------------------------------------
  *
- *  Get user name and Secure ID pin data for Legacy authentication
+ *  Get user name and Secure ID code data for Legacy authentication
  *
  *---------------------------------------------------------------------*/
 void CIkev1Dialog::GetAsyncSecureidDialogL(TAny *aUserInfo, MIkeDialogComplete*  aCallback)
 {
 	DEBUG_LOG2(_L("CIkev1Dialog::GetAsyncSecureidDialogL(), aUserInfo =  %x, aCallback = %x"), aUserInfo, aCallback);
 	
+    iDialogType = TKMDDialog::ESecurIdCode;
+    iUserInfo   = aUserInfo;
+    iCallback   = aCallback; // For asynchronous dialog RunL
+
+	TIPSecDialogInfo dialog_input(TKMDDialog::ESecurIdCode, 0);		
+	iInputData = CreateDialogInput(dialog_input, ETrue);// TRUE = Use user name cache    	
+    if ( iInputData )
+       LaunchDialogL();   //launch the dialog
+}
+
+/*--------------------------------------------------------------------
+ *
+ *  Get user name and Secure ID pin data for Legacy authentication
+ *
+ *---------------------------------------------------------------------*/
+void CIkev1Dialog::GetAsyncSecureidPinDialogL(TAny *aUserInfo, MIkeDialogComplete*  aCallback)
+{
+    DEBUG_LOG2(_L("CIkev1Dialog::GetAsyncSecureidPinDialogL(), aUserInfo =  %x, aCallback = %x"), aUserInfo, aCallback);
+    
     iDialogType = TKMDDialog::ESecurIdPin;
     iUserInfo   = aUserInfo;
     iCallback   = aCallback; // For asynchronous dialog RunL
 
-	TIPSecDialogInfo dialog_input(TKMDDialog::ESecurIdPin, 0);		
-	iInputData = CreateDialogInput(dialog_input, ETrue);// TRUE = Use user name cache    	
+    TIPSecDialogInfo dialog_input(TKMDDialog::ESecurIdPin, 0);      
+    iInputData = CreateDialogInput(dialog_input, ETrue);// TRUE = Use user name cache       
     if ( iInputData )
        LaunchDialogL();   //launch the dialog
 }
 
+
 /*--------------------------------------------------------------------
  *
  *  Get user name and Secure ID next pin data for Legacy authentication
--- a/vpnengine/ikev1lib/src/ikev1negotiation.cpp	Tue Sep 14 23:16:15 2010 +0300
+++ b/vpnengine/ikev1lib/src/ikev1negotiation.cpp	Wed Sep 15 13:20:54 2010 +0300
@@ -15,10 +15,12 @@
 *
 */
 
+#include <e32uid.h>
 #include <x509cert.h>
 #include <x500dn.h>
 #include <random.h>
 #include <vpnlogmessages.rsg>
+#include <softtokenpluginif.h>
 
 #include "ikev1negotiation.h"
 #include "ikedebug.h"
@@ -187,8 +189,8 @@
 
     delete iPkiService;     // Trusted CA certificate list
 
-    delete iSAPayload;
-    delete iPeerIdentPayload;
+    delete[] iSAPayload;
+    delete[] iPeerIdentPayload;
     delete iOwnIdentPayload;
     
     //Keys
@@ -1101,6 +1103,15 @@
     }
 }
 
+//
+// CIkev1Negotiation::ErrDialogCompletedL
+// Error dialog is completed. End negotiation.
+//
+void CIkev1Negotiation::ErrDialogCompletedL( )
+{
+    SendDeleteL(PROTO_ISAKMP);       
+    SetErrorStatus(KKmdIkeAuthFailedErr);
+}
 
 //
 // CIkev1Negotiation::StartCRACKAuthL
@@ -1273,18 +1284,37 @@
 //Sends the initial IKE packets to start the negotiation. PHASE I
 void CIkev1Negotiation::InitNegotiationL()   //Equiv. to stage 1
 {
-    
     if (iProposal_I.iAttrList->iAuthMethod == IKE_A_CRACK &&
         !iHostData->iCRACKLAMUserName && 
         !iHostData->iCRACKLAMPassword &&
         !iCRACKLAMUserName && 
         !iCRACKLAMPassword)
         {
-            
+        if ( (iHostData->iSoftToken) && (iPluginSession->SoftToken() != NULL) )
+            {
+            if (iPluginSession->SoftToken()->DefaultFoundL())
+                {
+                iDialog     = CIkev1Dialog::NewL( iPluginSession, iPluginSession->DialogAnchor(), iDebug );
+                iDialogInfo = new(ELeave) CAuthDialogInfo(iPluginSession, DIALOG_INFO_ID, SAId(), 0);
+                iDialog->GetAsyncSecureidPinDialogL(iDialogInfo, static_cast<MIkeDialogComplete*>(this));
+                return;
+                }
+            else
+                {
+                DEBUG_LOG(_L("Failed to find token!"));
+                iDialog     = CIkev1Dialog::NewL( iPluginSession, iPluginSession->DialogAnchor(), iDebug );
+                iDialogInfo = new(ELeave) CAuthDialogInfo(iPluginSession, ERROR_DIALOG_ID, SAId(), 0);
+                iDialog->ShowErrorDialogL(TVpnNoteDialog::EKmdTokenNotFound, iDialogInfo, static_cast<MIkeDialogComplete*>(this));
+                return;
+                }
+            }
+        else
+            {
             iDialog     = CIkev1Dialog::NewL( iPluginSession, iPluginSession->DialogAnchor(), iDebug );
             iDialogInfo = new(ELeave) CAuthDialogInfo(iPluginSession, DIALOG_INFO_ID, SAId(), 0);
-            iDialog->GetAsyncUNPWDialogL(iDialogInfo, (MIkeDialogComplete*)this);
+            iDialog->GetAsyncUNPWDialogL(iDialogInfo, static_cast<MIkeDialogComplete*>(this));
             return;
+            }
     }
     TIkev1IsakmpStream* msg = SaveIkeMsgBfr( new (ELeave) TIkev1IsakmpStream(iDebug) );
 	
@@ -8397,6 +8427,32 @@
 {
     delete iDialog;  /* delete dialog object */
     iDialog = NULL;
+
+    if (iHostData->iSoftToken && (iPluginSession->SoftToken() != NULL))
+        {
+        HBufC8* password = NULL;
+        TInt status;
+        status = iPluginSession->SoftToken()->CodeL(*aDialogInfo->iSecret, password);
+        
+        if (KErrNone != status)
+            {
+            if (KErrNoSecureTime == status)
+                {
+                DEBUG_LOG(_L("Token expired!"));
+                iDialog     = CIkev1Dialog::NewL( iPluginSession, iPluginSession->DialogAnchor(), iDebug );
+                iDialogInfo = new(ELeave) CAuthDialogInfo(iPluginSession, ERROR_DIALOG_ID, SAId(), 0);
+                iDialog->ShowErrorDialogL(TVpnNoteDialog::EKmdTokenExpired, iDialogInfo, static_cast<MIkeDialogComplete*>(this));
+                return status;
+                }
+            DEBUG_LOG(_L("Failed to get OTP from SoftToken!"));
+            SetFinished();
+            return KErrNotFound;
+            }
+        else
+            {
+            aDialogInfo->SetSecret(password);
+            }
+        }
     
     iCRACKLAMUserName = aDialogInfo->iUsername->AllocL();
     iCRACKLAMPassword = aDialogInfo->iSecret->AllocL();
@@ -8425,12 +8481,13 @@
  *  
  *-------------------------------------------------------------------------*/
     TUint32 obj_id = 1;
-    CAuthDialogInfo* info = (CAuthDialogInfo*)aUserInfo;
-    DEBUG_LOG1(_L("CIkev1Negotiation::DialogCompleteL(), aUserInfo =  %x"), aUserInfo);
+     CAuthDialogInfo* info = (CAuthDialogInfo*)aUserInfo;
+     DEBUG_LOG1(_L("CIkev1Negotiation::DialogCompleteL(), aUserInfo =  %x"), aUserInfo);
              
-    if ( info )
-    {
+     if ( info )
+     {
         obj_id = info->GetObjId();
+        info->iNegotiation = this;
         DEBUG_LOG1(_L("Preparing to call AuthDialogCompletedL(), ObjId = %x"), obj_id);
         if ( obj_id == DIALOG_INFO_ID )
         {
@@ -8438,7 +8495,14 @@
             info->SetSecret(aSecret);
             obj_id = info->PluginSession()->AuthDialogCompletedL(info);
         }   
-    }
-
-    return obj_id;
-}
+        if ( obj_id == ERROR_DIALOG_ID )
+        {
+           obj_id = info->PluginSession()->ErrDialogCompletedL(info);
+        }   
+     }
+
+     return obj_id;
+    
+}
+
+
--- a/vpnengine/ikev1lib/src/ikev1plugin.cpp	Tue Sep 14 23:16:15 2010 +0300
+++ b/vpnengine/ikev1lib/src/ikev1plugin.cpp	Wed Sep 15 13:20:54 2010 +0300
@@ -65,6 +65,7 @@
     iPluginSessions.Close();    
     delete iPFKeySocket;
     delete iIpsecPolicyUtil;
+    delete iSoftToken;
     }
 
 // ---------------------------------------------------------------------------
@@ -88,6 +89,14 @@
                                          iDebug );
     
     iIpsecPolicyUtil = CIpsecPolicyUtil::NewL();
+
+    TInt err(KErrNone);
+    TRAP(err, iSoftToken = CSoftTokenPluginIf::NewL());
+#ifdef _DEBUG            
+             if (err != KErrNone)
+                 DEBUG_LOG(_L("SoftTokenPlugin not found"));
+#endif // _DEBUG             
+
     }
     
 // ---------------------------------------------------------------------------
@@ -238,3 +247,14 @@
     return iEventLogger;
     }
 
+// ---------------------------------------------------------------------------
+// Returns SoftToken interface.
+// ---------------------------------------------------------------------------
+//
+//MSoftTokenPluginIf* CIkev1Plugin::SoftToken()
+CSoftTokenPluginIf* CIkev1Plugin::SoftToken()
+    {
+    return iSoftToken;
+    }
+
+
--- a/vpnengine/ikev1lib/src/ikev1pluginsession.cpp	Tue Sep 14 23:16:15 2010 +0300
+++ b/vpnengine/ikev1lib/src/ikev1pluginsession.cpp	Wed Sep 15 13:20:54 2010 +0300
@@ -902,7 +902,7 @@
 //    
 TInt CIkev1PluginSession::AuthDialogCompletedL( CAuthDialogInfo* aUserInfo )
     {
-    CIkev1Negotiation* negotiation = FindNegotiation( aUserInfo->SAId() );
+    CIkev1Negotiation* negotiation = aUserInfo->iNegotiation;
     if ( negotiation )
         {
         DEBUG_LOG1( _L("Dialog completed for SAID: %d"),
@@ -920,6 +920,31 @@
     return KErrNotFound;
     }
 
+// ---------------------------------------------------------------------------
+// Handles completion of error dialog processing.
+// ---------------------------------------------------------------------------
+//    
+TInt CIkev1PluginSession::ErrDialogCompletedL( CAuthDialogInfo* aUserInfo )
+    {
+    
+    CIkev1Negotiation* negotiation = aUserInfo->iNegotiation;
+    if ( negotiation )
+        {
+        DEBUG_LOG1( _L("Dialog completed for SAID: %d"),
+                aUserInfo->SAId() );
+        
+        negotiation->ErrDialogCompletedL();
+        if ( negotiation->Finished() )
+            {
+            DeleteNegotiation( negotiation );
+            }   
+        return KErrNone;
+        }   
+    DEBUG_LOG1( _L("Dialog completed, no negotiation found for SAID: %d"),
+            aUserInfo->SAId() );
+            
+    return KErrNotFound;    
+    }
 
 // ---------------------------------------------------------------------------
 // Handles change of internal address.
@@ -1053,6 +1078,16 @@
 MKmdEventLoggerIf& CIkev1PluginSession::EventLogger()
     {
     return iPlugin.EventLogger();
+    }
+
+// ---------------------------------------------------------------------------
+// Returns SoftToken interface.
+// ---------------------------------------------------------------------------
+//
+//MSoftTokenPluginIf* CIkev1PluginSession::SoftToken()
+CSoftTokenPluginIf* CIkev1PluginSession::SoftToken()
+    {
+    return iPlugin.SoftToken();
     }      
 
 // ---------------------------------------------------------------------------
--- a/vpnengine/ikev1lib/src/ikev1trans.cpp	Tue Sep 14 23:16:15 2010 +0300
+++ b/vpnengine/ikev1lib/src/ikev1trans.cpp	Wed Sep 15 13:20:54 2010 +0300
@@ -830,7 +830,7 @@
             //
             iDialog     = CIkev1Dialog::NewL(iPluginSession, iPluginSession->DialogAnchor(), iDebug);
             iDialogInfo = new(ELeave) CAuthDialogInfo(iPluginSession, XAUTH_DIALOG_ID, iNegotiation->SAId(), iCurrExchange->iMessageId);
-            iDialog->GetAsyncSecureidDialogL(iDialogInfo, (MIkeDialogComplete*)this);          
+            iDialog->GetAsyncSecureidDialogL(iDialogInfo, static_cast<MIkeDialogComplete*>(this));          
             break;
 
         case ( (1 << (ATTR_USER_NAME - ATTR_XAUTH_TYPE)) | (1 << (ATTR_NEXT_PIN - ATTR_XAUTH_TYPE))):
@@ -839,7 +839,7 @@
             //
 			iDialog     = CIkev1Dialog::NewL(iPluginSession, iPluginSession->DialogAnchor(), iDebug);			
 			iDialogInfo = new(ELeave) CAuthDialogInfo(iPluginSession, XAUTH_DIALOG_ID, iNegotiation->SAId(), iCurrExchange->iMessageId);
-            iDialog->GetAsyncSecureNextPinDialogL(iDialogInfo, (MIkeDialogComplete*)this);
+            iDialog->GetAsyncSecureNextPinDialogL(iDialogInfo, static_cast<MIkeDialogComplete*>(this));
             break;
 
         case ( (1 << (ATTR_CHALLENGE - ATTR_XAUTH_TYPE)) ):
@@ -850,7 +850,7 @@
 			{
 				iDialog     = CIkev1Dialog::NewL(iPluginSession, iPluginSession->DialogAnchor(), iDebug);			
 				iDialogInfo = new(ELeave) CAuthDialogInfo(iPluginSession, XAUTH_DIALOG_ID, iNegotiation->SAId(), iCurrExchange->iMessageId);
-                iDialog->GetAsyncRespDialog(challenge, iDialogInfo, (MIkeDialogComplete*)this);
+                iDialog->GetAsyncRespDialog(challenge, iDialogInfo, static_cast<MIkeDialogComplete*>(this));
             }   
             break;
 
@@ -1158,6 +1158,7 @@
 	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 )
 		{
@@ -1197,6 +1198,7 @@
     if( KErrNone == ret )
     {
         iCredentialType = KCredentialTypeCached;
+        iDialogInfo->iNegotiation = iNegotiation;
         TUint32 id = iPluginSession->AuthDialogCompletedL( iDialogInfo );
     }
     else
@@ -1208,7 +1210,7 @@
         iDialog = CIkev1Dialog::NewL(
             iPluginSession, iPluginSession->DialogAnchor(), iDebug );
 
-        iDialog->GetAsyncUNPWDialogL( iDialogInfo, (MIkeDialogComplete*)this );
+        iDialog->GetAsyncUNPWDialogL( iDialogInfo, static_cast<MIkeDialogComplete*>(this) );
     }
 }
 
--- a/vpnengine/vpncommon/inc/vpnnotifierdefs.h	Tue Sep 14 23:16:15 2010 +0300
+++ b/vpnengine/vpncommon/inc/vpnnotifierdefs.h	Wed Sep 15 13:20:54 2010 +0300
@@ -131,7 +131,8 @@
         {
         EUserPwd = 2000, // MUST be greater than the last value in enum TNoteDialog::TDialogId
         ESecurIdPin,
-        ESecurIdNextPin        
+        ESecurIdNextPin,
+        ESecurIdCode
         };
     };
 
@@ -185,7 +186,9 @@
         EVpnCannotForceDeviceLock,
         EVpnPolicyInstalled,
         // Kmd related notes
-        EKmdAuthenticationFailed = 2000
+        EKmdAuthenticationFailed = 2000,
+        EKmdTokenNotFound,
+        EKmdTokenExpired
         };
     };
 
--- a/vpnengine/vpnmanager/inc/policyimporter.h	Tue Sep 14 23:16:15 2010 +0300
+++ b/vpnengine/vpnmanager/inc/policyimporter.h	Wed Sep 15 13:20:54 2010 +0300
@@ -38,6 +38,7 @@
 
 const TInt KMaxExtPolicyIdLength = 256;
 const TInt KDoNotGetKeySize      = -1;
+const TInt KMaxIapLength = 10;
 
 typedef TBuf<KMaxExtPolicyIdLength> TExtVpnPolicyId;
 
--- a/vpnengine/vpnmanager/src/policyimporter.cpp	Tue Sep 14 23:16:15 2010 +0300
+++ b/vpnengine/vpnmanager/src/policyimporter.cpp	Wed Sep 15 13:20:54 2010 +0300
@@ -35,6 +35,7 @@
 #include "agileprovisionws.h"
 #include "agileprovisiondefs.h"
 #include "policyinstaller_constants.h"
+#include "vpnextapiservantdefs.h"
 
 
 
@@ -726,17 +727,73 @@
                    
             if ( iFileUtil.FileExists(serverSettingsFile) )
                {
-               HBufC8* fileData=iFileUtil.LoadFileDataL(serverSettingsFile);
-               CleanupStack::PushL(fileData);
-               HBufC8* newFileData =HBufC8::New(fileData->Length() + KCRLF().Length() + 4);
-               CleanupStack::PushL(newFileData);
-               TPtr8 fileDataPtr = newFileData->Des();
-               fileDataPtr.Copy(*fileData);
-               fileDataPtr.Append(KCRLF);
-               fileDataPtr.AppendNum(provisionIapId);
-               iFileUtil.SaveFileDataL(serverSettingsFile,fileDataPtr);
-               CleanupStack::PopAndDestroy(newFileData);
-               CleanupStack::PopAndDestroy(fileData);
+                _LIT(KCRLF, "\n");
+                RFile serverFile;
+                User::LeaveIfError(serverFile.Open(iFs,serverSettingsFile, EFileRead));
+                                               
+                TFileText tx;
+                tx.Set(serverFile);
+
+                TInt fileSize;
+                User::LeaveIfError(serverFile.Size(fileSize));
+
+                HBufC* serverUrlBuf = HBufC::NewLC(fileSize);
+                                          
+                TPtr serverUrlPtr=serverUrlBuf->Des();
+                                          
+                User::LeaveIfError(tx.Read(serverUrlPtr));
+                                           
+                            
+                HBufC* serverNameBuf = HBufC::NewLC(fileSize);
+                TPtr serverNamePtr=serverNameBuf->Des();
+                                           
+                User::LeaveIfError(tx.Read(serverNamePtr));
+                                           
+                
+                TBuf<KMaxIapLength> iapIdData;
+                User::LeaveIfError(tx.Read(iapIdData));
+                                
+                TBuf<KMaxIapLength> iapModeData;
+                User::LeaveIfError(tx.Read(iapModeData));
+                
+                HBufC* policyFileNameBuf = HBufC::NewLC(fileSize);
+                                
+                TPtr policyFileNamePtr = policyFileNameBuf->Des();
+                User::LeaveIfError(tx.Read(policyFileNamePtr));
+                
+                serverFile.Close();
+                
+                TBuf<KMaxIapLength> agileIapIdStr;
+                agileIapIdStr.Num(provisionIapId);
+                
+                HBufC* serverFileBuf = HBufC::NewL(fileSize + KCRLF().Length() + agileIapIdStr.Length());
+                CleanupStack::PushL(serverFileBuf);
+                TPtr tPtr(serverFileBuf->Des());
+                tPtr.Copy(serverUrlPtr);
+                tPtr.Append(KCRLF);
+                tPtr.Append(serverNamePtr);
+                tPtr.Append(KCRLF);
+                tPtr.Append(iapIdData);
+                tPtr.Append(KCRLF);
+                tPtr.Append(iapModeData);
+                tPtr.Append(KCRLF);
+                tPtr.Append(policyFileNamePtr);
+                tPtr.Append(KCRLF);
+                tPtr.AppendNum(provisionIapId);
+                       
+                RFile file;
+                CleanupClosePushL(file);
+                User::LeaveIfError(file.Replace(iFs, serverSettingsFile, EFileWrite));
+                TPtrC8 ptr8 ( (TUint8*) tPtr.Ptr(), tPtr.Size() );
+                file.Write ( ptr8 );
+                file.Close();
+                
+                CleanupStack::PopAndDestroy(1);  //file
+                CleanupStack::PopAndDestroy(serverFileBuf);
+                CleanupStack::PopAndDestroy(policyFileNameBuf);
+                CleanupStack::PopAndDestroy(serverNameBuf);
+                CleanupStack::PopAndDestroy(serverUrlBuf);
+                       
                }
             }
         }
@@ -1296,8 +1353,7 @@
     
     void CPolicyImporter::GetPolicyWsL()
         {
-        const TInt KEolLen = 2;
-        
+               
         delete iAgileProvisionWs;
         iImportDir=KTempDirectory();
         iFileUtil.CreateDirIfNeededL(iImportDir);
@@ -1308,44 +1364,63 @@
               
         serverSettingsFile.Append(KProvisionServerSettings);
                     
-               
-        HBufC8* fileData;
-        TInt endOfLine;
         HBufC8* serviceEndPoint;
-        TUint iapIdInt;
-        
+      
         if ( iFileUtil.FileExists(serverSettingsFile) )
             {
-            fileData=iFileUtil.LoadFileDataL(serverSettingsFile);
-            CleanupStack::PushL(fileData);
-            endOfLine=fileData->Find(KCRLF);
+           
                     
-            serviceEndPoint=HBufC8::NewL( KHTTPprefix().Length() + KServiceSuffix().Length() +  fileData->Mid(0,endOfLine).Length());
+            RFile serverFile;
+            User::LeaveIfError(serverFile.Open(iFs,serverSettingsFile, EFileRead));
+                         
+            TFileText tx;
+            tx.Set(serverFile);
+
+            TInt fileSize;
+            User::LeaveIfError(serverFile.Size(fileSize));
+
+            HBufC* serverUrlBuf = HBufC::NewLC(fileSize);
+                   
+            TPtr serverUrlPtr=serverUrlBuf->Des();
+                   
+            User::LeaveIfError(tx.Read(serverUrlPtr));
+                    
+            HBufC8* serverUrl=iFileUtil.To8BitL(serverUrlPtr);
+                             
+            CleanupStack::PopAndDestroy(serverUrlBuf);
+           
+            CleanupStack::PushL(serverUrl);
+            
+            
+            serviceEndPoint=HBufC8::NewL( KHTTPprefix().Length() + KServiceSuffix().Length() +  serverUrlPtr.Length());
             CleanupStack::PushL(serviceEndPoint);
             TPtr8 endPointPtr(serviceEndPoint->Des());
             endPointPtr=KHTTPprefix;
-            HBufC8* serviceAddrBuf=(fileData->Mid(0,endOfLine)).AllocL();
-            CleanupStack::PushL(serviceAddrBuf);
+                       
+            // serverUrl ownership transfer
+            iAgileProvisionWs->SetServiceAddr(serverUrl);
+            endPointPtr.Append(*serverUrl);
+            endPointPtr.Append(KServiceSuffix);
             
-            //serviceAddrBuf ownership transfer
-            iAgileProvisionWs->SetServiceAddr(serviceAddrBuf);
-            endPointPtr.Append(fileData->Mid(0,endOfLine));
-            endPointPtr.Append(KServiceSuffix);
-            CleanupStack::Pop(serviceAddrBuf);
             
-            TInt startOfLine(endOfLine+KEolLen);
-            TPtrC8 nameData=fileData->Right(fileData->Length()-startOfLine);
-            endOfLine=nameData.Find(KCRLF);      
-                                        
-            startOfLine = endOfLine + KEolLen;
-            TPtrC8 iapIdData=nameData.Right(nameData.Length()-startOfLine);
-            endOfLine=iapIdData.Find(KCRLF);
-            TLex8 iapIdConverter(iapIdData.Left(endOfLine));
-            
+            HBufC* serverNameBuf = HBufC::NewLC(fileSize);
+            TPtr serverNamePtr=serverNameBuf->Des();
+                      
+            User::LeaveIfError(tx.Read(serverNamePtr));
+                                          
+            CleanupStack::PopAndDestroy(serverNameBuf);
+                                                    
+            TBuf<KMaxIapLength> iapIdData;
+            User::LeaveIfError(tx.Read(iapIdData));
+                                
+            TLex iapIdConverter(iapIdData);
+            TUint iapIdInt;
             iapIdConverter.Val(iapIdInt);
+         
             iAgileProvisionWs->GetPolicy( *serviceEndPoint, iapIdInt, iStatus );
             CleanupStack::PopAndDestroy(serviceEndPoint);
-            CleanupStack::PopAndDestroy(fileData); 
+            CleanupStack::Pop(serverUrl);
+            serverFile.Close();
             }
                 
        
@@ -1397,83 +1472,114 @@
         TPtr fileNamePtr=policyServerSettingsFileName->Des();
         fileNamePtr.Append(privateDir);
         fileNamePtr.Append(KProvisionServerSettings);
-            
-                
+        _LIT(KCRLF, "\n");                
         if ( iFileUtil.FileExists(fileNamePtr) )
            {
-           HBufC8* fileData=iFileUtil.LoadFileDataL(fileNamePtr);
-           CleanupStack::PushL(fileData);
-        
-           TPtrC8 restOfData = *fileData;
+                             
+           RFile serverFile;
+           User::LeaveIfError(serverFile.Open(iFs,fileNamePtr, EFileRead));
+                                   
+           TFileText tx;
+           tx.Set(serverFile);
+
+           TInt fileSize;
+           User::LeaveIfError(serverFile.Size(fileSize));
+
+           HBufC* serverUrlBuf = HBufC::NewLC(fileSize);
+                              
+           TPtr serverUrlPtr=serverUrlBuf->Des();
+                              
+           User::LeaveIfError(tx.Read(serverUrlPtr));
+                               
+           HBufC* serverNameBuf = HBufC::NewLC(fileSize);
+           TPtr serverNamePtr=serverNameBuf->Des();
+                               
+           User::LeaveIfError(tx.Read(serverNamePtr));
+                               
+           
+           TBuf<KMaxIapLength> iapIdData;
+           User::LeaveIfError(tx.Read(iapIdData));
+                    
+           TBuf<KMaxIapLength> iapModeData;
+           User::LeaveIfError(tx.Read(iapModeData));
+                                       
+           TBuf<KMaxIapLength> iapIdBuf;
            
-           TInt bofInt;
-           TInt line=1;             
-           while ( (bofInt=restOfData.Find(KCRLF)) != KErrNotFound && line < KPolicyFileLine )
-                 {
-                 restOfData.Set(restOfData.Mid(bofInt + KCRLF().Length()));
-                 line++;                                  
-                 }
-           TInt iapIdStart=restOfData.Find(KCRLF);
-           HBufC16* iapIdBuf;
-           if ( iapIdStart!=KErrNotFound )
+           HBufC* policyFilePath;                               
+           HBufC* policyFileNameBuf = HBufC::NewLC(fileSize);
+           TPtr policyFileNamePtr = policyFileNameBuf->Des();
+           
+           if (  tx.Read(policyFileNamePtr) == KErrNone )
+               {
+               
+               tx.Read(iapIdBuf);
+               TLex iapIdConverter(iapIdBuf);
+               iapIdConverter.Val(iAgileProvisionAPId,EDecimal);
+                                  
+               policyFilePath = iFileUtil.MakeFileNameLC(privateDir, *policyFileNameBuf, KPolFileExt);
+               }
+           else
+               {
+               policyFilePath =iFileUtil.MakeFileNameLC(privateDir, *iNewPolicyId, KPolFileExt);
+               }
+
+           serverFile.Close();
+           
+           TBuf<KMaxIapLength> iapAgileIdStr;
+           //server configuration file includes installed policy file name and policy exists.
+           if ( (iAgileProvisionAPId > 0) && iFileUtil.FileExists(*policyFilePath) )
+              { 
+              iPolicyIdBuf.Append(*policyFileNameBuf);
+              iNewPolicyIdBuf=iPolicyIdBuf;
+              iPolicyStore.ReplacePolicyL(iPolicyIdBuf,*iNewPolicyId);
+              iNewPolicyId= &iNewPolicyIdBuf;
+              }
+               //either first configuration or policy removed
+           else
               {
-              TPtrC8 iapIdPtr=restOfData.Mid(iapIdStart + KCRLF().Length(),restOfData.Length()-KCRLF().Length()-iapIdStart);
-              iapIdBuf=iFileUtil.To16BitL(iapIdPtr);
-              CleanupStack::PushL(iapIdBuf);
-              TLex iapIdConverter(*iapIdBuf);
-              iapIdConverter.Val(iAgileProvisionAPId,EDecimal);     
-              CleanupStack::PopAndDestroy(iapIdBuf);           
-              }
-           
-           if ( iAgileProvisionAPId >0)
-               restOfData.Set(restOfData.Mid(0,iapIdStart));
-               HBufC16* policyFileNameBuf = iFileUtil.To16BitL(restOfData);
-               CleanupStack::PushL(policyFileNameBuf);
-               HBufC* policyFilePath = iFileUtil.MakeFileNameLC(privateDir, *policyFileNameBuf, KPolFileExt);
                
-               //server configuration file includes installed policy file name and policy exists.
-               if ( line == KPolicyFileLine && iFileUtil.FileExists(*policyFilePath) )
-                   { 
-                   HBufC16* restOfDataBuf=iFileUtil.To16BitL(restOfData);
-                   CleanupStack::PushL(restOfDataBuf);
-                   iPolicyIdBuf.Append(*restOfDataBuf);
-                   iNewPolicyIdBuf=iPolicyIdBuf;
-                   iPolicyStore.ReplacePolicyL(iPolicyIdBuf,*iNewPolicyId);
-                   iNewPolicyId= &iNewPolicyIdBuf;
-                   CleanupStack::PopAndDestroy(restOfDataBuf);
+               HBufC* serverFileBuf = HBufC::NewL(fileSize + KCRLF().Length() + iNewPolicyId->Length() + KMaxIapLength);
+               CleanupStack::PushL(serverFileBuf);
+               TPtr tPtr(serverFileBuf->Des());
+               tPtr.Copy(serverUrlPtr);
+               tPtr.Append(KCRLF);
+               tPtr.Append(serverNamePtr);
+               tPtr.Append(KCRLF);
+               tPtr.Append(iapIdData);
+               tPtr.Append(KCRLF);
+               tPtr.Append(iapModeData);
+                                             
+               //policy removed
+               if ( !iFileUtil.FileExists(*policyFilePath) )
+                  {
+                   tPtr.Append(KCRLF);
+                   tPtr.Append(*iNewPolicyId);
+                   tPtr.Append(KCRLF);
+                   iapAgileIdStr.Num(iAgileProvisionAPId);
+                   tPtr.Append(iapAgileIdStr);
                    }
-               //either first configuration or policy removed
+               //first configuration
                else
                    {
-                   HBufC* serverFile = HBufC::NewL(fileData->Length() + KCRLF().Length() + iNewPolicyId->Length());
-                   CleanupStack::PushL(serverFile);
-                   TPtr tPtr(serverFile->Des());
-                   HBufC16* fileData16=iFileUtil.To16BitL(*fileData);
-                   CleanupStack::PushL(fileData16);
-                   tPtr.Copy(*fileData16);
-                   _LIT(KCRLF, "\r\n");
-              
-                   //policy removed
-                   if ( line == KPolicyFileLine )
-                       {
-                       TInt lengthOfPolicyId=restOfData.Length();
-                       tPtr.Replace(fileData->Length()-lengthOfPolicyId,lengthOfPolicyId,*iNewPolicyId);
-                       }
-                   //first configuration
-                   else
-                       {
-                       tPtr.Append(KCRLF);
-                       tPtr.Append(*iNewPolicyId);
-                       }
-                   iFileUtil.SaveFileDataL(fileNamePtr,tPtr);
+                   tPtr.Append(KCRLF);
+                   tPtr.Append(*iNewPolicyId);
                    
-                   CleanupStack::PopAndDestroy(fileData16);
-                   CleanupStack::PopAndDestroy(serverFile);
                    }
+               RFile file;
+               CleanupClosePushL(file);
+               User::LeaveIfError(file.Replace(iFs, fileNamePtr, EFileWrite));
+                     
+               TPtrC8 ptr8 ( (TUint8*) tPtr.Ptr(), tPtr.Size() );
+               file.Write ( ptr8 );
+               file.Close();
+               CleanupStack::PopAndDestroy(1); //file   
+               CleanupStack::PopAndDestroy(serverFileBuf);
+               }
              
                CleanupStack::PopAndDestroy(policyFilePath);
                CleanupStack::PopAndDestroy(policyFileNameBuf); 
-               CleanupStack::PopAndDestroy(fileData);
+               CleanupStack::PopAndDestroy(serverNameBuf);
+               CleanupStack::PopAndDestroy(serverUrlBuf);
                CleanupStack::PopAndDestroy(policyServerSettingsFileName);
            }
 
--- a/vpnengine/vpnmanager/src/vpnapiservant.cpp	Tue Sep 14 23:16:15 2010 +0300
+++ b/vpnengine/vpnmanager/src/vpnapiservant.cpp	Wed Sep 15 13:20:54 2010 +0300
@@ -26,7 +26,6 @@
 #include "pwdchanger.h"
 #include "vpnapidefs.h"
 #include "vpnmanagerserverdefs.h"
-#include "vpnextapiservantdefs.h"
 #include "vpnmaninternal.h"
 #include "log_r6.h"
 #include "agileprovisionws.h"
@@ -575,59 +574,75 @@
       /* Check if file allready exists and copy policy and vpn iap id to a new file */
       TFileName policyFileName;
       TUint32 agileProvisionAPId=0;
-            
+      
+      HBufC* serverUrlBuf=NULL;
+      
+      HBufC* serverNameBuf=NULL;
+      
+      TBuf<KMaxIapLength> iapIdBuf;
+      
+      TBool serverFileExist=EFalse;
+      
       if ( iFileUtil.FileExists(serverFilePath) )
          {
-          HBufC8* fileData=iFileUtil.LoadFileDataL(serverFilePath);
-          CleanupStack::PushL(fileData);
-             
-          TPtrC8 restOfData = fileData->Des();
-                
-          TInt bofInt;
-          TInt line=1;             
-          while ( (bofInt=restOfData.Find(KCRLF)) != KErrNotFound && line < KPolicyFileLine )
-                {
-                restOfData.Set(restOfData.Mid(bofInt + KCRLF().Length()));
-                line++;                                  
-                }
-          TInt iapIdStart=restOfData.Find(KCRLF);
-          HBufC16* iapIdBuf;
-                 
-          if ( iapIdStart!=KErrNotFound )
+          RFile serverFile;
+          User::LeaveIfError(serverFile.Open(iFs,serverFilePath, EFileRead));
+                                        
+         
+          TFileText tx;
+          tx.Set(serverFile);
+
+          TInt fileSize;
+          User::LeaveIfError(serverFile.Size(fileSize));
+
+          serverUrlBuf = HBufC::NewLC(fileSize);
+                                   
+          TPtr serverUrlPtr=serverUrlBuf->Des();
+                                   
+          User::LeaveIfError(tx.Read(serverUrlPtr));
+                                    
+          serverNameBuf = HBufC::NewLC(fileSize);
+          TPtr serverNamePtr=serverNameBuf->Des();
+                                    
+          User::LeaveIfError(tx.Read(serverNamePtr));
+           
+          TBuf<KMaxIapLength> iapIdData;
+          User::LeaveIfError(tx.Read(iapIdData));
+                         
+          TBuf<KMaxIapLength> iapModeData;
+          User::LeaveIfError(tx.Read(iapModeData));
+          
+          HBufC* policyFileNameBuf = HBufC::NewLC(fileSize);
+          TPtr policyFileNamePtr = policyFileNameBuf->Des();
+          
+          if (  tx.Read(policyFileNamePtr) == KErrNone )
               {
-              TPtrC8 iapIdPtr=restOfData.Mid(iapIdStart + KCRLF().Length(),restOfData.Length()-KCRLF().Length()-iapIdStart);
-              iapIdBuf=iFileUtil.To16BitL(iapIdPtr);
-              CleanupStack::PushL(iapIdBuf);
-              TLex iapIdConverter(*iapIdBuf);
-              iapIdConverter.Val(agileProvisionAPId,EDecimal);     
-              CleanupStack::PopAndDestroy(iapIdBuf);           
+               tx.Read(iapIdBuf);
+               
+               TLex iapIdConverter(iapIdBuf);
+               iapIdConverter.Val(agileProvisionAPId,EDecimal);
+               policyFileName = *policyFileNameBuf;
               }
-                 
-          if ( agileProvisionAPId >0)
-              {
-               restOfData.Set(restOfData.Mid(0,iapIdStart));
-               HBufC16* policyFileNameBuf = iFileUtil.To16BitL(restOfData);
-               policyFileName = *policyFileNameBuf;
-               delete policyFileNameBuf;
-              }
-          CleanupStack::PopAndDestroy(fileData);
+          CleanupStack::PopAndDestroy(policyFileNameBuf);
+          serverFile.Close();
+          serverFileExist = ETrue;
           }
       /* end of saving old values */
       
       //IAP data Max value 255 
-      TBuf<10> iapIdStr;
-      TBuf<10> iapModeStr;
-      TBuf<10> iapAgileIdStr;
+      TBuf<KMaxIapLength> iapIdStr;
+      TBuf<KMaxIapLength> iapModeStr;
+      TBuf<KMaxIapLength> iapAgileIdStr;
       
       iapIdStr.Num(serverAccountLocalData->iSelection.iId);
       iapModeStr.Num(serverAccountLocalData->iSelection.iResult);
       HBufC* serverSettingsDataBuf;
+      _LIT(KCRLF, "\n"); 
       if ( agileProvisionAPId >0 )
           {
-          iapAgileIdStr.Num(agileProvisionAPId);
-                                                                                                                          
+                                                                                                                                    
           serverSettingsDataBuf = HBufC::NewL(serverAccountLocalData->iServerNameLocal.Length() + serverAccountLocalData->iServerAddress.Length() + 
-                                              iapIdStr.Length() + iapModeStr.Length() + policyFileName.Length() + iapAgileIdStr.Length() + 5*(KCRLF().Length()) );
+                                              iapIdStr.Length() + iapModeStr.Length() + policyFileName.Length() + iapIdBuf.Length() + 5*(KCRLF().Length()) );
           }
       else
           {                                                                                                         
@@ -637,7 +652,7 @@
       CleanupStack::PushL(serverSettingsDataBuf);
       TPtr tPtr(serverSettingsDataBuf->Des());
       tPtr.Copy(serverAccountLocalData->iServerAddress);
-      _LIT(KCRLF, "\r\n"); 
+     
       tPtr.Append(KCRLF);
       tPtr.Append(serverAccountLocalData->iServerNameLocal);
       tPtr.Append(KCRLF);
@@ -649,20 +664,35 @@
           tPtr.Append(KCRLF);
           tPtr.Append(policyFileName);
           tPtr.Append(KCRLF);
-          tPtr.Append(iapAgileIdStr);
+          tPtr.Append(iapIdBuf);
           }
-     
-      iFileUtil.SaveFileDataL(serverFilePath,tPtr);
-      CleanupStack::PopAndDestroy(3);
+      
+      RFile file;
+      CleanupClosePushL(file);
+
+      User::LeaveIfError(file.Replace(iFs, serverFilePath, EFileWrite));
+      
+      TPtrC8 ptr8 ( (TUint8*) tPtr.Ptr(), tPtr.Size() );
+      file.Write ( ptr8 );
+      file.Close();
+      CleanupStack::PopAndDestroy(1); //file
+      CleanupStack::PopAndDestroy(serverSettingsDataBuf);
+      
+      if ( serverFileExist != EFalse )
+          {
+          CleanupStack::PopAndDestroy(serverNameBuf);
+          CleanupStack::PopAndDestroy(serverUrlBuf);
+          }
+      
+      CleanupStack::PopAndDestroy(serverAccountLocalData);
+      CleanupStack::PopAndDestroy(serverCreate);
+      
       aMessage.Complete(KErrNone);
     }
 
 void CVpnApiServant::ListProvisionServerL( const RMessage2& aMessage )
     {
-      _LIT8(KCRLF, "\r\n");
-      
-      const TInt KEolLen = 2;
-      
+              
       TAgileProvisionApiServerListElem* serverList = new (ELeave) TAgileProvisionApiServerListElem();
       CleanupStack::PushL(serverList);
       TPckg<TAgileProvisionApiServerListElem> serverPckg(*serverList);
@@ -670,29 +700,48 @@
       TFileName serverFilePath;
       User::LeaveIfError(iFs.PrivatePath(serverFilePath));
       serverFilePath.Append(KProvisionServerSettings);   
-      
-      HBufC8* fileData(NULL);
-     
+          
       if ( iFileUtil.FileExists(serverFilePath) )
           {
-          fileData=iFileUtil.LoadFileDataL(serverFilePath);
-          CleanupStack::PushL(fileData);
-          TInt endOfLine=fileData->Find(KCRLF);
-          serverList->iServerUrl=fileData->Mid(0,endOfLine);
+         
+          RFile serverFile;
+          User::LeaveIfError(serverFile.Open(iFs,serverFilePath, EFileRead));
+      
+      
+          TFileText tx;
+          tx.Set(serverFile);
+
+          TInt fileSize;
+          User::LeaveIfError(serverFile.Size(fileSize));
+
+          HBufC* serverUrlBuf = HBufC::NewLC(fileSize);
+         
+          TPtr serverUrlPtr=serverUrlBuf->Des();
+         
+          User::LeaveIfError(tx.Read(serverUrlPtr));
           
-          TInt startOfLine(endOfLine+KEolLen);
-          TPtrC8 nameData=fileData->Right(fileData->Length()-startOfLine);
-          endOfLine=nameData.Find(KCRLF);
-          HBufC16* serverName=iFileUtil.To16BitL(nameData.Left(endOfLine));
-          serverList->iServerNameLocal=*serverName;
-          delete serverName;
-          serverName = NULL;
+          HBufC8* serverUrl=iFileUtil.To8BitL(serverUrlPtr);
+          serverList->iServerUrl=*serverUrl;
+          
+          delete serverUrl;
+          serverUrl=NULL;
+          
+          CleanupStack::PopAndDestroy(serverUrlBuf);
+          
+          HBufC* serverNameBuf = HBufC::NewLC(fileSize);
+          TPtr serverNamePtr=serverNameBuf->Des();
+          
+          User::LeaveIfError(tx.Read(serverNamePtr));
+          
+          serverList->iServerNameLocal=serverNamePtr;
+                   
+          CleanupStack::PopAndDestroy(serverNameBuf);
+          
+          serverFile.Close();
           }
       
       aMessage.WriteL(0, serverPckg);
-      if ( iFileUtil.FileExists(serverFilePath) )
-          CleanupStack::PopAndDestroy(fileData);
-      
+          
       CleanupStack::PopAndDestroy(serverList);
       aMessage.Complete(KErrNone);
     }
@@ -704,59 +753,65 @@
       CleanupStack::PushL(serverList);
       TPckg<TAgileProvisionApiServerSettings> serverPckg(*serverList);
       
-      _LIT8(KCRLF, "\r\n");     
-      
       TFileName serverFilePath;
       User::LeaveIfError(iFs.PrivatePath(serverFilePath));
       serverFilePath.Append(KProvisionServerSettings);  
       
-      HBufC8* fileData(NULL);
-      const TInt KEolLen = 2;
-      TBool serverFileExist = EFalse;
-      
       if ( iFileUtil.FileExists(serverFilePath) )
          {
-          fileData=iFileUtil.LoadFileDataL(serverFilePath);
-          CleanupStack::PushL(fileData);  
-          TInt endOfLine=fileData->Find(KCRLF);
-          serverList->iServerUrl=fileData->Mid(0,endOfLine);
-                
-          TInt startOfLine(endOfLine+2);
-          TPtrC8 nameData=fileData->Right(fileData->Length()-startOfLine);
-          endOfLine=nameData.Find(KCRLF);      
-             
-          HBufC16* serverName=iFileUtil.To16BitL(nameData.Left(endOfLine));
-          serverList->iServerNameLocal=*serverName;
-          delete serverName;
-          serverName = NULL;
+          RFile serverFile;
+          User::LeaveIfError(serverFile.Open(iFs,serverFilePath, EFileRead));
+            
+          TFileText tx;
+          tx.Set(serverFile);
+
+          TInt fileSize;
+          User::LeaveIfError(serverFile.Size(fileSize));
           
-          startOfLine = endOfLine + KEolLen;
-          TPtrC8 iapIdData=nameData.Right(nameData.Length()-startOfLine);
-          endOfLine=iapIdData.Find(KCRLF);
-          TLex8 iapIdConverter(iapIdData.Left(endOfLine));
+          HBufC* serverUrlBuf = HBufC::NewLC(fileSize);
+                   
+          TPtr serverUrlPtr=serverUrlBuf->Des();
+                   
+          User::LeaveIfError(tx.Read(serverUrlPtr));
+                    
+          HBufC8* serverUrl=iFileUtil.To8BitL(serverUrlPtr);
+          serverList->iServerUrl=*serverUrl;
+                    
+          delete serverUrl;
+          serverUrl=NULL;
+                    
+          CleanupStack::PopAndDestroy(serverUrlBuf);
+                    
+          HBufC* serverNameBuf = HBufC::NewLC(fileSize);
+          TPtr serverNamePtr=serverNameBuf->Des();
+                    
+          User::LeaveIfError(tx.Read(serverNamePtr));
+                    
+          serverList->iServerNameLocal=serverNamePtr;
+                             
+          CleanupStack::PopAndDestroy(serverNameBuf);
+          
+          TBuf<KMaxIapLength> iapIdData;
+          User::LeaveIfError(tx.Read(iapIdData));
+                    
+          TLex iapIdConverter(iapIdData);
           TUint idInt;
           iapIdConverter.Val(idInt);
           serverList->iSelection.iId = idInt;
         
-          startOfLine = endOfLine + KEolLen;
-          TPtrC8 iapModeData=iapIdData.Right(iapIdData.Length()-startOfLine);
-          TLex8 iapModeConverter;
-          endOfLine=iapModeData.Find(KCRLF);
-          if ( endOfLine==KErrNotFound )
-              iapModeConverter = iapModeData;
-          else
-              iapModeConverter = iapModeData.Left(endOfLine);
-              
+          TBuf<KMaxIapLength> iapModeData;
+          User::LeaveIfError(tx.Read(iapModeData));
+          
+          TLex iapModeConverter = iapModeData;
           iapModeConverter.Val(idInt);
+          
           CMManager::TCmSettingSelectionMode selectionMode = (CMManager::TCmSettingSelectionMode) idInt;
           serverList->iSelection.iResult = selectionMode; 
-          serverFileExist = ETrue;   
+          
+          serverFile.Close();
           }
       aMessage.WriteL(0, serverPckg);
       
-      if ( serverFileExist )
-          CleanupStack::PopAndDestroy(fileData);
-      
       CleanupStack::PopAndDestroy(serverList);
       
       aMessage.Complete(KErrNone);
@@ -800,62 +855,55 @@
     TAgileProvisionPolicy* policy = new (ELeave) TAgileProvisionPolicy();
     CleanupStack::PushL(policy);
     TPckg<TAgileProvisionPolicy> serverPckg(*policy);
-    
-    _LIT8(KCRLF, "\r\n");
-    
+          
     TFileName serverFilePath;
     User::LeaveIfError(iFs.PrivatePath(serverFilePath));
     serverFilePath.Append(KProvisionServerSettings);  
     
-    HBufC8* fileData(NULL);
-         
-    const TInt KEolLen = 2;
-    TBool serverFileExist = EFalse;
-    
     if ( iFileUtil.FileExists(serverFilePath) )
        {
-        fileData=iFileUtil.LoadFileDataL(serverFilePath);
-        CleanupStack::PushL(fileData);   
-        TInt endOfLine=fileData->Find(KCRLF);
-        if (endOfLine<=0)
-            User::Leave(KErrArgument);
+        RFile serverFile;
+        User::LeaveIfError(serverFile.Open(iFs,serverFilePath, EFileRead));
+                                       
+        TFileText tx;
+        tx.Set(serverFile);
+
+        TInt fileSize;
+        User::LeaveIfError(serverFile.Size(fileSize));
+
+        HBufC* serverUrlBuf = HBufC::NewLC(fileSize);
+                                  
+        TPtr serverUrlPtr=serverUrlBuf->Des();
+                                  
+        User::LeaveIfError(tx.Read(serverUrlPtr));
+                                   
+        HBufC* serverNameBuf = HBufC::NewLC(fileSize);
+        TPtr serverNamePtr=serverNameBuf->Des();
+                                   
+        User::LeaveIfError(tx.Read(serverNamePtr));
+                                   
+        TBuf<KMaxIapLength> iapIdData;
+        User::LeaveIfError(tx.Read(iapIdData));
                         
-        TInt startOfLine(endOfLine + KEolLen);
-        TPtrC8 nameData=fileData->Right(fileData->Length()-startOfLine);
-        endOfLine=nameData.Find(KCRLF);      
-        if (endOfLine<=0)
-            User::Leave(KErrArgument);      
-                
-        startOfLine = endOfLine + KEolLen;
-        TPtrC8 iapIdData=nameData.Right(nameData.Length()-startOfLine);
-        endOfLine=iapIdData.Find(KCRLF);
-        if (endOfLine<=0)
-            User::Leave(KErrArgument);      
-           
-        startOfLine = endOfLine + KEolLen;
-        TPtrC8 iapModeData=iapIdData.Right(iapIdData.Length()-startOfLine);
-        endOfLine=iapModeData.Find(KCRLF);
-        if (endOfLine<=0)
-            User::Leave(KErrArgument);      
+        TBuf<KMaxIapLength> iapModeData;
+        User::LeaveIfError(tx.Read(iapModeData));
+                                           
+        TBuf<KMaxIapLength> iapIdBuf;
+               
+        HBufC* policyFileNameBuf = HBufC::NewLC(fileSize);
+        TPtr policyFileNamePtr = policyFileNameBuf->Des();
+               
+        User::LeaveIfError(tx.Read(policyFileNamePtr));
+        policy->iPolicyName = policyFileNamePtr;
+        CleanupStack::PopAndDestroy(policyFileNameBuf);
+        serverFile.Close();
         
-        startOfLine = endOfLine + KEolLen;
-        TPtrC8 policyData=iapModeData.Right(iapModeData.Length()-startOfLine);
-        endOfLine=policyData.Find(KCRLF);
-        if (endOfLine<=0)
-            User::Leave(KErrArgument);      
-        
-        HBufC16* policyName = iFileUtil.To16BitL(policyData.Left(endOfLine));
-        policy->iPolicyName = *policyName;
-        delete policyName;
-        policyName=NULL;
-        serverFileExist = ETrue;
+        CleanupStack::PopAndDestroy(serverNameBuf);
+        CleanupStack::PopAndDestroy(serverUrlBuf);
         }
 
     aMessage.WriteL(0, serverPckg);
-    
-    if ( serverFileExist )
-        CleanupStack::PopAndDestroy(fileData);
-    
+           
     CleanupStack::PopAndDestroy(policy);
     
     aMessage.Complete(KErrNone);
--- a/vpnui/vpndialogmanager/group/vpndialogmanager.mmp	Tue Sep 14 23:16:15 2010 +0300
+++ b/vpnui/vpndialogmanager/group/vpndialogmanager.mmp	Wed Sep 15 13:20:54 2010 +0300
@@ -49,6 +49,7 @@
 LIBRARY         eikcore.lib // For Infowin
 LIBRARY         eiksrvui.lib // Eikon server ui (for suppressing app -key)
 LIBRARY         efsrv.lib
+LIBRARY         eikctl.lib
 LIBRARY         commonengine.lib
 LIBRARY         cdlengine.lib
 
--- a/vpnui/vpndialogmanager/inc/vpndialogshower.h	Tue Sep 14 23:16:15 2010 +0300
+++ b/vpnui/vpndialogmanager/inc/vpndialogshower.h	Wed Sep 15 13:20:54 2010 +0300
@@ -30,7 +30,7 @@
 
 
 const TInt KMaxAcuInputLength = 50;
-const TInt KMaxAuthenticationInputLength = 32;
+const TInt KMinSecurIDPINLength = 4;
 
 class CVpnDialog;
 class CEikColumnListBox;
@@ -57,6 +57,7 @@
     CVpnInfoDialog* ShowNoteDialogL(MVpnNotifierCallback* aNotifier, TInt aTextId);
 	CVpnMultiLineDialog* GetUserPwdDlgL(MVpnNotifierCallback* aNotifier, const TDesC8& aInput);
     CVpnMultiLineDialog* GetSecurIdDlgL(MVpnNotifierCallback* aNotifier, const TDesC8& aInput);
+    CVpnMultiLineDialog* GetSecurIdPinDlgL(MVpnNotifierCallback* aNotifier, const TDesC8& aInput);
     CVpnMultiLineDialog* GetSecurIdNextDlgL(MVpnNotifierCallback* aNotifier, const TDesC8& aInput);
     
 private: 
@@ -187,6 +188,7 @@
     // NewL
     static CKmdDlg* NewL(MVpnNotifierCallback* aNotifier, TDes& aText1, TDes& aText2, TTone aTone = ENoTone);
     static CKmdDlg* NewL(MVpnNotifierCallback* aNotifier, TDes& aText1, TDes& aText2, const TDesC8& aInput, TTone aTone = ENoTone);
+    void SetResourceId(TInt aResourceId);
 protected:  
     //Construction and destruction
     CKmdDlg(MVpnNotifierCallback* aNotifier, const TTone& aTone);
@@ -195,11 +197,13 @@
 
     void PreLayoutDynInitL();
     void SetInitialCurrentLine();
+    void UpdateLeftSoftKeyL();
     // From CVpnMultiLineDialog
     void GetOutputL(TVpnDialogOutput& aOutput, TInt aButtonId);
 
 private: // Data
     TPtrC8 iInput;
+    TInt iResourceId;
     };
 
 
--- a/vpnui/vpndialogmanager/src/vpndialogmanager.cpp	Tue Sep 14 23:16:15 2010 +0300
+++ b/vpnui/vpndialogmanager/src/vpndialogmanager.cpp	Wed Sep 15 13:20:54 2010 +0300
@@ -68,8 +68,10 @@
             // KMD Dialogs
             case TKmdDialog::EUserPwd:
                 return shower->GetUserPwdDlgL(aNotifier, aInput);
+            case TKmdDialog::ESecurIdCode:
+                return shower->GetSecurIdDlgL(aNotifier, aInput);
             case TKmdDialog::ESecurIdPin:
-                return shower->GetSecurIdDlgL(aNotifier, aInput);
+                return shower->GetSecurIdPinDlgL(aNotifier, aInput);
             case TKmdDialog::ESecurIdNextPin:
                 return shower->GetSecurIdNextDlgL(aNotifier, aInput);
 
@@ -125,6 +127,10 @@
         // Kmd note dialogs
         case TVpnNoteDialog::EKmdAuthenticationFailed:
         	return R_KMD_CRACK_AUTH_FAILED;
+        case TVpnNoteDialog::EKmdTokenNotFound:
+            return R_KMD_TOKEN_NOT_FOUND;
+        case TVpnNoteDialog::EKmdTokenExpired:
+            return R_KMD_TOKEN_EXPIRED;
         default:
             LOG_(" Calling CVpnDialogManagerBase::GetNoteTextId()");
             return CVpnDialogManager::GetNoteTextId(aNoteDialogId);
--- a/vpnui/vpndialogmanager/src/vpndialogshower.cpp	Tue Sep 14 23:16:15 2010 +0300
+++ b/vpnui/vpndialogmanager/src/vpndialogshower.cpp	Wed Sep 15 13:20:54 2010 +0300
@@ -103,6 +103,16 @@
     return dialog;
     }
 
+CVpnMultiLineDialog* CVpnDialogShower::GetSecurIdPinDlgL(MVpnNotifierCallback* aNotifier, const TDesC8& aInput)
+    {
+    iValue1 = KNullDesC;
+    iValue2 = KNullDesC;
+    CKmdDlg* dialog = CKmdDlg::NewL(aNotifier, iValue1, iValue2, aInput, CAknQueryDialog::ENoTone);
+    dialog->SetResourceId(R_KMD_CRACK_SID_PIN_QUERY);
+    dialog->ExecuteLD(R_KMD_CRACK_SID_PIN_QUERY);
+    return dialog;
+    }
+
 CVpnMultiLineDialog* CVpnDialogShower::GetSecurIdNextDlgL(MVpnNotifierCallback* aNotifier, const TDesC8& aInput)
     {
     iValue1 = KNullDesC;
@@ -489,12 +499,14 @@
 
 CKmdDlg::CKmdDlg(MVpnNotifierCallback* aNotifier, const TTone& aTone) : CVpnMultiLineDialog(aNotifier, aTone)
     {
+    iResourceId = 0;
     }
 
 CKmdDlg::CKmdDlg(MVpnNotifierCallback* aNotifier, const TDesC8& aInput, const TTone& aTone)
 : CVpnMultiLineDialog(aNotifier, aTone)
     {
     iInput.Set(aInput);
+    iResourceId = 0;
     }
 
 CKmdDlg* CKmdDlg::NewL(MVpnNotifierCallback* aNotifier, TDes& aData1, TDes& aData2, TTone aTone)
@@ -521,11 +533,18 @@
     return self;
     }
 
+void CKmdDlg::SetResourceId(TInt aResourceId)
+    {
+    iResourceId = aResourceId;
+    }
 void CKmdDlg::PreLayoutDynInitL()
     {
-    SetMaxLengthOfFirstEditor(KMaxAuthenticationInputLength);
-    SetMaxLengthOfSecondEditor(KMaxAuthenticationInputLength);
-    
+    if (iResourceId == R_KMD_CRACK_SID_PIN_QUERY)
+        {
+        CAknQueryControl* secondControl = static_cast<CAknQueryControl*>(Control(EEikCidPasswordConfirm));
+        CEikSecretEditor* secretEditor = static_cast<CEikSecretEditor*>(secondControl->ControlByLayoutOrNull( EMultiDataSecondSecEd ));
+        secretEditor->SetDefaultInputMode(EAknEditorNumericInputMode);
+        }
     CAknMultiLineDataQueryDialog::PreLayoutDynInitL();
     
     CAknQueryControl* usernameControl = static_cast<CAknQueryControl*>(Control(EEikCidPassword));
@@ -543,6 +562,27 @@
         }
     }
 
+void CKmdDlg::UpdateLeftSoftKeyL()
+    {
+  
+    CAknQueryControl* secondControl = static_cast<CAknQueryControl*>(Control(EEikCidPasswordConfirm));
+    if (iResourceId == R_KMD_CRACK_SID_PIN_QUERY)
+        {
+        if ( (0 == secondControl->GetTextLength()) || 
+             (KMinSecurIDPINLength <= secondControl->GetTextLength()) )
+            MakeLeftSoftkeyVisible(ETrue);
+        else 
+            MakeLeftSoftkeyVisible(EFalse);
+        }
+    else 
+        {
+        if (0 != secondControl->GetTextLength())
+            MakeLeftSoftkeyVisible(ETrue);
+        else
+            MakeLeftSoftkeyVisible(EFalse);
+        }
+    }
+
 void CKmdDlg::SetInitialCurrentLine()
     {
     CAknMultiLineDataQueryDialog::SetInitialCurrentLine();
--- a/vpnui/vpnecomnotifier/data/vpnecomnotifier.rss	Tue Sep 14 23:16:15 2010 +0300
+++ b/vpnui/vpnecomnotifier/data/vpnecomnotifier.rss	Wed Sep 15 13:20:54 2010 +0300
@@ -373,6 +373,50 @@
         };
     }
 
+RESOURCE DIALOG r_kmd_crack_sid_pin_query
+    {
+    flags=EEikDialogFlagNotifyEsc;
+    buttons=R_AVKON_SOFTKEYS_OK_CANCEL;
+    items=
+        {
+        DLG_LINE
+            {
+            type=EAknCtMultilineQuery;
+            id=EEikCidPassword;
+            control=AVKON_DATA_QUERY
+                {
+                layout = EMultiDataFirstEdwin;
+                label = qtn_vpn_prmpt_gw_username_legacy;
+                control=EDWIN
+                    {
+                    flags=0;
+                    width=5;
+                    lines=1;
+                    maxlength=32;
+                    default_case = EAknEditorLowerCase;
+                    allowed_case_modes = EAknEditorAllCaseModes;
+                    avkon_flags = EAknEditorFlagNoT9  | 
+                        EAknEditorFlagLatinInputModesOnly;                      
+                    };
+                };
+            },
+        DLG_LINE
+            {
+            type=EAknCtMultilineQuery;
+            id=EEikCidPasswordConfirm;
+            control= AVKON_DATA_QUERY
+                {
+                layout = EMultiDataSecondSecEd;
+                label = qtn_vpn_prmpt_gw_securid_pin;
+                control = SECRETED
+                    {
+                    num_letters = 8;
+                    };
+                };
+            }
+        };
+    }
+
 RESOURCE DIALOG r_kmd_crack_sid_next_query
     {
     flags=EEikDialogFlagNotifyEsc;
@@ -424,6 +468,16 @@
     buf = qtn_vpn_err_auth_failed;
     }
 
+RESOURCE TBUF r_kmd_token_not_found
+    {
+    buf = qtn_vpn_err_token_not_found;
+    }
+
+RESOURCE TBUF r_kmd_token_expired
+    {
+    buf = qtn_vpn_err_token_expired;
+    }
+
 RESOURCE TBUF r_acu_next_server_identity
     {
     buf = qtn_vpn_info_verify_hash;
--- a/vpnui/vpnecomnotifier/loc/vpnnotifier.loc	Tue Sep 14 23:16:15 2010 +0300
+++ b/vpnui/vpnecomnotifier/loc/vpnnotifier.loc	Wed Sep 15 13:20:54 2010 +0300
@@ -72,6 +72,12 @@
 //
 #define qtn_vpn_prmpt_gw_password_legacy "VPN password:"
 
+//d:SecurID PIN in VPN gateway user authentication query
+//d:SecurID based authentication
+//l:popup_query_data_window/opt5
+//
+#define qtn_vpn_prmpt_gw_securid_pin "SecurID (C) PIN:"
+
 //d:User identity query presented to the user during VPN certificate enrollment (fetching)
 //d:%U is replaced during run-time with a domain name such as "company.com" or "OU=Unit, O=Company" 
 //l:popup_query_data_window/opt5
@@ -110,6 +116,16 @@
 //
 #define qtn_vpn_err_auth_failed "Authentication failed"
 
+//d:SecurID software token is not installed.
+//l:popup_note_window
+//
+#define qtn_vpn_err_token_not_found "SecurID (C) token not found"
+
+//d:SecurID software token is expired.
+//l:popup_note_window
+//
+#define qtn_vpn_err_token_expired "SecurID (C) token expired"
+
 //d:Incorrect characters were entered
 //l:popup_note_window
 //
--- a/vpnui/vpnmanagementui/inc/vpnmanagementuiview.h	Tue Sep 14 23:16:15 2010 +0300
+++ b/vpnui/vpnmanagementui/inc/vpnmanagementuiview.h	Wed Sep 15 13:20:54 2010 +0300
@@ -229,6 +229,8 @@
         
         TInt iCurrentItem; // currently selected listbox item
         TInt iTopItemIndex; // first item in the listbox
+        
+        HBufC* iCaption; // caption text
     };
 
 #endif // __VPNMANAGEMENTUIVIEW_H__
--- a/vpnui/vpnmanagementui/src/vpnmanagementuiview.cpp	Tue Sep 14 23:16:15 2010 +0300
+++ b/vpnui/vpnmanagementui/src/vpnmanagementuiview.cpp	Wed Sep 15 13:20:54 2010 +0300
@@ -72,7 +72,8 @@
         AppUi()->RemoveFromViewStack(*this, iContainer);
         delete iContainer;
         }
-    delete iLoader;
+    delete iLoader;    
+    delete iCaption;
     LOG_("CVpnManagementUiView::~CVpnManagementUiView() exited");
     }
 
@@ -113,8 +114,12 @@
     LOG_("CVpnManagementUiView::ConstructL() entered");
     iLoader = CVpnUiLoader::NewL(iAvkonViewAppUi->ClientRect(), 
                 KVpnManagementPluginUid, this );
-    BaseConstructL( R_VPNUI_MANAGEMENT_VIEW );
+    
+    iLoader->AddResourceFileL();
+    BaseConstructL( R_VPNUI_MANAGEMENT_VIEW );    
+    iCaption = StringLoader::LoadL( R_VPN_MANAGEMENT_TITLE_BUF );    
     iLoader->ReleaseResource();
+    
     LOG_("CVpnManagementUiView::ConstructL() exited");
     }
 
@@ -124,9 +129,17 @@
 void CVpnManagementUiView::GetCaptionL( TDes& aCaption ) const
     {
     LOG_("CVpnManagementUiView::GetCaptionL() entered");
-    iLoader->AddResourceFileL();
-    StringLoader::Load( aCaption, R_VPN_MANAGEMENT_TITLE_BUF );
-    iLoader->ReleaseResource();
+    
+    __ASSERT_DEBUG(iCaption != NULL, User::Invariant());
+    
+    if (aCaption.MaxLength() < iCaption->Length())
+        {
+        aCaption = iCaption->Left(aCaption.MaxLength());
+        }
+    else
+        {
+        aCaption = *iCaption;
+        }
     LOG_("CVpnManagementUiView::GetCaptionL() exited");
     }
 
@@ -152,7 +165,8 @@
         {
         case EAknSoftkeyBack:
             {
-            iLoader->ChangeViewL( KChangeViewBack ); 
+            iLoader->ChangeViewL( KChangeViewBack );
+            iLoader->ReleaseResource(ETrue);
             break;
             }
         case EAknCmdExit:
--- a/vpnui/vpnmanagementui/src/vpnuiloader.cpp	Tue Sep 14 23:16:15 2010 +0300
+++ b/vpnui/vpnmanagementui/src/vpnuiloader.cpp	Wed Sep 15 13:20:54 2010 +0300
@@ -116,7 +116,6 @@
     {
     LOG_("CVpnUiLoader::ConstructL() - begin");
     
-    AddResourceFileL();
     //Initialization
     iBackFromServerDefinition = EFalse;
     iNewServerDefinition = EFalse;