eapol/eapol_framework/eapol_symbian/am/type/tls_peap/symbian/plugin/src/EapTlsPeap.cpp
changeset 0 c8830336c852
child 2 1c7bc153c08e
equal deleted inserted replaced
-1:000000000000 0:c8830336c852
       
     1 /*
       
     2 * Copyright (c) 2001-2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  EAP and WLAN authentication protocols.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // This is enumeration of EAPOL source code.
       
    20 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
       
    21 	#undef EAP_FILE_NUMBER_ENUM
       
    22 	#define EAP_FILE_NUMBER_ENUM 417 
       
    23 	#undef EAP_FILE_NUMBER_DATE 
       
    24 	#define EAP_FILE_NUMBER_DATE 1127594498 
       
    25 #endif //#if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
       
    26 
       
    27 
       
    28 // INCLUDE FILES
       
    29 
       
    30 #include "EapTlsPeap.h"
       
    31 #include "eap_base_type.h"
       
    32 #include "EapTlsPeapGlobal.h"
       
    33 #include <EapTypeInfo.h>
       
    34 
       
    35 #include <EapTlsPeapUiConnection.h>
       
    36 #include <EapTlsUi.h>
       
    37 #include <EapPeapUi.h>
       
    38 #if defined(USE_TTLS_EAP_TYPE)
       
    39 	#include <EapTtlsUi.h>
       
    40 #endif
       
    41 
       
    42 #if defined(USE_FAST_EAP_TYPE)
       
    43 #include <eapfastui.h>
       
    44 #include "tls_application_eap_fast.h"
       
    45 #endif 
       
    46 
       
    47 #include "eap_am_type_tls_peap_symbian.h"
       
    48 #include "eap_type_tls_peap.h"
       
    49 #include "tls_record.h"
       
    50 #include "eap_core.h"
       
    51 #include "tls_application_eap_core.h"
       
    52 #include "eap_am_tools_symbian.h"
       
    53 #include "eap_am_trace_symbian.h"
       
    54 
       
    55 #ifdef USE_PAC_STORE
       
    56 #include "pac_store_db_symbian.h"
       
    57 #endif
       
    58 
       
    59 #include <papui.h>
       
    60 
       
    61 // LOCAL CONSTANTS
       
    62 
       
    63 // The version number of this interface. At the moment this version number is
       
    64 // common for all three plug-in interfaces.
       
    65 const TUint KInterfaceVersion = 1;
       
    66 
       
    67 
       
    68 // ================= MEMBER FUNCTIONS =======================
       
    69 
       
    70 
       
    71 CEapTlsPeap::CEapTlsPeap(const TIndexType aIndexType,	
       
    72 				 const TInt aIndex,
       
    73 				 const eap_type_value_e aEapType)
       
    74 : iIndexType(aIndexType)
       
    75 , iIndex(aIndex)
       
    76 , iEapType(aEapType)
       
    77 , iTunnelingType(eap_type_none)
       
    78 {
       
    79 
       
    80 #ifdef USE_EAP_EXPANDED_TYPES
       
    81 
       
    82 	ASSERT(iEapType.get_vendor_id() == eap_type_vendor_id_ietf);
       
    83 	ASSERT(iTunnelingType.get_vendor_id() == eap_type_vendor_id_ietf);
       
    84 
       
    85 #endif //#ifdef USE_EAP_EXPANDED_TYPES
       
    86 
       
    87 }
       
    88 
       
    89 // ----------------------------------------------------------
       
    90 
       
    91 CEapTlsPeap* CEapTlsPeap::NewTlsL(SIapInfo *aIapInfo)
       
    92 {
       
    93 	return new (ELeave) CEapTlsPeap(aIapInfo->indexType, aIapInfo->index, eap_type_tls);
       
    94 }
       
    95 
       
    96 // ----------------------------------------------------------
       
    97 
       
    98 CEapTlsPeap* CEapTlsPeap::NewPeapL(SIapInfo *aIapInfo)
       
    99 {
       
   100 	return new (ELeave) CEapTlsPeap(aIapInfo->indexType, aIapInfo->index, eap_type_peap);
       
   101 }
       
   102 
       
   103 // ----------------------------------------------------------
       
   104 
       
   105 #if defined(USE_TTLS_EAP_TYPE)
       
   106 
       
   107 CEapTlsPeap* CEapTlsPeap::NewTtlsL(SIapInfo *aIapInfo)
       
   108 {
       
   109 	return new (ELeave) CEapTlsPeap(aIapInfo->indexType, aIapInfo->index, eap_type_ttls);
       
   110 }
       
   111 
       
   112 #endif // #if defined(USE_TTLS_EAP_TYPE)
       
   113 
       
   114 // ----------------------------------------------------------
       
   115 
       
   116 
       
   117 // ---------------------------------------------------------
       
   118 // CEapTtlsPapActive::NewTtlsPapL()
       
   119 // ---------------------------------------------------------
       
   120 // 
       
   121 
       
   122 CEapTlsPeap* CEapTlsPeap::NewTtlsPapL( SIapInfo* aIapInfo )
       
   123     {
       
   124 	return new (ELeave) CEapTlsPeap(
       
   125 		aIapInfo->indexType, aIapInfo->index, eap_type_ttls_plain_pap );    
       
   126     }
       
   127 
       
   128 
       
   129 // ----------------------------------------------------------
       
   130 
       
   131 #if defined(USE_FAST_EAP_TYPE)
       
   132 
       
   133 CEapTlsPeap* CEapTlsPeap::NewFastL(SIapInfo *aIapInfo)
       
   134 {
       
   135 	return new (ELeave) CEapTlsPeap(aIapInfo->indexType, aIapInfo->index, eap_type_fast);
       
   136 }
       
   137 
       
   138 #endif // #if defined(USE_FAST_EAP_TYPE)
       
   139 
       
   140 // ----------------------------------------------------------
       
   141 
       
   142 CEapTlsPeap::~CEapTlsPeap()
       
   143 {
       
   144 	iEapArray.ResetAndDestroy();
       
   145 }
       
   146 
       
   147 // ----------------------------------------------------------
       
   148 
       
   149 #ifdef USE_EAP_SIMPLE_CONFIG
       
   150 
       
   151 eap_base_type_c* CEapTlsPeap::GetStackInterfaceL(abs_eap_am_tools_c* const aTools, 
       
   152 											   abs_eap_base_type_c* const aPartner,
       
   153 											   const bool is_client_when_true,
       
   154 											   const eap_am_network_id_c * const receive_network_id,
       
   155 											   abs_eap_configuration_if_c * const /*configuration_if*/)
       
   156 	
       
   157 #else
       
   158 	
       
   159 eap_base_type_c* CEapTlsPeap::GetStackInterfaceL(abs_eap_am_tools_c* const aTools, 
       
   160 											abs_eap_base_type_c* const aPartner,
       
   161 											const bool is_client_when_true,
       
   162 											const eap_am_network_id_c * const receive_network_id)
       
   163 	
       
   164 #endif // #ifdef USE_EAP_SIMPLE_CONFIG
       
   165 {
       
   166 #ifdef USE_EAP_EXPANDED_TYPES
       
   167 	
       
   168 	EAP_TRACE_DEBUG_SYMBIAN(
       
   169 		(_L("CEapTlsPeap::GetStackInterfaceL -Start- iIndexType=%d, iIndex=%d, Tunneling vendor type=%d, Eap vendor type=%d \n"),
       
   170 		iIndexType,iIndex, iTunnelingType.get_vendor_type(), iEapType.get_vendor_type()));
       
   171 	
       
   172 #else
       
   173 	
       
   174 	EAP_TRACE_DEBUG_SYMBIAN(
       
   175 		(_L("CEapTlsPeap::GetStackInterfaceL -Start- iIndexType=%d, iIndex=%d, iTunnelingType=%d, iEapType=%d \n"),
       
   176 		iIndexType, iIndex, iTunnelingType, iEapType));
       
   177 	
       
   178 #endif //#ifdef USE_EAP_EXPANDED_TYPES
       
   179 
       
   180 	// Create adaptation layer
       
   181 	eap_am_type_tls_peap_symbian_c* amEapType;
       
   182 	eap_base_type_c* type;
       
   183 	tls_record_c* record;
       
   184 
       
   185 	amEapType = eap_am_type_tls_peap_symbian_c::NewL(
       
   186 		aTools,
       
   187 		aPartner,
       
   188 		iIndexType,
       
   189 		iIndex,
       
   190 		iTunnelingType,
       
   191 		iEapType,
       
   192 		is_client_when_true,
       
   193 		receive_network_id);
       
   194 	if (amEapType->get_is_valid() == false)
       
   195 	{
       
   196 		amEapType->shutdown();
       
   197 		delete amEapType;
       
   198 		User::Leave(KErrGeneral);
       
   199 	}
       
   200 	
       
   201 	EAP_TRACE_DEBUG_SYMBIAN(
       
   202 		(_L("CEapTlsPeap::GetStackInterfaceL - created eap_am_type_tls_peap_symbian_c \n")));
       
   203 
       
   204 	if (iEapType == eap_type_tls)
       
   205 	{
       
   206 		// TLS
       
   207 		record = new tls_record_c(
       
   208 			aTools,
       
   209 			amEapType,
       
   210 			false,
       
   211 			0,
       
   212 			false,
       
   213 			is_client_when_true,
       
   214 			iEapType,
       
   215 			receive_network_id);
       
   216 		if (record == 0)
       
   217 		{
       
   218 			// Out of memory
       
   219 			amEapType->shutdown();
       
   220 			delete amEapType;
       
   221 			User::Leave(KErrNoMemory);
       
   222 		}
       
   223 		else if (record->get_is_valid() == false)
       
   224 		{
       
   225 			record->shutdown();
       
   226 			delete record;
       
   227 			amEapType->shutdown();
       
   228 			delete amEapType;
       
   229 			User::Leave(KErrGeneral);
       
   230 		}	
       
   231 	}
       
   232 	else
       
   233 	{
       
   234 		// PEAP, TTLS and FAST.
       
   235 	
       
   236 		eap_core_c* eap_core = new eap_core_c(
       
   237 			aTools,
       
   238 			0,
       
   239 			is_client_when_true,
       
   240 			receive_network_id,
       
   241 			true);
       
   242 		if (eap_core == 0)
       
   243 		{
       
   244 			// Out of memory
       
   245 			amEapType->shutdown();
       
   246 			delete amEapType;
       
   247 			User::Leave(KErrNoMemory);
       
   248 		} 
       
   249 		else if (eap_core->get_is_valid() == false)
       
   250 		{
       
   251 			// Out of memory
       
   252 			eap_core->shutdown();
       
   253 			delete eap_core;
       
   254 			amEapType->shutdown();
       
   255 			delete amEapType;
       
   256 			User::Leave(KErrGeneral);
       
   257 		}
       
   258 		
       
   259 		EAP_TRACE_DEBUG_SYMBIAN(
       
   260 			(_L("CEapTlsPeap::GetStackInterfaceL - created eap_core_c \n")));
       
   261 		
       
   262 		tls_base_application_c* application;
       
   263 		
       
   264 #if defined (USE_FAST_EAP_TYPE)		
       
   265 		if(iEapType == eap_type_fast)
       
   266 		{
       
   267 			application = new tls_application_eap_fast_c(
       
   268 				aTools,
       
   269 				eap_core,
       
   270 				true,
       
   271 				is_client_when_true,
       
   272 				iEapType,
       
   273 				receive_network_id,
       
   274 				amEapType);
       
   275 			
       
   276 			EAP_TRACE_DEBUG_SYMBIAN(
       
   277 				(_L("CEapTlsPeap::GetStackInterfaceL - created tls_application_eap_fast_c \n")));			
       
   278 		}
       
   279 		else		
       
   280 #endif // End: #if defined (USE_FAST_EAP_TYPE)
       
   281 		{			
       
   282 			application = new tls_application_eap_core_c(
       
   283 				aTools,
       
   284 				eap_core,
       
   285 				true,
       
   286 				is_client_when_true,
       
   287 				iEapType,
       
   288 				receive_network_id);
       
   289 			
       
   290 			EAP_TRACE_DEBUG_SYMBIAN(
       
   291 				(_L("CEapTlsPeap::GetStackInterfaceL - created tls_application_eap_core_c \n")));	
       
   292 		}
       
   293 		if (application == 0)
       
   294 		{
       
   295 			// Out of memory
       
   296 			eap_core->shutdown();
       
   297 			delete eap_core;
       
   298 			amEapType->shutdown();
       
   299 			delete amEapType;
       
   300 			User::Leave(KErrNoMemory);			
       
   301 		} 
       
   302 		else if (application->get_is_valid() == false)
       
   303 		{
       
   304 			// Out of memory
       
   305 			// application takes care of eap_core_c deletion
       
   306 			application->shutdown();
       
   307 			delete application;
       
   308 			amEapType->shutdown();
       
   309 			delete amEapType;
       
   310 			User::Leave(KErrGeneral);
       
   311 		}
       
   312 
       
   313 		EAP_TRACE_DEBUG_SYMBIAN(
       
   314 			(_L("CEapTlsPeap::GetStackInterfaceL - application is valid \n")));	
       
   315 		
       
   316 		record = new tls_record_c(
       
   317 			aTools,
       
   318 			amEapType,
       
   319 			false,
       
   320 			application,
       
   321 			true,
       
   322 			is_client_when_true,
       
   323 			iEapType,
       
   324 			receive_network_id);		
       
   325 		if (record == 0)
       
   326 		{
       
   327 			// Out of memory
       
   328 			// application takes care of eap_core_c deletion
       
   329 			application->shutdown();
       
   330 			delete application;
       
   331 			amEapType->shutdown();
       
   332 			delete amEapType;
       
   333 			User::Leave(KErrGeneral);		
       
   334 		}
       
   335 		else if (record->get_is_valid() == false)
       
   336 		{
       
   337 			// Out of memory
       
   338 			// record takes care of application deletion
       
   339 			record->shutdown();
       
   340 			delete record;
       
   341 			amEapType->shutdown();
       
   342 			delete amEapType;
       
   343 			User::Leave(KErrGeneral);					
       
   344 		}	
       
   345 
       
   346 	}	
       
   347 
       
   348 	EAP_TRACE_DEBUG_SYMBIAN(
       
   349 		(_L("CEapTlsPeap::GetStackInterfaceL - Creating the OS independent portion - eap_type_tls_peap_c \n")));
       
   350 	
       
   351 	// Create the OS independent portion
       
   352 	
       
   353 	type = new eap_type_tls_peap_c(
       
   354 		aTools, 
       
   355 		aPartner, 
       
   356 		amEapType, 
       
   357 		true, 
       
   358 		record, 
       
   359 		true, 
       
   360 		is_client_when_true, 
       
   361 		iEapType, 
       
   362 		receive_network_id);	
       
   363 	if (type == 0)
       
   364 	{
       
   365 		// Out of memory
       
   366 		// record takes care of application deletion
       
   367 		record->shutdown();
       
   368 		delete record;
       
   369 		amEapType->shutdown();
       
   370 		delete amEapType;
       
   371 		User::Leave(KErrNoMemory);							
       
   372 	}
       
   373 	else if(type->get_is_valid() == false)
       
   374 	{
       
   375 		type->shutdown();
       
   376 		// type deletes all
       
   377 		delete type;
       
   378 		User::Leave(KErrGeneral);		
       
   379 	}
       
   380 	
       
   381 	return type;
       
   382 }
       
   383 
       
   384 // ----------------------------------------------------------
       
   385 TInt CEapTlsPeap::InvokeUiL()
       
   386 {
       
   387 	TInt buttonId(0);
       
   388 
       
   389 #ifdef USE_EAP_EXPANDED_TYPES
       
   390 
       
   391 	EAP_TRACE_DEBUG_SYMBIAN(
       
   392 		(_L("CEapTlsPeap::InvokeUiL -Start- iIndexType=%d, iIndex=%d, Tunneling vendor type=%d, Eap vendor type=%d \n"),
       
   393 		iIndexType,iIndex, iTunnelingType.get_vendor_type(), iEapType.get_vendor_type()));
       
   394 
       
   395 	CEapTlsPeapUiConnection uiConn(iIndexType, iIndex, 
       
   396 									iTunnelingType.get_vendor_type(), iEapType.get_vendor_type());
       
   397 	
       
   398 #else
       
   399 
       
   400 	EAP_TRACE_DEBUG_SYMBIAN(
       
   401 		(_L("CEapTlsPeap::InvokeUiL -Start- iIndexType=%d, iIndex=%d, iTunnelingType=%d, iEapType=%d \n"),
       
   402 		iIndexType, iIndex, iTunnelingType, iEapType));
       
   403 
       
   404     CEapTlsPeapUiConnection uiConn(iIndexType, iIndex, iTunnelingType, iEapType);
       
   405 
       
   406 #endif //#ifdef USE_EAP_EXPANDED_TYPES
       
   407 
       
   408 	EAP_TRACE_DEBUG_SYMBIAN(
       
   409 			(_L("CEapTlsPeap::InvokeUiL Created UI connection \n")));
       
   410 
       
   411 #ifdef USE_EAP_EXPANDED_TYPES
       
   412 
       
   413 	switch (iEapType.get_vendor_type())
       
   414 	
       
   415 #else
       
   416 
       
   417 	switch (iEapType)
       
   418 
       
   419 #endif //#ifdef USE_EAP_EXPANDED_TYPES
       
   420 	{
       
   421 	case eap_type_tls:
       
   422 		{
       
   423 			CEapTlsUi* tls_ui = CEapTlsUi::NewL(&uiConn);	
       
   424 			CleanupStack::PushL(tls_ui);
       
   425 			buttonId = tls_ui->InvokeUiL();
       
   426 			CleanupStack::PopAndDestroy(tls_ui);	
       
   427 		}
       
   428 		break;
       
   429 
       
   430 	case eap_type_peap:
       
   431 		{
       
   432 			CEapPeapUi* peap_ui = CEapPeapUi::NewL(&uiConn, iIndexType, iIndex);
       
   433 			CleanupStack::PushL(peap_ui);
       
   434 			buttonId = peap_ui->InvokeUiL();
       
   435 			CleanupStack::PopAndDestroy(peap_ui);
       
   436 		}
       
   437 		break;
       
   438 
       
   439 #if defined (USE_TTLS_EAP_TYPE)
       
   440 	case eap_type_ttls:
       
   441 		{
       
   442 			CEapTtlsUi* ttls_ui = CEapTtlsUi::NewL(&uiConn, iIndexType, iIndex);
       
   443 			CleanupStack::PushL(ttls_ui);
       
   444 			buttonId = ttls_ui->InvokeUiL();
       
   445 			CleanupStack::PopAndDestroy(ttls_ui);
       
   446 		}
       
   447 		break;
       
   448 #endif
       
   449 
       
   450 #if defined (USE_FAST_EAP_TYPE)
       
   451 	case eap_type_fast:
       
   452 		{
       
   453 			CEapFastUi* fast_ui = CEapFastUi::NewL(&uiConn, iIndexType, iIndex);
       
   454 			CleanupStack::PushL(fast_ui);
       
   455 			buttonId = fast_ui->InvokeUiL();
       
   456 			CleanupStack::PopAndDestroy(fast_ui);
       
   457 		}
       
   458 		break;
       
   459 #endif
       
   460 		
       
   461 	case eap_type_ttls_plain_pap:
       
   462 	    {
       
   463 	        CPapUi* papUi = CPapUi::NewL( &uiConn );
       
   464 	        CleanupStack::PushL( papUi );
       
   465 	        buttonId = papUi->InvokeUiL();
       
   466 	        CleanupStack::PopAndDestroy( papUi );
       
   467 	    }
       
   468 	    break;
       
   469 
       
   470 	default:
       
   471 		// Should never happen
       
   472 		User::Leave(KErrArgument);
       
   473 	}
       
   474 	
       
   475 	EAP_TRACE_DEBUG_SYMBIAN(
       
   476 			(_L("CEapTlsPeap::InvokeUiL -End-\n")));
       
   477 	
       
   478 	return buttonId;
       
   479 }
       
   480 // ----------------------------------------------------------
       
   481 CEapTypeInfo* CEapTlsPeap::GetInfoLC()
       
   482 {
       
   483 	CEapTypeInfo* info = new(ELeave) CEapTypeInfo((TDesC&)KReleaseDate, (TDesC&)KEapTypeVersion,
       
   484 												   (TDesC&)KManufacturer);
       
   485 	CleanupStack::PushL(info);
       
   486 	return info;
       
   487 }
       
   488 
       
   489 // ----------------------------------------------------------
       
   490 
       
   491 void CEapTlsPeap::DeleteConfigurationL()
       
   492 {
       
   493 #ifdef USE_EAP_EXPANDED_TYPES
       
   494 	
       
   495 	TUint aTunnelingVendorType = iTunnelingType.get_vendor_type();
       
   496 	TUint aEapVendorType = iEapType.get_vendor_type();
       
   497 	
       
   498 #else
       
   499 	
       
   500 	TUint aTunnelingVendorType = static_cast<TUint>(iTunnelingType);
       
   501 	TUint aEapVendorType = static_cast<TUint>(iEapType);
       
   502 	
       
   503 #endif //#ifdef USE_EAP_EXPANDED_TYPES
       
   504 
       
   505 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeap::DeleteConfigurationL:Start:iIndexType=%d,iIndex=%d,TunnelingType=%d,EapType=%d"),
       
   506 			iIndexType, iIndex, aTunnelingVendorType, aEapVendorType));
       
   507 
       
   508     EapTlsPeapUtils::DeleteConfigurationL(iIndexType, iIndex, iTunnelingType, iEapType);
       
   509 	
       
   510 	// For Encapsulated types
       
   511 	
       
   512 	if (iEapType == eap_type_peap
       
   513 		|| iEapType == eap_type_ttls
       
   514 
       
   515 #ifdef USE_FAST_EAP_TYPE
       
   516 		|| iEapType == eap_type_fast
       
   517 #endif		
       
   518 
       
   519 		|| iEapType == eap_type_ttls_plain_pap
       
   520 
       
   521 
       
   522 	) 
       
   523 	{
       
   524 		iEapArray.ResetAndDestroy();
       
   525 		REComSession::ListImplementationsL(KEapTypeInterfaceUid, iEapArray);
       
   526 			
       
   527 		for (TInt i = 0; i < iEapArray.Count(); i++)
       
   528 		{
       
   529 			if ((iEapType == eap_type_peap && !CEapType::IsDisallowedInsidePEAP(*iEapArray[i])) 
       
   530 				|| (iEapType == eap_type_ttls && !CEapType::IsDisallowedInsideTTLS(*iEapArray[i]))
       
   531 				
       
   532 #ifdef USE_FAST_EAP_TYPE
       
   533 				|| (iEapType == eap_type_fast && !CEapType::IsDisallowedInsidePEAP(*iEapArray[i]))
       
   534 #endif						
       
   535 
       
   536 				|| (iEapType == eap_type_ttls_plain_pap && !CEapType::IsDisallowedInsidePEAP(*iEapArray[i]))
       
   537 					
       
   538 
       
   539 			)
       
   540 			{
       
   541 				// Deleting the encapsulated EAP type configurations possible inside PEAP, TTLS and FAST.
       
   542 
       
   543 				EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeap::DeleteConfigurationL: Deleting encapsulated types for EAP type=%d"),
       
   544 						aEapVendorType));
       
   545 			
       
   546 				CEapType* eapType;
       
   547 			
       
   548 #ifdef USE_EAP_EXPANDED_TYPES		
       
   549 			
       
   550 				TBuf8<KExpandedEAPTypeSize> expandedCue = iEapArray[i]->DataType();
       
   551 			
       
   552 				EAP_TRACE_DATA_DEBUG_SYMBIAN(("CEapTlsPeap::DeleteConfigurationL: Expanded cue:",
       
   553 				expandedCue.Ptr(), expandedCue.Size()));
       
   554 			
       
   555 				eapType = CEapType::NewL(expandedCue, iIndexType, iIndex);
       
   556 				
       
   557 				if(eapType == NULL)
       
   558 				{
       
   559 					EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeap::DeleteConfigurationL: Ecom Error - No specified Expanded EAP plugin")) );
       
   560 					User::Leave(KErrNotFound);
       
   561 				}
       
   562 				
       
   563 				eapType->SetTunnelingType(iEapType.get_vendor_type());						
       
   564 
       
   565 #ifdef USE_FAST_EAP_TYPE
       
   566 				
       
   567 				// This IAP is deleted. Update the PAC store cleanup table if this IAP is 
       
   568 				// for EAP-FAST.
       
   569 				
       
   570 				if(iEapType == eap_type_fast)
       
   571 				{
       
   572 				
       
   573 #ifdef USE_PAC_STORE
       
   574 				
       
   575 					TRAPD(error, UpdatePacStoreCleanupTableL(iIndexType, iIndex, iTunnelingType));
       
   576 					
       
   577 					if(error != KErrNone)
       
   578 					{
       
   579 						EAP_TRACE_DEBUG_SYMBIAN(
       
   580 						(_L("CEapTlsPeap::DeleteConfigurationL: WARNING: LEAVE: from UpdatePacStoreCleanupTableL, error=%d"),
       
   581 						error));			
       
   582 					}
       
   583 					else
       
   584 					{
       
   585 						EAP_TRACE_DEBUG_SYMBIAN(
       
   586 						(_L("CEapTlsPeap::DeleteConfigurationL: successfully done UpdatePacStoreCleanupTableL")));						
       
   587 					}
       
   588 					
       
   589 #endif // #ifdef USE_PAC_STORE
       
   590 					
       
   591 				}
       
   592 				
       
   593 #endif // #ifdef USE_FAST_EAP_TYPE
       
   594 #endif // USE_EAP_EXPANDED_TYPES		
       
   595 	
       
   596 
       
   597 #ifndef USE_EAP_EXPANDED_TYPES		
       
   598 //#else // For normal EAP types.
       
   599 			
       
   600 				TBuf8<3> cue = iEapArray[i]->DataType();
       
   601 
       
   602 				EAP_TRACE_DATA_DEBUG_SYMBIAN(("CEapTlsPeap::DeleteConfigurationL: cue:",
       
   603 						cue.Ptr(), cue.Size()));
       
   604 
       
   605 				eapType = CEapType::NewL(cue, iIndexType, iIndex);	
       
   606 
       
   607 				if(eapType == NULL)
       
   608 					{
       
   609 						EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeap::DeleteConfigurationL: Ecom Error - No specified EAP plugin")) );
       
   610 						User::Leave(KErrNotFound);
       
   611 					}
       
   612 				
       
   613 				eapType->SetTunnelingType(iEapType);					
       
   614 
       
   615 #endif //#ifndef USE_EAP_EXPANDED_TYPES
       
   616 								
       
   617 				EAP_TRACE_DEBUG_SYMBIAN(
       
   618 						(_L("CEapTlsPeap::DeleteConfigurationL: PushL(...)")));	
       
   619 				
       
   620 				CleanupStack::PushL(eapType);
       
   621 				
       
   622 				EAP_TRACE_DEBUG_SYMBIAN(
       
   623 						(_L("CEapTlsPeap::DeleteConfigurationL: DeleteConfigurationL()")));	
       
   624 				
       
   625 				eapType->DeleteConfigurationL();
       
   626 				
       
   627 				CleanupStack::PopAndDestroy();			
       
   628 			}
       
   629 		}	
       
   630 	} // End: 	if (iEapType == eap_type_peap
       
   631 	
       
   632 
       
   633 }
       
   634 
       
   635 // ----------------------------------------------------------
       
   636 
       
   637 TUint CEapTlsPeap::GetInterfaceVersion()
       
   638 {
       
   639 	return KInterfaceVersion;
       
   640 }
       
   641 
       
   642 // ----------------------------------------------------------
       
   643 
       
   644 void CEapTlsPeap::SetTunnelingType(const TInt aTunnelingType)
       
   645 {
       
   646 #ifdef USE_EAP_EXPANDED_TYPES
       
   647 
       
   648 	// Vendor id is eap_type_vendor_id_ietf always in this plugin.
       
   649 	iTunnelingType.set_eap_type_values(eap_type_vendor_id_ietf, aTunnelingType);
       
   650 
       
   651 #else
       
   652 
       
   653 	iTunnelingType = static_cast<eap_type_value_e>(aTunnelingType);
       
   654 
       
   655 #endif //#ifdef USE_EAP_EXPANDED_TYPES
       
   656 }
       
   657 
       
   658 // ----------------------------------------------------------
       
   659 void CEapTlsPeap::SetIndexL(
       
   660 		const TIndexType aIndexType, 
       
   661 		const TInt aIndex)
       
   662 {
       
   663 #ifdef USE_EAP_EXPANDED_TYPES
       
   664 	
       
   665 	TUint aTunnelingVendorType = iTunnelingType.get_vendor_type();
       
   666 	TUint aEapVendorType = iEapType.get_vendor_type();
       
   667 	
       
   668 #else
       
   669 	
       
   670 	TUint aTunnelingVendorType = static_cast<TUint>(iTunnelingType);
       
   671 	TUint aEapVendorType = static_cast<TUint>(iEapType);
       
   672 	
       
   673 #endif //#ifdef USE_EAP_EXPANDED_TYPES
       
   674 
       
   675 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeap::SetIndexL:Start: Old: iIndexType=%d,iIndex=%d,TunnelingType=%d,EapType=%d"),
       
   676 			iIndexType, iIndex, aTunnelingVendorType, aEapVendorType));
       
   677 	
       
   678 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeap::SetIndexL: New: IndexType=%d,Index=%d"),
       
   679 			aIndexType, aIndex));
       
   680 	
       
   681 	// First delete the target configuration
       
   682 	TIndexType tmpIndexType = iIndexType;
       
   683 	TInt tmpIndex = iIndex;
       
   684 			
       
   685 	iIndexType = aIndexType;
       
   686 	iIndex = aIndex;
       
   687 
       
   688 	TInt err(KErrNone);
       
   689 	TRAP(err, DeleteConfigurationL());
       
   690 	// Ignore error on purpose
       
   691 	
       
   692 	// Return the indices
       
   693 	iIndexType = tmpIndexType;
       
   694 	iIndex = tmpIndex;
       
   695 	
       
   696 	RDbNamedDatabase db;
       
   697 
       
   698 	RDbs session;
       
   699 
       
   700     EapTlsPeapUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType, iEapType);
       
   701 	
       
   702 	CleanupClosePushL(session);
       
   703 	CleanupClosePushL(db);
       
   704 	
       
   705 	TPtrC settings;
       
   706 	TPtrC usercerts;
       
   707 	TPtrC cacerts;
       
   708 	TPtrC ciphersuites;
       
   709 
       
   710 #ifdef USE_FAST_EAP_TYPE
       
   711 	TPtrC fastSpecialSettings;
       
   712 #endif
       
   713 	
       
   714 #ifdef USE_EAP_EXPANDED_TYPES
       
   715 
       
   716 	switch (iEapType.get_vendor_type())
       
   717 	
       
   718 #else
       
   719 
       
   720 	switch (iEapType)
       
   721 
       
   722 #endif //#ifdef USE_EAP_EXPANDED_TYPES
       
   723 	{
       
   724 	case eap_type_tls:
       
   725 		{
       
   726 			settings.Set(KTlsDatabaseTableName);
       
   727 			usercerts.Set(KTlsAllowedUserCertsDatabaseTableName);
       
   728 			cacerts.Set(KTlsAllowedCACertsDatabaseTableName);
       
   729 			ciphersuites.Set(KTlsAllowedCipherSuitesDatabaseTableName);
       
   730 		}
       
   731 		break;
       
   732 
       
   733 	case eap_type_peap:
       
   734 		{
       
   735 			settings.Set(KPeapDatabaseTableName);
       
   736 			usercerts.Set(KPeapAllowedUserCertsDatabaseTableName);
       
   737 			cacerts.Set(KPeapAllowedCACertsDatabaseTableName);
       
   738 			ciphersuites.Set(KPeapAllowedCipherSuitesDatabaseTableName);
       
   739 		}
       
   740 		break;
       
   741 
       
   742 #if defined (USE_TTLS_EAP_TYPE)
       
   743 	case eap_type_ttls:
       
   744 		{
       
   745 			settings.Set(KTtlsDatabaseTableName);
       
   746 			usercerts.Set(KTtlsAllowedUserCertsDatabaseTableName);
       
   747 			cacerts.Set(KTtlsAllowedCACertsDatabaseTableName);
       
   748 			ciphersuites.Set(KTtlsAllowedCipherSuitesDatabaseTableName);
       
   749 		}
       
   750 		break;
       
   751 #endif
       
   752 
       
   753 #ifdef USE_FAST_EAP_TYPE
       
   754 	case eap_type_fast:
       
   755 		{
       
   756 			settings.Set(KFastGeneralSettingsDBTableName); // This is general settings for FAST.
       
   757 			fastSpecialSettings.Set(KFastSpecialSettingsDBTableName);
       
   758 			
       
   759 			usercerts.Set(KFastAllowedUserCertsDatabaseTableName);
       
   760 			cacerts.Set(KFastAllowedCACertsDatabaseTableName);
       
   761 			ciphersuites.Set(KFastAllowedCipherSuitesDatabaseTableName);			
       
   762 		}
       
   763 		break;
       
   764 #endif		
       
   765 
       
   766 	case eap_type_ttls_plain_pap:
       
   767 		{
       
   768 			settings.Set(KTtlsDatabaseTableName);
       
   769 			usercerts.Set(KTtlsAllowedUserCertsDatabaseTableName);
       
   770 			cacerts.Set(KTtlsAllowedCACertsDatabaseTableName);
       
   771 			ciphersuites.Set(KTtlsAllowedCipherSuitesDatabaseTableName);
       
   772 		}
       
   773 		break;
       
   774 		
       
   775 	default:
       
   776 		// Should never happen
       
   777 		User::Leave(KErrArgument);
       
   778 	}	
       
   779 	
       
   780 	EAP_TRACE_DEBUG_SYMBIAN(
       
   781 		(_L("EapTlsPeapUtils::SetIndexL - Setting indices to the tables\n")));
       
   782 	
       
   783 	// For the settings db. For EAP-FAST this is the general settings.
       
   784 	EapTlsPeapUtils::SetIndexL(
       
   785 		db, 
       
   786 		settings,
       
   787 		iIndexType, 
       
   788 		iIndex, 
       
   789 		iTunnelingType, 
       
   790 		aIndexType, 
       
   791 		aIndex, 
       
   792 		iTunnelingType);
       
   793 
       
   794 	EAP_TRACE_DEBUG_SYMBIAN(
       
   795 		(_L("EapTlsPeapUtils::SetIndexL - Set the index to (general) settings table\n")));
       
   796 	
       
   797 	// For the USER certificate db.		
       
   798 	EapTlsPeapUtils::SetIndexL(
       
   799 		db, 
       
   800 		usercerts,
       
   801 		iIndexType, 
       
   802 		iIndex, 
       
   803 		iTunnelingType, 
       
   804 		aIndexType, 
       
   805 		aIndex, 
       
   806 		iTunnelingType);		
       
   807 
       
   808 	EAP_TRACE_DEBUG_SYMBIAN(
       
   809 		(_L("EapTlsPeapUtils::SetIndexL - Set the index to USER cert table\n")));
       
   810 	
       
   811 	// For the CA certificate db.
       
   812 	EapTlsPeapUtils::SetIndexL(
       
   813 		db, 
       
   814 		cacerts,
       
   815 		iIndexType, 
       
   816 		iIndex, 
       
   817 		iTunnelingType, 
       
   818 		aIndexType, 
       
   819 		aIndex, 
       
   820 		iTunnelingType);
       
   821 
       
   822 	EAP_TRACE_DEBUG_SYMBIAN(
       
   823 		(_L("EapTlsPeapUtils::SetIndexL - Set the index to CA cert table\n")));
       
   824 	
       
   825 	// For the ciphersuites db.		
       
   826 	EapTlsPeapUtils::SetIndexL(
       
   827 		db, 
       
   828 		ciphersuites,
       
   829 		iIndexType, 
       
   830 		iIndex, 
       
   831 		iTunnelingType, 
       
   832 		aIndexType, 
       
   833 		aIndex, 
       
   834 		iTunnelingType);		
       
   835 
       
   836 	EAP_TRACE_DEBUG_SYMBIAN(
       
   837 		(_L("EapTlsPeapUtils::SetIndexL - Set the index to Cipher suite table\n")));
       
   838 	
       
   839 #ifdef USE_FAST_EAP_TYPE
       
   840 	// This special settings is only for EAP-FAST
       
   841 	if(iEapType == eap_type_fast)
       
   842 	{
       
   843 		EapTlsPeapUtils::SetIndexL(
       
   844 			db, 
       
   845 			fastSpecialSettings,
       
   846 			iIndexType, 
       
   847 			iIndex, 
       
   848 			iTunnelingType, 
       
   849 			aIndexType, 
       
   850 			aIndex, 
       
   851 			iTunnelingType);
       
   852 		
       
   853 		EAP_TRACE_DEBUG_SYMBIAN(
       
   854 			(_L("EapTlsPeapUtils::SetIndexL - Set the index to EAP-FAST Special settings table\n")));		
       
   855 		
       
   856 	}// End: if(iEapType == eap_type_fast)
       
   857 	
       
   858 #endif // End: #ifdef USE_FAST_EAP_TYPE
       
   859 		
       
   860 	db.Close();
       
   861 	CleanupStack::PopAndDestroy(2); // db, session.
       
   862 	
       
   863 	//////// Encapsulated types
       
   864 
       
   865 	if (iEapType == eap_type_peap
       
   866 		|| iEapType == eap_type_ttls
       
   867 
       
   868 #ifdef USE_FAST_EAP_TYPE
       
   869 		|| iEapType == eap_type_fast
       
   870 #endif				
       
   871 
       
   872 		|| iEapType == eap_type_ttls_plain_pap
       
   873 			
       
   874 
       
   875 	)
       
   876 	{
       
   877 		iEapArray.ResetAndDestroy();
       
   878 		REComSession::ListImplementationsL(KEapTypeInterfaceUid, iEapArray);
       
   879 				
       
   880 		for (TInt i = 0; i < iEapArray.Count(); i++)
       
   881 		{
       
   882 			if ((iEapType == eap_type_peap && !CEapType::IsDisallowedInsidePEAP(*iEapArray[i])) 
       
   883 				|| (iEapType == eap_type_ttls && !CEapType::IsDisallowedInsideTTLS(*iEapArray[i]))
       
   884 
       
   885 #ifdef USE_FAST_EAP_TYPE
       
   886 				|| (iEapType == eap_type_fast && !CEapType::IsDisallowedInsidePEAP(*iEapArray[i]))
       
   887 #endif										
       
   888 
       
   889 				|| (iEapType == eap_type_ttls_plain_pap && !CEapType::IsDisallowedInsidePEAP(*iEapArray[i]))
       
   890 										
       
   891 
       
   892 			)
       
   893 			{
       
   894 				// Setting the  index for encapsulated EAP type configurations possible 
       
   895 				// inside PEAP, TTLS and FAST.
       
   896 
       
   897 				EAP_TRACE_DEBUG_SYMBIAN(
       
   898 		    		(_L("EapTlsPeapUtils::SetIndexL - Setting the index to encapsulated EAP types\n")));	
       
   899 				
       
   900 				CEapType* eapType;
       
   901 			
       
   902 #ifdef USE_EAP_EXPANDED_TYPES		
       
   903 			
       
   904 				TBuf8<KExpandedEAPTypeSize> expandedCue = iEapArray[i]->DataType();
       
   905 			
       
   906 				EAP_TRACE_DATA_DEBUG_SYMBIAN(("CEapTlsPeap::SetIndexL: Expanded cue:",
       
   907 				expandedCue.Ptr(), expandedCue.Size()));
       
   908 			
       
   909 				eapType = CEapType::NewL(expandedCue, iIndexType, iIndex);
       
   910 
       
   911 				if(eapType == NULL)
       
   912 				{
       
   913 					EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeap::SetIndexL: Ecom Error - No specified Expanded EAP plugin")) );
       
   914 					User::Leave(KErrNotFound);
       
   915 				}				
       
   916 				
       
   917 				eapType->SetTunnelingType(iEapType.get_vendor_type());						
       
   918 
       
   919 #else // For normal EAP types.
       
   920 			
       
   921 				TBuf8<3> cue = iEapArray[i]->DataType();
       
   922 			
       
   923 				eapType = CEapType::NewL(cue, iIndexType, iIndex);	
       
   924 				
       
   925 				eapType->SetTunnelingType(iEapType);					
       
   926 
       
   927 #endif //#ifdef USE_EAP_EXPANDED_TYPES
       
   928 
       
   929 				CleanupStack::PushL(eapType);
       
   930 				
       
   931 				eapType->SetIndexL(aIndexType, aIndex);
       
   932 				
       
   933 				EAP_TRACE_DEBUG_SYMBIAN(
       
   934 		    		(_L("EapTlsPeapUtils::SetIndexL - Set the index to encapsulated EAP types\n")));	
       
   935 								
       
   936 				CleanupStack::PopAndDestroy();
       
   937 			}
       
   938 		}	
       
   939 	}
       
   940 	iIndexType = aIndexType;
       
   941 	iIndex = aIndex;
       
   942 	
       
   943 	EAP_TRACE_DEBUG_SYMBIAN(
       
   944 		(_L("EapTlsPeapUtils::SetIndexL - End\n")));		
       
   945 }
       
   946 
       
   947 void CEapTlsPeap::SetConfigurationL(const EAPSettings& aSettings)
       
   948 {
       
   949 	RDbNamedDatabase db;
       
   950 
       
   951 	RDbs session;	
       
   952 	
       
   953 	// This also creates the IAP entry if it doesn't exist
       
   954 	EapTlsPeapUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType, iEapType);
       
   955 	
       
   956 	CleanupClosePushL(session);
       
   957 	CleanupClosePushL(db);
       
   958 
       
   959 	EapTlsPeapUtils::SetConfigurationL(
       
   960 		db,
       
   961 		aSettings, 
       
   962 		iIndexType,
       
   963 		iIndex,
       
   964 		iTunnelingType,
       
   965 		iEapType);		
       
   966 		
       
   967 	CleanupStack::PopAndDestroy(2); // db, session
       
   968 }
       
   969 
       
   970 void CEapTlsPeap::GetConfigurationL(EAPSettings& aSettings)
       
   971 {
       
   972 	RDbNamedDatabase db;
       
   973 
       
   974 	RDbs session;
       
   975 	
       
   976 	// This also creates the IAP entry if it doesn't exist
       
   977 	EapTlsPeapUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType, iEapType);
       
   978 	
       
   979 	CleanupClosePushL(session);
       
   980 	CleanupClosePushL(db);
       
   981 
       
   982 	EapTlsPeapUtils::GetConfigurationL(
       
   983 		db,
       
   984 		aSettings, 
       
   985 		iIndexType,
       
   986 		iIndex,
       
   987 		iTunnelingType,
       
   988 		iEapType);
       
   989 		
       
   990 	db.Close();
       
   991 	CleanupStack::PopAndDestroy(2); // db, session
       
   992 }
       
   993 
       
   994 void CEapTlsPeap::CopySettingsL(
       
   995 	const TIndexType aDestinationIndexType,
       
   996 	const TInt aDestinationIndex)
       
   997 {
       
   998 #ifdef USE_EAP_EXPANDED_TYPES
       
   999 	
       
  1000 	TUint aTunnelingVendorType = iTunnelingType.get_vendor_type();
       
  1001 	TUint aEapVendorType = iEapType.get_vendor_type();
       
  1002 	
       
  1003 #else
       
  1004 	
       
  1005 	TUint aTunnelingVendorType = static_cast<TUint>(iTunnelingType);
       
  1006 	TUint aEapVendorType = static_cast<TUint>(iEapType);
       
  1007 	
       
  1008 #endif //#ifdef USE_EAP_EXPANDED_TYPES
       
  1009 
       
  1010 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeap::CopySettingsL:Start:iIndexType=%d,iIndex=%d,TunnelingType=%d,EapType=%d"),
       
  1011 			iIndexType, iIndex, aTunnelingVendorType, aEapVendorType));
       
  1012 	
       
  1013 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeap::CopySettingsL: DestinationIndexType=%d,DestinationIndex=%d"),
       
  1014 			aDestinationIndexType, aDestinationIndex));
       
  1015 
       
  1016 	// First delete the target configuration
       
  1017 	TIndexType tmpIndexType = iIndexType;
       
  1018 	TInt tmpIndex = iIndex;
       
  1019 			
       
  1020 	iIndexType = aDestinationIndexType;
       
  1021 	iIndex = aDestinationIndex;
       
  1022 	
       
  1023 	// Return the indices
       
  1024 	iIndexType = tmpIndexType;
       
  1025 	iIndex = tmpIndex;
       
  1026 	
       
  1027 	RDbNamedDatabase db;
       
  1028 
       
  1029 	RDbs session;
       
  1030 	
       
  1031 	EapTlsPeapUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType, iEapType);
       
  1032 	
       
  1033 	CleanupClosePushL(session);
       
  1034 	CleanupClosePushL(db);
       
  1035 	
       
  1036 	TPtrC settings;
       
  1037 	TPtrC usercerts;
       
  1038 	TPtrC cacerts;
       
  1039 	TPtrC ciphersuites;
       
  1040 
       
  1041 #ifdef USE_FAST_EAP_TYPE
       
  1042 	TPtrC fastSpecialSettings;
       
  1043 #endif
       
  1044 	
       
  1045 #ifdef USE_EAP_EXPANDED_TYPES
       
  1046 
       
  1047 	switch (iEapType.get_vendor_type())
       
  1048 	
       
  1049 #else
       
  1050 
       
  1051 	switch (iEapType)
       
  1052 
       
  1053 #endif //#ifdef USE_EAP_EXPANDED_TYPES
       
  1054 	{
       
  1055 	case eap_type_tls:
       
  1056 		{
       
  1057 			settings.Set(KTlsDatabaseTableName);
       
  1058 			usercerts.Set(KTlsAllowedUserCertsDatabaseTableName);
       
  1059 			cacerts.Set(KTlsAllowedCACertsDatabaseTableName);
       
  1060 			ciphersuites.Set(KTlsAllowedCipherSuitesDatabaseTableName);
       
  1061 		}
       
  1062 		break;
       
  1063 
       
  1064 	case eap_type_peap:
       
  1065 		{
       
  1066 			settings.Set(KPeapDatabaseTableName);
       
  1067 			usercerts.Set(KPeapAllowedUserCertsDatabaseTableName);
       
  1068 			cacerts.Set(KPeapAllowedCACertsDatabaseTableName);
       
  1069 			ciphersuites.Set(KPeapAllowedCipherSuitesDatabaseTableName);
       
  1070 		}
       
  1071 		break;
       
  1072 
       
  1073 #if defined (USE_TTLS_EAP_TYPE)
       
  1074 	case eap_type_ttls:
       
  1075 		{
       
  1076 			settings.Set(KTtlsDatabaseTableName);
       
  1077 			usercerts.Set(KTtlsAllowedUserCertsDatabaseTableName);
       
  1078 			cacerts.Set(KTtlsAllowedCACertsDatabaseTableName);
       
  1079 			ciphersuites.Set(KTtlsAllowedCipherSuitesDatabaseTableName);
       
  1080 		}
       
  1081 		break;
       
  1082 #endif
       
  1083 
       
  1084 	case eap_type_ttls_plain_pap:
       
  1085 		{
       
  1086 			settings.Set(KTtlsDatabaseTableName);
       
  1087 			usercerts.Set(KTtlsAllowedUserCertsDatabaseTableName);
       
  1088 			cacerts.Set(KTtlsAllowedCACertsDatabaseTableName);
       
  1089 			ciphersuites.Set(KTtlsAllowedCipherSuitesDatabaseTableName);
       
  1090 		}
       
  1091 		break;
       
  1092 		
       
  1093 #ifdef USE_FAST_EAP_TYPE
       
  1094 	case eap_type_fast:
       
  1095 		{
       
  1096 			settings.Set(KFastGeneralSettingsDBTableName); // This is general settings for FAST.
       
  1097 			fastSpecialSettings.Set(KFastSpecialSettingsDBTableName);
       
  1098 			
       
  1099 			usercerts.Set(KFastAllowedUserCertsDatabaseTableName);
       
  1100 			cacerts.Set(KFastAllowedCACertsDatabaseTableName);
       
  1101 			ciphersuites.Set(KFastAllowedCipherSuitesDatabaseTableName);			
       
  1102 		}
       
  1103 		break;
       
  1104 #endif		
       
  1105 
       
  1106 	default:
       
  1107 		// Should never happen
       
  1108 		User::Leave(KErrArgument);
       
  1109 	}	
       
  1110 
       
  1111 	EAP_TRACE_DEBUG_SYMBIAN(
       
  1112 		(_L("EapTlsPeapUtils::CopySettingsL - Copying the tables\n")));
       
  1113 	
       
  1114 	// For the settings db. For EAP-FAST this is the general settings.
       
  1115 	EapTlsPeapUtils::CopySettingsL(
       
  1116 		db, 
       
  1117 		settings,
       
  1118 		iIndexType, 
       
  1119 		iIndex, 
       
  1120 		iTunnelingType, 
       
  1121 		aDestinationIndexType, 
       
  1122 		aDestinationIndex, 
       
  1123 		iTunnelingType);
       
  1124 
       
  1125 	EAP_TRACE_DEBUG_SYMBIAN(
       
  1126 		(_L("EapTlsPeapUtils::CopySettingsL - Copied the (general) settings table\n")));
       
  1127 	
       
  1128 	// For the USER certificate db.				
       
  1129 	EapTlsPeapUtils::CopySettingsL(
       
  1130 		db, 
       
  1131 		usercerts,
       
  1132 		iIndexType, 
       
  1133 		iIndex, 
       
  1134 		iTunnelingType, 
       
  1135 		aDestinationIndexType, 
       
  1136 		aDestinationIndex, 
       
  1137 		iTunnelingType);		
       
  1138 
       
  1139 	EAP_TRACE_DEBUG_SYMBIAN(
       
  1140 		(_L("EapTlsPeapUtils::CopySettingsL - Copied the USER certs table\n")));
       
  1141 	
       
  1142 	// For the CA certificate db.
       
  1143 	EapTlsPeapUtils::CopySettingsL(
       
  1144 		db, 
       
  1145 		cacerts,
       
  1146 		iIndexType, 
       
  1147 		iIndex, 
       
  1148 		iTunnelingType, 
       
  1149 		aDestinationIndexType, 
       
  1150 		aDestinationIndex, 
       
  1151 		iTunnelingType);
       
  1152 		
       
  1153 	EAP_TRACE_DEBUG_SYMBIAN(
       
  1154 		(_L("EapTlsPeapUtils::CopySettingsL - Copied the CA certs table\n")));
       
  1155 	
       
  1156 	// For the ciphersuites db.		
       
  1157 	EapTlsPeapUtils::CopySettingsL(
       
  1158 		db, 
       
  1159 		ciphersuites,
       
  1160 		iIndexType, 
       
  1161 		iIndex, 
       
  1162 		iTunnelingType, 
       
  1163 		aDestinationIndexType, 
       
  1164 		aDestinationIndex, 
       
  1165 		iTunnelingType);
       
  1166 
       
  1167 	EAP_TRACE_DEBUG_SYMBIAN(
       
  1168 		(_L("EapTlsPeapUtils::CopySettingsL - Copied the Cipher suites table\n")));
       
  1169 	
       
  1170 #ifdef USE_FAST_EAP_TYPE
       
  1171 	// This special settings is only for EAP-FAST
       
  1172 	if(iEapType == eap_type_fast)
       
  1173 	{
       
  1174 		EapTlsPeapUtils::CopySettingsL(
       
  1175 			db, 
       
  1176 			fastSpecialSettings,
       
  1177 			iIndexType, 
       
  1178 			iIndex, 
       
  1179 			iTunnelingType, 
       
  1180 			aDestinationIndexType, 
       
  1181 			aDestinationIndex, 
       
  1182 			iTunnelingType);
       
  1183 		
       
  1184 		EAP_TRACE_DEBUG_SYMBIAN(
       
  1185 			(_L("EapTlsPeapUtils::CopySettingsL - Copied the EAP-FAST Special settings table\n")));		
       
  1186 		
       
  1187 	} // End: if(iEapType == eap_type_fast)
       
  1188 	
       
  1189 #endif // End: #ifdef USE_FAST_EAP_TYPE	
       
  1190 	
       
  1191 	db.Close();
       
  1192 	CleanupStack::PopAndDestroy(2); // db, session
       
  1193 	
       
  1194 	//////// Copy Encapsulated types
       
  1195 	
       
  1196 	// Operator == takes care of expanded EAP type conversion automatically.
       
  1197 	if (iEapType == eap_type_peap
       
  1198 		|| iEapType == eap_type_ttls
       
  1199 
       
  1200 #ifdef USE_FAST_EAP_TYPE
       
  1201 		|| iEapType == eap_type_fast
       
  1202 #endif						
       
  1203 
       
  1204 		|| iEapType == eap_type_ttls_plain_pap
       
  1205 						
       
  1206 
       
  1207 	)
       
  1208 	{
       
  1209 		EAP_TRACE_DEBUG_SYMBIAN(
       
  1210 			(_L("EapTlsPeapUtils::CopySettingsL - Copying encapsulated EAP types\n")));		
       
  1211 		
       
  1212 		iEapArray.ResetAndDestroy();
       
  1213 		REComSession::ListImplementationsL(KEapTypeInterfaceUid, iEapArray);
       
  1214 				
       
  1215 		for (TInt i = 0; i < iEapArray.Count(); i++)
       
  1216 		{
       
  1217 			if ((iEapType == eap_type_peap && !CEapType::IsDisallowedInsidePEAP(*iEapArray[i])) 
       
  1218 				|| (iEapType == eap_type_ttls && !CEapType::IsDisallowedInsideTTLS(*iEapArray[i]))
       
  1219 
       
  1220 #ifdef USE_FAST_EAP_TYPE
       
  1221 				|| (iEapType == eap_type_fast && !CEapType::IsDisallowedInsidePEAP(*iEapArray[i]))
       
  1222 #endif										
       
  1223 
       
  1224 				|| (iEapType == eap_type_ttls_plain_pap && !CEapType::IsDisallowedInsidePEAP(*iEapArray[i]))
       
  1225 									
       
  1226 			)
       
  1227 			{
       
  1228 				// Copying the settings of encapsulated EAP type configurations possible inside PEAP and TTLS.
       
  1229 			
       
  1230 				CEapType* eapType;
       
  1231 			
       
  1232 #ifdef USE_EAP_EXPANDED_TYPES		
       
  1233 			
       
  1234 				TBuf8<KExpandedEAPTypeSize> expandedCue = iEapArray[i]->DataType();
       
  1235 			
       
  1236 				EAP_TRACE_DATA_DEBUG_SYMBIAN(("CEapTlsPeap::CopySettingsL: Expanded cue:",
       
  1237 				expandedCue.Ptr(), expandedCue.Size()));
       
  1238 			
       
  1239 				eapType = CEapType::NewL(expandedCue, iIndexType, iIndex);
       
  1240 				
       
  1241 				if(eapType == NULL)
       
  1242 				{
       
  1243 					EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeap::CopySettingsL: Ecom Error - No specified Expanded EAP plugin")) );
       
  1244 					User::Leave(KErrNotFound);
       
  1245 				}
       
  1246 				
       
  1247 				eapType->SetTunnelingType(iEapType.get_vendor_type());						
       
  1248 
       
  1249 #else // For normal EAP types.
       
  1250 			
       
  1251 				TBuf8<3> cue = iEapArray[i]->DataType();
       
  1252 			
       
  1253 				eapType = CEapType::NewL(cue, iIndexType, iIndex);	
       
  1254 				
       
  1255 				eapType->SetTunnelingType(iEapType);					
       
  1256 
       
  1257 #endif //#ifdef USE_EAP_EXPANDED_TYPES
       
  1258 				
       
  1259 				CleanupStack::PushL(eapType);
       
  1260 				
       
  1261 				eapType->CopySettingsL(aDestinationIndexType, aDestinationIndex);
       
  1262 				
       
  1263 				EAP_TRACE_DEBUG_SYMBIAN(
       
  1264 					(_L("EapTlsPeapUtils::CopySettingsL - Copied the encapsulated settings\n")));	
       
  1265 		
       
  1266 				CleanupStack::PopAndDestroy();
       
  1267 			}
       
  1268 		}	
       
  1269 	}
       
  1270 	
       
  1271 	EAP_TRACE_DEBUG_SYMBIAN(
       
  1272 		(_L("EapTlsPeapUtils::CopySettingsL - End \n")));	
       
  1273 
       
  1274 }
       
  1275 
       
  1276 #ifdef USE_PAC_STORE
       
  1277 
       
  1278 void CEapTlsPeap::UpdatePacStoreCleanupTableL(const TIndexType aIndexType,
       
  1279 	const TInt aIndex, 
       
  1280 	const eap_type_value_e aTunnelingType)
       
  1281 {
       
  1282 	EAP_TRACE_DEBUG_SYMBIAN(
       
  1283 	(_L("CEapTlsPeap::UpdatePacStoreCleanupTableL: Start")));
       
  1284 	
       
  1285 	CPacStoreDatabase * pacStoreDb	= CPacStoreDatabase::NewL();
       
  1286 	User::LeaveIfNull(pacStoreDb);
       
  1287 	
       
  1288 	EAP_TRACE_DEBUG_SYMBIAN(
       
  1289 	(_L("CEapTlsPeap::UpdatePacStoreCleanupTableL Created PAC store")));	
       
  1290 	
       
  1291 	pacStoreDb->OpenPacStoreL();
       
  1292 	
       
  1293 	EAP_TRACE_DEBUG_SYMBIAN(
       
  1294 	(_L("CEapTlsPeap::UpdatePacStoreCleanupTableL Opened PAC store")));	
       
  1295 
       
  1296 	pacStoreDb->AddACleanupReferenceEntryL(aIndexType, aIndex, aTunnelingType);	
       
  1297 	
       
  1298 	EAP_TRACE_DEBUG_SYMBIAN(
       
  1299 	(_L("CEapTlsPeap::UpdatePacStoreCleanupTableL: AddACleanupReferenceEntryL returns")));					
       
  1300 		
       
  1301 	pacStoreDb->Close();
       
  1302 
       
  1303 	EAP_TRACE_DEBUG_SYMBIAN(
       
  1304 			(_L("CEapTlsPeap::UpdatePacStoreCleanupTableL: pacStoreDb Closed")));					
       
  1305 	
       
  1306 	delete pacStoreDb;
       
  1307 			
       
  1308 	EAP_TRACE_DEBUG_SYMBIAN(
       
  1309 	(_L("CEapTlsPeap::UpdatePacStoreCleanupTableL: End")));	
       
  1310 	User::Leave(KErrNone);
       
  1311 }
       
  1312 
       
  1313 #endif // #ifdef USE_PAC_STORE
       
  1314 
       
  1315 // End of file
       
  1316