eapol/eapol_framework/eapol_symbian/am/type/tls_peap/symbian/eap_am_type_tls_peap_symbian.cpp
changeset 52 c23bdf5a328a
parent 42 53085837e73a
equal deleted inserted replaced
51:e863583e6720 52:c23bdf5a328a
    14 * Description:  EAP and WLAN authentication protocols.
    14 * Description:  EAP and WLAN authentication protocols.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: 256 %
    19 * %version: 294 %
    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
    58 
    58 
    59 #if defined(USE_FAST_EAP_TYPE)
    59 #if defined(USE_FAST_EAP_TYPE)
    60 #include "abs_tls_am_application_eap_fast.h"
    60 #include "abs_tls_am_application_eap_fast.h"
    61 #include "eap_fast_strings.h"
    61 #include "eap_fast_strings.h"
    62 #include "eap_fast_tlv_payloads.h"
    62 #include "eap_fast_tlv_payloads.h"
    63 //#include "eap_am_async_wait_symbian.h"
       
    64 #include "EapFastActive.h"
       
    65 #include "eap_tlv_header.h"
    63 #include "eap_tlv_header.h"
    66 #include "eap_tlv_message_data.h"
    64 #include "eap_tlv_message_data.h"
    67 #endif
    65 #endif
    68 #include <utf.h>
    66 #include <utf.h>
    69 
    67 
   118 	const eap_type_value_e aTunnelingType,
   116 	const eap_type_value_e aTunnelingType,
   119 	const eap_type_value_e aEapType,
   117 	const eap_type_value_e aEapType,
   120 	const bool aIsClient,
   118 	const bool aIsClient,
   121 	const eap_am_network_id_c * const receive_network_id)
   119 	const eap_am_network_id_c * const receive_network_id)
   122 	: CActive(CActive::EPriorityStandard)
   120 	: CActive(CActive::EPriorityStandard)
   123 	  , m_index_type(aIndexType)
   121 	, m_index_type(aIndexType)
   124 	  , m_index(aIndex)
   122 	, m_index(aIndex)
   125 	  , m_tunneling_type(aTunnelingType)
   123 	, m_tunneling_type(aTunnelingType)
   126 	  , m_partner(aPartner)
   124 	, m_partner(aPartner)
   127 	  , m_am_tools(static_cast<eap_am_tools_symbian_c*> (aTools))
   125 	, m_am_tools(static_cast<eap_am_tools_symbian_c*> (aTools))
   128 	  , m_tls_am_partner(0)
   126 	, m_tls_am_partner(0)
       
   127 
   129 #if defined(USE_FAST_EAP_TYPE)
   128 #if defined(USE_FAST_EAP_TYPE)
   130 	  , m_tls_application(0)
   129 	, m_tls_application(0)
   131 	  //, iWaitNoteCancelled( EFalse )
   130 	//, iWaitNoteCancelled( EFalse )
   132 
       
   133 #endif //#if defined(USE_FAST_EAP_TYPE)
   131 #endif //#if defined(USE_FAST_EAP_TYPE)
   134 	  , m_is_valid(false)
   132 
   135 	  , m_is_client(aIsClient)
   133 	, m_is_valid(false)
   136 	  , m_current_eap_type(aEapType)
   134 	, m_is_client(aIsClient)
   137 	  , m_max_count_of_session_resumes(0ul)
   135 	, m_current_eap_type(aEapType)
   138 	  , m_cipher_suite(tls_cipher_suites_TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA)
   136 	, m_max_count_of_session_resumes(0ul)
   139 	  , m_ca_certificate(0)
   137 	, m_cipher_suite(tls_cipher_suites_TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA)
   140 	  , m_own_certificate(0)
   138 	, m_ca_certificate(0)
   141 	  , m_peer_certificate(0)
   139 	, m_own_certificate(0)
   142 	  , m_cert_if(0)
   140 	, m_peer_certificate(0)
   143 	  , m_receive_network_id(aTools)
   141 	, m_cert_if(0)
   144 	  , m_eap_identifier(0u)
   142 	, m_receive_network_id(aTools)
   145 	  , m_subject_key_id(0)
   143 	, m_eap_identifier(0u)
   146 	  , m_allowed_user_certs(1)
   144 	, m_subject_key_id(0)
   147 	  , m_allowed_server_certs(1)
   145 	, m_allowed_user_certs(1)
   148 	  , m_peer_public_key(aTools)
   146 	, m_allowed_server_certs(1)
   149 	  , m_param_p(aTools)
   147 	, m_peer_public_key(aTools)
   150 	  , m_param_q(aTools)
   148 	, m_param_p(aTools)
   151 	  , m_param_g(aTools)
   149 	, m_param_q(aTools)
   152 	  , m_shutdown_was_called(false)
   150 	, m_param_g(aTools)
   153 
   151 	, m_shutdown_was_called(false)
   154 	  , m_tunneled_type(eap_type_none)
   152 
   155 	  , m_verify_certificate_realm(true)
   153 	, m_tunneled_type(eap_type_none)
   156 	  , m_allow_subdomain_matching(false)
   154 	, m_verify_certificate_realm(true)
   157 	  , m_latest_alert_description(tls_alert_description_none)
   155 	, m_allow_subdomain_matching(false)
   158 	  , m_use_manual_username(false)
   156 	, m_latest_alert_description(tls_alert_description_none)
   159 	  , m_manual_username(aTools)
   157 	, m_use_manual_username(false)
   160 	  , m_use_manual_realm(false)
   158 	, m_manual_username(aTools)
   161 	  , m_manual_realm(aTools)
   159 	, m_use_manual_realm(false)
   162 	  , m_tls_peap_server_authenticates_client_policy_flag(true)
   160 	, m_manual_realm(aTools)
   163 	  , m_use_automatic_ca_certificate(false)
   161 	, m_tls_peap_server_authenticates_client_policy_flag(true)
   164 	  , m_configured(false)
   162 	, m_use_automatic_ca_certificate(false)
   165 	  , m_max_session_time(0)
   163 	, m_configured(false)
       
   164 	, m_max_session_time(0)
       
   165 
   166 #if defined(USE_EAP_TLS_SESSION_TICKET)
   166 #if defined(USE_EAP_TLS_SESSION_TICKET)
   167 	  , m_use_session_ticket(false)
   167 	, m_use_session_ticket(false)
   168 #endif //#if defined(USE_EAP_TLS_SESSION_TICKET)
   168 #endif //#if defined(USE_EAP_TLS_SESSION_TICKET)
   169 
   169 
   170 #if defined(USE_FAST_EAP_TYPE)
   170 #if defined(USE_FAST_EAP_TYPE)
   171 	, m_received_tunnel_pac_in_session_ticket(0)
   171 	, m_received_tunnel_pac_in_session_ticket(0)
   172 	, m_received_user_authorization_pac_in_session_ticket(0)
   172 	, m_received_user_authorization_pac_in_session_ticket(0)
   187 	, m_references_and_data_blocks(aTools)
   187 	, m_references_and_data_blocks(aTools)
   188 	, m_new_references_and_data_blocks(aTools)
   188 	, m_new_references_and_data_blocks(aTools)
   189 	, m_ready_references_and_data_blocks(aTools)
   189 	, m_ready_references_and_data_blocks(aTools)
   190 	, m_serv_unauth_prov_mode(false)
   190 	, m_serv_unauth_prov_mode(false)
   191 	, m_serv_auth_prov_mode(false)
   191 	, m_serv_auth_prov_mode(false)
   192 
   192 	, m_is_pac_store_initialization(false)
   193 	, m_notifier_data_to_user(NULL)
       
   194 	, m_notifier_data_pckg_to_user(NULL)
       
   195 
       
   196 	, iMMETELConnectionStatus(false)
   193 	, iMMETELConnectionStatus(false)
   197 	, m_completed_with_zero(false)
   194 	, m_completed_with_zero(false)
   198 	, m_verificationStatus(false)
   195 	, m_verificationStatus(false)
   199 	, m_pacStorePWBuf8(0)
   196 	, m_pacStorePWBuf8(0)
   200 	, m_userAction(EEapFastNotifierUserActionOk)
   197 	, m_userAction(EEapFastNotifierUserActionOk)
   208 	, m_provisioning_mode(eap_fast_completion_operation_none)
   205 	, m_provisioning_mode(eap_fast_completion_operation_none)
   209 	, iCompletionOperation(eap_fast_completion_operation_none)
   206 	, iCompletionOperation(eap_fast_completion_operation_none)
   210 	, iCompletion(eap_fast_initialize_pac_store_completion_none)
   207 	, iCompletion(eap_fast_initialize_pac_store_completion_none)
   211 #endif //#if defined(USE_FAST_EAP_TYPE)
   208 #endif //#if defined(USE_FAST_EAP_TYPE)
   212 
   209 
   213 	, m_notifier_complete(false)
   210 	, m_notifier_data_to_user(NULL)
       
   211 	, m_notifier_data_pckg_to_user(NULL)
   214 
   212 
   215 #ifdef USE_PAC_STORE
   213 #ifdef USE_PAC_STORE
   216 	,iPacStoreDb(NULL)
   214 	,iPacStoreDb(NULL)
   217 #endif    
   215 #endif    
   218 	
   216 	
   229 
   227 
   230 	, iEapAuthNotifier(0)	
   228 	, iEapAuthNotifier(0)	
   231 
   229 
   232 {
   230 {
   233 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   231 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   232 
       
   233 	EAP_TRACE_DEBUG(
       
   234 		m_am_tools,
       
   235 		TRACE_FLAGS_DEFAULT,
       
   236 		(EAPL("TLS: %s: function: eap_am_type_tls_peap_symbian_c::eap_am_type_tls_peap_symbian_c(): this = 0x%08x\n"),
       
   237 		 (m_is_client == true ? "client": "server"),
       
   238 		 this));
   234 
   239 
   235 	// Set the database table name based on the type
   240 	// Set the database table name based on the type
   236 	if (m_current_eap_type == eap_type_tls)
   241 	if (m_current_eap_type == eap_type_tls)
   237 	{
   242 	{
   238 		m_db_table_name = KTlsDatabaseTableName;
   243 		m_db_table_name = KTlsDatabaseTableName;
   328 		)
   333 		)
   329 	{
   334 	{
   330 		User::Leave(KErrNotSupported);
   335 		User::Leave(KErrNotSupported);
   331 	}
   336 	}
   332 
   337 
   333 	eap_am_type_tls_peap_symbian_c* self = new(ELeave) eap_am_type_tls_peap_symbian_c(
   338 	eap_am_type_tls_peap_symbian_c* self = new eap_am_type_tls_peap_symbian_c(
   334 		aTools, 
   339 		aTools, 
   335 		aPartner, 
   340 		aPartner, 
   336 		aIndexType, 
   341 		aIndexType, 
   337 		aIndex, 
   342 		aIndex, 
   338 		aTunnelingType,
   343 		aTunnelingType,
   339 		aEapType, 
   344 		aEapType, 
   340 		aIsClient,
   345 		aIsClient,
   341 		receive_network_id);
   346 		receive_network_id);
   342 
   347 
   343 	CleanupStack::PushL(self);
   348 	if (self == 0
   344 
   349 		|| self->get_is_valid() != true)
   345 	if (self->get_is_valid() != true)
   350 	{
   346 	{
   351 		if (self != 0)
       
   352 		{
       
   353 			self->shutdown();
       
   354 		}
       
   355 
       
   356 		delete self;
       
   357 
   347 		User::Leave(KErrGeneral);
   358 		User::Leave(KErrGeneral);
   348 	}
   359 	}
   349 
   360 
   350 	self->ConstructL();
   361 	TRAPD(error, self->ConstructL());
   351 	
   362 
   352 	CleanupStack::Pop();
   363 	if (error != KErrNone)
       
   364 	{
       
   365 		self->shutdown();
       
   366 		delete self;
       
   367 
       
   368 		User::Leave(error);
       
   369 	}
       
   370 	
   353 	return self;
   371 	return self;
   354 }
   372 }
   355 
   373 
   356 //--------------------------------------------------
   374 //--------------------------------------------------
   357 
   375 
   358 //
   376 //
   359 void eap_am_type_tls_peap_symbian_c::ConstructL()
   377 void eap_am_type_tls_peap_symbian_c::ConstructL()
   360 {
   378 {
   361 	TInt error = m_session.Connect();
   379 	TInt error = m_session.Connect();
   362 	EAP_TRACE_DEBUG_SYMBIAN((_L("eap_am_type_tls_peap_symbian_c::ConstructL(): - m_session.Connect(), error=%d\n"), error));
   380 
       
   381 	EAP_TRACE_DEBUG(
       
   382 		m_am_tools,
       
   383 		TRACE_FLAGS_DEFAULT,
       
   384 		(EAPL("eap_am_type_tls_peap_symbian_c::ConstructL(): m_session.Connect(), error=%d\n"), error));
       
   385 
   363 	User::LeaveIfError(error);
   386 	User::LeaveIfError(error);
   364 
   387 
   365 	// Open/create database
   388 	// Open/create database
   366 	EapTlsPeapUtils::OpenDatabaseL(m_database, m_session, m_index_type, m_index, m_tunneling_type, m_current_eap_type);
   389 	EapTlsPeapUtils::OpenDatabaseL(m_database, m_session, m_index_type, m_index, m_tunneling_type, m_current_eap_type);
   367 
   390 
   368 	m_cert_if = CEapTlsPeapCertInterface::NewL(m_am_tools, this);
   391 	m_cert_if = CEapTlsPeapCertInterface::NewL(m_am_tools, this);
   369 
   392 
   370 	CActiveScheduler::Add(this);
   393 	CActiveScheduler::Add(this);
   371 
   394 
   372 	// Create and open PAC store (only for EAP-FAST at the moment)
       
   373 #ifdef USE_PAC_STORE
   395 #ifdef USE_PAC_STORE
   374 #ifdef USE_FAST_EAP_TYPE
   396 #ifdef USE_FAST_EAP_TYPE
   375 	
   397 	
   376 	if(m_current_eap_type == eap_type_fast && iPacStoreDb == NULL)
   398 	if(m_current_eap_type == eap_type_fast
   377 	{
   399 		&& iPacStoreDb == NULL)
   378 		iPacStoreDb = CPacStoreDatabase::NewL( this );
   400 	{
       
   401 		// Create PAC-store (only for EAP-FAST at the moment)
       
   402 		iPacStoreDb = CPacStoreDatabase::NewL(m_am_tools);
   379 		User::LeaveIfNull(iPacStoreDb);
   403 		User::LeaveIfNull(iPacStoreDb);
   380 		
   404 		
   381 		EAP_TRACE_DEBUG_SYMBIAN(
   405 		EAP_TRACE_DEBUG(
   382 			(_L("eap_am_type_tls_peap_symbian_c::ConstructL Created PAC store")));	
   406 			m_am_tools,
   383 		
   407 			TRACE_FLAGS_DEFAULT,
   384 		iPacStoreDb->OpenPacStoreL();
   408 			(EAPL("eap_am_type_tls_peap_symbian_c::ConstructL(): Created PAC store, this = 0x%08x"),
   385 		
   409 			this));
   386 		EAP_TRACE_DEBUG_SYMBIAN(
   410 	}
   387 			(_L("eap_am_type_tls_peap_symbian_c::ConstructL Opened PAC store")));		
   411 
   388 	}
       
   389 	m_info_array.ResetAndDestroy();
   412 	m_info_array.ResetAndDestroy();
   390 	
   413 	
   391 #endif	// End: #ifdef USE_FAST_EAP_TYPE
   414 #endif	// End: #ifdef USE_FAST_EAP_TYPE
   392 #endif // End: 	#ifdef USE_PAC_STORE
   415 #endif // End: 	#ifdef USE_PAC_STORE
   393 
   416 
   408 		(EAPL("TLS: %s: function: eap_am_type_tls_peap_symbian_c::shutdown()\n"),
   431 		(EAPL("TLS: %s: function: eap_am_type_tls_peap_symbian_c::shutdown()\n"),
   409 		 (m_is_client == true ? "client": "server")));
   432 		 (m_is_client == true ? "client": "server")));
   410 
   433 
   411 	if(IsActive())
   434 	if(IsActive())
   412 	{
   435 	{
   413 	    RDebug::Print( _L("eap_am_type_tls_peap_symbian_c::shutdown() cancelling active object") );
   436 		RDebug::Print( _L("eap_am_type_tls_peap_symbian_c::shutdown() cancelling active object") );
   414 		Cancel();		
   437 		Cancel();		
   415 	}
   438 	}
   416 	
   439 
   417 	else
   440 	else
   418 	{
   441 	{
   419 		if(m_cert_if->IsActive())
   442 		if(m_cert_if != 0
       
   443 			&& m_cert_if->IsActive())
   420 		{
   444 		{
   421 			m_cert_if->Cancel();
   445 			m_cert_if->Cancel();
   422 		}		
   446 		}		
   423 	}
   447 	}
   424 
   448 
   425 	if (iEapAuthNotifier != 0)
   449 	if (iEapAuthNotifier != 0)
   426 		{
   450 	{
   427 		iEapAuthNotifier->Cancel();
   451 		iEapAuthNotifier->Cancel();
   428 		}
   452 	}
   429 
   453 
   430 	
   454 	if (m_partner != NULL)
   431 
   455 	{
   432 	
   456 
       
   457 		EAP_TRACE_DEBUG(
       
   458 			m_am_tools,
       
   459 			TRACE_FLAGS_DEFAULT,
       
   460 			(EAPL(" eap_am_type_tls_peap_symbian_c::shutdown(): Cancel timers ...")));
       
   461 
   433 #if defined(USE_FAST_EAP_TYPE)
   462 #if defined(USE_FAST_EAP_TYPE)
   434 
   463 
   435 
   464 		m_partner->cancel_timer(
   436 
   465 			this, 
   437 #endif 
   466 			KRemoveIAPReferenceTimerID);
   438 
   467 
   439 		if (m_partner != NULL)
   468 		m_partner->cancel_timer(
   440 		    {
   469 			this, 
   441 		    EAP_TRACE_DEBUG_SYMBIAN(
   470 			KImportFileTimerID);
   442 				(_L(" eap_am_type_tls_peap_symbian_c::shutdown - Cancel timers ...")));
   471 	
   443 
   472 		m_partner->cancel_timer(
   444 #if defined(USE_FAST_EAP_TYPE)
   473 			this, 
   445 		    m_partner->cancel_timer(
   474 			KCompleteReadPacstoreTimerID);
   446 				this, 
   475 
   447 				KRemoveIAPReferenceTimerID);
   476 		m_partner->cancel_timer(
   448 
   477 			this, 
   449 		    m_partner->cancel_timer(
   478 			KHandleReadPacstoreTimerID);
   450 				this, 
   479 
   451 				KImportFileTimerID);
   480 		m_partner->cancel_timer(
   452 		
   481 			this, 
   453 		    m_partner->cancel_timer(
   482 			KHandleCompletePacstoreNokTimerID);
   454 				this, 
   483 
   455 				KCompleteReadPacstoreTimerID);
   484 		m_partner->cancel_timer(
   456 
   485 			this, 
   457 		    m_partner->cancel_timer(
   486 			KHandleCompletePacstoreOkTimerID);
   458 				this, 
   487 
   459 				KHandleReadPacstoreTimerID);
       
   460 
       
   461 		    m_partner->cancel_timer(
       
   462 				this, 
       
   463 				KHandleCompletePacstoreNokTimerID);
       
   464 
       
   465 		    m_partner->cancel_timer(
       
   466 				this, 
       
   467 				KHandleCompletePacstoreOkTimerID);
       
   468 				
       
   469 #endif
   488 #endif
   470 		    EAP_TRACE_DEBUG_SYMBIAN(
   489 
   471 				(_L(" eap_am_type_tls_peap_symbian_c::shutdown - Timers canceled")));
   490 		EAP_TRACE_DEBUG(
   472 		    }
   491 			m_am_tools,
   473 		
   492 			TRACE_FLAGS_DEFAULT,
   474 #if defined(USE_FAST_EAP_TYPE)
   493 			(EAPL(" eap_am_type_tls_peap_symbian_c::shutdown(): Timers canceled")));
   475 
   494 	}
   476 #endif // #if defined(USE_FAST_EAP_TYPE)
       
   477 	
   495 	
   478 
   496 
   479 	m_allowed_server_certs.ResetAndDestroy();
   497 	m_allowed_server_certs.ResetAndDestroy();
   480 	m_allowed_ca_certs.ResetAndDestroy();			
   498 	m_allowed_ca_certs.ResetAndDestroy();			
   481 	m_allowed_cipher_suites.Close();			
   499 	m_allowed_cipher_suites.Close();			
   482 	m_allowed_user_certs.ResetAndDestroy();			
   500 	m_allowed_user_certs.ResetAndDestroy();			
   483 
   501 
   484 #ifdef USE_PAC_STORE
   502 #ifdef USE_PAC_STORE
   485 #ifdef USE_FAST_EAP_TYPE
   503 #ifdef USE_FAST_EAP_TYPE
   486 	
   504 
   487 	if(m_current_eap_type == eap_type_fast && iPacStoreDb != NULL)
   505 	if(iPacStoreDb != NULL)
   488 	{
   506 	{
   489 		iPacStoreDb->Close();
   507 		iPacStoreDb->Close();
   490 	}
   508 	}
   491 	
   509 
   492 	m_info_array.ResetAndDestroy();
   510 	m_info_array.ResetAndDestroy();
   493 
   511 
   494 	EAP_TRACE_DEBUG_SYMBIAN(
   512 	EAP_TRACE_DEBUG(
   495 			(_L(" eap_am_type_tls_peap_symbian_c::shutdown - Arrays cleared")));
   513 		m_am_tools,
       
   514 		TRACE_FLAGS_DEFAULT,
       
   515 		(EAPL(" eap_am_type_tls_peap_symbian_c::shutdown(): Arrays cleared")));
   496 
   516 
   497 #endif	// End: #ifdef USE_FAST_EAP_TYPE	
   517 #endif	// End: #ifdef USE_FAST_EAP_TYPE	
   498 #endif	// End: #ifdef USE_PAC_STORE
   518 #endif	// End: #ifdef USE_PAC_STORE
   499 		
   519 		
   500 	m_shutdown_was_called = true;
   520 	m_shutdown_was_called = true;
   501 	
   521 
   502 #if defined(USE_EAP_CONFIGURATION_TO_SKIP_USER_INTERACTIONS)
   522 #if defined(USE_EAP_CONFIGURATION_TO_SKIP_USER_INTERACTIONS)
   503    delete m_fileconfig;
   523 	delete m_fileconfig;
   504    m_fileconfig = 0;
   524 	m_fileconfig = 0;
   505 #endif
   525 #endif
       
   526 
       
   527 	m_database.Close();
       
   528 	m_session.Close();
       
   529 
       
   530 	delete m_notifier_data_to_user;
       
   531 	m_notifier_data_to_user = 0;
       
   532 	delete m_notifier_data_pckg_to_user;
       
   533 	m_notifier_data_pckg_to_user = 0;
       
   534 		
       
   535 	delete m_cert_if;
       
   536 	m_cert_if = 0;
       
   537 
       
   538 	delete m_ca_certificate;
       
   539 	m_ca_certificate = 0;
       
   540 	delete m_own_certificate;
       
   541 	m_own_certificate = 0;
       
   542 	delete m_peer_certificate;
       
   543 	m_peer_certificate = 0;
       
   544 
       
   545 	m_enabled_tunneling_exp_eap_array.ResetAndDestroy();
       
   546 	m_disabled_tunneling_exp_eap_array.ResetAndDestroy();
       
   547 
       
   548 #ifdef USE_PAC_STORE
       
   549 	
       
   550 	delete iPacStoreDb;
       
   551 	iPacStoreDb = 0;
       
   552 	
       
   553 #endif // #ifdef USE_PAC_STORE	
       
   554 
       
   555 	delete iEapAuthNotifier;
       
   556 	iEapAuthNotifier = 0;
   506 
   557 
   507 	EAP_TRACE_DEBUG(
   558 	EAP_TRACE_DEBUG(
   508 		m_am_tools,
   559 		m_am_tools,
   509 		TRACE_FLAGS_DEFAULT,
   560 		TRACE_FLAGS_DEFAULT,
   510 		(EAPL("TLS: %s: function: eap_am_type_tls_peap_symbian_c::shutdown() returns\n"),
   561 		(EAPL("TLS: %s: function: eap_am_type_tls_peap_symbian_c::shutdown() returns\n"),
   527 		(EAPL("TLS: %s: function: eap_am_type_tls_peap_symbian_c::~eap_am_type_tls_peap_symbian_c()\n"),
   578 		(EAPL("TLS: %s: function: eap_am_type_tls_peap_symbian_c::~eap_am_type_tls_peap_symbian_c()\n"),
   528 		 (m_is_client == true ? "client": "server")));
   579 		 (m_is_client == true ? "client": "server")));
   529 
   580 
   530 	EAP_ASSERT(m_shutdown_was_called == true);	
   581 	EAP_ASSERT(m_shutdown_was_called == true);	
   531 
   582 
   532 	m_database.Close();
       
   533 	m_session.Close();
       
   534 
       
   535 	delete m_notifier_data_to_user;
       
   536 	delete m_notifier_data_pckg_to_user;
       
   537 		
       
   538 	delete m_cert_if;
       
   539 
       
   540 	delete m_ca_certificate;
       
   541 	delete m_own_certificate;
       
   542 	delete m_peer_certificate;
       
   543 
       
   544 	m_enabled_tunneling_exp_eap_array.ResetAndDestroy();
       
   545 	m_disabled_tunneling_exp_eap_array.ResetAndDestroy();
       
   546 
       
   547 	EAP_TRACE_DEBUG(
       
   548 			m_am_tools,
       
   549 			TRACE_FLAGS_DEFAULT,
       
   550 			(EAPL("eap_am_type_tls_peap_symbian_c::~eap_am_type_tls_peap_symbian_c() tunneling done.\n")));
       
   551 
       
   552 #ifdef USE_PAC_STORE
       
   553 	
       
   554 	delete iPacStoreDb;
       
   555 	
       
   556 #endif // #ifdef USE_PAC_STORE	
       
   557 
       
   558 	delete iEapAuthNotifier;
       
   559 	iEapAuthNotifier = 0;
       
   560 
       
   561 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   583 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   562 }
   584 }
   563 //--------------------------------------------------
   585 //--------------------------------------------------
   564 
   586 
   565 EAP_FUNC_EXPORT void eap_am_type_tls_peap_symbian_c::DlgComplete( TInt aStatus )
   587 EAP_FUNC_EXPORT void eap_am_type_tls_peap_symbian_c::DlgComplete( TInt aStatus )
   566 {
   588 {
   567 	EAP_TRACE_DEBUG(
   589 	EAP_TRACE_DEBUG(
   568 		m_am_tools,
   590 		m_am_tools,
   569 		TRACE_FLAGS_DEFAULT,
   591 		TRACE_FLAGS_DEFAULT,
   570 		(EAPL("TLS: function: eap_am_type_tls_peap_symbian_c::DlgComplete(): m_notifier_complete=%d, m_state=%d\n"),
   592 		(EAPL("TLS: function: eap_am_type_tls_peap_symbian_c::DlgComplete():  m_state=%d\n"),
   571 		m_notifier_complete,
       
   572 		m_state));
   593 		m_state));
   573 
   594 
   574 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_type_tls_peap_symbian_c::DlgComplete()");
   595 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_type_tls_peap_symbian_c::DlgComplete()");
   575 
   596 
   576 #ifdef USE_FAST_EAP_TYPE
   597 #ifdef USE_FAST_EAP_TYPE
   577 	m_userAction = EEapFastNotifierUserActionOk;
   598 	m_userAction = EEapFastNotifierUserActionOk;
   578 #endif
   599 #endif
   579 
   600 
   580 	eap_status_e status = m_am_tools->convert_am_error_to_eapol_error(aStatus);
   601 	eap_status_e status = m_am_tools->convert_am_error_to_eapol_error(aStatus);
   581 
   602 
   582 	if(m_notifier_complete)
   603 	EAP_TRACE_DATA_DEBUG(
   583 	{
   604 		m_am_tools,
   584 		EAP_TRACE_DATA_DEBUG(
   605 		TRACE_FLAGS_DEFAULT,
   585 			m_am_tools,
   606 		(EAPL( "m_notifier_data_pckg_to_user" ),
   586 			TRACE_FLAGS_DEFAULT,
   607 		m_notifier_data_pckg_to_user->Ptr(),
   587 			(EAPL( "m_notifier_data_pckg_to_user" ),
   608 		m_notifier_data_pckg_to_user->Size() ) );
   588 			m_notifier_data_pckg_to_user->Ptr(),
   609 
   589 			m_notifier_data_pckg_to_user->Size() ) );
   610 		if ( aStatus != KErrNone)
   590 
       
   591 		if ( aStatus == KErrCancel )
       
   592 		{
   611 		{
   593 			EAP_TRACE_DEBUG(
   612 			EAP_TRACE_DEBUG(
   594 				m_am_tools,
   613 				m_am_tools,
   595 				TRACE_FLAGS_DEFAULT,
   614 				TRACE_FLAGS_DEFAULT,
   596 				(EAPL("TLS: function: eap_am_type_tls_peap_symbian_c::DlgComplete(): User cancelled the dialog\n")));
   615 				(EAPL("TLS: function: eap_am_type_tls_peap_symbian_c::DlgComplete(): User cancelled the dialog\n")));
   597 
   616 
   598 #ifdef USE_FAST_EAP_TYPE
   617 #ifdef USE_FAST_EAP_TYPE
   599 			m_userAction = EEapFastNotifierUserActionCancel;	
   618 			m_userAction = EEapFastNotifierUserActionCancel;	
   600 #endif
   619 #endif
   601 		}		
   620 		}
   602 		else if( aStatus != KErrNone )
   621 #ifdef USE_FAST_EAP_TYPE
   603 		{
   622 		else
   604 			EAP_TRACE_DEBUG(
   623 			{
   605 				m_am_tools,
   624 			m_userAction = EEapFastNotifierUserActionOk;	
   606 				TRACE_FLAGS_DEFAULT,
   625 			}	
   607 				(EAPL("ERROR: TLS: function: eap_am_type_tls_peap_symbian_c::DlgComplete(): dialog error=%d\n"),
   626 #endif
   608 				aStatus));
   627 			
   609 
       
   610 			TBuf8<KMaxNotifItemLength> userNameUtf8;
       
   611 			TBuf8<KMaxUiDataLength> challengeUtf8;
       
   612 			userNameUtf8.Zero();
       
   613 			challengeUtf8.Zero();
       
   614 
       
   615 			CompleteQueryTtlsPapUserNameAndPassword(
       
   616 				status, userNameUtf8, challengeUtf8 );
       
   617 
       
   618 			return; // m_am_tools->convert_am_error_to_eapol_error(aStatus);		
       
   619 		}
       
   620 
       
   621 		if ( m_notifier_data_to_user->iPassword.Size() > 0 )
   628 		if ( m_notifier_data_to_user->iPassword.Size() > 0 )
   622 		{
   629 		{
   623 			HBufC8* notifier_data8 = NULL;
   630 			HBufC8* notifier_data8 = NULL;
   624 			TRAPD(err, notifier_data8 = HBufC8::NewL(m_notifier_data_to_user->iPassword.Size()));
   631 			TRAPD(error, notifier_data8 = HBufC8::NewL(m_notifier_data_to_user->iPassword.Size()));
   625 			if (err)
   632 			if (error)
   626 			{
   633 			{
       
   634 				delete notifier_data8;
   627 				return;	
   635 				return;	
   628 			}
   636 			}
       
   637 
   629 			TPtr8 notifier_dataPtr8 = notifier_data8->Des();
   638 			TPtr8 notifier_dataPtr8 = notifier_data8->Des();
   630 
   639 
   631 			notifier_dataPtr8.Copy(m_notifier_data_to_user->iPassword); // Unicode -> ascii.
   640 			notifier_dataPtr8.Copy(m_notifier_data_to_user->iPassword); // Unicode -> ascii.
   632 
   641 
   633 			EAP_TRACE_DATA_DEBUG(
   642 			EAP_TRACE_DATA_DEBUG(
   640 #ifdef USE_FAST_EAP_TYPE
   649 #ifdef USE_FAST_EAP_TYPE
   641 			status = m_userResponse.set_copy_of_buffer(
   650 			status = m_userResponse.set_copy_of_buffer(
   642 				notifier_dataPtr8.Ptr(),
   651 				notifier_dataPtr8.Ptr(),
   643 				notifier_dataPtr8.Size());
   652 				notifier_dataPtr8.Size());
   644 #endif			
   653 #endif			
   645 			CleanupStack::PopAndDestroy( notifier_data8 );
   654 			delete notifier_data8;
   646 		}
   655 		}
   647 	}
       
   648 
       
   649 	m_notifier_complete = 0;
       
   650 
   656 
   651 	if ( m_state == EPapChallenge)
   657 	if ( m_state == EPapChallenge)
   652 	{
   658 	{
   653 		EAP_TRACE_DEBUG(
   659 		EAP_TRACE_DEBUG(
   654 			m_am_tools,
   660 			m_am_tools,
   658 		m_state = EPapUserNameAndPassword;
   664 		m_state = EPapUserNameAndPassword;
   659 		TEapExpandedType aEapType(*EapExpandedTypeTtlsPap.GetType());
   665 		TEapExpandedType aEapType(*EapExpandedTypeTtlsPap.GetType());
   660 
   666 
   661 		if (iEapAuthNotifier == 0)
   667 		if (iEapAuthNotifier == 0)
   662 		{
   668 		{
   663 			TRAPD(err, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
   669 			TRAPD(error, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
   664 			if (err)
   670 			if (error)
   665 			{
   671 			{
   666 			eap_variable_data_c userNameUtf8( m_am_tools );
   672 			eap_variable_data_c userNameUtf8( m_am_tools );
   667 			eap_variable_data_c passwordUtf8( m_am_tools );
   673 			eap_variable_data_c passwordUtf8( m_am_tools );
   668 		
   674 		
   669 			(void) m_tls_am_partner->
   675 			(void) m_tls_am_partner->
   846 
   852 
   847 }
   853 }
   848 
   854 
   849 //--------------------------------------------------
   855 //--------------------------------------------------
   850 
   856 
   851 //
   857 TBool eap_am_type_tls_peap_symbian_c::IsMasterKeyAndPasswordMatchingL(
       
   858 	      const TDesC16 & aPassword)
       
   859 {
       
   860 EAP_UNREFERENCED_PARAMETER(aPassword);
       
   861  
       
   862 #ifdef USE_FAST_EAP_TYPE
       
   863 
       
   864 	HBufC8 * pacStorePWBuf8 = HBufC8::NewLC(aPassword.Length());
       
   865 	TPtr8 pacStorePWPtr8 = pacStorePWBuf8->Des();
       
   866 
       
   867 	CnvUtfConverter::ConvertFromUnicodeToUtf8(pacStorePWPtr8, aPassword);
       
   868 
       
   869 	TBool verification = iPacStoreDb->IsMasterKeyAndPasswordMatchingL(pacStorePWPtr8);
       
   870 
       
   871 	CleanupStack::PopAndDestroy(pacStorePWBuf8);
       
   872 
       
   873 	return verification;
       
   874 
       
   875 #else
       
   876 
       
   877 	return EFalse;
       
   878 
       
   879 #endif
       
   880 
       
   881 }
       
   882 
       
   883 //--------------------------------------------------
       
   884 
   852 void eap_am_type_tls_peap_symbian_c::RunL()
   885 void eap_am_type_tls_peap_symbian_c::RunL()
   853 {
   886 {
   854 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);		
   887 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);		
   855 	
   888 	
   856 	EAP_TRACE_DEBUG_SYMBIAN(
   889 	EAP_TRACE_DEBUG(
   857 		(_L("eap_am_type_tls_peap_symbian_c::RunL - iStatus.Int()=%d, m_state=%d "),
   890 		m_am_tools,
   858 		iStatus.Int() , m_state));
   891 		TRACE_FLAGS_DEFAULT,
       
   892 		(EAPL("eap_am_type_tls_peap_symbian_c::RunL(): iStatus.Int()=%d, m_state=%d.\n"),
       
   893 		iStatus.Int(),
       
   894 		m_state));
   859 	
   895 	
   860 #ifdef USE_FAST_EAP_TYPE
   896 #ifdef USE_FAST_EAP_TYPE
   861 	if (m_state == ENone)
   897 	if (m_state == ENone)
   862 		{
   898 		{
   863 		return;		
   899 		return;		
   864 		}
   900 		}
   865 
   901 
   866 		if ( m_state == EHandlingDeviceSeedQuery)
   902 	if ( m_state == EHandlingDeviceSeedQuery)
   867 			{
   903 		{
   868 		  CompleteCreateDeviceSeedL( iStatus.Int() );     
   904 		CompleteCreateDeviceSeedL( iStatus.Int() );
   869 
   905 
   870 		  return;
   906 		return;
   871 			}
   907 		}
   872 #endif // #ifdef USE_FAST_EAP_TYPE
   908 #endif // #ifdef USE_FAST_EAP_TYPE
   873 
   909 
   874 	if (iStatus.Int() != KErrNone)
   910 	if (iStatus.Int() != KErrNone)
   875 	{
   911 	{
   876 		// Notifier was cancelled or something went wrong
   912 		// Notifier was cancelled or something went wrong
   944 		{
   980 		{
   945 			retrieve_chain = false;
   981 			retrieve_chain = false;
   946 		}
   982 		}
   947 		
   983 		
   948 		TInt allowed_user_cert_count = m_allowed_user_certs.Count();
   984 		TInt allowed_user_cert_count = m_allowed_user_certs.Count();
   949 		TInt err(KErrNone);
   985 		TInt error(KErrNone);
   950 		
   986 		
   951 		if(allowed_user_cert_count > 0)
   987 		if(allowed_user_cert_count > 0)
   952 		{
   988 		{
   953 			TRAP(err, m_cert_if->ReadCertificateL(*m_allowed_user_certs[index], retrieve_chain));			
   989 			TRAP(error, m_cert_if->ReadCertificateL(*m_allowed_user_certs[index], retrieve_chain));			
   954 		}
   990 		}
   955 		if (err != KErrNone || allowed_user_cert_count <= 0)
   991 		if (error != KErrNone || allowed_user_cert_count <= 0)
   956 		{
   992 		{
   957 			EAP_TRACE_ERROR(
   993 			EAP_TRACE_ERROR(
   958 			m_am_tools,
   994 			m_am_tools,
   959 			TRACE_FLAGS_DEFAULT,
   995 			TRACE_FLAGS_DEFAULT,
   960 			(EAPL("ERROR: Certificate reading failed or no user cert, user cert count=%d\n"),
   996 			(EAPL("ERROR: Certificate reading failed or no user cert, user cert count=%d\n"),
  1003 //
  1039 //
  1004 eap_status_e eap_am_type_tls_peap_symbian_c::CreateDeviceSeedAsync()
  1040 eap_status_e eap_am_type_tls_peap_symbian_c::CreateDeviceSeedAsync()
  1005 {   
  1041 {   
  1006     EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  1042     EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  1007 
  1043 
  1008     EAP_TRACE_DEBUG_SYMBIAN(
  1044 	EAP_TRACE_DEBUG(
  1009         (_L("eap_am_type_tls_peap_symbian_c::CreateDeviceSeedAsync-Start ActiveStatus=%d"),
  1045 		m_am_tools,
  1010         IsActive()));       
  1046 		TRACE_FLAGS_DEFAULT,
  1011     
  1047 		(EAPL("eap_am_type_tls_peap_symbian_c::CreateDeviceSeedAsync-Start ActiveStatus=%d"),
       
  1048         IsActive()));
       
  1049 
  1012     if ( IsActive() )
  1050     if ( IsActive() )
  1013     {
  1051     {
  1014         EAP_TRACE_DEBUG_SYMBIAN(
  1052 		EAP_TRACE_DEBUG(
  1015             (_L("CreateDeviceSeedAsync: Already active when tried to create device seed")));       
  1053 			m_am_tools,
       
  1054 			TRACE_FLAGS_DEFAULT,
       
  1055 			(EAPL("CreateDeviceSeedAsync: Already active when tried to create device seed")));       
  1016         
  1056         
  1017         return eap_status_device_busy;
  1057         return eap_status_device_busy;
  1018     }
  1058     }
  1019 
  1059 
  1020     eap_status_e status(eap_status_ok); 
  1060     eap_status_e status(eap_status_ok); 
  1026     if(error !=KErrNone)
  1066     if(error !=KErrNone)
  1027     {
  1067     {
  1028         return m_am_tools->convert_am_error_to_eapol_error(error);
  1068         return m_am_tools->convert_am_error_to_eapol_error(error);
  1029     }
  1069     }
  1030     
  1070     
  1031     iPhone.GetPhoneId( iStatus, iDeviceId ); 
  1071 #if defined(__WINS__)
  1032 
  1072 
  1033     SetActive();
  1073 	EAP_TRACE_DEBUG(
  1034     return status;
  1074 		m_am_tools,
       
  1075 		TRACE_FLAGS_DEFAULT,
       
  1076 		(EAPL("WARNING: No iPhone.GetPhoneId() call.\n")));
       
  1077 
       
  1078 	_LIT(MANUFACTURER, "Test MANUFACTURER");
       
  1079     iDeviceId.iManufacturer.Copy(MANUFACTURER);
       
  1080 
       
  1081 	_LIT(MODEL, "Test MODEL");
       
  1082     iDeviceId.iModel.Copy(MODEL);
       
  1083 
       
  1084 	_LIT(REVISION, "1");
       
  1085     iDeviceId.iRevision.Copy(REVISION);
       
  1086 
       
  1087 	_LIT(SERIALNUMBER, "0123456789");
       
  1088     iDeviceId.iSerialNumber.Copy(SERIALNUMBER);
       
  1089 
       
  1090     {
       
  1091 		TRequestStatus* ao_status = &iStatus;
       
  1092 		User::RequestComplete(ao_status, KErrNone);
       
  1093 	}
       
  1094 
       
  1095 #else
       
  1096 
       
  1097 	iPhone.GetPhoneId( iStatus, iDeviceId ); 
       
  1098 
       
  1099 #endif //#if defined(__WINS__)
       
  1100 
       
  1101     EAP_TRACE_DEBUG(
       
  1102 		m_am_tools,
       
  1103 		TRACE_FLAGS_DEFAULT,
       
  1104 		(EAPL("WARNING: Not opened phone subsession on WINS.\n")));
       
  1105 
       
  1106 	SetActive();
       
  1107 	return EAP_STATUS_RETURN(m_am_tools, status);
  1035 } // eap_am_type_tls_peap_symbian_c::CreateDeviceSeedAsynch()
  1108 } // eap_am_type_tls_peap_symbian_c::CreateDeviceSeedAsynch()
  1036 
  1109 
  1037 //--------------------------------------------------
  1110 //--------------------------------------------------
  1038 
  1111 
  1039 void eap_am_type_tls_peap_symbian_c::CompleteCreateDeviceSeedL( TInt aStatus )
  1112 void eap_am_type_tls_peap_symbian_c::CompleteCreateDeviceSeedL( TInt aStatus )
  1040 {
  1113 {
  1041     EAP_TRACE_DEBUG_SYMBIAN(
  1114 	EAP_TRACE_DEBUG(
  1042             (_L("eap_am_type_tls_peap_symbian_c::CompleteCreateDeviceSeedL aStatus=%d"),
  1115 		m_am_tools,
  1043             iStatus.Int()));
  1116 		TRACE_FLAGS_DEFAULT,
       
  1117 		(EAPL("eap_am_type_tls_peap_symbian_c::CompleteCreateDeviceSeedL aStatus=%d"),
       
  1118 		iStatus.Int()));
       
  1119 
  1044     if ( aStatus != KErrNone )
  1120     if ( aStatus != KErrNone )
  1045         {
  1121         {
  1046         EAP_TRACE_DEBUG_SYMBIAN(
  1122 		EAP_TRACE_DEBUG(
  1047                 (_L("eap_am_type_tls_peap_symbian_c::CompleteCreateDeviceSeedL ERROR: aStatus=%d"),
  1123 			m_am_tools,
  1048                 iStatus.Int()));        
  1124 			TRACE_FLAGS_DEFAULT,
       
  1125 			(EAPL("ERROR: eap_am_type_tls_peap_symbian_c::CompleteCreateDeviceSeedL(): aStatus=%d"),
       
  1126 			iStatus.Int()));        
  1049         }
  1127         }
       
  1128 
  1050     EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Manufacturer"),
  1129     EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Manufacturer"),
  1051         iDeviceId.iManufacturer.Ptr(),
  1130         iDeviceId.iManufacturer.Ptr(),
  1052         iDeviceId.iManufacturer.Size()));
  1131         iDeviceId.iManufacturer.Size()));
  1053     EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Model"),
  1132     EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Model"),
  1054         iDeviceId.iModel.Ptr(),
  1133         iDeviceId.iModel.Ptr(),
  1105     ContinueInitializePacStore();
  1184     ContinueInitializePacStore();
  1106 
  1185 
  1107 } // eap_am_type_tls_peap_symbian_c::CompleteCreateDeviceSeedL()
  1186 } // eap_am_type_tls_peap_symbian_c::CompleteCreateDeviceSeedL()
  1108 
  1187 
  1109 #endif
  1188 #endif
       
  1189 
  1110 //--------------------------------------------------
  1190 //--------------------------------------------------
  1111 
  1191 
  1112 void eap_am_type_tls_peap_symbian_c::DoCancel()
  1192 void eap_am_type_tls_peap_symbian_c::DoCancel()
  1113 {
  1193 {
  1114 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);	
  1194 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);	
  1115     
  1195     
  1116 	RDebug::Print( _L("eap_am_type_tls_peap_symbian_c::DoCancel()\n") );
  1196 	EAP_TRACE_DEBUG(
       
  1197 		m_am_tools,
       
  1198 		TRACE_FLAGS_DEFAULT,
       
  1199 		(EAPL("eap_am_type_tls_peap_symbian_c::DoCancel(): iStatus.Int()=%d\n"),
       
  1200 		iStatus.Int()));
  1117 
  1201 
  1118 	if(m_cert_if->IsActive())
  1202 	if(m_cert_if->IsActive())
  1119 	{
  1203 	{
  1120 		m_cert_if->Cancel();		
  1204 		m_cert_if->Cancel();		
  1121 	}
  1205 	}
  1163 	// Validate length.
  1247 	// Validate length.
  1164 	if(manual_username.Length() > KMaxUsernameLengthInDB
  1248 	if(manual_username.Length() > KMaxUsernameLengthInDB
  1165 		|| manual_realm.Length() > KMaxRealmLengthInDB)
  1249 		|| manual_realm.Length() > KMaxRealmLengthInDB)
  1166 	{
  1250 	{
  1167 		// Username or realm too long. Can not be stored in DB.
  1251 		// Username or realm too long. Can not be stored in DB.
  1168 		EAP_TRACE_DEBUG_SYMBIAN((_L("eap_am_type_tls_peap_symbian_c::SaveManualIdentityL: Too long username or realm. Length: manual_username=%d, manual_realm=%d\n"),
  1252 		EAP_TRACE_DEBUG(
  1169 		manual_username.Length(), manual_realm.Length()));
  1253 			m_am_tools,
       
  1254 			TRACE_FLAGS_DEFAULT,
       
  1255 			(EAPL("ERROR: eap_am_type_tls_peap_symbian_c::SaveManualIdentityL: Too long username or realm. Length: manual_username=%d, manual_realm=%d\n"),
       
  1256 			manual_username.Length(),
       
  1257 			manual_realm.Length()));
  1170 		
  1258 		
  1171 		User::Leave(KErrArgument);
  1259 		User::Leave(KErrArgument);
  1172 	}
  1260 	}
  1173 		
  1261 		
  1174 	HBufC* sqlbuf = HBufC::NewLC(KMaxSqlQueryLength);
  1262 	HBufC* sqlbuf = HBufC::NewLC(KMaxSqlQueryLength);
  1300 //
  1388 //
  1301 eap_status_e
  1389 eap_status_e
  1302 eap_am_type_tls_peap_symbian_c::CompleteQueryUserPermissionForAid(
  1390 eap_am_type_tls_peap_symbian_c::CompleteQueryUserPermissionForAid(
  1303 	EEapFastNotifierUserAction aUserAction )
  1391 	EEapFastNotifierUserAction aUserAction )
  1304 {
  1392 {
  1305 	EAP_TRACE_DEBUG_SYMBIAN(
  1393 	EAP_TRACE_DEBUG(
  1306 			(_L("eap_am_type_tls_peap_symbian_c::CompleteQueryUserPermissionForAid")));
  1394 		m_am_tools,
       
  1395 		TRACE_FLAGS_DEFAULT,
       
  1396 		(EAPL("eap_am_type_tls_peap_symbian_c::CompleteQueryUserPermissionForAid")));
       
  1397 
  1307 	if ( aUserAction == EEapFastNotifierUserActionOk )
  1398 	if ( aUserAction == EEapFastNotifierUserActionOk )
  1308 		{
  1399 		{
  1309 		EAP_TRACE_DEBUG_SYMBIAN(
  1400 		EAP_TRACE_DEBUG(
  1310 		    (_L("eap_am_type_tls_peap_symbian_c::CompleteQueryUserPermissionForAid eap_status_ok")));
  1401 			m_am_tools,
  1311 		m_eap_fast_completion_status = m_tls_application->
  1402 			TRACE_FLAGS_DEFAULT,
  1312 		    complete_query_user_permission_for_A_ID(
  1403 			(EAPL("eap_am_type_tls_peap_symbian_c::CompleteQueryUserPermissionForAid eap_status_ok")));
       
  1404 
       
  1405 		m_eap_fast_completion_status = m_tls_application->complete_query_user_permission_for_A_ID(
  1313 			eap_status_ok,
  1406 			eap_status_ok,
  1314 			m_pending_operation );
  1407 			m_pending_operation );
  1315  		}
  1408  		}
  1316   	else //if (userAction == EEapFastNotifierUserActionCancel)
  1409   	else //if (userAction == EEapFastNotifierUserActionCancel)
  1317   		{
  1410   		{
  1318 		EAP_TRACE_DEBUG_SYMBIAN(
  1411 		EAP_TRACE_DEBUG(
  1319 				_L("eap_am_type_tls_peap_symbian_c::CompleteQueryUserPermissionForAid eap_status_user_cancel_authentication"));
  1412 			m_am_tools,
       
  1413 			TRACE_FLAGS_DEFAULT,
       
  1414 			(EAPL("eap_am_type_tls_peap_symbian_c::CompleteQueryUserPermissionForAid eap_status_user_cancel_authentication")));
  1320 
  1415 
  1321 		// comlete query
  1416 		// comlete query
  1322   		m_eap_fast_completion_status = m_tls_application->
  1417   		m_eap_fast_completion_status = m_tls_application->
  1323   		    complete_query_user_permission_for_A_ID(
  1418   		    complete_query_user_permission_for_A_ID(
  1324   			    eap_status_user_cancel_authentication,
  1419   			    eap_status_user_cancel_authentication,
  1337 {
  1432 {
  1338 	if (m_is_client == true)
  1433 	if (m_is_client == true)
  1339 	{
  1434 	{
  1340 		EAP_UNREFERENCED_PARAMETER(configuration_status); // in release
  1435 		EAP_UNREFERENCED_PARAMETER(configuration_status); // in release
  1341 
  1436 
  1342 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("EAP-TLS: Configuration error notification, %d.\n"),
  1437 		EAP_TRACE_DEBUG(
       
  1438 			m_am_tools,
       
  1439 			TRACE_FLAGS_DEFAULT,
       
  1440 			(EAPL("ERROR: EAP-TLS: Configuration error notification, %d.\n"),
  1343 			configuration_status));
  1441 			configuration_status));
  1344 
  1442 
  1345 		// Here we swap the addresses.
  1443 		// Here we swap the addresses.
  1346 		eap_am_network_id_c send_network_id(m_am_tools,
  1444 		eap_am_network_id_c send_network_id(m_am_tools,
  1347 			m_receive_network_id.get_destination_id(),
  1445 			m_receive_network_id.get_destination_id(),
  1394 	}
  1492 	}
  1395 
  1493 
  1396 	//----------------------------------------------------------
  1494 	//----------------------------------------------------------
  1397 
  1495 
  1398 	{
  1496 	{
  1399 		TRAPD(err, EapTlsPeapUtils::ReadCertRowsToArrayL(
  1497 		TRAPD(error, EapTlsPeapUtils::ReadCertRowsToArrayL(
  1400 			m_database,
  1498 			m_database,
  1401 			m_am_tools, 			
  1499 			m_am_tools, 			
  1402 			m_db_user_cert_table_name, 			 
  1500 			m_db_user_cert_table_name, 			 
  1403 			m_index_type, 
  1501 			m_index_type, 
  1404 			m_index, 
  1502 			m_index, 
  1405 			m_tunneling_type,
  1503 			m_tunneling_type,
  1406 			m_allowed_user_certs));
  1504 			m_allowed_user_certs));
  1407 
  1505 
  1408 		if (err != KErrNone)
  1506 		if (error != KErrNone)
  1409 		{
  1507 		{
  1410 			EAP_TRACE_ERROR(m_am_tools, 
  1508 			EAP_TRACE_ERROR(
  1411 				TRACE_FLAGS_DEFAULT, (
  1509 				m_am_tools, 
  1412 				EAPL("eap_am_type_tls_peap_symbian_c::configure(): ReadCertRowsToArrayL, User cert, Error =%d \n"),
  1510 				TRACE_FLAGS_DEFAULT,
  1413 				err));
  1511 				(EAPL("eap_am_type_tls_peap_symbian_c::configure(): ReadCertRowsToArrayL, User cert, Error =%d \n"),
       
  1512 				error));
  1414 		
  1513 		
  1415 			// Convert the leave error code to EAPOL stack error code.
  1514 			// Convert the leave error code to EAPOL stack error code.
  1416 			status = m_am_tools->convert_am_error_to_eapol_error(err);
  1515 			status = m_am_tools->convert_am_error_to_eapol_error(error);
  1417 			return EAP_STATUS_RETURN(m_am_tools, status);
  1516 			return EAP_STATUS_RETURN(m_am_tools, status);
  1418 		}
  1517 		}
  1419 		else
  1518 		else
  1420 		{
  1519 		{
  1421 			EAP_TRACE_DEBUG_SYMBIAN(
  1520 			EAP_TRACE_DEBUG(
  1422 			(_L("eap_am_type_tls_peap_symbian_c::configure, EapTlsPeapUtils::ReadCertRowsToArrayL success, m_allowed_user_certs count=%d"),
  1521 				m_am_tools,
  1423 			m_allowed_user_certs.Count()));	
  1522 				TRACE_FLAGS_DEFAULT,
  1424 		}
  1523 				(EAPL("eap_am_type_tls_peap_symbian_c::configure, EapTlsPeapUtils::ReadCertRowsToArrayL success, m_allowed_user_certs count=%d"),
  1425 
  1524 				m_allowed_user_certs.Count()));	
  1426 		TRAP(err, EapTlsPeapUtils::ReadCertRowsToArrayL(
  1525 		}
       
  1526 
       
  1527 		TRAP(error, EapTlsPeapUtils::ReadCertRowsToArrayL(
  1427 			m_database,
  1528 			m_database,
  1428 			m_am_tools, 			
  1529 			m_am_tools, 			
  1429 			m_db_ca_cert_table_name, 
  1530 			m_db_ca_cert_table_name, 
  1430 			m_index_type, 
  1531 			m_index_type, 
  1431 			m_index, 
  1532 			m_index, 
  1432 			m_tunneling_type,
  1533 			m_tunneling_type,
  1433 			m_allowed_ca_certs));
  1534 			m_allowed_ca_certs));
  1434 		if (err != KErrNone)
  1535 		if (error != KErrNone)
  1435 		{
  1536 		{
  1436 			EAP_TRACE_ERROR(m_am_tools, 
  1537 			EAP_TRACE_ERROR(m_am_tools, 
  1437 				TRACE_FLAGS_DEFAULT, (
  1538 				TRACE_FLAGS_DEFAULT, (
  1438 				EAPL("eap_am_type_tls_peap_symbian_c::configure(): ReadCertRowsToArrayL, CA cert, Error =%d \n"),
  1539 				EAPL("eap_am_type_tls_peap_symbian_c::configure(): ReadCertRowsToArrayL, CA cert, Error =%d \n"),
  1439 				err));
  1540 				error));
  1440 		
  1541 		
  1441 			// Convert the leave error code to EAPOL stack error code.
  1542 			// Convert the leave error code to EAPOL stack error code.
  1442 			status = m_am_tools->convert_am_error_to_eapol_error(err);			
  1543 			status = m_am_tools->convert_am_error_to_eapol_error(error);			
  1443 			return EAP_STATUS_RETURN(m_am_tools, status);
  1544 			return EAP_STATUS_RETURN(m_am_tools, status);
  1444 		}
  1545 		}
  1445 		else
  1546 		else
  1446 		{
  1547 		{
  1447 			EAP_TRACE_DEBUG_SYMBIAN(
  1548 			EAP_TRACE_DEBUG(
  1448 			(_L("eap_am_type_tls_peap_symbian_c::configure, EapTlsPeapUtils::ReadCertRowsToArrayL success, m_allowed_ca_certs count=%d"),
  1549 				m_am_tools,
  1449 			m_allowed_ca_certs.Count()));	
  1550 				TRACE_FLAGS_DEFAULT,
  1450 		}
  1551 				(EAPL("eap_am_type_tls_peap_symbian_c::configure, EapTlsPeapUtils::ReadCertRowsToArrayL success, m_allowed_ca_certs count=%d"),
  1451 		
  1552 				m_allowed_ca_certs.Count()));	
  1452 		TRAP(err, EapTlsPeapUtils::ReadUintRowsToArrayL(
  1553 		}
       
  1554 		
       
  1555 		TRAP(error, EapTlsPeapUtils::ReadUintRowsToArrayL(
  1453 			m_database,
  1556 			m_database,
  1454 			m_am_tools, 
  1557 			m_am_tools, 
  1455 			m_db_cipher_suite_table_name, 
  1558 			m_db_cipher_suite_table_name, 
  1456 			KCipherSuite, 
  1559 			KCipherSuite, 
  1457 			m_index_type, 
  1560 			m_index_type, 
  1458 			m_index, 
  1561 			m_index, 
  1459 			m_tunneling_type,
  1562 			m_tunneling_type,
  1460 			m_allowed_cipher_suites));
  1563 			m_allowed_cipher_suites));
  1461 		if (err != KErrNone)
  1564 		if (error != KErrNone)
  1462 		{
  1565 		{
  1463 			EAP_TRACE_ERROR(m_am_tools, 
  1566 			EAP_TRACE_ERROR(m_am_tools, 
  1464 				TRACE_FLAGS_DEFAULT, (
  1567 				TRACE_FLAGS_DEFAULT, (
  1465 				EAPL("eap_am_type_tls_peap_symbian_c::configure(): ReadUintRowsToArrayL, CipherSuit, Error =%d \n"),
  1568 				EAPL("eap_am_type_tls_peap_symbian_c::configure(): ReadUintRowsToArrayL, CipherSuit, Error =%d \n"),
  1466 				err));
  1569 				error));
  1467 
  1570 
  1468 			// Convert the leave error code to EAPOL stack error code.
  1571 			// Convert the leave error code to EAPOL stack error code.
  1469 			status = m_am_tools->convert_am_error_to_eapol_error(err);			
  1572 			status = m_am_tools->convert_am_error_to_eapol_error(error);			
  1470 			return EAP_STATUS_RETURN(m_am_tools, status);
  1573 			return EAP_STATUS_RETURN(m_am_tools, status);
  1471 		}	
  1574 		}	
  1472 	}
  1575 	}
  1473 
  1576 
  1474 	//----------------------------------------------------------
  1577 	//----------------------------------------------------------
  1483 #endif
  1586 #endif
  1484 
  1587 
  1485 		
  1588 		
  1486 		)
  1589 		)
  1487 	{
  1590 	{
  1488 		TRAPD(err, EapTlsPeapUtils::GetTunnelingExpandedEapDataL(
  1591 		TRAPD(error, EapTlsPeapUtils::GetTunnelingExpandedEapDataL(
  1489 			m_database,
  1592 			m_database,
  1490 			m_am_tools,
  1593 			m_am_tools,
  1491 			m_enabled_tunneling_exp_eap_array,
  1594 			m_enabled_tunneling_exp_eap_array,
  1492 			m_disabled_tunneling_exp_eap_array,
  1595 			m_disabled_tunneling_exp_eap_array,
  1493 			m_index_type,
  1596 			m_index_type,
  1494 			m_index,
  1597 			m_index,
  1495 			m_tunneling_type,
  1598 			m_tunneling_type,
  1496 			m_current_eap_type));
  1599 			m_current_eap_type));
  1497 	
  1600 	
  1498 		if (err != KErrNone)
  1601 		if (error != KErrNone)
  1499 		{
  1602 		{
  1500 			EAP_TRACE_ERROR(m_am_tools, 
  1603 			EAP_TRACE_ERROR(m_am_tools, 
  1501 				TRACE_FLAGS_DEFAULT, (
  1604 				TRACE_FLAGS_DEFAULT, (
  1502 				EAPL("eap_am_type_tls_peap_symbian_c::configure(): GetEapDataL or GetTunnelingExpandedEapDataL, Error =%d \n"),
  1605 				EAPL("eap_am_type_tls_peap_symbian_c::configure(): GetEapDataL or GetTunnelingExpandedEapDataL, Error =%d \n"),
  1503 				err));
  1606 				error));
  1504 
  1607 
  1505 			// Convert the leave error code to EAPOL stack error code.
  1608 			// Convert the leave error code to EAPOL stack error code.
  1506 			status = m_am_tools->convert_am_error_to_eapol_error(err);			
  1609 			status = m_am_tools->convert_am_error_to_eapol_error(error);			
  1507 			return EAP_STATUS_RETURN(m_am_tools, status);
  1610 			return EAP_STATUS_RETURN(m_am_tools, status);
  1508 		}
  1611 		}
  1509 	}
  1612 	}
  1510 
  1613 
  1511 	//----------------------------------------------------------
  1614 	//----------------------------------------------------------
  1900 		if (m_allowed_ca_certs.Count() == 0)
  2003 		if (m_allowed_ca_certs.Count() == 0)
  1901 		{
  2004 		{
  1902 			// needed because of nonworking wrong settings
  2005 			// needed because of nonworking wrong settings
  1903 #if defined(USE_FAST_EAP_TYPE)
  2006 #if defined(USE_FAST_EAP_TYPE)
  1904 			if(m_current_eap_type == eap_type_fast
  2007 			if(m_current_eap_type == eap_type_fast
  1905 				&& m_serv_auth_prov_mode != true)
  2008 				&& m_serv_unauth_prov_mode == true)
  1906 			{
  2009 			{
  1907 				// In the case of EAP-FAST, CA cert is must if m_serv_auth_prov_mode is TRUE.
  2010 				// In the case of EAP-FAST, no CA cert is needed if m_serv_unauth_prov_mode is true.
  1908 				status = eap_status_ok;
  2011 				status = eap_status_ok;
  1909 				
  2012 				
  1910 				EAP_TRACE_DEBUG(
  2013 				EAP_TRACE_DEBUG(
  1911 					m_am_tools, 
  2014 					m_am_tools, 
  1912 					TRACE_FLAGS_DEFAULT,
  2015 					TRACE_FLAGS_DEFAULT,
  1913 					(EAPL("eap_am_type_tls_peap_symbian_c::configure(): No CA certificate but exception for EAP-FAST as m_serv_auth_prov_mode is FALSE and for all m_serv_unauth_prov_mode \n")));
  2016 					(EAPL("eap_am_type_tls_peap_symbian_c::configure(): No CA certificate but exception for EAP-FAST because m_serv_unauth_prov_mode is true\n")));
  1914 			}
  2017 			}
  1915 			else	
  2018 			else	
  1916 #endif // #if defined(USE_FAST_EAP_TYPE)
  2019 #endif // #if defined(USE_FAST_EAP_TYPE)
  1917 			{
  2020 			{
  1918 				EAP_TRACE_ERROR(
  2021 				EAP_TRACE_ERROR(
  1919 					m_am_tools, 
  2022 					m_am_tools, 
  1920 					TRACE_FLAGS_DEFAULT,
  2023 					TRACE_FLAGS_DEFAULT,
  1921 					(EAPL("eap_am_type_tls_peap_symbian_c::configure(): Error - No CA certificate\n")));
  2024 					(EAPL("WARNING: eap_am_type_tls_peap_symbian_c::configure(): No CA certificate and no unauthenticated provision\n")));
  1922 			
  2025 			
  1923 				// No root certificate selected. Cannot continue.
  2026 				// No root certificate selected and no unauthenticated provision.
  1924 				status = eap_status_ca_certificate_unknown;
  2027 				// Cannot continue if no tunnel PAC exists. That can be checked only on authentication.
  1925 				send_error_notification(status);
       
  1926 			}			
  2028 			}			
  1927 		}
  2029 		}
  1928 		else
  2030 		else
  1929 		{
  2031 		{
  1930 			EAP_TRACE_DEBUG(
  2032 			EAP_TRACE_DEBUG(
  1951 		{
  2053 		{
  1952 			m_use_manual_realm = true;
  2054 			m_use_manual_realm = true;
  1953 
  2055 
  1954 			if (m_use_manual_username == false)
  2056 			if (m_use_manual_username == false)
  1955 			{
  2057 			{
  1956 				TRAPD(err, status=ConfigureL());
  2058 				TRAPD(error, status=ConfigureL());
  1957 				if (err != KErrNone)
  2059 				if (error != KErrNone)
  1958 				{
  2060 				{
  1959 					EAP_TRACE_ERROR(m_am_tools, 
  2061 					EAP_TRACE_ERROR(m_am_tools, 
  1960 							TRACE_FLAGS_DEFAULT, (
  2062 							TRACE_FLAGS_DEFAULT, (
  1961 							EAPL("eap_am_type_tls_peap_symbian_c::configure LEAVE from ConfigureL, Error =%d \n"),
  2063 							EAPL("eap_am_type_tls_peap_symbian_c::configure LEAVE from ConfigureL, Error =%d \n"),
  1962 							err));
  2064 							error));
  1963 				}
  2065 				}
  1964 			}
  2066 			}
  1965 		}
  2067 		}
  1966 #endif // #if defined(USE_FAST_EAP_TYPE)
  2068 #endif // #if defined(USE_FAST_EAP_TYPE)
  1967 	}
  2069 	}
  1990 #endif // #if defined(USE_FAST_EAP_TYPE)
  2092 #endif // #if defined(USE_FAST_EAP_TYPE)
  1991 	    {
  2093 	    {
  1992 			EAP_TRACE_ERROR(
  2094 			EAP_TRACE_ERROR(
  1993 				m_am_tools, 
  2095 				m_am_tools, 
  1994 				TRACE_FLAGS_DEFAULT,
  2096 				TRACE_FLAGS_DEFAULT,
  1995 				(EAPL("eap_am_type_tls_peap_symbian_c::configure(): Error - No USER certificate\n")));
  2097 				(EAPL("ERROR: eap_am_type_tls_peap_symbian_c::configure(): Error - No USER certificate\n")));
  1996 		
  2098 		
  1997 			// No user certificate selected. Cannot continue.
  2099 			// No user certificate selected. Cannot continue.
  1998 			status = eap_status_user_certificate_unknown;
  2100 			status = eap_status_user_certificate_unknown;
  1999 			send_error_notification(status);
  2101 			send_error_notification(status);
  2000 	    }
  2102 	    }
  2001 	}
  2103 	}
  2002 
  2104 
  2003 	if (m_allowed_cipher_suites.Count() == 0)
  2105 #if defined(USE_FAST_EAP_TYPE)
  2004 	{
  2106 	if (m_is_pac_store_initialization == false)
  2005 		EAP_TRACE_ERROR(
  2107 #endif //#if defined(USE_FAST_EAP_TYPE)
  2006 			m_am_tools, 
  2108 	{
  2007 			TRACE_FLAGS_DEFAULT,
  2109 		if (m_allowed_cipher_suites.Count() == 0)
  2008 			(EAPL("eap_am_type_tls_peap_symbian_c::configure(): Error - No cipher suit\n")));
  2110 		{
  2009 
  2111 			EAP_TRACE_ERROR(
  2010 		// No sipher suites selected. Cannot continue.
  2112 				m_am_tools, 
  2011 		status = eap_status_illegal_cipher_suite;
  2113 				TRACE_FLAGS_DEFAULT,
  2012 		send_error_notification(status);
  2114 				(EAPL("eap_am_type_tls_peap_symbian_c::configure(): Error - No cipher suit\n")));
  2013 	}
  2115 
  2014 	else
  2116 			// No sipher suites selected. Cannot continue.
  2015 	{
  2117 			status = eap_status_illegal_cipher_suite;
  2016 		EAP_TRACE_DEBUG(
  2118 			send_error_notification(status);
  2017 			m_am_tools, 
  2119 		}
  2018 			TRACE_FLAGS_DEFAULT,
  2120 		else
  2019 			(EAPL("eap_am_type_tls_peap_symbian_c::configure(): %d cipher suites selected.\n"),
  2121 		{
  2020 			m_allowed_cipher_suites.Count()));
  2122 			EAP_TRACE_DEBUG(
       
  2123 				m_am_tools, 
       
  2124 				TRACE_FLAGS_DEFAULT,
       
  2125 				(EAPL("eap_am_type_tls_peap_symbian_c::configure(): %d cipher suites selected.\n"),
       
  2126 				m_allowed_cipher_suites.Count()));
       
  2127 		}
  2021 	}
  2128 	}
  2022 
  2129 
  2023 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2130 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2024 
  2131 
  2025 	if (status != eap_status_ok)
  2132 	if (status != eap_status_ok)
  2069 		u32_t toBinaryPtr8SizeForTools = static_cast<u32_t>(KMacAddressLength*2);
  2176 		u32_t toBinaryPtr8SizeForTools = static_cast<u32_t>(KMacAddressLength*2);
  2070 		u32_t fromTextPtr8SizeForTools = static_cast<u32_t>(tempUserBufPtr8.Size());
  2177 		u32_t fromTextPtr8SizeForTools = static_cast<u32_t>(tempUserBufPtr8.Size());
  2071 		
  2178 		
  2072 		u8_t * toBinaryPtr8ForTools = const_cast<u8_t *>(ConvertedtempUserBuf8->Ptr());
  2179 		u8_t * toBinaryPtr8ForTools = const_cast<u8_t *>(ConvertedtempUserBuf8->Ptr());
  2073 		
  2180 		
  2074 		EAP_TRACE_DEBUG_SYMBIAN(
  2181 		EAP_TRACE_DEBUG(
  2075 		(_L("eap_am_type_tls_peap_symbian_c::configure,Call convert_bytes_to_hex_ascii, toBinaryPtr8SizeForTools=%d"),
  2182 			m_am_tools,
  2076 		toBinaryPtr8SizeForTools));	
  2183 			TRACE_FLAGS_DEFAULT,
       
  2184 			(EAPL("eap_am_type_tls_peap_symbian_c::configure,Call convert_bytes_to_hex_ascii, toBinaryPtr8SizeForTools=%d"),
       
  2185 			toBinaryPtr8SizeForTools));	
  2077 		
  2186 		
  2078 		// Convert hex to ascii string.
  2187 		// Convert hex to ascii string.
  2079 		status = m_am_tools->convert_bytes_to_hex_ascii(
  2188 		status = m_am_tools->convert_bytes_to_hex_ascii(
  2080 			tempUserBufPtr8.Ptr(),
  2189 			tempUserBufPtr8.Ptr(),
  2081 			fromTextPtr8SizeForTools,
  2190 			fromTextPtr8SizeForTools,
  2082 			toBinaryPtr8ForTools,
  2191 			toBinaryPtr8ForTools,
  2083 			&toBinaryPtr8SizeForTools);	
  2192 			&toBinaryPtr8SizeForTools);	
  2084 
  2193 
  2085 		if(status != eap_status_ok)
  2194 		if(status != eap_status_ok)
  2086 		{
  2195 			{
  2087 			EAP_TRACE_DEBUG_SYMBIAN(
  2196 			EAP_TRACE_DEBUG(
  2088 			(_L("eap_am_type_tls_peap_symbian_c::configure, Error in convert_hex_ascii_to_bytes. status=%d"),
  2197 				m_am_tools,
  2089 			status));		
  2198 				TRACE_FLAGS_DEFAULT,
       
  2199 				(EAPL("ERROR: eap_am_type_tls_peap_symbian_c::configure, Error in convert_hex_ascii_to_bytes. status=%d"),
       
  2200 				status));		
  2090 		
  2201 		
  2091 			User::Leave(m_am_tools->convert_eapol_error_to_am_error(status));
  2202 			User::Leave(m_am_tools->convert_eapol_error_to_am_error(status));
  2092 		}
  2203 			}
  2093 		
  2204 		
  2094 		ConvertedtempUserBufPtr8.SetLength(KMacAddressLength*2);
  2205 		ConvertedtempUserBufPtr8.SetLength(KMacAddressLength*2);
  2095 		
  2206 		
  2096 		EAP_TRACE_DATA_DEBUG(
  2207 		EAP_TRACE_DATA_DEBUG(
  2097 				m_am_tools,
  2208 				m_am_tools,
  2118 
  2229 
  2119 		status = m_manual_username.set_copy_of_buffer(
  2230 		status = m_manual_username.set_copy_of_buffer(
  2120 				bufPtr.Ptr(), 
  2231 				bufPtr.Ptr(), 
  2121 				bufPtr.Size());
  2232 				bufPtr.Size());
  2122 		}
  2233 		}
       
  2234 
  2123 	EAP_TRACE_DEBUG(
  2235 	EAP_TRACE_DEBUG(
  2124 			m_am_tools,
  2236 			m_am_tools,
  2125 			TRACE_FLAGS_DEFAULT,
  2237 			TRACE_FLAGS_DEFAULT,
  2126 			(EAPL("eap_am_type_tls_peap_symbian_c::config: UserName = %s \n"),
  2238 			(EAPL("eap_am_type_tls_peap_symbian_c::config: UserName = %s \n"),
  2127 			 bufPtr.Ptr(), bufPtr.Size()));
  2239 			 bufPtr.Ptr(), bufPtr.Size()));
  2130 	CleanupStack::PopAndDestroy(tempUserBuf8);
  2242 	CleanupStack::PopAndDestroy(tempUserBuf8);
  2131 	CleanupStack::PopAndDestroy(buf);
  2243 	CleanupStack::PopAndDestroy(buf);
  2132 
  2244 
  2133 	m_use_manual_username = true;
  2245 	m_use_manual_username = true;
  2134 	
  2246 	
  2135 	return status;
  2247 	return EAP_STATUS_RETURN(m_am_tools, status);
  2136 }
  2248 }
  2137 
  2249 
  2138 #endif // #if defined(USE_FAST_EAP_TYPE)
  2250 #endif // #if defined(USE_FAST_EAP_TYPE)
  2139 
  2251 
  2140 //--------------------------------------------------
  2252 //--------------------------------------------------
  2153 	const bool true_when_successful,
  2265 	const bool true_when_successful,
  2154 	const tls_session_type_e tls_session_type)
  2266 	const tls_session_type_e tls_session_type)
  2155 {
  2267 {
  2156 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  2268 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  2157 
  2269 
       
  2270 #if defined(USE_FAST_EAP_TYPE)
       
  2271 	bool serv_unauth_prov_mode(m_serv_unauth_prov_mode);
       
  2272 #else
       
  2273 	bool serv_unauth_prov_mode(false);
       
  2274 #endif
       
  2275 
       
  2276 	EAP_TRACE_DEBUG(
       
  2277 		m_am_tools,
       
  2278 		TRACE_FLAGS_DEFAULT,
       
  2279 		(EAPL("TLS: %s: function: eap_am_type_tls_peap_symbian_c::authentication_finished(): true_when_successful=%d, tls_session_type=%d=%s, m_serv_unauth_prov_mode=%d\n"),
       
  2280 		(m_is_client == true ? "client": "server"),
       
  2281 		true_when_successful,
       
  2282 		tls_session_type,
       
  2283 		eap_tls_trace_string_c::get_tls_session_type_string(tls_session_type),
       
  2284 		serv_unauth_prov_mode));
       
  2285 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_type_tls_peap_symbian_c::authentication_finished()");
       
  2286 
  2158 	eap_status_e status(eap_status_ok);
  2287 	eap_status_e status(eap_status_ok);
  2159 
  2288 
  2160 	TRAPD(err, authentication_finishedL(true_when_successful, tls_session_type));
  2289 	TRAPD(error, authentication_finishedL(true_when_successful, tls_session_type));
  2161 	if (err != KErrNone)
  2290 	if (error != KErrNone)
  2162 	{
  2291 	{
       
  2292 		EAP_UNREFERENCED_PARAMETER(serv_unauth_prov_mode); // in release
  2163 		EAP_TRACE_DEBUG(m_am_tools, 
  2293 		EAP_TRACE_DEBUG(m_am_tools, 
  2164 			TRACE_FLAGS_DEFAULT, 
  2294 			TRACE_FLAGS_DEFAULT, 
  2165 			(EAPL("eap_am_type_tls_peap_symbian_c::authentication_finished, TRAP ERROR=%d\n"),
  2295 			(EAPL("ERROR: eap_am_type_tls_peap_symbian_c::authentication_finished(): TRAP error=%d\n"),
  2166 			err));	
  2296 			error));	
  2167 	
  2297 	
  2168 		status = m_am_tools->convert_am_error_to_eapol_error(err);
  2298 		status = m_am_tools->convert_am_error_to_eapol_error(error);
  2169 		send_error_notification(status);
  2299 		send_error_notification(status);
  2170 	}
  2300 	}
  2171 
  2301 
  2172 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2302 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2173 	return EAP_STATUS_RETURN(m_am_tools, status);
  2303 	return EAP_STATUS_RETURN(m_am_tools, status);
  2179 	const bool true_when_successful,
  2309 	const bool true_when_successful,
  2180 	const tls_session_type_e tls_session_type)
  2310 	const tls_session_type_e tls_session_type)
  2181 {
  2311 {
  2182 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  2312 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  2183 
  2313 
       
  2314 	EAP_TRACE_DEBUG(
       
  2315 		m_am_tools,
       
  2316 		TRACE_FLAGS_DEFAULT,
       
  2317 		(EAPL("eap_am_type_tls_peap_symbian_c::authentication_finishedL()")));
       
  2318 
  2184 	if (m_is_client == false)
  2319 	if (m_is_client == false)
  2185 	{
  2320 	{
  2186 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2321 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2187 		return;
  2322 		return;
  2188 	}
  2323 	}
  2189 	
  2324 	
  2190 	// In EAP-FAST this could be called when provisioning is successfull.
  2325 	// In EAP-FAST this could be called when provisioning is successfull.
  2191 	// If there was provisioning, We have to toggle 
  2326 	// If there was provisioning, We have to toggle 
  2192 	// cf_str_EAP_FAST_allow_server_unauthenticated_provisioning_mode_ADHP_literal 
  2327 	// cf_str_EAP_FAST_allow_server_unauthenticated_provisioning_mode_ADHP_literal 
  2193 	
  2328 
  2194 #if defined(USE_FAST_EAP_TYPE)
  2329 #if defined(USE_FAST_EAP_TYPE)
  2195 	
  2330 	if(m_is_pac_store_initialization == false)
  2196 	if(m_current_eap_type == eap_type_fast &&
  2331 #endif //#if defined(USE_FAST_EAP_TYPE)
  2197 	   m_serv_unauth_prov_mode == true)
  2332 	{
  2198 	{		
  2333 
  2199 		EAP_TRACE_DEBUG_SYMBIAN(
  2334 #if defined(USE_FAST_EAP_TYPE)
  2200 		(_L("eap_am_type_tls_peap_symbian_c::authentication_finishedL EAP-FAST Provisioning!")));			
  2335 	
  2201 		
  2336 		if(m_current_eap_type == eap_type_fast
  2202 		eap_variable_data_c unauthProvMode(m_am_tools);		
  2337 			&& m_serv_unauth_prov_mode == true)
  2203 		unauthProvMode.set_copy_of_buffer(
  2338 		{
       
  2339 			EAP_TRACE_DEBUG(
       
  2340 				m_am_tools,
       
  2341 				TRACE_FLAGS_DEFAULT,
       
  2342 				(EAPL("eap_am_type_tls_peap_symbian_c::authentication_finishedL(): EAP-FAST Provisioning!")));
       
  2343 
       
  2344 			eap_variable_data_c unauthProvMode(m_am_tools);
       
  2345 
       
  2346 			eap_status_e status = unauthProvMode.set_copy_of_buffer(
  2204 				&default_EAP_FAST_Unauth_Prov_Mode_Allowed, 
  2347 				&default_EAP_FAST_Unauth_Prov_Mode_Allowed, 
  2205 				sizeof(default_EAP_FAST_Unauth_Prov_Mode_Allowed));
  2348 				sizeof(default_EAP_FAST_Unauth_Prov_Mode_Allowed));
  2206 		
  2349 			if (status != eap_status_ok)
  2207 		EapTlsPeapUtils::SetEapSettingsDataL(
  2350 			{
  2208 			m_database,
  2351 				User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
  2209 			m_index_type,
  2352 			}
  2210 			m_index,
  2353 
  2211 			m_tunneling_type,
  2354 			EapTlsPeapUtils::SetEapSettingsDataL(
  2212 			m_current_eap_type,
  2355 				m_database,
  2213 			cf_str_EAP_FAST_allow_server_unauthenticated_provisioning_mode_ADHP_literal,
  2356 				m_index_type,
  2214 			&unauthProvMode);	
  2357 				m_index,
  2215 		
  2358 				m_tunneling_type,
  2216 		EAP_TRACE_DEBUG_SYMBIAN(
  2359 				m_current_eap_type,
  2217 		(_L("eap_am_type_tls_peap_symbian_c::authentication_finishedL Unauth Prov mode set to default (NO)!")));					
  2360 				cf_str_EAP_FAST_allow_server_unauthenticated_provisioning_mode_ADHP_literal,
  2218 	}
  2361 				&unauthProvMode);
  2219 #endif
  2362 
  2220 	
  2363 			EAP_TRACE_DEBUG(
  2221 	// Store the authentication time if the full authentication is successful
  2364 				m_am_tools,
  2222 	if (true_when_successful == true
  2365 				TRACE_FLAGS_DEFAULT,
  2223 		&& tls_session_type == tls_session_type_full_authentication)
  2366 				(EAPL("eap_am_type_tls_peap_symbian_c::authentication_finishedL(): Unauth Prov mode set to default (NO)!")));
  2224 	{
  2367 		}
  2225 		store_authentication_timeL();
  2368 
  2226 	}
  2369 #endif //#if defined(USE_FAST_EAP_TYPE)
  2227 	
  2370 	
  2228 	if (m_latest_alert_description == tls_alert_description_certificate_expired)
  2371 		// Store the authentication time if the full authentication is successful
  2229 	{
  2372 		if (true_when_successful == true
  2230 		send_error_notification(eap_status_certificate_expired);
  2373 			&& tls_session_type == tls_session_type_full_authentication)
  2231 	}
  2374 		{
  2232 	else if (m_latest_alert_description == tls_alert_description_bad_certificate)
  2375 			store_authentication_timeL();
  2233 	{
  2376 		}
  2234 		send_error_notification(eap_status_bad_certificate);
  2377 		
  2235 	}
  2378 		if (m_latest_alert_description == tls_alert_description_certificate_expired)
  2236 	else if (m_latest_alert_description == tls_alert_description_unsupported_certificate)
  2379 		{
  2237 	{
  2380 			send_error_notification(eap_status_certificate_expired);
  2238 		send_error_notification(eap_status_unsupported_certificate);
  2381 		}
  2239 	}
  2382 		else if (m_latest_alert_description == tls_alert_description_bad_certificate)
  2240 	else if (m_latest_alert_description == tls_alert_description_certificate_revoked)
  2383 		{
  2241 	{
  2384 			send_error_notification(eap_status_bad_certificate);
  2242 		send_error_notification(eap_status_certificate_revoked);
  2385 		}
  2243 	}
  2386 		else if (m_latest_alert_description == tls_alert_description_unsupported_certificate)
  2244 	else if (m_latest_alert_description == tls_alert_description_certificate_unknown)
  2387 		{
  2245 	{
  2388 			send_error_notification(eap_status_unsupported_certificate);
  2246 		send_error_notification(eap_status_user_certificate_unknown);
  2389 		}
  2247 	}
  2390 		else if (m_latest_alert_description == tls_alert_description_certificate_revoked)
  2248 	else if(m_latest_alert_description != tls_alert_description_none)
  2391 		{
  2249 	{
  2392 			send_error_notification(eap_status_certificate_revoked);
  2250 		// Send error notification any alert other than tls_alert_description_none.
  2393 		}
  2251 		send_error_notification(eap_status_process_general_error);
  2394 		else if (m_latest_alert_description == tls_alert_description_certificate_unknown)
  2252 	}
  2395 		{
  2253 
  2396 			send_error_notification(eap_status_user_certificate_unknown);
  2254 	if (true_when_successful == false)
  2397 		}
  2255 	{
  2398 		else if(m_latest_alert_description != tls_alert_description_none)
  2256 		ResetSessionIdL();	
  2399 		{
       
  2400 			// Send error notification any alert other than tls_alert_description_none.
       
  2401 			send_error_notification(eap_status_process_general_error);
       
  2402 		}
       
  2403 
       
  2404 		if (true_when_successful == false)
       
  2405 		{
       
  2406 			ResetSessionIdL();	
       
  2407 		}
  2257 	}
  2408 	}
  2258 
  2409 
  2259 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2410 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2260 }
  2411 }
  2261 
  2412 
  2279 		
  2430 		
  2280 	// Get the own certificate only if it has already been retrieved
  2431 	// Get the own certificate only if it has already been retrieved
  2281 	if (m_own_certificate == 0)
  2432 	if (m_own_certificate == 0)
  2282 	{
  2433 	{
  2283 		// Get the matching certificates. This function call is completed asyncronously by complete_get_matching_certificates() function call.
  2434 		// Get the matching certificates. This function call is completed asyncronously by complete_get_matching_certificates() function call.
  2284 		TRAPD(err, m_cert_if->GetMatchingCertificatesL(
  2435 		TRAPD(error, m_cert_if->GetMatchingCertificatesL(
  2285 			m_allowed_user_certs, 
  2436 			m_allowed_user_certs, 
  2286 			EFalse, 
  2437 			EFalse, 
  2287 			0, 
  2438 			0, 
  2288 			EFalse, 
  2439 			EFalse, 
  2289 			0, 
  2440 			0, 
  2290 			ETrue, 
  2441 			ETrue, 
  2291 			m_allowed_cipher_suites));
  2442 			m_allowed_cipher_suites));
  2292 		if (err != KErrNone)
  2443 		if (error != KErrNone)
  2293 		{
  2444 		{
  2294 			status = m_am_tools->convert_am_error_to_eapol_error(err);
  2445 			status = m_am_tools->convert_am_error_to_eapol_error(error);
  2295 		}
  2446 		}
  2296 		else
  2447 		else
  2297 		{
  2448 		{
  2298 			status = eap_status_pending_request;
  2449 			status = eap_status_pending_request;
  2299 		}
  2450 		}
  2417 		|| aEqual == EFalse)
  2568 		|| aEqual == EFalse)
  2418 	{
  2569 	{
  2419 		delete m_own_certificate;
  2570 		delete m_own_certificate;
  2420 	
  2571 	
  2421 		// Create a copy of the certificate
  2572 		// Create a copy of the certificate
  2422 		TRAPD(err, m_own_certificate = CX509Certificate::NewL(*aCertChain[0]));
  2573 		TRAPD(error, m_own_certificate = CX509Certificate::NewL(*aCertChain[0]));
  2423 		if (err != KErrNone)
  2574 		if (error != KErrNone)
  2424 		{				
  2575 		{				
  2425 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2576 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2426 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
  2577 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
  2427 		}
  2578 		}
  2428 	}
  2579 	}
  2432 	case EHandlingIdentityQuery:
  2583 	case EHandlingIdentityQuery:
  2433 		{
  2584 		{
  2434 			eap_variable_data_c subjectIdentity(m_am_tools);
  2585 			eap_variable_data_c subjectIdentity(m_am_tools);
  2435 			eap_variable_data_c IssuerIdentity(m_am_tools);
  2586 			eap_variable_data_c IssuerIdentity(m_am_tools);
  2436 			
  2587 			
  2437 			TRAPD(err, get_identity_from_alternative_nameL(m_own_certificate, &subjectIdentity));
  2588 			TRAPD(error, get_identity_from_alternative_nameL(m_own_certificate, &subjectIdentity));
  2438 			if (err != KErrNone)
  2589 			if (error != KErrNone)
  2439 			{
  2590 			{
  2440 				EAP_TRACE_DEBUG(
  2591 				EAP_TRACE_DEBUG(
  2441 					m_am_tools,
  2592 					m_am_tools,
  2442 					TRACE_FLAGS_DEFAULT,
  2593 					TRACE_FLAGS_DEFAULT,
  2443 					(EAPL("Could not find identity in SubjectAltName field.\n")));
  2594 					(EAPL("Could not find identity in SubjectAltName field.\n")));
  2444 
  2595 
  2445 				TRAPD(err, get_identities_from_distinguished_namesL(m_own_certificate, &subjectIdentity, &IssuerIdentity));
  2596 				TRAPD(error, get_identities_from_distinguished_namesL(m_own_certificate, &subjectIdentity, &IssuerIdentity));
  2446 				if (err != KErrNone)
  2597 				if (error != KErrNone)
  2447 				{
  2598 				{
  2448 					EAP_TRACE_DEBUG(
  2599 					EAP_TRACE_DEBUG(
  2449 						m_am_tools,
  2600 						m_am_tools,
  2450 						TRACE_FLAGS_DEFAULT,
  2601 						TRACE_FLAGS_DEFAULT,
  2451 						(EAPL("ERROR: Could not find subject identity from certificate.\n")));
  2602 						(EAPL("ERROR: Could not find subject identity from certificate.\n")));
  2686 		|| aEqual == EFalse)
  2837 		|| aEqual == EFalse)
  2687 	{
  2838 	{
  2688 		delete m_ca_certificate;
  2839 		delete m_ca_certificate;
  2689 	
  2840 	
  2690 		// Create a copy of the certificate
  2841 		// Create a copy of the certificate
  2691 		TRAPD(err, m_ca_certificate = CX509Certificate::NewL(*aCertChain[0]));
  2842 		TRAPD(error, m_ca_certificate = CX509Certificate::NewL(*aCertChain[0]));
  2692 		if (err != KErrNone)
  2843 		if (error != KErrNone)
  2693 		{				
  2844 		{				
  2694 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2845 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2695 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
  2846 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
  2696 		}
  2847 		}
  2697 	}
  2848 	}
  2913 	{
  3064 	{
  2914 		// Start parsing the alt. name
  3065 		// Start parsing the alt. name
  2915 		TPtrC8 name = ext->Data();
  3066 		TPtrC8 name = ext->Data();
  2916 	
  3067 	
  2917 		EAP_TRACE_DATA_DEBUG(
  3068 		EAP_TRACE_DATA_DEBUG(
  2918 		m_am_tools,
  3069 			m_am_tools,
  2919 		TRACE_FLAGS_DEFAULT,
  3070 			TRACE_FLAGS_DEFAULT,
  2920 		(EAPL("eap_am_type_tls_peap_symbian_c::get_identity_from_alternative_nameL: Alt Name from Cert extn:"),
  3071 			(EAPL("eap_am_type_tls_peap_symbian_c::get_identity_from_alternative_nameL: Alt Name from Cert extn:"),
  2921  		name.Ptr(),
  3072  			name.Ptr(),
  2922  		name.Size()));		 			
  3073  			name.Size()));		 			
  2923 
  3074 
  2924 		if(0 == name.Size())
  3075 		if(0 == name.Size())
  2925 		{
  3076 		{
  2926 			EAP_TRACE_DEBUG(
  3077 			EAP_TRACE_DEBUG(
  2927 			m_am_tools, 
  3078 				m_am_tools, 
  2928 			TRACE_FLAGS_DEFAULT, 
  3079 				TRACE_FLAGS_DEFAULT, 
  2929 			(EAPL("ERROR:get_identity_from_alternative_nameL:No Alternative Name in cert extension\n")));
  3080 				(EAPL("ERROR: get_identity_from_alternative_nameL:No Alternative Name in cert extension\n")));
  2930 					
  3081 					
  2931 			User::Leave(KErrNotFound);			
  3082 			User::Leave(KErrNotFound);			
  2932 		}
  3083 		}
  2933 		
  3084 		
  2934 		// Extension is inside an octet string
  3085 		// Extension is inside an octet string
  2937 		HBufC8* pOct = octetstring.DecodeDERL(name, pos);		
  3088 		HBufC8* pOct = octetstring.DecodeDERL(name, pos);		
  2938 
  3089 
  2939 		if(NULL == pOct)
  3090 		if(NULL == pOct)
  2940 		{
  3091 		{
  2941 			EAP_TRACE_DEBUG(
  3092 			EAP_TRACE_DEBUG(
  2942 			m_am_tools, 
  3093 				m_am_tools, 
  2943 			TRACE_FLAGS_DEFAULT, 
  3094 				TRACE_FLAGS_DEFAULT, 
  2944 			(EAPL("ERROR:get_identity_from_alternative_nameL:No ASN1DecOctetString or DecodeDER failed\n")));
  3095 				(EAPL("ERROR:get_identity_from_alternative_nameL:No ASN1DecOctetString or DecodeDER failed\n")));
  2945 					
  3096 					
  2946 			User::Leave(KErrNotFound);			
  3097 			User::Leave(KErrNotFound);			
  2947 		}
  3098 		}
  2948 
  3099 
  2949 		CleanupStack::PushL(pOct);
  3100 		CleanupStack::PushL(pOct);
  2954 		CArrayPtrFlat<TASN1DecGeneric>* pSeq = seq.DecodeDERLC(pOct->Des(), pos);
  3105 		CArrayPtrFlat<TASN1DecGeneric>* pSeq = seq.DecodeDERLC(pOct->Des(), pos);
  2955 		
  3106 		
  2956 		if(0 == pSeq->Count())
  3107 		if(0 == pSeq->Count())
  2957 		{
  3108 		{
  2958 			EAP_TRACE_DEBUG(
  3109 			EAP_TRACE_DEBUG(
  2959 			m_am_tools, 
  3110 				m_am_tools, 
  2960 			TRACE_FLAGS_DEFAULT, 
  3111 				TRACE_FLAGS_DEFAULT, 
  2961 			(EAPL("ERROR:get_identity_from_alternative_nameL:No ASN1DecSequence or DecodeDER failed\n")));
  3112 				(EAPL("ERROR: get_identity_from_alternative_nameL:No ASN1DecSequence or DecodeDER failed\n")));
  2962 					
  3113 					
  2963 			User::Leave(KErrNotFound);			
  3114 			User::Leave(KErrNotFound);			
  2964 		}
  3115 		}
  2965 		
  3116 		
  2966 		// Get the first item in the sequence (ignore other possible items)
  3117 		// Get the first item in the sequence (ignore other possible items)
  2967 		TASN1DecGeneric* gen;
  3118 		TASN1DecGeneric* gen;
  2968 		gen = pSeq->At(0);
  3119 		gen = pSeq->At(0);
  2969 		if (gen == 0)
  3120 		if (gen == 0)
  2970 		{
  3121 		{
  2971 			EAP_TRACE_DEBUG(
  3122 			EAP_TRACE_DEBUG(
  2972 			m_am_tools, 
  3123 				m_am_tools, 
  2973 			TRACE_FLAGS_DEFAULT, 
  3124 				TRACE_FLAGS_DEFAULT, 
  2974 			(EAPL("ERROR:get_identity_from_alternative_nameL:No ASN1DecGeneric\n")));
  3125 				(EAPL("ERROR: get_identity_from_alternative_nameL:No ASN1DecGeneric\n")));
  2975 
  3126 
  2976 			User::Leave(KErrNotFound);
  3127 			User::Leave(KErrNotFound);
  2977 		}
  3128 		}
  2978 		if (gen->Tag() != 0)  // Only parse otherName in the CHOICE at the moment.
  3129 		if (gen->Tag() != 0)  // Only parse otherName in the CHOICE at the moment.
  2979 		{
  3130 		{
  2980 			EAP_TRACE_DEBUG(
  3131 			EAP_TRACE_DEBUG(
  2981 			m_am_tools, 
  3132 				m_am_tools, 
  2982 			TRACE_FLAGS_DEFAULT, 
  3133 				TRACE_FLAGS_DEFAULT, 
  2983 			(EAPL("ERROR:get_identity_from_alternative_nameL:Some Tag in ASN1DecGeneric\n")));
  3134 				(EAPL("ERROR: get_identity_from_alternative_nameL:Some Tag in ASN1DecGeneric\n")));
  2984 		
  3135 		
  2985 			User::Leave(KErrNotSupported);
  3136 			User::Leave(KErrNotSupported);
  2986 		}
  3137 		}
  2987 	
  3138 	
  2988 		TPtrC8 pOtherName = gen->GetContentDER(); 
  3139 		TPtrC8 pOtherName = gen->GetContentDER(); 
  2993 		HBufC* objId = objid.DecodeDERL(pOtherName, pos);
  3144 		HBufC* objId = objid.DecodeDERL(pOtherName, pos);
  2994 		
  3145 		
  2995 		if(NULL == objId)
  3146 		if(NULL == objId)
  2996 		{
  3147 		{
  2997 			EAP_TRACE_DEBUG(
  3148 			EAP_TRACE_DEBUG(
  2998 			m_am_tools, 
  3149 				m_am_tools, 
  2999 			TRACE_FLAGS_DEFAULT, 
  3150 				TRACE_FLAGS_DEFAULT, 
  3000 			(EAPL("ERROR:get_identity_from_alternative_name_L:No ASN1DecObjectIdentifier or DecodeDER failed\n")));
  3151 				(EAPL("ERROR: get_identity_from_alternative_name_L:No ASN1DecObjectIdentifier or DecodeDER failed\n")));
  3001 					
  3152 					
  3002 			User::Leave(KErrNotFound);			
  3153 			User::Leave(KErrNotFound);			
  3003 		}
  3154 		}
  3004 		
  3155 		
  3005 		CleanupStack::PushL(objId);
  3156 		CleanupStack::PushL(objId);
  3009 		if (objId->Compare(KMSObjectId) != 0)
  3160 		if (objId->Compare(KMSObjectId) != 0)
  3010 		{
  3161 		{
  3011 			// Not supported object type
  3162 			// Not supported object type
  3012 		
  3163 		
  3013 			EAP_TRACE_DEBUG(
  3164 			EAP_TRACE_DEBUG(
  3014 			m_am_tools, 
  3165 				m_am_tools, 
  3015 			TRACE_FLAGS_DEFAULT, 
  3166 				TRACE_FLAGS_DEFAULT, 
  3016 			(EAPL("ERROR:get_identity_from_alternative_nameL:Not supported object type\n")));
  3167 				(EAPL("ERROR: get_identity_from_alternative_nameL:Not supported object type\n")));
  3017 
  3168 
  3018 			User::Leave(KErrNotSupported);
  3169 			User::Leave(KErrNotSupported);
  3019 		}
  3170 		}
  3020 
  3171 
  3021 		pos += 2; // Skip over explicit tag
  3172 		pos += 2; // Skip over explicit tag
  3024 		HBufC* utf8name = utf8.DecodeDERL(pOtherName, pos);
  3175 		HBufC* utf8name = utf8.DecodeDERL(pOtherName, pos);
  3025 		
  3176 		
  3026 		if(NULL == utf8name)
  3177 		if(NULL == utf8name)
  3027 		{
  3178 		{
  3028 			EAP_TRACE_DEBUG(
  3179 			EAP_TRACE_DEBUG(
  3029 			m_am_tools, 
  3180 				m_am_tools, 
  3030 			TRACE_FLAGS_DEFAULT, 
  3181 				TRACE_FLAGS_DEFAULT, 
  3031 			(EAPL("ERROR:get_identity_from_alternative_nameL:No ASN1DecUTF8String or DecodeDER failed\n")));
  3182 				(EAPL("ERROR: get_identity_from_alternative_nameL:No ASN1DecUTF8String or DecodeDER failed\n")));
  3032 					
  3183 					
  3033 			User::Leave(KErrNotFound);			
  3184 			User::Leave(KErrNotFound);			
  3034 		}
  3185 		}
  3035 		
  3186 		
  3036 		CleanupStack::PushL(utf8name);
  3187 		CleanupStack::PushL(utf8name);
  3065 		CleanupStack::PopAndDestroy(5);
  3216 		CleanupStack::PopAndDestroy(5);
  3066 	} 
  3217 	} 
  3067 	else
  3218 	else
  3068 	{
  3219 	{
  3069 		EAP_TRACE_DEBUG(
  3220 		EAP_TRACE_DEBUG(
  3070 		m_am_tools, 
  3221 			m_am_tools, 
  3071 		TRACE_FLAGS_DEFAULT, 
  3222 			TRACE_FLAGS_DEFAULT, 
  3072 		(EAPL("get_identity_from_alternative_nameL:No X509 Cert Extension\n")));
  3223 			(EAPL("get_identity_from_alternative_nameL:No X509 Cert Extension\n")));
  3073 	
  3224 	
  3074 		User::Leave(KErrNotFound);
  3225 		User::Leave(KErrNotFound);
  3075 	}
  3226 	}
  3076 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3227 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3077 }
  3228 }
  3086 	EAP_UNREFERENCED_PARAMETER(id); // in release
  3237 	EAP_UNREFERENCED_PARAMETER(id); // in release
  3087 	EAP_UNREFERENCED_PARAMETER(data); // in release
  3238 	EAP_UNREFERENCED_PARAMETER(data); // in release
  3088 
  3239 
  3089 	eap_status_e status = eap_status_ok;
  3240 	eap_status_e status = eap_status_ok;
  3090 
  3241 
  3091 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("TIMER: [0x%08x]->eap_am_type_tls_peap_symbian_c::timer_expired(id 0x%02x, data 0x%08x).\n"),
  3242 	EAP_TRACE_DEBUG(
  3092 		this, id, data));
  3243 		m_am_tools,
       
  3244 		TRACE_FLAGS_DEFAULT,
       
  3245 		(EAPL("TIMER: [0x%08x]->eap_am_type_tls_peap_symbian_c::timer_expired(id 0x%02x, data 0x%08x).\n"),
       
  3246 		this,
       
  3247 		id,
       
  3248 		data));
  3093 
  3249 
  3094 #if defined(USE_FAST_EAP_TYPE)
  3250 #if defined(USE_FAST_EAP_TYPE)
  3095 
  3251 
  3096 	if(id == KHandleCompletePacstoreNokTimerID)
  3252 	if(id == KHandleCompletePacstoreNokTimerID)
  3097 	    {
  3253 		{
  3098         m_eap_fast_completion_status = eap_status_file_does_not_exist;
  3254 
  3099         m_tls_application->complete_initialize_PAC_store( iCompletionOperation, iCompletion );
  3255 #ifdef USE_PAC_STORE
  3100         return eap_status_ok;
  3256 		if (m_is_pac_store_initialization == true)
  3101 	    }
  3257 			{
  3102     if(id == KHandleCompletePacstoreOkTimerID)
  3258 			// First shutdown everything, this closes PAC-store, then others can use it immediately.
  3103         {
  3259 			shutdown();
  3104         m_eap_fast_completion_status = eap_status_ok;
  3260 			}
  3105         m_tls_application->complete_initialize_PAC_store( iCompletionOperation, iCompletion );
  3261 #endif //#ifdef USE_PAC_STORE
  3106         return eap_status_ok;
  3262 
  3107         }
  3263 		m_eap_fast_completion_status = eap_status_file_does_not_exist;
  3108     if (id == KRemoveIAPReferenceTimerID)
  3264 		m_tls_application->complete_initialize_PAC_store( iCompletionOperation, iCompletion );
       
  3265 		return eap_status_ok;
       
  3266 		}
       
  3267 	else if(id == KHandleCompletePacstoreOkTimerID)
       
  3268 		{
       
  3269 
       
  3270 #ifdef USE_PAC_STORE
       
  3271 		if (m_is_pac_store_initialization == true)
       
  3272 			{
       
  3273 			// First shutdown everything, this closes PAC-store, then others can use it immediately.
       
  3274 			shutdown();
       
  3275 			}
       
  3276 #endif //#ifdef USE_PAC_STORE
       
  3277 
       
  3278 		m_eap_fast_completion_status = eap_status_ok;
       
  3279 		m_tls_application->complete_initialize_PAC_store( iCompletionOperation, iCompletion );
       
  3280 		return eap_status_ok;
       
  3281 		}
       
  3282 	else if (id == KRemoveIAPReferenceTimerID)
  3109 		{
  3283 		{
  3110 		status = RemoveIAPReference();
  3284 		status = RemoveIAPReference();
  3111 
  3285 		}
  3112 		}
  3286 	else if (id == KImportFileTimerID)
  3113 	if (id == KImportFileTimerID)
  3287 		{
  3114 		{
  3288 		TRAPD(error, status = ImportFilesL());
  3115 		TRAPD(err, status = ImportFilesL());
  3289 		if (error != KErrNone)
  3116 		if (err != KErrNone)
  3290 			{
  3117 			{
  3291 			EAP_TRACE_DEBUG(
  3118 			EAP_TRACE_DEBUG(m_am_tools, 
  3292 				m_am_tools, 
  3119 					TRACE_FLAGS_DEFAULT, 
  3293 				TRACE_FLAGS_DEFAULT, 
  3120 					(EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - Leave From ImportFilesL %d\n"),err));
  3294 				(EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - Leave From ImportFilesL %d\n"),error));
  3121 			}
  3295 			}
  3122 		}
  3296 		}
  3123 
  3297 	else if (id == KCompleteReadPacstoreTimerID)
  3124 	if (id == KCompleteReadPacstoreTimerID)
  3298 		{
  3125 		{
  3299 		TRAPD(error, FinalCompleteReadPACStoreDataL(m_eap_fast_completion_status));
  3126 		TRAPD(err, FinalCompleteReadPACStoreDataL(m_eap_fast_completion_status));
  3300 		if (error != KErrNone)
  3127 		if (err != KErrNone)
  3301 			{
  3128 			{
  3302 			EAP_TRACE_DEBUG(
  3129 			EAP_TRACE_DEBUG(m_am_tools, 
  3303 				m_am_tools, 
  3130 					TRACE_FLAGS_DEFAULT, 
  3304 				TRACE_FLAGS_DEFAULT, 
  3131 					(EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - Leave From FinalCompleteReadPACStoreDataL %d\n"),err));
  3305 				(EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - Leave From FinalCompleteReadPACStoreDataL %d\n"),error));
  3132 			}
  3306 			}
  3133 		}
  3307 		}
  3134 
  3308 	else if (id == KHandleReadPacstoreTimerID)
  3135 	if (id == KHandleReadPacstoreTimerID)
       
  3136 		{
  3309 		{
  3137 		if (m_state == EPasswordCancel)
  3310 		if (m_state == EPasswordCancel)
  3138 			{
  3311 			{
  3139 			m_eap_fast_completion_status = eap_status_user_cancel_authentication;
  3312 			m_eap_fast_completion_status = eap_status_user_cancel_authentication;
  3140 			EAP_TRACE_DEBUG(m_am_tools, 
  3313 			EAP_TRACE_DEBUG(
  3141 					TRACE_FLAGS_DEFAULT, 
  3314 				m_am_tools, 
  3142 					(EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - PW query Cancel\n")));
  3315 				TRACE_FLAGS_DEFAULT, 
       
  3316 				(EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - PW query Cancel\n")));
  3143 			
  3317 			
  3144 			
  3318 			
  3145 			status = m_partner->set_timer(
  3319 			status = m_partner->set_timer(
  3146 					this,
  3320 					this,
  3147 					KCompleteReadPacstoreTimerID, 
  3321 					KCompleteReadPacstoreTimerID, 
  3151 			}
  3325 			}
  3152 		if (m_state == EMasterkeyQuery && m_verificationStatus == EFalse)
  3326 		if (m_state == EMasterkeyQuery && m_verificationStatus == EFalse)
  3153 			{
  3327 			{
  3154 			if (m_userResponse.get_data_length()>0)
  3328 			if (m_userResponse.get_data_length()>0)
  3155 				{
  3329 				{
  3156 				EAP_TRACE_DEBUG(m_am_tools, 
  3330 				EAP_TRACE_DEBUG(
       
  3331 					m_am_tools, 
       
  3332 					TRACE_FLAGS_DEFAULT, 
       
  3333 					(EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - Masterkey Create\n")));
       
  3334 
       
  3335 				m_verificationStatus = ETrue;
       
  3336 				TRAPD(error, m_eap_fast_completion_status=CreateMasterkeyL());
       
  3337 				if (error != KErrNone)
       
  3338 					{
       
  3339 					EAP_TRACE_DEBUG(
       
  3340 						m_am_tools, 
  3157 						TRACE_FLAGS_DEFAULT, 
  3341 						TRACE_FLAGS_DEFAULT, 
  3158 						(EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - Masterkey Create\n")));
  3342 						(EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - Leave From CreateMasterkeyL %d\n"),error));
  3159 				m_verificationStatus = ETrue;
       
  3160 				TRAPD(err, m_eap_fast_completion_status=CreateMasterkeyL());
       
  3161 				if (err != KErrNone)
       
  3162 					{
       
  3163 					EAP_TRACE_DEBUG(m_am_tools, 
       
  3164 							TRACE_FLAGS_DEFAULT, 
       
  3165 							(EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - Leave From CreateMasterkeyL %d\n"),err));
       
  3166 					}
  3343 					}
  3167 				}
  3344 				}
  3168 			else
  3345 			else
  3169 				{
  3346 				{
  3170 				EAP_TRACE_DEBUG(m_am_tools, 
  3347 				EAP_TRACE_DEBUG(
  3171 						TRACE_FLAGS_DEFAULT, 
  3348 					m_am_tools, 
  3172 						(EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - Masterkey, no data -> final complete for PW\n")));
  3349 					TRACE_FLAGS_DEFAULT, 
       
  3350 					(EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - Masterkey, no data -> final complete for PW\n")));
       
  3351 
  3173 				m_state = EWrongPassword;
  3352 				m_state = EWrongPassword;
  3174 				m_verificationStatus = EFalse;
  3353 				m_verificationStatus = EFalse;
  3175 
  3354 
  3176 	        	status = m_partner->set_timer(
  3355 				status = m_partner->set_timer(
  3177 						this,
  3356 						this,
  3178 						KCompleteReadPacstoreTimerID,  
  3357 						KCompleteReadPacstoreTimerID,  
  3179 						0,
  3358 						0,
  3180 						0);
  3359 						0);
  3181 
  3360 
  3182 	        	return status;
  3361 				return EAP_STATUS_RETURN(m_am_tools, status);
  3183 				}
  3362 				}
  3184 			}
  3363 			}
  3185 
  3364 
  3186 		if (m_state == EPasswordQuery || m_state == EWrongPassword || m_state == EMasterkeyQuery)
  3365 		if (m_state == EPasswordQuery || m_state == EWrongPassword || m_state == EMasterkeyQuery)
  3187 			{
  3366 			{
  3188 			if (m_verificationStatus == EFalse)
  3367 			if (m_verificationStatus == EFalse)
  3189 				{
  3368 				{
  3190 				TRAPD(err, status = PasswordQueryL());
  3369 				TRAPD(error, status = PasswordQueryL());
       
  3370 
  3191 				m_eap_fast_completion_status = m_am_tools->convert_am_error_to_eapol_error(status);
  3371 				m_eap_fast_completion_status = m_am_tools->convert_am_error_to_eapol_error(status);
  3192 				if (err != KErrNone)
  3372 
       
  3373 				if (error != KErrNone)
  3193 					{
  3374 					{
  3194 					EAP_TRACE_DEBUG(m_am_tools, 
  3375 					EAP_TRACE_DEBUG(
  3195 							TRACE_FLAGS_DEFAULT, 
  3376 						m_am_tools, 
  3196 							(EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - Leave From PasswordQueryL %d\n"),err));
  3377 						TRACE_FLAGS_DEFAULT, 
       
  3378 						(EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - Leave From PasswordQueryL %d\n"),error));
  3197 					}
  3379 					}
  3198 
  3380 
  3199 				if (m_eap_fast_completion_status != eap_status_ok)
  3381 				if (m_eap_fast_completion_status != eap_status_ok)
  3200 					{
  3382 					{
  3201 					EAP_TRACE_DEBUG(m_am_tools, 
  3383 					EAP_TRACE_DEBUG(
  3202 							TRACE_FLAGS_DEFAULT, 
  3384 						m_am_tools, 
  3203 							(EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - PW query NOK, final complete for PW\n")));
  3385 						TRACE_FLAGS_DEFAULT, 
       
  3386 						(EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - PW query NOK, final complete for PW\n")));
  3204 					
  3387 					
  3205 					status = m_partner->set_timer(
  3388 					status = m_partner->set_timer(
  3206 							this,
  3389 							this,
  3207 							KCompleteReadPacstoreTimerID, 
  3390 							KCompleteReadPacstoreTimerID, 
  3208 							0,
  3391 							0,
  3209 							0);
  3392 							0);
  3210 					}
  3393 					}
  3211 				}
  3394 				}
  3212 			if (m_verificationStatus != EFalse)
  3395 			if (m_verificationStatus != EFalse)
  3213 				{
  3396 				{
  3214 				TRAPD(err, CompletePasswordQueryL());
  3397 				TRAPD(error, CompletePasswordQueryL());
  3215 				if (err != KErrNone)
  3398 				if (error != KErrNone)
  3216 					{
  3399 					{
  3217 					EAP_TRACE_DEBUG(m_am_tools, 
  3400 					EAP_TRACE_DEBUG(
  3218 							TRACE_FLAGS_DEFAULT, 
  3401 						m_am_tools, 
  3219 							(EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - Leave From CompletePasswordQueryL %d\n"),err));
  3402 						TRACE_FLAGS_DEFAULT, 
       
  3403 						(EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - Leave From CompletePasswordQueryL %d\n"),error));
  3220 					}
  3404 					}
  3221 
  3405 
  3222 				EAP_TRACE_DEBUG(
  3406 				EAP_TRACE_DEBUG(
  3223 						m_am_tools,
  3407 					m_am_tools,
  3224 						TRACE_FLAGS_DEFAULT,
  3408 					TRACE_FLAGS_DEFAULT,
  3225 						(EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - Complete_password_query, m_both_completed=%d, m_both_asked=%d status=%d.\n"),
  3409 					(EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - Complete_password_query, m_both_completed=%d, m_both_asked=%d status=%d.\n"),
  3226 								m_both_completed,
  3410 					m_both_completed,
  3227 								m_both_asked,
  3411 					m_both_asked,
  3228 								m_eap_fast_completion_status));
  3412 					m_eap_fast_completion_status));
       
  3413 
  3229 				if (m_both_completed == m_both_asked)
  3414 				if (m_both_completed == m_both_asked)
  3230 					{
  3415 					{
  3231 					m_both_completed = 0;
  3416 					m_both_completed = 0;
  3232 					m_both_asked = 0;
  3417 					m_both_asked = 0;
  3233 					m_verificationStatus = EFalse;
  3418 					m_verificationStatus = EFalse;
  3234 					
  3419 					
  3235 					EAP_TRACE_DEBUG(m_am_tools, 
  3420 					EAP_TRACE_DEBUG(
  3236 							TRACE_FLAGS_DEFAULT, 
  3421 						m_am_tools, 
  3237 							(EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - All OK, final complete for PW\n")));
  3422 						TRACE_FLAGS_DEFAULT, 
       
  3423 						(EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - All OK, final complete for PW\n")));
       
  3424 
  3238 					status = m_partner->set_timer(
  3425 					status = m_partner->set_timer(
  3239 							this,
  3426 							this,
  3240 							KCompleteReadPacstoreTimerID,  
  3427 							KCompleteReadPacstoreTimerID,  
  3241 							0,
  3428 							0,
  3242 							0);
  3429 							0);
  3243 					return status;
  3430 					return EAP_STATUS_RETURN(m_am_tools, status);
  3244 					}
  3431 					}
  3245 				}
  3432 				}
  3246 			}
  3433 			}
  3247 
  3434 
  3248 		if (m_state == EFilePasswordQuery)
  3435 		if (m_state == EFilePasswordQuery)
  3249 			{
  3436 			{
  3250 			TRAPD( err, status = CompleteFilePasswordQueryL());
  3437 			TRAPD( error, status = CompleteFilePasswordQueryL());
  3251 			if (err != KErrNone)
  3438 			if (error != KErrNone)
  3252 				{
  3439 				{
  3253 				EAP_TRACE_DEBUG(m_am_tools, 
  3440 				EAP_TRACE_DEBUG(
  3254 						TRACE_FLAGS_DEFAULT, 
  3441 					m_am_tools, 
  3255 						(EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - Leave From CompleteFilePasswordQueryL %d\n"),err));
  3442 					TRACE_FLAGS_DEFAULT, 
       
  3443 					(EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - Leave From CompleteFilePasswordQueryL %d\n"),error));
  3256 				}
  3444 				}
  3257 
  3445 
  3258 			EAP_TRACE_DEBUG(
  3446 			EAP_TRACE_DEBUG(
  3259 					m_am_tools,
  3447 				m_am_tools,
  3260 					TRACE_FLAGS_DEFAULT,
  3448 				TRACE_FLAGS_DEFAULT,
  3261 					(EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - Complete_file_password_query, m_both_completed=%d, m_both_asked=%d status=%d.\n"),
  3449 				(EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - Complete_file_password_query, m_both_completed=%d, m_both_asked=%d status=%d.\n"),
  3262 							m_both_completed,
  3450 				m_both_completed,
  3263 							m_both_asked,
  3451 				m_both_asked,
  3264 							status));
  3452 				status));
  3265 			if (status != eap_status_ok)
  3453 			if (status != eap_status_ok)
  3266 				{
  3454 				{
  3267 				EAP_TRACE_DEBUG(m_am_tools, 
  3455 				EAP_TRACE_DEBUG(
  3268 						TRACE_FLAGS_DEFAULT, 
  3456 					m_am_tools, 
  3269 						(EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - PW query NOK, final complete for PW\n")));
  3457 					TRACE_FLAGS_DEFAULT, 
       
  3458 					(EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - PW query NOK, final complete for PW\n")));
       
  3459 
  3270 				status = m_partner->set_timer(
  3460 				status = m_partner->set_timer(
  3271 						this,
  3461 						this,
  3272 						KCompleteReadPacstoreTimerID,  
  3462 						KCompleteReadPacstoreTimerID,  
  3273 						&status,
  3463 						&status,
  3274 						0);
  3464 						0);
  3275 				return status;
  3465 				return EAP_STATUS_RETURN(m_am_tools, status);
  3276 				}
  3466 				}
       
  3467 
  3277 			if (m_both_completed == m_both_asked)
  3468 			if (m_both_completed == m_both_asked)
  3278 				{
  3469 				{
  3279 				EAP_TRACE_DEBUG(m_am_tools, 
  3470 				EAP_TRACE_DEBUG(
  3280 						TRACE_FLAGS_DEFAULT, 
  3471 					m_am_tools, 
  3281 						(EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - All ok, final complete for PW\n")));
  3472 					TRACE_FLAGS_DEFAULT, 
       
  3473 					(EAPL("eap_am_type_tls_peap_symbian_c::timer_expired - All ok, final complete for PW\n")));
       
  3474 
  3282 				m_both_completed = 0;
  3475 				m_both_completed = 0;
  3283 				m_both_asked = 0;
  3476 				m_both_asked = 0;
       
  3477 
  3284 				status = m_partner->set_timer(
  3478 				status = m_partner->set_timer(
  3285 						this,
  3479 						this,
  3286 						KCompleteReadPacstoreTimerID,  
  3480 						KCompleteReadPacstoreTimerID,  
  3287 						&status,
  3481 						&status,
  3288 						0);
  3482 						0);
  3289 				}
  3483 				}
  3290 			return status;
  3484 
       
  3485 			return EAP_STATUS_RETURN(m_am_tools, status);
  3291 			}
  3486 			}
  3292 		}
  3487 		}
  3293 #endif //#if defined(USE_FAST_EAP_TYPE)
  3488 #endif //#if defined(USE_FAST_EAP_TYPE)
  3294 		
  3489 		
  3295 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3490 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3323 	EAP_UNREFERENCED_PARAMETER(id); // in release
  3518 	EAP_UNREFERENCED_PARAMETER(id); // in release
  3324 	EAP_UNREFERENCED_PARAMETER(data); // in release
  3519 	EAP_UNREFERENCED_PARAMETER(data); // in release
  3325 
  3520 
  3326 	eap_status_e status = eap_status_ok;
  3521 	eap_status_e status = eap_status_ok;
  3327 
  3522 
  3328 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("TIMER: [0x%08x]->eap_am_type_tls_peap_symbian_c::timer_delete_data(id 0x%02x, data 0x%08x).\n"),
  3523 	EAP_TRACE_DEBUG(
  3329 		this, id, data));
  3524 		m_am_tools,
       
  3525 		TRACE_FLAGS_DEFAULT,
       
  3526 		(EAPL("TIMER: [0x%08x]->eap_am_type_tls_peap_symbian_c::timer_delete_data(id 0x%02x, data 0x%08x).\n"),
       
  3527 		this,
       
  3528 		id,
       
  3529 		data));
  3330 
  3530 
  3331 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3531 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3332 	return EAP_STATUS_RETURN(m_am_tools, status);
  3532 	return EAP_STATUS_RETURN(m_am_tools, status);
  3333 }
  3533 }
  3334 
  3534 
  3343 	EAP_ASSERT(data != NULL);
  3543 	EAP_ASSERT(data != NULL);
  3344 	// Trap must be set here because the OS independent portion of EAP TLS
  3544 	// Trap must be set here because the OS independent portion of EAP TLS
  3345 	// that calls this function does not know anything about Symbian.	
  3545 	// that calls this function does not know anything about Symbian.	
  3346 	eap_status_e status(eap_status_ok);
  3546 	eap_status_e status(eap_status_ok);
  3347 	
  3547 	
  3348 	EAP_TRACE_DEBUG(m_am_tools, 
  3548 	EAP_TRACE_DEBUG(
       
  3549 		m_am_tools, 
  3349 		TRACE_FLAGS_DEFAULT, 
  3550 		TRACE_FLAGS_DEFAULT, 
  3350 		(EAPL("eap_am_type_tls_peap_symbian_c::type_configure_read - Start\n")));
  3551 		(EAPL("eap_am_type_tls_peap_symbian_c::type_configure_read(): this=0x%08x\n"),
       
  3552 		this));
  3351 	
  3553 	
  3352 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_type_tls_peap_symbian_c::type_configure_read()");
  3554 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_type_tls_peap_symbian_c::type_configure_read()");
  3353 
  3555 
  3354 
  3556 
  3355 	if (m_current_eap_type == eap_type_peap
  3557 	if (m_current_eap_type == eap_type_peap
  3428 			if (0 == m_enabled_tunneling_exp_eap_array.Count())
  3630 			if (0 == m_enabled_tunneling_exp_eap_array.Count())
  3429 			{
  3631 			{
  3430 				// No EAP types are ENABLED as tunneling type.
  3632 				// No EAP types are ENABLED as tunneling type.
  3431 				if (m_is_client)
  3633 				if (m_is_client)
  3432 				{
  3634 				{
  3433 					EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: No ENABLED encapsulated EAP types.\n")));
  3635 					EAP_TRACE_DEBUG(
       
  3636 						m_am_tools,
       
  3637 						TRACE_FLAGS_DEFAULT,
       
  3638 						(EAPL("ERROR: No ENABLED encapsulated EAP types.\n")));
  3434 				}
  3639 				}
  3435 				
  3640 				
  3436 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3641 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3437 				return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_field);
  3642 				return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_field);
  3438 			}
  3643 			}
  3497 				return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_type);
  3702 				return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_type);
  3498 			}
  3703 			}
  3499 		}
  3704 		}
  3500 	} // End of if (m_current_eap_type == eap_type_peap
  3705 	} // End of if (m_current_eap_type == eap_type_peap
  3501 
  3706 
  3502 	TRAPD(err, type_configure_readL(
  3707 	TRAPD(error, type_configure_readL(
  3503 		field->get_field(),
  3708 		field->get_field(),
  3504 		field->get_field_length(),
  3709 		field->get_field_length(),
  3505 		data));
  3710 		data));
  3506 	if (err != KErrNone) 
  3711 	if (error != KErrNone)
  3507 	{	
  3712 	{
       
  3713 		EAP_TRACE_DEBUG(
       
  3714 			m_am_tools,
       
  3715 			TRACE_FLAGS_DEFAULT,
       
  3716 			(EAPL("WARNING: eap_am_type_tls_peap_symbian_c::type_configure_readL() failed, error=%d, tries m_partner->read_configure(), partner=0x%08x.\n"),
       
  3717 			error,
       
  3718 			m_partner));
       
  3719 
  3508 		status = m_partner->read_configure(field, data);
  3720 		status = m_partner->read_configure(field, data);
       
  3721 
       
  3722 		EAP_TRACE_DEBUG(
       
  3723 			m_am_tools,
       
  3724 			TRACE_FLAGS_DEFAULT,
       
  3725 			(EAPL("m_partner->read_configure() returns status=%d=%s.\n"),
       
  3726 			status,
       
  3727 			eap_status_string_c::get_status_string(status)));
  3509 	}
  3728 	}
  3510 
  3729 
  3511 	m_am_tools->trace_configuration(
  3730 	m_am_tools->trace_configuration(
  3512 		status,
  3731 		status,
  3513 		field,
  3732 		field,
  3524 	const u32_t field_length,
  3743 	const u32_t field_length,
  3525 	eap_variable_data_c * const data)
  3744 	eap_variable_data_c * const data)
  3526 {
  3745 {
  3527 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  3746 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  3528 	EAP_UNREFERENCED_PARAMETER(field_length);
  3747 	EAP_UNREFERENCED_PARAMETER(field_length);
       
  3748 
       
  3749 	EAP_TRACE_DEBUG(
       
  3750 		m_am_tools, 
       
  3751 		TRACE_FLAGS_DEFAULT, 
       
  3752 		(EAPL("eap_am_type_tls_peap_symbian_c::type_configure_readL(): this=0x%08x\n"),
       
  3753 		this));
       
  3754 	
       
  3755 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_type_tls_peap_symbian_c::type_configure_readL()");
  3529 
  3756 
  3530 	// Create a buffer for the ascii strings - initialised with the argument
  3757 	// Create a buffer for the ascii strings - initialised with the argument
  3531 	HBufC8* asciibuf = HBufC8::NewLC(KMaxDBFieldNameLength);
  3758 	HBufC8* asciibuf = HBufC8::NewLC(KMaxDBFieldNameLength);
  3532 	TPtr8 asciiString = asciibuf->Des();
  3759 	TPtr8 asciiString = asciibuf->Des();
  3533 	asciiString.Copy(reinterpret_cast<const unsigned char *>(field));
  3760 	asciiString.Copy(reinterpret_cast<const unsigned char *>(field));
  3563 	   || (unicodeString.Compare(KFASTWarnADHPNoMatchingPAC) == 0)
  3790 	   || (unicodeString.Compare(KFASTWarnADHPNoMatchingPAC) == 0)
  3564 	   || (unicodeString.Compare(KFASTWarnNotDefaultServer) == 0)
  3791 	   || (unicodeString.Compare(KFASTWarnNotDefaultServer) == 0)
  3565 	   || (unicodeString.Compare(KFASTPACGroupImportReferenceCollection) == 0)
  3792 	   || (unicodeString.Compare(KFASTPACGroupImportReferenceCollection) == 0)
  3566 	   || (unicodeString.Compare(KFASTPACGroupDBReferenceCollection) == 0)))
  3793 	   || (unicodeString.Compare(KFASTPACGroupDBReferenceCollection) == 0)))
  3567 	{
  3794 	{
  3568 		EAP_TRACE_DEBUG(m_am_tools, 
  3795 		EAP_TRACE_DEBUG(
       
  3796 			m_am_tools, 
  3569 			TRACE_FLAGS_DEFAULT, 
  3797 			TRACE_FLAGS_DEFAULT, 
  3570 			(EAPL("eap_am_type_tls_peap_symbian_c::type_configure_readL This field will be read from EAP-FAST's special table\n")));
  3798 			(EAPL("eap_am_type_tls_peap_symbian_c::type_configure_readL This field will be read from EAP-FAST's special table\n")));
  3571 		
  3799 		
  3572 		sqlStatement.Format(
  3800 		sqlStatement.Format(
  3573 			KSQLQueryRow,
  3801 			KSQLQueryRow,
  3671 					User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
  3899 					User::Leave(m_am_tools->convert_eapol_error_to_am_error(EAP_STATUS_RETURN(m_am_tools, status)));
  3672 				}
  3900 				}
  3673 			}
  3901 			}
  3674 			break;
  3902 			break;
  3675 		default:
  3903 		default:
  3676 			EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("type_configure_readL: Unexpected column type.\n")));
  3904 			EAP_TRACE_DEBUG(
       
  3905 				m_am_tools,
       
  3906 				TRACE_FLAGS_DEFAULT,
       
  3907 				(EAPL("type_configure_readL: Unexpected column type.\n")));
  3677 			User::Leave(KErrGeneral);
  3908 			User::Leave(KErrGeneral);
  3678 			break;
  3909 			break;
  3679 		}
  3910 		}
  3680 	}
  3911 	}
  3681 	else
  3912 	else
  3682 	{
  3913 	{
  3683 		// Could not find parameter
  3914 		// Could not find parameter
  3684 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("type_configure_readL: Could not find configuration parameter.\n")));
  3915 		EAP_TRACE_DEBUG(
       
  3916 			m_am_tools,
       
  3917 			TRACE_FLAGS_DEFAULT,
       
  3918 			(EAPL("type_configure_readL: Could not find configuration parameter.\n")));
  3685 		User::Leave(KErrArgument);
  3919 		User::Leave(KErrArgument);
  3686 	}		
  3920 	}		
  3687 
  3921 
  3688 	// Close database
  3922 	// Close database
  3689 	CleanupStack::PopAndDestroy(4); // view
  3923 	CleanupStack::PopAndDestroy(4); // view
  3894 {	
  4128 {	
  3895 	eap_variable_data_c count_of_session_resumes(m_am_tools);
  4129 	eap_variable_data_c count_of_session_resumes(m_am_tools);
  3896 	eap_variable_data_c session_id(m_am_tools);
  4130 	eap_variable_data_c session_id(m_am_tools);
  3897 	eap_variable_data_c master_secret(m_am_tools);
  4131 	eap_variable_data_c master_secret(m_am_tools);
  3898 
  4132 
  3899 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, 
  4133 	EAP_TRACE_DEBUG(
       
  4134 		m_am_tools,
       
  4135 		TRACE_FLAGS_DEFAULT, 
  3900 		(EAPL("ResetSessionIdL - clearing session resume info.\n")));
  4136 		(EAPL("ResetSessionIdL - clearing session resume info.\n")));
  3901 		
  4137 		
  3902 	{	
  4138 	{	
  3903 		session_id.reset();
  4139 		session_id.reset();
  3904 		WriteBinaryParamL(
  4140 		WriteBinaryParamL(
  3933 	EAP_UNREFERENCED_PARAMETER(alert_description); // in release
  4169 	EAP_UNREFERENCED_PARAMETER(alert_description); // in release
  3934 	EAP_UNREFERENCED_PARAMETER(alert_level); // in release
  4170 	EAP_UNREFERENCED_PARAMETER(alert_level); // in release
  3935 
  4171 
  3936 	eap_tls_trace_string_c tls_trace;
  4172 	eap_tls_trace_string_c tls_trace;
  3937 
  4173 
  3938 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("\n")));
  4174 	EAP_TRACE_DEBUG(
       
  4175 		m_am_tools,
       
  4176 		TRACE_FLAGS_DEFAULT,
       
  4177 		(EAPL("\n")));
  3939 	EAP_TRACE_DEBUG(
  4178 	EAP_TRACE_DEBUG(
  3940 		m_am_tools,
  4179 		m_am_tools,
  3941 		TRACE_FLAGS_DEFAULT,
  4180 		TRACE_FLAGS_DEFAULT,
  3942 		(EAPL("ERROR: %s: message_function: alert_received(), level %d=%s, description %d=%s\n"),
  4181 		(EAPL("ERROR: %s: message_function: alert_received(), level %d=%s, description %d=%s\n"),
  3943 		 (m_is_client == true ? "client": "server"),
  4182 		 (m_is_client == true ? "client": "server"),
  4015 
  4254 
  4016 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::query_cipher_suites_and_previous_session()
  4255 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::query_cipher_suites_and_previous_session()
  4017 {
  4256 {
  4018 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  4257 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  4019 
  4258 
  4020 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("\n")));
  4259 	EAP_TRACE_DEBUG(
  4021 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("TLS: %s: function: query_cipher_suites_and_previous_session()\n"),
  4260 		m_am_tools,
       
  4261 		TRACE_FLAGS_DEFAULT,
       
  4262 		(EAPL("\n")));
       
  4263 	EAP_TRACE_DEBUG(
       
  4264 		m_am_tools,
       
  4265 		TRACE_FLAGS_DEFAULT,
       
  4266 		(EAPL("TLS: %s: function: query_cipher_suites_and_previous_session()\n"),
  4022 		(m_is_client == true ? "client": "server")));
  4267 		(m_is_client == true ? "client": "server")));
  4023 
  4268 
  4024 	EAP_ASSERT_ALWAYS(m_is_client == true);
  4269 	EAP_ASSERT_ALWAYS(m_is_client == true);
  4025 
  4270 
  4026 	eap_status_e status(eap_status_process_general_error);
  4271 	eap_status_e status(eap_status_process_general_error);
  4039 #if defined(USE_FAST_EAP_TYPE)
  4284 #if defined(USE_FAST_EAP_TYPE)
  4040 		
  4285 		
  4041 	if(m_current_eap_type == eap_type_fast &&
  4286 	if(m_current_eap_type == eap_type_fast &&
  4042 	   m_serv_unauth_prov_mode == true)
  4287 	   m_serv_unauth_prov_mode == true)
  4043 	{
  4288 	{
  4044 		EAP_TRACE_DEBUG(m_am_tools, 
  4289 		EAP_TRACE_DEBUG(
  4045 			TRACE_FLAGS_DEFAULT, (
  4290 			m_am_tools, 
  4046 			EAPL("eap_am_type_tls_peap_symbian_c::query_cipher_suites_and_previous_session-Exception for EAP-FAST as m_serv_unauth_prov_mode is true \n")));			
  4291 			TRACE_FLAGS_DEFAULT,
       
  4292 			(EAPL("eap_am_type_tls_peap_symbian_c::query_cipher_suites_and_previous_session-Exception for EAP-FAST as m_serv_unauth_prov_mode is true \n")));			
  4047 			
  4293 			
  4048 		tls_session_type = tls_session_type_eap_fast_server_unauthenticated_provisioning_mode_ADHP;
  4294 		tls_session_type = tls_session_type_eap_fast_server_unauthenticated_provisioning_mode_ADHP;
  4049 		
  4295 		
  4050 		// This is the only cipher suite needed in this case.		
  4296 		// This is the only cipher suite needed in this case.		
  4051 		{
  4297 		{
  4090 				
  4336 				
  4091 				if(m_current_eap_type == eap_type_fast)
  4337 				if(m_current_eap_type == eap_type_fast)
  4092 				{
  4338 				{
  4093 					// Exception for EAP-FAST
  4339 					// Exception for EAP-FAST
  4094 					
  4340 					
  4095 					EAP_TRACE_DEBUG(m_am_tools, 
  4341 					EAP_TRACE_DEBUG(
  4096 					TRACE_FLAGS_DEFAULT, (
  4342 						m_am_tools, 
  4097 					EAPL("eap_am_type_tls_peap_symbian_c::query_cipher_suites_and_previous_session - No CA certificate but exception for EAP-FAST\n")));				
  4343 						TRACE_FLAGS_DEFAULT,
       
  4344 						(EAPL("eap_am_type_tls_peap_symbian_c::query_cipher_suites_and_previous_session - No CA certificate but exception for EAP-FAST\n")));				
  4098 				}
  4345 				}
  4099 				else	
  4346 				else	
  4100 #endif // #if defined(USE_FAST_EAP_TYPE)
  4347 #endif // #if defined(USE_FAST_EAP_TYPE)
  4101 				{
  4348 				{
  4102 					m_state = EHandlingCipherSuiteQuery;
  4349 					m_state = EHandlingCipherSuiteQuery;
  4103 					
  4350 					
  4104 					TRAPD(err, m_cert_if->ReadCACertificateL(*m_allowed_ca_certs[0]));
  4351 					TRAPD(error, m_cert_if->ReadCACertificateL(*m_allowed_ca_certs[0]));
  4105 					if (err != KErrNone)
  4352 					if (error != KErrNone)
  4106 					{
  4353 					{
  4107 						// Error occurred. Just select all cipher suites.
  4354 						// Error occurred. Just select all cipher suites.
  4108 						select_all_cipher_suites = true;
  4355 						select_all_cipher_suites = true;
  4109 					}
  4356 					}
  4110 					else
  4357 					else
  4329 				m_am_tools,
  4576 				m_am_tools,
  4330 				TRACE_FLAGS_DEFAULT,
  4577 				TRACE_FLAGS_DEFAULT,
  4331 				(EAPL("TLS: %s: query_cipher_suites_and_previous_session(): creates new session.\n"),
  4578 				(EAPL("TLS: %s: query_cipher_suites_and_previous_session(): creates new session.\n"),
  4332 				(m_is_client == true ? "client": "server")));
  4579 				(m_is_client == true ? "client": "server")));
  4333 
  4580 
  4334 			TRAPD(err, ResetSessionIdL());
  4581 			TRAPD(error, ResetSessionIdL());
  4335 			if (err != KErrNone)
  4582 			if (error != KErrNone)
  4336 			{
  4583 			{
  4337 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4584 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4338 				return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error);					
  4585 				return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error);					
  4339 			}
  4586 			}
  4340 
  4587 
  4392 
  4639 
  4393 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::query_new_session_ticket()
  4640 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::query_new_session_ticket()
  4394 {
  4641 {
  4395 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  4642 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  4396 
  4643 
  4397 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("\n")));
  4644 	EAP_TRACE_DEBUG(
       
  4645 		m_am_tools,
       
  4646 		TRACE_FLAGS_DEFAULT,
       
  4647 		(EAPL("\n")));
  4398 	EAP_TRACE_DEBUG(
  4648 	EAP_TRACE_DEBUG(
  4399 		m_am_tools,
  4649 		m_am_tools,
  4400 		TRACE_FLAGS_DEFAULT,
  4650 		TRACE_FLAGS_DEFAULT,
  4401 		(EAPL("TLS: %s: message_function: query_new_session_ticket()\n"),
  4651 		(EAPL("TLS: %s: message_function: query_new_session_ticket()\n"),
  4402 		(m_is_client == true ? "client": "server")));
  4652 		(m_is_client == true ? "client": "server")));
  4419 #endif //#if defined(USE_EAP_TLS_SESSION_TICKET)
  4669 #endif //#if defined(USE_EAP_TLS_SESSION_TICKET)
  4420 	)
  4670 	)
  4421 {
  4671 {
  4422 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  4672 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  4423 
  4673 
  4424 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("\n")));
  4674 	EAP_TRACE_DEBUG(
  4425 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("TLS: %s: function: select_cipher_suite_and_check_session_id()\n"),
  4675 		m_am_tools,
       
  4676 		TRACE_FLAGS_DEFAULT,
       
  4677 		(EAPL("\n")));
       
  4678 	EAP_TRACE_DEBUG(
       
  4679 		m_am_tools,
       
  4680 		TRACE_FLAGS_DEFAULT,
       
  4681 		(EAPL("TLS: %s: function: select_cipher_suite_and_check_session_id()\n"),
  4426 		(m_is_client == true ? "client": "server")));
  4682 		(m_is_client == true ? "client": "server")));
  4427 
  4683 
  4428 	EAP_ASSERT_ALWAYS(m_is_client == false);
  4684 	EAP_ASSERT_ALWAYS(m_is_client == false);
  4429 
  4685 
  4430 	eap_status_e status = eap_status_illegal_payload;
  4686 	eap_status_e status = eap_status_illegal_payload;
  4522 			else
  4778 			else
  4523 			{
  4779 			{
  4524 				{	
  4780 				{	
  4525 					stored_session_id.reset();
  4781 					stored_session_id.reset();
  4526 
  4782 
  4527 					TRAPD(err, WriteBinaryParamL(
  4783 					TRAPD(error, WriteBinaryParamL(
  4528 						cf_str_EAP_TLS_PEAP_saved_session_id.get_field()->get_field(),
  4784 						cf_str_EAP_TLS_PEAP_saved_session_id.get_field()->get_field(),
  4529 						cf_str_EAP_TLS_PEAP_saved_session_id.get_field()->get_field_length(),
  4785 						cf_str_EAP_TLS_PEAP_saved_session_id.get_field()->get_field_length(),
  4530 						&stored_session_id));
  4786 						&stored_session_id));
  4531 					if (err != KErrNone)
  4787 					if (error != KErrNone)
  4532 					{
  4788 					{
  4533 						EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4789 						EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4534 						return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error);
  4790 						return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error);
  4535 					}
  4791 					}
  4536 				}
  4792 				}
  4537 
  4793 
  4538 				{
  4794 				{
  4539 					stored_master_secret.reset();
  4795 					stored_master_secret.reset();
  4540 
  4796 
  4541 					TRAPD(err, WriteBinaryParamL(
  4797 					TRAPD(error, WriteBinaryParamL(
  4542 						cf_str_EAP_TLS_PEAP_saved_master_secret.get_field()->get_field(),
  4798 						cf_str_EAP_TLS_PEAP_saved_master_secret.get_field()->get_field(),
  4543 						cf_str_EAP_TLS_PEAP_saved_master_secret.get_field()->get_field_length(),
  4799 						cf_str_EAP_TLS_PEAP_saved_master_secret.get_field()->get_field_length(),
  4544 						&stored_master_secret));
  4800 						&stored_master_secret));
  4545 					if (err != KErrNone)
  4801 					if (error != KErrNone)
  4546 					{
  4802 					{
  4547 						EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4803 						EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4548 						return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error);
  4804 						return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error);
  4549 					}
  4805 					}
  4550 				}					
  4806 				}					
  4551 
  4807 
  4552 				{
  4808 				{
  4553 					TRAPD(err, WriteIntParamL(
  4809 					TRAPD(error, WriteIntParamL(
  4554 						cf_str_EAP_TLS_PEAP_saved_cipher_suite.get_field()->get_field(),
  4810 						cf_str_EAP_TLS_PEAP_saved_cipher_suite.get_field()->get_field(),
  4555 						cf_str_EAP_TLS_PEAP_saved_cipher_suite.get_field()->get_field_length(),
  4811 						cf_str_EAP_TLS_PEAP_saved_cipher_suite.get_field()->get_field_length(),
  4556 						tls_cipher_suites_TLS_NULL_WITH_NULL_NULL));
  4812 						tls_cipher_suites_TLS_NULL_WITH_NULL_NULL));
  4557 					if (err != KErrNone)
  4813 					if (error != KErrNone)
  4558 					{
  4814 					{
  4559 						EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4815 						EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4560 						return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error);					
  4816 						return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error);					
  4561 					}
  4817 					}
  4562 				}					
  4818 				}					
  4607 
  4863 
  4608 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::verify_certificate_chain(
  4864 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::verify_certificate_chain(
  4609 	EAP_TEMPLATE_CONST eap_array_c<eap_variable_data_c> * const certificate_chain,
  4865 	EAP_TEMPLATE_CONST eap_array_c<eap_variable_data_c> * const certificate_chain,
  4610 	const tls_cipher_suites_e required_cipher_suite)
  4866 	const tls_cipher_suites_e required_cipher_suite)
  4611 {
  4867 {
  4612 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  4868 	EAP_TRACE_BEGIN(
  4613 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("\n")));
  4869 		m_am_tools,
  4614 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("TLS: %s: message_function: verify_certificate_chain()\n"),
  4870 		TRACE_FLAGS_DEFAULT);
       
  4871 	EAP_TRACE_DEBUG(
       
  4872 		m_am_tools,
       
  4873 		TRACE_FLAGS_DEFAULT,
       
  4874 		(EAPL("\n")));
       
  4875 	EAP_TRACE_DEBUG(
       
  4876 		m_am_tools,
       
  4877 		TRACE_FLAGS_DEFAULT,
       
  4878 		(EAPL("TLS: %s: message_function: verify_certificate_chain()\n"),
  4615 		(m_is_client == true ? "client": "server")));
  4879 		(m_is_client == true ? "client": "server")));
  4616 
  4880 
  4617 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_type_tls_peap_symbian_c::verify_certificate_chain()");
  4881 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_type_tls_peap_symbian_c::verify_certificate_chain()");
  4618 
  4882 
  4619 	EAP_ASSERT_ALWAYS(certificate_chain->get_object_count() > 0);
  4883 	EAP_ASSERT_ALWAYS(certificate_chain->get_object_count() > 0);
  4620 
  4884 
  4621 	eap_status_e status(eap_status_ok);
  4885 	eap_status_e status(eap_status_ok);
  4622 
  4886 
  4623 	TRAPD(err, verify_certificate_chainL(certificate_chain, required_cipher_suite));
  4887 	TRAPD(error, verify_certificate_chainL(certificate_chain, required_cipher_suite));
  4624 	if (err != KErrNone)
  4888 	if (error != KErrNone)
  4625 	{
  4889 	{
  4626 		if (err == KErrArgument)
  4890 		if (error == KErrArgument)
  4627 		{
  4891 		{
  4628 			status = eap_status_illegal_certificate;
  4892 			status = eap_status_illegal_certificate;
  4629 		}
  4893 		}
  4630 		else
  4894 		else
  4631 		{
  4895 		{
  4632 			status = m_am_tools->convert_am_error_to_eapol_error(err);
  4896 			status = m_am_tools->convert_am_error_to_eapol_error(error);
  4633 		}
  4897 		}
  4634 	}
  4898 	}
  4635 
  4899 
  4636 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4900 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4637 	return EAP_STATUS_RETURN(m_am_tools, status);
  4901 	return EAP_STATUS_RETURN(m_am_tools, status);
  4772 				client_subject_realm.get_data(client_subject_realm.get_data_length()),
  5036 				client_subject_realm.get_data(client_subject_realm.get_data_length()),
  4773 				client_subject_realm.get_data_length()));
  5037 				client_subject_realm.get_data_length()));
  4774 		}
  5038 		}
  4775 		else
  5039 		else
  4776 		{
  5040 		{
  4777 			EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Client subject realm is empty.\n")));
  5041 			EAP_TRACE_DEBUG(
       
  5042 				m_am_tools,
       
  5043 				TRACE_FLAGS_DEFAULT,
       
  5044 				(EAPL("Client subject realm is empty.\n")));
  4778 		}
  5045 		}
  4779 		
  5046 		
  4780 		if (manual_client_subject_realm.get_is_valid_data() == true)
  5047 		if (manual_client_subject_realm.get_is_valid_data() == true)
  4781 		{
  5048 		{
  4782 			EAP_TRACE_DATA_DEBUG(m_am_tools, 
  5049 			EAP_TRACE_DATA_DEBUG(m_am_tools, 
  4784 				manual_client_subject_realm.get_data(manual_client_subject_realm.get_data_length()),
  5051 				manual_client_subject_realm.get_data(manual_client_subject_realm.get_data_length()),
  4785 				manual_client_subject_realm.get_data_length()));
  5052 				manual_client_subject_realm.get_data_length()));
  4786 		}
  5053 		}
  4787 		else
  5054 		else
  4788 		{
  5055 		{
  4789 			EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Client manual realm is empty.\n")));
  5056 			EAP_TRACE_DEBUG(
       
  5057 				m_am_tools,
       
  5058 				TRACE_FLAGS_DEFAULT,
       
  5059 				(EAPL("Client manual realm is empty.\n")));
  4790 		}
  5060 		}
  4791 		
  5061 		
  4792 		EAP_TRACE_DATA_DEBUG(m_am_tools, 
  5062 		EAP_TRACE_DATA_DEBUG(m_am_tools, 
  4793 			TRACE_FLAGS_DEFAULT, (EAPL("Server subject realm:"),
  5063 			TRACE_FLAGS_DEFAULT, (EAPL("Server subject realm:"),
  4794 			server_subject_realm.get_data(server_subject_realm.get_data_length()),
  5064 			server_subject_realm.get_data(server_subject_realm.get_data_length()),
  4883 					User::Leave(KErrArgument);
  5153 					User::Leave(KErrArgument);
  4884 				}
  5154 				}
  4885 			}
  5155 			}
  4886 		}
  5156 		}
  4887 
  5157 
  4888 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Server certificate realm verification OK.\n")));
  5158 		EAP_TRACE_DEBUG(
       
  5159 			m_am_tools,
       
  5160 			TRACE_FLAGS_DEFAULT,
       
  5161 			(EAPL("Server certificate realm verification OK.\n")));
  4889 	}
  5162 	}
  4890 	else
  5163 	else
  4891 	{
  5164 	{
  4892 		EAP_TRACE_DEBUG(
  5165 		EAP_TRACE_DEBUG(
  4893 			m_am_tools, 
  5166 			m_am_tools, 
  5130 	TPtrC8 ptr = publicKey.KeyData();			
  5403 	TPtrC8 ptr = publicKey.KeyData();			
  5131 	m_peer_public_key.reset();
  5404 	m_peer_public_key.reset();
  5132 	eap_status_e status = m_peer_public_key.set_copy_of_buffer(ptr.Ptr(), ptr.Length());
  5405 	eap_status_e status = m_peer_public_key.set_copy_of_buffer(ptr.Ptr(), ptr.Length());
  5133 	if (status != eap_status_ok)
  5406 	if (status != eap_status_ok)
  5134 	{		
  5407 	{		
  5135 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: complete_validate_chain: could not allocate memory.")));
  5408 		EAP_TRACE_DEBUG(
       
  5409 			m_am_tools,
       
  5410 			TRACE_FLAGS_DEFAULT,
       
  5411 			(EAPL("ERROR: complete_validate_chain: could not allocate memory.")));
  5136 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
  5412 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
  5137 		return;
  5413 		return;
  5138 	}
  5414 	}
  5139 
  5415 
  5140 	get_tls_am_partner()->complete_verify_certificate_chain(result);
  5416 	get_tls_am_partner()->complete_verify_certificate_chain(result);
  5193 		}
  5469 		}
  5194 	}
  5470 	}
  5195 
  5471 
  5196 	iPacStoreDb->SkipUserActions(m_skip_user_interactions);        
  5472 	iPacStoreDb->SkipUserActions(m_skip_user_interactions);        
  5197 
  5473 
  5198 	return status;
  5474 	return EAP_STATUS_RETURN(m_am_tools, status);
  5199 }
  5475 }
  5200 
  5476 
  5201 #endif //#if defined(USE_EAP_CONFIGURATION_TO_SKIP_USER_INTERACTIONS)
  5477 #endif //#if defined(USE_EAP_CONFIGURATION_TO_SKIP_USER_INTERACTIONS)
  5202 #endif
  5478 #endif
  5203 
  5479 
  5216 		m_cipher_suite = required_cipher_suite;
  5492 		m_cipher_suite = required_cipher_suite;
  5217 	}
  5493 	}
  5218 
  5494 
  5219 	eap_status_e status(eap_status_pending_request);
  5495 	eap_status_e status(eap_status_pending_request);
  5220 	m_state = EHandlingChainQuery;
  5496 	m_state = EHandlingChainQuery;
  5221 	TInt err(KErrNone);
  5497 	TInt error(KErrNone);
  5222 
  5498 
  5223 	if (m_is_client)
  5499 	if (m_is_client)
  5224 	{
  5500 	{
  5225 		// client
  5501 		// client
  5226 		// Get the matching certificates. This function call is completed asyncronously by complete_get_matching_certificates() function call.
  5502 		// Get the matching certificates. This function call is completed asyncronously by complete_get_matching_certificates() function call.
  5227 		TRAPD(err, m_cert_if->GetMatchingCertificatesL(
  5503 		TRAPD(error, m_cert_if->GetMatchingCertificatesL(
  5228 			m_allowed_user_certs, 
  5504 			m_allowed_user_certs, 
  5229 			ETrue, 
  5505 			ETrue, 
  5230 			certificate_authorities, 
  5506 			certificate_authorities, 
  5231 			ETrue, 
  5507 			ETrue, 
  5232 			certificate_types, 
  5508 			certificate_types, 
  5233 			ETrue, 
  5509 			ETrue, 
  5234 			m_allowed_cipher_suites));
  5510 			m_allowed_cipher_suites));
  5235 	
  5511 	
  5236 		(void)EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(err));
  5512 		(void)EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(error));
  5237 	}
  5513 	}
  5238 	else
  5514 	else
  5239 	{
  5515 	{
  5240 		// server
  5516 		// server
  5241 		// Get the matching certificates. This function call is completed asyncronously by complete_get_matching_certificates() function call.
  5517 		// Get the matching certificates. This function call is completed asyncronously by complete_get_matching_certificates() function call.
  5242 		TRAPD(err, m_cert_if->GetMatchingCertificatesL(
  5518 		TRAPD(error, m_cert_if->GetMatchingCertificatesL(
  5243 				m_allowed_user_certs, 
  5519 				m_allowed_user_certs, 
  5244 				EFalse, 
  5520 				EFalse, 
  5245 				0, 
  5521 				0, 
  5246 				EFalse, 
  5522 				EFalse, 
  5247 				0, 
  5523 				0, 
  5248 				ETrue, 
  5524 				ETrue, 
  5249 				m_allowed_cipher_suites));
  5525 				m_allowed_cipher_suites));
  5250 
  5526 
  5251 		if (err != KErrNone)
  5527 		if (error != KErrNone)
  5252 		{
  5528 		{
  5253 			status = m_am_tools->convert_am_error_to_eapol_error(err);
  5529 			status = m_am_tools->convert_am_error_to_eapol_error(error);
  5254 		}		
  5530 		}		
  5255 	}
  5531 	}
  5256 
  5532 
  5257 	if (err == KErrNone)
  5533 	if (error == KErrNone)
  5258 	{
  5534 	{
  5259 		status = eap_status_pending_request;
  5535 		status = eap_status_pending_request;
  5260 	} 
  5536 	} 
  5261 	else
  5537 	else
  5262 	{	
  5538 	{	
  5263 		// Convert the leave error code to EAPOL stack error code.
  5539 		// Convert the leave error code to EAPOL stack error code.
  5264 		status = m_am_tools->convert_am_error_to_eapol_error(err);
  5540 		status = m_am_tools->convert_am_error_to_eapol_error(error);
  5265 	}	
  5541 	}	
  5266 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5542 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5267 	return EAP_STATUS_RETURN(m_am_tools, status);
  5543 	return EAP_STATUS_RETURN(m_am_tools, status);
  5268 
  5544 
  5269 }
  5545 }
  5276 {
  5552 {
  5277 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  5553 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  5278 
  5554 
  5279 	EAP_UNREFERENCED_PARAMETER(aStatus);
  5555 	EAP_UNREFERENCED_PARAMETER(aStatus);
  5280 
  5556 
  5281 	EAP_TRACE_DEBUG(m_am_tools, 
  5557 	EAP_TRACE_DEBUG(
  5282 	TRACE_FLAGS_DEFAULT, 
  5558 		m_am_tools, 
  5283 	(EAPL("eap_am_type_tls_peap_symbian_c::complete_get_matching_certificates-Matching cert count after possible cert removal=%d, m_state=%d, aStatus=%d\n"),
  5559 		TRACE_FLAGS_DEFAULT, 
  5284 	aMatchingCerts.Count(), m_state, aStatus));
  5560 		(EAPL("eap_am_type_tls_peap_symbian_c::complete_get_matching_certificates-Matching cert count after possible cert removal=%d, m_state=%d, aStatus=%d\n"),
       
  5561 		aMatchingCerts.Count(), m_state, aStatus));
  5285 	
  5562 	
  5286 	if (m_state == EHandlingIdentityQuery)
  5563 	if (m_state == EHandlingIdentityQuery)
  5287 	{
  5564 	{
  5288 		EAP_TRACE_DEBUG(
  5565 		EAP_TRACE_DEBUG(
  5289 			m_am_tools,
  5566 			m_am_tools,
  5344 		}
  5621 		}
  5345 
  5622 
  5346 		if (m_allowed_user_certs.Count() == 0)
  5623 		if (m_allowed_user_certs.Count() == 0)
  5347 		{
  5624 		{
  5348 			// No allowed user certificates. 
  5625 			// No allowed user certificates. 
  5349 			EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("EAP-TLS: No allowed user certificates configured.\n")));
  5626 			EAP_TRACE_DEBUG(
       
  5627 				m_am_tools,
       
  5628 				TRACE_FLAGS_DEFAULT,
       
  5629 				(EAPL("EAP-TLS: No allowed user certificates configured.\n")));
  5350 			
  5630 			
  5351 			if (m_tls_peap_server_authenticates_client_policy_flag == true)
  5631 			if (m_tls_peap_server_authenticates_client_policy_flag == true)
  5352 			{
  5632 			{
  5353                 // Certificate is really required
  5633                 // Certificate is really required
  5354 				EAP_TRACE_DEBUG(
  5634 				EAP_TRACE_DEBUG(
  5379 					m_am_tools, 
  5659 					m_am_tools, 
  5380 					TRACE_FLAGS_DEFAULT, 
  5660 					TRACE_FLAGS_DEFAULT, 
  5381 					(EAPL("eap_am_type_tls_peap_symbian_c::complete_get_matching_certificates(): no manual realm - no user cert. Get realm from CA certificate.\n")));
  5661 					(EAPL("eap_am_type_tls_peap_symbian_c::complete_get_matching_certificates(): no manual realm - no user cert. Get realm from CA certificate.\n")));
  5382 				
  5662 				
  5383 				TInt allowed_ca_cert_count = m_allowed_ca_certs.Count();
  5663 				TInt allowed_ca_cert_count = m_allowed_ca_certs.Count();
  5384 				TInt err(KErrNone);
  5664 				TInt error(KErrNone);
  5385 
  5665 
  5386 				if(allowed_ca_cert_count > 0)
  5666 				if(allowed_ca_cert_count > 0)
  5387 				{
  5667 				{
  5388 					TRAP(err, m_cert_if->ReadCACertificateL(*m_allowed_ca_certs[0]));
  5668 					TRAP(error, m_cert_if->ReadCACertificateL(*m_allowed_ca_certs[0]));
  5389 				}
  5669 				}
  5390 
  5670 
  5391 				if (err != KErrNone
  5671 				if (error != KErrNone
  5392 					|| allowed_ca_cert_count <= 0)
  5672 					|| allowed_ca_cert_count <= 0)
  5393 				{
  5673 				{
  5394 					if (m_use_automatic_ca_certificate == false)
  5674 					if (m_use_automatic_ca_certificate == false)
  5395 					{
  5675 					{
  5396 						EAP_TRACE_DEBUG(
  5676 						EAP_TRACE_DEBUG(
  5484 					error = KErrNoMemory;
  5764 					error = KErrNoMemory;
  5485 				}
  5765 				}
  5486 
  5766 
  5487 				if (error != KErrNone)
  5767 				if (error != KErrNone)
  5488 				{
  5768 				{
  5489 					EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: eap_am_type_tls_peap_symbian_c::complete_get_matching_certificates -EHandlingChainQuery- Error=%d\n"),
  5769 					EAP_TRACE_DEBUG(
       
  5770 						m_am_tools,
       
  5771 						TRACE_FLAGS_DEFAULT,
       
  5772 						(EAPL("ERROR: eap_am_type_tls_peap_symbian_c::complete_get_matching_certificates -EHandlingChainQuery- Error=%d\n"),
  5490 						error));
  5773 						error));
  5491 								
  5774 								
  5492 					get_tls_am_partner()->complete_query_certificate_chain(0, eap_status_allocation_error);
  5775 					get_tls_am_partner()->complete_query_certificate_chain(0, eap_status_allocation_error);
  5493 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);		
  5776 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);		
  5494 					return;					
  5777 					return;					
  5706 
  5989 
  5707 	TInt offset = KErrNotFound;
  5990 	TInt offset = KErrNotFound;
  5708 
  5991 
  5709 	// SUBJECT
  5992 	// SUBJECT
  5710 	// Try alternative name first
  5993 	// Try alternative name first
  5711 	TRAPD(err, get_identity_from_alternative_nameL(certificate, &subject_identity));
  5994 	TRAPD(error, get_identity_from_alternative_nameL(certificate, &subject_identity));
  5712 	if (err == KErrNone)
  5995 	if (error == KErrNone)
  5713 	{
  5996 	{
  5714 		// Parse realm from identity
  5997 		// Parse realm from identity
  5715 		TPtr8 ptr(
  5998 		TPtr8 ptr(
  5716 			subject_identity.get_data(subject_identity.get_data_length()), 
  5999 			subject_identity.get_data(subject_identity.get_data_length()), 
  5717 			subject_identity.get_data_length(),
  6000 			subject_identity.get_data_length(),
  5721 	}
  6004 	}
  5722 
  6005 
  5723 	if (offset == KErrNotFound)
  6006 	if (offset == KErrNotFound)
  5724 	{
  6007 	{
  5725 		// Check DN
  6008 		// Check DN
  5726 		TRAPD(err, get_identities_from_distinguished_namesL(certificate, &subject_identity, &issuer_identity));	
  6009 		TRAPD(error, get_identities_from_distinguished_namesL(certificate, &subject_identity, &issuer_identity));	
  5727 		if (err != KErrNone)
  6010 		if (error != KErrNone)
  5728 		{
  6011 		{
  5729 			EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: EAP-TLS: Could not find realm from certificate.\n")));
  6012 			EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: EAP-TLS: Could not find realm from certificate.\n")));
  5730 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_certificate);
  6013 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_certificate);
  5731 		}
  6014 		}
  5732 
  6015 
  5752 		return EAP_STATUS_RETURN(m_am_tools, status);
  6035 		return EAP_STATUS_RETURN(m_am_tools, status);
  5753 	}	
  6036 	}	
  5754 
  6037 
  5755 	// ISSUER
  6038 	// ISSUER
  5756 	// Check DN
  6039 	// Check DN
  5757 	TRAP(err, get_identities_from_distinguished_namesL(certificate, &subject_identity, &issuer_identity));	
  6040 	TRAP(error, get_identities_from_distinguished_namesL(certificate, &subject_identity, &issuer_identity));	
  5758 	if (err != KErrNone)
  6041 	if (error != KErrNone)
  5759 	{
  6042 	{
  5760 		EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: EAP-TLS: Could not find realm from certificate.\n")));
  6043 		EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: EAP-TLS: Could not find realm from certificate.\n")));
  5761 		return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_certificate);
  6044 		return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_certificate);
  5762 	}
  6045 	}
  5763 
  6046 
  5819 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6102 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5820 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
  6103 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_parameter);
  5821 		}
  6104 		}
  5822 	
  6105 	
  5823 		{			
  6106 		{			
  5824 			TRAPD(err, WriteBinaryParamL(
  6107 			TRAPD(error, WriteBinaryParamL(
  5825 				cf_str_EAP_TLS_PEAP_saved_session_id.get_field()->get_field(),
  6108 				cf_str_EAP_TLS_PEAP_saved_session_id.get_field()->get_field(),
  5826 				cf_str_EAP_TLS_PEAP_saved_session_id.get_field()->get_field_length(),
  6109 				cf_str_EAP_TLS_PEAP_saved_session_id.get_field()->get_field_length(),
  5827 				session_id));
  6110 				session_id));
  5828 			if (err != KErrNone)
  6111 			if (error != KErrNone)
  5829 			{
  6112 			{
  5830 				// Convert the leave error code to EAPOL stack error code.
  6113 				// Convert the leave error code to EAPOL stack error code.
  5831 				status = m_am_tools->convert_am_error_to_eapol_error(err);
  6114 				status = m_am_tools->convert_am_error_to_eapol_error(error);
  5832 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6115 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5833 				return EAP_STATUS_RETURN(m_am_tools, status);
  6116 				return EAP_STATUS_RETURN(m_am_tools, status);
  5834 			}
  6117 			}
  5835 		}
  6118 		}
  5836 
  6119 
  5837 		{
  6120 		{
  5838 			TRAPD(err, WriteBinaryParamL(
  6121 			TRAPD(error, WriteBinaryParamL(
  5839 				cf_str_EAP_TLS_PEAP_saved_master_secret.get_field()->get_field(),
  6122 				cf_str_EAP_TLS_PEAP_saved_master_secret.get_field()->get_field(),
  5840 				cf_str_EAP_TLS_PEAP_saved_master_secret.get_field()->get_field_length(),
  6123 				cf_str_EAP_TLS_PEAP_saved_master_secret.get_field()->get_field_length(),
  5841 				master_secret));
  6124 				master_secret));
  5842 			if (err != KErrNone)
  6125 			if (error != KErrNone)
  5843 			{
  6126 			{
  5844 				// Convert the leave error code to EAPOL stack error code.
  6127 				// Convert the leave error code to EAPOL stack error code.
  5845 				status = m_am_tools->convert_am_error_to_eapol_error(err);
  6128 				status = m_am_tools->convert_am_error_to_eapol_error(error);
  5846 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6129 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5847 				return EAP_STATUS_RETURN(m_am_tools, status);
  6130 				return EAP_STATUS_RETURN(m_am_tools, status);
  5848 			}
  6131 			}
  5849 		}
  6132 		}
  5850 
  6133 
  5851 		{
  6134 		{
  5852 			TRAPD(err, WriteIntParamL(
  6135 			TRAPD(error, WriteIntParamL(
  5853 				cf_str_EAP_TLS_PEAP_saved_cipher_suite.get_field()->get_field(),
  6136 				cf_str_EAP_TLS_PEAP_saved_cipher_suite.get_field()->get_field(),
  5854 				cf_str_EAP_TLS_PEAP_saved_cipher_suite.get_field()->get_field_length(),
  6137 				cf_str_EAP_TLS_PEAP_saved_cipher_suite.get_field()->get_field_length(),
  5855 				used_cipher_suite));
  6138 				used_cipher_suite));
  5856 			if (err != KErrNone)
  6139 			if (error != KErrNone)
  5857 			{
  6140 			{
  5858 				// Convert the leave error code to EAPOL stack error code.
  6141 				// Convert the leave error code to EAPOL stack error code.
  5859 				status = m_am_tools->convert_am_error_to_eapol_error(err);
  6142 				status = m_am_tools->convert_am_error_to_eapol_error(error);
  5860 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6143 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5861 				return EAP_STATUS_RETURN(m_am_tools, status);
  6144 				return EAP_STATUS_RETURN(m_am_tools, status);
  5862 			}
  6145 			}
  5863 		}		
  6146 		}		
  5864 	}
  6147 	}
  5890 	{
  6173 	{
  5891 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6174 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5892 		return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error);
  6175 		return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error);
  5893 	}
  6176 	}
  5894 
  6177 
  5895 	EAP_TRACE_DATA_DEBUG(m_am_tools, 
  6178 	EAP_TRACE_DATA_DEBUG(
  5896 		TRACE_FLAGS_DEFAULT, (EAPL("TLS: rsa_encrypt_with_public_key() m_peer_public_key"),
  6179 		m_am_tools, 
  5897 		   m_peer_public_key.get_data(m_peer_public_key.get_data_length()),
  6180 		TRACE_FLAGS_DEFAULT,
  5898 		   m_peer_public_key.get_data_length()));
  6181 		(EAPL("TLS: rsa_encrypt_with_public_key() m_peer_public_key"),
       
  6182 		m_peer_public_key.get_data(m_peer_public_key.get_data_length()),
       
  6183 		m_peer_public_key.get_data_length()));
  5899 
  6184 
  5900 
  6185 
  5901 	crypto_rsa_c rsa(m_am_tools);
  6186 	crypto_rsa_c rsa(m_am_tools);
  5902 
  6187 
  5903 	eap_variable_data_c encrypted_premaster_secret(m_am_tools);
  6188 	eap_variable_data_c encrypted_premaster_secret(m_am_tools);
  5939 		return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error);
  6224 		return EAP_STATUS_RETURN(m_am_tools, eap_status_process_general_error);
  5940 	}
  6225 	}
  5941 
  6226 
  5942 	HBufC8* data = 0;
  6227 	HBufC8* data = 0;
  5943 
  6228 
  5944 	TRAPD(err, data = HBufC8::NewL(encrypted_premaster_secret->get_data_length()));
  6229 	TRAPD(error, data = HBufC8::NewL(encrypted_premaster_secret->get_data_length()));
  5945 	if (err != KErrNone)
  6230 	if (error != KErrNone)
  5946 	{
  6231 	{
  5947 		status = m_am_tools->convert_am_error_to_eapol_error(err);
  6232 		status = m_am_tools->convert_am_error_to_eapol_error(error);
  5948 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6233 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5949 		return EAP_STATUS_RETURN(m_am_tools, status);
  6234 		return EAP_STATUS_RETURN(m_am_tools, status);
  5950 	}
  6235 	}
  5951 	
  6236 	
  5952 	TPtr8 ptr = data->Des();
  6237 	TPtr8 ptr = data->Des();
  5953 
  6238 
  5954 	ptr.Copy(encrypted_premaster_secret->get_data(encrypted_premaster_secret->get_data_length()), 
  6239 	ptr.Copy(encrypted_premaster_secret->get_data(encrypted_premaster_secret->get_data_length()), 
  5955 		encrypted_premaster_secret->get_data_length());
  6240 		encrypted_premaster_secret->get_data_length());
  5956 
  6241 
  5957 	TRAP(err, m_cert_if->DecryptL(m_own_certificate_info.GetSubjectKeyId(), *data));
  6242 	TRAP(error, m_cert_if->DecryptL(m_own_certificate_info.GetSubjectKeyId(), *data));
  5958 
  6243 
  5959 	if (err != KErrNone)
  6244 	if (error != KErrNone)
  5960 	{
  6245 	{
  5961 		status = m_am_tools->convert_am_error_to_eapol_error(err);
  6246 		status = m_am_tools->convert_am_error_to_eapol_error(error);
  5962 	}
  6247 	}
  5963 	else
  6248 	else
  5964 	{
  6249 	{
  5965 		status = eap_status_pending_request;
  6250 		status = eap_status_pending_request;
  5966 	}
  6251 	}
  6040 		 message_hash->get_data(message_hash->get_data_length()),
  6325 		 message_hash->get_data(message_hash->get_data_length()),
  6041 		 message_hash->get_data_length()));
  6326 		 message_hash->get_data_length()));
  6042 
  6327 
  6043 
  6328 
  6044 	HBufC8* buf = 0;
  6329 	HBufC8* buf = 0;
  6045 	TRAPD(err, buf = HBufC8::NewL(message_hash->get_data_length()))
  6330 	TRAPD(error, buf = HBufC8::NewL(message_hash->get_data_length()))
  6046 	if (err != KErrNone)
  6331 	if (error != KErrNone)
  6047 	{
  6332 	{
  6048 		status = m_am_tools->convert_am_error_to_eapol_error(err);		
  6333 		status = m_am_tools->convert_am_error_to_eapol_error(error);		
  6049 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6334 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6050 		return EAP_STATUS_RETURN(m_am_tools, status);
  6335 		return EAP_STATUS_RETURN(m_am_tools, status);
  6051 	}
  6336 	}
  6052 	
  6337 	
  6053 	TPtr8 hash = buf->Des();
  6338 	TPtr8 hash = buf->Des();
  6073 		// public_key_data actually has the asn.1 header so it is a few bytes longer
  6358 		// public_key_data actually has the asn.1 header so it is a few bytes longer
  6074 		// than the actual signature.
  6359 		// than the actual signature.
  6075 		signature_length = public_key_data.Size();
  6360 		signature_length = public_key_data.Size();
  6076 	}
  6361 	}
  6077 
  6362 
  6078 	TRAP(err, m_cert_if->SignL(m_own_certificate_info.GetSubjectKeyId(), hash, signature_length));
  6363 	TRAP(error, m_cert_if->SignL(m_own_certificate_info.GetSubjectKeyId(), hash, signature_length));
  6079 	if (err != KErrNone)
  6364 	if (error != KErrNone)
  6080 	{
  6365 	{
  6081 		status = m_am_tools->convert_am_error_to_eapol_error(err);
  6366 		status = m_am_tools->convert_am_error_to_eapol_error(error);
  6082 	}
  6367 	}
  6083 	else
  6368 	else
  6084 	{
  6369 	{
  6085 		status = eap_status_pending_request;
  6370 		status = eap_status_pending_request;
  6086 	}	
  6371 	}	
  6103 	{
  6388 	{
  6104 		get_tls_am_partner()->complete_sign_with_private_key(0, aStatus);
  6389 		get_tls_am_partner()->complete_sign_with_private_key(0, aStatus);
  6105 		return;
  6390 		return;
  6106 	}
  6391 	}
  6107 	
  6392 	
  6108 	TRAPD(err, complete_signL(aR, aS, eap_status_ok));
  6393 	TRAPD(error, complete_signL(aR, aS, eap_status_ok));
  6109 	if (err != KErrNone)
  6394 	if (error != KErrNone)
  6110 	{
  6395 	{
  6111 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: complete_signL leaved.\n")));
  6396 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: complete_signL leaved.\n")));
  6112 		get_tls_am_partner()->complete_sign_with_private_key(0, m_am_tools->convert_am_error_to_eapol_error(err));
  6397 		get_tls_am_partner()->complete_sign_with_private_key(0, m_am_tools->convert_am_error_to_eapol_error(error));
  6113 	}
  6398 	}
  6114 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6399 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6115 }
  6400 }
  6116 
  6401 
  6117 //--------------------------------------------------
  6402 //--------------------------------------------------
  6234 
  6519 
  6235 	eap_status_e status = eap_status_process_general_error;
  6520 	eap_status_e status = eap_status_process_general_error;
  6236 
  6521 
  6237 	if (EapTlsPeapUtils::CipherSuiteUseDSAKeys(m_cipher_suite))
  6522 	if (EapTlsPeapUtils::CipherSuiteUseDSAKeys(m_cipher_suite))
  6238 	{
  6523 	{
  6239 		TRAPD(err, read_dsa_parametersL());
  6524 		TRAPD(error, read_dsa_parametersL());
  6240 		if (err != KErrNone)
  6525 		if (error != KErrNone)
  6241 		{
  6526 		{
  6242 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6527 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6243 			return EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(err));
  6528 			return EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(error));
  6244 		}
  6529 		}
  6245 		crypto_dsa_c dsa(m_am_tools);
  6530 		crypto_dsa_c dsa(m_am_tools);
  6246 
  6531 
  6247 		status = dsa.init();
  6532 		status = dsa.init();
  6248 		if (status != eap_status_ok)
  6533 		if (status != eap_status_ok)
  6761 {
  7046 {
  6762 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  7047 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6763 	
  7048 	
  6764 	bool sessionValidity(false);
  7049 	bool sessionValidity(false);
  6765 	
  7050 	
  6766 	TRAPD(err, sessionValidity = is_session_validL());
  7051 	TRAPD(error, sessionValidity = is_session_validL());
  6767 	if (err != KErrNone) 
  7052 	if (error != KErrNone) 
  6768 	{
  7053 	{
  6769 		EAP_TRACE_ERROR(m_am_tools, 
  7054 		EAP_TRACE_ERROR(m_am_tools, 
  6770 			TRACE_FLAGS_DEFAULT, (
  7055 			TRACE_FLAGS_DEFAULT, (
  6771 			EAPL("eap_am_type_tls_peap_symbian_c::is_session_valid - LEAVE - error=%d, Assuming session is invalid \n"),
  7056 			EAPL("eap_am_type_tls_peap_symbian_c::is_session_valid - LEAVE - error=%d, Assuming session is invalid \n"),
  6772 			err));
  7057 			error));
  6773 			
  7058 			
  6774 		sessionValidity = false;
  7059 		sessionValidity = false;
  6775 	}
  7060 	}
  6776 	 		
  7061 	 		
  6777 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  7062 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6899 	
  7184 	
  6900 	TDateTime currentDateTime = currentTime.DateTime();
  7185 	TDateTime currentDateTime = currentTime.DateTime();
  6901 		
  7186 		
  6902 	TDateTime fullAuthDateTime = lastFullAuthTime.DateTime();
  7187 	TDateTime fullAuthDateTime = lastFullAuthTime.DateTime();
  6903 	
  7188 	
  6904 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT,
  7189 	EAP_TRACE_DEBUG(
  6905 	(EAPL("Session Validity - Current Time,        %2d-%2d-%4d : %2d-%2d-%2d-%d\n"), 
  7190 		m_am_tools,
  6906 	currentDateTime.Day()+1, currentDateTime.Month()+1, currentDateTime.Year(), currentDateTime.Hour(),
  7191 		TRACE_FLAGS_DEFAULT,
  6907 	currentDateTime.Minute(), currentDateTime.Second(), currentDateTime.MicroSecond()));
  7192 		(EAPL("Session Validity - Current Time,        %04d-%02d-%02d : %02d-%02d-%02d.%06d\n"), 
  6908 
  7193 		currentDateTime.Year(),
  6909 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT,
  7194 		currentDateTime.Month()+1,
  6910 	(EAPL("Session Validity - Last Full Auth Time, %2d-%2d-%4d : %2d-%2d-%2d-%d\n"), 
  7195 		currentDateTime.Day()+1,
  6911 	fullAuthDateTime.Day()+1, fullAuthDateTime.Month()+1, fullAuthDateTime.Year(), fullAuthDateTime.Hour(),
  7196 		currentDateTime.Hour(),
  6912 	fullAuthDateTime.Minute(), fullAuthDateTime.Second(), fullAuthDateTime.MicroSecond()));
  7197 		currentDateTime.Minute(),
       
  7198 		currentDateTime.Second(),
       
  7199 		currentDateTime.MicroSecond()));
       
  7200 
       
  7201 	EAP_TRACE_DEBUG(
       
  7202 		m_am_tools,
       
  7203 		TRACE_FLAGS_DEFAULT,
       
  7204 		(EAPL("Session Validity - Last Full Auth Time, %04d-%02d-%02d : %02d-%02d-%02d.%06d\n"), 
       
  7205 		fullAuthDateTime.Year(),
       
  7206 		fullAuthDateTime.Month()+1,
       
  7207 		fullAuthDateTime.Day()+1,
       
  7208 		fullAuthDateTime.Hour(),
       
  7209 		fullAuthDateTime.Minute(),
       
  7210 		fullAuthDateTime.Second(),
       
  7211 		fullAuthDateTime.MicroSecond()));
  6913 
  7212 
  6914 #endif
  7213 #endif
  6915 
  7214 
  6916 	TTimeIntervalMicroSeconds interval = currentTime.MicroSecondsFrom(lastFullAuthTime);
  7215 	TTimeIntervalMicroSeconds interval = currentTime.MicroSecondsFrom(lastFullAuthTime);
  6917 		
  7216 		
  6918 	EAP_TRACE_DATA_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT,(EAPL("eap_am_type_tls_peap_symbian_c::is_session_valid:interval in microseconds:"),
  7217 	EAP_TRACE_DATA_DEBUG(
  6919 			&(interval.Int64()),
  7218 		m_am_tools,
  6920 			sizeof(interval.Int64()) ) );
  7219 		TRACE_FLAGS_DEFAULT,
       
  7220 		(EAPL("eap_am_type_tls_peap_symbian_c::is_session_valid:interval in microseconds:"),
       
  7221 		&(interval.Int64()),
       
  7222 		sizeof(interval.Int64()) ) );
  6921 			
  7223 			
  6922 	EAP_TRACE_DATA_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT,(EAPL("eap_am_type_tls_peap_symbian_c::is_session_valid:max session time in microseconds:"),
  7224 	EAP_TRACE_DATA_DEBUG(
  6923 			&(maxSessionTime),
  7225 		m_am_tools,
  6924 			sizeof(maxSessionTime) ) );
  7226 		TRACE_FLAGS_DEFAULT,
       
  7227 		(EAPL("eap_am_type_tls_peap_symbian_c::is_session_valid:max session time in microseconds:"),
       
  7228 		&(maxSessionTime),
       
  7229 		sizeof(maxSessionTime) ) );
  6925 	
  7230 	
  6926 #if defined(_DEBUG) || defined(DEBUG)
  7231 #if defined(_DEBUG) || defined(DEBUG)
  6927 
  7232 
  6928 	TTimeIntervalMinutes intervalMins;
  7233 	TTimeIntervalMinutes intervalMins;
  6929 	TInt error = currentTime.MinutesFrom(lastFullAuthTime, intervalMins);
  7234 	TInt error = currentTime.MinutesFrom(lastFullAuthTime, intervalMins);
  7049 		
  7354 		
  7050 #if defined(_DEBUG) || defined(DEBUG)	
  7355 #if defined(_DEBUG) || defined(DEBUG)	
  7051 	
  7356 	
  7052 	TDateTime currentDateTime = currentTime.DateTime();
  7357 	TDateTime currentDateTime = currentTime.DateTime();
  7053 	
  7358 	
  7054 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT,
  7359 	EAP_TRACE_DEBUG(
  7055 	(EAPL("eap_am_type_tls_peap_symbian_c::store_authentication_time, %2d-%2d-%4d : %2d-%2d-%2d-%d\n"), 
  7360 		m_am_tools,
  7056 	currentDateTime.Day()+1, currentDateTime.Month()+1,currentDateTime.Year(), currentDateTime.Hour(),
  7361 		TRACE_FLAGS_DEFAULT,
  7057 	currentDateTime.Minute(), currentDateTime.Second(), currentDateTime.MicroSecond()));
  7362 		(EAPL("eap_am_type_tls_peap_symbian_c::store_authentication_time, %04d-%02d-%02d : %02d-%02d-%02d.%06d\n"), 
       
  7363 		currentDateTime.Year(),
       
  7364 		currentDateTime.Month()+1,
       
  7365 		currentDateTime.Day()+1,
       
  7366 		currentDateTime.Hour(),
       
  7367 		currentDateTime.Minute(),
       
  7368 		currentDateTime.Second(),
       
  7369 		currentDateTime.MicroSecond()));
  7058 
  7370 
  7059 #endif
  7371 #endif
  7060 
  7372 
  7061 	TInt64 fullAuthTime = currentTime.Int64();
  7373 	TInt64 fullAuthTime = currentTime.Int64();
  7062 	
  7374 	
  7175 	
  7487 	
  7176 	m_pending_operation = in_pending_operation;
  7488 	m_pending_operation = in_pending_operation;
  7177 
  7489 
  7178  	if (in_pac_attribute_A_ID_info->get_data_length()>0)
  7490  	if (in_pac_attribute_A_ID_info->get_data_length()>0)
  7179 		{
  7491 		{
  7180 		TRAPD(err, status = QueryUserPermissionForAIDL(in_pac_attribute_A_ID_info, in_pac_attribute_A_ID ));
  7492 		TRAPD(error, status = QueryUserPermissionForAIDL(in_pac_attribute_A_ID_info, in_pac_attribute_A_ID ));
  7181 		if (err != KErrNone)
  7493 		if (error != KErrNone)
  7182 			{
  7494 			{
  7183 			EAP_TRACE_DEBUG(
  7495 			EAP_TRACE_DEBUG(
  7184 					m_am_tools,
  7496 					m_am_tools,
  7185 					TRACE_FLAGS_DEFAULT,
  7497 					TRACE_FLAGS_DEFAULT,
  7186 					(EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::read_PAC_store_data() ERROR: LEAVE from QueryUserPermissionForAIDL error=%d"),
  7498 					(EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::read_PAC_store_data() ERROR: LEAVE from QueryUserPermissionForAIDL error=%d"),
  7187 					err));
  7499 					error));
  7188 					
  7500 					
  7189 				m_eap_fast_completion_status = m_am_tools->convert_am_error_to_eapol_error(err);
  7501 				m_eap_fast_completion_status = m_am_tools->convert_am_error_to_eapol_error(error);
  7190 			 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  7502 			 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  7191 				return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7503 				return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7192 			}
  7504 			}
  7193 		}
  7505 		}
  7194  	if (status == KErrNone)
  7506  	if (status == KErrNone)
  7224 	A_ID_infoPtr8.Copy(in_pac_attribute_A_ID_info->get_data(in_pac_attribute_A_ID_info->get_data_length()),in_pac_attribute_A_ID_info->get_data_length() );
  7536 	A_ID_infoPtr8.Copy(in_pac_attribute_A_ID_info->get_data(in_pac_attribute_A_ID_info->get_data_length()),in_pac_attribute_A_ID_info->get_data_length() );
  7225 	A_ID_infoPtr.Copy(A_ID_infoPtr8);
  7537 	A_ID_infoPtr.Copy(A_ID_infoPtr8);
  7226 	
  7538 	
  7227 	A_IDPtr.Copy(in_pac_attribute_A_ID->get_data(in_pac_attribute_A_ID->get_data_length()),in_pac_attribute_A_ID->get_data_length() );
  7539 	A_IDPtr.Copy(in_pac_attribute_A_ID->get_data(in_pac_attribute_A_ID->get_data_length()),in_pac_attribute_A_ID->get_data_length() );
  7228 
  7540 
  7229 	EAP_TRACE_DATA_DEBUG_SYMBIAN(
  7541 	EAP_TRACE_DATA_DEBUG(
  7230 			("eap_am_type_tls_peap_symbian_c::query_user_permission_for_A_ID(): in_pac_attribute_A_ID_info",
  7542 		m_am_tools,
  7231 			(A_ID_infoPtr.Ptr()),
  7543 		TRACE_FLAGS_DEFAULT,
  7232 			(in_pac_attribute_A_ID_info->get_data_length())));
  7544 		(EAPL("eap_am_type_tls_peap_symbian_c::query_user_permission_for_A_ID(): in_pac_attribute_A_ID_info"),
  7233 
  7545 		(A_ID_infoPtr.Ptr()),
  7234  	EAP_TRACE_DATA_DEBUG_SYMBIAN(
  7546 		(in_pac_attribute_A_ID_info->get_data_length())));
  7235 			("eap_am_type_tls_peap_symbian_c::query_user_permission_for_A_ID(): in_pac_attribute_A_ID",
  7547 
  7236 			(A_IDPtr.Ptr()),
  7548  	EAP_TRACE_DATA_DEBUG(
  7237 			(in_pac_attribute_A_ID->get_data_length())));
  7549 		m_am_tools,
       
  7550 		TRACE_FLAGS_DEFAULT,
       
  7551 		(EAPL("eap_am_type_tls_peap_symbian_c::query_user_permission_for_A_ID(): in_pac_attribute_A_ID"),
       
  7552 		(A_IDPtr.Ptr()),
       
  7553 		(in_pac_attribute_A_ID->get_data_length())));
  7238 
  7554 
  7239  	if (A_ID_infoPtr.Size()>=KMaxNotifItemLength)
  7555  	if (A_ID_infoPtr.Size()>=KMaxNotifItemLength)
  7240 	{
  7556 	{
  7241   		CleanupStack::PopAndDestroy(3); // A_ID, A_ID_info
  7557   		CleanupStack::PopAndDestroy(3); // A_ID, A_ID_info
  7242   		status = m_am_tools->convert_am_error_to_eapol_error(KErrArgument);
  7558   		status = m_am_tools->convert_am_error_to_eapol_error(KErrArgument);
  7249     
  7565     
  7250     m_notifier_data_to_user->iPassword.Copy(A_ID_infoPtr);
  7566     m_notifier_data_to_user->iPassword.Copy(A_ID_infoPtr);
  7251     
  7567     
  7252     if (iEapAuthNotifier == 0)
  7568     if (iEapAuthNotifier == 0)
  7253     	{
  7569     	{
  7254     	TRAPD(err, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
  7570     	TRAPD(error, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
  7255 	  	if (err)
  7571 	  	if (error)
  7256 	  		{
  7572 	  		{
  7257 	  			return eap_status_process_general_error;
  7573 	  			return eap_status_process_general_error;
  7258 	  		}
  7574 	  		}
  7259     	}
  7575     	}
  7260     else
  7576     else
  7274  
  7590  
  7275  
  7591  
  7276 
  7592 
  7277  	CleanupStack::PopAndDestroy(3); // A_ID, A_ID_info
  7593  	CleanupStack::PopAndDestroy(3); // A_ID, A_ID_info
  7278  	
  7594  	
  7279  	return status;
  7595  	return EAP_STATUS_RETURN(m_am_tools, status);
  7280 }
  7596 }
  7281 
  7597 
  7282 //--------------------------------------------------
  7598 //--------------------------------------------------
  7283 
  7599 
  7284 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::read_PAC_store_data(
  7600 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::read_PAC_store_data(
  7354 		(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);		
  7670 		(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);		
  7355 	}
  7671 	}
  7356 
  7672 
  7357 	// - - - - - - - - - - - - - - - - - - - - - - - -	
  7673 	// - - - - - - - - - - - - - - - - - - - - - - - -	
  7358 	
  7674 	
  7359 	EAP_TRACE_DEBUG_SYMBIAN(
  7675 	EAP_TRACE_DEBUG(
  7360 		(_L("eap_am_type_tls_peap_symbian_c::read_PAC_store_data-End, m_eap_fast_completion_status=%d"),
  7676 		m_am_tools,
       
  7677 		TRACE_FLAGS_DEFAULT,
       
  7678 		(EAPL("eap_am_type_tls_peap_symbian_c::read_PAC_store_data-End, m_eap_fast_completion_status=%d"),
  7361 		m_eap_fast_completion_status));			
  7679 		m_eap_fast_completion_status));			
  7362 	
  7680 	
  7363 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  7681 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  7364 	return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);	
  7682 	return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);	
  7365 }
  7683 }
  7379 
  7697 
  7380 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_type_tls_peap_symbian_c::ReadPACStoredataL()");
  7698 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_type_tls_peap_symbian_c::ReadPACStoredataL()");
  7381 
  7699 
  7382 	// - - - - - - - - - - - - - - - - - - - - - - - -
  7700 	// - - - - - - - - - - - - - - - - - - - - - - - -
  7383 
  7701 
  7384 	m_eap_fast_completion_status = eap_status_ok;
  7702 	eap_status_e status(eap_status_ok);
       
  7703 
       
  7704 	m_eap_fast_completion_status = status;
  7385 
  7705 
  7386 	m_eap_fast_pac_store_pending_operation = in_pending_operation;
  7706 	m_eap_fast_pac_store_pending_operation = in_pending_operation;
  7387 
  7707 
  7388 	(void) m_references_and_data_blocks.reset();
  7708 	(void) m_references_and_data_blocks.reset();
  7389 
  7709 
  7402 				TRACE_FLAGS_DEFAULT,
  7722 				TRACE_FLAGS_DEFAULT,
  7403 				(EAPL("ReadPACStoredataL(): data_reference type=%d=%s\n"),
  7723 				(EAPL("ReadPACStoredataL(): data_reference type=%d=%s\n"),
  7404 				pacStoreDataRefType,
  7724 				pacStoreDataRefType,
  7405 				eap_fast_tlv_header_string_c::get_fast_pac_store_data_string(pacStoreDataRefType)));
  7725 				eap_fast_tlv_header_string_c::get_fast_pac_store_data_string(pacStoreDataRefType)));
  7406 				
  7726 				
  7407 			EAP_TRACE_DATA_DEBUG_SYMBIAN(
  7727 			EAP_TRACE_DATA_DEBUG(
  7408 				("ReadPACStoredataL(): data_reference reference:",
  7728 				m_am_tools,
       
  7729 				TRACE_FLAGS_DEFAULT,
       
  7730 				(EAPL("ReadPACStoredataL(): data_reference reference:"),
  7409 				data_reference->get_reference()->get_data(data_reference->get_reference()->get_data_length()), 
  7731 				data_reference->get_reference()->get_data(data_reference->get_reference()->get_data_length()), 
  7410 				data_reference->get_reference()->get_data_length()));
  7732 				data_reference->get_reference()->get_data_length()));
  7411 			
  7733 			
  7412 			switch(pacStoreDataRefType)	
  7734 			switch(pacStoreDataRefType)	
  7413 			{
  7735 			{
  7442 					}
  7764 					}
  7443 
  7765 
  7444 					new_data->set_type(pacStoreDataRefType);					
  7766 					new_data->set_type(pacStoreDataRefType);					
  7445 
  7767 
  7446 					// Set the reference.
  7768 					// Set the reference.
  7447 					m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(data_reference->get_reference());
  7769 					status = new_data->get_writable_reference()->set_copy_of_buffer(data_reference->get_reference());
  7448 					if (m_eap_fast_completion_status != eap_status_ok)
  7770 					if (status != eap_status_ok)
  7449 					{
  7771 					{
  7450 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7772 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  7451 						break;
  7773 						break;
  7452 					}
  7774 					}
  7453 					
  7775 					
  7454 					m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(&master_key);
  7776 					status = new_data->get_writable_data()->set_copy_of_buffer(&master_key);
  7455 
  7777 
  7456 					if (m_eap_fast_completion_status != eap_status_ok)
  7778 					if (status != eap_status_ok)
  7457 					{
  7779 					{
  7458 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7780 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  7459 						break;
  7781 						break;
  7460 					}
  7782 					}
  7461 
  7783 
  7462 					automatic_new_data.do_not_free_variable();
  7784 					automatic_new_data.do_not_free_variable();
  7463 
  7785 
  7464 					m_eap_fast_completion_status = m_references_and_data_blocks.add_object(new_data, true);
  7786 					status = m_references_and_data_blocks.add_object(new_data, true);
  7465 					if (m_eap_fast_completion_status != eap_status_ok)
  7787 					if (status != eap_status_ok)
  7466 					{
  7788 					{
  7467 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7789 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  7468 						break;
  7790 						break;
  7469 					}
  7791 					}
  7470 					
  7792 					
  7471 					EAP_TRACE_DATA_DEBUG_SYMBIAN(
  7793 					EAP_TRACE_DATA_DEBUG(
  7472 						("eap_pac_store_data_type_PAC_store_master_key - added data",
  7794 						m_am_tools,
       
  7795 						TRACE_FLAGS_DEFAULT,
       
  7796 						(EAPL("eap_pac_store_data_type_PAC_store_master_key - added data"),
  7473 						(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
  7797 						(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
  7474 						(new_data->get_data())->get_data_length()));						
  7798 						(new_data->get_data())->get_data_length()));						
  7475 					
  7799 					
  7476 					break;
  7800 					break;
  7477 					
  7801 					
  7499 					eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
  7823 					eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
  7500 						m_am_tools, new_data);
  7824 						m_am_tools, new_data);
  7501 
  7825 
  7502 					if (new_data == 0)
  7826 					if (new_data == 0)
  7503 					{
  7827 					{
  7504 						m_eap_fast_completion_status = eap_status_allocation_error;
  7828 						status = eap_status_allocation_error;
  7505 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7829 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  7506 						break;
  7830 						break;
  7507 					}
  7831 					}
  7508 
  7832 
  7509 					new_data->set_type(pacStoreDataRefType);
  7833 					new_data->set_type(pacStoreDataRefType);
  7510 					
  7834 					
  7511 					// Set the reference.
  7835 					// Set the reference.
  7512 					m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(data_reference->get_reference());
  7836 					status = new_data->get_writable_reference()->set_copy_of_buffer(data_reference->get_reference());
  7513 					if (m_eap_fast_completion_status != eap_status_ok)
  7837 					if (status != eap_status_ok)
  7514 					{
  7838 					{
  7515 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7839 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  7516 						break;
  7840 						break;
  7517 					}
  7841 					}
  7518 					
  7842 					
  7519 
  7843 
  7520 					m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(&reference_counter);
  7844 					status = new_data->get_writable_data()->set_copy_of_buffer(&reference_counter);
  7521 					if (m_eap_fast_completion_status != eap_status_ok)
  7845 					if (status != eap_status_ok)
  7522 					{
  7846 					{
  7523 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7847 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  7524 						break;
  7848 						break;
  7525 					}
  7849 					}
  7526 
  7850 
  7527 					automatic_new_data.do_not_free_variable();
  7851 					automatic_new_data.do_not_free_variable();
  7528 
  7852 
  7529 					m_eap_fast_completion_status = m_references_and_data_blocks.add_object(new_data, true);
  7853 					status = m_references_and_data_blocks.add_object(new_data, true);
  7530 					if (m_eap_fast_completion_status != eap_status_ok)
  7854 					if (status != eap_status_ok)
  7531 					{
  7855 					{
  7532 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7856 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  7533 						break;
  7857 						break;
  7534 					}
  7858 					}
  7535 					
  7859 					
  7536 					EAP_TRACE_DATA_DEBUG_SYMBIAN(
  7860 					EAP_TRACE_DATA_DEBUG(
  7537 						("eap_pac_store_data_type_reference_counter - added data",
  7861 						m_am_tools,
       
  7862 						TRACE_FLAGS_DEFAULT,
       
  7863 						(EAPL("eap_pac_store_data_type_reference_counter - added data"),
  7538 						(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
  7864 						(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
  7539 						(new_data->get_data())->get_data_length()));
  7865 						(new_data->get_data())->get_data_length()));
  7540 					
  7866 					
  7541 					break;
  7867 					break;
  7542 					
  7868 					
  7565 					eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
  7891 					eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
  7566 						m_am_tools, new_data);
  7892 						m_am_tools, new_data);
  7567 
  7893 
  7568 					if (new_data == 0)
  7894 					if (new_data == 0)
  7569 					{
  7895 					{
  7570 						m_eap_fast_completion_status = eap_status_allocation_error;
  7896 						status = eap_status_allocation_error;
  7571 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7897 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  7572 						break;
  7898 						break;
  7573 					}
  7899 					}
  7574 
  7900 
  7575 					new_data->set_type(pacStoreDataRefType);					
  7901 					new_data->set_type(pacStoreDataRefType);					
  7576 
  7902 
  7577 					// Set the reference.
  7903 					// Set the reference.
  7578 					m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(data_reference->get_reference());
  7904 					status = new_data->get_writable_reference()->set_copy_of_buffer(data_reference->get_reference());
  7579 					if (m_eap_fast_completion_status != eap_status_ok)
  7905 					if (status != eap_status_ok)
  7580 					{
  7906 					{
  7581 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7907 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  7582 						break;
  7908 						break;
  7583 					}
  7909 					}
  7584 					
  7910 					
  7585 					m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(&group_data);
  7911 					status = new_data->get_writable_data()->set_copy_of_buffer(&group_data);
  7586 					if (m_eap_fast_completion_status != eap_status_ok)
  7912 					if (status != eap_status_ok)
  7587 					{
  7913 					{
  7588 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7914 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  7589 						break;
  7915 						break;
  7590 					}
  7916 					}
  7591 
  7917 
  7592 					automatic_new_data.do_not_free_variable();
  7918 					automatic_new_data.do_not_free_variable();
  7593 
  7919 
  7594 					m_eap_fast_completion_status = m_references_and_data_blocks.add_object(new_data, true);
  7920 					status = m_references_and_data_blocks.add_object(new_data, true);
  7595 					if (m_eap_fast_completion_status != eap_status_ok)
  7921 					if (status != eap_status_ok)
  7596 					{
  7922 					{
  7597 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7923 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  7598 						break;
  7924 						break;
  7599 					}
  7925 					}
  7600 					
  7926 					
  7601 					EAP_TRACE_DATA_DEBUG_SYMBIAN(
  7927 					EAP_TRACE_DATA_DEBUG(
  7602 						("eap_pac_store_data_type_group_data - added data",
  7928 						m_am_tools,
       
  7929 						TRACE_FLAGS_DEFAULT,
       
  7930 						(EAPL("eap_pac_store_data_type_group_data - added data"),
  7603 						(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
  7931 						(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
  7604 						(new_data->get_data())->get_data_length()));
  7932 						(new_data->get_data())->get_data_length()));
  7605 					
  7933 					
  7606 					break;
  7934 					break;
  7607 					
  7935 					
  7630 					eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
  7958 					eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
  7631 						m_am_tools, new_data);
  7959 						m_am_tools, new_data);
  7632 
  7960 
  7633 					if (new_data == 0)
  7961 					if (new_data == 0)
  7634 					{
  7962 					{
  7635 						m_eap_fast_completion_status = eap_status_allocation_error;
  7963 						status = eap_status_allocation_error;
  7636 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7964 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  7637 						break;
  7965 						break;
  7638 					}
  7966 					}
  7639 
  7967 
  7640 					new_data->set_type(pacStoreDataRefType);					
  7968 					new_data->set_type(pacStoreDataRefType);					
  7641 
  7969 
  7642 					// Set the reference.
  7970 					// Set the reference.
  7643 					m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(data_reference->get_reference());
  7971 					status = new_data->get_writable_reference()->set_copy_of_buffer(data_reference->get_reference());
  7644 					if (m_eap_fast_completion_status != eap_status_ok)
  7972 					if (status != eap_status_ok)
  7645 					{
  7973 					{
  7646 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7974 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  7647 						break;
  7975 						break;
  7648 					}
  7976 					}
  7649 					
  7977 					
  7650 					m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(&aid_data);
  7978 					status = new_data->get_writable_data()->set_copy_of_buffer(&aid_data);
  7651 					if (m_eap_fast_completion_status != eap_status_ok)
  7979 					if (status != eap_status_ok)
  7652 					{
  7980 					{
  7653 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7981 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  7654 						break;
  7982 						break;
  7655 					}
  7983 					}
  7656 
  7984 
  7657 					automatic_new_data.do_not_free_variable();
  7985 					automatic_new_data.do_not_free_variable();
  7658 
  7986 
  7659 					m_eap_fast_completion_status = m_references_and_data_blocks.add_object(new_data, true);
  7987 					status = m_references_and_data_blocks.add_object(new_data, true);
  7660 					if (m_eap_fast_completion_status != eap_status_ok)
  7988 					if (status != eap_status_ok)
  7661 					{
  7989 					{
  7662 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7990 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  7663 						break;
  7991 						break;
  7664 					}	
  7992 					}	
  7665 					
  7993 					
  7666 					EAP_TRACE_DATA_DEBUG_SYMBIAN(
  7994 					EAP_TRACE_DATA_DEBUG(
  7667 						("eap_pac_store_data_type_A_ID_data - added data",
  7995 						m_am_tools,
       
  7996 						TRACE_FLAGS_DEFAULT,
       
  7997 						(EAPL("eap_pac_store_data_type_A_ID_data - added data"),
  7668 						(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
  7998 						(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
  7669 						(new_data->get_data())->get_data_length()));
  7999 						(new_data->get_data())->get_data_length()));
  7670 					
  8000 					
  7671 					break;
  8001 					break;
  7672 					
  8002 					
  7695 					eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
  8025 					eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
  7696 						m_am_tools, new_data);
  8026 						m_am_tools, new_data);
  7697 
  8027 
  7698 					if (new_data == 0)
  8028 					if (new_data == 0)
  7699 					{
  8029 					{
  7700 						m_eap_fast_completion_status = eap_status_allocation_error;
  8030 						status = eap_status_allocation_error;
  7701 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8031 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  7702 						break;
  8032 						break;
  7703 					}
  8033 					}
  7704 
  8034 
  7705 					new_data->set_type(pacStoreDataRefType);					
  8035 					new_data->set_type(pacStoreDataRefType);					
  7706 
  8036 
  7707 					// Set the reference.
  8037 					// Set the reference.
  7708 					m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(data_reference->get_reference());
  8038 					status = new_data->get_writable_reference()->set_copy_of_buffer(data_reference->get_reference());
  7709 					if (m_eap_fast_completion_status != eap_status_ok)
  8039 					if (status != eap_status_ok)
  7710 					{
  8040 					{
  7711 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8041 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  7712 						break;
  8042 						break;
  7713 					}
  8043 					}
  7714 					
  8044 					
  7715 					m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(&pac_data);
  8045 					status = new_data->get_writable_data()->set_copy_of_buffer(&pac_data);
  7716 					if (m_eap_fast_completion_status != eap_status_ok)
  8046 					if (status != eap_status_ok)
  7717 					{
  8047 					{
  7718 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8048 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  7719 						break;
  8049 						break;
  7720 					}
  8050 					}
  7721 
  8051 
  7722 					automatic_new_data.do_not_free_variable();
  8052 					automatic_new_data.do_not_free_variable();
  7723 
  8053 
  7724 					m_eap_fast_completion_status = m_references_and_data_blocks.add_object(new_data, true);
  8054 					status = m_references_and_data_blocks.add_object(new_data, true);
  7725 					if (m_eap_fast_completion_status != eap_status_ok)
  8055 					if (status != eap_status_ok)
  7726 					{
  8056 					{
  7727 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8057 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  7728 						break;
  8058 						break;
  7729 					}	
  8059 					}	
  7730 					
  8060 					
  7731 					EAP_TRACE_DATA_DEBUG_SYMBIAN(
  8061 					EAP_TRACE_DATA_DEBUG(
  7732 						("eap_pac_store_data_type_PAC_data - added data",
  8062 						m_am_tools,
       
  8063 						TRACE_FLAGS_DEFAULT,
       
  8064 						(EAPL("eap_pac_store_data_type_PAC_data - added data"),
  7733 						(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
  8065 						(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
  7734 						(new_data->get_data())->get_data_length()));
  8066 						(new_data->get_data())->get_data_length()));
  7735 					
  8067 					
  7736 					break;
  8068 					break;
  7737 					
  8069 					
  7769 				
  8101 				
  7770 				m_info_array.ResetAndDestroy();
  8102 				m_info_array.ResetAndDestroy();
  7771 					
  8103 					
  7772 				iPacStoreDb->GetPacStoreDataL(dbTableName, m_info_array);
  8104 				iPacStoreDb->GetPacStoreDataL(dbTableName, m_info_array);
  7773 				
  8105 				
  7774 				EAP_TRACE_DEBUG_SYMBIAN(
  8106 				EAP_TRACE_DEBUG(
  7775 					(_L("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL:Number of entries in table %S=%d\n"),
  8107 					m_am_tools,
       
  8108 					TRACE_FLAGS_DEFAULT,
       
  8109 					(EAPL("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL:Number of entries in table %S=%d\n"),
  7776 					&dbTableName, m_info_array.Count()));
  8110 					&dbTableName, m_info_array.Count()));
  7777 				
  8111 				
  7778 				TInt first_index = 0;
  8112 				TInt first_index = 0;
  7779 
  8113 
  7780 				while (m_info_array.Count() > 0)
  8114 				while (m_info_array.Count() > 0)
  7784 						{
  8118 						{
  7785 						// Note this will get always the first object of array. After the first object is processed it is destryed and removed from array.
  8119 						// Note this will get always the first object of array. After the first object is processed it is destryed and removed from array.
  7786 						TPtr8 infoDataPtr = m_info_array[first_index]->GetData()->Des();
  8120 						TPtr8 infoDataPtr = m_info_array[first_index]->GetData()->Des();
  7787 						TPtr8 infoRefPtr = m_info_array[first_index]->GetReference()->Des();
  8121 						TPtr8 infoRefPtr = m_info_array[first_index]->GetReference()->Des();
  7788 						
  8122 						
  7789 						EAP_TRACE_DATA_DEBUG_SYMBIAN(
  8123 						EAP_TRACE_DATA_DEBUG(
  7790 							("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL: BINARY value from PAC DB (reference)",
  8124 							m_am_tools,
       
  8125 							TRACE_FLAGS_DEFAULT,
       
  8126 							(EAPL("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL: BINARY value from PAC DB (reference)"),
  7791 							infoRefPtr.Ptr(),
  8127 							infoRefPtr.Ptr(),
  7792 							infoRefPtr.Size()));
  8128 							infoRefPtr.Size()));
  7793 						
  8129 						
  7794 						EAP_TRACE_DATA_DEBUG_SYMBIAN(
  8130 						EAP_TRACE_DATA_DEBUG(
  7795 							("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL: BINARY value from PAC DB (value)",
  8131 							m_am_tools,
       
  8132 							TRACE_FLAGS_DEFAULT,
       
  8133 							(EAPL("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL: BINARY value from PAC DB (value)"),
  7796 							infoDataPtr.Ptr(),
  8134 							infoDataPtr.Ptr(),
  7797 							infoDataPtr.Size()));					
  8135 							infoDataPtr.Size()));					
  7798 						
  8136 						
  7799 						eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools);
  8137 						eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools);
  7800 
  8138 
  7801 						eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
  8139 						eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
  7802 							m_am_tools, new_data);
  8140 							m_am_tools, new_data);
  7803 
  8141 
  7804 						if (new_data == 0)
  8142 						if (new_data == 0)
  7805 						{
  8143 						{
  7806 							m_eap_fast_completion_status = eap_status_allocation_error;
  8144 							status = eap_status_allocation_error;
  7807 							(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8145 							(void) EAP_STATUS_RETURN(m_am_tools, status);
  7808 							break;
  8146 							break;
  7809 						}
  8147 						}
  7810 
  8148 
  7811 						new_data->set_type(dataType);					
  8149 						new_data->set_type(dataType);					
  7812 
  8150 
  7813 						// Set the reference.
  8151 						// Set the reference.
  7814 						m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(infoRefPtr.Ptr(), infoRefPtr.Size());
  8152 						status = new_data->get_writable_reference()->set_copy_of_buffer(infoRefPtr.Ptr(), infoRefPtr.Size());
  7815 						if (m_eap_fast_completion_status != eap_status_ok)
  8153 						if (status != eap_status_ok)
  7816 						{
  8154 						{
  7817 							(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8155 							(void) EAP_STATUS_RETURN(m_am_tools, status);
  7818 							delete m_info_array[first_index];
  8156 							delete m_info_array[first_index];
  7819 							m_info_array.Remove(first_index);
  8157 							m_info_array.Remove(first_index);
  7820 							break;
  8158 							break;
  7821 						}
  8159 						}
  7822 						
  8160 						
  7823 						m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(infoDataPtr.Ptr(), infoDataPtr.Size());
  8161 						status = new_data->get_writable_data()->set_copy_of_buffer(infoDataPtr.Ptr(), infoDataPtr.Size());
  7824 						if (m_eap_fast_completion_status != eap_status_ok)
  8162 						if (status != eap_status_ok)
  7825 						{
  8163 						{
  7826 							(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8164 							(void) EAP_STATUS_RETURN(m_am_tools, status);
  7827 							delete m_info_array[first_index];
  8165 							delete m_info_array[first_index];
  7828 							m_info_array.Remove(first_index);
  8166 							m_info_array.Remove(first_index);
  7829 							break;
  8167 							break;
  7830 						}
  8168 						}
  7831 
  8169 
  7832 						automatic_new_data.do_not_free_variable();
  8170 						automatic_new_data.do_not_free_variable();
  7833 
  8171 
  7834 						m_eap_fast_completion_status = m_references_and_data_blocks.add_object(new_data, true);
  8172 						status = m_references_and_data_blocks.add_object(new_data, true);
  7835 						if (m_eap_fast_completion_status != eap_status_ok)
  8173 						if (status != eap_status_ok)
  7836 						{
  8174 						{
  7837 							(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8175 							(void) EAP_STATUS_RETURN(m_am_tools, status);
  7838 							delete m_info_array[first_index];
  8176 							delete m_info_array[first_index];
  7839 							m_info_array.Remove(first_index);
  8177 							m_info_array.Remove(first_index);
  7840 							break;
  8178 							break;
  7841 						}
  8179 						}
  7842 						EAP_TRACE_DATA_DEBUG_SYMBIAN(
  8180 
  7843 							("For GROUP, AID, PAC INFOs - added data",
  8181 						EAP_TRACE_DATA_DEBUG(
       
  8182 							m_am_tools,
       
  8183 							TRACE_FLAGS_DEFAULT,
       
  8184 							(EAPL("For GROUP, AID, PAC INFOs - added data"),
  7844 							(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
  8185 							(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
  7845 							(new_data->get_data())->get_data_length()));					
  8186 							(new_data->get_data())->get_data_length()));					
  7846 						}
  8187 						}
  7847 							
  8188 							
  7848 					delete m_info_array[first_index];
  8189 					delete m_info_array[first_index];
  7850 					
  8191 					
  7851 		
  8192 		
  7852 					} // End: while
  8193 					} // End: while
  7853 					
  8194 					
  7854 				
  8195 				
  7855 					if (m_eap_fast_completion_status != eap_status_ok)
  8196 					if (status != eap_status_ok)
  7856 					{
  8197 					{
  7857 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8198 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  7858 						break;
  8199 						break;
  7859 					}
  8200 					}
  7860 				
  8201 				
  7861 					break;
  8202 					break;
  7862 				} // End: case eap_pac_store_data_type_group_info:
  8203 				} // End: case eap_pac_store_data_type_group_info:
  7877 					
  8218 					
  7878 					if(m_PAC_store_password.get_data_length() == 0)
  8219 					if(m_PAC_store_password.get_data_length() == 0)
  7879 					{
  8220 					{
  7880 						// Nothing in the PAC store DB.
  8221 						// Nothing in the PAC store DB.
  7881 						
  8222 						
  7882 						EAP_TRACE_DEBUG_SYMBIAN(
  8223 						EAP_TRACE_DEBUG(
  7883 							(_L("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL: NO PW in PAC store. Try Notifier")));					
  8224 							m_am_tools,
       
  8225 							TRACE_FLAGS_DEFAULT,
       
  8226 							(EAPL("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL: NO PW in PAC store. Try Notifier")));					
  7884 						
  8227 						
  7885 					
  8228 					
  7886 						// Show the password query notifier to get the password.
  8229 						// Show the password query notifier to get the password.
  7887 					
  8230 					
  7888 						m_ready_references_array_index = ind;
  8231 						m_ready_references_array_index = ind;
  7897 
  8240 
  7898 						m_both_asked++;
  8241 						m_both_asked++;
  7899 
  8242 
  7900 						if(iPacStoreDb->IsMasterKeyPresentL())
  8243 						if(iPacStoreDb->IsMasterKeyPresentL())
  7901 							{
  8244 							{
  7902 				    TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  8245 							TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  7903 				    
  8246 							
  7904 				    m_notifier_data_to_user->iPassword.Zero();
  8247 							m_notifier_data_to_user->iPassword.Zero();
  7905 				    
  8248 							
  7906 				    if (iEapAuthNotifier == 0)
  8249 							if (iEapAuthNotifier == 0)
  7907 				    	{
  8250 								{
  7908 				    	iEapAuthNotifier = CEapAuthNotifier::NewL( *this );
  8251 								iEapAuthNotifier = CEapAuthNotifier::NewL( *this );
  7909 				    	}
  8252 								}
  7910 				    else
  8253 							else
  7911 					   	{
  8254 								{
  7912 						 	iEapAuthNotifier->Cancel();
  8255 								iEapAuthNotifier->Cancel();
  7913 				     	}
  8256 								}
  7914 				
  8257 						
  7915 				    iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastPacStorePwQueryDialog, m_notifier_data_to_user, aEapType);
  8258 							m_eap_fast_completion_status = eap_status_pending_request;
  7916 
  8259 
  7917 
  8260 							iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastPacStorePwQueryDialog, m_notifier_data_to_user, aEapType);
  7918 							}
  8261 							}
  7919 						else
  8262 						else
  7920 							{
  8263 							{
  7921 							m_state =  EMasterkeyQuery; 
  8264 							m_state =  EMasterkeyQuery; 
  7922 					    TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  8265 							TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  7923 					    
  8266 							
  7924 					    m_notifier_data_to_user->iPassword.Zero();
  8267 							m_notifier_data_to_user->iPassword.Zero();
  7925 					    
  8268 							
  7926 					    if (iEapAuthNotifier == 0)
  8269 							if (iEapAuthNotifier == 0)
  7927 					    	{
  8270 								{
  7928 					    	iEapAuthNotifier = CEapAuthNotifier::NewL( *this );
  8271 								iEapAuthNotifier = CEapAuthNotifier::NewL( *this );
  7929 					    	}
  8272 								}
  7930 					    else
  8273 							else
  7931 						   	{
  8274 								{
  7932 							 	iEapAuthNotifier->Cancel();
  8275 								iEapAuthNotifier->Cancel();
  7933 					     	}
  8276 								}
  7934 					
  8277 						
  7935 					    iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastCreateMasterkeyQueryDialog, m_notifier_data_to_user, aEapType);
  8278 							m_eap_fast_completion_status = eap_status_pending_request;
  7936 
  8279 
       
  8280 							iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastCreateMasterkeyQueryDialog, m_notifier_data_to_user, aEapType);
  7937 							}
  8281 							}
  7938 
  8282 
  7939 						break;
  8283 						break;
  7940 					}
  8284 					}
  7941 			
  8285 			
  7944 					eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
  8288 					eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
  7945 						m_am_tools, new_data);
  8289 						m_am_tools, new_data);
  7946 
  8290 
  7947 					if (new_data == 0)
  8291 					if (new_data == 0)
  7948 					{
  8292 					{
  7949 						m_eap_fast_completion_status = eap_status_allocation_error;
  8293 						status = eap_status_allocation_error;
  7950 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8294 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  7951 						break;
  8295 						break;
  7952 					}
  8296 					}
  7953 
  8297 
  7954 					new_data->set_type(pacStoreDataRefType);
  8298 					new_data->set_type(pacStoreDataRefType);
  7955 					
  8299 					
  7956 					// Set the reference.
  8300 					// Set the reference.
  7957 					m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(data_reference->get_reference());
  8301 					status = new_data->get_writable_reference()->set_copy_of_buffer(data_reference->get_reference());
  7958 					if (m_eap_fast_completion_status != eap_status_ok)
  8302 					if (status != eap_status_ok)
  7959 					{
  8303 					{
  7960 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8304 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  7961 						break;
  8305 						break;
  7962 					}					
  8306 					}					
  7963 
  8307 
  7964 					m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(&m_PAC_store_password);
  8308 					status = new_data->get_writable_data()->set_copy_of_buffer(&m_PAC_store_password);
  7965 
  8309 
  7966 					if (m_eap_fast_completion_status != eap_status_ok)
  8310 					if (status != eap_status_ok)
  7967 					{
  8311 					{
  7968 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8312 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  7969 						break;
  8313 						break;
  7970 					}
  8314 					}
  7971 
  8315 
  7972 					automatic_new_data.do_not_free_variable();
  8316 					automatic_new_data.do_not_free_variable();
  7973 
  8317 
  7974 					m_eap_fast_completion_status = m_references_and_data_blocks.add_object(new_data, true);
  8318 					status = m_references_and_data_blocks.add_object(new_data, true);
  7975 					if (m_eap_fast_completion_status != eap_status_ok)
  8319 					if (status != eap_status_ok)
  7976 					{
  8320 					{
  7977 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8321 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  7978 						break;
  8322 						break;
  7979 					}
  8323 					}
  7980 					
  8324 					
  7981 					EAP_TRACE_DATA_DEBUG_SYMBIAN(
  8325 					EAP_TRACE_DATA_DEBUG(
  7982 						("eap_pac_store_data_type_PAC_store_password - added data",
  8326 						m_am_tools,
       
  8327 						TRACE_FLAGS_DEFAULT,
       
  8328 						(EAPL("eap_pac_store_data_type_PAC_store_password - added data"),
  7983 						(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
  8329 						(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
  7984 						(new_data->get_data())->get_data_length()));
  8330 						(new_data->get_data())->get_data_length()));
  7985 				
  8331 				
  7986 					m_eap_fast_completion_status = eap_status_pending_request;	
       
  7987 					
       
  7988 					break;
  8332 					break;
  7989 					
  8333 					
  7990 				} // End: case eap_pac_store_data_type_PAC_store_password:
  8334 				} // End: case eap_pac_store_data_type_PAC_store_password:
  7991 				
  8335 				
  7992 				case eap_pac_store_data_type_PAC_store_device_seed:
  8336 				case eap_pac_store_data_type_PAC_store_device_seed:
  7993 				{
  8337 				{
  7994 					// To get the device seed.
  8338 					// To get the device seed.
  7995 					
  8339 					
  7996 					// Create a device seed.
  8340 					// Create a device seed.
  7997 				
  8341 				
  7998 				    eap_variable_data_c m_PAC_store_device_seed(m_am_tools);
  8342 					eap_variable_data_c m_PAC_store_device_seed(m_am_tools);
  7999 				    m_eap_fast_completion_status = m_PAC_store_device_seed.set_copy_of_buffer(
  8343 					status = m_PAC_store_device_seed.set_copy_of_buffer(
  8000 				    	iPacStoreDeviceSeed );
  8344 						iPacStoreDeviceSeed );
  8001 					if ( m_eap_fast_completion_status != eap_status_ok )
  8345 					if ( status != eap_status_ok )
  8002 					    {
  8346 						{
  8003 					    EAP_TRACE_DEBUG_SYMBIAN(
  8347 						EAP_TRACE_DEBUG(
  8004 							(_L("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL: ERROR: seed data is not valid.")));	
  8348 							m_am_tools,
  8005 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8349 							TRACE_FLAGS_DEFAULT,
       
  8350 							(EAPL("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL: ERROR: seed data is not valid.")));	
       
  8351 
       
  8352 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  8006 						break;
  8353 						break;
  8007 					    }
  8354 						}
  8008 				    
  8355 					
  8009 					// continue normally
  8356 					// continue normally
  8010 					EAP_TRACE_DATA_DEBUG_SYMBIAN(
  8357 					EAP_TRACE_DATA_DEBUG(
  8011 						("Device Seed",
  8358 						m_am_tools,
       
  8359 						TRACE_FLAGS_DEFAULT,
       
  8360 						(EAPL("Device Seed"),
  8012 						m_PAC_store_device_seed.get_data(m_PAC_store_device_seed.get_data_length()),
  8361 						m_PAC_store_device_seed.get_data(m_PAC_store_device_seed.get_data_length()),
  8013 						m_PAC_store_device_seed.get_data_length()));
  8362 						m_PAC_store_device_seed.get_data_length()));
  8014 										
  8363 										
  8015 					eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools);
  8364 					eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools);
  8016 
  8365 
  8017 					eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
  8366 					eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
  8018 						m_am_tools, new_data);
  8367 						m_am_tools, new_data);
  8019 
  8368 
  8020 					if (new_data == 0)
  8369 					if (new_data == 0)
  8021 					{
  8370 					{
  8022 						m_eap_fast_completion_status = eap_status_allocation_error;
  8371 						status = eap_status_allocation_error;
  8023 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8372 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  8024 						break;
  8373 						break;
  8025 					}
  8374 					}
  8026 
  8375 
  8027 					new_data->set_type(pacStoreDataRefType);
  8376 					new_data->set_type(pacStoreDataRefType);
  8028 					
  8377 					
  8029 					// Set the reference.
  8378 					// Set the reference.
  8030 					m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(data_reference->get_reference());
  8379 					status = new_data->get_writable_reference()->set_copy_of_buffer(data_reference->get_reference());
  8031 					if (m_eap_fast_completion_status != eap_status_ok)
  8380 					if (status != eap_status_ok)
  8032 					{
  8381 					{
  8033 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8382 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  8034 						break;
  8383 						break;
  8035 					}					
  8384 					}					
  8036 
  8385 
  8037 					m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(&m_PAC_store_device_seed);
  8386 					status = new_data->get_writable_data()->set_copy_of_buffer(&m_PAC_store_device_seed);
  8038 
  8387 
  8039 					if (m_eap_fast_completion_status != eap_status_ok)
  8388 					if (status != eap_status_ok)
  8040 					{
  8389 					{
  8041 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8390 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  8042 						break;
  8391 						break;
  8043 					}
  8392 					}
  8044 
  8393 
  8045 					automatic_new_data.do_not_free_variable();
  8394 					automatic_new_data.do_not_free_variable();
  8046 
  8395 
  8047 					m_eap_fast_completion_status = m_references_and_data_blocks.add_object(new_data, true);
  8396 					status = m_references_and_data_blocks.add_object(new_data, true);
  8048 					if (m_eap_fast_completion_status != eap_status_ok)
  8397 					if (status != eap_status_ok)
  8049 					{
  8398 					{
  8050 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8399 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  8051 						break;
  8400 						break;
  8052 					}
  8401 					}
  8053 					
  8402 					
  8054 					EAP_TRACE_DATA_DEBUG_SYMBIAN(
  8403 					EAP_TRACE_DATA_DEBUG(
  8055 						("eap_pac_store_data_type_PAC_store_device_seed - added data",
  8404 						m_am_tools,
       
  8405 						TRACE_FLAGS_DEFAULT,
       
  8406 						(EAPL("eap_pac_store_data_type_PAC_store_device_seed - added data"),
  8056 						(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
  8407 						(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
  8057 						(new_data->get_data())->get_data_length()));					
  8408 						(new_data->get_data())->get_data_length()));					
  8058 					
  8409 					
  8059 					break;
  8410 					break;
  8060 				} // End: case eap_pac_store_data_type_PAC_store_device_seed:
  8411 				} // End: case eap_pac_store_data_type_PAC_store_device_seed:
  8068 					eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
  8419 					eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
  8069 						m_am_tools, new_data);
  8420 						m_am_tools, new_data);
  8070 
  8421 
  8071 					if (new_data == 0)
  8422 					if (new_data == 0)
  8072 					{
  8423 					{
  8073 						m_eap_fast_completion_status = eap_status_allocation_error;
  8424 						status = eap_status_allocation_error;
  8074 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8425 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  8075 						break;
  8426 						break;
  8076 					}
  8427 					}
  8077 
  8428 
  8078 					new_data->set_type(pacStoreDataRefType);
  8429 					new_data->set_type(pacStoreDataRefType);
  8079 					
  8430 					
  8080 					// Set the reference.
  8431 					// Set the reference.
  8081 					m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(data_reference->get_reference());
  8432 					status = new_data->get_writable_reference()->set_copy_of_buffer(data_reference->get_reference());
  8082 					if (m_eap_fast_completion_status != eap_status_ok)
  8433 					if (status != eap_status_ok)
  8083 					{
  8434 					{
  8084 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8435 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  8085 						break;
  8436 						break;
  8086 					}					
  8437 					}					
  8087 					
  8438 					
  8088 					// Provide Service table id (m_index) and type (m_index_type) 
  8439 					// Provide Service table id (m_index) and type (m_index_type) 
  8089 					// in the specified format.
  8440 					// in the specified format.
  8093 					
  8444 					
  8094 					eap_variable_data_c tmp_EAP_FAST_IAP_reference(m_am_tools);
  8445 					eap_variable_data_c tmp_EAP_FAST_IAP_reference(m_am_tools);
  8095 					
  8446 					
  8096 					// Copy the index and index type. The order of copying is important.
  8447 					// Copy the index and index type. The order of copying is important.
  8097 					
  8448 					
  8098 					m_eap_fast_completion_status = tmp_EAP_FAST_IAP_reference.set_copy_of_buffer(&tmpIndex,sizeof(i32_t));
  8449 					status = tmp_EAP_FAST_IAP_reference.set_copy_of_buffer(&tmpIndex,sizeof(i32_t));
  8099 					if (m_eap_fast_completion_status != eap_status_ok)
  8450 					if (status != eap_status_ok)
  8100 					{
  8451 					{
  8101 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8452 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  8102 						break;
  8453 						break;
  8103 					}
  8454 					}
  8104 					
  8455 					
  8105 					m_eap_fast_completion_status = tmp_EAP_FAST_IAP_reference.add_data(&tmpIndexType,sizeof(i32_t));
  8456 					status = tmp_EAP_FAST_IAP_reference.add_data(&tmpIndexType,sizeof(i32_t));
  8106 					if (m_eap_fast_completion_status != eap_status_ok)
  8457 					if (status != eap_status_ok)
  8107 					{
  8458 					{
  8108 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8459 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  8109 						break;
  8460 						break;
  8110 					}
  8461 					}
  8111 
  8462 
  8112 					if (tmp_EAP_FAST_IAP_reference.get_is_valid_data() == true)
  8463 					if (tmp_EAP_FAST_IAP_reference.get_is_valid_data() == true)
  8113 					{
  8464 					{
  8114 						m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(&tmp_EAP_FAST_IAP_reference);
  8465 						status = new_data->get_writable_data()->set_copy_of_buffer(&tmp_EAP_FAST_IAP_reference);
  8115 
  8466 
  8116 						if (m_eap_fast_completion_status != eap_status_ok)
  8467 						if (status != eap_status_ok)
  8117 						{
  8468 						{
  8118 							(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8469 							(void) EAP_STATUS_RETURN(m_am_tools, status);
  8119 							break;
  8470 							break;
  8120 						}
  8471 						}
  8121 					}
  8472 					}
  8122 					
  8473 					
  8123 					automatic_new_data.do_not_free_variable();					
  8474 					automatic_new_data.do_not_free_variable();					
  8124 
  8475 
  8125 					m_eap_fast_completion_status = m_references_and_data_blocks.add_object(new_data, true);
  8476 					status = m_references_and_data_blocks.add_object(new_data, true);
  8126 					if (m_eap_fast_completion_status != eap_status_ok)
  8477 					if (status != eap_status_ok)
  8127 					{
  8478 					{
  8128 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8479 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  8129 						break;
  8480 						break;
  8130 					}
  8481 					}
  8131 						
  8482 						
  8132 					EAP_TRACE_DATA_DEBUG_SYMBIAN(
  8483 					EAP_TRACE_DATA_DEBUG(
  8133 						("eap_pac_store_data_type_PAC_store_IAP_reference - added data",
  8484 						m_am_tools,
       
  8485 						TRACE_FLAGS_DEFAULT,
       
  8486 						(EAPL("eap_pac_store_data_type_PAC_store_IAP_reference - added data"),
  8134 						(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
  8487 						(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
  8135 						(new_data->get_data())->get_data_length()));
  8488 						(new_data->get_data())->get_data_length()));
  8136 					
  8489 					
  8137 					break;
  8490 					break;
  8138 					
  8491 					
  8155 						&groupDbReferenceData);
  8508 						&groupDbReferenceData);
  8156 					
  8509 					
  8157 					// groupDbReferenceData should have the value stored in PAC store DB.
  8510 					// groupDbReferenceData should have the value stored in PAC store DB.
  8158 					// Doesn't matter even if it is empty. Proceed as normal case.
  8511 					// Doesn't matter even if it is empty. Proceed as normal case.
  8159 					
  8512 					
  8160 					EAP_TRACE_DATA_DEBUG_SYMBIAN(
  8513 					EAP_TRACE_DATA_DEBUG(
  8161 						("PAC group ref from PAC store DB",
  8514 						m_am_tools,
       
  8515 						TRACE_FLAGS_DEFAULT,
       
  8516 						(EAPL("PAC group ref from PAC store DB"),
  8162 						groupDbReferenceData.get_data(groupDbReferenceData.get_data_length()), 
  8517 						groupDbReferenceData.get_data(groupDbReferenceData.get_data_length()), 
  8163 						groupDbReferenceData.get_data_length()));
  8518 						groupDbReferenceData.get_data_length()));
  8164 										
  8519 										
  8165 					eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools);
  8520 					eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools);
  8166 
  8521 
  8167 					eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
  8522 					eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
  8168 						m_am_tools, new_data);
  8523 						m_am_tools, new_data);
  8169 
  8524 
  8170 					if (new_data == 0)
  8525 					if (new_data == 0)
  8171 					{
  8526 					{
  8172 						m_eap_fast_completion_status = eap_status_allocation_error;
  8527 						status = eap_status_allocation_error;
  8173 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8528 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  8174 						break;
  8529 						break;
  8175 					}
  8530 					}
  8176 
  8531 
  8177 					new_data->set_type(pacStoreDataRefType);
  8532 					new_data->set_type(pacStoreDataRefType);
  8178 					
  8533 					
  8179 					// Set the reference.
  8534 					// Set the reference.
  8180 					m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(&groupDbReferenceData);
  8535 					status = new_data->get_writable_reference()->set_copy_of_buffer(&groupDbReferenceData);
  8181 					if (m_eap_fast_completion_status != eap_status_ok)
  8536 					if (status != eap_status_ok)
  8182 					{
  8537 					{
  8183 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8538 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  8184 						break;
  8539 						break;
  8185 					}					
  8540 					}					
  8186 
  8541 
  8187 					eap_variable_data_c group_data_2(m_am_tools);
  8542 					eap_variable_data_c group_data_2(m_am_tools);
  8188 					
  8543 					
  8195 				    						
  8550 				    						
  8196 #endif	// End: #ifdef USE_PAC_STORE
  8551 #endif	// End: #ifdef USE_PAC_STORE
  8197 
  8552 
  8198 					if ( group_data_2.get_data_length() == 0 )
  8553 					if ( group_data_2.get_data_length() == 0 )
  8199 						{
  8554 						{
  8200 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8555 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  8201 						break;						
  8556 						break;						
  8202 						}
  8557 						}
  8203 						
  8558 						
  8204 					m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(&group_data_2);
  8559 					status = new_data->get_writable_data()->set_copy_of_buffer(&group_data_2);
  8205 
  8560 
  8206 					if (m_eap_fast_completion_status != eap_status_ok)
  8561 					if (status != eap_status_ok)
  8207 					{
  8562 					{
  8208 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8563 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  8209 						break;
  8564 						break;
  8210 					}
  8565 					}
  8211 
  8566 
  8212 					automatic_new_data.do_not_free_variable();
  8567 					automatic_new_data.do_not_free_variable();
  8213 
  8568 
  8214 					m_eap_fast_completion_status = m_references_and_data_blocks.add_object(new_data, true);
  8569 					status = m_references_and_data_blocks.add_object(new_data, true);
  8215 					if (m_eap_fast_completion_status != eap_status_ok)
  8570 					if (status != eap_status_ok)
  8216 					{
  8571 					{
  8217 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8572 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  8218 						break;
  8573 						break;
  8219 					}
  8574 					}
  8220 					
  8575 					
  8221 					EAP_TRACE_DATA_DEBUG_SYMBIAN(
  8576 					EAP_TRACE_DATA_DEBUG(
  8222 						("eap_pac_store_data_type_PAC_store_group_reference - added data",
  8577 						m_am_tools,
       
  8578 						TRACE_FLAGS_DEFAULT,
       
  8579 						(EAPL("eap_pac_store_data_type_PAC_store_group_reference - added data"),
  8223 						(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
  8580 						(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
  8224 						(new_data->get_data())->get_data_length()));										
  8581 						(new_data->get_data())->get_data_length()));										
  8225 					
  8582 					
  8226 					break;
  8583 					break;
  8227 					
  8584 					
  8241 
  8598 
  8242 					m_state = EFilePasswordQuery;
  8599 					m_state = EFilePasswordQuery;
  8243 
  8600 
  8244 					m_both_asked++;
  8601 					m_both_asked++;
  8245 
  8602 
  8246 			    TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  8603 					TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  8247 			    
  8604 					
  8248 			    m_notifier_data_to_user->iPassword.Zero();
  8605 					m_notifier_data_to_user->iPassword.Zero();
  8249 			    
  8606 					
  8250 			    if (iEapAuthNotifier == 0)
  8607 					if (iEapAuthNotifier == 0)
  8251 			    	{
       
  8252 			    	iEapAuthNotifier = CEapAuthNotifier::NewL( *this );
       
  8253 			    	}
       
  8254 			    else
       
  8255 				   	{
       
  8256 					 	iEapAuthNotifier->Cancel();
       
  8257 			     	}
       
  8258 			
       
  8259 			    iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastPacFilePwQueryDialog, m_notifier_data_to_user, aEapType);
       
  8260 
       
  8261 					if (m_eap_fast_completion_status != eap_status_ok)
       
  8262 						{
  8608 						{
  8263 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8609 						iEapAuthNotifier = CEapAuthNotifier::NewL( *this );
       
  8610 						}
       
  8611 					else
       
  8612 						{
       
  8613 							iEapAuthNotifier->Cancel();
       
  8614 						}
       
  8615 				
       
  8616 					iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastPacFilePwQueryDialog, m_notifier_data_to_user, aEapType);
       
  8617 
       
  8618 					if (status != eap_status_ok)
       
  8619 						{
       
  8620 						(void) EAP_STATUS_RETURN(m_am_tools, status);
  8264 						break;
  8621 						break;
  8265 						}
  8622 						}
  8266 
  8623 
  8267 					break;
  8624 					break;
  8268 					
  8625 					
  8270 			
  8627 			
  8271 				default:
  8628 				default:
  8272 				{
  8629 				{
  8273 					// Unknown data query.
  8630 					// Unknown data query.
  8274 					
  8631 					
  8275 					EAP_TRACE_DEBUG_SYMBIAN(
  8632 					EAP_TRACE_DEBUG(
  8276 						(_L("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL: ERROR: Unknown data type")));					
  8633 						m_am_tools,
       
  8634 						TRACE_FLAGS_DEFAULT,
       
  8635 						(EAPL("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL: ERROR: Unknown data type")));					
  8277 										
  8636 										
  8278 					m_eap_fast_completion_status = eap_status_not_found;
  8637 					status = eap_status_not_found;
  8279 					(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8638 					(void) EAP_STATUS_RETURN(m_am_tools, status);
  8280 					break;
  8639 					break;
  8281 				}
  8640 				}
  8282 				
  8641 				
  8283 			} // End: switch(pacStoreDataRefType)			
  8642 			} // End: switch(pacStoreDataRefType)			
  8284 		}
  8643 		}
  8285 	} // for ()
  8644 	} // for ()
  8286 
  8645 
       
  8646 
  8287 	if (m_both_asked)
  8647 	if (m_both_asked)
  8288 	{
  8648 	{
  8289 		m_eap_fast_completion_status = eap_status_pending_request;
  8649 		m_eap_fast_completion_status = eap_status_pending_request;
  8290 	}
  8650 	}
  8291 
  8651 
       
  8652 
  8292 	m_info_array.ResetAndDestroy();
  8653 	m_info_array.ResetAndDestroy();
  8293 
  8654 
  8294 	EAP_TRACE_DEBUG_SYMBIAN(
  8655 	EAP_TRACE_DEBUG(
  8295 		(_L("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL-End, m_eap_fast_completion_status=%d"),
  8656 		m_am_tools,
  8296 		m_eap_fast_completion_status));			
  8657 		TRACE_FLAGS_DEFAULT,
  8297 	
  8658 		(EAPL("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL-End, status=%d=%s, m_eap_fast_completion_status=%d=%s"),
       
  8659 		status,
       
  8660 		eap_status_string_c::get_status_string(status),
       
  8661 		m_eap_fast_completion_status,
       
  8662 		eap_status_string_c::get_status_string(m_eap_fast_completion_status)));
       
  8663 
  8298 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
  8664 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
  8299 	return; 
  8665 	return; 
  8300 }
  8666 }
  8301 		
  8667 		
  8302 
  8668 
  8360 		(void) EAP_STATUS_RETURN(m_am_tools, status);		
  8726 		(void) EAP_STATUS_RETURN(m_am_tools, status);		
  8361 	}
  8727 	}
  8362 
  8728 
  8363 	// - - - - - - - - - - - - - - - - - - - - - - - -	
  8729 	// - - - - - - - - - - - - - - - - - - - - - - - -	
  8364 	
  8730 	
  8365 	EAP_TRACE_DEBUG_SYMBIAN(
  8731 	EAP_TRACE_DEBUG(
  8366 		(_L("eap_am_type_tls_peap_symbian_c::write_PAC_store_data-End, status=%d, m_eap_fast_completion_status=%d"),
  8732 		m_am_tools,
  8367 		status, m_eap_fast_completion_status));			
  8733 		TRACE_FLAGS_DEFAULT,
       
  8734 		(EAPL("eap_am_type_tls_peap_symbian_c::write_PAC_store_data-End, status=%d, m_eap_fast_completion_status=%d"),
       
  8735 		status,
       
  8736 		m_eap_fast_completion_status));			
  8368 	
  8737 	
  8369 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  8738 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  8370 	return EAP_STATUS_RETURN(m_am_tools, status);
  8739 	return EAP_STATUS_RETURN(m_am_tools, status);
  8371 }
  8740 }
  8372 
  8741 
  8409 				TRACE_FLAGS_DEFAULT,
  8778 				TRACE_FLAGS_DEFAULT,
  8410 				(EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::WritePACStoreDataL(): type %d=%s\n"),
  8779 				(EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::WritePACStoreDataL(): type %d=%s\n"),
  8411 				data_reference->get_type(),
  8780 				data_reference->get_type(),
  8412 				eap_fast_tlv_header_string_c::get_fast_pac_store_data_string(data_reference->get_type())));
  8781 				eap_fast_tlv_header_string_c::get_fast_pac_store_data_string(data_reference->get_type())));
  8413 			
  8782 			
  8414 			EAP_TRACE_DATA_DEBUG_SYMBIAN(
  8783 			EAP_TRACE_DATA_DEBUG(
  8415 				("WritePACStoreDataL(): data_reference data(value):",
  8784 				m_am_tools,
       
  8785 				TRACE_FLAGS_DEFAULT,
       
  8786 				(EAPL("WritePACStoreDataL(): data_reference data(value):"),
  8416 				data_reference->get_data()->get_data(data_reference->get_data()->get_data_length()), 
  8787 				data_reference->get_data()->get_data(data_reference->get_data()->get_data_length()), 
  8417 				data_reference->get_data()->get_data_length()));
  8788 				data_reference->get_data()->get_data_length()));
  8418 			
  8789 			
  8419 			EAP_TRACE_DATA_DEBUG_SYMBIAN(
  8790 			EAP_TRACE_DATA_DEBUG(
  8420 				("WritePACStoreDataL(): data_reference reference:",
  8791 				m_am_tools,
       
  8792 				TRACE_FLAGS_DEFAULT,
       
  8793 				(EAPL("WritePACStoreDataL(): data_reference reference:"),
  8421 				data_reference->get_reference()->get_data(data_reference->get_reference()->get_data_length()), 
  8794 				data_reference->get_reference()->get_data(data_reference->get_reference()->get_data_length()), 
  8422 				data_reference->get_reference()->get_data_length()));
  8795 				data_reference->get_reference()->get_data_length()));
  8423 			
  8796 			
  8424 			EAP_TRACE_DEBUG_SYMBIAN(
  8797 			EAP_TRACE_DEBUG(
  8425 				(_L("eap_am_type_tls_peap_symbian_c::WritePACStoreDataL: change status=%d (0=eap_pac_store_data_change_status_none)"),
  8798 				m_am_tools,
       
  8799 				TRACE_FLAGS_DEFAULT,
       
  8800 				(EAPL("eap_am_type_tls_peap_symbian_c::WritePACStoreDataL: change status=%d (0=eap_pac_store_data_change_status_none)"),
  8426 				data_reference->get_change_status()));
  8801 				data_reference->get_change_status()));
  8427 
  8802 
  8428 			if (data_reference != 0
  8803 			if (data_reference != 0
  8429 				&& data_reference->get_is_valid() == true
  8804 				&& data_reference->get_is_valid() == true
  8430 				&& data_reference->get_type() != eap_pac_store_data_type_none
  8805 				&& data_reference->get_type() != eap_pac_store_data_type_none
  8446 				HBufC8* pacStoreDBColVal8 = HBufC8::NewLC(data_reference->get_data()->get_data_length());
  8821 				HBufC8* pacStoreDBColVal8 = HBufC8::NewLC(data_reference->get_data()->get_data_length());
  8447 				TPtr8 pacStoreDBColValPtr8 = pacStoreDBColVal8->Des();
  8822 				TPtr8 pacStoreDBColValPtr8 = pacStoreDBColVal8->Des();
  8448 				pacStoreDBColValPtr8.Copy(data_reference->get_data()->get_data(),
  8823 				pacStoreDBColValPtr8.Copy(data_reference->get_data()->get_data(),
  8449 										  data_reference->get_data()->get_data_length());
  8824 										  data_reference->get_data()->get_data_length());
  8450 				
  8825 				
  8451 				EAP_TRACE_DATA_DEBUG_SYMBIAN(
  8826 				EAP_TRACE_DATA_DEBUG(
  8452 					("write_PAC_store_dataL(): 8 bit VALUE from common:",
  8827 					m_am_tools,
       
  8828 					TRACE_FLAGS_DEFAULT,
       
  8829 					(EAPL("write_PAC_store_dataL(): 8 bit VALUE from common:"),
  8453 					pacStoreDBColValPtr8.Ptr(), 
  8830 					pacStoreDBColValPtr8.Ptr(), 
  8454 					pacStoreDBColValPtr8.Size()));
  8831 					pacStoreDBColValPtr8.Size()));
  8455 				
  8832 				
  8456 				/* Get the reference from the input */			
  8833 				/* Get the reference from the input */			
  8457 				HBufC8* pacStoreDBColRef8 = HBufC8::NewLC(data_reference->get_reference()->get_data_length());
  8834 				HBufC8* pacStoreDBColRef8 = HBufC8::NewLC(data_reference->get_reference()->get_data_length());
  8458 				TPtr8 pacStoreDBColRefPtr8 = pacStoreDBColRef8->Des();
  8835 				TPtr8 pacStoreDBColRefPtr8 = pacStoreDBColRef8->Des();
  8459 				pacStoreDBColRefPtr8.Copy(data_reference->get_reference()->get_data(),
  8836 				pacStoreDBColRefPtr8.Copy(data_reference->get_reference()->get_data(),
  8460 										  data_reference->get_reference()->get_data_length());
  8837 										  data_reference->get_reference()->get_data_length());
  8461 
  8838 
  8462 				EAP_TRACE_DATA_DEBUG_SYMBIAN(
  8839 				EAP_TRACE_DATA_DEBUG(
  8463 					("write_PAC_store_dataL(): 8 bit REFERENCE from common:",
  8840 					m_am_tools,
       
  8841 					TRACE_FLAGS_DEFAULT,
       
  8842 					(EAPL("write_PAC_store_dataL(): 8 bit REFERENCE from common:"),
  8464 					pacStoreDBColRefPtr8.Ptr(), 
  8843 					pacStoreDBColRefPtr8.Ptr(), 
  8465 					pacStoreDBColRefPtr8.Size()));
  8844 					pacStoreDBColRefPtr8.Size()));
  8466 			
  8845 			
  8467 				writeToPacStore = EFalse;
  8846 				writeToPacStore = EFalse;
  8468 				
  8847 				
  8556 					}
  8935 					}
  8557 					default:
  8936 					default:
  8558 					{
  8937 					{
  8559 						// Unknown data type.
  8938 						// Unknown data type.
  8560 						
  8939 						
  8561 						EAP_TRACE_DEBUG_SYMBIAN(
  8940 						EAP_TRACE_DEBUG(
  8562 							(_L("eap_am_type_tls_peap_symbian_c::WritePACStoreDataL: ERROR: Unknown data type")));					
  8941 							m_am_tools,
       
  8942 							TRACE_FLAGS_DEFAULT,
       
  8943 							(EAPL("eap_am_type_tls_peap_symbian_c::WritePACStoreDataL: ERROR: Unknown data type")));
  8563 											
  8944 											
  8564 						m_eap_fast_completion_status = eap_status_not_found;
  8945 						m_eap_fast_completion_status = eap_status_not_found;
  8565 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8946 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8566 						break;
  8947 						break;
  8567 					}
  8948 					}
  8626 					 data_reference->get_data()->get_data_length()));
  9007 					 data_reference->get_data()->get_data_length()));
  8627 			}
  9008 			}
  8628 		}
  9009 		}
  8629 	} // for ()
  9010 	} // for ()
  8630 
  9011 
  8631 	EAP_TRACE_DEBUG_SYMBIAN(
  9012 	EAP_TRACE_DEBUG(
  8632 		(_L("eap_am_type_tls_peap_symbian_c::WritePACStoreDataL-End, m_eap_fast_completion_status=%d"),
  9013 		m_am_tools,
       
  9014 		TRACE_FLAGS_DEFAULT,
       
  9015 		(EAPL("eap_am_type_tls_peap_symbian_c::WritePACStoreDataL-End, m_eap_fast_completion_status=%d"),
  8633 		m_eap_fast_completion_status));			
  9016 		m_eap_fast_completion_status));			
  8634 	
  9017 	
  8635 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);		
  9018 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);		
  8636 }
  9019 }
  8637 
  9020 
  8653 			(m_is_client == true ? "client": "server"),
  9036 			(m_is_client == true ? "client": "server"),
  8654 			this));
  9037 			this));
  8655 	
  9038 	
  8656 	m_eap_fast_completion_status = eap_status_ok;
  9039 	m_eap_fast_completion_status = eap_status_ok;
  8657 
  9040 
  8658 	TRAPD(err, CompleteAddImportedPACFileL(in_imported_PAC_filename, out_used_group_reference));
  9041 	TRAPD(error, CompleteAddImportedPACFileL(in_imported_PAC_filename, out_used_group_reference));
  8659 	if (err != KErrNone)
  9042 	if (error != KErrNone)
  8660 		{
  9043 		{
  8661 		EAP_TRACE_DEBUG(
  9044 		EAP_TRACE_DEBUG(
  8662 				m_am_tools,
  9045 				m_am_tools,
  8663 				TRACE_FLAGS_DEFAULT,
  9046 				TRACE_FLAGS_DEFAULT,
  8664 				(EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::read_PAC_store_data() ERROR: LEAVE from CompleteAddImportedPACFfileL error=%d"),
  9047 				(EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::read_PAC_store_data() ERROR: LEAVE from CompleteAddImportedPACFfileL error=%d"),
  8665 				err));
  9048 				error));
  8666 				
  9049 				
  8667 			m_eap_fast_completion_status = m_am_tools->convert_am_error_to_eapol_error(err);
  9050 			m_eap_fast_completion_status = m_am_tools->convert_am_error_to_eapol_error(error);
  8668 		}
  9051 		}
  8669 
  9052 
  8670    	m_eap_fast_completion_status = m_partner->set_timer(
  9053    	m_eap_fast_completion_status = m_partner->set_timer(
  8671 		this,
  9054 		this,
  8672 		KImportFileTimerID, // if nothing in db & remove_IAP_reference called already with 0 -> import
  9055 		KImportFileTimerID, // if nothing in db & remove_IAP_reference called already with 0 -> import
  8673 		0,
  9056 		0,
  8674 		1);
  9057 		0);
  8675 
  9058 
  8676 	if (m_eap_fast_completion_status != eap_status_ok)
  9059 	if (m_eap_fast_completion_status != eap_status_ok)
  8677 		{
  9060 		{
  8678 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  9061 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  8679 		return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  9062 		return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8688 void eap_am_type_tls_peap_symbian_c::CompleteAddImportedPACFileL(
  9071 void eap_am_type_tls_peap_symbian_c::CompleteAddImportedPACFileL(
  8689 		const eap_variable_data_c * const in_imported_PAC_filename,
  9072 		const eap_variable_data_c * const in_imported_PAC_filename,
  8690 		const eap_variable_data_c * const out_used_group_reference)
  9073 		const eap_variable_data_c * const out_used_group_reference)
  8691 {
  9074 {
  8692 	RFs aFs;
  9075 	RFs aFs;
  8693 	aFs.Connect( KFileServerDefaultMessageSlots );
  9076 
       
  9077 	TInt error = aFs.Connect( KFileServerDefaultMessageSlots );
       
  9078 	User::LeaveIfError(error);
       
  9079 	
  8694 
  9080 
  8695 	HBufC8* buf = HBufC8::NewLC(in_imported_PAC_filename->get_data_length());
  9081 	HBufC8* buf = HBufC8::NewLC(in_imported_PAC_filename->get_data_length());
  8696 	TPtr8 bufPtr = buf->Des();
  9082 	TPtr8 bufPtr = buf->Des();
  8697 
  9083 
  8698 	if (in_imported_PAC_filename->get_data_length() != 0)
  9084 	if (in_imported_PAC_filename->get_data_length() != 0)
  8700 		bufPtr.Copy(in_imported_PAC_filename->get_data(), in_imported_PAC_filename->get_data_length());
  9086 		bufPtr.Copy(in_imported_PAC_filename->get_data(), in_imported_PAC_filename->get_data_length());
  8701 		}
  9087 		}
  8702 
  9088 
  8703 	eap_variable_data_c someVariableData(m_am_tools);
  9089 	eap_variable_data_c someVariableData(m_am_tools);
  8704 
  9090 
  8705 	EAP_TRACE_DEBUG_SYMBIAN(
  9091 	EAP_TRACE_DEBUG(
  8706 			(_L("eap_am_type_tls_peap_symbian_c::complete_add_imported_PAC_file: Get ImportReference from database")));					
  9092 		m_am_tools,
       
  9093 		TRACE_FLAGS_DEFAULT,
       
  9094 		(EAPL("eap_am_type_tls_peap_symbian_c::complete_add_imported_PAC_file: Get ImportReference from database")));					
  8707 
  9095 
  8708 	EapTlsPeapUtils::GetEapSettingsDataL(
  9096 	EapTlsPeapUtils::GetEapSettingsDataL(
  8709 		m_database,
  9097 		m_database,
  8710 		m_index_type,
  9098 		m_index_type,
  8711 		m_index,
  9099 		m_index,
  8731 	  	CleanupStack::PopAndDestroy(tempUserBuf8);
  9119 	  	CleanupStack::PopAndDestroy(tempUserBuf8);
  8732 
  9120 
  8733 		}
  9121 		}
  8734 	else
  9122 	else
  8735 		{
  9123 		{
  8736 		EAP_TRACE_DEBUG_SYMBIAN(
  9124 		EAP_TRACE_DEBUG(
  8737 				(_L("eap_am_type_tls_peap_symbian_c::complete_add_imported_PAC_file: NO ImportReference !!!!")));	
  9125 			m_am_tools,
  8738 		}
  9126 			TRACE_FLAGS_DEFAULT,
  8739 	
  9127 			(EAPL("eap_am_type_tls_peap_symbian_c::complete_add_imported_PAC_file: NO ImportReference !!!!")));	
  8740 	EAP_TRACE_DEBUG_SYMBIAN(
  9128 		}
  8741 			(_L("eap_am_type_tls_peap_symbian_c::complete_add_imported_PAC_file: Set GroupDBReference to database")));					
  9129 	
       
  9130 	EAP_TRACE_DEBUG(
       
  9131 		m_am_tools,
       
  9132 		TRACE_FLAGS_DEFAULT,
       
  9133 		(EAPL("eap_am_type_tls_peap_symbian_c::complete_add_imported_PAC_file: Set GroupDBReference to database")));					
  8742 
  9134 
  8743 	if (out_used_group_reference->get_data_length()>0 && someVariableData.get_data_length()>0)
  9135 	if (out_used_group_reference->get_data_length()>0 && someVariableData.get_data_length()>0)
  8744 		{
  9136 		{
  8745 		someVariableData.set_copy_of_buffer(out_used_group_reference->get_data(),
  9137 		someVariableData.set_copy_of_buffer(out_used_group_reference->get_data(),
  8746 				out_used_group_reference->get_data_length());
  9138 				out_used_group_reference->get_data_length());
  8755 			&someVariableData);
  9147 			&someVariableData);
  8756 	
  9148 	
  8757 		}
  9149 		}
  8758 	else
  9150 	else
  8759 		{
  9151 		{
  8760 		EAP_TRACE_DEBUG_SYMBIAN(
  9152 		EAP_TRACE_DEBUG(
  8761 				(_L("eap_am_type_tls_peap_symbian_c::complete_add_imported_PAC_file: NO GROUP REFERENCE !!!!")));	
  9153 			m_am_tools,
       
  9154 			TRACE_FLAGS_DEFAULT,
       
  9155 			(EAPL("eap_am_type_tls_peap_symbian_c::complete_add_imported_PAC_file: NO GROUP REFERENCE !!!!")));	
  8762 
  9156 
  8763 		}
  9157 		}
  8764 
  9158 
  8765 	HBufC* FilePath = HBufC::NewLC(KMaxFileName); // must be defined to correct maxs dir length
  9159 	HBufC* FilePath = HBufC::NewLC(KMaxFileName); // must be defined to correct maxs dir length
  8766 	TPtr FilePathPtr = FilePath->Des();
  9160 	TPtr FilePathPtr = FilePath->Des();
  8795    		FilePathPtr.Size()));
  9189    		FilePathPtr.Size()));
  8796 
  9190 
  8797    	if(aFs.Delete(FilePathPtr)!= KErrNone)
  9191    	if(aFs.Delete(FilePathPtr)!= KErrNone)
  8798    		{
  9192    		{
  8799    		EAP_TRACE_DATA_DEBUG(
  9193    		EAP_TRACE_DATA_DEBUG(
  8800    				m_am_tools,
  9194 			m_am_tools,
  8801    				TRACE_FLAGS_DEFAULT,
  9195 			TRACE_FLAGS_DEFAULT,
  8802    				(EAPL("eap_am_type_tls_peap_symbian_c::complete_add_imported_PAC_file: Couldn't delete file"),
  9196 			(EAPL("eap_am_type_tls_peap_symbian_c::complete_add_imported_PAC_file: Couldn't delete file"),
  8803    						FilePathPtr.Ptr(),
  9197 			FilePathPtr.Ptr(),
  8804    						FilePathPtr.Size()));
  9198 			FilePathPtr.Size()));
  8805 
  9199 
  8806 
  9200 
  8807    		m_eap_fast_completion_status = eap_status_file_does_not_exist;
  9201    		m_eap_fast_completion_status = eap_status_file_does_not_exist;
  8808    		}
  9202    		}
  8809 
  9203 
  8819 // eap_am_type_tls_peap_symbian_c::ContinueInitializePacStore()
  9213 // eap_am_type_tls_peap_symbian_c::ContinueInitializePacStore()
  8820 // ---------------------------------------------------------
  9214 // ---------------------------------------------------------
  8821 //
  9215 //
  8822 void eap_am_type_tls_peap_symbian_c::ContinueInitializePacStore()
  9216 void eap_am_type_tls_peap_symbian_c::ContinueInitializePacStore()
  8823 {
  9217 {
  8824 	EAP_TRACE_DEBUG_SYMBIAN(
  9218 	EAP_TRACE_DEBUG(
  8825 			(_L("eap_am_type_tls_peap_symbian_c::ContinueInitializePacStore()")));
  9219 		m_am_tools,
  8826 
  9220 		TRACE_FLAGS_DEFAULT,
  8827 	TRAPD(error, CheckPasswordTimeValidityL());
  9221 		(EAPL("eap_am_type_tls_peap_symbian_c::ContinueInitializePacStore()")));
       
  9222 
       
  9223 	TBool RemoveCache(EFalse);
       
  9224 
       
  9225 	TRAPD(error, iPacStoreDb->CheckPasswordTimeValidityL(RemoveCache, m_index_type, m_index, m_max_session_time));
  8828 
  9226 
  8829 	if(error != KErrNone)
  9227 	if(error != KErrNone)
  8830 	{
  9228 	{
  8831 		EAP_TRACE_DEBUG(
  9229 		EAP_TRACE_DEBUG(
  8832 			m_am_tools,
  9230 			m_am_tools,
  8833 			TRACE_FLAGS_DEFAULT,
  9231 			TRACE_FLAGS_DEFAULT,
  8834 			(EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::ContinueInitializePacStore() ERROR: LEAVE from CheckPasswordTimeValidityL() error=%d"),
  9232 			(EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::ContinueInitializePacStore() ERROR: LEAVE from CheckPasswordTimeValidityL() error=%d"),
  8835 			error));
  9233 			error));
       
  9234 	}
       
  9235 
       
  9236 	if (RemoveCache)
       
  9237 	{
       
  9238 		m_tls_application->remove_cached_pac_store_data();
  8836 	}
  9239 	}
  8837 	
  9240 	
  8838 	EAP_TRACE_DEBUG(
  9241 	EAP_TRACE_DEBUG(
  8839 		m_am_tools,
  9242 		m_am_tools,
  8840 		TRACE_FLAGS_DEFAULT,
  9243 		TRACE_FLAGS_DEFAULT,
  8843 		(m_is_client == true ? "client": "server"),
  9246 		(m_is_client == true ? "client": "server"),
  8844 		this));
  9247 		this));
  8845 	
  9248 	
  8846 	m_eap_fast_completion_status = eap_status_ok;
  9249 	m_eap_fast_completion_status = eap_status_ok;
  8847 
  9250 
  8848 	EAP_TRACE_DEBUG_SYMBIAN(
  9251 	EAP_TRACE_DEBUG(
  8849 			(_L("eap_am_type_tls_peap_symbian_c::ContinueInitializePacStore: Remove removed IAP references")));					
  9252 		m_am_tools,
       
  9253 		TRACE_FLAGS_DEFAULT,
       
  9254 		(EAPL("eap_am_type_tls_peap_symbian_c::ContinueInitializePacStore: Remove removed IAP references")));					
  8850 
  9255 
  8851 	m_eap_fast_completion_status = m_partner->set_timer(
  9256 	m_eap_fast_completion_status = m_partner->set_timer(
  8852 			this,
  9257 			this,
  8853 			KRemoveIAPReferenceTimerID, 
  9258 			KRemoveIAPReferenceTimerID, 
  8854 			0,
  9259 			0,
  8855 			1);
  9260 			0);
  8856 
  9261 
       
  9262 }
       
  9263 
       
  9264 //--------------------------------------------------
       
  9265 
       
  9266 void eap_am_type_tls_peap_symbian_c::set_is_pac_store_initialization()
       
  9267 {
       
  9268 	m_is_pac_store_initialization = true;
  8857 }
  9269 }
  8858 
  9270 
  8859 //--------------------------------------------------
  9271 //--------------------------------------------------
  8860 
  9272 
  8861 // This is commented in eap_am_fast_pac_store_services_c::complete_remove_PAC().
  9273 // This is commented in eap_am_fast_pac_store_services_c::complete_remove_PAC().
  8939 		{
  9351 		{
  8940 		m_eap_fast_completion_status = m_partner->set_timer(
  9352 		m_eap_fast_completion_status = m_partner->set_timer(
  8941 			this,
  9353 			this,
  8942 			KRemoveIAPReferenceTimerID, 
  9354 			KRemoveIAPReferenceTimerID, 
  8943 			0,
  9355 			0,
  8944 			1);
  9356 			0);
  8945 		
  9357 		
  8946 		if (m_eap_fast_completion_status != eap_status_ok)
  9358 		if (m_eap_fast_completion_status != eap_status_ok)
  8947 			{
  9359 			{
  8948 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  9360 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  8949 			return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  9361 			return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8953 		{
  9365 		{
  8954 		m_eap_fast_completion_status = m_partner->set_timer(
  9366 		m_eap_fast_completion_status = m_partner->set_timer(
  8955 			this,
  9367 			this,
  8956 			KImportFileTimerID, // if nothing in db & remove_IAP_reference called already with 0 -> import
  9368 			KImportFileTimerID, // if nothing in db & remove_IAP_reference called already with 0 -> import
  8957 			0,
  9369 			0,
  8958 			1);
  9370 			0);
  8959 		
  9371 		
  8960 		if (m_eap_fast_completion_status != eap_status_ok)
  9372 		if (m_eap_fast_completion_status != eap_status_ok)
  8961 			{
  9373 			{
  8962 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  9374 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  8963 				return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  9375 				return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  9004 	   (EAPL("eap_am_type_tls_peap_symbian_c::initialize_PAC_store IN\n")));
  9416 	   (EAPL("eap_am_type_tls_peap_symbian_c::initialize_PAC_store IN\n")));
  9005 	
  9417 	
  9006     iCompletionOperation = aCompletionOperation;
  9418     iCompletionOperation = aCompletionOperation;
  9007     iCompletion = aCompletion;
  9419     iCompletion = aCompletion;
  9008 
  9420 
  9009     TRAPD( err, FixOldTableForPacStoreInitL() );
  9421     TRAPD( error, iPacStoreDb->FixOldTableForPacStoreInitL() );
  9010     if ( err != KErrNone )
  9422     if ( error != KErrNone )
  9011     	{
  9423     	{
  9012         EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
  9424         EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
  9013         	"ERROR: eap_am_type_tls_peap_symbian_c::initialize_PAC_store() \
  9425         	"ERROR: eap_am_type_tls_peap_symbian_c::initialize_PAC_store() \
  9014         	Failed to fix table.\n" ) ) );
  9426         	Failed to fix table.\n" ) ) );
  9015     	}
  9427     	}
  9016 
  9428 
  9017     if ( iPacStoreDb )
  9429     if ( iPacStoreDb )
  9018     	{
  9430     	{
  9019     	
  9431     	
  9020     	TBool isInitialized = EFalse;
  9432     	TBool isInitialized = EFalse;
  9021     	TRAP( err, isInitialized = iPacStoreDb->IsInitializedL() );
  9433     	TRAP( error, isInitialized = iPacStoreDb->IsInitializedL() );
  9022     	if ( err == KErrNone )
  9434     	if ( error == KErrNone )
  9023     		{
  9435     		{
  9024             if ( !isInitialized )
  9436             if ( !isInitialized )
  9025         	    {
  9437         	    {
  9026 		        EAP_TRACE_DEBUG_SYMBIAN(
  9438 				EAP_TRACE_DEBUG(
  9027 			    (_L("eap_am_type_tls_peap_symbian_c::initialize_PAC_store(): PAC store initialized, erase memorystore")));	
  9439 					m_am_tools,
       
  9440 					TRACE_FLAGS_DEFAULT,
       
  9441 					(EAPL("eap_am_type_tls_peap_symbian_c::initialize_PAC_store(): PAC store initialized, erase memorystore")));
       
  9442 
  9028 		        m_tls_application->remove_cached_pac_store_data();
  9443 		        m_tls_application->remove_cached_pac_store_data();
  9029 		        TRAP( err, iPacStoreDb->SetPacStoreInitValueL(
  9444 
       
  9445 		        TRAP( error, iPacStoreDb->SetPacStoreInitValueL(
  9030 		    	    CPacStoreDatabase::EPacStoreInitialized ) );
  9446 		    	    CPacStoreDatabase::EPacStoreInitialized ) );
  9031 		        if ( err != KErrNone )
  9447 		        if ( error != KErrNone )
  9032 		    	    {
  9448 		    	    {
  9033 			        EAP_TRACE_DEBUG_SYMBIAN(
  9449 					EAP_TRACE_DEBUG(
  9034 						(_L("eap_am_type_tls_peap_symbian_c::initialize_PAC_store(): ERROR: Leave in SetPacStoreInitValueL()")));	
  9450 						m_am_tools,
       
  9451 						TRACE_FLAGS_DEFAULT,
       
  9452 						(EAPL("eap_am_type_tls_peap_symbian_c::initialize_PAC_store(): ERROR: Leave in SetPacStoreInitValueL()")));	
  9035 		    	    }
  9453 		    	    }
  9036         	    }
  9454         	    }
  9037 		    // asynch. call, return immediately
  9455 		    // asynch. call, return immediately
  9038 		    CreateDeviceSeedAsync();
  9456 		    CreateDeviceSeedAsync();
  9039 		    }
  9457 		    }
  9040     	else
  9458     	else
  9041     		{
  9459     		{
  9042 	        EAP_TRACE_DEBUG_SYMBIAN( ( _L(
  9460 			EAP_TRACE_DEBUG(
  9043 	        	"ERROR: eap_am_type_tls_peap_symbian_c::initialize_PAC_store(): Leave, IsInitializedL(), err=%d.\n"),
  9461 				m_am_tools,
  9044 	        	err ) );	
  9462 				TRACE_FLAGS_DEFAULT,
       
  9463 				(EAPL("ERROR: eap_am_type_tls_peap_symbian_c::initialize_PAC_store(): Leave, IsInitializedL(), error=%d.\n"),
       
  9464 				error ) );	
  9045     		
  9465     		
  9046     		return m_am_tools->convert_am_error_to_eapol_error(err);
  9466     		return m_am_tools->convert_am_error_to_eapol_error(error);
  9047     		}
  9467     		}
  9048     	}
  9468     	}
  9049 	
  9469 	
  9050 	m_eap_fast_completion_status = eap_status_pending_request;
  9470 	m_eap_fast_completion_status = eap_status_pending_request;
  9051 		
  9471 		
  9113 		}
  9533 		}
  9114 	}
  9534 	}
  9115 
  9535 
  9116 
  9536 
  9117 
  9537 
  9118 	return status;
  9538 	return EAP_STATUS_RETURN(m_am_tools, status);
  9119 }
  9539 }
  9120 
  9540 
  9121 // ---------------------------------------------------------------------------
  9541 // ---------------------------------------------------------------------------
  9122 // eap_am_type_tls_peap_symbian_c::indicates_eap_fast_provisioning_ends
  9542 // eap_am_type_tls_peap_symbian_c::indicates_eap_fast_provisioning_ends
  9123 // ---------------------------------------------------------------------------
  9543 // ---------------------------------------------------------------------------
  9125 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::indicates_eap_fast_provisioning_ends(
  9545 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::indicates_eap_fast_provisioning_ends(
  9126     const bool provisioning_successfull,
  9546     const bool provisioning_successfull,
  9127     const eap_fast_completion_operation_e provisioning_mode,
  9547     const eap_fast_completion_operation_e provisioning_mode,
  9128     const eap_fast_pac_type_e pac_type )
  9548     const eap_fast_pac_type_e pac_type )
  9129 {	
  9549 {	
  9130 	EAP_TRACE_DEBUG_SYMBIAN( (_L("eap_am_type_tls_peap_symbian_c::indicates_eap_fast_provisioning_ends()")));
  9550 	EAP_TRACE_DEBUG(
       
  9551 		m_am_tools,
       
  9552 		TRACE_FLAGS_DEFAULT,
       
  9553 		(EAPL("eap_am_type_tls_peap_symbian_c::indicates_eap_fast_provisioning_ends()")));
  9131 
  9554 
  9132 	EAP_UNREFERENCED_PARAMETER(provisioning_mode);
  9555 	EAP_UNREFERENCED_PARAMETER(provisioning_mode);
  9133 
  9556 
  9134 	TInt error(KErrNone);
  9557 	TInt error(KErrNone);
  9135 
  9558 
  9167 				return m_am_tools->convert_am_error_to_eapol_error(error);
  9590 				return m_am_tools->convert_am_error_to_eapol_error(error);
  9168 			}
  9591 			}
  9169 		}
  9592 		}
  9170 	} // if ( pac_type == eap_fast_pac_type_tunnel_pac )
  9593 	} // if ( pac_type == eap_fast_pac_type_tunnel_pac )
  9171 
  9594 
  9172 	return status;
  9595 	return EAP_STATUS_RETURN(m_am_tools, status);
  9173 }
  9596 }
  9174 
  9597 
  9175 #endif //#if defined(USE_FAST_EAP_TYPE)
  9598 #endif //#if defined(USE_FAST_EAP_TYPE)
  9176 
  9599 
  9177 //--------------------------------------------------
  9600 //--------------------------------------------------
  9181 void eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL(
  9604 void eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL(
  9182 	const eap_pac_store_data_type_e aPacStoreDataType,
  9605 	const eap_pac_store_data_type_e aPacStoreDataType,
  9183 	eap_variable_data_c * aPacStoreData,
  9606 	eap_variable_data_c * aPacStoreData,
  9184 	const eap_variable_data_c * const aPacStoreReference /*=NULL*/)
  9607 	const eap_variable_data_c * const aPacStoreReference /*=NULL*/)
  9185 {
  9608 {
  9186 	EAP_TRACE_DEBUG_SYMBIAN(
  9609 	EAP_TRACE_DEBUG(
  9187 		(_L("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL Start aPacStoreDataType=%d"),
  9610 		m_am_tools,
       
  9611 		TRACE_FLAGS_DEFAULT,
       
  9612 		(EAPL("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL(): Start aPacStoreDataType=%d"),
  9188 		aPacStoreDataType));	
  9613 		aPacStoreDataType));	
  9189 	
  9614 	
  9190 	if(m_current_eap_type != eap_type_fast || iPacStoreDb == NULL)
  9615 	if(m_current_eap_type != eap_type_fast || iPacStoreDb == NULL)
  9191 	{
  9616 	{
  9192 		EAP_TRACE_DEBUG_SYMBIAN(
  9617 		EAP_TRACE_DEBUG(
  9193 			(_L("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL ERROR: Unknown EAP type or No PAC store DB!")));
  9618 			m_am_tools,
       
  9619 			TRACE_FLAGS_DEFAULT,
       
  9620 			(EAPL("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL ERROR: Unknown EAP type or No PAC store DB!")));
  9194 		
  9621 		
  9195 		// Can't proceed.
  9622 		// Can't proceed.
  9196 		User::Leave(KErrNotSupported);		
  9623 		User::Leave(KErrNotSupported);		
  9197 	}					
  9624 	}					
  9198 	
  9625 	
  9219 		}		
  9646 		}		
  9220 		case eap_pac_store_data_type_PAC_store_device_seed:
  9647 		case eap_pac_store_data_type_PAC_store_device_seed:
  9221 		{
  9648 		{
  9222 			// Not in PAC store. This should not be called.
  9649 			// Not in PAC store. This should not be called.
  9223 
  9650 
  9224 			EAP_TRACE_DEBUG_SYMBIAN(
  9651 			EAP_TRACE_DEBUG(
  9225 				(_L("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL ERROR: This is not in PAC store DB!")));
  9652 				m_am_tools,
       
  9653 				TRACE_FLAGS_DEFAULT,
       
  9654 				(EAPL("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL ERROR: This is not in PAC store DB!")));
  9226 			
  9655 			
  9227 			return;		
  9656 			return;		
  9228 		}		
  9657 		}		
  9229 		case eap_pac_store_data_type_PAC_store_IAP_reference:
  9658 		case eap_pac_store_data_type_PAC_store_IAP_reference:
  9230 		{
  9659 		{
  9231 			// Not in PAC store. This should not be called.
  9660 			// Not in PAC store. This should not be called.
  9232 
  9661 
  9233 			EAP_TRACE_DEBUG_SYMBIAN(
  9662 			EAP_TRACE_DEBUG(
  9234 				(_L("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL ERROR: This is not in PAC store DB!")));
  9663 				m_am_tools,
       
  9664 				TRACE_FLAGS_DEFAULT,
       
  9665 				(EAPL("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL ERROR: This is not in PAC store DB!")));
  9235 			
  9666 			
  9236 			return;		
  9667 			return;		
  9237 		}		
  9668 		}		
  9238 		case eap_pac_store_data_type_PAC_store_group_reference:
  9669 		case eap_pac_store_data_type_PAC_store_group_reference:
  9239 		{
  9670 		{
  9240 			// Not in PAC store. This should not be called.
  9671 			// Not in PAC store. This should not be called.
  9241 
  9672 
  9242 			EAP_TRACE_DEBUG_SYMBIAN(
  9673 			EAP_TRACE_DEBUG(
  9243 				(_L("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL ERROR: This is not in PAC store DB!")));
  9674 				m_am_tools,
       
  9675 				TRACE_FLAGS_DEFAULT,
       
  9676 				(EAPL("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL ERROR: This is not in PAC store DB!")));
  9244 			
  9677 			
  9245 			return;		
  9678 			return;		
  9246 		}		
  9679 		}		
  9247 		case eap_pac_store_data_type_reference_counter:
  9680 		case eap_pac_store_data_type_reference_counter:
  9248 		{
  9681 		{
  9252 		}		
  9685 		}		
  9253 		case eap_pac_store_data_type_PAC_file_password:
  9686 		case eap_pac_store_data_type_PAC_file_password:
  9254 		{
  9687 		{
  9255 			// Not in PAC store. This should not be called.
  9688 			// Not in PAC store. This should not be called.
  9256 
  9689 
  9257 			EAP_TRACE_DEBUG_SYMBIAN(
  9690 			EAP_TRACE_DEBUG(
  9258 				(_L("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL ERROR: This is not in PAC store DB!")));
  9691 				m_am_tools,
       
  9692 				TRACE_FLAGS_DEFAULT,
       
  9693 				(EAPL("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL ERROR: This is not in PAC store DB!")));
  9259 			
  9694 			
  9260 			return;		
  9695 			return;		
  9261 		}		
  9696 		}		
  9262 		case eap_pac_store_data_type_group_info:
  9697 		case eap_pac_store_data_type_group_info:
  9263 		{
  9698 		{
  9304 		case eap_pac_store_data_type_PAC_store_password:
  9739 		case eap_pac_store_data_type_PAC_store_password:
  9305 		case eap_pac_store_data_type_reference_counter:
  9740 		case eap_pac_store_data_type_reference_counter:
  9306 		{
  9741 		{
  9307 			TPtr8 pacStoreDBColValPtr8 = pacStoreDBColValBuf8->Des();
  9742 			TPtr8 pacStoreDBColValPtr8 = pacStoreDBColValBuf8->Des();
  9308 				
  9743 				
  9309 			TRAPD( err, iPacStoreDb->GetPacStoreDataL(pacStoreDBColName, pacStoreDBColValPtr8) );
  9744 			TRAPD( error, iPacStoreDb->GetPacStoreDataL(pacStoreDBColName, pacStoreDBColValPtr8) );
  9310 			if ( err )
  9745 			if ( error )
  9311 				{
  9746 				{
  9312 				if(pacStoreDBColValBuf8 != NULL)
  9747 				if(pacStoreDBColValBuf8 != NULL)
  9313 					{
  9748 					{
  9314 						CleanupStack::PopAndDestroy(pacStoreDBColValBuf8);
  9749 						CleanupStack::PopAndDestroy(pacStoreDBColValBuf8);
  9315 						pacStoreDBColValBuf8 = NULL;
  9750 						pacStoreDBColValBuf8 = NULL;
  9316 						User::Leave( err );
  9751 						User::Leave( error );
  9317 					}
  9752 					}
  9318 				}
  9753 				}
  9319 			
  9754 			
  9320 			status = aPacStoreData->set_copy_of_buffer(
  9755 			status = aPacStoreData->set_copy_of_buffer(
  9321 				pacStoreDBColValPtr8.Ptr(),
  9756 				pacStoreDBColValPtr8.Ptr(),
  9326 		}
  9761 		}
  9327 		case eap_pac_store_data_type_group_data:
  9762 		case eap_pac_store_data_type_group_data:
  9328 		case eap_pac_store_data_type_A_ID_data:
  9763 		case eap_pac_store_data_type_A_ID_data:
  9329 		case eap_pac_store_data_type_PAC_data:
  9764 		case eap_pac_store_data_type_PAC_data:
  9330 		{
  9765 		{
  9331 			EAP_TRACE_DEBUG_SYMBIAN(
  9766 			EAP_TRACE_DEBUG(
  9332 			(_L("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL: To get GROUP, PAC or AID data")));			
  9767 				m_am_tools,
       
  9768 				TRACE_FLAGS_DEFAULT,
       
  9769 				(EAPL("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL: To get GROUP, PAC or AID data")));			
  9333 			
  9770 			
  9334 			
  9771 			
  9335 			if(aPacStoreReference == NULL )//|| aPacStoreReference->get_data_length() <= 0)
  9772 			if(aPacStoreReference == NULL )//|| aPacStoreReference->get_data_length() <= 0)
  9336 			{
  9773 			{
  9337 				EAP_TRACE_DEBUG_SYMBIAN(
  9774 				EAP_TRACE_DEBUG(
  9338 				(_L("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL ERROR: Empty reference")));
  9775 					m_am_tools,
       
  9776 					TRACE_FLAGS_DEFAULT,
       
  9777 					(EAPL("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL ERROR: Empty reference")));
  9339 				
  9778 				
  9340 				// Can't proceed.
  9779 				// Can't proceed.
  9341 				User::Leave(KErrArgument);		
  9780 				User::Leave(KErrArgument);		
  9342 			}								
  9781 			}								
  9343 			if ( aPacStoreReference->get_data_length() <= 0 )
  9782 			if ( aPacStoreReference->get_data_length() <= 0 )
  9344 				{
  9783 				{
  9345 				EAP_TRACE_DEBUG_SYMBIAN(
  9784 				EAP_TRACE_DEBUG(
  9346 					(_L("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL reset aPacStoreData.")));				
  9785 					m_am_tools,
       
  9786 					TRACE_FLAGS_DEFAULT,
       
  9787 					(EAPL("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL reset aPacStoreData.")));				
  9347 				aPacStoreData->reset();
  9788 				aPacStoreData->reset();
  9348 				break;
  9789 				break;
  9349 				}
  9790 				}
  9350 			
  9791 			
  9351 			
  9792 			
  9353 			TPtr8 referencePtr8 = reference8->Des();
  9794 			TPtr8 referencePtr8 = reference8->Des();
  9354 						
  9795 						
  9355 			referencePtr8.Copy(aPacStoreReference->get_data(),
  9796 			referencePtr8.Copy(aPacStoreReference->get_data(),
  9356 					aPacStoreReference->get_data_length());
  9797 					aPacStoreReference->get_data_length());
  9357 	
  9798 	
  9358 			EAP_TRACE_DATA_DEBUG_SYMBIAN(
  9799 			EAP_TRACE_DATA_DEBUG(
  9359 			("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL: reference to DB",
  9800 				m_am_tools,
  9360 			referencePtr8.Ptr(), 
  9801 				TRACE_FLAGS_DEFAULT,
  9361 			referencePtr8.Size()));	
  9802 				(EAPL("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL: reference to DB"),
       
  9803 				referencePtr8.Ptr(), 
       
  9804 				referencePtr8.Size()));	
  9362 			
  9805 			
  9363 			TPtr8 pacStoreDBColDataValPtr8(0,0);
  9806 			TPtr8 pacStoreDBColDataValPtr8(0,0);
  9364 					
  9807 					
  9365 			TRAPD( err, iPacStoreDb->GetPacStoreDataL(pacStoreDBColName, pacStoreDBColDataValPtr8, referencePtr8, &aDbBinaryColumnValue) );
  9808 			TRAPD( error, iPacStoreDb->GetPacStoreDataL(pacStoreDBColName, pacStoreDBColDataValPtr8, referencePtr8, &aDbBinaryColumnValue) );
  9366 			if ( err )
  9809 			if ( error )
  9367 				{
  9810 				{
  9368 				CleanupStack::PopAndDestroy(1); // reference8.
  9811 				CleanupStack::PopAndDestroy(1); // reference8.
  9369 				if(pacStoreDBColValBuf8 != NULL)
  9812 				if(pacStoreDBColValBuf8 != NULL)
  9370 					{
  9813 					{
  9371 						CleanupStack::PopAndDestroy(pacStoreDBColValBuf8);
  9814 						CleanupStack::PopAndDestroy(pacStoreDBColValBuf8);
  9372 						pacStoreDBColValBuf8 = NULL;
  9815 						pacStoreDBColValBuf8 = NULL;
  9373 						delete (aDbBinaryColumnValue);
  9816 						delete (aDbBinaryColumnValue);
  9374 						User::Leave( err );
  9817 						User::Leave( error );
  9375 					}
  9818 					}
  9376 				}
  9819 				}
  9377 			
  9820 			
  9378 			
  9821 			
  9379 			CleanupStack::PopAndDestroy(1); // reference8.
  9822 			CleanupStack::PopAndDestroy(1); // reference8.
  9380 			
  9823 			
  9381 			if (aDbBinaryColumnValue != NULL)
  9824 			if (aDbBinaryColumnValue != NULL)
  9382 				{
  9825 				{
  9383 				TPtr8 aDbBinaryColumnValuePtr = aDbBinaryColumnValue->Des();
  9826 				TPtr8 aDbBinaryColumnValuePtr = aDbBinaryColumnValue->Des();
  9384 			 
  9827 			 
  9385 				EAP_TRACE_DEBUG_SYMBIAN(
  9828 				EAP_TRACE_DEBUG(
  9386 						(_L("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL, data size=%d"),
  9829 					m_am_tools,
  9387 								aDbBinaryColumnValuePtr.Size()));	
  9830 					TRACE_FLAGS_DEFAULT,
       
  9831 					(EAPL("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL, data size=%d"),
       
  9832 					aDbBinaryColumnValuePtr.Size()));	
  9388 				
  9833 				
  9389 				if (aDbBinaryColumnValuePtr.Size() > 0)
  9834 				if (aDbBinaryColumnValuePtr.Size() > 0)
  9390 					{
  9835 					{
  9391 					status = aPacStoreData->set_copy_of_buffer(
  9836 					status = aPacStoreData->set_copy_of_buffer(
  9392 						aDbBinaryColumnValuePtr.Ptr(),
  9837 						aDbBinaryColumnValuePtr.Ptr(),
  9393 						aDbBinaryColumnValuePtr.Size());
  9838 						aDbBinaryColumnValuePtr.Size());
  9394 					}
  9839 					}
  9395 				else
  9840 				else
  9396 					{
  9841 					{
  9397 					EAP_TRACE_DEBUG_SYMBIAN(
  9842 					EAP_TRACE_DEBUG(
  9398 						(_L("eap_am_type_tls_peap_symbian_c::No data to fill !!")));	
  9843 						m_am_tools,
       
  9844 						TRACE_FLAGS_DEFAULT,
       
  9845 						(EAPL("eap_am_type_tls_peap_symbian_c::No data to fill !!")));	
  9399 				
  9846 				
  9400 					}
  9847 					}
  9401 				delete (aDbBinaryColumnValue);
  9848 				delete (aDbBinaryColumnValue);
  9402 				}
  9849 				}
  9403 			else
  9850 			else
  9404 				{
  9851 				{
  9405 				EAP_TRACE_DEBUG_SYMBIAN(
  9852 				EAP_TRACE_DEBUG(
  9406 						(_L("eap_am_type_tls_peap_symbian_c::Data NULL !!")));	
  9853 					m_am_tools,
       
  9854 					TRACE_FLAGS_DEFAULT,
       
  9855 					(EAPL("eap_am_type_tls_peap_symbian_c::Data NULL !!")));	
  9407 				}
  9856 				}
  9408 			
  9857 			
  9409 			error = m_am_tools->convert_eapol_error_to_am_error(status);
  9858 			error = m_am_tools->convert_eapol_error_to_am_error(status);
  9410 			
  9859 			
  9411 			delete (pacStoreDBColDataValPtr8.Ptr());
  9860 			delete (pacStoreDBColDataValPtr8.Ptr());
  9415 		case eap_pac_store_data_type_group_info:
  9864 		case eap_pac_store_data_type_group_info:
  9416 		case eap_pac_store_data_type_A_ID_info:
  9865 		case eap_pac_store_data_type_A_ID_info:
  9417 		case eap_pac_store_data_type_PAC_info:
  9866 		case eap_pac_store_data_type_PAC_info:
  9418 		{
  9867 		{
  9419 			
  9868 			
  9420 			EAP_TRACE_DEBUG_SYMBIAN(
  9869 			EAP_TRACE_DEBUG(
  9421 					(_L("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL:ERROR: Calls for INFOs should not come here !!!")));
  9870 				m_am_tools,
       
  9871 				TRACE_FLAGS_DEFAULT,
       
  9872 				(EAPL("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL:ERROR: Calls for INFOs should not come here !!!")));
  9422 			
  9873 			
  9423 			break;
  9874 			break;
  9424 		}		
  9875 		}		
  9425 		default:
  9876 		default:
  9426 		{
  9877 		{
  9427 			EAP_TRACE_DEBUG_SYMBIAN(
  9878 			EAP_TRACE_DEBUG(
  9428 					(_L("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL - UNSUPPORTED Column !!!")));
  9879 				m_am_tools,
       
  9880 				TRACE_FLAGS_DEFAULT,
       
  9881 				(EAPL("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL - UNSUPPORTED Column !!!")));
  9429 			
  9882 			
  9430 			break;		
  9883 			break;		
  9431 		}
  9884 		}
  9432 	}// End: switch(aPacStoreDataType)	
  9885 	}// End: switch(aPacStoreDataType)	
  9433 		
  9886 		
  9434 	if(pacStoreDBColValBuf8 != NULL)
  9887 	if(pacStoreDBColValBuf8 != NULL)
  9435 	{
  9888 	{
  9436 		CleanupStack::PopAndDestroy(pacStoreDBColValBuf8);
  9889 		CleanupStack::PopAndDestroy(pacStoreDBColValBuf8);
  9437 	}
  9890 	}
  9438 	
  9891 	
  9439 	EAP_TRACE_DEBUG_SYMBIAN(
  9892 	EAP_TRACE_DEBUG(
  9440 		(_L("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL-End")));
  9893 		m_am_tools,
       
  9894 		TRACE_FLAGS_DEFAULT,
       
  9895 		(EAPL("eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL-End")));
  9441 	
  9896 	
  9442 	User::LeaveIfError(error); // This could be success or error. Does't matter.	
  9897 	User::LeaveIfError(error); // This could be success or error. Does't matter.	
  9443 }
  9898 }
  9444 	
  9899 	
  9445 #endif	// End: #ifdef USE_PAC_STORE
  9900 #endif	// End: #ifdef USE_PAC_STORE
  9446 
  9901 
  9447 //--------------------------------------------------
  9902 //--------------------------------------------------
  9448 
  9903 
  9449 #ifdef USE_FAST_EAP_TYPE
  9904 #ifdef USE_FAST_EAP_TYPE
       
  9905 
  9450 //--------------------------------------------------
  9906 //--------------------------------------------------
  9451 
  9907 
  9452 eap_status_e eap_am_type_tls_peap_symbian_c::RemoveIAPReference()
  9908 eap_status_e eap_am_type_tls_peap_symbian_c::RemoveIAPReference()
  9453 {
  9909 {
  9454 	EAP_TRACE_DEBUG_SYMBIAN(
  9910 	EAP_TRACE_DEBUG(
  9455 		(_L("eap_am_type_tls_peap_symbian_c::RemoveIAPReference - Start")));
  9911 		m_am_tools,
       
  9912 		TRACE_FLAGS_DEFAULT,
       
  9913 		(EAPL("eap_am_type_tls_peap_symbian_c::RemoveIAPReference(): Start")));
       
  9914 
  9456 	m_eap_fast_completion_status = eap_status_ok;	
  9915 	m_eap_fast_completion_status = eap_status_ok;	
  9457 			
  9916 			
  9458 	eap_variable_data_c aIapReference(m_am_tools);
  9917 	eap_variable_data_c aIapReference(m_am_tools);
  9459 	if (aIapReference.get_is_valid() == false)
  9918 	if (aIapReference.get_is_valid() == false)
  9460 	{
  9919 	{
  9481 	
  9940 	
  9482 		m_eap_fast_completion_status = m_am_tools->convert_am_error_to_eapol_error(error);
  9941 		m_eap_fast_completion_status = m_am_tools->convert_am_error_to_eapol_error(error);
  9483 	}
  9942 	}
  9484 	
  9943 	
  9485 	if (aIapReference.get_data_length() > 0)
  9944 	if (aIapReference.get_data_length() > 0)
  9486 		{
  9945 	{
  9487 		eap_fast_pac_store_data_c * const group_reference_and_data = new eap_fast_pac_store_data_c(m_am_tools);
  9946 		eap_fast_pac_store_data_c * const group_reference_and_data = new eap_fast_pac_store_data_c(m_am_tools);
  9488 	
  9947 	
  9489 	
  9948 	
  9490 		m_eap_fast_completion_status = group_reference_and_data->get_writable_data()->set_copy_of_buffer(aGroupReferenceCollection.get_data(), aGroupReferenceCollection.get_data_length());
  9949 		m_eap_fast_completion_status = group_reference_and_data->get_writable_data()->set_copy_of_buffer(aGroupReferenceCollection.get_data(), aGroupReferenceCollection.get_data_length());
  9491 	
  9950 	
  9492 		if (aIapReference.get_data_length() > 0)
  9951 		if (aIapReference.get_data_length() > 0)
       
  9952 		{
  9493 			m_completed_with_zero = EFalse;
  9953 			m_completed_with_zero = EFalse;
       
  9954 		}
  9494 		else
  9955 		else
       
  9956 		{
  9495 			m_completed_with_zero = ETrue;
  9957 			m_completed_with_zero = ETrue;
  9496 			
  9958 		}
  9497 		
  9959 
  9498 			if (m_eap_fast_completion_status == eap_status_ok)
  9960 		if (m_eap_fast_completion_status == eap_status_ok)
  9499 			{
  9961 		{
  9500 			m_eap_fast_completion_status = m_tls_application->remove_IAP_reference(
  9962 			m_eap_fast_completion_status = m_tls_application->remove_IAP_reference(
  9501 					&aIapReference,
  9963 					&aIapReference,
  9502 					group_reference_and_data);
  9964 					group_reference_and_data);
  9503 			}
  9965 		}
  9504 		}
  9966 	}
  9505 	else
  9967 	else
  9506 		{
  9968 	{
  9507 		m_eap_fast_completion_status = m_partner->set_timer(
  9969 		m_eap_fast_completion_status = m_partner->set_timer(
  9508 				this,
  9970 				this,
  9509 				KImportFileTimerID, // if nothing in db, go right to file read 
  9971 				KImportFileTimerID, // if nothing in db, go right to file read 
  9510 				0,
  9972 				0,
  9511 				1);
  9973 				0);
  9512 		}
  9974 	}
  9513 	EAP_TRACE_DEBUG_SYMBIAN(
  9975 
  9514 		(_L("eap_am_type_tls_peap_symbian_c::RemoveIAPReference - End")));
  9976 	EAP_TRACE_DEBUG(
       
  9977 		m_am_tools,
       
  9978 		TRACE_FLAGS_DEFAULT,
       
  9979 		(EAPL("eap_am_type_tls_peap_symbian_c::RemoveIAPReference - End")));
  9515 		
  9980 		
  9516 	return m_eap_fast_completion_status;
  9981 	return m_eap_fast_completion_status;
  9517 }
  9982 }
  9518 
  9983 
  9519 //--------------------------------------------------
  9984 //--------------------------------------------------
  9520 
  9985 
  9521 eap_status_e eap_am_type_tls_peap_symbian_c::ImportFilesL()
  9986 eap_status_e eap_am_type_tls_peap_symbian_c::ImportFilesL()
  9522 {
  9987 {
  9523 
  9988 	EAP_TRACE_DEBUG(
  9524 	EAP_TRACE_DEBUG_SYMBIAN(
  9989 		m_am_tools,
  9525 			(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL - Start")));
  9990 		TRACE_FLAGS_DEFAULT,
  9526 	
  9991 		(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL(): Start")));
  9527 	CDir* files;
  9992 
       
  9993 	CDir* files = 0;
  9528 		 
  9994 		 
  9529 	RFs aFs;
  9995 	RFs aFs;
  9530 	aFs.Connect( KFileServerDefaultMessageSlots );
  9996 	TInt error = aFs.Connect( KFileServerDefaultMessageSlots );
       
  9997 	User::LeaveIfError(error);
  9531 
  9998 
  9532 	m_eap_fast_completion_status = eap_status_pending_request;
  9999 	m_eap_fast_completion_status = eap_status_pending_request;
  9533 	
 10000 
  9534 	TBool aSuccess = EFalse;
 10001 	TBool aSuccess = EFalse;
  9535 	
 10002 
  9536 	eap_variable_data_c ImportReference(m_am_tools);
 10003 	eap_variable_data_c ImportReference(m_am_tools);
  9537 
 10004 
  9538 	EAP_TRACE_DEBUG_SYMBIAN(
 10005 	EAP_TRACE_DEBUG(
  9539 			(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: Get ImportReference from database")));					
 10006 		m_am_tools,
       
 10007 		TRACE_FLAGS_DEFAULT,
       
 10008 		(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Get ImportReference from database")));					
  9540 
 10009 
  9541 	EapTlsPeapUtils::GetEapSettingsDataL(
 10010 	EapTlsPeapUtils::GetEapSettingsDataL(
  9542 		m_database,
 10011 		m_database,
  9543 		m_index_type,
 10012 		m_index_type,
  9544 		m_index,
 10013 		m_index,
  9547 		KFASTPACGroupImportReferenceCollection,
 10016 		KFASTPACGroupImportReferenceCollection,
  9548 		&ImportReference);
 10017 		&ImportReference);
  9549 
 10018 
  9550 	HBufC8* group_reference8 = HBufC8::NewLC(KMaxFileName);
 10019 	HBufC8* group_reference8 = HBufC8::NewLC(KMaxFileName);
  9551 	TPtr8 group_referencePtr8 = group_reference8->Des();
 10020 	TPtr8 group_referencePtr8 = group_reference8->Des();
  9552 	
 10021 
  9553 	EAP_TRACE_DATA_DEBUG(
 10022 	EAP_TRACE_DATA_DEBUG(
       
 10023 		m_am_tools,
       
 10024 		TRACE_FLAGS_DEFAULT,
       
 10025 		(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: ImportReference"),
       
 10026 		ImportReference.get_data(),
       
 10027 		ImportReference.get_data_length()));
       
 10028 
       
 10029 	if (ImportReference.get_data_length() != 0)
       
 10030 		{
       
 10031 		group_referencePtr8.Copy(ImportReference.get_data(), ImportReference.get_data_length());
       
 10032 		EAP_TRACE_DATA_DEBUG(
  9554 			m_am_tools,
 10033 			m_am_tools,
  9555 			TRACE_FLAGS_DEFAULT,
 10034 			TRACE_FLAGS_DEFAULT,
  9556 			(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: ImportReference"),
 10035 			(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Reference"),
  9557 					ImportReference.get_data(),
 10036 			group_referencePtr8.Ptr(),
  9558 					ImportReference.get_data_length()));
 10037 			group_referencePtr8.Size()));
  9559 
       
  9560 	if (ImportReference.get_data_length() != 0)
       
  9561 		{
       
  9562 		group_referencePtr8.Copy(ImportReference.get_data(), ImportReference.get_data_length());
       
  9563 		EAP_TRACE_DATA_DEBUG(
       
  9564 				m_am_tools,
       
  9565 				TRACE_FLAGS_DEFAULT,
       
  9566 				(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Reference"),
       
  9567 						group_referencePtr8.Ptr(),
       
  9568 						group_referencePtr8.Size()));
       
  9569 						
 10038 						
  9570 		}
 10039 		}
  9571 	else
 10040 	else
  9572 		{
 10041 		{
  9573  	   	m_eap_fast_completion_status = m_partner->set_timer(
 10042  		m_eap_fast_completion_status = m_partner->set_timer(
  9574                 this,
 10043 				this,
  9575                 KHandleCompletePacstoreOkTimerID, 
 10044 				KHandleCompletePacstoreOkTimerID, 
  9576                 &m_eap_fast_completion_status,
 10045 				&m_eap_fast_completion_status,
  9577                 1);
 10046 				0);
  9578 
 10047 
  9579  	   	CleanupStack::PopAndDestroy(group_reference8);
 10048  		CleanupStack::PopAndDestroy(group_reference8);
  9580  	   	
 10049  		
  9581 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
 10050 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  9582 		return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10051 		return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  9583 		}
 10052 		}
  9584 	
 10053 
  9585 	HBufC8* tempUserBuf8 = HBufC8::NewLC(ImportReference.get_data_length());
 10054 	HBufC8* tempUserBuf8 = HBufC8::NewLC(ImportReference.get_data_length());
  9586 	TPtr8 tempUserBufPtr8 = tempUserBuf8->Des();
 10055 	TPtr8 tempUserBufPtr8 = tempUserBuf8->Des();
       
 10056 
  9587 	for (int i = 0; i< ImportReference.get_data_length();i++ )
 10057 	for (int i = 0; i< ImportReference.get_data_length();i++ )
  9588 		{
 10058 		{
  9589 		tempUserBufPtr8.Append(group_referencePtr8.Ptr()[i++]);
 10059 		tempUserBufPtr8.Append(group_referencePtr8.Ptr()[i++]);
  9590 		}
 10060 		}
       
 10061 
  9591 	group_referencePtr8.Copy(tempUserBufPtr8);
 10062 	group_referencePtr8.Copy(tempUserBufPtr8);
  9592   	CleanupStack::PopAndDestroy(tempUserBuf8);
 10063 	CleanupStack::PopAndDestroy(tempUserBuf8);
  9593 
 10064 
  9594 	EAP_TRACE_DATA_DEBUG(
 10065 	EAP_TRACE_DATA_DEBUG(
  9595 			m_am_tools,
 10066 		m_am_tools,
  9596 			TRACE_FLAGS_DEFAULT,
 10067 		TRACE_FLAGS_DEFAULT,
  9597 			(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Reformatted Reference"),
 10068 		(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Reformatted Reference"),
  9598 					group_referencePtr8.Ptr(),
 10069 		group_referencePtr8.Ptr(),
  9599 					group_referencePtr8.Size()));
 10070 		group_referencePtr8.Size()));
       
 10071 
  9600 	TInt fileCounter=0;
 10072 	TInt fileCounter=0;
  9601 	TBool directoryEmpty = false;
 10073 	TBool directoryEmpty = false;
  9602 	TBool directoryExists = true;
 10074 	TBool directoryExists = true;
  9603 	HBufC* buf2 = HBufC::NewLC(KMaxPath);
 10075 	HBufC* buf2 = HBufC::NewLC(KMaxPath);
  9604 	HBufC8* filename8 = HBufC8::NewLC(KMaxFileName);
 10076 	HBufC8* filename8 = HBufC8::NewLC(KMaxFileName);
  9610 	TPtr PathPtr = Path->Des();
 10082 	TPtr PathPtr = Path->Des();
  9611 	HBufC8* Path8 = HBufC8::NewLC(KMaxFileName);
 10083 	HBufC8* Path8 = HBufC8::NewLC(KMaxFileName);
  9612 	TPtr8 PathPtr8 = Path8->Des();
 10084 	TPtr8 PathPtr8 = Path8->Des();
  9613 	HBufC8* readData = NULL;
 10085 	HBufC8* readData = NULL;
  9614 	TBool FileFound(EFalse);
 10086 	TBool FileFound(EFalse);
  9615 	
 10087 
  9616 	PathPtr8.Zero();
 10088 	PathPtr8.Zero();
  9617 	PathPtr8.Append(group_referencePtr8);
 10089 	PathPtr8.Append(group_referencePtr8);
  9618 	PathPtr8.Append(KSeparator);
 10090 	PathPtr8.Append(KSeparator);
  9619 
 10091 
  9620 	EAP_TRACE_DATA_DEBUG(
 10092 	EAP_TRACE_DATA_DEBUG(
  9625 			PathPtr8.Size()));
 10097 			PathPtr8.Size()));
  9626 
 10098 
  9627 	PathPtr.Zero();
 10099 	PathPtr.Zero();
  9628 	// Copy is the only function that takes TPtr8 type of parameter.
 10100 	// Copy is the only function that takes TPtr8 type of parameter.
  9629 	PathPtr.Copy(PathPtr8);
 10101 	PathPtr.Copy(PathPtr8);
  9630 	
 10102 
  9631 	{
 10103 	{
  9632 		TFileName aPrivateDatabasePathName;
 10104 		TFileName aPrivateDatabasePathName;
  9633 
 10105 
  9634 		EapPluginTools::GetPrivatePathL(
 10106 		EapPluginTools::GetPrivatePathL(
  9635 			aPrivateDatabasePathName);
 10107 			aPrivateDatabasePathName);
  9645 			TRACE_FLAGS_DEFAULT,
 10117 			TRACE_FLAGS_DEFAULT,
  9646 			(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Path"),
 10118 			(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Path"),
  9647 			PathPtr.Ptr(),
 10119 			PathPtr.Ptr(),
  9648 			PathPtr.Size()));
 10120 			PathPtr.Size()));
  9649 
 10121 
  9650 	EAP_TRACE_DEBUG_SYMBIAN(
 10122 	EAP_TRACE_DEBUG(
  9651 			(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: Check directory availability")));					
 10123 		m_am_tools,
       
 10124 		TRACE_FLAGS_DEFAULT,
       
 10125 		(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Check directory availability")));
  9652 
 10126 
  9653 	if (aFs.GetDir(PathPtr, KEntryAttNormal, ESortByName, files) == KErrNone)
 10127 	if (aFs.GetDir(PathPtr, KEntryAttNormal, ESortByName, files) == KErrNone)
  9654 		{
 10128 		{
  9655 		EAP_TRACE_DEBUG_SYMBIAN(
 10129 		EAP_TRACE_DEBUG(
  9656 				(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: Files %d"),
 10130 			m_am_tools,
  9657 						files->Count()));
 10131 			TRACE_FLAGS_DEFAULT,
       
 10132 			(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Files %d"),
       
 10133 			files->Count()));
  9658 		
 10134 		
  9659 		while (!FileFound && (fileCounter < files->Count()))
 10135 		while (!FileFound && (fileCounter < files->Count()))
  9660 			{
 10136 			{
  9661 			directoryExists = true;
 10137 			directoryExists = true;
  9662 			
 10138 				
  9663 			EAP_TRACE_DEBUG_SYMBIAN(
 10139 			EAP_TRACE_DEBUG(
  9664 					(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: Get directory contents")));					
 10140 				m_am_tools,
  9665 
 10141 				TRACE_FLAGS_DEFAULT,
  9666 			directoryEmpty = false;
 10142 				(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Get directory contents")));
       
 10143 
       
 10144 			directoryEmpty = true;
  9667 
 10145 
  9668 			while( fileCounter < files->Count())
 10146 			while( fileCounter < files->Count())
  9669 				{
 10147 				{
  9670 				if (!((*files)[fileCounter].IsDir()))
 10148 				if (!((*files)[fileCounter].IsDir()))
  9671 					{
 10149 					{
  9672 					filesize = (*files)[fileCounter].iSize;
 10150 					filesize = (*files)[fileCounter].iSize;
  9673 					EAP_TRACE_DEBUG_SYMBIAN(
 10151 
  9674 							(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: File size %d"),
 10152 					EAP_TRACE_DEBUG(
       
 10153 						m_am_tools,
       
 10154 						TRACE_FLAGS_DEFAULT,
       
 10155 						(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: File size %d"),
  9675 									filesize));
 10156 									filesize));
       
 10157 
  9676 					filenamePtr8.Copy((*files)[fileCounter++].iName);
 10158 					filenamePtr8.Copy((*files)[fileCounter++].iName);
       
 10159 
  9677 					EAP_TRACE_DATA_DEBUG(
 10160 					EAP_TRACE_DATA_DEBUG(
  9678 							m_am_tools,
 10161 							m_am_tools,
  9679 							TRACE_FLAGS_DEFAULT,
 10162 							TRACE_FLAGS_DEFAULT,
  9680 							(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Filename"),
 10163 							(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Filename"),
  9681 							filenamePtr8.Ptr(),
 10164 							filenamePtr8.Ptr(),
  9682 							filenamePtr8.Size()));
 10165 							filenamePtr8.Size()));
       
 10166 
  9683 					FileFound = ETrue;
 10167 					FileFound = ETrue;
       
 10168 					directoryEmpty = false;
  9684 					}
 10169 					}
  9685 				else
 10170 				else
  9686 					{
 10171 					{
  9687 					fileCounter++;
 10172 					fileCounter++;
  9688 					}
 10173 					}
  9689 				}
 10174 				}
  9690 			
 10175 
  9691 			if (!FileFound)
 10176 			if (directoryEmpty == true || FileFound == EFalse)
  9692 				{
 10177 				{
  9693 				EAP_TRACE_DEBUG_SYMBIAN(
 10178 				EAP_TRACE_DEBUG(
  9694 					(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: DirectoryEmpty")));					
 10179 					m_am_tools,
  9695 				directoryEmpty = true;
 10180 					TRACE_FLAGS_DEFAULT,
  9696 				}
 10181 					(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: We would remove directory")));
  9697 
 10182 
  9698 			if (directoryEmpty == true ||  directoryExists == false || FileFound == EFalse)
       
  9699 				{
       
  9700 				if (directoryExists)
       
  9701 					{
 10183 					{
  9702 					EAP_TRACE_DEBUG_SYMBIAN(
 10184 					m_eap_fast_completion_status = m_partner->set_timer(
  9703 							(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: We would remove directory")));					
 10185 							  this,
  9704 					
 10186 							  KHandleCompletePacstoreOkTimerID, 
  9705 				   		{
 10187 							  &m_eap_fast_completion_status,
  9706 				           m_eap_fast_completion_status = m_partner->set_timer(
 10188 							  0);
  9707 				                    this,
 10189 
  9708 				                    KHandleCompletePacstoreOkTimerID, 
 10190 					CleanupStack::PopAndDestroy(5); // Path, Path8, filename, buf2, group_reference8
  9709 				                    &m_eap_fast_completion_status,
 10191 
  9710 				                    1);
 10192 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  9711 					   	CleanupStack::PopAndDestroy(5); // Path, Path8, filename, buf2, group_reference8
 10193 					return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  9712 						EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  9713 						return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
       
  9714 				   		}
       
  9715 					}
 10194 					}
  9716 				}
 10195 				}
  9717 			else if(directoryEmpty == false &&  directoryExists == true && FileFound != EFalse)
 10196 			else if(directoryEmpty == false && FileFound )
  9718 				{
 10197 				{
  9719 				PathPtr8.Zero();
 10198 				PathPtr8.Zero();
  9720 				PathPtr8.Append(group_referencePtr8);
 10199 				PathPtr8.Append(group_referencePtr8);
  9721 				PathPtr8.Append(KSeparator);
 10200 				PathPtr8.Append(KSeparator);
  9722 				PathPtr8.Append(filenamePtr8);
 10201 				PathPtr8.Append(filenamePtr8);
  9748 						TRACE_FLAGS_DEFAULT,
 10227 						TRACE_FLAGS_DEFAULT,
  9749 						(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: PathPtr"),
 10228 						(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: PathPtr"),
  9750 						PathPtr.Ptr(),
 10229 						PathPtr.Ptr(),
  9751 						PathPtr.Size()));
 10230 						PathPtr.Size()));
  9752 
 10231 
  9753 				EAP_TRACE_DEBUG_SYMBIAN(
 10232 				EAP_TRACE_DEBUG(
  9754 						(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: Read file")));	
 10233 					m_am_tools,
       
 10234 					TRACE_FLAGS_DEFAULT,
       
 10235 					(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Read file")));	
  9755 				
 10236 				
  9756 				RFile file;
 10237 				RFile file;
  9757 
 10238 
  9758 				if(file.Open(aFs, PathPtr, EFileRead)==KErrNone)
 10239 				if(file.Open(aFs, PathPtr, EFileRead)==KErrNone)
  9759 					{
 10240 					{
  9760 					readData= HBufC8::NewLC(filesize); 
 10241 					readData= HBufC8::NewLC(filesize); 
  9761 					TPtr8 readDataPtr = readData->Des();
 10242 					TPtr8 readDataPtr = readData->Des();
  9762 					file.Read(readDataPtr);
 10243 					file.Read(readDataPtr);
  9763 					file.Close();
 10244 					file.Close();
  9764 					
 10245 					
  9765 					EAP_TRACE_DEBUG_SYMBIAN(
 10246 					EAP_TRACE_DEBUG(
  9766 							(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: Copy data")));	
 10247 						m_am_tools,
  9767 					
 10248 						TRACE_FLAGS_DEFAULT,
       
 10249 						(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Copy data")));	
       
 10250 
  9768 					eap_variable_data_c * const in_imported_PAC_data = new eap_variable_data_c(m_am_tools);
 10251 					eap_variable_data_c * const in_imported_PAC_data = new eap_variable_data_c(m_am_tools);
  9769 					// eap_automatic_variable_c can be used in this block because no functions are leaving here.
 10252 					// eap_automatic_variable_c can be used in this block because no functions are leaving here.
  9770 					eap_automatic_variable_c<eap_variable_data_c> automatic_in_imported_PAC_data(m_am_tools, in_imported_PAC_data);
 10253 					eap_automatic_variable_c<eap_variable_data_c> automatic_in_imported_PAC_data(m_am_tools, in_imported_PAC_data);
  9771 					if (in_imported_PAC_data == 0)
 10254 					if (in_imported_PAC_data == 0)
  9772 					{
 10255 					{
  9811 					if (IAP_reference.get_data_length() != 0)
 10294 					if (IAP_reference.get_data_length() != 0)
  9812 						m_eap_fast_completion_status = IAP_reference.set_copy_of_buffer(reference, sizeof(reference));
 10295 						m_eap_fast_completion_status = IAP_reference.set_copy_of_buffer(reference, sizeof(reference));
  9813 					else
 10296 					else
  9814 						m_eap_fast_completion_status = IAP_reference.set_copy_of_buffer(EAP_FAST_ZERO_REFERENCE, sizeof(EAP_FAST_ZERO_REFERENCE));
 10297 						m_eap_fast_completion_status = IAP_reference.set_copy_of_buffer(EAP_FAST_ZERO_REFERENCE, sizeof(EAP_FAST_ZERO_REFERENCE));
  9815 						
 10298 						
  9816 					EAP_TRACE_DEBUG_SYMBIAN(
 10299 					EAP_TRACE_DEBUG(
  9817 							(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: Complete operation")));	
 10300 						m_am_tools,
       
 10301 						TRACE_FLAGS_DEFAULT,
       
 10302 						(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Complete operation")));	
  9818 					
 10303 					
  9819 					if (m_eap_fast_completion_status != eap_status_ok)
 10304 					if (m_eap_fast_completion_status != eap_status_ok)
  9820 						{
 10305 						{
  9821 					   	if (readData != NULL)
 10306 						if (readData != NULL)
  9822 							{
 10307 							{
  9823 					   		CleanupStack::PopAndDestroy(readData);
 10308 					   		CleanupStack::PopAndDestroy(readData);
  9824 							}
 10309 							}
  9825 					   	CleanupStack::PopAndDestroy(5); // filename, buf2, group_reference8, Path, path8
 10310 						CleanupStack::PopAndDestroy(5); // filename, buf2, group_reference8, Path, path8
  9826 					   	delete files;
 10311 						delete files;
  9827 						return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10312 						return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  9828 						}
 10313 						}
  9829 					else
 10314 					else
  9830 					    {
 10315 						{
  9831 						m_eap_fast_completion_status = m_tls_application->add_imported_PAC_file(
 10316 						m_eap_fast_completion_status = m_tls_application->add_imported_PAC_file(
  9832 							&IAP_reference,
 10317 							&IAP_reference,
  9833 							in_opt_group_reference_and_data,
 10318 							in_opt_group_reference_and_data,
  9834 							in_imported_PAC_data,
 10319 							in_imported_PAC_data,
  9835 							in_imported_PAC_filename);
 10320 							in_imported_PAC_filename);
  9836 						aSuccess = ETrue;
 10321 						aSuccess = ETrue;
  9837 					    }
 10322 						}
  9838 					}
 10323 					}
  9839 				}
 10324 				else
  9840 			else
 10325 					{
  9841 				{
 10326 					badFile = true;
  9842 				badFile = true;
 10327 					}					
  9843 				}
 10328 				}
  9844 			}
 10329 			}
  9845 		}
 10330 		}
  9846 	else
 10331 	else
  9847 		{
 10332 		{
  9848 		EAP_TRACE_DEBUG_SYMBIAN(
 10333 		EAP_TRACE_DEBUG(
  9849 				(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: No Directory")));					
 10334 			m_am_tools,
       
 10335 			TRACE_FLAGS_DEFAULT,
       
 10336 			(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: No Directory")));
       
 10337 
  9850 		directoryExists = false;
 10338 		directoryExists = false;
  9851 		}
 10339 		}
  9852 	
 10340 
  9853    	if (readData != NULL)
 10341 	if (readData != NULL)
  9854 		{
 10342 		{
  9855    		CleanupStack::PopAndDestroy(readData);
 10343    		CleanupStack::PopAndDestroy(readData);
  9856 		}
 10344 		}
  9857 	CleanupStack::PopAndDestroy(5); // Path, filename8, buf2, Path8, group_reference8
 10345 	CleanupStack::PopAndDestroy(5); // Path, filename8, buf2, Path8, group_reference8
  9858 
 10346 
  9859 	EAP_TRACE_DEBUG_SYMBIAN(
 10347 	EAP_TRACE_DEBUG(
  9860 		(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: Operation failed or Complete")));	
 10348 		m_am_tools,
       
 10349 		TRACE_FLAGS_DEFAULT,
       
 10350 		(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Operation failed or Complete")));
  9861 
 10351 
  9862 	delete files;
 10352 	delete files;
  9863 	
 10353 
  9864 	if (m_eap_fast_completion_status != eap_status_pending_request || aSuccess == EFalse)
 10354 	if (m_eap_fast_completion_status != eap_status_pending_request || aSuccess == EFalse)
  9865 		{
 10355 		{
  9866 		if(badFile == true || directoryEmpty == true ||  directoryExists == false)   	
 10356 		if(badFile == true || directoryEmpty == true ||  directoryExists == false)   	
  9867 			{
 10357 			{
  9868 			if (aSuccess == EFalse)
 10358 			if (aSuccess == EFalse)
  9869 			    m_eap_fast_completion_status = eap_status_ok;
 10359 				m_eap_fast_completion_status = eap_status_ok;
  9870 	        m_eap_fast_completion_status = m_partner->set_timer(
 10360 			m_eap_fast_completion_status = m_partner->set_timer(
  9871 	                this,
 10361 					this,
  9872 	                KHandleCompletePacstoreNokTimerID, 
 10362 					KHandleCompletePacstoreNokTimerID, 
  9873 	                &m_eap_fast_completion_status,
 10363 					&m_eap_fast_completion_status,
  9874 	                0);
 10364 					0);
  9875 			}
 10365 			}
  9876 		else
 10366 		else
  9877 			{
 10367 			{
  9878 		       m_eap_fast_completion_status = m_partner->set_timer(
 10368 			   m_eap_fast_completion_status = m_partner->set_timer(
  9879 		                this,
 10369 						this,
  9880 		                KHandleCompletePacstoreOkTimerID, 
 10370 						KHandleCompletePacstoreOkTimerID, 
  9881 		                &m_eap_fast_completion_status,
 10371 						&m_eap_fast_completion_status,
  9882 		                0);
 10372 						0);
  9883 			}
 10373 			}
  9884 		}
 10374 		}
  9885 	EAP_TRACE_DEBUG_SYMBIAN(
 10375 
  9886 			(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL - End")));
 10376 	EAP_TRACE_DEBUG(
       
 10377 		m_am_tools,
       
 10378 		TRACE_FLAGS_DEFAULT,
       
 10379 		(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL - End")));
  9887 
 10380 
  9888 	return m_eap_fast_completion_status;
 10381 	return m_eap_fast_completion_status;
  9889 }
 10382 }
  9890 
 10383 
  9891 // ----------------------------------------------------------------------------
 10384 // ----------------------------------------------------------------------------
  9892 
 10385 
  9893 eap_status_e eap_am_type_tls_peap_symbian_c::PasswordQueryL()
 10386 eap_status_e eap_am_type_tls_peap_symbian_c::PasswordQueryL()
  9894 {
 10387 {
  9895 
 10388 	EAP_TRACE_DEBUG(
  9896 	EAP_TRACE_DEBUG_SYMBIAN(
 10389 		m_am_tools,
  9897 			(_L("eap_am_type_tls_peap_symbian_c::PasswordQueryL")));
 10390 		TRACE_FLAGS_DEFAULT,
  9898 
 10391 		(EAPL("eap_am_type_tls_peap_symbian_c::PasswordQueryL()")));
       
 10392 
       
 10393 	delete m_pacStorePWBuf8;
  9899 	m_pacStorePWBuf8 = HBufC8::NewLC(m_userResponse.get_data_length());
 10394 	m_pacStorePWBuf8 = HBufC8::NewLC(m_userResponse.get_data_length());
  9900 	TPtr8 pacStorePWPtr8 = m_pacStorePWBuf8->Des();
 10395 	TPtr8 pacStorePWPtr8 = m_pacStorePWBuf8->Des();
  9901 	pacStorePWPtr8.Copy(m_userResponse.get_data(),m_userResponse.get_data_length() );
 10396 	pacStorePWPtr8.Copy(m_userResponse.get_data(),m_userResponse.get_data_length() );
  9902 	m_PAC_store_password.set_copy_of_buffer(m_userResponse.get_data(), m_userResponse.get_data_length());
 10397 
  9903 	EAP_TRACE_DATA_DEBUG_SYMBIAN(
 10398 	eap_status_e status = m_PAC_store_password.set_copy_of_buffer(m_userResponse.get_data(), m_userResponse.get_data_length());
  9904 	("eap_am_type_tls_peap_symbian_c::PasswordQueryL:PW used for masterkey verification (8bits)",
 10399 	if (status != eap_status_ok)
  9905 			pacStorePWPtr8.Ptr(), 
 10400 	{
  9906 			pacStorePWPtr8.Size()));	    
 10401 		CleanupStack::PopAndDestroy(m_pacStorePWBuf8);
  9907    
 10402 		m_pacStorePWBuf8 = 0;
  9908 
 10403 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);		
  9909     if (iPacStoreDb->IsMasterKeyPresentL() && pacStorePWPtr8.Size()>0 )
 10404 		return EAP_STATUS_RETURN(m_am_tools, status);
  9910    	    m_verificationStatus = iPacStoreDb->IsMasterKeyAndPasswordMatchingL(pacStorePWPtr8);
 10405 	}	
  9911    	
 10406 
  9912    	if ((pacStorePWPtr8.Size()==0 && (m_state == EPasswordQuery || m_state == EMasterkeyQuery ))
 10407 	EAP_TRACE_DATA_DEBUG(
       
 10408 		m_am_tools,
       
 10409 		TRACE_FLAGS_DEFAULT,
       
 10410 		(EAPL("eap_am_type_tls_peap_symbian_c::PasswordQueryL:PW used for masterkey verification (8bits)"),
       
 10411 		pacStorePWPtr8.Ptr(), 
       
 10412 		pacStorePWPtr8.Size()));
       
 10413 
       
 10414 
       
 10415 	if (iPacStoreDb->IsMasterKeyPresentL() && pacStorePWPtr8.Size()>0 )
       
 10416    		m_verificationStatus = iPacStoreDb->IsMasterKeyAndPasswordMatchingL(pacStorePWPtr8);
       
 10417 
       
 10418 	if ((pacStorePWPtr8.Size()==0 && (m_state == EPasswordQuery || m_state == EMasterkeyQuery ))
  9913    			|| m_userAction == EEapFastNotifierUserActionCancel || m_state == EPasswordCancel)
 10419    			|| m_userAction == EEapFastNotifierUserActionCancel || m_state == EPasswordCancel)
  9914    		{
 10420    		{
  9915     	m_verificationStatus = EFalse;
 10421 		m_verificationStatus = EFalse;
  9916     	m_state = EPasswordCancel;
 10422 		m_state = EPasswordCancel;
  9917     	CleanupStack::PopAndDestroy(m_pacStorePWBuf8);
 10423 		CleanupStack::PopAndDestroy(m_pacStorePWBuf8);
  9918    	
 10424 		m_pacStorePWBuf8 = 0;
       
 10425 
  9919    		m_eap_fast_completion_status = m_partner->set_timer(
 10426    		m_eap_fast_completion_status = m_partner->set_timer(
  9920 				this,
 10427 				this,
  9921 				KHandleReadPacstoreTimerID, 
 10428 				KHandleReadPacstoreTimerID, 
  9922 				&m_eap_fast_completion_status,
 10429 				&m_eap_fast_completion_status,
  9923 				0);
 10430 				0);
  9924 		return m_eap_fast_completion_status;
 10431 		return m_eap_fast_completion_status;
  9925  		}
 10432  		}
  9926    	
 10433 
  9927    	EAP_TRACE_DEBUG(
 10434 	EAP_TRACE_DEBUG(
  9928 			m_am_tools,
 10435 			m_am_tools,
  9929 			TRACE_FLAGS_DEFAULT,
 10436 			TRACE_FLAGS_DEFAULT,
  9930 			(EAPL("EAP-FAST:eap_am_type_tls_peap_symbian_c::PasswordQueryL:State:%d Prev_State:%d verificationstatus:%d"),
 10437 			(EAPL("EAP-FAST:eap_am_type_tls_peap_symbian_c::PasswordQueryL:State:%d Prev_State:%d verificationstatus:%d"),
  9931 					m_state, 
 10438 			m_state, 
  9932 					m_prev_state,
 10439 			m_prev_state,
  9933 					m_verificationStatus));
 10440 			m_verificationStatus));
  9934 	
 10441 
  9935 	eap_status_e m_eap_fast_completion_status(eap_status_ok);
 10442 	eap_status_e m_eap_fast_completion_status(eap_status_ok);
  9936 	
 10443 
  9937 	  if (m_state == EPasswordQuery)
 10444 	if (m_state == EPasswordQuery)
  9938 		  {
 10445 		{
  9939 		  m_state = EWrongPassword;
 10446 		m_state = EWrongPassword;
  9940 
 10447 
  9941 		  if(m_verificationStatus == EFalse)
 10448 		if(m_verificationStatus == EFalse)
  9942 	    	{
 10449 			{
  9943 	    	CleanupStack::PopAndDestroy(m_pacStorePWBuf8);
 10450 			CleanupStack::PopAndDestroy(m_pacStorePWBuf8);
  9944 	    	
 10451 			m_pacStorePWBuf8 = 0;
  9945 		    TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
 10452 
  9946 		    
 10453 			TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  9947 		    m_notifier_data_to_user->iPassword.Zero();
 10454 
  9948 	
 10455 			m_notifier_data_to_user->iPassword.Zero();
       
 10456 
  9949 			return m_eap_fast_completion_status;
 10457 			return m_eap_fast_completion_status;
  9950 			 	    
 10458 					
  9951 	    	}
 10459 			}
  9952 		  else
 10460 		else
  9953 	    	{
 10461 			{
  9954 			m_eap_fast_completion_status = m_partner->set_timer(
 10462 			m_eap_fast_completion_status = m_partner->set_timer(
  9955 					this,
 10463 					this,
  9956 					KHandleReadPacstoreTimerID, 
 10464 					KHandleReadPacstoreTimerID, 
  9957 					&m_eap_fast_completion_status,
 10465 					&m_eap_fast_completion_status,
  9958 					0);
 10466 					0);
  9959 
 10467 
  9960 			CleanupStack::PopAndDestroy(m_pacStorePWBuf8);
 10468 			CleanupStack::PopAndDestroy(m_pacStorePWBuf8);
  9961 	  		return m_eap_fast_completion_status;
 10469 			m_pacStorePWBuf8 = 0;
  9962 	    	}
 10470 			return m_eap_fast_completion_status;
  9963 		  }
 10471 			}
  9964 	  if (m_state == EWrongPassword)
 10472 		}
  9965     	{
 10473 
  9966         	m_state = EPasswordQuery;
 10474 	if (m_state == EWrongPassword)
  9967  
 10475 		{
  9968        	EAP_TRACE_DEBUG(
 10476 		m_state = EPasswordQuery;
       
 10477 
       
 10478 		EAP_TRACE_DEBUG(
  9969     			m_am_tools,
 10479     			m_am_tools,
  9970     			TRACE_FLAGS_DEFAULT,
 10480     			TRACE_FLAGS_DEFAULT,
  9971     			(EAPL("EAP-FAST:eap_am_type_tls_peap_symbian_c::PasswordQueryL (first pw ?):State:%d Prev_State:%d verificationstatus:%d"),
 10481     			(EAPL("EAP-FAST:eap_am_type_tls_peap_symbian_c::PasswordQueryL (first pw ?):State:%d Prev_State:%d verificationstatus:%d"),
  9972     					m_state, 
 10482     					m_state, 
  9973     					m_prev_state,
 10483     					m_prev_state,
  9974     					m_verificationStatus));
 10484     					m_verificationStatus));
  9975        	pacStorePWPtr8.Zero();
 10485 
  9976        	if (m_verificationStatus == EFalse)
 10486 		pacStorePWPtr8.Zero();
  9977 					{
 10487 
  9978     TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
 10488 		if (m_verificationStatus == EFalse)
  9979     if (iEapAuthNotifier == 0)
 10489 			{
  9980     	{
 10490 			TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  9981     	TRAPD(err3, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
 10491 			if (iEapAuthNotifier == 0)
  9982     	if (err3)
 10492 				{
  9983     		{
 10493 				TRAPD(err3, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
  9984     			return eap_status_process_general_error;
 10494 				if (err3)
  9985     		}
 10495     				{
  9986     	}
 10496     					return eap_status_process_general_error;
  9987     else
 10497     				}
  9988     	{
 10498 				}
  9989     	TRAPD(err4, iEapAuthNotifier->Cancel());
 10499 			else
  9990     	if (err4)
 10500 				{
  9991     		{
 10501 				TRAPD(err4, iEapAuthNotifier->Cancel());
  9992     			return eap_status_process_general_error;
 10502 				if (err4)
  9993     		}
 10503     				{
  9994     	}
 10504     					return eap_status_process_general_error;
  9995 
 10505     				}
  9996 		TRAPD(err5, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastPacStorePwQueryDialog, m_notifier_data_to_user, aEapType));
 10506 				}
  9997   	if (err5)
 10507 
  9998   		{
 10508 			TRAPD(err5, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastPacStorePwQueryDialog, m_notifier_data_to_user, aEapType));
  9999   			return eap_status_process_general_error;
 10509 			if (err5)
 10000   		}
 10510   				{
 10001  
 10511   					return eap_status_process_general_error;
 10002 
 10512   				}
 10003 					}
 10513 			}
 10004 		else
 10514 		else
       
 10515 			{
 10005 			m_eap_fast_completion_status = m_partner->set_timer(
 10516 			m_eap_fast_completion_status = m_partner->set_timer(
 10006 				this,
 10517 				this,
 10007 				KHandleReadPacstoreTimerID, 
 10518 				KHandleReadPacstoreTimerID, 
 10008 				&m_eap_fast_completion_status,
 10519 				&m_eap_fast_completion_status,
 10009 				0);
 10520 				0);
 10010 		
 10521 			}
       
 10522 
 10011 		CleanupStack::PopAndDestroy(m_pacStorePWBuf8);
 10523 		CleanupStack::PopAndDestroy(m_pacStorePWBuf8);
       
 10524 		m_pacStorePWBuf8 = 0;
 10012 		return m_eap_fast_completion_status;
 10525 		return m_eap_fast_completion_status;
 10013     	}
 10526 		}
 10014 
 10527 
 10015     if (m_PAC_store_password.get_data_length()>0 && m_state == EMasterkeyQuery)
 10528 	if (m_PAC_store_password.get_data_length()>0 && m_state == EMasterkeyQuery)
 10016     	{
 10529 		{
 10017     	
 10530 		if ( m_verificationStatus != EFalse)
 10018     	if ( m_verificationStatus != EFalse)
 10531 			{
 10019     		{
 10532 			EAP_TRACE_DEBUG(
 10020     		EAP_TRACE_DEBUG_SYMBIAN(
 10533 				m_am_tools,
 10021     			(_L("eap_am_type_tls_peap_symbian_c::PasswordQueryL - EMasterkeyQuery - OK")));
 10534 				TRACE_FLAGS_DEFAULT,
 10022     		}
 10535 				(EAPL("eap_am_type_tls_peap_symbian_c::PasswordQueryL - EMasterkeyQuery - OK")));
 10023      	else // temporary before masterkey creation is done dynamically !!!
 10536 			}
 10024     		{
 10537 		else // temporary before masterkey creation is done dynamically !!!
 10025     TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
 10538 			{
 10026     if (iEapAuthNotifier == 0)
 10539 			TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
 10027     	{
 10540 			if (iEapAuthNotifier == 0)
 10028     	TRAPD(err, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
 10541 				{
 10029 	  	if (err)
 10542 				TRAPD(error, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
 10030 	  		{
 10543 				if (error)
 10031 	  			return eap_status_process_general_error;
 10544 					{
 10032 	  		}
 10545   					return eap_status_process_general_error;
 10033     	}
 10546 					}
 10034     else
       
 10035     	{
       
 10036     	TRAPD(err1, iEapAuthNotifier->Cancel());
       
 10037 	  	if (err1)
       
 10038 	  		{
       
 10039 	  			return eap_status_process_general_error;
       
 10040 	  		}
       
 10041     	}
       
 10042 
       
 10043 		TRAPD(err2, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastCreateMasterkeyQueryDialog, m_notifier_data_to_user, aEapType));
       
 10044   	if (err2)
       
 10045   		{
       
 10046   			return eap_status_process_general_error;
       
 10047   		}
       
 10048 			
       
 10049 
       
 10050 
       
 10051 				}
 10547 				}
 10052     	}
 10548 			else
 10053 
 10549 				{
 10054     CleanupStack::PopAndDestroy(m_pacStorePWBuf8);
 10550 				TRAPD(err1, iEapAuthNotifier->Cancel());
 10055     
 10551 				if (err1)
       
 10552 					{
       
 10553   					return eap_status_process_general_error;
       
 10554 					}
       
 10555 				}
       
 10556 
       
 10557 			TRAPD(err2, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastCreateMasterkeyQueryDialog, m_notifier_data_to_user, aEapType));
       
 10558 			if (err2)
       
 10559 				{
       
 10560 				return eap_status_process_general_error;
       
 10561 				}
       
 10562 			}
       
 10563 		}
       
 10564 
       
 10565 	CleanupStack::PopAndDestroy(m_pacStorePWBuf8);
       
 10566 	m_pacStorePWBuf8 = 0;
       
 10567 
 10056 	return m_eap_fast_completion_status;
 10568 	return m_eap_fast_completion_status;
 10057 }
 10569 }
 10058 
 10570 
 10059 //--------------------------------------------------
 10571 //--------------------------------------------------
 10060 
 10572 
 10061 eap_status_e eap_am_type_tls_peap_symbian_c::CompletePasswordQueryL()
 10573 eap_status_e eap_am_type_tls_peap_symbian_c::CompletePasswordQueryL()
 10062 {
 10574 {
 10063 
 10575 	EAP_TRACE_DEBUG(
 10064 	EAP_TRACE_DEBUG_SYMBIAN(
 10576 		m_am_tools,
 10065 			(_L("eap_am_type_tls_peap_symbian_c::CompletePasswordQueryL")));
 10577 		TRACE_FLAGS_DEFAULT,
       
 10578 		(EAPL("eap_am_type_tls_peap_symbian_c::CompletePasswordQueryL()")));
 10066 
 10579 
 10067 	// m_PAC_store_password should have the PW now. Proceed as normal case.	
 10580 	// m_PAC_store_password should have the PW now. Proceed as normal case.	
 10068 	
 10581 	
 10069 	eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools);
 10582 	eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools);
 10070 
 10583 
 10075 	{
 10588 	{
 10076 		m_eap_fast_completion_status = eap_status_allocation_error;
 10589 		m_eap_fast_completion_status = eap_status_allocation_error;
 10077 		(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10590 		(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10078 		return m_eap_fast_completion_status;
 10591 		return m_eap_fast_completion_status;
 10079 	}
 10592 	}
       
 10593 
 10080 	//eap_pac_store_data_type_PAC_store_password
 10594 	//eap_pac_store_data_type_PAC_store_password
 10081 	EAP_TRACE_DEBUG(
 10595 	EAP_TRACE_DEBUG(
 10082 			m_am_tools,
 10596 			m_am_tools,
 10083 			TRACE_FLAGS_DEFAULT,
 10597 			TRACE_FLAGS_DEFAULT,
 10084 			(EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::CompletePasswordQueryL()Datatype=%d"),
 10598 			(EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::CompletePasswordQueryL()Datatype=%d"),
 10120 	
 10634 	
 10121 	if (m_eap_fast_completion_status != eap_status_ok)
 10635 	if (m_eap_fast_completion_status != eap_status_ok)
 10122 	{
 10636 	{
 10123 		(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10637 		(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10124 	
 10638 	
 10125 	EAP_TRACE_DATA_DEBUG_SYMBIAN(
 10639 	EAP_TRACE_DATA_DEBUG(
 10126 		("EAP-FAST: eap_am_type_tls_peap_symbian_c::CompletePasswordQueryL eap_pac_store_data_type_PAC_store_password - added data",
 10640 		m_am_tools,
       
 10641 		TRACE_FLAGS_DEFAULT,
       
 10642 		(EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::CompletePasswordQueryL eap_pac_store_data_type_PAC_store_password - added data"),
 10127 		(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
 10643 		(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
 10128 		(new_data->get_data())->get_data_length()));
 10644 		(new_data->get_data())->get_data_length()));
       
 10645 
 10129 	return m_eap_fast_completion_status;
 10646 	return m_eap_fast_completion_status;
 10130 	}
 10647 	}
 10131 
 10648 
 10132 	m_both_completed++;
 10649 	m_both_completed++;
 10133 
 10650 
 10136 
 10653 
 10137 //--------------------------------------------------
 10654 //--------------------------------------------------
 10138 
 10655 
 10139 eap_status_e eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL(eap_status_e status)
 10656 eap_status_e eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL(eap_status_e status)
 10140 {
 10657 {
 10141 	EAP_TRACE_DEBUG_SYMBIAN(
 10658 	EAP_TRACE_DEBUG(
 10142 			(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL")));
 10659 		m_am_tools,
 10143 	if (status == eap_status_ok && (m_new_references_and_data_blocks.get_object_count()>0))
 10660 		TRACE_FLAGS_DEFAULT,
 10144 		{
 10661 		(EAPL("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL()")));
       
 10662 
       
 10663 	if (status == eap_status_ok
       
 10664 		&& (m_new_references_and_data_blocks.get_object_count() > 0))
       
 10665 	{
 10145 		for (u32_t ind = 0ul; ind < m_ready_references_array_index; ++ind)
 10666 		for (u32_t ind = 0ul; ind < m_ready_references_array_index; ++ind)
 10146 			{
 10667 		{
 10147 			eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools);
 10668 			const eap_fast_pac_store_data_c * const original_data = m_references_and_data_blocks.get_object(ind);
 10148 	
 10669 			if (original_data == 0)
 10149 			eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
       
 10150 				m_am_tools, new_data);
       
 10151 	
       
 10152 			if (new_data == 0)
       
 10153 			{
 10670 			{
 10154 				m_eap_fast_completion_status = eap_status_allocation_error;
 10671 				m_eap_fast_completion_status = eap_status_allocation_error;
       
 10672 
 10155 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10673 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10156 	
 10674 	
 10157 				EAP_TRACE_DEBUG_SYMBIAN(
 10675 				EAP_TRACE_DEBUG(
 10158 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10676 					m_am_tools,
       
 10677 					TRACE_FLAGS_DEFAULT,
       
 10678 					(EAPL("ERROR: eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL(): original_data is NULL.")));
       
 10679 
 10159 				m_ready_references_and_data_blocks.reset();
 10680 				m_ready_references_and_data_blocks.reset();
 10160 				
 10681 				
 10161 				status = m_tls_application->complete_read_PAC_store_data(
 10682 				status = m_tls_application->complete_read_PAC_store_data(
 10162 					m_eap_fast_completion_status,
 10683 					m_eap_fast_completion_status,
 10163 					m_eap_fast_pac_store_pending_operation,
 10684 					m_eap_fast_pac_store_pending_operation,
 10164 					&m_references_and_data_blocks);
 10685 					&m_references_and_data_blocks);
 10165 				
 10686 				
 10166 				return status;
 10687 				return EAP_STATUS_RETURN(m_am_tools, status);
 10167 			}
 10688 			}
 10168 	
 10689 
 10169 			new_data->set_type(m_references_and_data_blocks.get_object(ind)->get_type());
 10690 			eap_fast_pac_store_data_c * const new_data = original_data->copy();
 10170 			
 10691 	
 10171 			// Set the reference.
 10692 			eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
 10172 			m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(m_references_and_data_blocks.get_object(ind)->get_reference());
 10693 				m_am_tools, new_data);
 10173 			if (m_eap_fast_completion_status != eap_status_ok)
 10694 	
 10174 			{
 10695 			if (new_data == 0)
       
 10696 			{
       
 10697 				m_eap_fast_completion_status = eap_status_allocation_error;
       
 10698 
 10175 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10699 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10176 				EAP_TRACE_DEBUG_SYMBIAN(
 10700 	
 10177 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10701 				EAP_TRACE_DEBUG(
       
 10702 					m_am_tools,
       
 10703 					TRACE_FLAGS_DEFAULT,
       
 10704 					(EAPL("ERROR: eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL(): new_data allocation failed.")));
       
 10705 
 10178 				m_ready_references_and_data_blocks.reset();
 10706 				m_ready_references_and_data_blocks.reset();
 10179 				
 10707 				
 10180 				status = m_tls_application->complete_read_PAC_store_data(
 10708 				status = m_tls_application->complete_read_PAC_store_data(
 10181 					m_eap_fast_completion_status,
 10709 					m_eap_fast_completion_status,
 10182 					m_eap_fast_pac_store_pending_operation,
 10710 					m_eap_fast_pac_store_pending_operation,
 10183 					&m_references_and_data_blocks);
 10711 					&m_references_and_data_blocks);
 10184 				
 10712 				
 10185 				return status;
 10713 				return EAP_STATUS_RETURN(m_am_tools, status);
 10186 			}					
 10714 			}
 10187 	
 10715 	
 10188 			m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(m_references_and_data_blocks.get_object(ind)->get_data());
 10716 			automatic_new_data.do_not_free_variable();
       
 10717 	
       
 10718 			m_eap_fast_completion_status = m_ready_references_and_data_blocks.add_object(new_data, true);
 10189 			if (m_eap_fast_completion_status != eap_status_ok)
 10719 			if (m_eap_fast_completion_status != eap_status_ok)
 10190 			{
 10720 			{
 10191 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10721 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10192 				EAP_TRACE_DEBUG_SYMBIAN(
 10722 
 10193 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10723 				EAP_TRACE_DEBUG(
       
 10724 					m_am_tools,
       
 10725 					TRACE_FLAGS_DEFAULT,
       
 10726 					(EAPL("ERROR: eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL(): add_object failed, status=%d=%s"),
       
 10727 					m_eap_fast_completion_status,
       
 10728 					eap_status_string_c::get_status_string(m_eap_fast_completion_status)));
       
 10729 
 10194 				m_ready_references_and_data_blocks.reset();
 10730 				m_ready_references_and_data_blocks.reset();
 10195 				
 10731 				
 10196 				status = m_tls_application->complete_read_PAC_store_data(
 10732 				status = m_tls_application->complete_read_PAC_store_data(
 10197 					m_eap_fast_completion_status,
 10733 					m_eap_fast_completion_status,
 10198 					m_eap_fast_pac_store_pending_operation,
 10734 					m_eap_fast_pac_store_pending_operation,
 10199 					&m_references_and_data_blocks);
 10735 					&m_references_and_data_blocks);
 10200 				
 10736 				
 10201 				return status;
 10737 				return EAP_STATUS_RETURN(m_am_tools, status);
 10202 			}
 10738 			}
 10203 	
 10739 			
 10204 			automatic_new_data.do_not_free_variable();
 10740 			EAP_TRACE_DATA_DEBUG(
 10205 	
 10741 				m_am_tools,
 10206 			m_eap_fast_completion_status = m_ready_references_and_data_blocks.add_object(new_data, true);
 10742 				TRACE_FLAGS_DEFAULT,
 10207 			if (m_eap_fast_completion_status != eap_status_ok)
 10743 				(EAPL("Final_complete_read_PAC_store_data - added original data"),
 10208 			{
 10744 				(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
       
 10745 				(new_data->get_data())->get_data_length()));
       
 10746 			
       
 10747 		} // for()
       
 10748 	
       
 10749 		// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
 10750 
       
 10751 		{
       
 10752 			const eap_fast_pac_store_data_c * const original_data = m_new_references_and_data_blocks.get_object(m_ready_references_array_index);
       
 10753 			if (original_data == 0)
       
 10754 			{
       
 10755 				m_eap_fast_completion_status = eap_status_allocation_error;
       
 10756 
 10209 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10757 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10210 				EAP_TRACE_DEBUG_SYMBIAN(
 10758 	
 10211 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10759 				EAP_TRACE_DEBUG(
       
 10760 					m_am_tools,
       
 10761 					TRACE_FLAGS_DEFAULT,
       
 10762 					(EAPL("ERROR: eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL(): original_data is NULL.")));
       
 10763 
 10212 				m_ready_references_and_data_blocks.reset();
 10764 				m_ready_references_and_data_blocks.reset();
 10213 				
 10765 				
 10214 				status = m_tls_application->complete_read_PAC_store_data(
 10766 				status = m_tls_application->complete_read_PAC_store_data(
 10215 					m_eap_fast_completion_status,
 10767 					m_eap_fast_completion_status,
 10216 					m_eap_fast_pac_store_pending_operation,
 10768 					m_eap_fast_pac_store_pending_operation,
 10217 					&m_references_and_data_blocks);
 10769 					&m_references_and_data_blocks);
 10218 				
 10770 				
 10219 				return status;
 10771 				return EAP_STATUS_RETURN(m_am_tools, status);
 10220 			}
 10772 			}
 10221 			
 10773 
 10222 			EAP_TRACE_DATA_DEBUG_SYMBIAN(
 10774 			eap_fast_pac_store_data_c * const new_data = original_data->copy();
 10223 				("Final_complete_read_PAC_store_data - added original data",
 10775 		
 10224 				(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
       
 10225 				(new_data->get_data())->get_data_length()));										
       
 10226 			
       
 10227 			}
       
 10228 	
       
 10229 		eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools);
       
 10230 	
       
 10231 		eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
       
 10232 			m_am_tools, new_data);
       
 10233 	
       
 10234 		if (new_data == 0)
       
 10235 		{
       
 10236 			m_eap_fast_completion_status = eap_status_allocation_error;
       
 10237 			(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
       
 10238 			EAP_TRACE_DEBUG_SYMBIAN(
       
 10239 					(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
       
 10240 			m_ready_references_and_data_blocks.reset();
       
 10241 			
       
 10242 			status = m_tls_application->complete_read_PAC_store_data(
       
 10243 				m_eap_fast_completion_status,
       
 10244 				m_eap_fast_pac_store_pending_operation,
       
 10245 				&m_references_and_data_blocks);
       
 10246 			
       
 10247 			return status;
       
 10248 		}
       
 10249 	
       
 10250 		new_data->set_type(m_new_references_and_data_blocks.get_object(m_ready_references_array_index)->get_type());
       
 10251 		
       
 10252 		// Set the reference.
       
 10253 		m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(m_new_references_and_data_blocks.get_object(m_ready_references_array_index)->get_reference());
       
 10254 		if (m_eap_fast_completion_status != eap_status_ok)
       
 10255 		{
       
 10256 			(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
       
 10257 			EAP_TRACE_DEBUG_SYMBIAN(
       
 10258 					(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
       
 10259 			m_ready_references_and_data_blocks.reset();
       
 10260 			
       
 10261 			status = m_tls_application->complete_read_PAC_store_data(
       
 10262 				m_eap_fast_completion_status,
       
 10263 				m_eap_fast_pac_store_pending_operation,
       
 10264 				&m_references_and_data_blocks);
       
 10265 			
       
 10266 			return status;
       
 10267 		}					
       
 10268 	
       
 10269 		m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(m_new_references_and_data_blocks.get_object(m_ready_references_array_index)->get_data());
       
 10270 		if (m_eap_fast_completion_status != eap_status_ok)
       
 10271 		{
       
 10272 			(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
       
 10273 			EAP_TRACE_DEBUG_SYMBIAN(
       
 10274 					(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
       
 10275 			m_ready_references_and_data_blocks.reset();
       
 10276 			
       
 10277 			status = m_tls_application->complete_read_PAC_store_data(
       
 10278 				m_eap_fast_completion_status,
       
 10279 				m_eap_fast_pac_store_pending_operation,
       
 10280 				&m_references_and_data_blocks);
       
 10281 			
       
 10282 			return status;
       
 10283 		}
       
 10284 	
       
 10285 		automatic_new_data.do_not_free_variable();
       
 10286 	
       
 10287 		m_eap_fast_completion_status = m_ready_references_and_data_blocks.add_object(new_data, true);
       
 10288 		if (m_eap_fast_completion_status != eap_status_ok)
       
 10289 		{
       
 10290 			(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
       
 10291 			EAP_TRACE_DEBUG_SYMBIAN(
       
 10292 					(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
       
 10293 			m_ready_references_and_data_blocks.reset();
       
 10294 			
       
 10295 			status = m_tls_application->complete_read_PAC_store_data(
       
 10296 				m_eap_fast_completion_status,
       
 10297 				m_eap_fast_pac_store_pending_operation,
       
 10298 				&m_references_and_data_blocks);
       
 10299 			
       
 10300 			return status;
       
 10301 		}
       
 10302 		
       
 10303 		EAP_TRACE_DATA_DEBUG_SYMBIAN(
       
 10304 			("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL - added extra data",
       
 10305 			(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
       
 10306 			(new_data->get_data())->get_data_length()));										
       
 10307 	
       
 10308 		
       
 10309 		for (u32_t ind = m_ready_references_array_index; ind < m_references_and_data_blocks.get_object_count(); ++ind)
       
 10310 			{
       
 10311 			eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools);
       
 10312 	
       
 10313 			eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
 10776 			eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
 10314 				m_am_tools, new_data);
 10777 				m_am_tools, new_data);
 10315 	
 10778 		
 10316 			if (new_data == 0)
 10779 			if (new_data == 0)
 10317 			{
 10780 			{
 10318 				m_eap_fast_completion_status = eap_status_allocation_error;
 10781 				m_eap_fast_completion_status = eap_status_allocation_error;
 10319 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10782 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10320 				EAP_TRACE_DEBUG_SYMBIAN(
 10783 
 10321 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10784 				EAP_TRACE_DEBUG(
       
 10785 					m_am_tools,
       
 10786 					TRACE_FLAGS_DEFAULT,
       
 10787 					(EAPL("ERROR: eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL(): new_data allocation failed, status=%d=%s"),
       
 10788 					m_eap_fast_completion_status,
       
 10789 					eap_status_string_c::get_status_string(m_eap_fast_completion_status)));
       
 10790 
 10322 				m_ready_references_and_data_blocks.reset();
 10791 				m_ready_references_and_data_blocks.reset();
 10323 				
 10792 				
 10324 				status = m_tls_application->complete_read_PAC_store_data(
 10793 				status = m_tls_application->complete_read_PAC_store_data(
 10325 					m_eap_fast_completion_status,
 10794 					m_eap_fast_completion_status,
 10326 					m_eap_fast_pac_store_pending_operation,
 10795 					m_eap_fast_pac_store_pending_operation,
 10327 					&m_references_and_data_blocks);
 10796 					&m_references_and_data_blocks);
 10328 				
 10797 				
 10329 				return status;
 10798 				return EAP_STATUS_RETURN(m_am_tools, status);
 10330 			}
 10799 			}
 10331 	
 10800 
 10332 			new_data->set_type(m_references_and_data_blocks.get_object(ind)->get_type());
 10801 			automatic_new_data.do_not_free_variable();
 10333 			
 10802 		
 10334 			// Set the reference.
 10803 			m_eap_fast_completion_status = m_ready_references_and_data_blocks.add_object(new_data, true);
 10335 			m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(m_references_and_data_blocks.get_object(ind)->get_reference());
       
 10336 			if (m_eap_fast_completion_status != eap_status_ok)
 10804 			if (m_eap_fast_completion_status != eap_status_ok)
 10337 			{
 10805 			{
 10338 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10806 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10339 				EAP_TRACE_DEBUG_SYMBIAN(
 10807 
 10340 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10808 				EAP_TRACE_DEBUG(
       
 10809 					m_am_tools,
       
 10810 					TRACE_FLAGS_DEFAULT,
       
 10811 					(EAPL("ERROR: eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL(): add_object() failed, status=%d=%s"),
       
 10812 					m_eap_fast_completion_status,
       
 10813 					eap_status_string_c::get_status_string(m_eap_fast_completion_status)));
       
 10814 
 10341 				m_ready_references_and_data_blocks.reset();
 10815 				m_ready_references_and_data_blocks.reset();
 10342 				
 10816 				
 10343 				status = m_tls_application->complete_read_PAC_store_data(
 10817 				status = m_tls_application->complete_read_PAC_store_data(
 10344 					m_eap_fast_completion_status,
 10818 					m_eap_fast_completion_status,
 10345 					m_eap_fast_pac_store_pending_operation,
 10819 					m_eap_fast_pac_store_pending_operation,
 10346 					&m_references_and_data_blocks);
 10820 					&m_references_and_data_blocks);
 10347 				
 10821 				
 10348 				return status;
 10822 				return EAP_STATUS_RETURN(m_am_tools, status);
 10349 			}					
 10823 			}
 10350 	
 10824 			
 10351 			m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(m_references_and_data_blocks.get_object(ind)->get_data());
 10825 			EAP_TRACE_DATA_DEBUG(
 10352 			if (m_eap_fast_completion_status != eap_status_ok)
 10826 				m_am_tools,
 10353 			{
 10827 				TRACE_FLAGS_DEFAULT,
       
 10828 				(EAPL("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL(): added extra data"),
       
 10829 				(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
       
 10830 				(new_data->get_data())->get_data_length()));										
       
 10831 
       
 10832 		}
       
 10833 
       
 10834 		// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
 10835 		
       
 10836 		for (u32_t ind = m_ready_references_array_index; ind < m_references_and_data_blocks.get_object_count(); ++ind)
       
 10837 		{
       
 10838 			const eap_fast_pac_store_data_c * const original_data = m_references_and_data_blocks.get_object(ind);
       
 10839 			if (original_data == 0)
       
 10840 			{
       
 10841 				m_eap_fast_completion_status = eap_status_allocation_error;
       
 10842 
 10354 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10843 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10355 				EAP_TRACE_DEBUG_SYMBIAN(
 10844 	
 10356 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10845 				EAP_TRACE_DEBUG(
       
 10846 					m_am_tools,
       
 10847 					TRACE_FLAGS_DEFAULT,
       
 10848 					(EAPL("ERROR: eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL(): original_data is NULL.")));
       
 10849 
 10357 				m_ready_references_and_data_blocks.reset();
 10850 				m_ready_references_and_data_blocks.reset();
 10358 				
 10851 				
 10359 				status = m_tls_application->complete_read_PAC_store_data(
 10852 				status = m_tls_application->complete_read_PAC_store_data(
 10360 					m_eap_fast_completion_status,
 10853 					m_eap_fast_completion_status,
 10361 					m_eap_fast_pac_store_pending_operation,
 10854 					m_eap_fast_pac_store_pending_operation,
 10362 					&m_references_and_data_blocks);
 10855 					&m_references_and_data_blocks);
 10363 				
 10856 				
 10364 				return status;
 10857 				return EAP_STATUS_RETURN(m_am_tools, status);
 10365 			}
 10858 			}
 10366 	
 10859 
 10367 			automatic_new_data.do_not_free_variable();
 10860 			eap_fast_pac_store_data_c * const new_data = original_data->copy();
 10368 	
 10861 	
 10369 			m_eap_fast_completion_status = m_ready_references_and_data_blocks.add_object(new_data, true);
 10862 			eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
 10370 			if (m_eap_fast_completion_status != eap_status_ok)
 10863 				m_am_tools, new_data);
 10371 			{
 10864 	
       
 10865 			if (new_data == 0)
       
 10866 			{
       
 10867 				m_eap_fast_completion_status = eap_status_allocation_error;
       
 10868 
 10372 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10869 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10373 				EAP_TRACE_DEBUG_SYMBIAN(
 10870 
 10374 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10871 				EAP_TRACE_DEBUG(
       
 10872 					m_am_tools,
       
 10873 					TRACE_FLAGS_DEFAULT,
       
 10874 					(EAPL("ERROR: eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL(): new_data allocation failed")));
       
 10875 
 10375 				m_ready_references_and_data_blocks.reset();
 10876 				m_ready_references_and_data_blocks.reset();
 10376 				
 10877 				
 10377 				status = m_tls_application->complete_read_PAC_store_data(
 10878 				status = m_tls_application->complete_read_PAC_store_data(
 10378 					m_eap_fast_completion_status,
 10879 					m_eap_fast_completion_status,
 10379 					m_eap_fast_pac_store_pending_operation,
 10880 					m_eap_fast_pac_store_pending_operation,
 10380 					&m_references_and_data_blocks);
 10881 					&m_references_and_data_blocks);
 10381 				
 10882 				
 10382 				return status;
 10883 				return EAP_STATUS_RETURN(m_am_tools, status);
       
 10884 			}
       
 10885 	
       
 10886 			automatic_new_data.do_not_free_variable();
       
 10887 	
       
 10888 			m_eap_fast_completion_status = m_ready_references_and_data_blocks.add_object(new_data, true);
       
 10889 			if (m_eap_fast_completion_status != eap_status_ok)
       
 10890 			{
       
 10891 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
       
 10892 
       
 10893 				EAP_TRACE_DEBUG(
       
 10894 					m_am_tools,
       
 10895 					TRACE_FLAGS_DEFAULT,
       
 10896 					(EAPL("ERROR: eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL(): add_object() failed, status=%d=%s"),
       
 10897 					m_eap_fast_completion_status,
       
 10898 					eap_status_string_c::get_status_string(m_eap_fast_completion_status)));
       
 10899 
       
 10900 				m_ready_references_and_data_blocks.reset();
       
 10901 				
       
 10902 				status = m_tls_application->complete_read_PAC_store_data(
       
 10903 					m_eap_fast_completion_status,
       
 10904 					m_eap_fast_pac_store_pending_operation,
       
 10905 					&m_references_and_data_blocks);
       
 10906 				
       
 10907 				return EAP_STATUS_RETURN(m_am_tools, status);
 10383 			}
 10908 			}
 10384 			
 10909 			
 10385 			EAP_TRACE_DATA_DEBUG_SYMBIAN(
 10910 			EAP_TRACE_DATA_DEBUG(
 10386 				("Final_complete_read_PAC_store_data - added original data",
 10911 				m_am_tools,
       
 10912 				TRACE_FLAGS_DEFAULT,
       
 10913 				(EAPL("Final_complete_read_PAC_store_data - added original data"),
 10387 				(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
 10914 				(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
 10388 				(new_data->get_data())->get_data_length()));										
 10915 				(new_data->get_data())->get_data_length()));										
 10389 			}
 10916 
       
 10917 		} // for()
 10390 		
 10918 		
 10391 		if (status == eap_status_ok)
 10919 		if (status == eap_status_ok)
 10392 			{
 10920 		{
 10393 			EAP_TRACE_DEBUG(
 10921 			EAP_TRACE_DEBUG(
 10394 					m_am_tools,
 10922 				m_am_tools,
 10395 					TRACE_FLAGS_DEFAULT,
 10923 				TRACE_FLAGS_DEFAULT,
 10396 					(EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL: index=%d, original objects=%d, new=%d total=%d"),
 10924 				(EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL(): index=%d, original objects=%d, new=%d total=%d"),
 10397 							m_ready_references_array_index,
 10925 				m_ready_references_array_index,
 10398 							m_references_and_data_blocks.get_object_count(),
 10926 				m_references_and_data_blocks.get_object_count(),
 10399 							 m_new_references_and_data_blocks.get_object_count(),
 10927 				m_new_references_and_data_blocks.get_object_count(),
 10400 							 m_ready_references_and_data_blocks.get_object_count())); 
 10928 				m_ready_references_and_data_blocks.get_object_count())); 
       
 10929 
       
 10930 
       
 10931 			EAP_TRACE_DEBUG(
       
 10932 				m_am_tools,
       
 10933 				TRACE_FLAGS_DEFAULT,
       
 10934 				(EAPL("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL(): Reset unsent data")));
 10401 			
 10935 			
 10402 	
 10936 			m_references_and_data_blocks.reset();
 10403 			EAP_TRACE_DEBUG_SYMBIAN(
 10937 			m_new_references_and_data_blocks.reset();
 10404 					(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL Reset unsent data")));
 10938 
 10405 			
 10939 			EAP_TRACE_DEBUG(
 10406 		m_references_and_data_blocks.reset();
 10940 				m_am_tools,
 10407 		m_new_references_and_data_blocks.reset();
 10941 				TRACE_FLAGS_DEFAULT,
 10408 
 10942 				(EAPL("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL(): Reset Done")));
 10409 		EAP_TRACE_DEBUG_SYMBIAN(
 10943 
 10410 				(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL Reset Done")));
 10944 			status = m_tls_application->complete_read_PAC_store_data(
 10411 		
 10945 				m_eap_fast_completion_status,
 10412 		status = m_tls_application->complete_read_PAC_store_data(
 10946 				m_eap_fast_pac_store_pending_operation,
 10413 			m_eap_fast_completion_status,
 10947 				&m_ready_references_and_data_blocks);
 10414 			m_eap_fast_pac_store_pending_operation,
 10948 		}
 10415 			&m_ready_references_and_data_blocks);
 10949 		else
 10416 		}
 10950 		{
       
 10951 			EAP_TRACE_DEBUG(
       
 10952 				m_am_tools,
       
 10953 				TRACE_FLAGS_DEFAULT,
       
 10954 				(EAPL("ERROR: eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL(): status=%d=%s"),
       
 10955 				status,
       
 10956 				eap_status_string_c::get_status_string(status)));
       
 10957 
       
 10958 			m_eap_fast_completion_status = eap_status_user_cancel_authentication;
       
 10959 			m_new_references_and_data_blocks.reset();
       
 10960 			m_ready_references_and_data_blocks.reset();
       
 10961 
       
 10962 			status = m_tls_application->complete_read_PAC_store_data(
       
 10963 				m_eap_fast_completion_status,
       
 10964 				m_eap_fast_pac_store_pending_operation,
       
 10965 				&m_references_and_data_blocks);
       
 10966 		}
       
 10967 	}
 10417 	else
 10968 	else
 10418 		{
 10969 	{
 10419 		EAP_TRACE_DEBUG_SYMBIAN(
 10970 		EAP_TRACE_DEBUG(
 10420 				(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10971 			m_am_tools,
       
 10972 			TRACE_FLAGS_DEFAULT,
       
 10973 			(EAPL("ERROR: eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL(): status=%d=%s, m_new_references_and_data_blocks.get_object_count()=%d"),
       
 10974 			status,
       
 10975 			eap_status_string_c::get_status_string(status),
       
 10976 			m_new_references_and_data_blocks.get_object_count()));
       
 10977 
 10421 		m_eap_fast_completion_status = eap_status_user_cancel_authentication;
 10978 		m_eap_fast_completion_status = eap_status_user_cancel_authentication;
 10422 		m_new_references_and_data_blocks.reset();
 10979 		m_new_references_and_data_blocks.reset();
 10423 		m_ready_references_and_data_blocks.reset();
 10980 		m_ready_references_and_data_blocks.reset();
 10424 		
 10981 		
 10425 		status = m_tls_application->complete_read_PAC_store_data(
 10982 		status = m_tls_application->complete_read_PAC_store_data(
 10426 			m_eap_fast_completion_status,
 10983 			m_eap_fast_completion_status,
 10427 			m_eap_fast_pac_store_pending_operation,
 10984 			m_eap_fast_pac_store_pending_operation,
 10428 			&m_references_and_data_blocks);
 10985 			&m_references_and_data_blocks);
 10429 		}
 10986 	}
 10430 		}
 10987 	
 10431 	else
 10988 	TRAPD(error, iPacStoreDb->UpdatePasswordTimeL());
 10432 	{
       
 10433 	EAP_TRACE_DEBUG_SYMBIAN(
       
 10434 			(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
       
 10435 	m_eap_fast_completion_status = eap_status_user_cancel_authentication;
       
 10436 	m_new_references_and_data_blocks.reset();
       
 10437 	m_ready_references_and_data_blocks.reset();
       
 10438 	
       
 10439 	status = m_tls_application->complete_read_PAC_store_data(
       
 10440 		m_eap_fast_completion_status,
       
 10441 		m_eap_fast_pac_store_pending_operation,
       
 10442 		&m_references_and_data_blocks);
       
 10443 	}
       
 10444 	
       
 10445 	TRAPD(error, UpdatePasswordTimeL());
       
 10446 
 10989 
 10447 	if(error != KErrNone)
 10990 	if(error != KErrNone)
 10448 	{
 10991 	{
 10449 		EAP_TRACE_DEBUG(
 10992 		EAP_TRACE_DEBUG(
 10450 			m_am_tools,
 10993 			m_am_tools,
 10451 			TRACE_FLAGS_DEFAULT,
 10994 			TRACE_FLAGS_DEFAULT,
 10452 			(EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL ERROR: LEAVE from UpdatePasswordTimeL() error=%d"),
 10995 			(EAPL("ERROR: EAP-FAST: eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL(): LEAVE from UpdatePasswordTimeL() error=%d"),
 10453 			error));
 10996 			error));
 10454 	}
 10997 
 10455 	return status;
 10998 		status = m_am_tools->convert_am_error_to_eapol_error(error);
       
 10999 	}
       
 11000 
       
 11001 	return EAP_STATUS_RETURN(m_am_tools, status);
 10456 }
 11002 }
 10457 
 11003 
 10458 //--------------------------------------------------
 11004 //--------------------------------------------------
 10459 
 11005 
 10460 eap_status_e eap_am_type_tls_peap_symbian_c::CompleteFilePasswordQueryL()
 11006 eap_status_e eap_am_type_tls_peap_symbian_c::CompleteFilePasswordQueryL()
 10461 {
 11007 {
       
 11008 	EAP_TRACE_DEBUG(
       
 11009 		m_am_tools,
       
 11010 		TRACE_FLAGS_DEFAULT,
       
 11011 		(EAPL("eap_am_type_tls_peap_symbian_c::CompleteFilePasswordQueryL()")));
       
 11012 
 10462 	eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools);
 11013 	eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools);
 10463 
 11014 
 10464 	eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
 11015 	eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
 10465 		m_am_tools, new_data);
 11016 		m_am_tools, new_data);
 10466 
 11017 
 10510 	{
 11061 	{
 10511 		(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 11062 		(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10512 		return m_eap_fast_completion_status;
 11063 		return m_eap_fast_completion_status;
 10513 	}
 11064 	}
 10514 	
 11065 	
 10515 	EAP_TRACE_DATA_DEBUG_SYMBIAN(
 11066 	EAP_TRACE_DATA_DEBUG(
 10516 		("EAP-FAST: eap_am_type_tls_peap_symbian_c::CompleteFilePasswordQueryL eap_pac_store_data_type_PAC_file_password - added data",
 11067 		m_am_tools,
       
 11068 		TRACE_FLAGS_DEFAULT,
       
 11069 		(EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::CompleteFilePasswordQueryL eap_pac_store_data_type_PAC_file_password - added data"),
 10517 		(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
 11070 		(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
 10518 		(new_data->get_data())->get_data_length()));
 11071 		(new_data->get_data())->get_data_length()));
 10519 	
 11072 	
 10520 	m_both_completed++;
 11073 	m_both_completed++;
 10521 	return m_eap_fast_completion_status;
 11074 	return m_eap_fast_completion_status;
 10524 
 11077 
 10525 //--------------------------------------------------
 11078 //--------------------------------------------------
 10526 
 11079 
 10527 void eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL(const TDesC16& aFromUnicode, TDes8& aToAscii)
 11080 void eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL(const TDesC16& aFromUnicode, TDes8& aToAscii)
 10528 {
 11081 {
 10529 	EAP_TRACE_DATA_DEBUG_SYMBIAN(
 11082 	EAP_TRACE_DATA_DEBUG(
 10530 		("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL:From TEXT",
 11083 		m_am_tools,
       
 11084 		TRACE_FLAGS_DEFAULT,
       
 11085 		(EAPL("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL(): From TEXT"),
 10531 		aFromUnicode.Ptr(), 
 11086 		aFromUnicode.Ptr(), 
 10532 		aFromUnicode.Size()));	
 11087 		aFromUnicode.Size()));	
 10533 	
 11088 	
 10534 	if(aFromUnicode.Length() <= 0)
 11089 	if(aFromUnicode.Length() <= 0)
 10535 	{
 11090 	{
 10536 		EAP_TRACE_DEBUG_SYMBIAN(
 11091 		EAP_TRACE_DEBUG(
 10537 		(_L("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL: Return: NOTHING TO CONVERT")));
 11092 			m_am_tools,
       
 11093 			TRACE_FLAGS_DEFAULT,
       
 11094 			(EAPL("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL: Return: NOTHING TO CONVERT")));
 10538 		
 11095 		
 10539 		return;
 11096 		return;
 10540 	}	
 11097 	}	
 10541 	
 11098 	
 10542 	EAP_TRACE_DEBUG_SYMBIAN(
 11099 	EAP_TRACE_DEBUG(
 10543 		(_L("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL, aFromUnicode.Length=%d, aFromUnicode.Size=%d"),
 11100 		m_am_tools,
       
 11101 		TRACE_FLAGS_DEFAULT,
       
 11102 		(EAPL("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL, aFromUnicode.Length=%d, aFromUnicode.Size=%d"),
 10544 		aFromUnicode.Length(), aFromUnicode.Size()));	
 11103 		aFromUnicode.Length(), aFromUnicode.Size()));	
 10545 	
 11104 	
 10546 	// Convert from Unicode to ascii.
 11105 	// Convert from Unicode to ascii.
 10547 	HBufC8* aFromUnicodeBuf8 = HBufC8::NewLC(aFromUnicode.Length()); // Half times size of source (or length) is enough here.
 11106 	HBufC8* aFromUnicodeBuf8 = HBufC8::NewLC(aFromUnicode.Length()); // Half times size of source (or length) is enough here.
 10548 	TPtr8 aFromUnicodePtr8 = aFromUnicodeBuf8->Des();
 11107 	TPtr8 aFromUnicodePtr8 = aFromUnicodeBuf8->Des();
 10549 	
 11108 	
 10550 	EAP_TRACE_DEBUG_SYMBIAN(
 11109 	EAP_TRACE_DEBUG(
 10551 		(_L("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL, aFromUnicodePtr8.Length=%d, aFromUnicodePtr8.Size=%d, aFromUnicodePtr8.MaxLength=%d, aFromUnicodePtr8.MaxSize=%d"),
 11110 		m_am_tools,
 10552 		aFromUnicodePtr8.Length(), aFromUnicodePtr8.Size(), aFromUnicodePtr8.MaxLength(), aFromUnicodePtr8.MaxSize()));				
 11111 		TRACE_FLAGS_DEFAULT,
 10553 	
 11112 		(EAPL("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL, aFromUnicodePtr8.Length=%d, aFromUnicodePtr8.Size=%d, aFromUnicodePtr8.MaxLength=%d, aFromUnicodePtr8.MaxSize=%d"),
       
 11113 		aFromUnicodePtr8.Length(),
       
 11114 		aFromUnicodePtr8.Size(),
       
 11115 		aFromUnicodePtr8.MaxLength(),
       
 11116 		aFromUnicodePtr8.MaxSize()));
       
 11117 
 10554 	aFromUnicodePtr8.Copy(aFromUnicode); // Unicode -> ascii.
 11118 	aFromUnicodePtr8.Copy(aFromUnicode); // Unicode -> ascii.
 10555 	
 11119 	
 10556 	aToAscii = aFromUnicodePtr8;	
 11120 	aToAscii = aFromUnicodePtr8;	
 10557 
 11121 
 10558 	CleanupStack::PopAndDestroy(aFromUnicodeBuf8); // Delete aFromUnicodeBuf8.	
 11122 	CleanupStack::PopAndDestroy(aFromUnicodeBuf8); // Delete aFromUnicodeBuf8.	
 10559 
 11123 
 10560 	EAP_TRACE_DATA_DEBUG_SYMBIAN(
 11124 	EAP_TRACE_DATA_DEBUG(
 10561 		("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL:To ASCII",
 11125 		m_am_tools,
       
 11126 		TRACE_FLAGS_DEFAULT,
       
 11127 		(EAPL("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL:To ASCII"),
 10562 		aToAscii.Ptr(), 
 11128 		aToAscii.Ptr(), 
 10563 		aToAscii.Size()));	
 11129 		aToAscii.Size()));
 10564 }
 11130 }
 10565 
 11131 
 10566 
       
 10567 // ---------------------------------------------------------
       
 10568 // eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL()
       
 10569 // ---------------------------------------------------------
       
 10570 //
       
 10571 void eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL()
       
 10572 {
       
 10573 	/* Check validity of password against timelimit */
       
 10574 	
       
 10575 	EAP_TRACE_DEBUG(m_am_tools, 
       
 10576 			TRACE_FLAGS_DEFAULT, (
       
 10577 			EAPL("CheckPasswordTimeValidityL - Start\n")));
       
 10578 
       
 10579 	TInt64 maxSessionTime = 0;
       
 10580 	TInt64 fullAuthTime = 0;
       
 10581 	
       
 10582     // get max session time
       
 10583 	HBufC* buf = HBufC::NewLC( KMaxSqlQueryLength );
       
 10584 	TPtr sqlStatement = buf->Des();	
       
 10585 
       
 10586 	_LIT( KSqlQuery, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d" );
       
 10587 
       
 10588 	sqlStatement.Format(
       
 10589 		KSqlQuery,
       
 10590 		&cf_str_EAP_FAST_max_session_validity_time_literal,
       
 10591 		&KFastGeneralSettingsDBTableName,
       
 10592 		&KServiceType,
       
 10593 		m_index_type, 
       
 10594 		&KServiceIndex,
       
 10595 		m_index,
       
 10596 		&KTunnelingTypeVendorId,
       
 10597 		m_tunneling_type.get_vendor_id(),
       
 10598 		&KTunnelingType, 
       
 10599 		m_tunneling_type.get_vendor_type());
       
 10600 
       
 10601 	TRAPD( err,  maxSessionTime =  ReadIntDbValueL(
       
 10602 		m_database,
       
 10603 		cf_str_EAP_FAST_max_session_validity_time_literal,
       
 10604 		sqlStatement ) );
       
 10605 	if ( err != KErrNone )
       
 10606 		{
       
 10607 		EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT,
       
 10608 			( EAPL( "ERROR: Leave happened trying to read max session time,  \
       
 10609 			error=%d.\n" ), err ) );
       
 10610 		}
       
 10611 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (
       
 10612 		EAPL("CheckPasswordTimeValidityL - maxSessionTime=%ld\n"),
       
 10613 		maxSessionTime ) );	
       
 10614 	
       
 10615 #ifdef USE_PAC_STORE
       
 10616     sqlStatement.Zero();
       
 10617 	if ( !iPacStoreDb )
       
 10618 		{
       
 10619 		EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (
       
 10620 			EAPL("CheckPasswordTimeValidityL - iPacStoreDb is NULL.\n")));
       
 10621 		CleanupStack::PopAndDestroy( buf ); // Delete buf.
       
 10622 		User::Leave( KErrArgument );
       
 10623 		}
       
 10624 	_LIT( KSqlQuery1, "SELECT %S FROM %S" );
       
 10625 	sqlStatement.Format(
       
 10626 		KSqlQuery1,
       
 10627 		&KFASTLastPasswordIdentityTime,
       
 10628 		&KPacStoreGeneralSettingsTableName );	
       
 10629 	RDbNamedDatabase& db = iPacStoreDb->GetPacStoreDb();
       
 10630 	TRAP( err, fullAuthTime = ReadIntDbValueL(
       
 10631 		db,
       
 10632 		KFASTLastPasswordIdentityTime,
       
 10633 		sqlStatement ) );
       
 10634 	if ( err == KErrNotFound ) // KFASTLastPasswordIdentityTime was not found
       
 10635 		{
       
 10636 		TRAP( err, FixOldTablesForPwdIdentityTimeL() );
       
 10637 		if ( err != KErrNone  )
       
 10638 			{
       
 10639 		    EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
       
 10640 		    	"ERROR: eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL() \
       
 10641 		        Leave happened trying to fix old table for pwd \
       
 10642 			    identity time, error=%d.\n" ), err ) );
       
 10643 		    User::Leave( err );
       
 10644 			}
       
 10645 		TRAP( err, fullAuthTime = ReadIntDbValueL(
       
 10646 			db,
       
 10647 			KFASTLastPasswordIdentityTime,
       
 10648 			sqlStatement ) );
       
 10649  		if ( err != KErrNone )
       
 10650 			{
       
 10651 			EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
       
 10652 				"ERROR: eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL() \
       
 10653 				Leave happened trying to read full auth. time, \
       
 10654 			    error=%d.\n" ), err ) );		
       
 10655 		    User::Leave( err );
       
 10656 			}
       
 10657 		}
       
 10658 	else if ( err != KErrNone )
       
 10659 		{
       
 10660 		EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
       
 10661 			"ERROR: eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL() \
       
 10662 			Leave happened trying to read full auth. time,  \
       
 10663 			error=%d.\n" ), err ) );
       
 10664 		User::Leave( err );
       
 10665 		}
       
 10666 #else
       
 10667 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (
       
 10668 		EAPL("CheckPasswordTimeValidityL - PAC store is not used.\n")));
       
 10669 	CleanupStack::PopAndDestroy( buf ); // Delete buf.
       
 10670 	User::Leave( KErrNotSupported );
       
 10671 #endif
       
 10672 	
       
 10673 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT,
       
 10674 		( EAPL( "CheckPasswordTimeValidityL - fullAuthTime=%ld.\n" ),
       
 10675 	    fullAuthTime ) );		
       
 10676 
       
 10677 	CleanupStack::PopAndDestroy( buf ); // Delete buf.
       
 10678 		
       
 10679 	// If the max session time from DB is zero then we use the 
       
 10680 	// one read from configuration file.	
       
 10681 	if( maxSessionTime == 0)
       
 10682 		{
       
 10683 			EAP_TRACE_DEBUG(m_am_tools, 
       
 10684 				TRACE_FLAGS_DEFAULT, (
       
 10685 				EAPL("CheckPasswordTimeValidityL - Using max session validity time from config file\n")));
       
 10686 		
       
 10687 			maxSessionTime = m_max_session_time; // value from configuration file.
       
 10688 		}
       
 10689 	
       
 10690 	// Get the current time.
       
 10691 	EAP_TRACE_DEBUG(m_am_tools, 
       
 10692 			TRACE_FLAGS_DEFAULT, (
       
 10693 			EAPL("UpdatePasswordTimeL - Get time\n")));
       
 10694 
       
 10695 	TTime currentTime;
       
 10696 	currentTime.UniversalTime();
       
 10697 	
       
 10698 	TTime lastFullAuthTime(fullAuthTime);
       
 10699 	
       
 10700 	#if defined(_DEBUG) || defined(DEBUG)	
       
 10701 	
       
 10702 	TDateTime currentDateTime = currentTime.DateTime();
       
 10703 		
       
 10704 	TDateTime fullAuthDateTime = lastFullAuthTime.DateTime();
       
 10705 	
       
 10706 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT,
       
 10707 	(EAPL("CheckPasswordTimeValidityL Session Validity - Current Time,        %2d-%2d-%4d : %2d-%2d-%2d-%d\n"), 
       
 10708 	currentDateTime.Day()+1, currentDateTime.Month()+1, currentDateTime.Year(), currentDateTime.Hour(),
       
 10709 	currentDateTime.Minute(), currentDateTime.Second(), currentDateTime.MicroSecond()));
       
 10710 	
       
 10711 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT,
       
 10712 	(EAPL("CheckPasswordTimeValidityL Session Validity - Last Full Auth Time, %2d-%2d-%4d : %2d-%2d-%2d-%d\n"), 
       
 10713 	fullAuthDateTime.Day()+1, fullAuthDateTime.Month()+1, fullAuthDateTime.Year(), fullAuthDateTime.Hour(),
       
 10714 	fullAuthDateTime.Minute(), fullAuthDateTime.Second(), fullAuthDateTime.MicroSecond()));
       
 10715 	
       
 10716 	#endif
       
 10717 	
       
 10718 	TTimeIntervalMicroSeconds interval = currentTime.MicroSecondsFrom(lastFullAuthTime);
       
 10719 		
       
 10720 	EAP_TRACE_DATA_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT,(EAPL("eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL:interval in microseconds:"),
       
 10721 			&(interval.Int64()),
       
 10722 			sizeof(interval.Int64()) ) );
       
 10723 			
       
 10724 	EAP_TRACE_DATA_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT,(EAPL("eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL:max session time in microseconds:"),
       
 10725 			&(maxSessionTime),
       
 10726 			sizeof(maxSessionTime) ) );
       
 10727 	
       
 10728 	#if defined(_DEBUG) || defined(DEBUG)
       
 10729 	
       
 10730 	TTimeIntervalMinutes intervalMins;
       
 10731 	TInt error = currentTime.MinutesFrom(lastFullAuthTime, intervalMins);
       
 10732 	
       
 10733 	if(error == KErrNone)
       
 10734 		{
       
 10735 		EAP_TRACE_DEBUG(
       
 10736 			m_am_tools,
       
 10737 			TRACE_FLAGS_DEFAULT,
       
 10738 			(EAPL("eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL")
       
 10739 			 EAPL("interval in Minutes =%d\n"),
       
 10740 			 intervalMins.Int()));
       
 10741 		}
       
 10742 	
       
 10743 	#endif
       
 10744 	
       
 10745 	if( maxSessionTime >= interval.Int64() )
       
 10746 		{
       
 10747 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL - Session Valid \n")));
       
 10748 	
       
 10749 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);			
       
 10750 	
       
 10751 		/* do nothing */	
       
 10752 		}
       
 10753 	else
       
 10754 		{
       
 10755 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL - Session NOT Valid \n")));
       
 10756 	
       
 10757 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);			
       
 10758 		
       
 10759 		m_tls_application->remove_cached_pac_store_data();
       
 10760 		
       
 10761 		TRAPD(error, UpdatePasswordTimeL());
       
 10762 
       
 10763 		if(error != KErrNone)
       
 10764 			{
       
 10765 			EAP_TRACE_DEBUG(
       
 10766 				m_am_tools,
       
 10767 				TRACE_FLAGS_DEFAULT,
       
 10768 				(EAPL("EAP-FAST: eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL() ERROR: LEAVE from UpdatePasswordTimeL() error=%d"),
       
 10769 				error));
       
 10770 		
       
 10771 			}
       
 10772 		}
       
 10773 	
       
 10774 } // eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL()
       
 10775 
       
 10776 
       
 10777 // ---------------------------------------------------------
       
 10778 // eap_am_type_tls_peap_symbian_c::AlterTableL()
       
 10779 // ---------------------------------------------------------
       
 10780 //
       
 10781 void eap_am_type_tls_peap_symbian_c::AlterTableL(
       
 10782 	RDbNamedDatabase& aDb,
       
 10783 	TAlterTableCmd aCmd,
       
 10784 	const TDesC& aTableName,
       
 10785 	const TDesC& aColumnName,
       
 10786 	const TDesC& aColumnDef )
       
 10787 {
       
 10788 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
       
 10789 		"eap_am_type_tls_peap_symbian_c::AlterTableL() IN\n" ) ) );
       
 10790 	
       
 10791 	CDbColSet* colSet = aDb.ColSetL( aTableName );
       
 10792 	User::LeaveIfNull( colSet );
       
 10793 	CleanupStack::PushL( colSet );	
       
 10794 		
       
 10795 	EAP_TRACE_DEBUG_SYMBIAN( ( _L(
       
 10796         "eap_am_type_tls_peap_symbian_c::AlterTableL() \
       
 10797         Number of columns in %S table is %d.\n" ),
       
 10798 		&aTableName, colSet->Count() ) );
       
 10799 	
       
 10800     if ( aCmd == EAddColumn )
       
 10801     	{
       
 10802     	// Check if there is a target column
       
 10803     	if( colSet->ColNo( aColumnName ) != KDbNullColNo )
       
 10804     		{
       
 10805     		EAP_TRACE_DEBUG_SYMBIAN( ( _L(
       
 10806    		        "eap_am_type_tls_peap_symbian_c::AlterTableL() \
       
 10807    		        Column %S exists already in table %S.\n" ),
       
 10808     			&aColumnName, &aTableName ) );
       
 10809     		CleanupStack::PopAndDestroy( colSet );
       
 10810     		return;
       
 10811     		}
       
 10812     	}
       
 10813     else
       
 10814     	{
       
 10815     	// Check if there is a target column
       
 10816     	if( colSet->ColNo( aColumnName ) == KDbNullColNo )
       
 10817     		{
       
 10818     		EAP_TRACE_DEBUG_SYMBIAN( ( _L(
       
 10819    		        "eap_am_type_tls_peap_symbian_c::AlterTableL() \
       
 10820    		        Column %S does not exists already in table %S.\n" ),
       
 10821     			&aColumnName, &aTableName ) );
       
 10822     		CleanupStack::PopAndDestroy( colSet );
       
 10823     		return;
       
 10824     		}
       
 10825     	}
       
 10826 
       
 10827 	HBufC* buf = HBufC::NewLC( KMaxSqlQueryLength );
       
 10828 	TPtr sqlStatement = buf->Des();
       
 10829 		
       
 10830 	_LIT( KSqlAddCol, "ALTER TABLE %S ADD %S %S" );
       
 10831 	_LIT( KSqlRemoveCol, "ALTER TABLE %S DROP %S" );
       
 10832 	
       
 10833 	if ( aCmd == EAddColumn )
       
 10834 		{
       
 10835 		sqlStatement.Format( KSqlAddCol, &aTableName, 
       
 10836 		    &aColumnName, &aColumnDef );
       
 10837 		}
       
 10838 	else
       
 10839 		{
       
 10840 		sqlStatement.Format( KSqlRemoveCol, &aTableName, 
       
 10841 	        &aColumnName );
       
 10842 		}
       
 10843 		
       
 10844 	EAP_TRACE_DEBUG_SYMBIAN( ( _L(
       
 10845 		"eap_am_type_tls_peap_symbian_c::AlterTableL(): sqlStatement=%S\n"),
       
 10846 		&sqlStatement ) );
       
 10847 	
       
 10848 	User::LeaveIfError( aDb.Execute( sqlStatement ) );		
       
 10849 	CleanupStack::PopAndDestroy( buf );
       
 10850 	CleanupStack::PopAndDestroy( colSet );
       
 10851 
       
 10852 	CDbColSet* alteredColSet = aDb.ColSetL( aTableName );
       
 10853 	User::LeaveIfNull( alteredColSet );
       
 10854 	EAP_TRACE_DEBUG_SYMBIAN( ( _L(
       
 10855         "eap_am_type_tls_peap_symbian_c::AlterTableL() \
       
 10856         Number of columns in %S table is %d.\n" ),
       
 10857 		&aTableName, alteredColSet->Count() ) );
       
 10858 	delete alteredColSet;
       
 10859 		
       
 10860 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
       
 10861 	    "eap_am_type_tls_peap_symbian_c::AlterTableL() OUT\n" ) ) );
       
 10862 
       
 10863 } // eap_am_type_tls_peap_symbian_c::AlterTableL()
       
 10864 
       
 10865 
       
 10866 // ---------------------------------------------------------
       
 10867 // eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL()
       
 10868 // ---------------------------------------------------------
       
 10869 //
       
 10870 void eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL()
       
 10871 {
       
 10872 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
       
 10873 	    "eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL() IN" ) ) );	
       
 10874 	
       
 10875 	// remove password identity time from fast table	
       
 10876 	_LIT( KColumnDef, "BIGINT" );
       
 10877 	AlterTableL( m_database, ERemoveColumn, KFastGeneralSettingsDBTableName,
       
 10878 		KFASTLastPasswordIdentityTime );
       
 10879 	
       
 10880 	// add password identity time to PAC store table
       
 10881 #ifdef USE_PAC_STORE
       
 10882 	if ( !iPacStoreDb )
       
 10883 		{
       
 10884 		EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
       
 10885 			"ERROR: eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL() \
       
 10886 			iPacStoreDb is NULL.\n" ) ) );
       
 10887 		User::Leave( KErrArgument );
       
 10888 		}
       
 10889 	RDbNamedDatabase& pacStoreDb = iPacStoreDb->GetPacStoreDb();
       
 10890 	AlterTableL( pacStoreDb, EAddColumn , KPacStoreGeneralSettingsTableName,
       
 10891 		KFASTLastPasswordIdentityTime, KColumnDef );
       
 10892 #else
       
 10893 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (	EAPL(
       
 10894 		"ERROR: eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL() \
       
 10895 		PAC store is not used.\n" ) ) );
       
 10896 		User::Leave( KErrNotSupported );
       
 10897 #endif
       
 10898 		
       
 10899 	// update password identity time
       
 10900 	UpdatePasswordTimeL();
       
 10901 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
       
 10902 	    "eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL() OUT" ) ) );
       
 10903 	
       
 10904 } // eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL()
       
 10905 
       
 10906 
       
 10907 // ---------------------------------------------------------
       
 10908 // eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL()
       
 10909 // ---------------------------------------------------------
       
 10910 //
       
 10911 void eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL()
       
 10912 {
       
 10913 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
       
 10914 		"eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL() IN\n" ) ) );
       
 10915 	
       
 10916 #ifdef USE_PAC_STORE
       
 10917 	
       
 10918 	if ( !iPacStoreDb )
       
 10919 		{
       
 10920 		EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
       
 10921 			"ERROR: eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL() \
       
 10922 			iPacStoreDb is NULL.\n" ) ) );
       
 10923 		User::Leave( KErrArgument );
       
 10924 		}
       
 10925 	RDbNamedDatabase& pacStoreDb = iPacStoreDb->GetPacStoreDb();
       
 10926 	_LIT( KColumnDef, "UNSIGNED INTEGER" );
       
 10927 	AlterTableL( pacStoreDb, EAddColumn, KPacStoreGeneralSettingsTableName,
       
 10928         KPacStoreInitialized, KColumnDef );
       
 10929 
       
 10930 #else
       
 10931 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (	EAPL(
       
 10932 		"ERROR: eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL() \
       
 10933 		PAC store is not used.\n" ) ) );
       
 10934 	User::Leave( KErrNotSupported );
       
 10935 #endif
       
 10936 		
       
 10937 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
       
 10938 	    "eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL() OUT\n" ) ) );
       
 10939 
       
 10940 } // eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL()
       
 10941 
       
 10942 
       
 10943 // ---------------------------------------------------------
       
 10944 // eap_am_type_tls_peap_symbian_c::ReadIntDbValue()
       
 10945 // ---------------------------------------------------------
       
 10946 //
       
 10947 TInt64 eap_am_type_tls_peap_symbian_c::ReadIntDbValueL(
       
 10948 	RDbNamedDatabase& aDb,
       
 10949 	const TDesC& aColumnName,
       
 10950 	const TDesC& aSqlStatement )
       
 10951 {
       
 10952 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (
       
 10953 			EAPL( "eap_am_type_tls_peap_symbian_c::ReadIntDbValueL()\n" ) ) );
       
 10954     TPtrC columnName;    
       
 10955 	columnName.Set( aColumnName );
       
 10956 	
       
 10957 	RDbView view;
       
 10958 	// Evaluate view
       
 10959 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (
       
 10960 		EAPL( "ReadIntDbValue() prepare view\n" ) ) );
       
 10961 	User::LeaveIfError( view.Prepare( aDb, TDbQuery(
       
 10962 		aSqlStatement ) ) );
       
 10963 	CleanupClosePushL( view );
       
 10964 	
       
 10965 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (
       
 10966 		EAPL("ReadIntDbValue() evaluate view\n" ) ) );
       
 10967 	User::LeaveIfError( view.EvaluateAll() );		
       
 10968 	// Get the first (and only) row
       
 10969 	view.FirstL();
       
 10970 	view.GetL();
       
 10971 	// Get column set so we get the correct column numbers
       
 10972 	CDbColSet* colSet = view.ColSetL();
       
 10973 	CleanupStack::PushL( colSet );
       
 10974 	TInt64 retVal = view.ColInt64( colSet->ColNo( columnName ) );
       
 10975 
       
 10976 	CleanupStack::PopAndDestroy( colSet ); // Delete colSet.
       
 10977 	CleanupStack::PopAndDestroy( &view ); // Close view.
       
 10978 
       
 10979 	return retVal;
       
 10980 } // eap_am_type_tls_peap_symbian_c::ReadIntDbValueL
       
 10981 
       
 10982 
       
 10983 // ---------------------------------------------------------
       
 10984 // eap_am_type_tls_peap_symbian_c::UpdatePasswordTimeL()
       
 10985 // ---------------------------------------------------------
       
 10986 //
       
 10987 void eap_am_type_tls_peap_symbian_c::UpdatePasswordTimeL()
       
 10988 {
       
 10989 	/* update last password time */
       
 10990 	TPtrC lastFullPasswordTimeString;
       
 10991 	
       
 10992 	EAP_TRACE_DEBUG(m_am_tools, 
       
 10993 			TRACE_FLAGS_DEFAULT, (
       
 10994 			EAPL("UpdatePasswordTimeL - Start\n")));
       
 10995 
       
 10996 	lastFullPasswordTimeString.Set(KFASTLastPasswordIdentityTime);
       
 10997 	
       
 10998 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
       
 10999 	TPtr sqlStatement = buf->Des();
       
 11000 	
       
 11001 	EAP_TRACE_DEBUG(m_am_tools, 
       
 11002 			TRACE_FLAGS_DEFAULT, (
       
 11003 			EAPL("UpdatePasswordTimeL - prepare query\n")));
       
 11004 	// Query all the relevant parameters
       
 11005 	_LIT(KSQLQuery, "SELECT %S FROM %S");
       
 11006 	sqlStatement.Format( KSQLQuery, &lastFullPasswordTimeString,
       
 11007         &KPacStoreGeneralSettingsTableName );
       
 11008 
       
 11009 	RDbView view;
       
 11010 	// Evaluate view
       
 11011 	EAP_TRACE_DEBUG(m_am_tools, 
       
 11012 			TRACE_FLAGS_DEFAULT, (
       
 11013 			EAPL("UpdatePasswordTimeL - prepare view\n")));
       
 11014 
       
 11015 #ifdef USE_PAC_STORE
       
 11016 	if ( !iPacStoreDb )
       
 11017 		{
       
 11018 		EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (
       
 11019 			EAPL("CheckPasswordTimeValidityL - iPacStoreDb is NULL.\n")));
       
 11020 		CleanupStack::PopAndDestroy( buf ); // Delete buf.
       
 11021 		User::Leave( KErrArgument );
       
 11022 		}
       
 11023 	RDbNamedDatabase& db = iPacStoreDb->GetPacStoreDb();
       
 11024 	User::LeaveIfError( view.Prepare( db, TDbQuery( sqlStatement ),
       
 11025 		TDbWindow::EUnlimited ) );
       
 11026 	CleanupClosePushL( view );
       
 11027 #else
       
 11028 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (
       
 11029 		EAPL("CheckPasswordTimeValidityL - PAC store is not used.\n")));
       
 11030 	CleanupStack::PopAndDestroy( buf ); // Delete buf.
       
 11031 	User::Leave( KErrNotSupported );
       
 11032 #endif
       
 11033 	
       
 11034 	EAP_TRACE_DEBUG(m_am_tools, 
       
 11035 			TRACE_FLAGS_DEFAULT, (
       
 11036 			EAPL("UpdatePasswordTimeL - evaluate view\n")));
       
 11037 	User::LeaveIfError(view.EvaluateAll());
       
 11038 	
       
 11039 	// Get the first (and only) row.
       
 11040 	view.FirstL();
       
 11041 	view.UpdateL();
       
 11042 	
       
 11043 	// Get column set so we get the correct column numbers
       
 11044 	CDbColSet* colSet = view.ColSetL();
       
 11045 	CleanupStack::PushL(colSet);
       
 11046 	
       
 11047 	// Get the current universal time.
       
 11048 	EAP_TRACE_DEBUG(m_am_tools, 
       
 11049 			TRACE_FLAGS_DEFAULT, (
       
 11050 			EAPL("UpdatePasswordTimeL - Get time\n")));
       
 11051 	TTime currentTime;
       
 11052 	currentTime.UniversalTime();
       
 11053 		
       
 11054 	
       
 11055 	TDateTime currentDateTime = currentTime.DateTime();
       
 11056 	
       
 11057 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT,
       
 11058 	(EAPL("eap_am_type_tls_peap_symbian_c::UpdatePasswordTimeL:store_authentication_time, %2d-%2d-%4d : %2d-%2d-%2d-%d\n"), 
       
 11059 	currentDateTime.Day()+1, currentDateTime.Month()+1,currentDateTime.Year(), currentDateTime.Hour(),
       
 11060 	currentDateTime.Minute(), currentDateTime.Second(), currentDateTime.MicroSecond()));
       
 11061 	
       
 11062 	TInt64 fullAuthTime = currentTime.Int64();
       
 11063 	
       
 11064 	view.SetColL(colSet->ColNo(lastFullPasswordTimeString), fullAuthTime);
       
 11065 	
       
 11066 	view.PutL();	
       
 11067 	
       
 11068 	CleanupStack::PopAndDestroy(colSet); // Delete colSet.
       
 11069 	CleanupStack::PopAndDestroy(&view); // Close view.
       
 11070 	CleanupStack::PopAndDestroy(buf); // Delete buf.
       
 11071 	
       
 11072 	/* update end */	
       
 11073 	
       
 11074 } // eap_am_type_tls_peap_symbian_c::UpdatePasswordTimeL()
       
 11075 
 11132 
 11076 //--------------------------------------------------
 11133 //--------------------------------------------------
 11077 
 11134 
 11078 eap_status_e eap_am_type_tls_peap_symbian_c::CreateMasterkeyL()
 11135 eap_status_e eap_am_type_tls_peap_symbian_c::CreateMasterkeyL()
 11079 {
 11136 {
 11096 // eap_am_type_tls_peap_symbian_c::is_ttls_pap_session_valid()
 11153 // eap_am_type_tls_peap_symbian_c::is_ttls_pap_session_valid()
 11097 // ------------------------------------------------------------------------
 11154 // ------------------------------------------------------------------------
 11098 //
 11155 //
 11099 EAP_FUNC_EXPORT bool eap_am_type_tls_peap_symbian_c::is_ttls_pap_session_valid()
 11156 EAP_FUNC_EXPORT bool eap_am_type_tls_peap_symbian_c::is_ttls_pap_session_valid()
 11100 {
 11157 {
 11101     EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::is_ttls_pap_session_valid()" )));    
 11158     EAP_TRACE_DEBUG(
       
 11159 		m_am_tools,
       
 11160 		TRACE_FLAGS_DEFAULT,
       
 11161 		(EAPL( "eap_am_type_tls_peap_symbian_c::is_ttls_pap_session_valid()" )));    
 11102 
 11162 
 11103     TBool isValid = EFalse;
 11163     TBool isValid = EFalse;
 11104     TInt err = KErrNone;
 11164     TInt error = KErrNone;
 11105     bool retVal = false;
 11165     bool retVal = false;
 11106 	
 11166 	
 11107     TRAP( err, isValid = IsTtlsPapSessionValidL() );
 11167     TRAP( error, isValid = IsTtlsPapSessionValidL() );
 11108     if ( err != KErrNone )
 11168     if ( error != KErrNone )
 11109 	    {
 11169 	    {
 11110 	    EAP_TRACE_DEBUG_SYMBIAN((_L("ERROR: eap_am_type_tls_peap_symbian_c::is_ttls_pap_session_valid(): Leave, err==%d."), err ));
 11170 	    EAP_TRACE_DEBUG(
       
 11171 			m_am_tools,
       
 11172 			TRACE_FLAGS_DEFAULT,
       
 11173 			(EAPL("ERROR: eap_am_type_tls_peap_symbian_c::is_ttls_pap_session_valid(): Leave, error==%d."), error ));
       
 11174 
 11111 	    retVal = false;
 11175 	    retVal = false;
 11112 	    }
 11176 	    }
 11113     else
 11177     else
 11114     	{
 11178     	{
 11115     	retVal = ( isValid ) ? true : false;
 11179     	retVal = ( isValid ) ? true : false;
 11122 // ------------------------------------------------------------------------
 11186 // ------------------------------------------------------------------------
 11123 //    
 11187 //    
 11124 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password(
 11188 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password(
 11125 	const eap_variable_data_c * const aInSrvChallengeUtf8 )
 11189 	const eap_variable_data_c * const aInSrvChallengeUtf8 )
 11126 {
 11190 {
 11127 	EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password()" )));    
 11191 	EAP_TRACE_DEBUG(
       
 11192 		m_am_tools,
       
 11193 		TRACE_FLAGS_DEFAULT,
       
 11194 		(EAPL( "eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password()" )));
 11128 
 11195 
 11129 	eap_status_e status( eap_status_pending_request );
 11196 	eap_status_e status( eap_status_pending_request );
 11130 	TEapExpandedType aEapType(*EapExpandedTypeTtlsPap.GetType());
 11197 	TEapExpandedType aEapType(*EapExpandedTypeTtlsPap.GetType());
 11131 
 11198 
 11132 	m_notifier_data_to_user->iUsername.Zero();
 11199 	m_notifier_data_to_user->iUsername.Zero();
 11151 		m_state = EPapChallenge;
 11218 		m_state = EPapChallenge;
 11152 		TEapExpandedType aEapType(*EapExpandedTypeTtlsPap.GetType());
 11219 		TEapExpandedType aEapType(*EapExpandedTypeTtlsPap.GetType());
 11153 
 11220 
 11154 		if (iEapAuthNotifier == 0)
 11221 		if (iEapAuthNotifier == 0)
 11155 		{
 11222 		{
 11156 			TRAPD(err, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
 11223 			TRAPD(error, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
 11157 			if (err)
 11224 			if (error)
 11158 			{
 11225 			{
 11159 				return eap_status_process_general_error;
 11226 				return eap_status_process_general_error;
 11160 			}
 11227 			}
 11161 		}
 11228 		}
 11162 
 11229 
 11245 
 11312 
 11246 			DlgComplete(KErrNone);
 11313 			DlgComplete(KErrNone);
 11247 		}
 11314 		}
 11248 	}
 11315 	}
 11249 
 11316 
 11250 	return status;
 11317 	return EAP_STATUS_RETURN(m_am_tools, status);
 11251 }
 11318 }
 11252 
 11319 
 11253 // ================= TTLS-PAP public not exported =======================
 11320 // ================= TTLS-PAP public not exported =======================
 11254 
 11321 
 11255 // ------------------------------------------------------------------------
 11322 // ------------------------------------------------------------------------
 11258 //    
 11325 //    
 11259 eap_status_e eap_am_type_tls_peap_symbian_c::verify_ttls_pap_username_and_password(
 11326 eap_status_e eap_am_type_tls_peap_symbian_c::verify_ttls_pap_username_and_password(
 11260 	const eap_variable_data_c * const /*aUserName*/,
 11327 	const eap_variable_data_c * const /*aUserName*/,
 11261 	const eap_variable_data_c * const /*aUserPassword*/ )
 11328 	const eap_variable_data_c * const /*aUserPassword*/ )
 11262 {
 11329 {
 11263 	EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::verify_ttls_pap_username_and_password()" )));
 11330 	EAP_TRACE_DEBUG(
       
 11331 		m_am_tools,
       
 11332 		TRACE_FLAGS_DEFAULT,
       
 11333 		(EAPL( "eap_am_type_tls_peap_symbian_c::verify_ttls_pap_username_and_password()" )));
       
 11334 
 11264 	return eap_status_not_supported;
 11335 	return eap_status_not_supported;
 11265 }
 11336 }
 11266 
 11337 
 11267 // ================= TTLS-PAP public new =======================
 11338 // ================= TTLS-PAP public new =======================
 11268 
 11339 
 11273 eap_status_e eap_am_type_tls_peap_symbian_c::CompleteQueryTtlsPapUserNameAndPassword(
 11344 eap_status_e eap_am_type_tls_peap_symbian_c::CompleteQueryTtlsPapUserNameAndPassword(
 11274 	eap_status_e aStatus,
 11345 	eap_status_e aStatus,
 11275 	const TDesC8& aUserNameUtf8,
 11346 	const TDesC8& aUserNameUtf8,
 11276 	const TDesC8& aPasswordUtf8 )
 11347 	const TDesC8& aPasswordUtf8 )
 11277 {
 11348 {
 11278 	EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::CompleteQueryTtlsPapUserNameAndPassword()" )));
 11349 	EAP_TRACE_DEBUG(
       
 11350 		m_am_tools,
       
 11351 		TRACE_FLAGS_DEFAULT,
       
 11352 		(EAPL( "eap_am_type_tls_peap_symbian_c::CompleteQueryTtlsPapUserNameAndPassword()" )));
 11279 	
 11353 	
 11280 	eap_status_e retStatus = aStatus;
 11354 	eap_status_e retStatus = aStatus;
 11281 	eap_status_e tmpStatus = eap_status_ok;
 11355 	eap_status_e tmpStatus = eap_status_ok;
 11282 	
 11356 	
 11283 	eap_variable_data_c userNameUtf8( m_am_tools );
 11357 	eap_variable_data_c userNameUtf8( m_am_tools );
 11295 		{
 11369 		{
 11296 		retStatus = tmpStatus;
 11370 		retStatus = tmpStatus;
 11297 		}
 11371 		}
 11298 	if ( m_tls_am_partner == NULL )
 11372 	if ( m_tls_am_partner == NULL )
 11299 		{
 11373 		{
 11300 		EAP_TRACE_DEBUG_SYMBIAN((_L( "ERROR: eap_am_type_tls_peap_symbian_c::CompleteQueryTtlsPapUserNameAndPassword(): m_tls_am_partner is NULL." )));
 11374 		EAP_TRACE_DEBUG(
       
 11375 			m_am_tools,
       
 11376 			TRACE_FLAGS_DEFAULT,
       
 11377 			(EAPL( "ERROR: eap_am_type_tls_peap_symbian_c::CompleteQueryTtlsPapUserNameAndPassword(): m_tls_am_partner is NULL." )));
       
 11378 
 11301         return eap_status_process_general_error;
 11379         return eap_status_process_general_error;
 11302 		}
 11380 		}
 11303 	retStatus = m_tls_am_partner->
 11381 	retStatus = m_tls_am_partner->
 11304 	    complete_query_ttls_pap_username_and_password(
 11382 	    complete_query_ttls_pap_username_and_password(
 11305 		    &userNameUtf8, &passwordUtf8, retStatus );	
 11383 		    &userNameUtf8, &passwordUtf8, retStatus );	
 11312 // ------------------------------------------------------------------------
 11390 // ------------------------------------------------------------------------
 11313 //    
 11391 //    
 11314 eap_status_e
 11392 eap_status_e
 11315 eap_am_type_tls_peap_symbian_c::ConvertAmErrorToEapolError( TInt aErr )
 11393 eap_am_type_tls_peap_symbian_c::ConvertAmErrorToEapolError( TInt aErr )
 11316 {
 11394 {
 11317 	EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::ConvertAmErrorToEapolError()" )));
 11395 	EAP_TRACE_DEBUG(
       
 11396 		m_am_tools,
       
 11397 		TRACE_FLAGS_DEFAULT,
       
 11398 		(EAPL( "eap_am_type_tls_peap_symbian_c::ConvertAmErrorToEapolError()" )));
       
 11399 
 11318     if ( m_am_tools )
 11400     if ( m_am_tools )
 11319     	{
 11401     	{
 11320     	return m_am_tools->convert_am_error_to_eapol_error( aErr );
 11402     	return m_am_tools->convert_am_error_to_eapol_error( aErr );
 11321     	}
 11403     	}
 11322 	return eap_status_process_general_error;
 11404 	return eap_status_process_general_error;
 11333 //| EAP_TLS_PEAP_ttls_pap_max_session_validity_time		| BIGINT		   	| cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time_literal |//
 11415 //| EAP_TLS_PEAP_ttls_pap_max_session_validity_time		| BIGINT		   	| cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time_literal |//
 11334 //| EAP_TLS_PEAP_ttls_pap_last_full_authentication_time	| BIGINT		   	| KTTLSPAPLastFullAuthTime	                             |//
 11416 //| EAP_TLS_PEAP_ttls_pap_last_full_authentication_time	| BIGINT		   	| KTTLSPAPLastFullAuthTime	                             |//
 11335 void eap_am_type_tls_peap_symbian_c::ReadTtlsPapDbL(
 11417 void eap_am_type_tls_peap_symbian_c::ReadTtlsPapDbL(
 11336 	TTtlsPapDbInfo& aOutDbInfo )
 11418 	TTtlsPapDbInfo& aOutDbInfo )
 11337 {
 11419 {
 11338 	EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::ReadTtlsPapDbL()" )));
 11420 	EAP_TRACE_DEBUG(
       
 11421 		m_am_tools,
       
 11422 		TRACE_FLAGS_DEFAULT,
       
 11423 		(EAPL( "eap_am_type_tls_peap_symbian_c::ReadTtlsPapDbL()" )));
 11339 	
 11424 	
 11340 	HBufC* buf = HBufC::NewLC( KMaxSqlQueryLength );
 11425 	HBufC* buf = HBufC::NewLC( KMaxSqlQueryLength );
 11341 	TPtr sqlStatement = buf->Des();
 11426 	TPtr sqlStatement = buf->Des();
 11342 	
 11427 	
 11343 	// Query all the relevant parameters
 11428 	// Query all the relevant parameters
 11426 //| EAP_TLS_PEAP_ttls_pap_max_session_validity_time		| BIGINT		   	| cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time_literal |//
 11511 //| EAP_TLS_PEAP_ttls_pap_max_session_validity_time		| BIGINT		   	| cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time_literal |//
 11427 //| EAP_TLS_PEAP_ttls_pap_last_full_authentication_time	| BIGINT		   	| KTTLSPAPLastFullAuthTime	                             |//
 11512 //| EAP_TLS_PEAP_ttls_pap_last_full_authentication_time	| BIGINT		   	| KTTLSPAPLastFullAuthTime	                             |//
 11428 void eap_am_type_tls_peap_symbian_c::WriteTtlsPapDbL(
 11513 void eap_am_type_tls_peap_symbian_c::WriteTtlsPapDbL(
 11429 	const TTtlsPapDbInfo& aInDbInfo )
 11514 	const TTtlsPapDbInfo& aInDbInfo )
 11430 {
 11515 {
 11431 	EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::WriteTtlsPapDbL()" )));
 11516 	EAP_TRACE_DEBUG(
       
 11517 		m_am_tools,
       
 11518 		TRACE_FLAGS_DEFAULT,
       
 11519 		(EAPL( "eap_am_type_tls_peap_symbian_c::WriteTtlsPapDbL()" )));
 11432 	
 11520 	
 11433 	
 11521 	
 11434 	HBufC* buf = HBufC::NewLC( KMaxSqlQueryLength );
 11522 	HBufC* buf = HBufC::NewLC( KMaxSqlQueryLength );
 11435 	TPtr sqlStatement = buf->Des();
 11523 	TPtr sqlStatement = buf->Des();
 11436 	
 11524 	
 11520 // eap_am_type_tls_peap_symbian_c::SetTtlsPapColumnToNullL
 11608 // eap_am_type_tls_peap_symbian_c::SetTtlsPapColumnToNullL
 11521 // ------------------------------------------------------------------------
 11609 // ------------------------------------------------------------------------
 11522 //
 11610 //
 11523 void eap_am_type_tls_peap_symbian_c::SetTtlsPapColumnToNullL( const TDesC& aColName )
 11611 void eap_am_type_tls_peap_symbian_c::SetTtlsPapColumnToNullL( const TDesC& aColName )
 11524 {
 11612 {
 11525 	EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::SetColumnNullL()" )));
 11613 	EAP_TRACE_DEBUG(
       
 11614 		m_am_tools,
       
 11615 		TRACE_FLAGS_DEFAULT,
       
 11616 		(EAPL( "eap_am_type_tls_peap_symbian_c::SetColumnNullL()" )));
 11526 
 11617 
 11527 	HBufC* buf = HBufC::NewLC( KMaxSqlQueryLength );
 11618 	HBufC* buf = HBufC::NewLC( KMaxSqlQueryLength );
 11528 	TPtr sqlStatement = buf->Des();
 11619 	TPtr sqlStatement = buf->Des();
 11529 	
 11620 	
 11530 	// Query all the relevant parameters
 11621 	// Query all the relevant parameters
 11579 // eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL()
 11670 // eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL()
 11580 // ------------------------------------------------------------------------
 11671 // ------------------------------------------------------------------------
 11581 //
 11672 //
 11582 TBool eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL()
 11673 TBool eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL()
 11583 {
 11674 {
 11584 	EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL()" )));
 11675 	EAP_TRACE_DEBUG(
       
 11676 		m_am_tools,
       
 11677 		TRACE_FLAGS_DEFAULT,
       
 11678 		(EAPL( "eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL()" )));
 11585 
 11679 
 11586 	TTtlsPapDbInfo dbInfo;
 11680 	TTtlsPapDbInfo dbInfo;
 11587 	TInt err = KErrNone;
 11681 	TInt error = KErrNone;
 11588 	TBool retValue = EFalse;
 11682 	TBool retValue = EFalse;
 11589 	
 11683 	
 11590 	TRAP( err, ReadTtlsPapDbL( dbInfo ) );
 11684 	TRAP( error, ReadTtlsPapDbL( dbInfo ) );
 11591 	
 11685 	
 11592     if 	( err != KErrNone )
 11686     if 	( error != KErrNone )
 11593         {
 11687         {
 11594         EAP_TRACE_DEBUG_SYMBIAN((_L("ERROR: eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL(): Leave happened, err=%d."), err ));
 11688         EAP_TRACE_DEBUG(
       
 11689 			m_am_tools,
       
 11690 			TRACE_FLAGS_DEFAULT,
       
 11691 			(EAPL("ERROR: eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL(): Leave happened, error=%d."), error ));
       
 11692 
 11595         retValue = EFalse;
 11693         retValue = EFalse;
 11596         }
 11694         }
 11597     else
 11695     else
 11598     	{
 11696     	{
 11599 	    if ( dbInfo.iUsrPwdInfo.iPasswordPromptEnabled )
 11697 	    if ( dbInfo.iUsrPwdInfo.iPasswordPromptEnabled )
 11600 		    {
 11698 		    {
 11601 			// If the max session time from DB is zero then we use the 
 11699 			// If the max session time from DB is zero then we use the 
 11602 			// one read from configuration file.
 11700 			// one read from configuration file.
 11603 		    if( dbInfo.iMaxSessionTime == 0 )
 11701 		    if( dbInfo.iMaxSessionTime == 0 )
 11604 	            {
 11702 	            {
 11605 	            EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL() Using max TTLS PAP session validity time from config file." )));
 11703 	            EAP_TRACE_DEBUG(
       
 11704 					m_am_tools,
       
 11705 					TRACE_FLAGS_DEFAULT,
       
 11706 					(EAPL( "eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL() Using max TTLS PAP session validity time from config file." )));
 11606 			
 11707 			
 11607 				// use value from config file
 11708 				// use value from config file
 11608 				dbInfo.iMaxSessionTime = iEapTtlsPapMaxSessionConfigTime;
 11709 				dbInfo.iMaxSessionTime = iEapTtlsPapMaxSessionConfigTime;
 11609 			    }
 11710 			    }
 11610 
 11711 
 11622 //
 11723 //
 11623 TBool eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity(
 11724 TBool eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity(
 11624 	const TInt64& aInMaxSessionTime,
 11725 	const TInt64& aInMaxSessionTime,
 11625 	const TInt64& aInLastFullAuthTime )
 11726 	const TInt64& aInLastFullAuthTime )
 11626 {
 11727 {
 11627 	EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity()" )));
 11728 	EAP_TRACE_DEBUG(
       
 11729 		m_am_tools,
       
 11730 		TRACE_FLAGS_DEFAULT,
       
 11731 		(EAPL( "eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity()" )));
 11628 	
 11732 	
 11629 	// Get the current time.
 11733 	// Get the current time.
 11630 	TTime currentTime;
 11734 	TTime currentTime;
 11631 	currentTime.UniversalTime();
 11735 	currentTime.UniversalTime();
 11632 	
 11736 	
 11695 		return EFalse;	
 11799 		return EFalse;	
 11696 	    }
 11800 	    }
 11697 } // eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity
 11801 } // eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity
 11698 
 11802 
 11699 //--------------------------------------------------
 11803 //--------------------------------------------------
       
 11804 
 11700 #if defined(USE_FAST_EAP_TYPE)
 11805 #if defined(USE_FAST_EAP_TYPE)
 11701 
 11806 
 11702 TInt eap_am_type_tls_peap_symbian_c::CreateMMETelConnectionL()
 11807 TInt eap_am_type_tls_peap_symbian_c::CreateMMETelConnectionL()
 11703 {
 11808 {
 11704     EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
 11809     EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
 11741             User::LeaveIfError( iServer.GetPhoneInfo( phoneCount, phoneInfo ) );        
 11846             User::LeaveIfError( iServer.GetPhoneInfo( phoneCount, phoneInfo ) );        
 11742             
 11847             
 11743             EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Got phone info.\n")));
 11848             EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Got phone info.\n")));
 11744         } 
 11849         } 
 11745 
 11850 
       
 11851 #if defined(__WINS__)
       
 11852 
       
 11853         EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("WARNING: Not opened phone subsession on WINS.\n")));
       
 11854 
       
 11855 #else
       
 11856 
 11746         // This function opens a phone subsession by name. ("DefaultPhone").
 11857         // This function opens a phone subsession by name. ("DefaultPhone").
 11747         User::LeaveIfError( iPhone.Open( iServer, phoneInfo.iName ) );  
 11858         User::LeaveIfError( iPhone.Open( iServer, phoneInfo.iName ) );  
 11748         
 11859 
 11749         EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Opened phone subsession.\n")));
 11860         EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Opened phone subsession.\n")));
       
 11861 
       
 11862 #endif //#if defined(__WINS__)
 11750         
 11863         
 11751         // MMETel connected and the phone module loaded fine.   
 11864         // MMETel connected and the phone module loaded fine.   
 11752         iMMETELConnectionStatus = ETrue;    
 11865         iMMETELConnectionStatus = ETrue;    
 11753     }
 11866     }
 11754     else
 11867     else
 11779     {
 11892     {
 11780         EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("RMobilePhone and MMETEL already closed.\n")));      
 11893         EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("RMobilePhone and MMETEL already closed.\n")));      
 11781     }   
 11894     }   
 11782 }
 11895 }
 11783 #endif
 11896 #endif
       
 11897 
 11784 //--------------------------------------------------
 11898 //--------------------------------------------------
 11785 
 11899 
 11786 // End of file.
 11900 // End of file.