--- 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;
+
+}
+
+