34 #include "ikev1payload.h" |
34 #include "ikev1payload.h" |
35 #include "ikev1timeout.h" |
35 #include "ikev1timeout.h" |
36 #include "ikev1crack.h" |
36 #include "ikev1crack.h" |
37 #include "ikev1isakmpstream.h" |
37 #include "ikev1isakmpstream.h" |
38 #include "ikev1crypto.h" |
38 #include "ikev1crypto.h" |
39 #include "credentialcache.h" |
|
40 |
|
41 |
39 |
42 const TUint8 XAUTH_VID_DATA[8] = {0x09, 0x00, 0x26, 0x89, 0xdf, 0xd6, 0xb7, 0x12}; |
40 const TUint8 XAUTH_VID_DATA[8] = {0x09, 0x00, 0x26, 0x89, 0xdf, 0xd6, 0xb7, 0x12}; |
43 const TUint8 CISCO_UNITY_VID_DATA[16] = {0x12, 0xf5, 0xf2, 0x8c, 0x45, 0x71, 0x68, 0xa9, |
41 const TUint8 CISCO_UNITY_VID_DATA[16] = {0x12, 0xf5, 0xf2, 0x8c, 0x45, 0x71, 0x68, 0xa9, |
44 0x70, 0x2d, 0x9f, 0xe2, 0x74, 0xcc, 0x01, 0x00}; |
42 0x70, 0x2d, 0x9f, 0xe2, 0x74, 0xcc, 0x01, 0x00}; |
45 |
43 |
46 const TInt KCredentialTypeUnknown = 0; |
|
47 const TInt KCredentialTypeNew = 1; |
|
48 const TInt KCredentialTypeCached = 2; |
|
49 |
|
50 |
44 |
51 CTransNegotiation::CTransNegotiation( TInt aGranularity, |
45 CTransNegotiation::CTransNegotiation( TInt aGranularity, |
52 TBool aUseXauth, |
46 TBool aUseXauth, |
53 TBool aUseCfgMode, |
47 TBool aUseCfgMode, |
54 CIkev1PluginSession* aPluginSession, |
48 CIkev1PluginSession* aPluginSession, |
119 { |
112 { |
120 if ( !iPluginSession || !iNegotiation || (!iUseXauth && !iUseCfgMode)) |
113 if ( !iPluginSession || !iNegotiation || (!iUseXauth && !iUseCfgMode)) |
121 { |
114 { |
122 User::Leave(KErrArgument); |
115 User::Leave(KErrArgument); |
123 } |
116 } |
124 |
117 |
|
118 DEBUG_LOG(_L("Transaction exchange object constructed")); |
125 if ( !iUseXauth ) |
119 if ( !iUseXauth ) |
126 { |
120 { |
127 iXauthCompleted = ETrue; |
121 iXauthCompleted = ETrue; |
128 iNegotiation->iTimer->Cancel(); // Stop retransmission timer |
122 iNegotiation->iTimer->Cancel(); // Stop retransmission timer |
129 } |
123 } |
130 else |
124 else |
131 { |
125 { |
132 if ( !iUseCfgMode ) |
126 if ( !iUseCfgMode ) |
133 iCfgModeCompleted = ETrue; |
127 iCfgModeCompleted = ETrue; |
134 DEBUG_LOG(_L("Starting to Wait XAUTH request")); |
128 DEBUG_LOG(_L("Starting to Wait XAUTH request")); |
135 } |
129 } |
136 |
|
137 if( EFalse != iPluginSession->IkeData().iUseCache ) |
|
138 { |
|
139 iCache = CCredentialCache::NewL( iDebug ); |
|
140 } |
|
141 |
|
142 DEBUG_LOG(_L("Transaction exchange object constructed")); |
|
143 } |
130 } |
144 |
131 |
145 /**------------------------------------------------------------------- |
132 /**------------------------------------------------------------------- |
146 * |
133 * |
147 * Method GetAuthMethod() |
134 * Method GetAuthMethod() |
324 case (1 << (ATTR_NEXT_PIN - ATTR_XAUTH_TYPE)): |
306 case (1 << (ATTR_NEXT_PIN - ATTR_XAUTH_TYPE)): |
325 AttrType = ATTR_NEXT_PIN; |
307 AttrType = ATTR_NEXT_PIN; |
326 break; |
308 break; |
327 |
309 |
328 default: |
310 default: |
329 if( iCache && KCredentialTypeNew == iCredentialType ) |
|
330 { |
|
331 iCache->SetSecret( *aDialogInfo->iSecret ); |
|
332 } |
|
333 break; |
311 break; |
334 } |
312 |
|
313 } |
335 AddAttributeData(attr_ptr, AttrType, aDialogInfo->iSecret->Length(), |
314 AddAttributeData(attr_ptr, AttrType, aDialogInfo->iSecret->Length(), |
336 (TUint8*)aDialogInfo->iSecret->Ptr()); |
315 (TUint8*)aDialogInfo->iSecret->Ptr()); |
337 } |
316 } |
338 |
317 |
339 BuildAndSendMessageL(attr_ptr, ISAKMP_CFG_REPLY); |
318 BuildAndSendMessageL(attr_ptr, ISAKMP_CFG_REPLY); |
819 |
798 |
820 case ( (1 << (ATTR_USER_NAME - ATTR_XAUTH_TYPE)) | (1 << (ATTR_PASSWORD - ATTR_XAUTH_TYPE))): |
799 case ( (1 << (ATTR_USER_NAME - ATTR_XAUTH_TYPE)) | (1 << (ATTR_PASSWORD - ATTR_XAUTH_TYPE))): |
821 // |
800 // |
822 // User name/Password authentication required |
801 // User name/Password authentication required |
823 // |
802 // |
824 GetCredentialsL(); |
803 iDialog = CIkev1Dialog::NewL(iPluginSession, iPluginSession->DialogAnchor(), iDebug); |
|
804 iDialogInfo = new(ELeave) CAuthDialogInfo(iPluginSession, XAUTH_DIALOG_ID, iNegotiation->SAId(), iCurrExchange->iMessageId); |
|
805 iDialog->GetAsyncUNPWDialogL(iDialogInfo, (MIkeDialogComplete*)this); |
825 break; |
806 break; |
826 |
807 |
827 case ( (1 << (ATTR_USER_NAME - ATTR_XAUTH_TYPE)) | (1 << (ATTR_PASSCODE - ATTR_XAUTH_TYPE))): |
808 case ( (1 << (ATTR_USER_NAME - ATTR_XAUTH_TYPE)) | (1 << (ATTR_PASSCODE - ATTR_XAUTH_TYPE))): |
828 // |
809 // |
829 // User name/Secure ID authentication required |
810 // User name/Secure ID authentication required |
830 // |
811 // |
831 iDialog = CIkev1Dialog::NewL(iPluginSession, iPluginSession->DialogAnchor(), iDebug); |
812 iDialog = CIkev1Dialog::NewL(iPluginSession, iPluginSession->DialogAnchor(), iDebug); |
832 iDialogInfo = new(ELeave) CAuthDialogInfo(iPluginSession, XAUTH_DIALOG_ID, iNegotiation->SAId(), iCurrExchange->iMessageId); |
813 iDialogInfo = new(ELeave) CAuthDialogInfo(iPluginSession, XAUTH_DIALOG_ID, iNegotiation->SAId(), iCurrExchange->iMessageId); |
833 iDialog->GetAsyncSecureidDialogL(iDialogInfo, static_cast<MIkeDialogComplete*>(this)); |
814 iDialog->GetAsyncSecureidDialogL(iDialogInfo, (MIkeDialogComplete*)this); |
834 break; |
815 break; |
835 |
816 |
836 case ( (1 << (ATTR_USER_NAME - ATTR_XAUTH_TYPE)) | (1 << (ATTR_NEXT_PIN - ATTR_XAUTH_TYPE))): |
817 case ( (1 << (ATTR_USER_NAME - ATTR_XAUTH_TYPE)) | (1 << (ATTR_NEXT_PIN - ATTR_XAUTH_TYPE))): |
837 // |
818 // |
838 // User name/Secure ID next pin required |
819 // User name/Secure ID next pin required |
839 // |
820 // |
840 iDialog = CIkev1Dialog::NewL(iPluginSession, iPluginSession->DialogAnchor(), iDebug); |
821 iDialog = CIkev1Dialog::NewL(iPluginSession, iPluginSession->DialogAnchor(), iDebug); |
841 iDialogInfo = new(ELeave) CAuthDialogInfo(iPluginSession, XAUTH_DIALOG_ID, iNegotiation->SAId(), iCurrExchange->iMessageId); |
822 iDialogInfo = new(ELeave) CAuthDialogInfo(iPluginSession, XAUTH_DIALOG_ID, iNegotiation->SAId(), iCurrExchange->iMessageId); |
842 iDialog->GetAsyncSecureNextPinDialogL(iDialogInfo, static_cast<MIkeDialogComplete*>(this)); |
823 iDialog->GetAsyncSecureNextPinDialogL(iDialogInfo, (MIkeDialogComplete*)this); |
843 break; |
824 break; |
844 |
825 |
845 case ( (1 << (ATTR_CHALLENGE - ATTR_XAUTH_TYPE)) ): |
826 case ( (1 << (ATTR_CHALLENGE - ATTR_XAUTH_TYPE)) ): |
846 // |
827 // |
847 // User Challenge response dialog |
828 // User Challenge response dialog |
848 // |
829 // |
849 if ( xauth_type == ATTR_XAUTH_RADIUS_CHAP ) |
830 if ( xauth_type == ATTR_XAUTH_RADIUS_CHAP ) |
850 { |
831 { |
851 iDialog = CIkev1Dialog::NewL(iPluginSession, iPluginSession->DialogAnchor(), iDebug); |
832 iDialog = CIkev1Dialog::NewL(iPluginSession, iPluginSession->DialogAnchor(), iDebug); |
852 iDialogInfo = new(ELeave) CAuthDialogInfo(iPluginSession, XAUTH_DIALOG_ID, iNegotiation->SAId(), iCurrExchange->iMessageId); |
833 iDialogInfo = new(ELeave) CAuthDialogInfo(iPluginSession, XAUTH_DIALOG_ID, iNegotiation->SAId(), iCurrExchange->iMessageId); |
853 iDialog->GetAsyncRespDialog(challenge, iDialogInfo, static_cast<MIkeDialogComplete*>(this)); |
834 iDialog->GetAsyncRespDialog(challenge, iDialogInfo, (MIkeDialogComplete*)this); |
854 } |
835 } |
855 break; |
836 break; |
856 |
837 |
857 default: |
838 default: |
858 break; |
839 break; |
859 |
840 |
860 } |
841 } |
861 |
842 |
862 return status; |
843 return status; |
|
844 |
863 } |
845 } |
864 |
846 |
865 /**------------------------------------------------------------------- |
847 /**------------------------------------------------------------------- |
866 * |
848 * |
867 * Method ProcessXauthStatus() |
849 * Method ProcessXauthStatus() |
872 TInt CTransNegotiation::ProcessXauthStatusL(TDataISAKMP* aAttr, TInt aLth) |
854 TInt CTransNegotiation::ProcessXauthStatusL(TDataISAKMP* aAttr, TInt aLth) |
873 { |
855 { |
874 TBuf8<16> attributes; |
856 TBuf8<16> attributes; |
875 TInt status = TRANSACTION_CONTINUE; |
857 TInt status = TRANSACTION_CONTINUE; |
876 TInt16 attr_status; |
858 TInt16 attr_status; |
877 |
859 |
878 while ( aLth > 0 ) { |
860 while ( aLth > 0 ) { |
879 |
861 |
880 aLth = aLth - aAttr->Size(); |
862 aLth = aLth - aAttr->Size(); |
881 if ( aLth < 0 ) { |
863 if ( aLth < 0 ) { |
882 DEBUG_LOG(_L("XAUTH SET ERROR (Length mismatch in the attibutes)")); |
864 DEBUG_LOG(_L("XAUTH SET ERROR (Length mismatch in the attibutes)")); |
883 iCredentialType = KCredentialTypeUnknown; |
|
884 return TRANSACTION_FAILED; |
865 return TRANSACTION_FAILED; |
885 } |
866 } |
886 |
867 |
887 switch ( aAttr->Type() ) { |
868 switch ( aAttr->Type() ) { |
888 |
869 |
918 AddAttributeData(attributes, AttrType, 2, (TUint8*)&attr_status); |
899 AddAttributeData(attributes, AttrType, 2, (TUint8*)&attr_status); |
919 BuildAndSendMessageL(attributes, ISAKMP_CFG_ACK); |
900 BuildAndSendMessageL(attributes, ISAKMP_CFG_ACK); |
920 if ( status == TRANSACTION_SUCCESS ) { |
901 if ( status == TRANSACTION_SUCCESS ) { |
921 DEBUG_LOG(_L("XAUTH authentication succeeded!")); |
902 DEBUG_LOG(_L("XAUTH authentication succeeded!")); |
922 iXauthCompleted = ETrue; |
903 iXauthCompleted = ETrue; |
923 |
|
924 if( iCache && KCredentialTypeNew == iCredentialType ) |
|
925 { |
|
926 iCache->Store( iPluginSession->VpnIapId() ); |
|
927 } |
|
928 |
|
929 if ( iUserName ) { |
904 if ( iUserName ) { |
|
905 // |
930 // Cache user name into user name file |
906 // Cache user name into user name file |
|
907 // |
931 CIkev1Dialog* Dialog = CIkev1Dialog::NewL(iPluginSession, iPluginSession->DialogAnchor(), iDebug); |
908 CIkev1Dialog* Dialog = CIkev1Dialog::NewL(iPluginSession, iPluginSession->DialogAnchor(), iDebug); |
932 CleanupStack::PushL(Dialog); |
909 CleanupStack::PushL(Dialog); |
933 TInt err(KErrNone); |
910 TInt err(KErrNone); |
934 TRAP(err, Dialog->StoreUserNameL(iUserName->Des())); |
911 TRAP(err, Dialog->StoreUserNameL(iUserName->Des())); |
935 |
|
936 #ifdef _DEBUG |
912 #ifdef _DEBUG |
937 if (err == KErrNone) |
913 if (err == KErrNone) |
938 DEBUG_LOG(_L("User Name caching succeeded")); |
914 DEBUG_LOG(_L("User Name caching succeeded")); |
939 else DEBUG_LOG(_L("User Name caching failed")); |
915 else DEBUG_LOG(_L("User Name caching failed")); |
940 #endif // _DEBUG |
916 #endif // _DEBUG |
941 CleanupStack::PopAndDestroy(); |
917 CleanupStack::PopAndDestroy(); |
942 } |
918 } |
943 } |
919 } |
944 else { |
920 else { |
945 if( iCache ) |
|
946 { |
|
947 iCache->Clear(); |
|
948 } |
|
949 DEBUG_LOG(_L("XAUTH authentication failed!")); |
921 DEBUG_LOG(_L("XAUTH authentication failed!")); |
|
922 // Dialog object shall be delete in Dialog->RunL when dialog completed |
|
923 CIkev1Dialog* Dialog = CIkev1Dialog::NewL(iPluginSession, iPluginSession->DialogAnchor(), iDebug); |
|
924 Dialog->ShowErrorDialogL(TVpnNoteDialog::EKmdAuthenticationFailed, NULL, NULL); |
950 } |
925 } |
951 } |
926 } |
952 |
927 |
953 iCredentialType = KCredentialTypeUnknown; |
|
954 |
|
955 return status; |
928 return status; |
956 } |
929 } |
957 |
930 |
958 /**-------------------------------------------------------------------------------- |
931 /**-------------------------------------------------------------------------------- |
959 * |
932 * |
1136 } |
1112 } |
1137 |
1113 |
1138 // |
1114 // |
1139 // The implementation for class MIkeDialogComplete virtual function |
1115 // The implementation for class MIkeDialogComplete virtual function |
1140 // |
1116 // |
1141 TInt CTransNegotiation::DialogCompleteL( |
1117 TInt CTransNegotiation::DialogCompleteL(CIkev1Dialog* /*aDialog*/, TAny* aUserInfo, |
1142 TAny* aUserInfo, HBufC8* aUsername, HBufC8* aSecret) |
1118 HBufC8* aUsername, HBufC8* aSecret, HBufC8* aDomain) |
1143 { |
1119 { |
1144 /*--------------------------------------------------------------------------- |
1120 /*--------------------------------------------------------------------------- |
1145 * |
1121 * |
1146 * A response received from client user (through asynchronous dialog) |
1122 * A response received from client user (through asynchronous dialog) |
1147 * This method is introduced as a TUserCallback for CGetIKEPassword dialog |
1123 * This method is introduced as a TUserCallback for CGetIKEPassword dialog |
1151 * entry |
1127 * entry |
1152 * |
1128 * |
1153 *-------------------------------------------------------------------------*/ |
1129 *-------------------------------------------------------------------------*/ |
1154 TUint32 obj_id = 1; |
1130 TUint32 obj_id = 1; |
1155 CAuthDialogInfo* info = (CAuthDialogInfo*)aUserInfo; |
1131 CAuthDialogInfo* info = (CAuthDialogInfo*)aUserInfo; |
1156 DEBUG_LOG1(_L("CTransNegotiation::DialogCompleteL(), aUserInfo=%x"), aUserInfo); |
1132 DEBUG_LOG1(_L("CIKECRACKNegotiation::DialogCompleteL(), aUserInfo = %x"), aUserInfo); |
1157 |
1133 |
1158 if ( info ) |
1134 if ( info ) |
1159 { |
1135 { |
1160 obj_id = info->GetObjId(); |
1136 obj_id = info->GetObjId(); |
1161 info->iNegotiation = iNegotiation; |
|
1162 DEBUG_LOG1(_L("Preparing to call AuthDialogCompletedL(), ObjId = %x"), obj_id); |
1137 DEBUG_LOG1(_L("Preparing to call AuthDialogCompletedL(), ObjId = %x"), obj_id); |
1163 if ( obj_id == XAUTH_DIALOG_ID ) |
1138 if ( obj_id == XAUTH_DIALOG_ID ) |
1164 { |
1139 { |
1165 info->SetUserName( aUsername ); |
1140 info->iUsername = aUsername; |
1166 info->SetSecret( aSecret ); |
1141 info->iSecret = aSecret; |
|
1142 info->iDomain = aDomain; |
1167 obj_id = info->PluginSession()->AuthDialogCompletedL(info); |
1143 obj_id = info->PluginSession()->AuthDialogCompletedL(info); |
1168 } |
1144 } |
1169 } |
1145 } |
1170 |
1146 |
1171 return obj_id; |
1147 return obj_id; |
1172 } |
1148 } |
1173 |
|
1174 |
|
1175 void CTransNegotiation::GetCredentialsL() |
|
1176 { |
|
1177 DEBUG_LOG( _L( "CTransNegotiation::GetCredentialsL" ) ); |
|
1178 |
|
1179 TInt ret = KErrNotFound; |
|
1180 |
|
1181 delete iDialogInfo; iDialogInfo = NULL; |
|
1182 |
|
1183 iDialogInfo = new (ELeave) CAuthDialogInfo( |
|
1184 iPluginSession, |
|
1185 XAUTH_DIALOG_ID, |
|
1186 iNegotiation->SAId(), |
|
1187 iCurrExchange->iMessageId ); |
|
1188 |
|
1189 if( iCache && KCredentialTypeUnknown == iCredentialType ) |
|
1190 { |
|
1191 ret = iCache->GetCredentials( |
|
1192 iPluginSession->VpnIapId(), |
|
1193 iDialogInfo->iUsername, |
|
1194 iDialogInfo->iSecret |
|
1195 ); |
|
1196 } |
|
1197 |
|
1198 if( KErrNone == ret ) |
|
1199 { |
|
1200 iCredentialType = KCredentialTypeCached; |
|
1201 iDialogInfo->iNegotiation = iNegotiation; |
|
1202 TUint32 id = iPluginSession->AuthDialogCompletedL( iDialogInfo ); |
|
1203 } |
|
1204 else |
|
1205 { |
|
1206 iCredentialType = KCredentialTypeNew; |
|
1207 |
|
1208 delete iDialog; iDialog = NULL; |
|
1209 |
|
1210 iDialog = CIkev1Dialog::NewL( |
|
1211 iPluginSession, iPluginSession->DialogAnchor(), iDebug ); |
|
1212 |
|
1213 iDialog->GetAsyncUNPWDialogL( iDialogInfo, static_cast<MIkeDialogComplete*>(this) ); |
|
1214 } |
|
1215 } |
|
1216 |
|
1217 |
|
1218 /***/ |
|