eapol/eapol_framework/eapol_symbian/am/type/mschapv2/symbian/plugin/src/EapMsChapV2.cpp
branchRCL_3
changeset 18 bad0cc58d154
parent 2 1c7bc153c08e
child 19 c74b3d9f6b9e
equal deleted inserted replaced
17:30e048a7b597 18:bad0cc58d154
    14 * Description:  EAP and WLAN authentication protocols.
    14 * Description:  EAP and WLAN authentication protocols.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: 17.1.3 %
    19 * %version: 31 %
    20 */
    20 */
    21 
    21 
    22 // This is enumeration of EAPOL source code.
    22 // This is enumeration of EAPOL source code.
    23 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
    23 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
    24 	#undef EAP_FILE_NUMBER_ENUM
    24 	#undef EAP_FILE_NUMBER_ENUM
    35 #include "eap_type_mschapv2.h"
    35 #include "eap_type_mschapv2.h"
    36 #include "EapMsChapV2Global.h"
    36 #include "EapMsChapV2Global.h"
    37 #include <EapTypeInfo.h>
    37 #include <EapTypeInfo.h>
    38 #include "EapMsChapV2DbUtils.h"
    38 #include "EapMsChapV2DbUtils.h"
    39 
    39 
    40 #include <EapMsChapV2UiConnection.h>
    40 #include "EapConversion.h"
    41 #include "EapMschapv2Ui.h"
    41 #include "EapTraceSymbian.h"
    42 
    42 
    43 // LOCAL CONSTANTS
    43 // LOCAL CONSTANTS
    44 
    44 
    45 // The version number of this interface.
    45 // The version number of this interface.
    46 const TUint KInterfaceVersion = 1;
    46 const TUint KInterfaceVersion = 1;
    47 
    47 
    48 
    48 
    49 // ================= MEMBER FUNCTIONS =======================
    49 // ================= MEMBER FUNCTIONS =======================
    50 
    50 
    51 
    51 
    52 CEapMsChapV2::CEapMsChapV2(const TIndexType aIndexType,	
    52 CEapMsChapV2::CEapMsChapV2(
    53 				 const TInt aIndex, const eap_type_value_e aEapType /* =eap_type_mschapv2 */)
    53 	const TIndexType aIndexType,	
       
    54 	const TInt aIndex,
       
    55 	const eap_type_value_e aEapType)
    54 : iIndexType(aIndexType)
    56 : iIndexType(aIndexType)
    55 , iIndex(aIndex)
    57 , iIndex(aIndex)
    56 , iTunnelingType(eap_type_none)
    58 , iTunnelingType(eap_type_none)
    57 , iEapType(aEapType)
    59 , iEapType(aEapType)
    58 {
    60 {
       
    61 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapMsChapV2::CEapMsChapV2()\n")));
       
    62 	EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: CEapMsChapV2::CEapMsChapV2()\n"));
       
    63 
    59 }
    64 }
    60 
    65 
    61 // ----------------------------------------------------------
    66 // ----------------------------------------------------------
    62 
    67 
    63 CEapMsChapV2* CEapMsChapV2::NewL(SIapInfo *aIapInfo)
    68 CEapMsChapV2* CEapMsChapV2::NewL(SIapInfo *aIapInfo)
    64 {
    69 {
    65 	return new (ELeave) CEapMsChapV2(aIapInfo->indexType, aIapInfo->index);
    70 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapMsChapV2::NewL()\n")));
       
    71 	EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: CEapMsChapV2::NewL()\n"));
       
    72 
       
    73 	return new (ELeave) CEapMsChapV2(aIapInfo->indexType, aIapInfo->index, eap_type_mschapv2);
    66 }
    74 }
    67 
    75 
    68 // ----------------------------------------------------------
    76 // ----------------------------------------------------------
    69 
    77 
    70 CEapMsChapV2* CEapMsChapV2::NewPlainMSCHAPv2L(SIapInfo *aIapInfo)
    78 CEapMsChapV2* CEapMsChapV2::NewPlainMSCHAPv2L(SIapInfo *aIapInfo)
    71 {
    79 {
       
    80 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapMsChapV2::NewPlainMSCHAPv2L()\n")));
       
    81 	EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: CEapMsChapV2::NewPlainMSCHAPv2L()\n"));
       
    82 
    72 	return new (ELeave) CEapMsChapV2(
    83 	return new (ELeave) CEapMsChapV2(
    73 		aIapInfo->indexType,
    84 		aIapInfo->indexType,
    74 		aIapInfo->index,
    85 		aIapInfo->index,
    75 #if defined(USE_EAP_EXPANDED_TYPES)
       
    76 		eap_expanded_type_ttls_plain_mschapv2.get_type()
    86 		eap_expanded_type_ttls_plain_mschapv2.get_type()
    77 #else
       
    78 		eap_type_plain_mschapv2
       
    79 #endif //#if defined(USE_EAP_EXPANDED_TYPES)
       
    80 		);
    87 		);
    81 }
    88 }
    82 
    89 
    83 
    90 
    84 // ----------------------------------------------------------
    91 // ----------------------------------------------------------
    85 
    92 
    86 CEapMsChapV2::~CEapMsChapV2()
    93 CEapMsChapV2::~CEapMsChapV2()
    87 {
    94 {
       
    95 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapMsChapV2::~CEapMsChapV2()\n")));
       
    96 	EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: CEapMsChapV2::~CEapMsChapV2()\n"));
       
    97 
    88 }
    98 }
    89 
    99 
    90 // ----------------------------------------------------------
   100 // ----------------------------------------------------------
    91 
   101 
    92 #ifdef USE_EAP_SIMPLE_CONFIG
   102 #ifdef USE_EAP_SIMPLE_CONFIG
   104 											const bool is_client_when_true,
   114 											const bool is_client_when_true,
   105 											const eap_am_network_id_c * const receive_network_id)
   115 											const eap_am_network_id_c * const receive_network_id)
   106 	
   116 	
   107 #endif // #ifdef USE_EAP_SIMPLE_CONFIG
   117 #endif // #ifdef USE_EAP_SIMPLE_CONFIG
   108 {
   118 {
       
   119 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapMsChapV2::GetStackInterfaceL()\n")));
       
   120 	EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: CEapMsChapV2::GetStackInterfaceL()\n"));
       
   121 
   109 	// Create AM
   122 	// Create AM
   110 	eap_am_type_mschapv2_symbian_c* amEapType = eap_am_type_mschapv2_symbian_c::NewL(
   123 	eap_am_type_mschapv2_symbian_c* amEapType = eap_am_type_mschapv2_symbian_c::NewL(
   111 		aTools,
   124 		aTools,
   112 		aPartner,
   125 		aPartner,
   113 		iIndexType,
   126 		iIndexType,
   151 
   164 
   152 // ----------------------------------------------------------
   165 // ----------------------------------------------------------
   153 
   166 
   154 TUint CEapMsChapV2::GetInterfaceVersion() 
   167 TUint CEapMsChapV2::GetInterfaceVersion() 
   155 { 
   168 { 
       
   169 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapMsChapV2::GetInterfaceVersion()\n")));
       
   170 	EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: CEapMsChapV2::GetInterfaceVersion()\n"));
       
   171 
   156 	return KInterfaceVersion; 
   172 	return KInterfaceVersion; 
   157 }
   173 }
   158 
   174 
   159 
   175 // ----------------------------------------------------------
   160 // ----------------------------------------------------------
   176 
   161 TInt CEapMsChapV2::InvokeUiL()
   177 CEapTypeInfo* CEapMsChapV2::GetInfoL()
   162 {
   178 {
   163 	TInt buttonId(0);
   179 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapMsChapV2::GetInfoL()\n")));
   164    	
   180 	EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: CEapMsChapV2::GetInfoL()\n"));
   165 #ifdef USE_EAP_EXPANDED_TYPES
   181 
   166 
       
   167 	CEapMsChapV2UiConnection uiConn(iIndexType, iIndex, 
       
   168 									iTunnelingType.get_vendor_type(), iEapType.get_vendor_type());
       
   169 	
       
   170 #else
       
   171 
       
   172    	CEapMsChapV2UiConnection uiConn(iIndexType, iIndex, iTunnelingType, (TInt)iEapType);
       
   173 
       
   174 #endif //#ifdef USE_EAP_EXPANDED_TYPES
       
   175 	
       
   176 	CEapMsChapV2Ui* ui = CEapMsChapV2Ui::NewL(&uiConn);
       
   177 	CleanupStack::PushL(ui);
       
   178 	buttonId = ui->InvokeUiL();
       
   179 	CleanupStack::PopAndDestroy(ui);
       
   180 	return buttonId;
       
   181 }
       
   182 
       
   183 
       
   184 // ----------------------------------------------------------
       
   185 CEapTypeInfo* CEapMsChapV2::GetInfoLC()
       
   186 {
       
   187 	CEapTypeInfo* info = new(ELeave) CEapTypeInfo(
   182 	CEapTypeInfo* info = new(ELeave) CEapTypeInfo(
   188 		(TDesC&)KReleaseDate, 
   183 		(TDesC&)KReleaseDate, 
   189 		(TDesC&)KEapTypeVersion,
   184 		(TDesC&)KEapTypeVersion,
   190 		(TDesC&)KManufacturer);
   185 		(TDesC&)KManufacturer);
   191 
   186 
   192 	CleanupStack::PushL(info);
       
   193 	return info;
   187 	return info;
   194 }
   188 }
   195 
   189 
   196 // ----------------------------------------------------------
   190 // ----------------------------------------------------------
   197 
   191 
   198 void CEapMsChapV2::DeleteConfigurationL()
   192 void CEapMsChapV2::DeleteConfigurationL()
   199 {		
   193 {		
       
   194 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapMsChapV2::DeleteConfigurationL()\n")));
       
   195 	EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: CEapMsChapV2::DeleteConfigurationL()\n"));
       
   196 
   200 	EapMsChapV2DbUtils::DeleteConfigurationL(iIndexType, iIndex, iTunnelingType);
   197 	EapMsChapV2DbUtils::DeleteConfigurationL(iIndexType, iIndex, iTunnelingType);
   201 }
   198 }
   202 
   199 
   203 // ----------------------------------------------------------
   200 // ----------------------------------------------------------
   204 
   201 
   205 void CEapMsChapV2::SetTunnelingType(const TInt aTunnelingType)
   202 void CEapMsChapV2::SetTunnelingType(const TEapExpandedType aTunnelingType)
   206 {
   203     {
   207 #ifdef USE_EAP_EXPANDED_TYPES
   204 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapMsChapV2::SetTunnelingType()\n")));
   208 
   205 	EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: CEapMsChapV2::SetTunnelingType()\n"));
   209 	// Vendor id is eap_type_vendor_id_ietf always in this plugin.
   206 
   210 	iTunnelingType.set_eap_type_values(eap_type_vendor_id_ietf, aTunnelingType);
   207     EAP_TRACE_DATA_DEBUG_SYMBIAN(
   211 
   208         (EAPL("CEapMsChapV2::SetTunnelingType - tunneling type"),
   212 #else
   209         aTunnelingType.GetValue().Ptr(), aTunnelingType.GetValue().Length()));
   213 
   210     
   214 	iTunnelingType = static_cast<eap_type_value_e>(aTunnelingType);
   211     eap_type_value_e aInternalType;
   215 
   212     
   216 #endif //#ifdef USE_EAP_EXPANDED_TYPES
   213     TInt err = CEapConversion::ConvertExpandedEAPTypeToInternalType(
   217 }
   214             &aTunnelingType,
   218 
   215             &aInternalType);
   219 // ----------------------------------------------------------
   216     
       
   217     iTunnelingType = aInternalType;
       
   218     
       
   219     }
       
   220 
       
   221 // ----------------------------------------------------------
       
   222 
   220 void CEapMsChapV2::SetIndexL(
   223 void CEapMsChapV2::SetIndexL(
   221 		const TIndexType aIndexType, 
   224 		const TIndexType aIndexType, 
   222 		const TInt aIndex)
   225 		const TInt aIndex)
   223 {		
   226 {		
       
   227 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapMsChapV2::SetIndexL()\n")));
       
   228 	EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: CEapMsChapV2::SetIndexL()\n"));
       
   229 
   224 	// First delete the target configuration
   230 	// First delete the target configuration
   225 	TIndexType tmpIndexType = iIndexType;
   231 	TIndexType tmpIndexType = iIndexType;
   226 	TInt tmpIndex = iIndex;
   232 	TInt tmpIndex = iIndex;
   227 		
   233 		
   228 	iIndexType = aIndexType;
   234 	iIndexType = aIndexType;
   236 	iIndexType = tmpIndexType;
   242 	iIndexType = tmpIndexType;
   237 	iIndex = tmpIndex;
   243 	iIndex = tmpIndex;
   238 
   244 
   239 	RDbNamedDatabase db;
   245 	RDbNamedDatabase db;
   240 
   246 
   241 	RDbs session;
   247 	RFs session;
   242 	
       
   243 	EapMsChapV2DbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
       
   244 	
   248 	
   245 	CleanupClosePushL(session);
   249 	CleanupClosePushL(session);
   246 	CleanupClosePushL(db);
   250 	CleanupClosePushL(db);
   247 		
   251 	TInt error = session.Connect();
       
   252 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapMsChapV2::SetIndexL(): - session.Connect(), error=%d\n"), error));
       
   253 	User::LeaveIfError(error);
       
   254 
       
   255 	EapMsChapV2DbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
       
   256 
   248 	EapMsChapV2DbUtils::SetIndexL(
   257 	EapMsChapV2DbUtils::SetIndexL(
   249 		db, 
   258 		db, 
   250 		iIndexType, 
   259 		iIndexType, 
   251 		iIndex, 
   260 		iIndex, 
   252 		iTunnelingType, 
   261 		iTunnelingType, 
   255 		iTunnelingType);
   264 		iTunnelingType);
   256 	
   265 	
   257 	iIndexType = aIndexType;
   266 	iIndexType = aIndexType;
   258 	iIndex = aIndex;
   267 	iIndex = aIndex;
   259 
   268 
   260 	CleanupStack::PopAndDestroy(2); // db
   269 	db.Close();
       
   270 	session.Close();
       
   271 
       
   272 	CleanupStack::PopAndDestroy(&db);
       
   273 	CleanupStack::PopAndDestroy(&session);
   261 }
   274 }
   262 
   275 
   263 void CEapMsChapV2::SetConfigurationL(const EAPSettings& aSettings)
   276 void CEapMsChapV2::SetConfigurationL(const EAPSettings& aSettings)
   264 {
   277 {
       
   278 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapMsChapV2::SetConfigurationL()\n")));
       
   279 	EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: CEapMsChapV2::SetConfigurationL()\n"));
       
   280 
   265 	RDbNamedDatabase db;
   281 	RDbNamedDatabase db;
   266 
   282 
   267 	RDbs session;	
   283 	RFs session;
   268 	
   284 	
       
   285 	CleanupClosePushL(session);
       
   286 	CleanupClosePushL(db);
       
   287 	TInt error = session.Connect();
       
   288 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapMsChapV2::SetConfigurationL(): - session.Connect(), error=%d\n"), error));
       
   289 	User::LeaveIfError(error);
       
   290 
   269 	// This also creates the IAP entry if it doesn't exist
   291 	// This also creates the IAP entry if it doesn't exist
   270 	EapMsChapV2DbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
   292 	EapMsChapV2DbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
   271 	
       
   272 	CleanupClosePushL(session);
       
   273 	CleanupClosePushL(db);
       
   274 
   293 
   275 	EapMsChapV2DbUtils::SetConfigurationL(
   294 	EapMsChapV2DbUtils::SetConfigurationL(
   276 		db,
   295 		db,
   277 		aSettings, 
   296 		aSettings, 
   278 		iIndexType,
   297 		iIndexType,
   279 		iIndex,
   298 		iIndex,
   280 		iTunnelingType);		
   299 		iTunnelingType);		
   281 		
   300 		
   282 	CleanupStack::PopAndDestroy(2); // db, session
   301 	db.Close();
       
   302 	session.Close();
       
   303 
       
   304 	CleanupStack::PopAndDestroy(&db);
       
   305 	CleanupStack::PopAndDestroy(&session);
   283 }
   306 }
   284 
   307 
   285 void CEapMsChapV2::GetConfigurationL(EAPSettings& aSettings)
   308 void CEapMsChapV2::GetConfigurationL(EAPSettings& aSettings)
   286 {
   309 {
       
   310 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapMsChapV2::GetConfigurationL()\n")));
       
   311 	EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: CEapMsChapV2::GetConfigurationL()\n"));
       
   312 
   287 	RDbNamedDatabase db;
   313 	RDbNamedDatabase db;
   288 
   314 
   289 	RDbs session;
   315 	RFs session;
   290 	
   316 	
       
   317 	CleanupClosePushL(session);
       
   318 	CleanupClosePushL(db);
       
   319 	TInt error = session.Connect();
       
   320 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapMsChapV2::GetConfigurationL(): - session.Connect(), error=%d\n"), error));
       
   321 	User::LeaveIfError(error);
       
   322 
   291 	// This also creates the IAP entry if it doesn't exist
   323 	// This also creates the IAP entry if it doesn't exist
   292 	EapMsChapV2DbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
   324 	EapMsChapV2DbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
   293 	
       
   294 	CleanupClosePushL(session);
       
   295 	CleanupClosePushL(db);
       
   296 
   325 
   297 	EapMsChapV2DbUtils::GetConfigurationL(
   326 	EapMsChapV2DbUtils::GetConfigurationL(
   298 		db,
   327 		db,
   299 		aSettings, 
   328 		aSettings, 
   300 		iIndexType,
   329 		iIndexType,
   301 		iIndex,
   330 		iIndex,
   302 		iTunnelingType);
   331 		iTunnelingType);
       
   332 
       
   333 	// Plain-MsChapv2 and EAP-MsChapv2 uses the same database.
       
   334 	// Here we set the correct authentication method to read settings.
       
   335 	error = CEapConversion::ConvertInternalTypeToExpandedEAPType(
       
   336 		&iEapType,
       
   337 		&aSettings.iEAPExpandedType);
       
   338 	if (error != KErrNone)
       
   339 	{
       
   340 		User::Leave(error);
       
   341 	}
   303 		
   342 		
   304 	CleanupStack::PopAndDestroy(2); // db, session
   343 	db.Close();
       
   344 	session.Close();
       
   345 
       
   346 	CleanupStack::PopAndDestroy(&db);
       
   347 	CleanupStack::PopAndDestroy(&session);
   305 }
   348 }
   306 
   349 
   307 void CEapMsChapV2::CopySettingsL(
   350 void CEapMsChapV2::CopySettingsL(
   308 	const TIndexType aDestinationIndexType,
   351 	const TIndexType aDestinationIndexType,
   309 	const TInt aDestinationIndex)
   352 	const TInt aDestinationIndex)
   310 {
   353 {
       
   354 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapMsChapV2::CopySettingsL()\n")));
       
   355 	EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: CEapMsChapV2::CopySettingsL()\n"));
       
   356 
   311 	// First delete the target configuration
   357 	// First delete the target configuration
   312 	TIndexType tmpIndexType = iIndexType;
   358 	TIndexType tmpIndexType = iIndexType;
   313 	TInt tmpIndex = iIndex;
   359 	TInt tmpIndex = iIndex;
   314 		
   360 		
   315 	iIndexType = aDestinationIndexType;
   361 	iIndexType = aDestinationIndexType;
   323 	iIndexType = tmpIndexType;
   369 	iIndexType = tmpIndexType;
   324 	iIndex = tmpIndex;
   370 	iIndex = tmpIndex;
   325 
   371 
   326 	RDbNamedDatabase db;
   372 	RDbNamedDatabase db;
   327 
   373 
   328 	RDbs session;
   374 	RFs session;
   329 	
       
   330 	EapMsChapV2DbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
       
   331 	
   375 	
   332 	CleanupClosePushL(session);
   376 	CleanupClosePushL(session);
   333 	CleanupClosePushL(db);
   377 	CleanupClosePushL(db);
   334 		
   378 	TInt error = session.Connect();
       
   379 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapMsChapV2::CopySettingsL(): - session.Connect(), error=%d\n"), error));
       
   380 	User::LeaveIfError(error);
       
   381 
       
   382 	EapMsChapV2DbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
       
   383 
   335 	EapMsChapV2DbUtils::CopySettingsL(
   384 	EapMsChapV2DbUtils::CopySettingsL(
   336 		db,
   385 		db,
   337 		iIndexType,
   386 		iIndexType,
   338 		iIndex,
   387 		iIndex,
   339 		iTunnelingType, 
   388 		iTunnelingType, 
   340 		aDestinationIndexType, 
   389 		aDestinationIndexType, 
   341 		aDestinationIndex, 
   390 		aDestinationIndex, 
   342 		iTunnelingType);
   391 		iTunnelingType);
   343 		
   392 		
   344 	CleanupStack::PopAndDestroy(2); // db
   393 	db.Close();
       
   394 	session.Close();
       
   395 
       
   396 	CleanupStack::PopAndDestroy(&db);
       
   397 	CleanupStack::PopAndDestroy(&session);
   345 	
   398 	
   346 }
   399 }
   347 
   400 
   348 // End of file
   401 // End of file