eapol/eapol_framework/eapol_symbian/am/type/mschapv2/symbian/plugin/src/EapMsChapV2.cpp
changeset 26 9abfd4f00d37
parent 22 093cf0757204
child 34 ad1f037f1ac2
equal deleted inserted replaced
25:e03a3db4489e 26:9abfd4f00d37
    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.4 %
    19 * %version: 28 %
    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 "EapConversion.h"
       
    41 #include "EapTraceSymbian.h"
    40 
    42 
    41 // LOCAL CONSTANTS
    43 // LOCAL CONSTANTS
    42 
    44 
    43 // The version number of this interface.
    45 // The version number of this interface.
    44 const TUint KInterfaceVersion = 1;
    46 const TUint KInterfaceVersion = 1;
    45 
    47 
    46 
    48 
    47 // ================= MEMBER FUNCTIONS =======================
    49 // ================= MEMBER FUNCTIONS =======================
    48 
    50 
    49 
    51 
    50 CEapMsChapV2::CEapMsChapV2(const TIndexType aIndexType,	
    52 CEapMsChapV2::CEapMsChapV2(
    51 				 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)
    52 : iIndexType(aIndexType)
    56 : iIndexType(aIndexType)
    53 , iIndex(aIndex)
    57 , iIndex(aIndex)
    54 , iTunnelingType(eap_type_none)
    58 , iTunnelingType(eap_type_none)
    55 , iEapType(aEapType)
    59 , iEapType(aEapType)
    56 {
    60 {
       
    61 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapMsChapV2::CEapMsChapV2()\n")));
       
    62 	EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: CEapMsChapV2::CEapMsChapV2()\n"));
       
    63 
    57 }
    64 }
    58 
    65 
    59 // ----------------------------------------------------------
    66 // ----------------------------------------------------------
    60 
    67 
    61 CEapMsChapV2* CEapMsChapV2::NewL(SIapInfo *aIapInfo)
    68 CEapMsChapV2* CEapMsChapV2::NewL(SIapInfo *aIapInfo)
    62 {
    69 {
    63 	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);
    64 }
    74 }
    65 
    75 
    66 // ----------------------------------------------------------
    76 // ----------------------------------------------------------
    67 
    77 
    68 CEapMsChapV2* CEapMsChapV2::NewPlainMSCHAPv2L(SIapInfo *aIapInfo)
    78 CEapMsChapV2* CEapMsChapV2::NewPlainMSCHAPv2L(SIapInfo *aIapInfo)
    69 {
    79 {
       
    80 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapMsChapV2::NewPlainMSCHAPv2L()\n")));
       
    81 	EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: CEapMsChapV2::NewPlainMSCHAPv2L()\n"));
       
    82 
    70 	return new (ELeave) CEapMsChapV2(
    83 	return new (ELeave) CEapMsChapV2(
    71 		aIapInfo->indexType,
    84 		aIapInfo->indexType,
    72 		aIapInfo->index,
    85 		aIapInfo->index,
    73 #if defined(USE_EAP_EXPANDED_TYPES)
       
    74 		eap_expanded_type_ttls_plain_mschapv2.get_type()
    86 		eap_expanded_type_ttls_plain_mschapv2.get_type()
    75 #else
       
    76 		eap_type_plain_mschapv2
       
    77 #endif //#if defined(USE_EAP_EXPANDED_TYPES)
       
    78 		);
    87 		);
    79 }
    88 }
    80 
    89 
    81 
    90 
    82 // ----------------------------------------------------------
    91 // ----------------------------------------------------------
    83 
    92 
    84 CEapMsChapV2::~CEapMsChapV2()
    93 CEapMsChapV2::~CEapMsChapV2()
    85 {
    94 {
       
    95 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapMsChapV2::~CEapMsChapV2()\n")));
       
    96 	EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: CEapMsChapV2::~CEapMsChapV2()\n"));
       
    97 
    86 }
    98 }
    87 
    99 
    88 // ----------------------------------------------------------
   100 // ----------------------------------------------------------
    89 
   101 
    90 #ifdef USE_EAP_SIMPLE_CONFIG
   102 #ifdef USE_EAP_SIMPLE_CONFIG
   102 											const bool is_client_when_true,
   114 											const bool is_client_when_true,
   103 											const eap_am_network_id_c * const receive_network_id)
   115 											const eap_am_network_id_c * const receive_network_id)
   104 	
   116 	
   105 #endif // #ifdef USE_EAP_SIMPLE_CONFIG
   117 #endif // #ifdef USE_EAP_SIMPLE_CONFIG
   106 {
   118 {
       
   119 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapMsChapV2::GetStackInterfaceL()\n")));
       
   120 	EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: CEapMsChapV2::GetStackInterfaceL()\n"));
       
   121 
   107 	// Create AM
   122 	// Create AM
   108 	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(
   109 		aTools,
   124 		aTools,
   110 		aPartner,
   125 		aPartner,
   111 		iIndexType,
   126 		iIndexType,
   149 
   164 
   150 // ----------------------------------------------------------
   165 // ----------------------------------------------------------
   151 
   166 
   152 TUint CEapMsChapV2::GetInterfaceVersion() 
   167 TUint CEapMsChapV2::GetInterfaceVersion() 
   153 { 
   168 { 
       
   169 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapMsChapV2::GetInterfaceVersion()\n")));
       
   170 	EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: CEapMsChapV2::GetInterfaceVersion()\n"));
       
   171 
   154 	return KInterfaceVersion; 
   172 	return KInterfaceVersion; 
   155 }
   173 }
   156 
   174 
   157 
   175 // ----------------------------------------------------------
   158 // ----------------------------------------------------------
   176 
   159 TInt CEapMsChapV2::InvokeUiL()
   177 CEapTypeInfo* CEapMsChapV2::GetInfoL()
   160 {
   178 {
   161 	TInt buttonId(0);
   179 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapMsChapV2::GetInfoL()\n")));
   162 
   180 	EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: CEapMsChapV2::GetInfoL()\n"));
   163 	return buttonId;
   181 
   164 }
       
   165 
       
   166 
       
   167 // ----------------------------------------------------------
       
   168 CEapTypeInfo* CEapMsChapV2::GetInfoLC()
       
   169 {
       
   170 	CEapTypeInfo* info = new(ELeave) CEapTypeInfo(
   182 	CEapTypeInfo* info = new(ELeave) CEapTypeInfo(
   171 		(TDesC&)KReleaseDate, 
   183 		(TDesC&)KReleaseDate, 
   172 		(TDesC&)KEapTypeVersion,
   184 		(TDesC&)KEapTypeVersion,
   173 		(TDesC&)KManufacturer);
   185 		(TDesC&)KManufacturer);
   174 
   186 
   175 	CleanupStack::PushL(info);
       
   176 	return info;
   187 	return info;
   177 }
   188 }
   178 
   189 
   179 // ----------------------------------------------------------
   190 // ----------------------------------------------------------
   180 
   191 
   181 void CEapMsChapV2::DeleteConfigurationL()
   192 void CEapMsChapV2::DeleteConfigurationL()
   182 {		
   193 {		
       
   194 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapMsChapV2::DeleteConfigurationL()\n")));
       
   195 	EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: CEapMsChapV2::DeleteConfigurationL()\n"));
       
   196 
   183 	EapMsChapV2DbUtils::DeleteConfigurationL(iIndexType, iIndex, iTunnelingType);
   197 	EapMsChapV2DbUtils::DeleteConfigurationL(iIndexType, iIndex, iTunnelingType);
   184 }
   198 }
   185 
   199 
   186 // ----------------------------------------------------------
   200 // ----------------------------------------------------------
   187 
   201 
   188 void CEapMsChapV2::SetTunnelingType(const TInt aTunnelingType)
   202 void CEapMsChapV2::SetTunnelingType(const TEapExpandedType aTunnelingType)
   189 {
   203     {
   190 #ifdef USE_EAP_EXPANDED_TYPES
   204 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapMsChapV2::SetTunnelingType()\n")));
   191 
   205 	EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: CEapMsChapV2::SetTunnelingType()\n"));
   192 	// Vendor id is eap_type_vendor_id_ietf always in this plugin.
   206 
   193 	iTunnelingType.set_eap_type_values(eap_type_vendor_id_ietf, aTunnelingType);
   207     EAP_TRACE_DATA_DEBUG_SYMBIAN(
   194 
   208         (EAPL("CEapMsChapV2::SetTunnelingType - tunneling type"),
   195 #else
   209         aTunnelingType.GetValue().Ptr(), aTunnelingType.GetValue().Length()));
   196 
   210     
   197 	iTunnelingType = static_cast<eap_type_value_e>(aTunnelingType);
   211     eap_type_value_e aInternalType;
   198 
   212     
   199 #endif //#ifdef USE_EAP_EXPANDED_TYPES
   213     TInt err = CEapConversion::ConvertExpandedEAPTypeToInternalType(
   200 }
   214             &aTunnelingType,
   201 
   215             &aInternalType);
   202 // ----------------------------------------------------------
   216     
       
   217     iTunnelingType = aInternalType;
       
   218     
       
   219     }
       
   220 
       
   221 // ----------------------------------------------------------
       
   222 
   203 void CEapMsChapV2::SetIndexL(
   223 void CEapMsChapV2::SetIndexL(
   204 		const TIndexType aIndexType, 
   224 		const TIndexType aIndexType, 
   205 		const TInt aIndex)
   225 		const TInt aIndex)
   206 {		
   226 {		
       
   227 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapMsChapV2::SetIndexL()\n")));
       
   228 	EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: CEapMsChapV2::SetIndexL()\n"));
       
   229 
   207 	// First delete the target configuration
   230 	// First delete the target configuration
   208 	TIndexType tmpIndexType = iIndexType;
   231 	TIndexType tmpIndexType = iIndexType;
   209 	TInt tmpIndex = iIndex;
   232 	TInt tmpIndex = iIndex;
   210 		
   233 		
   211 	iIndexType = aIndexType;
   234 	iIndexType = aIndexType;
   219 	iIndexType = tmpIndexType;
   242 	iIndexType = tmpIndexType;
   220 	iIndex = tmpIndex;
   243 	iIndex = tmpIndex;
   221 
   244 
   222 	RDbNamedDatabase db;
   245 	RDbNamedDatabase db;
   223 
   246 
   224 	RDbs session;
   247 	RFs session;
   225 	
   248 	
   226 	EapMsChapV2DbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
   249 	EapMsChapV2DbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
   227 	
   250 	
   228 	CleanupClosePushL(session);
   251 	CleanupClosePushL(session);
   229 	CleanupClosePushL(db);
   252 	CleanupClosePushL(db);
   238 		iTunnelingType);
   261 		iTunnelingType);
   239 	
   262 	
   240 	iIndexType = aIndexType;
   263 	iIndexType = aIndexType;
   241 	iIndex = aIndex;
   264 	iIndex = aIndex;
   242 
   265 
   243 	CleanupStack::PopAndDestroy(2); // db
   266 	CleanupStack::PopAndDestroy(&db);
       
   267 	CleanupStack::PopAndDestroy(&session);
   244 }
   268 }
   245 
   269 
   246 void CEapMsChapV2::SetConfigurationL(const EAPSettings& aSettings)
   270 void CEapMsChapV2::SetConfigurationL(const EAPSettings& aSettings)
   247 {
   271 {
       
   272 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapMsChapV2::SetConfigurationL()\n")));
       
   273 	EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: CEapMsChapV2::SetConfigurationL()\n"));
       
   274 
   248 	RDbNamedDatabase db;
   275 	RDbNamedDatabase db;
   249 
   276 
   250 	RDbs session;	
   277 	RFs session;
   251 	
   278 	
   252 	// This also creates the IAP entry if it doesn't exist
   279 	// This also creates the IAP entry if it doesn't exist
   253 	EapMsChapV2DbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
   280 	EapMsChapV2DbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
   254 	
   281 	
   255 	CleanupClosePushL(session);
   282 	CleanupClosePushL(session);
   260 		aSettings, 
   287 		aSettings, 
   261 		iIndexType,
   288 		iIndexType,
   262 		iIndex,
   289 		iIndex,
   263 		iTunnelingType);		
   290 		iTunnelingType);		
   264 		
   291 		
   265 	CleanupStack::PopAndDestroy(2); // db, session
   292 	CleanupStack::PopAndDestroy(&db);
       
   293 	CleanupStack::PopAndDestroy(&session);
   266 }
   294 }
   267 
   295 
   268 void CEapMsChapV2::GetConfigurationL(EAPSettings& aSettings)
   296 void CEapMsChapV2::GetConfigurationL(EAPSettings& aSettings)
   269 {
   297 {
       
   298 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapMsChapV2::GetConfigurationL()\n")));
       
   299 	EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: CEapMsChapV2::GetConfigurationL()\n"));
       
   300 
   270 	RDbNamedDatabase db;
   301 	RDbNamedDatabase db;
   271 
   302 
   272 	RDbs session;
   303 	RFs session;
   273 	
   304 	
   274 	// This also creates the IAP entry if it doesn't exist
   305 	// This also creates the IAP entry if it doesn't exist
   275 	EapMsChapV2DbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
   306 	EapMsChapV2DbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
   276 	
   307 	
   277 	CleanupClosePushL(session);
   308 	CleanupClosePushL(session);
   282 		aSettings, 
   313 		aSettings, 
   283 		iIndexType,
   314 		iIndexType,
   284 		iIndex,
   315 		iIndex,
   285 		iTunnelingType);
   316 		iTunnelingType);
   286 		
   317 		
   287 	CleanupStack::PopAndDestroy(2); // db, session
   318 	CleanupStack::PopAndDestroy(&db);
       
   319 	CleanupStack::PopAndDestroy(&session);
   288 }
   320 }
   289 
   321 
   290 void CEapMsChapV2::CopySettingsL(
   322 void CEapMsChapV2::CopySettingsL(
   291 	const TIndexType aDestinationIndexType,
   323 	const TIndexType aDestinationIndexType,
   292 	const TInt aDestinationIndex)
   324 	const TInt aDestinationIndex)
   293 {
   325 {
       
   326 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapMsChapV2::CopySettingsL()\n")));
       
   327 	EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: CEapMsChapV2::CopySettingsL()\n"));
       
   328 
   294 	// First delete the target configuration
   329 	// First delete the target configuration
   295 	TIndexType tmpIndexType = iIndexType;
   330 	TIndexType tmpIndexType = iIndexType;
   296 	TInt tmpIndex = iIndex;
   331 	TInt tmpIndex = iIndex;
   297 		
   332 		
   298 	iIndexType = aDestinationIndexType;
   333 	iIndexType = aDestinationIndexType;
   306 	iIndexType = tmpIndexType;
   341 	iIndexType = tmpIndexType;
   307 	iIndex = tmpIndex;
   342 	iIndex = tmpIndex;
   308 
   343 
   309 	RDbNamedDatabase db;
   344 	RDbNamedDatabase db;
   310 
   345 
   311 	RDbs session;
   346 	RFs session;
   312 	
   347 	
   313 	EapMsChapV2DbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
   348 	EapMsChapV2DbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
   314 	
   349 	
   315 	CleanupClosePushL(session);
   350 	CleanupClosePushL(session);
   316 	CleanupClosePushL(db);
   351 	CleanupClosePushL(db);
   322 		iTunnelingType, 
   357 		iTunnelingType, 
   323 		aDestinationIndexType, 
   358 		aDestinationIndexType, 
   324 		aDestinationIndex, 
   359 		aDestinationIndex, 
   325 		iTunnelingType);
   360 		iTunnelingType);
   326 		
   361 		
   327 	CleanupStack::PopAndDestroy(2); // db
   362 	CleanupStack::PopAndDestroy(&db);
       
   363 	CleanupStack::PopAndDestroy(&session);
   328 	
   364 	
   329 }
   365 }
   330 
   366 
   331 // End of file
   367 // End of file