eapol/eapol_framework/eapol_symbian/am/type/tls_peap/symbian/eap_am_type_tls_peap_symbian.cpp
changeset 26 9abfd4f00d37
parent 2 1c7bc153c08e
child 34 ad1f037f1ac2
equal deleted inserted replaced
25:e03a3db4489e 26:9abfd4f00d37
    14 * Description:  EAP and WLAN authentication protocols.
    14 * Description:  EAP and WLAN authentication protocols.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: 253 %
    19 * %version: 247.2.42 %
    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
    51 #include "eap_am_dh_primes.h"
    51 #include "eap_am_dh_primes.h"
    52 #include <asn1dec.h>
    52 #include <asn1dec.h>
    53 #include <asn1enc.h>
    53 #include <asn1enc.h>
    54 #include "EapTlsPeapTimerValues.h"
    54 #include "EapTlsPeapTimerValues.h"
    55 #include "eap_state_notification.h"
    55 #include "eap_state_notification.h"
    56 #include "eap_am_trace_symbian.h"
    56 #include "EapTraceSymbian.h"
    57 #include "eap_automatic_variable.h"
    57 #include "eap_automatic_variable.h"
    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"
    63 //#include "eap_am_async_wait_symbian.h"
    63 //#include "eap_am_async_wait_symbian.h"
    64 #include "EapFastActive.h"
    64 #include "EapFastActive.h"
    65 #include "eap_tlv_header.h"
    65 #include "eap_tlv_header.h"
    66 #include "eap_tlv_message_data.h"
    66 #include "eap_tlv_message_data.h"
    67 #endif
    67 #endif
    68 
    68 #include <utf.h>
    69 #include "eap_ttls_pap_active.h"
    69 
    70 
    70 
    71 #ifdef USE_PAC_STORE
    71 #ifdef USE_PAC_STORE
    72 #include "pac_store_db_symbian.h"
    72 	#include "pac_store_db_symbian.h"
    73 #include <f32file.h>
    73 	#include <f32file.h>
    74 #endif
    74 #endif
    75 
    75 
    76 #ifdef USE_EAP_EXPANDED_TYPES
       
    77 #include "eap_header_string.h"
    76 #include "eap_header_string.h"
    78 #endif //#ifdef USE_EAP_EXPANDED_TYPES
       
    79 
    77 
    80 #if defined(USE_EAP_CONFIGURATION_TO_SKIP_USER_INTERACTIONS)
    78 #if defined(USE_EAP_CONFIGURATION_TO_SKIP_USER_INTERACTIONS)
    81 #include "eap_config.h"
    79 	#include "eap_config.h"
    82 #include "eap_file_config.h"
    80 	#include "eap_file_config.h"
    83 #include "eap_am_file_input_symbian.h"
    81 	#include "eap_am_file_input_symbian.h"
    84 #endif
    82 #endif
       
    83 
       
    84 #include "EapConfigToolsSymbian.h"
       
    85 #include "EapConversion.h"
       
    86 
       
    87 #include <EapPluginTools.h>
       
    88 #include <mmtsy_names.h>
       
    89 
    85 
    90 
    86 const TUint KMaxSqlQueryLength = 512;
    91 const TUint KMaxSqlQueryLength = 512;
    87 const TUint KMaxDBFieldNameLength = 255;
    92 const TUint KMaxDBFieldNameLength = 255;
    88 const TUint KDSASignatureLength = 40;
    93 const TUint KDSASignatureLength = 40;
    89 const TInt 	KDefaultColumnInView_One = 1; // For DB view.
    94 const TInt 	KDefaultColumnInView_One = 1; // For DB view.
    90 const TInt 	KMicroSecsInASecond = 1000000; // 1000000 micro seconds is 1 second.
    95 const TInt 	KMicroSecsInASecond = 1000000; // 1000000 micro seconds is 1 second.
    91 		
    96 
       
    97 #ifdef USE_FAST_EAP_TYPE
       
    98 
       
    99 const TUint KMaxDeviceSeedLength = RMobilePhone::KPhoneManufacturerIdSize+
       
   100 			RMobilePhone::KPhoneModelIdSize+
       
   101 			RMobilePhone::KPhoneSerialNumberSize;
       
   102 const TUint KMaxDeviceSeedSize = 2*KMaxDeviceSeedLength;
       
   103 #endif	
    92 /**
   104 /**
    93  * Length of the MAC address
   105  * Length of the MAC address
    94  */
   106  */
    95 #ifdef USE_FAST_EAP_TYPE
   107 #ifdef USE_FAST_EAP_TYPE
    96  const TUint8 KMacAddressLength = 6;
   108 	const TUint8 KMacAddressLength = 6;
    97 #endif
   109 #endif
       
   110 
    98 //--------------------------------------------------
   111 //--------------------------------------------------
    99 
   112 
   100 eap_am_type_tls_peap_symbian_c::eap_am_type_tls_peap_symbian_c(
   113 eap_am_type_tls_peap_symbian_c::eap_am_type_tls_peap_symbian_c(
   101 	abs_eap_am_tools_c * const aTools,
   114 	abs_eap_am_tools_c * const aTools,
   102 	abs_eap_base_type_c * const aPartner,
   115 	abs_eap_base_type_c * const aPartner,
   114 	  , m_am_tools(static_cast<eap_am_tools_symbian_c*> (aTools))
   127 	  , m_am_tools(static_cast<eap_am_tools_symbian_c*> (aTools))
   115 	  , m_tls_am_partner(0)
   128 	  , m_tls_am_partner(0)
   116 #if defined(USE_FAST_EAP_TYPE)
   129 #if defined(USE_FAST_EAP_TYPE)
   117 	  , m_tls_application(0)
   130 	  , m_tls_application(0)
   118 	  //, iWaitNoteCancelled( EFalse )
   131 	  //, iWaitNoteCancelled( EFalse )
   119       , iEapFastActiveWaitNote( NULL )
   132 
   120       , iEapFastActiveNotes( NULL )
       
   121 #endif //#if defined(USE_FAST_EAP_TYPE)
   133 #endif //#if defined(USE_FAST_EAP_TYPE)
   122 	  , m_is_valid(false)
   134 	  , m_is_valid(false)
   123 	  , m_is_client(aIsClient)
   135 	  , m_is_client(aIsClient)
   124 	  , m_current_eap_type(aEapType)
   136 	  , m_current_eap_type(aEapType)
   125 	  , m_max_count_of_session_resumes(0ul)
   137 	  , m_max_count_of_session_resumes(0ul)
   136 	  , m_peer_public_key(aTools)
   148 	  , m_peer_public_key(aTools)
   137 	  , m_param_p(aTools)
   149 	  , m_param_p(aTools)
   138 	  , m_param_q(aTools)
   150 	  , m_param_q(aTools)
   139 	  , m_param_g(aTools)
   151 	  , m_param_g(aTools)
   140 	  , m_shutdown_was_called(false)
   152 	  , m_shutdown_was_called(false)
   141 	  , m_identity_info(0)
   153 
   142 	  , m_tunneled_type(eap_type_none)
   154 	  , m_tunneled_type(eap_type_none)
   143 	  , m_verify_certificate_realm(true)
   155 	  , m_verify_certificate_realm(true)
   144 	  , m_allow_subdomain_matching(false)
   156 	  , m_allow_subdomain_matching(false)
   145 	  , m_latest_alert_description(tls_alert_description_none)
   157 	  , m_latest_alert_description(tls_alert_description_none)
   146 	  , m_use_manual_username(false)
   158 	  , m_use_manual_username(false)
   147 	  , m_manual_username(aTools)
   159 	  , m_manual_username(aTools)
   148 	  , m_use_manual_realm(false)
   160 	  , m_use_manual_realm(false)
   149 	  , m_manual_realm(aTools)
   161 	  , m_manual_realm(aTools)
   150 	  , m_tls_peap_server_authenticates_client_policy_flag(true)
   162 	  , m_tls_peap_server_authenticates_client_policy_flag(true)
       
   163 	  , m_use_automatic_ca_certificate(false)
   151 	  , m_configured(false)
   164 	  , m_configured(false)
   152 	  , m_max_session_time(0)
   165 	  , m_max_session_time(0)
   153 #if defined(USE_EAP_TLS_SESSION_TICKET)
   166 #if defined(USE_EAP_TLS_SESSION_TICKET)
   154 	  , m_use_session_ticket(false)
   167 	  , m_use_session_ticket(false)
   155 #endif //#if defined(USE_EAP_TLS_SESSION_TICKET)
   168 #endif //#if defined(USE_EAP_TLS_SESSION_TICKET)
   174 	, m_references_and_data_blocks(aTools)
   187 	, m_references_and_data_blocks(aTools)
   175 	, m_new_references_and_data_blocks(aTools)
   188 	, m_new_references_and_data_blocks(aTools)
   176 	, m_ready_references_and_data_blocks(aTools)
   189 	, m_ready_references_and_data_blocks(aTools)
   177 	, m_serv_unauth_prov_mode(false)
   190 	, m_serv_unauth_prov_mode(false)
   178 	, m_serv_auth_prov_mode(false)
   191 	, m_serv_auth_prov_mode(false)
   179 	, m_is_notifier_connected(false)
   192 
   180 	, m_notifier_data_to_user(NULL)
   193 	, m_notifier_data_to_user(NULL)
   181 	, m_notifier_data_pckg_to_user(NULL)
   194 	, m_notifier_data_pckg_to_user(NULL)
   182 	, m_notifier_data_from_user(NULL)
   195 
   183 	, m_notifier_data_pckg_from_user(NULL)
   196 	, iMMETELConnectionStatus(false)
   184 	, m_completed_with_zero(false)
   197 	, m_completed_with_zero(false)
   185 	, m_verificationStatus(false)
   198 	, m_verificationStatus(false)
       
   199 	, m_pacStorePWBuf8(0)
       
   200 	, m_userAction(EEapFastNotifierUserActionOk)
       
   201 	, m_pacStoreDataRefType(eap_pac_store_data_type_none)
   186 	, m_data_reference(m_am_tools)
   202 	, m_data_reference(m_am_tools)
   187 	, m_notifier_complete(false)
       
   188 	, m_userResponse(m_am_tools)
   203 	, m_userResponse(m_am_tools)
       
   204 	, m_pending_operation(eap_fast_pac_store_pending_operation_none)
   189 	, m_both_completed(0)
   205 	, m_both_completed(0)
   190 	, m_both_asked(0)
   206 	, m_both_asked(0)
       
   207 	, m_ready_references_array_index(0)
       
   208 	, m_provisioning_mode(eap_fast_completion_operation_none)
       
   209 	, iCompletionOperation(eap_fast_completion_operation_none)
       
   210 	, iCompletion(eap_fast_initialize_pac_store_completion_none)
   191 #endif //#if defined(USE_FAST_EAP_TYPE)
   211 #endif //#if defined(USE_FAST_EAP_TYPE)
       
   212 
       
   213 	, m_notifier_complete(false)
   192 
   214 
   193 #ifdef USE_PAC_STORE
   215 #ifdef USE_PAC_STORE
   194 	,iPacStoreDb(NULL)
   216 	,iPacStoreDb(NULL)
   195 #endif    
   217 #endif    
   196 	
   218 	
   197 #ifdef USE_EAP_CONFIGURATION_TO_SKIP_USER_INTERACTIONS
   219 #ifdef USE_EAP_CONFIGURATION_TO_SKIP_USER_INTERACTIONS
   198 , m_skip_user_interactions(false)
   220 	, m_skip_user_interactions(false)
   199 , m_fileconfig(0)
   221 	, m_fileconfig(0)
   200 #endif
   222 #endif
   201 	
   223 
   202 	
   224   , iEapTtlsPapMaxSessionConfigTime( 0 )
   203 	
   225 
   204     , iEapTtlsPapMaxSessionConfigTime( 0 )
   226 
   205     , iEapTtlsPapActive( NULL )
   227 
   206     
   228   , iPacStoreDeviceSeed(0)
       
   229 
       
   230 	, iEapAuthNotifier(0)	
       
   231 
   207 {
   232 {
   208 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   233 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   209 
   234 
   210 #ifdef USE_EAP_EXPANDED_TYPES
       
   211 
       
   212 	m_tunneling_vendor_type = m_tunneling_type.get_vendor_type();
       
   213 	m_current_eap_vendor_type = m_current_eap_type.get_vendor_type();
       
   214 
       
   215 #else
       
   216 
       
   217 	m_tunneling_vendor_type = static_cast<TUint>(m_tunneling_type);
       
   218 	m_current_eap_vendor_type = static_cast<TUint>(m_current_eap_type);
       
   219 
       
   220 #endif //#ifdef USE_EAP_EXPANDED_TYPES
       
   221 
       
   222 	// Set the database table name based on the type
   235 	// Set the database table name based on the type
   223 	switch (m_current_eap_vendor_type)
   236 	if (m_current_eap_type == eap_type_tls)
   224 	{
   237 	{
   225 		case eap_type_tls:
   238 		m_db_table_name = KTlsDatabaseTableName;
   226 			m_db_table_name = KTlsDatabaseTableName;
   239 		m_db_user_cert_table_name = KTlsAllowedUserCertsDatabaseTableName;
   227 			m_db_user_cert_table_name = KTlsAllowedUserCertsDatabaseTableName;
   240 		m_db_ca_cert_table_name = KTlsAllowedCACertsDatabaseTableName;
   228 			m_db_ca_cert_table_name = KTlsAllowedCACertsDatabaseTableName;
   241 		m_db_cipher_suite_table_name = KTlsAllowedCipherSuitesDatabaseTableName;
   229 			m_db_cipher_suite_table_name = KTlsAllowedCipherSuitesDatabaseTableName;
   242 		m_db_name = KTlsDatabaseName;	
   230 			m_db_name = KTlsDatabaseName;	
   243 	}
   231 			break;
   244 	else if (m_current_eap_type == eap_type_peap)
   232 		
   245 	{
   233 		case eap_type_peap:
   246 		m_db_table_name = KPeapDatabaseTableName;
   234 			m_db_table_name = KPeapDatabaseTableName;
   247 		m_db_user_cert_table_name = KPeapAllowedUserCertsDatabaseTableName;
   235 			m_db_user_cert_table_name = KPeapAllowedUserCertsDatabaseTableName;
   248 		m_db_ca_cert_table_name = KPeapAllowedCACertsDatabaseTableName;
   236 			m_db_ca_cert_table_name = KPeapAllowedCACertsDatabaseTableName;
   249 		m_db_cipher_suite_table_name = KPeapAllowedCipherSuitesDatabaseTableName;
   237 			m_db_cipher_suite_table_name = KPeapAllowedCipherSuitesDatabaseTableName;
   250 		m_db_name = KPeapDatabaseName;	
   238 			m_db_name = KPeapDatabaseName;	
   251 	}
   239 			break;
   252 	else if (m_current_eap_type == eap_type_ttls_plain_pap
   240 			
   253 			|| m_current_eap_type == eap_type_ttls)
   241 		case eap_type_ttls_plain_pap:
   254 	{
   242 		    // use the same case as for eap_type_ttls;
   255 		m_db_table_name = KTtlsDatabaseTableName;
   243 		    // break is not needed
   256 		m_db_user_cert_table_name = KTtlsAllowedUserCertsDatabaseTableName;
   244 		
   257 		m_db_ca_cert_table_name = KTtlsAllowedCACertsDatabaseTableName;
   245 		case eap_type_ttls:
   258 		m_db_cipher_suite_table_name = KTtlsAllowedCipherSuitesDatabaseTableName;
   246 			m_db_table_name = KTtlsDatabaseTableName;
   259 		m_db_name = KTtlsDatabaseName;
   247 			m_db_user_cert_table_name = KTtlsAllowedUserCertsDatabaseTableName;
   260 	}
   248 			m_db_ca_cert_table_name = KTtlsAllowedCACertsDatabaseTableName;
       
   249 			m_db_cipher_suite_table_name = KTtlsAllowedCipherSuitesDatabaseTableName;
       
   250 			m_db_name = KTtlsDatabaseName;
       
   251 			break;
       
   252 			
   261 			
   253 #if defined (USE_FAST_EAP_TYPE)
   262 #if defined (USE_FAST_EAP_TYPE)
   254 			case eap_type_fast:
   263 	else if (m_current_eap_type == eap_type_fast)
   255 			m_db_table_name = KFastGeneralSettingsDBTableName; // General settings
   264 	{
   256 			m_db_fast_special_table_name = KFastSpecialSettingsDBTableName; // Special settings  for only FAST
   265 		m_db_table_name = KFastGeneralSettingsDBTableName; // General settings
   257 			m_db_user_cert_table_name = KFastAllowedUserCertsDatabaseTableName;
   266 		m_db_fast_special_table_name = KFastSpecialSettingsDBTableName; // Special settings  for only FAST
   258 			m_db_ca_cert_table_name = KFastAllowedCACertsDatabaseTableName;
   267 		m_db_user_cert_table_name = KFastAllowedUserCertsDatabaseTableName;
   259 			m_db_cipher_suite_table_name = KFastAllowedCipherSuitesDatabaseTableName;
   268 		m_db_ca_cert_table_name = KFastAllowedCACertsDatabaseTableName;
   260 			m_db_name = KFastDatabaseName;
   269 		m_db_cipher_suite_table_name = KFastAllowedCipherSuitesDatabaseTableName;
   261 			break;
   270 		m_db_name = KFastDatabaseName;
       
   271 	}
   262 #endif // #if defined (USE_FAST_EAP_TYPE)			
   272 #endif // #if defined (USE_FAST_EAP_TYPE)			
   263 		default:
   273 	else
   264 			{
   274 	{
   265 				// Unsupported type		
   275 		// Unsupported type		
   266 				// Should never happen
   276 		// Should never happen
   267 				EAP_TRACE_ERROR(m_am_tools, 
   277 		EAP_TRACE_ERROR(m_am_tools, 
   268 					TRACE_FLAGS_DEFAULT, (
   278 			TRACE_FLAGS_DEFAULT,
   269 					EAPL("Unsupported EAP type, m_current_eap_vendor_type=%d \n"),
   279 			(EAPL("Unsupported EAP type, m_current_eap_vendor_type=0xfe%06x%08x\n"),
   270 					m_current_eap_vendor_type));
   280 			m_current_eap_type.get_vendor_id(),
   271 		
   281 			m_current_eap_type.get_vendor_type()));
   272 				return;
   282 
   273 			}
   283 		return;
   274 	}
   284 	}
   275 
   285 
   276 	if (receive_network_id != 0
   286 	if (receive_network_id != 0
   277 		&& receive_network_id->get_is_valid_data() == true)
   287 		&& receive_network_id->get_is_valid_data() == true)
   278 	{
   288 	{
   370 		iPacStoreDb->OpenPacStoreL();
   380 		iPacStoreDb->OpenPacStoreL();
   371 		
   381 		
   372 		EAP_TRACE_DEBUG_SYMBIAN(
   382 		EAP_TRACE_DEBUG_SYMBIAN(
   373 			(_L("eap_am_type_tls_peap_symbian_c::ConstructL Opened PAC store")));		
   383 			(_L("eap_am_type_tls_peap_symbian_c::ConstructL Opened PAC store")));		
   374 	}
   384 	}
   375 	m_info_array.Reset();
   385 	m_info_array.ResetAndDestroy();
   376 	
   386 	
   377 #endif	// End: #ifdef USE_FAST_EAP_TYPE
   387 #endif	// End: #ifdef USE_FAST_EAP_TYPE
   378 #endif // End: 	#ifdef USE_PAC_STORE
   388 #endif // End: 	#ifdef USE_PAC_STORE
   379 
   389 
   380 #ifdef USE_FAST_EAP_TYPE
   390 	m_notifier_data_to_user = new(ELeave) CEapAuthNotifier::TEapDialogInfo;
   381 	
   391 	m_notifier_data_pckg_to_user = new(ELeave) TPckg<CEapAuthNotifier::TEapDialogInfo> (*m_notifier_data_to_user);
   382 	if(m_current_eap_type == eap_type_fast)
   392 
   383 	{
       
   384 		m_notifier_data_to_user = new(ELeave) TEapFastNotifierStruct;
       
   385 		m_notifier_data_pckg_to_user = new(ELeave) TPckg<TEapFastNotifierStruct> (*m_notifier_data_to_user);
       
   386 		
       
   387 		EAP_TRACE_DATA_DEBUG(
   393 		EAP_TRACE_DATA_DEBUG(
   388 			m_am_tools,
   394 			m_am_tools,
   389 			TRACE_FLAGS_DEFAULT,
   395 			TRACE_FLAGS_DEFAULT,
   390 			(EAPL("eap_am_type_tls_peap_symbian_c::ConstructL m_notifier_data_pckg_to_user"),
   396 			(EAPL("eap_am_type_tls_peap_symbian_c::ConstructL m_notifier_data_pckg_to_user"),
   391 			m_notifier_data_pckg_to_user->Ptr(),
   397 			m_notifier_data_pckg_to_user->Ptr(),
   392 			m_notifier_data_pckg_to_user->Size()));	
   398 			m_notifier_data_pckg_to_user->Size()));	
   393 		
   399 
   394 		m_notifier_data_from_user = new(ELeave) TEapFastNotifierStruct;
   400 
   395 		m_notifier_data_pckg_from_user = new(ELeave) TPckg<TEapFastNotifierStruct> (*m_notifier_data_from_user);		
   401 #ifdef USE_FAST_EAP_TYPE
   396 	}	
   402 
   397 #endif	// End: #ifdef USE_FAST_EAP_TYPE	
   403 #endif	// End: #ifdef USE_FAST_EAP_TYPE	
   398 	
   404 	
   399 
   405 
   400 }
   406 }
   401 
   407 
   422 		if(m_cert_if->IsActive())
   428 		if(m_cert_if->IsActive())
   423 		{
   429 		{
   424 			m_cert_if->Cancel();
   430 			m_cert_if->Cancel();
   425 		}		
   431 		}		
   426 	}
   432 	}
   427 	
   433 
   428 	if ( iEapTtlsPapActive )
   434 	if (iEapAuthNotifier != 0)
   429 		{
   435 		{
   430 		if ( iEapTtlsPapActive->IsActive() )
   436 		iEapAuthNotifier->Cancel();
   431 			{
   437 		}
   432 			EAP_TRACE_DEBUG_SYMBIAN(
   438 
   433 				( _L( " eap_am_type_tls_peap_symbian_c::shutdown() \
   439 	
   434 				Cancelling iEapTtlsPapActive." ) ) );
   440 
   435 			iEapTtlsPapActive->Cancel();
   441 	
   436 			}
   442 #if defined(USE_FAST_EAP_TYPE)
   437 		EAP_TRACE_DEBUG_SYMBIAN(
   443 
   438 			( _L( " eap_am_type_tls_peap_symbian_c::shutdown() \
   444 
   439 			Deleting iEapTtlsPapActive." ) ) );
   445 
   440 		delete iEapTtlsPapActive;
   446 #endif 
   441 		iEapTtlsPapActive = NULL;
       
   442 		}
       
   443 	
       
   444 #if defined(USE_FAST_EAP_TYPE)		
       
   445 		if( m_is_notifier_connected )
       
   446 		{
       
   447 			EAP_TRACE_DEBUG_SYMBIAN(
       
   448 				(_L(" eap_am_type_tls_peap_symbian_c::shutdown - calling m_notifier.CancelNotifier")));
       
   449 			if(IsActive())
       
   450 				{
       
   451 				TInt error = m_notifier.CancelNotifier(KEapFastNotifierUid);
       
   452 				EAP_TRACE_DEBUG_SYMBIAN(
       
   453 					(_L("eap_am_type_tls_peap_symbian_c::shutdown - CancelNotifier=%d"), error));
       
   454 				}	
       
   455 			EAP_TRACE_DEBUG_SYMBIAN(
       
   456 				(_L(" eap_am_type_securid_symbian_c::shutdown - calling m_notifier.Close()")));
       
   457 			
       
   458 			m_notifier.Close(); // Call close only if it is connected.	
       
   459 			
       
   460 			m_is_notifier_connected = false;
       
   461 			
       
   462 		} // End: if( m_is_notifier_connected )	
       
   463 
   447 
   464 		if (m_partner != NULL)
   448 		if (m_partner != NULL)
   465 		    {
   449 		    {
   466 		    EAP_TRACE_DEBUG_SYMBIAN(
   450 		    EAP_TRACE_DEBUG_SYMBIAN(
   467 				(_L(" eap_am_type_tls_peap_symbian_c::shutdown - Cancel timers ...")));
   451 				(_L(" eap_am_type_tls_peap_symbian_c::shutdown - Cancel timers ...")));
   468 
   452 
       
   453 #if defined(USE_FAST_EAP_TYPE)
   469 		    m_partner->cancel_timer(
   454 		    m_partner->cancel_timer(
   470 				this, 
   455 				this, 
   471 				KRemoveIAPReferenceTimerID);
   456 				KRemoveIAPReferenceTimerID);
   472 
   457 
   473 		    m_partner->cancel_timer(
   458 		    m_partner->cancel_timer(
   480 
   465 
   481 		    m_partner->cancel_timer(
   466 		    m_partner->cancel_timer(
   482 				this, 
   467 				this, 
   483 				KHandleReadPacstoreTimerID);
   468 				KHandleReadPacstoreTimerID);
   484 
   469 
       
   470 		    m_partner->cancel_timer(
       
   471 				this, 
       
   472 				KHandleCompletePacstoreNokTimerID);
       
   473 
       
   474 		    m_partner->cancel_timer(
       
   475 				this, 
       
   476 				KHandleCompletePacstoreOkTimerID);
       
   477 				
       
   478 #endif
   485 		    EAP_TRACE_DEBUG_SYMBIAN(
   479 		    EAP_TRACE_DEBUG_SYMBIAN(
   486 				(_L(" eap_am_type_tls_peap_symbian_c::shutdown - Timers canceled")));
   480 				(_L(" eap_am_type_tls_peap_symbian_c::shutdown - Timers canceled")));
   487 		    }
   481 		    }
   488 		
   482 		
   489 		if ( iEapFastActiveWaitNote )
   483 #if defined(USE_FAST_EAP_TYPE)
   490 			{
   484 
   491 			if ( iEapFastActiveWaitNote->IsActive() )
       
   492 				{
       
   493 				iEapFastActiveWaitNote->Cancel();
       
   494 				}
       
   495 			delete iEapFastActiveWaitNote;
       
   496 			iEapFastActiveWaitNote = NULL;
       
   497 			}
       
   498 
       
   499 		if ( iEapFastActiveNotes )
       
   500 			{
       
   501 			if ( iEapFastActiveNotes->IsActive() )
       
   502 				{
       
   503 			    iEapFastActiveNotes->Cancel();
       
   504 				}
       
   505 			delete iEapFastActiveNotes;
       
   506 			iEapFastActiveNotes = NULL;
       
   507 			}
       
   508 #endif // #if defined(USE_FAST_EAP_TYPE)
   485 #endif // #if defined(USE_FAST_EAP_TYPE)
   509 	
   486 	
   510 
   487 
   511 	m_allowed_server_certs.Reset();
   488 	m_allowed_server_certs.ResetAndDestroy();
   512 	m_allowed_ca_certs.Close();			
   489 	m_allowed_ca_certs.ResetAndDestroy();			
   513 	m_allowed_cipher_suites.Close();			
   490 	m_allowed_cipher_suites.Close();			
   514 	m_allowed_user_certs.Reset();			
   491 	m_allowed_user_certs.ResetAndDestroy();			
   515 
   492 
   516 #ifdef USE_PAC_STORE
   493 #ifdef USE_PAC_STORE
   517 #ifdef USE_FAST_EAP_TYPE
   494 #ifdef USE_FAST_EAP_TYPE
   518 	
   495 	
   519 	if(m_current_eap_type == eap_type_fast && iPacStoreDb != NULL)
   496 	if(m_current_eap_type == eap_type_fast && iPacStoreDb != NULL)
   520 	{
   497 	{
   521 		iPacStoreDb->Close();
   498 		iPacStoreDb->Close();
   522 	}
   499 	}
   523 	
   500 	
   524 	TInt count=0;
   501 	m_info_array.ResetAndDestroy();
   525 	while (count < m_info_array.Count())
       
   526 		{
       
   527 		delete m_info_array[count].iData;
       
   528 		delete m_info_array[count].iReference;
       
   529 		}
       
   530 	m_info_array.Reset();
       
   531 
   502 
   532 	EAP_TRACE_DEBUG_SYMBIAN(
   503 	EAP_TRACE_DEBUG_SYMBIAN(
   533 			(_L(" eap_am_type_tls_peap_symbian_c::shutdown - Arrays cleared")));
   504 			(_L(" eap_am_type_tls_peap_symbian_c::shutdown - Arrays cleared")));
   534 
   505 
   535 #endif	// End: #ifdef USE_FAST_EAP_TYPE	
   506 #endif	// End: #ifdef USE_FAST_EAP_TYPE	
   549 		 (m_is_client == true ? "client": "server")));
   520 		 (m_is_client == true ? "client": "server")));
   550 
   521 
   551 	return eap_status_ok;
   522 	return eap_status_ok;
   552 }
   523 }
   553 
   524 
   554 
       
   555 //--------------------------------------------------
   525 //--------------------------------------------------
   556 
   526 
   557 EAP_FUNC_EXPORT eap_am_type_tls_peap_symbian_c::~eap_am_type_tls_peap_symbian_c()
   527 EAP_FUNC_EXPORT eap_am_type_tls_peap_symbian_c::~eap_am_type_tls_peap_symbian_c()
   558 {
   528 {
   559 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   529 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   569 	EAP_ASSERT(m_shutdown_was_called == true);	
   539 	EAP_ASSERT(m_shutdown_was_called == true);	
   570 
   540 
   571 	m_database.Close();
   541 	m_database.Close();
   572 	m_session.Close();
   542 	m_session.Close();
   573 
   543 
       
   544 	delete m_notifier_data_to_user;
       
   545 	delete m_notifier_data_pckg_to_user;
       
   546 
       
   547 
   574 #ifdef USE_FAST_EAP_TYPE
   548 #ifdef USE_FAST_EAP_TYPE
   575 	
   549 	
   576 	if(m_current_eap_type == eap_type_fast)
       
   577 	{
       
   578 		delete m_notifier_data_to_user;
       
   579 		delete m_notifier_data_pckg_to_user;
       
   580 		
       
   581 		delete m_notifier_data_from_user;
       
   582 		delete m_notifier_data_pckg_from_user;		
       
   583 	}	
       
   584 #endif	// End: #ifdef USE_FAST_EAP_TYPE	
   550 #endif	// End: #ifdef USE_FAST_EAP_TYPE	
   585 		
   551 		
   586 	delete m_cert_if;
   552 	delete m_cert_if;
   587 
   553 
   588 	delete m_ca_certificate;
   554 	delete m_ca_certificate;
   589 	delete m_own_certificate;
   555 	delete m_own_certificate;
   590 	delete m_peer_certificate;
   556 	delete m_peer_certificate;
   591 	delete m_identity_info;
       
   592 
       
   593 #ifdef USE_EAP_EXPANDED_TYPES
       
   594 
   557 
   595 	m_enabled_tunneling_exp_eap_array.ResetAndDestroy();
   558 	m_enabled_tunneling_exp_eap_array.ResetAndDestroy();
   596 	m_disabled_tunneling_exp_eap_array.ResetAndDestroy();
   559 	m_disabled_tunneling_exp_eap_array.ResetAndDestroy();
   597 
   560 
   598 	EAP_TRACE_DEBUG(
   561 	EAP_TRACE_DEBUG(
   599 			m_am_tools,
   562 			m_am_tools,
   600 			TRACE_FLAGS_DEFAULT,
   563 			TRACE_FLAGS_DEFAULT,
   601 			(EAPL("eap_am_type_tls_peap_symbian_c::~eap_am_type_tls_peap_symbian_c() tunneling done.\n")));
   564 			(EAPL("eap_am_type_tls_peap_symbian_c::~eap_am_type_tls_peap_symbian_c() tunneling done.\n")));
   602 
   565 
   603 #else
       
   604 
       
   605 	m_iap_eap_array.ResetAndDestroy();
       
   606 
       
   607 #endif  // #ifdef USE_EAP_EXPANDED_TYPES
       
   608 
       
   609 #ifdef USE_PAC_STORE
   566 #ifdef USE_PAC_STORE
   610 	
   567 	
   611 	delete iPacStoreDb;
   568 	delete iPacStoreDb;
   612 	
   569 	
   613 #endif	// End: #ifdef USE_PAC_STORE	
   570 #endif	// End: #ifdef USE_PAC_STORE	
   614 	
   571 	delete iEapAuthNotifier;
       
   572 	iEapAuthNotifier = 0;
       
   573 
   615 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   574 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   616 }
   575 }
   617 //--------------------------------------------------
   576 //--------------------------------------------------
   618 
   577 
   619 //
   578 EAP_FUNC_EXPORT void eap_am_type_tls_peap_symbian_c::DlgComplete( TInt aStatus )
   620 
   579 	{
   621 void eap_am_type_tls_peap_symbian_c::RunL()
       
   622 {
       
   623 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);		
       
   624 	
       
   625 	EAP_TRACE_DEBUG_SYMBIAN(
       
   626 		(_L("eap_am_type_tls_peap_symbian_c::RunL - iStatus.Int()=%d, m_state=%d "),
       
   627 		iStatus.Int() , m_state));
       
   628 	
       
   629 #ifdef USE_FAST_EAP_TYPE
   580 #ifdef USE_FAST_EAP_TYPE
   630 	eap_status_e status(eap_status_ok);
   581 	m_userAction = EEapFastNotifierUserActionOk;
   631 
   582 #endif
   632 	if (m_notifier_complete)
   583 	eap_status_e status = m_am_tools->convert_am_error_to_eapol_error(aStatus);
   633 	{
   584 	
   634 	
   585 	
   635 		TRAPD(err, CompleteNotifierL());// Only for the notifiers.
   586 	if(m_notifier_complete)
   636 		if (err != KErrNone)
   587 		{
   637 			{
   588   	EAP_TRACE_DEBUG_SYMBIAN(
   638 			EAP_TRACE_ERROR(m_am_tools, 
   589   			(_L("m_notifier_data_pckg_to_user"),
   639 					TRACE_FLAGS_DEFAULT, (
   590   			m_notifier_data_pckg_to_user->Ptr(),
   640 					EAPL("eap_am_type_tls_peap_symbian_c::RunL LEAVE from CompleteNotifierL, Error =%d \n"),
   591   			m_notifier_data_pckg_to_user->Size()));	    		
   641 					err));
   592   	if ( aStatus == KErrCancel )
       
   593   		{
       
   594   		EAP_TRACE_DEBUG_SYMBIAN(
       
   595   				(_L("eap_am_type_tls_peap_symbian_c::DlgComplete - User cancelled the dialog")));
       
   596 #ifdef USE_FAST_EAP_TYPE
       
   597   		m_userAction = EEapFastNotifierUserActionCancel;	
       
   598 #endif
       
   599   		}		
       
   600   	else if( aStatus != KErrNone )
       
   601   		{
       
   602   		EAP_TRACE_DEBUG_SYMBIAN(
       
   603   			(_L("eap_am_type_tls_peap_symbian_c::DlgComplete - ERROR: dialog error=%d"),
       
   604   			aStatus));	
       
   605 	  	TBuf8<KMaxNotifItemLength> userNameUtf8;
       
   606 	  	TBuf8<KMaxUiDataLength> challengeUtf8;
       
   607 			userNameUtf8.Zero();
       
   608 			challengeUtf8.Zero();
       
   609 			
       
   610     	CompleteQueryTtlsPapUserNameAndPassword(
       
   611        	status, userNameUtf8, challengeUtf8 );  
       
   612   		return; // m_am_tools->convert_am_error_to_eapol_error(aStatus);		
       
   613   		}
       
   614 
       
   615   	if ( m_notifier_data_to_user->iPassword.Size() > 0 )
       
   616   		{
       
   617   		HBufC8* notifier_data8 = NULL;
       
   618 			TRAPD(err, notifier_data8 = HBufC8::NewL(m_notifier_data_to_user->iPassword.Size()));
       
   619 			if (err)
       
   620 				{
       
   621 				return;	
       
   622 				}
       
   623 			TPtr8 notifier_dataPtr8 = notifier_data8->Des();
       
   624 			
       
   625 			notifier_dataPtr8.Copy(m_notifier_data_to_user->iPassword); // Unicode -> ascii.
       
   626 			EAP_TRACE_DEBUG_SYMBIAN(
       
   627 				(_L("eap_am_type_tls_peap_symbian_c::DlgComplete Data copy done")));
       
   628 		    
       
   629 			EAP_TRACE_DATA_DEBUG_SYMBIAN(
       
   630   			("eap_am_type_tls_peap_symbian_c::DlgComplete PW from UI (8bits)",
       
   631 				notifier_dataPtr8.Ptr(), 
       
   632 				notifier_dataPtr8.Size()));	    
       
   633 		    
       
   634 #ifdef USE_FAST_EAP_TYPE
       
   635 			status = m_userResponse.set_copy_of_buffer(
       
   636 				notifier_dataPtr8.Ptr(),
       
   637 				notifier_dataPtr8.Size());
       
   638 #endif			
       
   639   		CleanupStack::PopAndDestroy( notifier_data8 );
       
   640   		}
       
   641 		}
       
   642   m_notifier_complete = 0;
       
   643 
       
   644 	if ( m_state == EPapChallenge)
       
   645 		{
       
   646   	TBuf8<KMaxNotifItemLength> userNameUtf8;
       
   647   	TBuf8<KMaxUiDataLength> challengeUtf8;
       
   648 		userNameUtf8.Zero();
       
   649 		challengeUtf8.Zero();
       
   650 
       
   651 		if (m_notifier_data_to_user->iUsername.Size()>0)
       
   652 			{
       
   653 			const TPtrC16 unicode_uname(
       
   654 				reinterpret_cast<unsigned short *>(&m_notifier_data_to_user->iUsername),
       
   655 				m_notifier_data_to_user->iUsername.Size()); // Length in unicode characters
       
   656 	
       
   657 	  	CnvUtfConverter::ConvertFromUnicodeToUtf8( userNameUtf8, unicode_uname );
   642 			}
   658 			}
   643 
   659   	EAP_TRACE_DATA_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (
   644 		m_notifier_complete = EFalse;
   660   		EAPL( "userNameUtf8" ),
   645 	}
   661   		userNameUtf8.Ptr(),
   646 
   662   		userNameUtf8.Size() ) );
   647 	if ( m_state == EPasswordCancel ||
   663 
       
   664 		if (m_notifier_data_to_user->iUidata.Size()>0)
       
   665 			{
       
   666 			const TPtrC16 unicode_pw(
       
   667 				reinterpret_cast<unsigned short *>(&m_notifier_data_to_user->iUidata),
       
   668 				m_notifier_data_to_user->iUidata.Size()); // Length in unicode characters
       
   669 	
       
   670 	  	CnvUtfConverter::ConvertFromUnicodeToUtf8( challengeUtf8, unicode_pw );  
       
   671   		} 	
       
   672   	EAP_TRACE_DATA_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (
       
   673   		EAPL( "challengeUtf8" ),
       
   674   		challengeUtf8.Ptr(),
       
   675   		challengeUtf8.Size() ) );
       
   676 
       
   677     	CompleteQueryTtlsPapUserNameAndPassword(
       
   678        	status, userNameUtf8, challengeUtf8 );  
       
   679 		}
       
   680 	if ( m_state == EPapUserNameAndPassword )
       
   681 		{
       
   682   	TBuf8<KMaxNotifItemLength> userNameUtf8;
       
   683   	TBuf8<KMaxNotifItemLength> passwordUtf8;
       
   684 		userNameUtf8.Zero();
       
   685 		passwordUtf8.Zero();
       
   686 
       
   687 		if (m_notifier_data_to_user->iUsername.Size()>0)
       
   688 			{
       
   689 			const TPtrC16 unicode_uname(
       
   690 				reinterpret_cast<unsigned short *>(&m_notifier_data_to_user->iUsername),
       
   691 				m_notifier_data_to_user->iUsername.Size()); // Length in unicode characters
       
   692 	
       
   693 	  	CnvUtfConverter::ConvertFromUnicodeToUtf8( userNameUtf8, unicode_uname );
       
   694 	  	EAP_TRACE_DATA_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (
       
   695 	  		EAPL( "userNameUtf8" ),
       
   696 	  		userNameUtf8.Ptr(),
       
   697 	  		userNameUtf8.Size() ) );
       
   698 			}
       
   699 		if (m_notifier_data_to_user->iPassword.Size()>0)
       
   700 			{
       
   701 			const TPtrC16 unicode_pw(
       
   702 				reinterpret_cast<unsigned short *>(&m_notifier_data_to_user->iPassword),
       
   703 				m_notifier_data_to_user->iPassword.Size()); // Length in unicode characters
       
   704 	
       
   705 	  	CnvUtfConverter::ConvertFromUnicodeToUtf8( passwordUtf8, unicode_pw );   	
       
   706   		}
       
   707   	EAP_TRACE_DATA_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (
       
   708   		EAPL( "passwordUtf8" ),
       
   709   		passwordUtf8.Ptr(),
       
   710   		passwordUtf8.Size() ) );
       
   711 
       
   712     	CompleteQueryTtlsPapUserNameAndPassword(
       
   713        	status, userNameUtf8, passwordUtf8 );  
       
   714 	  		
       
   715 			TTtlsPapDbInfo aInDbInfo;
       
   716 			aInDbInfo.iUsrPwdInfo.iPasswordPromptEnabled = m_notifier_data_to_user->iPasswordPromptEnabled;
       
   717 			aInDbInfo.iUsrPwdInfo.iUserName.Copy(userNameUtf8);
       
   718 			aInDbInfo.iUsrPwdInfo.iPassword.Copy(passwordUtf8);
       
   719 		
       
   720 			TRAPD(err1, WriteTtlsPapDbL( aInDbInfo));
       
   721 			if (err1)
       
   722 				{
       
   723 					// continue
       
   724 				}
       
   725  		}
       
   726 #ifdef USE_FAST_EAP_TYPE
       
   727 	else if ( m_state == EPasswordCancel ||
   648 		 m_state == EMasterkeyQuery ||
   728 		 m_state == EMasterkeyQuery ||
   649 		 m_state == EPasswordQuery ||
   729 		 m_state == EPasswordQuery ||
   650 		 m_state == EWrongPassword ||
   730 		 m_state == EWrongPassword ||
   651 		 m_state == EFilePasswordQuery )
   731 		 m_state == EFilePasswordQuery )
   652 		{
   732 		{
   653 		m_eap_fast_completion_status = m_partner->set_timer(
   733 		m_eap_fast_completion_status = m_partner->set_timer(
   654 				this,
   734 				this,
   655 				KHandleReadPacstoreTimerID, 
   735 				KHandleReadPacstoreTimerID, 
   656 				&status,
   736 				&aStatus,
   657 				0);
   737 				0);
   658 		return;
   738 		return;
   659 		}
   739 		}
       
   740 #endif		
       
   741 		
       
   742 	}
       
   743 
       
   744 //--------------------------------------------------
       
   745 
       
   746 //
       
   747 void eap_am_type_tls_peap_symbian_c::RunL()
       
   748 {
       
   749 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);		
       
   750 	
       
   751 	EAP_TRACE_DEBUG_SYMBIAN(
       
   752 		(_L("eap_am_type_tls_peap_symbian_c::RunL - iStatus.Int()=%d, m_state=%d "),
       
   753 		iStatus.Int() , m_state));
       
   754 	
       
   755 #ifdef USE_FAST_EAP_TYPE
       
   756 	eap_status_e status(eap_status_ok);
       
   757 
       
   758 
   660 	if (m_state == ENone)
   759 	if (m_state == ENone)
   661 		{
   760 		{
   662 		return;		
   761 		return;		
   663 		}
   762 		}
   664 
   763 
       
   764 		if ( m_state == EHandlingDeviceSeedQuery)
       
   765 			{
       
   766 		  CompleteCreateDeviceSeedL( iStatus.Int() );     
       
   767 
       
   768 		  return;
       
   769 			}
   665 #endif // #ifdef USE_FAST_EAP_TYPE
   770 #endif // #ifdef USE_FAST_EAP_TYPE
   666 
   771 
   667 	if (iStatus.Int() != KErrNone)
   772 	if (iStatus.Int() != KErrNone)
   668 	{
   773 	{
   669 		// Notifier was cancelled or something went wrong
   774 		// Notifier was cancelled or something went wrong
   699 			// Notifier was cancelled or something went wrong		
   804 			// Notifier was cancelled or something went wrong		
   700 			get_tls_am_partner()->complete_query_certificate_chain(
   805 			get_tls_am_partner()->complete_query_certificate_chain(
   701 				0, 
   806 				0, 
   702 				eap_status_process_general_error);			
   807 				eap_status_process_general_error);			
   703 			return;
   808 			return;
       
   809 			
   704 		default:
   810 		default:
   705 			return;
   811 			return;
   706 		}
   812 		}
   707 	}
   813 	} // (iStatus.Int() != KErrNone)
   708 
   814 
   709 	if (m_state == EHandlingIdentityQuery
   815 	if (m_state == EHandlingIdentityQuery
   710 		|| m_state == EHandlingChainQuery)
   816 		|| m_state == EHandlingChainQuery)
   711 	{
   817 	{
   712 		TUint index(0);
   818 		TUint index(0);
   721 			index = 0;
   827 			index = 0;
   722 		}
   828 		}
   723 		
   829 		
   724 		if(m_allowed_user_certs.Count() > 0)
   830 		if(m_allowed_user_certs.Count() > 0)
   725 		{
   831 		{
   726 			m_own_certificate_info = m_allowed_user_certs[index];			
   832 			m_own_certificate_info = *m_allowed_user_certs[index];			
   727 		}
   833 		}
   728 		
   834 		
   729 		TBool retrieve_chain;
   835 		TBool retrieve_chain;
   730 
   836 
   731 		if (m_state == EHandlingChainQuery)
   837 		if (m_state == EHandlingChainQuery)
   740 		TInt allowed_user_cert_count = m_allowed_user_certs.Count();
   846 		TInt allowed_user_cert_count = m_allowed_user_certs.Count();
   741 		TInt err(KErrNone);
   847 		TInt err(KErrNone);
   742 		
   848 		
   743 		if(allowed_user_cert_count > 0)
   849 		if(allowed_user_cert_count > 0)
   744 		{
   850 		{
   745 			TRAP(err, m_cert_if->ReadCertificateL(m_allowed_user_certs[index], retrieve_chain));			
   851 			TRAP(err, m_cert_if->ReadCertificateL(*m_allowed_user_certs[index], retrieve_chain));			
   746 		}
   852 		}
   747 		if (err != KErrNone || allowed_user_cert_count <= 0)
   853 		if (err != KErrNone || allowed_user_cert_count <= 0)
   748 		{
   854 		{
   749 			EAP_TRACE_ERROR(
   855 			EAP_TRACE_ERROR(
   750 			m_am_tools,
   856 			m_am_tools,
   780 			default:
   886 			default:
   781 				return;
   887 				return;
   782 			}
   888 			}
   783 		}
   889 		}
   784 	}
   890 	}
   785 	else if (m_state == EHandlingManualIdentityQuery)
       
   786 	{
       
   787 		// Convert to 8-bit text
       
   788 		TBuf8<KIdentityFieldLength> buf;
       
   789 		buf.Copy(m_identity_info->iUsername);
       
   790 		
       
   791 		eap_status_e status = m_manual_username.set_copy_of_buffer(
       
   792 			buf.Ptr(), 
       
   793 			buf.Size());
       
   794 
       
   795 		if (status != eap_status_ok)
       
   796 		{
       
   797 			EAP_TRACE_DEBUG(
       
   798 				m_am_tools,
       
   799 				TRACE_FLAGS_DEFAULT,
       
   800 				(EAPL("ERROR: EAP-TLS: EHandlingIdentityQuery: Cannot read manual username.\n")));
       
   801 
       
   802 			get_am_partner()->complete_eap_identity_query(
       
   803 				0, // 0 because identity query failed
       
   804 				&m_receive_network_id,
       
   805 				m_eap_identifier,
       
   806 				status,
       
   807 				false,
       
   808 				0,
       
   809 				false,
       
   810 				0);
       
   811 		}
       
   812 
       
   813 		buf.Copy(m_identity_info->iRealm);
       
   814 		status = m_manual_realm.set_copy_of_buffer(
       
   815 			buf.Ptr(), 
       
   816 			buf.Size());
       
   817 
       
   818 		if (status != eap_status_ok)
       
   819 		{
       
   820 			EAP_TRACE_DEBUG(
       
   821 				m_am_tools,
       
   822 				TRACE_FLAGS_DEFAULT,
       
   823 				(EAPL("ERROR: EAP-TLS: EHandlingIdentityQuery: Cannot read manual realm.\n")));
       
   824 
       
   825 			get_am_partner()->complete_eap_identity_query(
       
   826 				0, // 0 because identity query failed
       
   827 				&m_receive_network_id,
       
   828 				m_eap_identifier,
       
   829 				status,
       
   830 				false,
       
   831 				0,
       
   832 				false,
       
   833 				0);
       
   834 		}
       
   835 
       
   836 		// This must be true
       
   837 		m_use_manual_realm = true; 
       
   838 		
       
   839 		if (m_identity_info->iUseManualUsername)
       
   840 		{
       
   841 			m_use_manual_username = true;
       
   842 		}
       
   843 		else
       
   844 		{
       
   845 			m_use_manual_username = false;
       
   846 		}
       
   847 		
       
   848 		
       
   849 		get_am_partner()->complete_eap_identity_query(
       
   850 			0, // 0 because identity query failed
       
   851 			&m_receive_network_id,
       
   852 			m_eap_identifier,
       
   853 			eap_status_ok,
       
   854 			m_use_manual_username,
       
   855 			&m_manual_username,
       
   856 			m_use_manual_realm,
       
   857 			&m_manual_realm);
       
   858 		
       
   859 		TRAPD(err, SaveManualIdentityL( 
       
   860 				m_identity_info->iUseManualUsername,
       
   861 				m_identity_info->iUsername,
       
   862 				ETrue,
       
   863 				m_identity_info->iRealm));
       
   864 
       
   865 		(void)EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(err));
       
   866 
       
   867 		// Ignore return value on purpose. It's not fatal if saving fails.							
       
   868 					
       
   869 		delete m_identity_info; 
       
   870 		m_identity_info = 0;
       
   871 
       
   872 	}
       
   873 
   891 
   874 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
   892 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
   875 }
   893 }
   876 
   894 
   877 //--------------------------------------------------
   895 //--------------------------------------------------
   878 
   896 #ifdef USE_FAST_EAP_TYPE
   879 //
   897 //
   880 
   898 // ---------------------------------------------------------
       
   899 // eap_am_type_tls_peap_symbian_c::CreateDeviceSeedAsync()
       
   900 // ---------------------------------------------------------
       
   901 //
       
   902 eap_status_e eap_am_type_tls_peap_symbian_c::CreateDeviceSeedAsync()
       
   903 {   
       
   904     EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   905 
       
   906     EAP_TRACE_DEBUG_SYMBIAN(
       
   907         (_L("eap_am_type_tls_peap_symbian_c::CreateDeviceSeedAsync-Start ActiveStatus=%d"),
       
   908         IsActive()));       
       
   909     
       
   910     if ( IsActive() )
       
   911     {
       
   912         EAP_TRACE_DEBUG_SYMBIAN(
       
   913             (_L("CreateDeviceSeedAsync: Already active when tried to create device seed")));       
       
   914         
       
   915         return eap_status_device_busy;
       
   916     }
       
   917 
       
   918     eap_status_e status(eap_status_ok); 
       
   919     
       
   920     m_state = EHandlingDeviceSeedQuery;
       
   921         
       
   922     // Create MMETEL connection.
       
   923     TRAPD(error, CreateMMETelConnectionL());
       
   924     if(error !=KErrNone)
       
   925     {
       
   926         return m_am_tools->convert_am_error_to_eapol_error(error);
       
   927     }
       
   928     
       
   929     iPhone.GetPhoneId( iStatus, iDeviceId ); 
       
   930 
       
   931     SetActive();
       
   932     return status;
       
   933 } // eap_am_type_tls_peap_symbian_c::CreateDeviceSeedAsynch()
       
   934 
       
   935 //--------------------------------------------------
       
   936 
       
   937 void eap_am_type_tls_peap_symbian_c::CompleteCreateDeviceSeedL( TInt aStatus )
       
   938 {
       
   939     EAP_TRACE_DEBUG_SYMBIAN(
       
   940             (_L("eap_am_type_tls_peap_symbian_c::CompleteCreateDeviceSeedL aStatus=%d"),
       
   941             iStatus.Int()));
       
   942     if ( aStatus != KErrNone )
       
   943         {
       
   944         EAP_TRACE_DEBUG_SYMBIAN(
       
   945                 (_L("eap_am_type_tls_peap_symbian_c::CompleteCreateDeviceSeedL ERROR: aStatus=%d"),
       
   946                 iStatus.Int()));        
       
   947         }
       
   948     EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Manufacturer"),
       
   949         iDeviceId.iManufacturer.Ptr(),
       
   950         iDeviceId.iManufacturer.Size()));
       
   951     EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Model"),
       
   952         iDeviceId.iModel.Ptr(),
       
   953         iDeviceId.iModel.Size()));
       
   954     EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Revision"),
       
   955         iDeviceId.iRevision.Ptr(),
       
   956         iDeviceId.iRevision.Size()));
       
   957     EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("SerialNumber"),
       
   958         iDeviceId.iSerialNumber.Ptr(),
       
   959         iDeviceId.iSerialNumber.Size()));
       
   960         
       
   961     // Combine all the above four items.            
       
   962     TBuf<KMaxDeviceSeedLength> deviceSeed16;    
       
   963     deviceSeed16 += iDeviceId.iManufacturer;
       
   964     deviceSeed16 += iDeviceId.iModel;
       
   965     deviceSeed16 += iDeviceId.iSerialNumber;
       
   966         
       
   967     TBuf8<KMaxDeviceSeedSize> deviceSeed8;
       
   968     deviceSeed8.Copy(deviceSeed16);     
       
   969 
       
   970     if ( iPacStoreDeviceSeed == NULL )
       
   971         {
       
   972         iPacStoreDeviceSeed  = new  eap_variable_data_c(m_am_tools);
       
   973         if ( iPacStoreDeviceSeed == NULL )
       
   974             {
       
   975             User::Leave( KErrNoMemory );
       
   976             }
       
   977         }
       
   978 
       
   979 #if defined(USE_EAP_CONFIGURATION_TO_SKIP_USER_INTERACTIONS)
       
   980     const char DUMMY_SEED[]="empty";
       
   981  
       
   982 
       
   983     if (m_skip_user_interactions == true)
       
   984         {
       
   985         iPacStoreDeviceSeed->set_copy_of_buffer(DUMMY_SEED, sizeof(DUMMY_SEED));
       
   986         }
       
   987     else
       
   988 #endif //#if defined(USE_EAP_CONFIGURATION_TO_SKIP_USER_INTERACTIONS)
       
   989         {
       
   990         
       
   991         if ( iPacStoreDeviceSeed != NULL )
       
   992             {
       
   993             if( deviceSeed8.Size() > 0)
       
   994                 {
       
   995                 iPacStoreDeviceSeed->set_copy_of_buffer(
       
   996                     deviceSeed8.Ptr(),
       
   997                     deviceSeed8.Size());
       
   998                 }
       
   999             }
       
  1000         }
       
  1001     DisconnectMMETel();
       
  1002     
       
  1003     ContinueInitializePacStore();
       
  1004 
       
  1005 } // eap_am_type_tls_peap_symbian_c::CompleteCreateDeviceSeedL()
       
  1006 
       
  1007 #endif
       
  1008 //--------------------------------------------------
   881 
  1009 
   882 void eap_am_type_tls_peap_symbian_c::DoCancel()
  1010 void eap_am_type_tls_peap_symbian_c::DoCancel()
   883 {
  1011 {
   884 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);	
  1012 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);	
   885     
  1013     
   887 
  1015 
   888 	if(m_cert_if->IsActive())
  1016 	if(m_cert_if->IsActive())
   889 	{
  1017 	{
   890 		m_cert_if->Cancel();		
  1018 		m_cert_if->Cancel();		
   891 	}
  1019 	}
   892 
  1020 	if (iEapAuthNotifier != 0)
   893 	if ( iEapTtlsPapActive )
  1021 		{
   894 		{
  1022 		iEapAuthNotifier->Cancel();
   895 		if ( iEapTtlsPapActive->IsActive() )
  1023 		}
   896 			{
  1024 
   897 			EAP_TRACE_DEBUG_SYMBIAN(
  1025 
   898 				( _L( " eap_am_type_tls_peap_symbian_c::DoCancel() \
       
   899 				Cancelling iEapTtlsPapActive." ) ) );
       
   900 			iEapTtlsPapActive->Cancel();
       
   901 			}
       
   902 		}
       
   903 	
       
   904 #if defined(USE_FAST_EAP_TYPE)
  1026 #if defined(USE_FAST_EAP_TYPE)
   905 
  1027 
   906 	m_partner->cancel_timer(
  1028 	m_partner->cancel_timer(
   907 			this, 
  1029 			this, 
   908 			KRemoveIAPReferenceTimerID);
  1030 			KRemoveIAPReferenceTimerID);
   917 
  1039 
   918 	m_partner->cancel_timer(
  1040 	m_partner->cancel_timer(
   919 			this, 
  1041 			this, 
   920 			KHandleReadPacstoreTimerID);
  1042 			KHandleReadPacstoreTimerID);
   921 
  1043 
   922 	if( m_is_notifier_connected )
       
   923 	{
       
   924 		EAP_TRACE_DEBUG_SYMBIAN(
       
   925 			(_L(" eap_am_type_tls_peap_symbian_c::DoCancel - calling m_notifier.CancelNotifier")));
       
   926 		if(IsActive())
       
   927 			{
       
   928 			TInt error = m_notifier.CancelNotifier(KEapFastNotifierUid);
       
   929 			EAP_TRACE_DEBUG_SYMBIAN(
       
   930 				(_L("eap_am_type_tls_peap_symbian_c::DoCancel:CancelNotifier=%d"),
       
   931 				error));
       
   932 			}
       
   933 
       
   934 		m_notifier.Close(); // Call close only if it is connected.	
       
   935 			
       
   936 		m_is_notifier_connected = false;
       
   937 
       
   938 	} // End: if( m_is_notifier_connected )		
       
   939 
  1044 
   940 #endif // #if defined(USE_FAST_EAP_TYPE)
  1045 #endif // #if defined(USE_FAST_EAP_TYPE)
   941 	
  1046 	
   942 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
  1047 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
   943 }
  1048 }
   944 
  1049 
   945 //--------------------------------------------------
  1050 //--------------------------------------------------
   946 
  1051 
   947 //
  1052 //
   948 
       
   949 eap_status_e eap_am_type_tls_peap_symbian_c::SaveManualIdentityL( 
  1053 eap_status_e eap_am_type_tls_peap_symbian_c::SaveManualIdentityL( 
   950 	const TBool use_manual_username,
  1054 	const TBool use_manual_username,
   951 	TDesC& manual_username,
  1055 	TDesC& manual_username,
   952 	const TBool use_manual_realm,
  1056 	const TBool use_manual_realm,
   953 	TDesC& manual_realm)
  1057 	TDesC& manual_realm)
   954 {
  1058 {
   955 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  1059 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   956 	
  1060 	
   957 	// Validate length.
  1061 	// Validate length.
   958 	if(manual_username.Length() > KMaxManualUsernameLengthInDB
  1062 	if(manual_username.Length() > KMaxUsernameLengthInDB
   959 		|| manual_realm.Length() > KMaxManualRealmLengthInDB)
  1063 		|| manual_realm.Length() > KMaxRealmLengthInDB)
   960 	{
  1064 	{
   961 		// Username or realm too long. Can not be stored in DB.
  1065 		// Username or realm too long. Can not be stored in DB.
   962 		EAP_TRACE_DEBUG_SYMBIAN((_L("eap_am_type_tls_peap_symbian_c::SaveManualIdentityL: Too long username or realm. Length: UN=%d, Realm=%d\n"),
  1066 		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"),
   963 		manual_username.Length(), manual_realm.Length()));
  1067 		manual_username.Length(), manual_realm.Length()));
   964 		
  1068 		
   965 		User::Leave(KErrArgument);
  1069 		User::Leave(KErrArgument);
   966 	}
  1070 	}
   967 		
  1071 		
   968 	HBufC* sqlbuf = HBufC::NewLC(KMaxSqlQueryLength);
  1072 	HBufC* sqlbuf = HBufC::NewLC(KMaxSqlQueryLength);
   969 	TPtr sqlStatement = sqlbuf->Des();
  1073 	TPtr sqlStatement = sqlbuf->Des();
   970 
  1074 
   971 	RDbView view;
  1075 	RDbView view;
   972 
  1076 
   973 	_LIT(KSQL, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d");
  1077 	_LIT(KSQL, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
   974 	
  1078 	
   975 	sqlStatement.Format(KSQL, &m_db_table_name, 
  1079 	sqlStatement.Format(
   976 		&KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);
  1080 		KSQL,
       
  1081 		&m_db_table_name, 
       
  1082 		&KServiceType,
       
  1083 		m_index_type,
       
  1084 		&KServiceIndex,
       
  1085 		m_index,
       
  1086 		&KTunnelingTypeVendorId,
       
  1087 		m_tunneling_type.get_vendor_id(),
       
  1088 		&KTunnelingType, 
       
  1089 		m_tunneling_type.get_vendor_type());
   977 	
  1090 	
   978 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));	
  1091 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));	
   979 	CleanupClosePushL(view);
  1092 	CleanupClosePushL(view);
   980 	User::LeaveIfError(view.EvaluateAll());
  1093 	User::LeaveIfError(view.EvaluateAll());
   981 
  1094 
  1049 // eap_am_type_tls_peap_symbian_c::SendErrorNotification()
  1162 // eap_am_type_tls_peap_symbian_c::SendErrorNotification()
  1050 // ---------------------------------------------------------
  1163 // ---------------------------------------------------------
  1051 //
  1164 //
  1052 void eap_am_type_tls_peap_symbian_c::SendErrorNotification(
  1165 void eap_am_type_tls_peap_symbian_c::SendErrorNotification(
  1053 	const eap_status_e aError )
  1166 	const eap_status_e aError )
  1054 	{
  1167 {
  1055 	send_error_notification( aError );
  1168 	send_error_notification( aError );
  1056 	}
  1169 }
       
  1170 
  1057 //--------------------------------------------------
  1171 //--------------------------------------------------
  1058 
  1172 
  1059 #if defined(USE_FAST_EAP_TYPE)
  1173 #if defined(USE_FAST_EAP_TYPE)
  1060 
  1174 
  1061 EAP_FUNC_EXPORT void eap_am_type_tls_peap_symbian_c::set_tls_application(
  1175 EAP_FUNC_EXPORT void eap_am_type_tls_peap_symbian_c::set_tls_application(
  1065 
  1179 
  1066 	m_tls_application = tls_application;
  1180 	m_tls_application = tls_application;
  1067 
  1181 
  1068 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1182 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1069 }
  1183 }
  1070 
       
  1071 
       
  1072 
       
  1073 
  1184 
  1074 // ---------------------------------------------------------
  1185 // ---------------------------------------------------------
  1075 // eap_am_type_tls_peap_symbian_c::IsProvisioningMode()
  1186 // eap_am_type_tls_peap_symbian_c::IsProvisioningMode()
  1076 // ---------------------------------------------------------
  1187 // ---------------------------------------------------------
  1077 //
  1188 //
  1078 TBool eap_am_type_tls_peap_symbian_c::IsProvisioningMode()
  1189 TBool eap_am_type_tls_peap_symbian_c::IsProvisioningMode()
  1079 	{
  1190 {
  1080 	return ( m_provisioning_mode ==
  1191 	return ( m_provisioning_mode ==
  1081         eap_fast_completion_operation_server_authenticated_provisioning_mode ) ? ETrue : EFalse;
  1192         eap_fast_completion_operation_server_authenticated_provisioning_mode ) ? ETrue : EFalse;
  1082 	}
  1193 }
  1083 
       
  1084 
  1194 
  1085 // ---------------------------------------------------------
  1195 // ---------------------------------------------------------
  1086 // eap_am_type_tls_peap_symbian_c::CompleteQueryUserPermissionForAid()
  1196 // eap_am_type_tls_peap_symbian_c::CompleteQueryUserPermissionForAid()
  1087 // ---------------------------------------------------------
  1197 // ---------------------------------------------------------
  1088 //
  1198 //
  1089 eap_status_e
  1199 eap_status_e
  1090 eap_am_type_tls_peap_symbian_c::CompleteQueryUserPermissionForAid(
  1200 eap_am_type_tls_peap_symbian_c::CompleteQueryUserPermissionForAid(
  1091 	EEapFastNotifierUserAction aUserAction )
  1201 	EEapFastNotifierUserAction aUserAction )
  1092 	{
  1202 {
  1093 	EAP_TRACE_DEBUG_SYMBIAN(
  1203 	EAP_TRACE_DEBUG_SYMBIAN(
  1094 			(_L("eap_am_type_tls_peap_symbian_c::CompleteQueryUserPermissionForAid")));
  1204 			(_L("eap_am_type_tls_peap_symbian_c::CompleteQueryUserPermissionForAid")));
  1095 	if ( aUserAction == EEapFastNotifierUserActionOk )
  1205 	if ( aUserAction == EEapFastNotifierUserActionOk )
  1096 		{
  1206 		{
  1097 		EAP_TRACE_DEBUG_SYMBIAN(
  1207 		EAP_TRACE_DEBUG_SYMBIAN(
  1111   		    complete_query_user_permission_for_A_ID(
  1221   		    complete_query_user_permission_for_A_ID(
  1112   			    eap_status_user_cancel_authentication,
  1222   			    eap_status_user_cancel_authentication,
  1113   		        m_pending_operation );
  1223   		        m_pending_operation );
  1114   		} 
  1224   		} 
  1115 	return m_eap_fast_completion_status;
  1225 	return m_eap_fast_completion_status;
  1116 	}
  1226 }
  1117 
       
  1118 
  1227 
  1119 #endif //#if defined(USE_FAST_EAP_TYPE)
  1228 #endif //#if defined(USE_FAST_EAP_TYPE)
  1120 
  1229 
  1121 //--------------------------------------------------
  1230 //--------------------------------------------------
  1122 
  1231 
  1196 
  1305 
  1197 		if (err != KErrNone)
  1306 		if (err != KErrNone)
  1198 		{
  1307 		{
  1199 			EAP_TRACE_ERROR(m_am_tools, 
  1308 			EAP_TRACE_ERROR(m_am_tools, 
  1200 				TRACE_FLAGS_DEFAULT, (
  1309 				TRACE_FLAGS_DEFAULT, (
  1201 				EAPL("eap_am_type_tls_peap_symbian_c::configure - ReadCertRowsToArrayL, User cert, Error =%d \n"),
  1310 				EAPL("eap_am_type_tls_peap_symbian_c::configure(): ReadCertRowsToArrayL, User cert, Error =%d \n"),
  1202 				err));
  1311 				err));
  1203 		
  1312 		
  1204 			// Convert the leave error code to EAPOL stack error code.
  1313 			// Convert the leave error code to EAPOL stack error code.
  1205 			status = m_am_tools->convert_am_error_to_eapol_error(err);
  1314 			status = m_am_tools->convert_am_error_to_eapol_error(err);
  1206 			return EAP_STATUS_RETURN(m_am_tools, status);
  1315 			return EAP_STATUS_RETURN(m_am_tools, status);
  1222 			m_allowed_ca_certs));
  1331 			m_allowed_ca_certs));
  1223 		if (err != KErrNone)
  1332 		if (err != KErrNone)
  1224 		{
  1333 		{
  1225 			EAP_TRACE_ERROR(m_am_tools, 
  1334 			EAP_TRACE_ERROR(m_am_tools, 
  1226 				TRACE_FLAGS_DEFAULT, (
  1335 				TRACE_FLAGS_DEFAULT, (
  1227 				EAPL("eap_am_type_tls_peap_symbian_c::configure - ReadCertRowsToArrayL, CA cert, Error =%d \n"),
  1336 				EAPL("eap_am_type_tls_peap_symbian_c::configure(): ReadCertRowsToArrayL, CA cert, Error =%d \n"),
  1228 				err));
  1337 				err));
  1229 		
  1338 		
  1230 			// Convert the leave error code to EAPOL stack error code.
  1339 			// Convert the leave error code to EAPOL stack error code.
  1231 			status = m_am_tools->convert_am_error_to_eapol_error(err);			
  1340 			status = m_am_tools->convert_am_error_to_eapol_error(err);			
  1232 			return EAP_STATUS_RETURN(m_am_tools, status);
  1341 			return EAP_STATUS_RETURN(m_am_tools, status);
  1249 			m_allowed_cipher_suites));
  1358 			m_allowed_cipher_suites));
  1250 		if (err != KErrNone)
  1359 		if (err != KErrNone)
  1251 		{
  1360 		{
  1252 			EAP_TRACE_ERROR(m_am_tools, 
  1361 			EAP_TRACE_ERROR(m_am_tools, 
  1253 				TRACE_FLAGS_DEFAULT, (
  1362 				TRACE_FLAGS_DEFAULT, (
  1254 				EAPL("eap_am_type_tls_peap_symbian_c::configure - ReadUintRowsToArrayL, CipherSuit, Error =%d \n"),
  1363 				EAPL("eap_am_type_tls_peap_symbian_c::configure(): ReadUintRowsToArrayL, CipherSuit, Error =%d \n"),
  1255 				err));
  1364 				err));
  1256 
  1365 
  1257 			// Convert the leave error code to EAPOL stack error code.
  1366 			// Convert the leave error code to EAPOL stack error code.
  1258 			status = m_am_tools->convert_am_error_to_eapol_error(err);			
  1367 			status = m_am_tools->convert_am_error_to_eapol_error(err);			
  1259 			return EAP_STATUS_RETURN(m_am_tools, status);
  1368 			return EAP_STATUS_RETURN(m_am_tools, status);
  1272 #endif
  1381 #endif
  1273 
  1382 
  1274 		
  1383 		
  1275 		)
  1384 		)
  1276 	{
  1385 	{
  1277 #ifdef USE_EAP_EXPANDED_TYPES
       
  1278 
       
  1279 		TRAPD(err, EapTlsPeapUtils::GetTunnelingExpandedEapDataL(
  1386 		TRAPD(err, EapTlsPeapUtils::GetTunnelingExpandedEapDataL(
  1280 			m_database,
  1387 			m_database,
  1281 			m_am_tools,
  1388 			m_am_tools,
  1282 			m_enabled_tunneling_exp_eap_array,
  1389 			m_enabled_tunneling_exp_eap_array,
  1283 			m_disabled_tunneling_exp_eap_array,
  1390 			m_disabled_tunneling_exp_eap_array,
  1284 			m_index_type,
  1391 			m_index_type,
  1285 			m_index,
  1392 			m_index,
  1286 			m_tunneling_type,
  1393 			m_tunneling_type,
  1287 			m_current_eap_type));
  1394 			m_current_eap_type));
  1288 
       
  1289 #else
       
  1290 		TRAPD(err, EapTlsPeapUtils::GetEapDataL(
       
  1291 			m_database,
       
  1292 			m_am_tools,
       
  1293 			m_iap_eap_array,
       
  1294 			m_index_type,
       
  1295 			m_index,
       
  1296 			m_tunneling_type,
       
  1297 			m_current_eap_type));
       
  1298 
       
  1299 #endif //#ifdef USE_EAP_EXPANDED_TYPES
       
  1300 	
  1395 	
  1301 		if (err != KErrNone)
  1396 		if (err != KErrNone)
  1302 		{
  1397 		{
  1303 			EAP_TRACE_ERROR(m_am_tools, 
  1398 			EAP_TRACE_ERROR(m_am_tools, 
  1304 				TRACE_FLAGS_DEFAULT, (
  1399 				TRACE_FLAGS_DEFAULT, (
  1305 				EAPL("eap_am_type_tls_peap_symbian_c::configure - GetEapDataL or GetTunnelingExpandedEapDataL, Error =%d \n"),
  1400 				EAPL("eap_am_type_tls_peap_symbian_c::configure(): GetEapDataL or GetTunnelingExpandedEapDataL, Error =%d \n"),
  1306 				err));
  1401 				err));
  1307 
  1402 
  1308 			// Convert the leave error code to EAPOL stack error code.
  1403 			// Convert the leave error code to EAPOL stack error code.
  1309 			status = m_am_tools->convert_am_error_to_eapol_error(err);			
  1404 			status = m_am_tools->convert_am_error_to_eapol_error(err);			
  1310 			return EAP_STATUS_RETURN(m_am_tools, status);
  1405 			return EAP_STATUS_RETURN(m_am_tools, status);
  1365 		}
  1460 		}
  1366 	}
  1461 	}
  1367 
  1462 
  1368 	//----------------------------------------------------------
  1463 	//----------------------------------------------------------
  1369 
  1464 
       
  1465 	if (m_is_client == true)
       
  1466 	{
       
  1467 		eap_variable_data_c use_automatic_ca_certificate(m_am_tools);
       
  1468 
       
  1469 		eap_status_e status = m_partner->read_configure(
       
  1470 			cf_str_EAP_TLS_PEAP_use_automatic_ca_certificate.get_field(),
       
  1471 			&use_automatic_ca_certificate);
       
  1472 		if (status == eap_status_ok
       
  1473 			&& use_automatic_ca_certificate.get_is_valid_data() == true)
       
  1474 		{
       
  1475 			u32_t *use_automatic_ca_certificate_flag = reinterpret_cast<u32_t *>(
       
  1476 				use_automatic_ca_certificate.get_data(sizeof(u32_t)));
       
  1477 			if (use_automatic_ca_certificate_flag != 0
       
  1478 				&& *use_automatic_ca_certificate_flag != 0)
       
  1479 			{
       
  1480 				m_use_automatic_ca_certificate = true;
       
  1481 			}
       
  1482 		}
       
  1483 	}
       
  1484 
       
  1485 	//----------------------------------------------------------
       
  1486 
  1370 	// This is only for server
  1487 	// This is only for server
  1371 	{
  1488 	{
  1372 		eap_variable_data_c cipher_suite(m_am_tools);
  1489 		eap_variable_data_c cipher_suite(m_am_tools);
  1373 
  1490 
  1374 		eap_status_e status = type_configure_read(
  1491 		eap_status_e status = type_configure_read(
  1384 			m_cipher_suite = (tls_cipher_suites_e)*reinterpret_cast<u32_t *>(
  1501 			m_cipher_suite = (tls_cipher_suites_e)*reinterpret_cast<u32_t *>(
  1385 				cipher_suite.get_data(sizeof(u32_t)));
  1502 				cipher_suite.get_data(sizeof(u32_t)));
  1386 		}
  1503 		}
  1387 	}
  1504 	}
  1388 	
  1505 	
  1389 	//----------------------------------------------------------
       
  1390 
       
  1391 #ifndef USE_EAP_EXPANDED_TYPES // This is not needed it seems. Still keeping it for normal EAP types.
       
  1392 								  // Intention of this is to get tunneled EAP types, but m_tunneled_type is not used
       
  1393 								  // anywhere other than this place.
       
  1394 
       
  1395 	if (m_current_eap_type == eap_type_peap
       
  1396 #if defined(USE_TTLS_EAP_TYPE)
       
  1397 		|| m_current_eap_type == eap_type_ttls
       
  1398 #endif // #if defined(USE_TTLS_EAP_TYPE)
       
  1399 
       
  1400 #if defined(USE_FAST_EAP_TYPE)
       
  1401 		|| m_current_eap_type == eap_type_fast
       
  1402 #endif
       
  1403 	
       
  1404 		
       
  1405 		)
       
  1406 	{
       
  1407 		eap_variable_data_c tunneled_type(m_am_tools);
       
  1408 
       
  1409 		eap_status_e status = type_configure_read(
       
  1410 			cf_str_PEAP_tunneled_eap_type_hex_data.get_field(),
       
  1411 			&tunneled_type);
       
  1412 		if (status == eap_status_illegal_configure_type)
       
  1413 		{
       
  1414 			status = m_partner->read_configure(
       
  1415 				cf_str_PEAP_tunneled_eap_type_u32_t.get_field(),
       
  1416 				&tunneled_type);
       
  1417 		}
       
  1418 		if (status != eap_status_ok)
       
  1419 		{
       
  1420 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1421 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1422 		}
       
  1423 		else if (tunneled_type.get_is_valid_data() == true
       
  1424 			&& tunneled_type.get_data_length() == sizeof(u32_t)
       
  1425 			&& tunneled_type.get_data(sizeof(u32_t)) != 0)
       
  1426 		{
       
  1427 			m_tunneled_type = static_cast<eap_type_value_e>(
       
  1428 				*reinterpret_cast<u32_t *>(tunneled_type.get_data(sizeof(u32_t))));
       
  1429 		}
       
  1430 		else if (tunneled_type.get_data_length()
       
  1431 				 == eap_expanded_type_c::get_eap_expanded_type_size()
       
  1432 				 && tunneled_type.get_data(tunneled_type.get_data_length()) != 0)
       
  1433 		{
       
  1434 			eap_expanded_type_c eap_type(eap_type_none);
       
  1435 
       
  1436 			status = eap_type.set_expanded_type_data(
       
  1437 				m_am_tools,
       
  1438 				&tunneled_type);
       
  1439 			if (status != eap_status_ok)
       
  1440 			{
       
  1441 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1442 				return EAP_STATUS_RETURN(m_am_tools, status);
       
  1443 			}
       
  1444 
       
  1445 			status = eap_type.get_type_data(
       
  1446 				m_am_tools,
       
  1447 				&m_tunneled_type);
       
  1448 			if (status != eap_status_ok)
       
  1449 			{
       
  1450 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1451 				return EAP_STATUS_RETURN(m_am_tools, status);
       
  1452 			}
       
  1453 		}
       
  1454 	}
       
  1455   
       
  1456 #endif //#ifndef USE_EAP_EXPANDED_TYPES
       
  1457 
       
  1458 	//----------------------------------------------------------
  1506 	//----------------------------------------------------------
  1459 
  1507 
  1460 	{
  1508 	{
  1461 		eap_variable_data_c use_manual_username(m_am_tools);
  1509 		eap_variable_data_c use_manual_username(m_am_tools);
  1462 
  1510 
  1601 		// Read Maximum Session Validity Time from the config file
  1649 		// Read Maximum Session Validity Time from the config file
  1602 		eap_variable_data_c sessionTimeFromFile(m_am_tools);
  1650 		eap_variable_data_c sessionTimeFromFile(m_am_tools);
  1603 		
  1651 		
  1604 		eap_status_e status(eap_status_ok);
  1652 		eap_status_e status(eap_status_ok);
  1605 
  1653 
  1606 		switch (m_current_eap_vendor_type)
  1654 		if (m_current_eap_type == eap_type_tls)
  1607 		{
  1655 		{
  1608 		case eap_type_tls:
  1656 			status = m_partner->read_configure(
  1609 			{
  1657 				cf_str_EAP_TLS_max_session_validity_time.get_field(),
  1610 				status = m_partner->read_configure(
  1658 				&sessionTimeFromFile);
  1611 					cf_str_EAP_TLS_max_session_validity_time.get_field(),
  1659 		}
  1612 					&sessionTimeFromFile);
  1660 		else if (m_current_eap_type == eap_type_peap)
  1613 			}
  1661 		{
  1614 			break;
  1662 			status = m_partner->read_configure(
  1615 
  1663 				cf_str_EAP_PEAP_max_session_validity_time.get_field(),
  1616 		case eap_type_peap:
  1664 				&sessionTimeFromFile);
  1617 			{
  1665 		}
  1618 				status = m_partner->read_configure(
  1666 		else if (m_current_eap_type == eap_type_ttls)
  1619 					cf_str_EAP_PEAP_max_session_validity_time.get_field(),
  1667 		{
  1620 					&sessionTimeFromFile);
  1668 			status = m_partner->read_configure(
  1621 			}
  1669 				cf_str_EAP_TTLS_max_session_validity_time.get_field(),
  1622 			break;
  1670 				&sessionTimeFromFile);
  1623 
  1671 		}
  1624 		case eap_type_ttls:
  1672 		else if (m_current_eap_type == eap_type_ttls_plain_pap)
  1625 			{
  1673 		{
  1626 				status = m_partner->read_configure(
       
  1627 					cf_str_EAP_TTLS_max_session_validity_time.get_field(),
       
  1628 					&sessionTimeFromFile);
       
  1629 			}
       
  1630 			break;
       
  1631 
       
  1632 		case eap_type_ttls_plain_pap:
       
  1633 			{
       
  1634 			// read PAP session time
  1674 			// read PAP session time
  1635 			status = m_partner->read_configure(
  1675 			status = m_partner->read_configure(
  1636 				cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time.get_field(),
  1676 				cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time.get_field(),
  1637 				&sessionTimeFromFile );
  1677 				&sessionTimeFromFile );
  1638 			}
  1678 		}
  1639 			break;
       
  1640 			
       
  1641 #if defined(USE_FAST_EAP_TYPE)
  1679 #if defined(USE_FAST_EAP_TYPE)
  1642 		case eap_type_fast:
  1680 		else if (m_current_eap_type == eap_type_fast)
  1643 			{
  1681 		{
  1644 				status = m_partner->read_configure(
  1682 			status = m_partner->read_configure(
  1645 					cf_str_EAP_FAST_max_session_validity_time.get_field(),
  1683 				cf_str_EAP_FAST_max_session_validity_time.get_field(),
  1646 					&sessionTimeFromFile);
  1684 				&sessionTimeFromFile);
  1647 			}
  1685 		}
  1648 			break;
       
  1649 #endif
  1686 #endif
  1650 			
  1687 		else
  1651 		default:
  1688 		{
  1652 			{
  1689 			// Should never happen
  1653 				// Should never happen
  1690 			EAP_TRACE_ERROR(m_am_tools, 
  1654 				EAP_TRACE_ERROR(m_am_tools, 
  1691 				TRACE_FLAGS_DEFAULT, (
  1655 					TRACE_FLAGS_DEFAULT, (
  1692 				EAPL("eap_am_type_tls_peap_symbian_c::configure(): Unsupported EAP type, m_current_eap_vendor_type=0xfe%06x%08x\n"),
  1656 					EAPL("eap_am_type_tls_peap_symbian_c::configure - Unsupported EAP type, m_current_eap_vendor_type=%d \n"),
  1693 				m_current_eap_type.get_vendor_id(),
  1657 					m_current_eap_vendor_type));
  1694 				m_current_eap_type.get_vendor_type()));
  1658 			}
  1695 		}
  1659 		}	
       
  1660 
  1696 
  1661 		// set m_max_session_time
  1697 		// set m_max_session_time
  1662 		if (status == eap_status_ok
  1698 		if (status == eap_status_ok
  1663 			&& sessionTimeFromFile.get_is_valid_data() == true
  1699 			&& sessionTimeFromFile.get_is_valid_data() == true
  1664 			&& sessionTimeFromFile.get_data_length() == sizeof(u32_t))
  1700 			&& sessionTimeFromFile.get_data_length() == sizeof(u32_t))
  1755 	
  1791 	
  1756 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - -	
  1792 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - -	
  1757 	
  1793 	
  1758 	status = eap_status_ok;
  1794 	status = eap_status_ok;
  1759 
  1795 
  1760 	if (m_allowed_ca_certs.Count() == 0)
  1796 	if (m_use_automatic_ca_certificate == false)
  1761 	{		
  1797 	{
  1762 	// needed because of nonworking wrong settings
  1798 		if (m_allowed_ca_certs.Count() == 0)
       
  1799 		{
       
  1800 			// needed because of nonworking wrong settings
  1763 #if defined(USE_FAST_EAP_TYPE)
  1801 #if defined(USE_FAST_EAP_TYPE)
  1764 		if(m_current_eap_type == eap_type_fast &&
  1802 			if(m_current_eap_type == eap_type_fast
  1765 			m_serv_auth_prov_mode != true)
  1803 				&& m_serv_auth_prov_mode != true)
  1766 		{
  1804 			{
  1767 			// In the case of EAP-FAST, CA cert is must if m_serv_auth_prov_mode is TRUE.
  1805 				// In the case of EAP-FAST, CA cert is must if m_serv_auth_prov_mode is TRUE.
  1768 			status = eap_status_ok;
  1806 				status = eap_status_ok;
       
  1807 				
       
  1808 				EAP_TRACE_DEBUG(
       
  1809 					m_am_tools, 
       
  1810 					TRACE_FLAGS_DEFAULT,
       
  1811 					(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")));
       
  1812 			}
       
  1813 			else	
       
  1814 #endif // #if defined(USE_FAST_EAP_TYPE)
       
  1815 			{
       
  1816 				EAP_TRACE_ERROR(
       
  1817 					m_am_tools, 
       
  1818 					TRACE_FLAGS_DEFAULT,
       
  1819 					(EAPL("eap_am_type_tls_peap_symbian_c::configure(): Error - No CA certificate\n")));
  1769 			
  1820 			
  1770 			EAP_TRACE_DEBUG(m_am_tools, 
  1821 				// No root certificate selected. Cannot continue.
  1771 				TRACE_FLAGS_DEFAULT, (
  1822 				status = eap_status_ca_certificate_unknown;
  1772 				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")));				
  1823 				send_error_notification(status);
  1773 		}
  1824 			}			
  1774 		else	
  1825 		}
  1775 #endif // #if defined(USE_FAST_EAP_TYPE)
  1826 		else
  1776 		{
  1827 		{
  1777 			EAP_TRACE_ERROR(m_am_tools, 
  1828 			EAP_TRACE_DEBUG(
  1778 				TRACE_FLAGS_DEFAULT, (
  1829 				m_am_tools, 
  1779 				EAPL("eap_am_type_tls_peap_symbian_c::configure - Error - No CA certificate\n")));
  1830 				TRACE_FLAGS_DEFAULT,
  1780 		
  1831 				(EAPL("eap_am_type_tls_peap_symbian_c::configure(): %d CA certificates selected.\n"),
  1781 			// No root certificate selected. Cannot continue.
  1832 				m_allowed_ca_certs.Count()));
  1782 			status = eap_status_ca_certificate_unknown;
  1833 		}
  1783 			send_error_notification(status);
  1834 	}
  1784 		}			
  1835 	else
  1785 	}
  1836 	{
  1786 	
  1837 		EAP_TRACE_DEBUG(
       
  1838 			m_am_tools, 
       
  1839 			TRACE_FLAGS_DEFAULT,
       
  1840 			(EAPL("eap_am_type_tls_peap_symbian_c::configure(): %d CA certificate selected in automatic CA selection.\n"),
       
  1841 			m_allowed_ca_certs.Count()));
       
  1842 	}
       
  1843 	
       
  1844 
  1787 	if(m_allowed_user_certs.Count() == 0)
  1845 	if(m_allowed_user_certs.Count() == 0)
  1788 		{
  1846 	{
  1789 #if defined(USE_FAST_EAP_TYPE)
  1847 #if defined(USE_FAST_EAP_TYPE)
  1790 		if(m_current_eap_type == eap_type_fast)
  1848 		if(m_current_eap_type == eap_type_fast)
  1791 			{
  1849 		{
  1792 			m_use_manual_realm = true;
  1850 			m_use_manual_realm = true;
  1793 
  1851 
  1794 			if (m_use_manual_username == false)
  1852 			if (m_use_manual_username == false)
  1795 				{
  1853 			{
  1796 				TRAPD(err, status=ConfigureL());
  1854 				TRAPD(err, status=ConfigureL());
  1797 				if (err != KErrNone)
  1855 				if (err != KErrNone)
  1798 					{
  1856 				{
  1799 					EAP_TRACE_ERROR(m_am_tools, 
  1857 					EAP_TRACE_ERROR(m_am_tools, 
  1800 							TRACE_FLAGS_DEFAULT, (
  1858 							TRACE_FLAGS_DEFAULT, (
  1801 							EAPL("eap_am_type_tls_peap_symbian_c::configure LEAVE from ConfigureL, Error =%d \n"),
  1859 							EAPL("eap_am_type_tls_peap_symbian_c::configure LEAVE from ConfigureL, Error =%d \n"),
  1802 							err));
  1860 							err));
  1803 					}
       
  1804 				}
  1861 				}
  1805 			}
  1862 			}
       
  1863 		}
  1806 #endif // #if defined(USE_FAST_EAP_TYPE)
  1864 #endif // #if defined(USE_FAST_EAP_TYPE)
  1807 		}
  1865 	}
       
  1866 	else
       
  1867 	{
       
  1868 		EAP_TRACE_DEBUG(
       
  1869 			m_am_tools, 
       
  1870 			TRACE_FLAGS_DEFAULT,
       
  1871 			(EAPL("eap_am_type_tls_peap_symbian_c::configure(): %d user certificates selected.\n"),
       
  1872 			m_allowed_user_certs.Count()));
       
  1873 	}
       
  1874 
       
  1875 
  1808 	if (m_tls_peap_server_authenticates_client_policy_flag == true
  1876 	if (m_tls_peap_server_authenticates_client_policy_flag == true
  1809 		&& m_allowed_user_certs.Count() == 0)
  1877 		&& m_allowed_user_certs.Count() == 0)
  1810 	{
  1878 	{
  1811 #if defined(USE_FAST_EAP_TYPE)
  1879 #if defined(USE_FAST_EAP_TYPE)
  1812     if (m_current_eap_type == eap_type_fast)
  1880 		if (m_current_eap_type == eap_type_fast)
  1813         {
  1881 		{
  1814         EAP_TRACE_DEBUG(m_am_tools, 
  1882 			EAP_TRACE_DEBUG(
  1815             TRACE_FLAGS_DEFAULT, 
  1883 				m_am_tools, 
  1816             (EAPL("eap_am_type_tls_peap_symbian_c::configure - No USER certificate, but in eap_fast it's not mandatory\n")));  
  1884 				TRACE_FLAGS_DEFAULT, 
  1817     
  1885 				(EAPL("eap_am_type_tls_peap_symbian_c::configure(): No USER certificate, but in eap_fast it's not mandatory\n")));
  1818         }
  1886 		}
  1819 	else
  1887 		else
  1820 #endif // #if defined(USE_FAST_EAP_TYPE)
  1888 #endif // #if defined(USE_FAST_EAP_TYPE)
  1821 	    {
  1889 	    {
  1822 	    EAP_TRACE_ERROR(m_am_tools, 
  1890 			EAP_TRACE_ERROR(
  1823 			TRACE_FLAGS_DEFAULT, (
  1891 				m_am_tools, 
  1824 			EAPL("eap_am_type_tls_peap_symbian_c::configure - Error - No USER certificate\n")));
  1892 				TRACE_FLAGS_DEFAULT,
  1825 	
  1893 				(EAPL("eap_am_type_tls_peap_symbian_c::configure(): Error - No USER certificate\n")));
  1826 		// No user certificate selected. Cannot continue.
  1894 		
  1827 		status = eap_status_user_certificate_unknown;
  1895 			// No user certificate selected. Cannot continue.
  1828 		send_error_notification(status);
  1896 			status = eap_status_user_certificate_unknown;
       
  1897 			send_error_notification(status);
  1829 	    }
  1898 	    }
  1830 	}
  1899 	}
  1831 
  1900 
  1832 	if (m_allowed_cipher_suites.Count() == 0)
  1901 	if (m_allowed_cipher_suites.Count() == 0)
  1833 	{
  1902 	{
  1834 		EAP_TRACE_ERROR(m_am_tools, 
  1903 		EAP_TRACE_ERROR(
  1835 			TRACE_FLAGS_DEFAULT, (
  1904 			m_am_tools, 
  1836 			EAPL("eap_am_type_tls_peap_symbian_c::configure - Error - No cipher suit\n")));
  1905 			TRACE_FLAGS_DEFAULT,
       
  1906 			(EAPL("eap_am_type_tls_peap_symbian_c::configure(): Error - No cipher suit\n")));
  1837 
  1907 
  1838 		// No sipher suites selected. Cannot continue.
  1908 		// No sipher suites selected. Cannot continue.
  1839 		status = eap_status_illegal_cipher_suite;
  1909 		status = eap_status_illegal_cipher_suite;
  1840 		send_error_notification(status);
  1910 		send_error_notification(status);
  1841 	}
  1911 	}
       
  1912 	else
       
  1913 	{
       
  1914 		EAP_TRACE_DEBUG(
       
  1915 			m_am_tools, 
       
  1916 			TRACE_FLAGS_DEFAULT,
       
  1917 			(EAPL("eap_am_type_tls_peap_symbian_c::configure(): %d cipher suites selected.\n"),
       
  1918 			m_allowed_cipher_suites.Count()));
       
  1919 	}
  1842 
  1920 
  1843 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1921 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1844 
  1922 
  1845 	if (status != eap_status_ok)
  1923 	if (status != eap_status_ok)
  1846 	{
  1924 	{
  1847 		notify_configuration_error(status);
  1925 		notify_configuration_error(status);
  1848 	}
  1926 	}
  1849 	
  1927 	
  1850 	m_configured = true;
  1928 	m_configured = true;
  1851 	
  1929 	
  1852 	EAP_TRACE_DEBUG(m_am_tools, 
  1930 	EAP_TRACE_DEBUG(
       
  1931 		m_am_tools, 
  1853 		TRACE_FLAGS_DEFAULT, 
  1932 		TRACE_FLAGS_DEFAULT, 
  1854 		(EAPL("eap_am_type_tls_peap_symbian_c::configure - END \n")));	
  1933 		(EAPL("eap_am_type_tls_peap_symbian_c::configure(): END \n")));
  1855 	
  1934 	
  1856 
  1935 
  1857 	return EAP_STATUS_RETURN(m_am_tools, status);
  1936 	return EAP_STATUS_RETURN(m_am_tools, status);
  1858 }
  1937 }
  1859 
  1938 
  1860 //--------------------------------------------------
  1939 //--------------------------------------------------
       
  1940 
  1861 #if defined(USE_FAST_EAP_TYPE)
  1941 #if defined(USE_FAST_EAP_TYPE)
  1862 
  1942 
  1863 eap_status_e eap_am_type_tls_peap_symbian_c::ConfigureL()
  1943 eap_status_e eap_am_type_tls_peap_symbian_c::ConfigureL()
  1864 	{
  1944 {
  1865 	
  1945 	
  1866 	eap_status_e status(eap_status_ok);
  1946 	eap_status_e status(eap_status_ok);
  1867 	
  1947 	
  1868 	_LIT(KTempUserName, "EAP-FAST-");
  1948 	_LIT(KTempUserName, "EAP-FAST-");
  1869 	TBuf8<10> TempUserName;	
  1949 	TBuf8<10> TempUserName;	
  1870 
  1950 
  1871 	TempUserName.Copy(KTempUserName);
  1951 	TempUserName.Copy(KTempUserName);
  1872 	
  1952 	
  1873 	HBufC8* buf = HBufC8::NewLC(KIdentityFieldLength);
  1953   HBufC8* buf = HBufC8::NewLC(KMaxNotifItemLength);
       
  1954 
  1874 	TPtr8 bufPtr = buf->Des();
  1955 	TPtr8 bufPtr = buf->Des();
  1875 
  1956 
  1876 	HBufC8* tempUserBuf8 = HBufC8::NewLC(KMacAddressLength);
  1957 	HBufC8* tempUserBuf8 = HBufC8::NewLC(KMacAddressLength);
  1877 	TPtr8 tempUserBufPtr8 = tempUserBuf8->Des();
  1958 	TPtr8 tempUserBufPtr8 = tempUserBuf8->Des();
  1878 
  1959 
  1948 	CleanupStack::PopAndDestroy(buf);
  2029 	CleanupStack::PopAndDestroy(buf);
  1949 
  2030 
  1950 	m_use_manual_username = true;
  2031 	m_use_manual_username = true;
  1951 	
  2032 	
  1952 	return status;
  2033 	return status;
  1953 	}
  2034 }
  1954 
  2035 
  1955 #endif // #if defined(USE_FAST_EAP_TYPE)
  2036 #endif // #if defined(USE_FAST_EAP_TYPE)
  1956 
  2037 
  1957 //--------------------------------------------------
  2038 //--------------------------------------------------
  1958 
  2039 
  1987 	}
  2068 	}
  1988 
  2069 
  1989 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2070 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1990 	return EAP_STATUS_RETURN(m_am_tools, status);
  2071 	return EAP_STATUS_RETURN(m_am_tools, status);
  1991 }
  2072 }
       
  2073 
       
  2074 //--------------------------------------------------
  1992 
  2075 
  1993 void eap_am_type_tls_peap_symbian_c::authentication_finishedL(
  2076 void eap_am_type_tls_peap_symbian_c::authentication_finishedL(
  1994 	const bool true_when_successful,
  2077 	const bool true_when_successful,
  1995 	const tls_session_type_e tls_session_type)
  2078 	const tls_session_type_e tls_session_type)
  1996 {
  2079 {
  2093 	m_state = EHandlingIdentityQuery;
  2176 	m_state = EHandlingIdentityQuery;
  2094 		
  2177 		
  2095 	// Get the own certificate only if it has already been retrieved
  2178 	// Get the own certificate only if it has already been retrieved
  2096 	if (m_own_certificate == 0)
  2179 	if (m_own_certificate == 0)
  2097 	{
  2180 	{
       
  2181 		// Get the matching certificates. This function call is completed asyncronously by complete_get_matching_certificates() function call.
  2098 		TRAPD(err, m_cert_if->GetMatchingCertificatesL(
  2182 		TRAPD(err, m_cert_if->GetMatchingCertificatesL(
  2099 			m_allowed_user_certs, 
  2183 			m_allowed_user_certs, 
  2100 			EFalse, 
  2184 			EFalse, 
  2101 			0, 
  2185 			0, 
  2102 			EFalse, 
  2186 			EFalse, 
  2129 		
  2213 		
  2130 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2214 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2131 	return EAP_STATUS_RETURN(m_am_tools, status);
  2215 	return EAP_STATUS_RETURN(m_am_tools, status);
  2132 }
  2216 }
  2133 
  2217 
       
  2218 //--------------------------------------------------
  2134 
  2219 
  2135 eap_status_e eap_am_type_tls_peap_symbian_c::complete_read_own_certificate(
  2220 eap_status_e eap_am_type_tls_peap_symbian_c::complete_read_own_certificate(
  2136 	const RPointerArray<CX509Certificate>& aCertChain, eap_status_e aStatus)
  2221 	const RPointerArray<CX509Certificate>& aCertChain, eap_status_e aStatus)
  2137 {
  2222 {
  2138 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);	
  2223 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);	
  2391 	
  2476 	
  2392 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2477 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2393 	return EAP_STATUS_RETURN(m_am_tools, status);
  2478 	return EAP_STATUS_RETURN(m_am_tools, status);
  2394 }
  2479 }
  2395 
  2480 
       
  2481 //--------------------------------------------------
       
  2482 
  2396 eap_status_e eap_am_type_tls_peap_symbian_c::complete_read_ca_certificate(
  2483 eap_status_e eap_am_type_tls_peap_symbian_c::complete_read_ca_certificate(
  2397 		const RPointerArray<CX509Certificate>& aCertChain, eap_status_e aStatus)
  2484 		const RPointerArray<CX509Certificate>& aCertChain, eap_status_e aStatus)
  2398 {
  2485 {
  2399 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  2486 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  2400 
  2487 
  2580 
  2667 
  2581 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2668 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2582 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);	
  2669 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);	
  2583 }
  2670 }
  2584 
  2671 
       
  2672 //--------------------------------------------------
       
  2673 
  2585 void eap_am_type_tls_peap_symbian_c::get_identities_from_distinguished_namesL(
  2674 void eap_am_type_tls_peap_symbian_c::get_identities_from_distinguished_namesL(
  2586 	const CX509Certificate * const aCertificate, 
  2675 	const CX509Certificate * const aCertificate, 
  2587 	eap_variable_data_c * const aSubjectIdentity,
  2676 	eap_variable_data_c * const aSubjectIdentity,
  2588 	eap_variable_data_c * const aIssuerIdentity)
  2677 	eap_variable_data_c * const aIssuerIdentity)
  2589 {
  2678 {
  2683 		}				
  2772 		}				
  2684 	}
  2773 	}
  2685 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2774 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2686 }
  2775 }
  2687 
  2776 
       
  2777 //--------------------------------------------------
       
  2778 
  2688 void eap_am_type_tls_peap_symbian_c::get_identity_from_alternative_nameL(
  2779 void eap_am_type_tls_peap_symbian_c::get_identity_from_alternative_nameL(
  2689 	const CX509Certificate * const aCertificate, 
  2780 	const CX509Certificate * const aCertificate, 
  2690 	eap_variable_data_c * const aIdentity)
  2781 	eap_variable_data_c * const aIdentity)
  2691 {
  2782 {
  2692 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  2783 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  2881 		User::Leave(KErrNotFound);
  2972 		User::Leave(KErrNotFound);
  2882 	}
  2973 	}
  2883 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2974 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2884 }
  2975 }
  2885 
  2976 
  2886 //--------------------------------------------------
       
  2887 
       
  2888 //
       
  2889 //--------------------------------------------------
  2977 //--------------------------------------------------
  2890 
  2978 
  2891 //
  2979 //
  2892 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::timer_expired(
  2980 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::timer_expired(
  2893 	const u32_t id, void *data)
  2981 	const u32_t id, void *data)
  3228 
  3316 
  3229 		if (!wanted_field.compare(&type_field))
  3317 		if (!wanted_field.compare(&type_field))
  3230 		{
  3318 		{
  3231 			// We are asked to return cf_str_PEAP_tunneled_eap_type_hex_data
  3319 			// We are asked to return cf_str_PEAP_tunneled_eap_type_hex_data
  3232 			
  3320 			
  3233 #ifdef USE_EAP_EXPANDED_TYPES
       
  3234 	
       
  3235 			// We need to return here the next ENABLED tunneled EAP type we should try. 
  3321 			// We need to return here the next ENABLED tunneled EAP type we should try. 
  3236 	
  3322 	
  3237 			if (0 == m_enabled_tunneling_exp_eap_array.Count())
  3323 			if (0 == m_enabled_tunneling_exp_eap_array.Count())
  3238 			{
  3324 			{
  3239 				// No EAP types are ENABLED as tunneling type.
  3325 				// No EAP types are ENABLED as tunneling type.
  3247 			}
  3333 			}
  3248 			else
  3334 			else
  3249 			{
  3335 			{
  3250 				// Get the first enabled EAP type (tunneling).
  3336 				// Get the first enabled EAP type (tunneling).
  3251 
  3337 
  3252 				TBuf8<KExpandedEAPTypeSize> tmpExpEAP(m_enabled_tunneling_exp_eap_array[0]->iExpandedEAPType); //first item.
       
  3253 
       
  3254 				EAP_TRACE_DATA_DEBUG(
  3338 				EAP_TRACE_DATA_DEBUG(
  3255 					m_am_tools,
  3339 					m_am_tools,
  3256 					TRACE_FLAGS_DEFAULT,
  3340 					TRACE_FLAGS_DEFAULT,
  3257 					(EAPL("type_configure_read:Enabled expanded tunneling EAP type:"),
  3341 					(EAPL("type_configure_read:Enabled expanded tunneling EAP type:"),
  3258 					tmpExpEAP.Ptr(),
  3342 					m_enabled_tunneling_exp_eap_array[0]->GetValue().Ptr(),
  3259 					tmpExpEAP.Size()));
  3343 					m_enabled_tunneling_exp_eap_array[0]->GetValue().Length()));
  3260 					
  3344 					
  3261 					status = data->set_copy_of_buffer(tmpExpEAP.Ptr(), KExpandedEAPTypeSize);
  3345 				status = data->set_copy_of_buffer(
  3262 					if (status != eap_status_ok)
  3346 					m_enabled_tunneling_exp_eap_array[0]->GetValue().Ptr(),
  3263 					{
  3347 					m_enabled_tunneling_exp_eap_array[0]->GetValue().Length());
  3264 						EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3348 				if (status != eap_status_ok)
  3265 						return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);			
  3349 				{
  3266 					}
  3350 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3351 					return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);			
       
  3352 				}
  3267 					
  3353 					
  3268 				EAP_TRACE_DATA_DEBUG(
  3354 				EAP_TRACE_DATA_DEBUG(
  3269 					m_am_tools,
  3355 					m_am_tools,
  3270 					TRACE_FLAGS_DEFAULT,
  3356 					TRACE_FLAGS_DEFAULT,
  3271 					(EAPL("EAP-PEAP or EAP-TTLS: Trying encapsulated EAP type:"),
  3357 					(EAPL("EAP-PEAP or EAP-TTLS: Trying encapsulated EAP type:"),
  3272 					tmpExpEAP.Ptr(),
  3358 					m_enabled_tunneling_exp_eap_array[0]->GetValue().Ptr(),
  3273 					tmpExpEAP.Size()));
  3359 					m_enabled_tunneling_exp_eap_array[0]->GetValue().Length()));
  3274 			}
  3360 			}
  3275 	
  3361 
  3276 #else // For normal EAP types.
       
  3277 			
       
  3278 			// We need to return here the next tunneled EAP type we should try. 
       
  3279 			TInt i;
       
  3280 
       
  3281 			for (i = 0; i < m_iap_eap_array.Count(); i++)
       
  3282 			{
       
  3283 				// Find the first enabled EAP type (highest priority)
       
  3284 				TEap *eapType = m_iap_eap_array[i];			
       
  3285 				if (eapType->Enabled == 1)
       
  3286 				{
       
  3287 					// Convert the string to integer
       
  3288 					TLex8 tmp(eapType->UID);
       
  3289 					TInt val(0);
       
  3290 					tmp.Val(val);
       
  3291 					status = data->set_copy_of_buffer(reinterpret_cast<u8_t *>(&val), sizeof(TUint));
       
  3292 					if (status != eap_status_ok)
       
  3293 					{
       
  3294 						EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3295 						return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);			
       
  3296 					}
       
  3297 					EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("EAP-PEAP: Trying encapsulated EAP type: %d.\n"), val));
       
  3298 					break;
       
  3299 				}
       
  3300 			}		
       
  3301 			if (i == m_iap_eap_array.Count())
       
  3302 			{
       
  3303 				// Not found
       
  3304 				if (m_is_client)
       
  3305 				{
       
  3306 					EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: No configured encapsulated EAP types.\n")));
       
  3307 				}
       
  3308 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3309 				return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_field);
       
  3310 			}
       
  3311 			
       
  3312 #endif //#ifdef USE_EAP_EXPANDED_TYPES
       
  3313 					
       
  3314 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3362 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3315 			return EAP_STATUS_RETURN(m_am_tools, status);
  3363 			return EAP_STATUS_RETURN(m_am_tools, status);
  3316 		
  3364 		
  3317 		} // End of  if (!wanted_field.compare(&type_field))
  3365 		} // End of  if (!wanted_field.compare(&type_field))
  3318 		
  3366 		
  3319 #if !defined(USE_EAP_EXPANDED_TYPES)
       
  3320 
       
  3321 		// cf_str_PEAP_accepted_tunneled_client_types_hex_data is available only for expaned EAP types.
       
  3322 		// cf_str_PEAP_accepted_tunneled_client_types_u32array should be used otherwise.
       
  3323 		// So for cf_str_PEAP_accepted_tunneled_client_types_hex_data and eap_configure_type_hex_data
       
  3324 		// we should return eap_status_illegal_configure_field.
       
  3325 		// This is needed only if USE_EAP_EXPANDED_TYPES is not defined. Otherwise the field 
       
  3326 		// cf_str_PEAP_accepted_tunneled_client_types_hex_data can be read from the database using
       
  3327 		// type_configure_readL (let it fall through).
       
  3328 
       
  3329 		eap_variable_data_c tunneled_type_field(m_am_tools);
       
  3330 
       
  3331 		status = tunneled_type_field.set_buffer(
       
  3332 			cf_str_PEAP_accepted_tunneled_client_types_hex_data.get_field()->get_field(),
       
  3333 			cf_str_PEAP_accepted_tunneled_client_types_hex_data.get_field()->get_field_length(),
       
  3334 			false,
       
  3335 			false);
       
  3336 		if (status != eap_status_ok)
       
  3337 		{
       
  3338 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3339 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  3340 		}
       
  3341 
       
  3342 		if (!wanted_field.compare(&tunneled_type_field))
       
  3343 		{
       
  3344 			// Check if the type is eap_configure_type_hex_data.
       
  3345 			
       
  3346 			if( eap_configure_type_hex_data ==  field->get_type() )
       
  3347 			{
       
  3348 				// This field is used only for exapanded EAP types.
       
  3349 				return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_type);
       
  3350 			}
       
  3351 		}
       
  3352 		
       
  3353 #else // For expanded EAP type.
       
  3354 
  3367 
  3355 		// cf_str_PEAP_accepted_tunneled_client_types_u32array is available only for normal EAP types.
  3368 		// cf_str_PEAP_accepted_tunneled_client_types_u32array is available only for normal EAP types.
  3356 		// So for cf_str_PEAP_accepted_tunneled_client_types_u32array and eap_configure_type_u32array
  3369 		// So for cf_str_PEAP_accepted_tunneled_client_types_u32array and eap_configure_type_u32array
  3357 		// we should return eap_status_illegal_configure_field.
  3370 		// we should return eap_status_illegal_configure_field.
  3358 		
  3371 		
  3377 			{
  3390 			{
  3378 				// This field is used only for Normal EAP types. This is illegal here.
  3391 				// This field is used only for Normal EAP types. This is illegal here.
  3379 				return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_type);
  3392 				return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_type);
  3380 			}
  3393 			}
  3381 		}
  3394 		}
  3382 		
       
  3383 #endif // End of #if !defined(USE_EAP_EXPANDED_TYPES)
       
  3384 		
       
  3385 	} // End of if (m_current_eap_type == eap_type_peap
  3395 	} // End of if (m_current_eap_type == eap_type_peap
  3386 	
  3396 	
  3387 	TRAPD(err, type_configure_readL(
  3397 	TRAPD(err, type_configure_readL(
  3388 		field->get_field(),
  3398 		field->get_field(),
  3389 		field->get_field_length(),
  3399 		field->get_field_length(),
  3405 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3415 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3406 	return EAP_STATUS_RETURN(m_am_tools, status);
  3416 	return EAP_STATUS_RETURN(m_am_tools, status);
  3407 }
  3417 }
  3408 
  3418 
  3409 //--------------------------------------------------
  3419 //--------------------------------------------------
       
  3420 
  3410 void eap_am_type_tls_peap_symbian_c::type_configure_readL(
  3421 void eap_am_type_tls_peap_symbian_c::type_configure_readL(
  3411 	eap_config_string field,
  3422 	eap_config_string field,
  3412 	const u32_t field_length,
  3423 	const u32_t field_length,
  3413 	eap_variable_data_c * const data)
  3424 	eap_variable_data_c * const data)
  3414 {
  3425 {
  3435 	
  3446 	
  3436 	// Now do the database query
  3447 	// Now do the database query
  3437 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  3448 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  3438 	TPtr sqlStatement = buf->Des();
  3449 	TPtr sqlStatement = buf->Des();
  3439 	
  3450 	
  3440 	_LIT(KSQLQueryRow, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d");	
  3451 	_LIT(KSQLQueryRow, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");	
  3441 	
  3452 	
  3442 #if defined(USE_FAST_EAP_TYPE)
  3453 #if defined(USE_FAST_EAP_TYPE)
  3443 	
  3454 	
  3444 	// Unlike other EAP types, EAP-FAST has some settings in special settings table
  3455 	// Unlike other EAP types, EAP-FAST has some settings in special settings table
  3445 	// (m_db_fast_special_table_name)
  3456 	// (m_db_fast_special_table_name)
  3446 	
  3457 	
  3447 	if(m_current_eap_type == eap_type_fast
  3458 	if(m_current_eap_type == eap_type_fast
  3448 	   && ((unicodeString.Compare(cf_str_EAP_FAST_allow_server_authenticated_provisioning_mode_literal) == 0)
  3459 	   && ((unicodeString.Compare(cf_str_EAP_FAST_allow_server_authenticated_provisioning_mode_literal) == 0)
  3449 	   || (unicodeString.Compare(cf_str_EAP_FAST_allow_server_unauthenticated_provisioning_mode_ADHP_literal) == 0)
  3460 	   || (unicodeString.Compare(cf_str_EAP_FAST_allow_server_unauthenticated_provisioning_mode_ADHP_literal) == 0)
  3450 	   || (unicodeString.Compare(cf_str_EAP_FAST_warn_ADHP_no_PAC_literal) == 0)
  3461 	   || (unicodeString.Compare(KFASTWarnADHPNoPAC) == 0)
  3451 	   || (unicodeString.Compare(cf_str_EAP_FAST_warn_ADHP_no_matching_PAC_literal) == 0)
  3462 	   || (unicodeString.Compare(KFASTWarnADHPNoMatchingPAC) == 0)
  3452 	   || (unicodeString.Compare(cf_str_EAP_FAST_warn_ADHP_not_default_server_literal) == 0)
  3463 	   || (unicodeString.Compare(KFASTWarnNotDefaultServer) == 0)
  3453 	   || (unicodeString.Compare(KFASTPACGroupImportReferenceCollection) == 0)
  3464 	   || (unicodeString.Compare(KFASTPACGroupImportReferenceCollection) == 0)
  3454 	   || (unicodeString.Compare(KFASTPACGroupDBReferenceCollection) == 0)))
  3465 	   || (unicodeString.Compare(KFASTPACGroupDBReferenceCollection) == 0)))
  3455 	    {
  3466 	{
  3456 	    if (unicodeString.Compare(cf_str_EAP_FAST_warn_ADHP_no_matching_PAC_literal) == 0)
       
  3457 	        {
       
  3458 	        unicodeString.Copy(KFASTWarnADHPNoMatchingPAC);
       
  3459 	        }
       
  3460         if (unicodeString.Compare(cf_str_EAP_FAST_warn_ADHP_no_PAC_literal) == 0)
       
  3461             {
       
  3462             unicodeString.Copy(KFASTWarnADHPNoPAC);
       
  3463             }
       
  3464         if (unicodeString.Compare(cf_str_EAP_FAST_warn_ADHP_not_default_server_literal) == 0)
       
  3465             {
       
  3466             unicodeString.Copy(KFASTWarnNotDefaultServer);
       
  3467             }
       
  3468 		EAP_TRACE_DEBUG(m_am_tools, 
  3467 		EAP_TRACE_DEBUG(m_am_tools, 
  3469 			TRACE_FLAGS_DEFAULT, 
  3468 			TRACE_FLAGS_DEFAULT, 
  3470 			(EAPL("eap_am_type_tls_peap_symbian_c::type_configure_readL This field will be read from EAP-FAST's special table\n")));
  3469 			(EAPL("eap_am_type_tls_peap_symbian_c::type_configure_readL This field will be read from EAP-FAST's special table\n")));
  3471 		
  3470 		
  3472 		sqlStatement.Format(KSQLQueryRow, &unicodeString, &m_db_fast_special_table_name, 
  3471 		sqlStatement.Format(
  3473 			&KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);		
  3472 			KSQLQueryRow,
  3474 	    }
  3473 			&unicodeString,
       
  3474 			&m_db_fast_special_table_name, 
       
  3475 			&KServiceType,
       
  3476 			m_index_type,
       
  3477 			&KServiceIndex,
       
  3478 			m_index,
       
  3479 			&KTunnelingTypeVendorId,
       
  3480 			m_tunneling_type.get_vendor_id(),
       
  3481 			&KTunnelingType, 
       
  3482 			m_tunneling_type.get_vendor_type());
       
  3483 	}
  3475 	else
  3484 	else
  3476 	    {
  3485 	{
  3477 		sqlStatement.Format(KSQLQueryRow, &unicodeString, &m_db_table_name, 
  3486 		sqlStatement.Format(
  3478 			&KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);		
  3487 			KSQLQueryRow,
  3479 	    }
  3488 			&unicodeString,
       
  3489 			&m_db_table_name, 
       
  3490 			&KServiceType,
       
  3491 			m_index_type,
       
  3492 			&KServiceIndex,
       
  3493 			m_index,
       
  3494 			&KTunnelingTypeVendorId,
       
  3495 			m_tunneling_type.get_vendor_id(),
       
  3496 			&KTunnelingType, 
       
  3497 			m_tunneling_type.get_vendor_type());
       
  3498 	}
  3480 	
  3499 	
  3481 #else
  3500 #else
  3482 
  3501 
  3483 	sqlStatement.Format(KSQLQueryRow, &unicodeString, &m_db_table_name, 
  3502 	sqlStatement.Format(
  3484 		&KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);
  3503 		KSQLQueryRow,
       
  3504 		&unicodeString,
       
  3505 		&m_db_table_name, 
       
  3506 		&KServiceType,
       
  3507 		m_index_type,
       
  3508 		&KServiceIndex,
       
  3509 		m_index,
       
  3510 		&KTunnelingTypeVendorId,
       
  3511 		m_tunneling_type.get_vendor_id(),
       
  3512 		&KTunnelingType, 
       
  3513 		m_tunneling_type.get_vendor_type());
  3485 		
  3514 		
  3486 #endif // End: #if defined(USE_FAST_EAP_TYPE)
  3515 #endif // End: #if defined(USE_FAST_EAP_TYPE)
  3487 	
  3516 
  3488 	RDbView view;
  3517 	RDbView view;
  3489 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  3518 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  3490 	CleanupClosePushL(view);
  3519 	CleanupClosePushL(view);
  3491 	User::LeaveIfError(view.EvaluateAll());	
  3520 	User::LeaveIfError(view.EvaluateAll());	
  3492 	if (view.FirstL())
  3521 	if (view.FirstL())
  3558 	// Close database
  3587 	// Close database
  3559 	CleanupStack::PopAndDestroy(4); // view
  3588 	CleanupStack::PopAndDestroy(4); // view
  3560 
  3589 
  3561 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3590 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3562 }
  3591 }
       
  3592 
  3563 //--------------------------------------------------
  3593 //--------------------------------------------------
  3564 
  3594 
  3565 //
  3595 //
  3566 
       
  3567 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::type_configure_write(
  3596 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::type_configure_write(
  3568 	const eap_configuration_field_c * const field,
  3597 	const eap_configuration_field_c * const field,
  3569 	eap_variable_data_c * const data)
  3598 	eap_variable_data_c * const data)
  3570 {
  3599 {
  3571 	// Here configuration data must be read from type spesific database.
  3600 	// Here configuration data must be read from type spesific database.
  3598 	field_name.Copy(p);
  3627 	field_name.Copy(p);
  3599 	
  3628 	
  3600 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  3629 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  3601 	TPtr sqlStatement = buf->Des();
  3630 	TPtr sqlStatement = buf->Des();
  3602 	
  3631 	
  3603 	_LIT(KSQLInsert, "SELECT %s FROM %S WHERE %S=%d AND %S=%d AND %S=%d");
  3632 	_LIT(KSQLInsert, "SELECT %s FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
  3604 	sqlStatement.Format(KSQLInsert, field_name.PtrZ(), &m_db_table_name, 
  3633 
  3605 		&KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);
  3634 	sqlStatement.Format(
       
  3635 		KSQLInsert,
       
  3636 		field_name.PtrZ(),
       
  3637 		&m_db_table_name, 
       
  3638 		&KServiceType,
       
  3639 		m_index_type,
       
  3640 		&KServiceIndex,
       
  3641 		m_index,
       
  3642 		&KTunnelingTypeVendorId,
       
  3643 		m_tunneling_type.get_vendor_id(),
       
  3644 		&KTunnelingType, 
       
  3645 		m_tunneling_type.get_vendor_type());
       
  3646 
  3606 	// Evaluate view
  3647 	// Evaluate view
  3607 	RDbView view;
  3648 	RDbView view;
  3608 	User::LeaveIfError(view.Prepare(m_database,TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  3649 	User::LeaveIfError(view.Prepare(m_database,TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  3609 	CleanupClosePushL(view);
  3650 	CleanupClosePushL(view);
  3610 	User::LeaveIfError(view.EvaluateAll());
  3651 	User::LeaveIfError(view.EvaluateAll());
  3628 	CleanupStack::PopAndDestroy(3); // view, 2 strings
  3669 	CleanupStack::PopAndDestroy(3); // view, 2 strings
  3629 
  3670 
  3630 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
  3671 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
  3631 }
  3672 }
  3632 
  3673 
       
  3674 //--------------------------------------------------
       
  3675 
  3633 void eap_am_type_tls_peap_symbian_c::WriteIntParamL(
  3676 void eap_am_type_tls_peap_symbian_c::WriteIntParamL(
  3634 	eap_config_string field,
  3677 	eap_config_string field,
  3635 	const u32_t field_length,
  3678 	const u32_t field_length,
  3636 	eap_variable_data_c * const data)
  3679 	eap_variable_data_c * const data)
  3637 {
  3680 {
  3646 	
  3689 	
  3647 	// Form the insertion command
  3690 	// Form the insertion command
  3648 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  3691 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  3649 	TPtr sqlStatement = buf->Des();
  3692 	TPtr sqlStatement = buf->Des();
  3650 
  3693 
  3651 	_LIT(KSQLInsert, "SELECT %s FROM %S WHERE %S=%d AND %S=%d AND %S=%d");
  3694 	_LIT(KSQLInsert, "SELECT %s FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
  3652 	sqlStatement.Format(KSQLInsert, field_name.PtrZ(), &m_db_table_name, 
  3695 
  3653 		&KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);
  3696 	sqlStatement.Format(
       
  3697 		KSQLInsert,
       
  3698 		field_name.PtrZ(),
       
  3699 		&m_db_table_name, 
       
  3700 		&KServiceType,
       
  3701 		m_index_type,
       
  3702 		&KServiceIndex,
       
  3703 		m_index,
       
  3704 		&KTunnelingTypeVendorId,
       
  3705 		m_tunneling_type.get_vendor_id(),
       
  3706 		&KTunnelingType, 
       
  3707 		m_tunneling_type.get_vendor_type());
  3654 	
  3708 	
  3655 	// Evaluate view
  3709 	// Evaluate view
  3656 	RDbView view;
  3710 	RDbView view;
  3657 	User::LeaveIfError(view.Prepare(m_database,TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  3711 	User::LeaveIfError(view.Prepare(m_database,TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  3658 	CleanupClosePushL(view);
  3712 	CleanupClosePushL(view);
  3676 	CleanupStack::PopAndDestroy(3); // view, buf, 2nd buf
  3730 	CleanupStack::PopAndDestroy(3); // view, buf, 2nd buf
  3677 
  3731 
  3678 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3732 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3679 }
  3733 }
  3680 
  3734 
       
  3735 //--------------------------------------------------
       
  3736 
  3681 void eap_am_type_tls_peap_symbian_c::WriteIntParamL(
  3737 void eap_am_type_tls_peap_symbian_c::WriteIntParamL(
  3682 	eap_config_string field,
  3738 	eap_config_string field,
  3683 	const u32_t field_length,
  3739 	const u32_t field_length,
  3684 	const u32_t value)
  3740 	const u32_t value)
  3685 {
  3741 {
  3694 	
  3750 	
  3695 	// Form the insertion command
  3751 	// Form the insertion command
  3696 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  3752 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  3697 	TPtr sqlStatement = buf->Des();
  3753 	TPtr sqlStatement = buf->Des();
  3698 
  3754 
  3699 	_LIT(KSQLInsert, "SELECT %s FROM %S WHERE %S=%d AND %S=%d AND %S=%d");
  3755 	_LIT(KSQLInsert, "SELECT %s FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
  3700 	sqlStatement.Format(KSQLInsert, field_name.PtrZ(), &m_db_table_name, 
  3756 
  3701 		&KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);
  3757 	sqlStatement.Format(
       
  3758 		KSQLInsert,
       
  3759 		field_name.PtrZ(),
       
  3760 		&m_db_table_name, 
       
  3761 		&KServiceType,
       
  3762 		m_index_type,
       
  3763 		&KServiceIndex,
       
  3764 		m_index,
       
  3765 		&KTunnelingTypeVendorId,
       
  3766 		m_tunneling_type.get_vendor_id(),
       
  3767 		&KTunnelingType, 
       
  3768 		m_tunneling_type.get_vendor_type());
  3702 	
  3769 	
  3703 	// Evaluate view
  3770 	// Evaluate view
  3704 	RDbView view;
  3771 	RDbView view;
  3705 	User::LeaveIfError(view.Prepare(m_database,TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  3772 	User::LeaveIfError(view.Prepare(m_database,TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  3706 	CleanupClosePushL(view);
  3773 	CleanupClosePushL(view);
  3785 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3852 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3786 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
  3853 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
  3787 }
  3854 }
  3788 
  3855 
  3789 //--------------------------------------------------
  3856 //--------------------------------------------------
  3790 
       
  3791 
  3857 
  3792 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::query_cipher_suites_and_previous_session()
  3858 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::query_cipher_suites_and_previous_session()
  3793 {
  3859 {
  3794 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  3860 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  3795 
  3861 
  3874 				else	
  3940 				else	
  3875 #endif // #if defined(USE_FAST_EAP_TYPE)
  3941 #endif // #if defined(USE_FAST_EAP_TYPE)
  3876 				{
  3942 				{
  3877 					m_state = EHandlingCipherSuiteQuery;
  3943 					m_state = EHandlingCipherSuiteQuery;
  3878 					
  3944 					
  3879 					TRAPD(err, m_cert_if->ReadCACertificateL(m_allowed_ca_certs[0]));
  3945 					TRAPD(err, m_cert_if->ReadCACertificateL(*m_allowed_ca_certs[0]));
  3880 					if (err != KErrNone)
  3946 					if (err != KErrNone)
  3881 					{
  3947 					{
  3882 						// Error occurred. Just select all cipher suites.
  3948 						// Error occurred. Just select all cipher suites.
  3883 						select_all_cipher_suites = true;
  3949 						select_all_cipher_suites = true;
  3884 					}
  3950 					}
  3937 			{
  4003 			{
  3938 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4004 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3939 				return EAP_STATUS_RETURN(m_am_tools, status);
  4005 				return EAP_STATUS_RETURN(m_am_tools, status);
  3940 			}
  4006 			}
  3941 		}
  4007 		}
       
  4008 
  3942 		if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_RSA_WITH_AES_128_CBC_SHA) != KErrNotFound
  4009 		if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_RSA_WITH_AES_128_CBC_SHA) != KErrNotFound
  3943 			// AND the algorithm matches the certificates algorithm
  4010 			// AND the algorithm matches the certificates algorithm
  3944 			&& (select_all_cipher_suites == true
  4011 			&& (select_all_cipher_suites == true
  3945 				|| certAlgorithm == ERSA))
  4012 				|| certAlgorithm == ERSA))
  3946 			// THEN add it to list.
  4013 			// THEN add it to list.
  3958 			{
  4025 			{
  3959 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4026 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3960 				return EAP_STATUS_RETURN(m_am_tools, status);
  4027 				return EAP_STATUS_RETURN(m_am_tools, status);
  3961 			}
  4028 			}
  3962 		}
  4029 		}
       
  4030 
  3963 		if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA) != KErrNotFound
  4031 		if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA) != KErrNotFound
  3964 			// AND the algorithm matches the certificates algorithm
  4032 			// AND the algorithm matches the certificates algorithm
  3965 			&& (select_all_cipher_suites == true
  4033 			&& (select_all_cipher_suites == true
  3966 				|| certAlgorithm == EDSA))
  4034 				|| certAlgorithm == EDSA))
  3967 			// THEN add it to list.
  4035 			// THEN add it to list.
  3979 			{
  4047 			{
  3980 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4048 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3981 				return EAP_STATUS_RETURN(m_am_tools, status);
  4049 				return EAP_STATUS_RETURN(m_am_tools, status);
  3982 			}
  4050 			}
  3983 		}
  4051 		}
       
  4052 
  3984 		if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_DHE_DSS_WITH_AES_128_CBC_SHA) != KErrNotFound
  4053 		if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_DHE_DSS_WITH_AES_128_CBC_SHA) != KErrNotFound
  3985 			// AND the algorithm matches the certificates algorithm
  4054 			// AND the algorithm matches the certificates algorithm
  3986 			&& (select_all_cipher_suites == true
  4055 			&& (select_all_cipher_suites == true
  3987 				|| certAlgorithm == EDSA))
  4056 				|| certAlgorithm == EDSA))
  3988 			// THEN add it to list.
  4057 			// THEN add it to list.
  4000 			{
  4069 			{
  4001 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4070 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4002 				return EAP_STATUS_RETURN(m_am_tools, status);
  4071 				return EAP_STATUS_RETURN(m_am_tools, status);
  4003 			}
  4072 			}
  4004 		}
  4073 		}
       
  4074 
  4005 		if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA) != KErrNotFound
  4075 		if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA) != KErrNotFound
  4006 			// AND the algorithm matches the certificates algorithm
  4076 			// AND the algorithm matches the certificates algorithm
  4007 			&& (select_all_cipher_suites == true
  4077 			&& (select_all_cipher_suites == true
  4008 				|| certAlgorithm == ERSA))
  4078 				|| certAlgorithm == ERSA))
  4009 			// THEN add it to list.
  4079 			// THEN add it to list.
  4021 			{
  4091 			{
  4022 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4092 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4023 				return EAP_STATUS_RETURN(m_am_tools, status);
  4093 				return EAP_STATUS_RETURN(m_am_tools, status);
  4024 			}
  4094 			}
  4025 		}
  4095 		}
       
  4096 
  4026 		if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_DHE_RSA_WITH_AES_128_CBC_SHA) != KErrNotFound
  4097 		if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_DHE_RSA_WITH_AES_128_CBC_SHA) != KErrNotFound
  4027 			// AND the algorithm matches the certificates algorithm
  4098 			// AND the algorithm matches the certificates algorithm
  4028 			&& (select_all_cipher_suites == true
  4099 			&& (select_all_cipher_suites == true
  4029 				|| certAlgorithm == ERSA))
  4100 				|| certAlgorithm == ERSA))
  4030 			// THEN add it to list.
  4101 			// THEN add it to list.
  4042 			{
  4113 			{
  4043 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4114 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4044 				return EAP_STATUS_RETURN(m_am_tools, status);
  4115 				return EAP_STATUS_RETURN(m_am_tools, status);
  4045 			}
  4116 			}
  4046 		}
  4117 		}
       
  4118 
  4047 		if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_RSA_WITH_RC4_128_MD5) != KErrNotFound
  4119 		if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_RSA_WITH_RC4_128_MD5) != KErrNotFound
  4048 			// AND the algorithm matches the certificates algorithm
  4120 			// AND the algorithm matches the certificates algorithm
  4049 			&& (select_all_cipher_suites == true
  4121 			&& (select_all_cipher_suites == true
  4050 				|| certAlgorithm == ERSA))
  4122 				|| certAlgorithm == ERSA))
  4051 			// THEN add it to list.
  4123 			// THEN add it to list.
  4063 			{
  4135 			{
  4064 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4136 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4065 				return EAP_STATUS_RETURN(m_am_tools, status);
  4137 				return EAP_STATUS_RETURN(m_am_tools, status);
  4066 			}
  4138 			}
  4067 		}
  4139 		}
       
  4140 
  4068 		if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_RSA_WITH_RC4_128_SHA) != KErrNotFound
  4141 		if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_RSA_WITH_RC4_128_SHA) != KErrNotFound
  4069 			// AND the algorithm matches the certificates algorithm
  4142 			// AND the algorithm matches the certificates algorithm
  4070 			&& (select_all_cipher_suites == true
  4143 			&& (select_all_cipher_suites == true
  4071 				|| certAlgorithm == ERSA))
  4144 				|| certAlgorithm == ERSA))
  4072 			// THEN add it to list.)
  4145 			// THEN add it to list.)
  4442 	EAP_TEMPLATE_CONST eap_array_c<eap_variable_data_c> * const certificate_chain,
  4515 	EAP_TEMPLATE_CONST eap_array_c<eap_variable_data_c> * const certificate_chain,
  4443 	const tls_cipher_suites_e required_cipher_suite)
  4516 	const tls_cipher_suites_e required_cipher_suite)
  4444 {
  4517 {
  4445 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  4518 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  4446 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("\n")));
  4519 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("\n")));
  4447 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("TLS: %s: message_function: verify_certificate_chain_and_query_public_key()\n"),
  4520 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("TLS: %s: message_function: verify_certificate_chain()\n"),
  4448 		(m_is_client == true ? "client": "server")));
  4521 		(m_is_client == true ? "client": "server")));
       
  4522 
       
  4523 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_type_tls_peap_symbian_c::verify_certificate_chain()");
  4449 
  4524 
  4450 	EAP_ASSERT_ALWAYS(certificate_chain->get_object_count() > 0);
  4525 	EAP_ASSERT_ALWAYS(certificate_chain->get_object_count() > 0);
  4451 
  4526 
  4452 	eap_status_e status(eap_status_ok);
  4527 	eap_status_e status(eap_status_ok);
  4453 
  4528 
  4466 
  4541 
  4467 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4542 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4468 	return EAP_STATUS_RETURN(m_am_tools, status);
  4543 	return EAP_STATUS_RETURN(m_am_tools, status);
  4469 }
  4544 }
  4470 
  4545 
       
  4546 //--------------------------------------------------
       
  4547 
  4471 void eap_am_type_tls_peap_symbian_c::verify_certificate_chainL(
  4548 void eap_am_type_tls_peap_symbian_c::verify_certificate_chainL(
  4472 	EAP_TEMPLATE_CONST eap_array_c<eap_variable_data_c> * const certificate_chain,
  4549 	EAP_TEMPLATE_CONST eap_array_c<eap_variable_data_c> * const certificate_chain,
  4473 	const tls_cipher_suites_e required_cipher_suite)
  4550 	const tls_cipher_suites_e required_cipher_suite)
  4474 {
  4551 {
  4475 	EAP_TRACE_DEBUG(m_am_tools, 
  4552 	EAP_TRACE_DEBUG(
  4476 	TRACE_FLAGS_DEFAULT, 
  4553 		m_am_tools, 
  4477 	(EAPL("eap_am_type_tls_peap_symbian_c::verify_certificate_chainL: Number of certificates in chain=%d\n"),
  4554 		TRACE_FLAGS_DEFAULT, 
       
  4555 		(EAPL("eap_am_type_tls_peap_symbian_c::verify_certificate_chainL(): Number of certificates in chain=%d\n"),
  4478 		certificate_chain->get_object_count()));
  4556 		certificate_chain->get_object_count()));
       
  4557 
       
  4558 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_type_tls_peap_symbian_c::verify_certificate_chainL()");
  4479 
  4559 
  4480 	eap_status_e status(eap_status_process_general_error);
  4560 	eap_status_e status(eap_status_process_general_error);
  4481 	if (m_is_client)
  4561 	if (m_is_client)
  4482 	{
  4562 	{
  4483 		m_cipher_suite = required_cipher_suite;
  4563 		m_cipher_suite = required_cipher_suite;
  4490 		&& m_verify_certificate_realm == true
  4570 		&& m_verify_certificate_realm == true
  4491 		&& (m_own_certificate != 0
  4571 		&& (m_own_certificate != 0
  4492 			|| (m_use_manual_realm == true
  4572 			|| (m_use_manual_realm == true
  4493 				&& m_manual_realm.get_is_valid_data() == true)))
  4573 				&& m_manual_realm.get_is_valid_data() == true)))
  4494 	{
  4574 	{
       
  4575 		EAP_TRACE_DEBUG(
       
  4576 			m_am_tools, 
       
  4577 			TRACE_FLAGS_DEFAULT, 
       
  4578 			(EAPL("eap_am_type_tls_peap_symbian_c::verify_certificate_chainL(): Does server certificate realm verification\n")));
       
  4579 
  4495 		eap_variable_data_c client_subject_realm(m_am_tools);
  4580 		eap_variable_data_c client_subject_realm(m_am_tools);
  4496 		eap_variable_data_c manual_client_subject_realm(m_am_tools);
  4581 		eap_variable_data_c manual_client_subject_realm(m_am_tools);
  4497 		eap_variable_data_c client_issuer_realm(m_am_tools);
  4582 		eap_variable_data_c client_issuer_realm(m_am_tools);
  4498 
  4583 
  4499 		if (m_own_certificate != 0)
  4584 		if (m_own_certificate != 0)
  4703 
  4788 
  4704 					User::Leave(KErrArgument);
  4789 					User::Leave(KErrArgument);
  4705 				}
  4790 				}
  4706 			}
  4791 			}
  4707 		}
  4792 		}
       
  4793 
  4708 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Server certificate realm verification OK.\n")));
  4794 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Server certificate realm verification OK.\n")));
  4709 	}
  4795 	}
  4710 
  4796 	else
  4711 	HBufC8* chain = HBufC8::NewL(0);
  4797 	{
       
  4798 		EAP_TRACE_DEBUG(
       
  4799 			m_am_tools, 
       
  4800 			TRACE_FLAGS_DEFAULT, 
       
  4801 			(EAPL("eap_am_type_tls_peap_symbian_c::verify_certificate_chainL(): No server certificate realm verification\n")));
       
  4802 	}
       
  4803 
       
  4804 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  4805 
       
  4806 	HBufC8* chain = HBufC8::NewL(1);
       
  4807 
       
  4808 	EAP_TRACE_DEBUG(
       
  4809 		m_am_tools, 
       
  4810 		TRACE_FLAGS_DEFAULT, 
       
  4811 		(EAPL("eap_am_type_tls_peap_symbian_c::verify_certificate_chainL(): Calls CleanupStack::PushL(chain)\n")));
       
  4812 
       
  4813 	CleanupStack::PushL(chain);
       
  4814 	chain->Des().SetLength(0);
       
  4815 
  4712 	HBufC8* temp;
  4816 	HBufC8* temp;
  4713 	eap_variable_data_c* cert;
  4817 	eap_variable_data_c* cert;
  4714 	
  4818 	
  4715 	for (u32_t i = 0; i < certificate_chain->get_object_count(); i++)
  4819 	for (u32_t i = 0; i < certificate_chain->get_object_count(); i++)
  4716 	{
  4820 	{
  4726 			User::Leave(KErrArgument);		
  4830 			User::Leave(KErrArgument);		
  4727 		}
  4831 		}
  4728 	
  4832 	
  4729 #if defined(_DEBUG) || defined(DEBUG)
  4833 #if defined(_DEBUG) || defined(DEBUG)
  4730 
  4834 
  4731 		TPtr8 certPtr(
  4835 		{
  4732 			cert->get_data(cert->get_data_length()), 
  4836 			TPtr8 certPtr(
  4733 			cert->get_data_length(),
  4837 				cert->get_data(cert->get_data_length()), 
  4734 			cert->get_data_length());
  4838 				cert->get_data_length(),
  4735 		CX509Certificate* x509Cert = CX509Certificate::NewL(certPtr);
  4839 				cert->get_data_length());
  4736 
  4840 
  4737 		if( x509Cert != NULL )
  4841 			CX509Certificate* x509Cert = CX509Certificate::NewL(certPtr);
  4738 		{				
  4842 
  4739 			CleanupStack::PushL(x509Cert);
  4843 			if( x509Cert != NULL )
  4740 
  4844 			{				
  4741 			TKeyIdentifier KeyIdentifier = x509Cert->KeyIdentifierL();
  4845 				CleanupStack::PushL(x509Cert);
  4742 			
  4846 
  4743 			EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Key identifier is"),
  4847 				TKeyIdentifier KeyIdentifier = x509Cert->KeyIdentifierL();
  4744 				KeyIdentifier.Ptr(),
       
  4745 				KeyIdentifier.Size()));
       
  4746 								
       
  4747 			// This is for subject key id.
       
  4748 			const CX509CertExtension* certExt = x509Cert->Extension(KSubjectKeyId);
       
  4749 			
       
  4750 			if (certExt)
       
  4751 			{
       
  4752 				const CX509SubjectKeyIdExt* subKeyExt = CX509SubjectKeyIdExt::NewLC(certExt->Data());
       
  4753 				EAP_UNREFERENCED_PARAMETER(subKeyExt);
       
  4754 
       
  4755 				EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("The Subject key Id is:"),
       
  4756 					subKeyExt->KeyId().Ptr(),
       
  4757 					subKeyExt->KeyId().Size()));					
       
  4758 				
  4848 				
  4759 				CleanupStack::PopAndDestroy(); // subKeyExt					
  4849 				EAP_TRACE_DATA_DEBUG(
       
  4850 					m_am_tools,
       
  4851 					TRACE_FLAGS_DEFAULT,
       
  4852 					(EAPL("Key identifier is"),
       
  4853 					KeyIdentifier.Ptr(),
       
  4854 					KeyIdentifier.Size()));
       
  4855 									
       
  4856 				// This is for subject key id.
       
  4857 				const CX509CertExtension* certExt = x509Cert->Extension(KSubjectKeyId);
       
  4858 				
       
  4859 				if (certExt)
       
  4860 				{
       
  4861 					const CX509SubjectKeyIdExt* subKeyExt = CX509SubjectKeyIdExt::NewLC(certExt->Data());
       
  4862 					EAP_UNREFERENCED_PARAMETER(subKeyExt);
       
  4863 
       
  4864 					EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("The Subject key Id is:"),
       
  4865 						subKeyExt->KeyId().Ptr(),
       
  4866 						subKeyExt->KeyId().Size()));					
       
  4867 					
       
  4868 					CleanupStack::PopAndDestroy();
       
  4869 				}
       
  4870 				else
       
  4871 				{
       
  4872 					EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: verify_certificate_chainL - No extension for this certificate\n")));			
       
  4873 				}
       
  4874 				
       
  4875 				CleanupStack::PopAndDestroy();
  4760 			}
  4876 			}
  4761 			else
  4877 		}
  4762 			{
       
  4763 				EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: verify_certificate_chainL - No extension for this certificate\n")));			
       
  4764 			}
       
  4765 			
       
  4766 			CleanupStack::PopAndDestroy(x509Cert);
       
  4767 		}
       
  4768 
       
  4769 #endif
  4878 #endif
  4770 
  4879 
       
  4880 		temp = chain->ReAllocL(chain->Length() + cert->get_data_length());
       
  4881 
       
  4882 		CleanupStack::Pop(chain);
       
  4883 
       
  4884 		chain = temp;
       
  4885 
  4771 		CleanupStack::PushL(chain);
  4886 		CleanupStack::PushL(chain);
  4772 		temp = chain->ReAllocL(chain->Length() + cert->get_data_length());
  4887 
  4773 		chain = temp;
       
  4774 		TPtr8 ptr = chain->Des();
  4888 		TPtr8 ptr = chain->Des();
       
  4889 
  4775 		ptr.Append(cert->get_data(cert->get_data_length()), cert->get_data_length());
  4890 		ptr.Append(cert->get_data(cert->get_data_length()), cert->get_data_length());
  4776 		if (i == 0)
  4891 		if (i == 0)
  4777 		{
  4892 		{
  4778 			// This is the peer certificate. Save it.
  4893 			// This is the peer certificate. Save it.
  4779 			if (m_peer_certificate != 0)
  4894 			if (m_peer_certificate != 0)
  4780 			{
  4895 			{
  4781 				delete m_peer_certificate;
  4896 				delete m_peer_certificate;
  4782 			}
  4897 			}
  4783 			m_peer_certificate = CX509Certificate::NewL(ptr);
  4898 			m_peer_certificate = CX509Certificate::NewL(ptr);
  4784 		}
  4899 		}
  4785 		CleanupStack::Pop();
  4900 
  4786 	}
  4901 	} // for()
  4787 	CleanupStack::PushL(chain);
  4902 
       
  4903 
       
  4904 	EAP_TRACE_DEBUG(
       
  4905 		m_am_tools, 
       
  4906 		TRACE_FLAGS_DEFAULT, 
       
  4907 		(EAPL("eap_am_type_tls_peap_symbian_c::verify_certificate_chainL(): calls chain->Des()\n")));
       
  4908 
  4788 	TPtr8 certChain = chain->Des();
  4909 	TPtr8 certChain = chain->Des();
  4789 	m_cert_if->ValidateChainL(certChain, m_allowed_ca_certs);
  4910 	TBool aUseAutomaticCaCertificate = (m_use_automatic_ca_certificate == true) ? ETrue : EFalse;
  4790 	
  4911 
  4791 	CleanupStack::PopAndDestroy();
  4912 	EAP_TRACE_DEBUG(
       
  4913 		m_am_tools, 
       
  4914 		TRACE_FLAGS_DEFAULT, 
       
  4915 		(EAPL("eap_am_type_tls_peap_symbian_c::verify_certificate_chainL(): calls m_cert_if->ValidateChainL()\n")));
       
  4916 
       
  4917 	m_cert_if->ValidateChainL(certChain, m_allowed_ca_certs, aUseAutomaticCaCertificate);
       
  4918 	
       
  4919 	CleanupStack::PopAndDestroy(chain);
       
  4920 
  4792 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4921 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  4922 
  4793 	// This returns eap_status_pending_request
  4923 	// This returns eap_status_pending_request
  4794 	User::Leave(KErrCompletion);
  4924 	User::Leave(KErrCompletion);
  4795 
  4925 
  4796 }
  4926 }
  4797 
  4927 
       
  4928 //--------------------------------------------------
       
  4929 
       
  4930 #if defined(USE_EAP_DEBUG_TRACE)
       
  4931 
       
  4932 static eap_const_string get_certificate_error_string(const enum TValidationError certificate_error)
       
  4933 {
       
  4934 #if defined(USE_EAP_TRACE_STRINGS)
       
  4935 	EAP_IF_RETURN_STRING(certificate_error, EValidatedOK)
       
  4936 	else EAP_IF_RETURN_STRING(certificate_error, EChainHasNoRoot)
       
  4937 	else EAP_IF_RETURN_STRING(certificate_error, ESignatureInvalid)
       
  4938 	else EAP_IF_RETURN_STRING(certificate_error, EDateOutOfRange)
       
  4939 	else EAP_IF_RETURN_STRING(certificate_error, ENameIsExcluded)
       
  4940 	else EAP_IF_RETURN_STRING(certificate_error, ENameNotPermitted)
       
  4941 	else EAP_IF_RETURN_STRING(certificate_error, ENotCACert)
       
  4942 	else EAP_IF_RETURN_STRING(certificate_error, ECertificateRevoked)
       
  4943 	else EAP_IF_RETURN_STRING(certificate_error, EUnrecognizedCriticalExtension)
       
  4944 	else EAP_IF_RETURN_STRING(certificate_error, ENoBasicConstraintInCACert)
       
  4945 	else EAP_IF_RETURN_STRING(certificate_error, ENoAcceptablePolicy)
       
  4946 	else EAP_IF_RETURN_STRING(certificate_error, EPathTooLong)
       
  4947 	else EAP_IF_RETURN_STRING(certificate_error, ENegativePathLengthSpecified)
       
  4948 	else EAP_IF_RETURN_STRING(certificate_error, ENamesDontChain)
       
  4949 	else EAP_IF_RETURN_STRING(certificate_error, ERequiredPolicyNotFound)
       
  4950 	else EAP_IF_RETURN_STRING(certificate_error, EBadKeyUsage)
       
  4951 	else EAP_IF_RETURN_STRING(certificate_error, ERootCertNotSelfSigned)
       
  4952 	else EAP_IF_RETURN_STRING(certificate_error, ECriticalExtendedKeyUsage)
       
  4953 	else EAP_IF_RETURN_STRING(certificate_error, ECriticalCertPoliciesWithQualifiers)
       
  4954 	else EAP_IF_RETURN_STRING(certificate_error, ECriticalPolicyMapping)
       
  4955 	else EAP_IF_RETURN_STRING(certificate_error, ECriticalDeviceId)
       
  4956 	else EAP_IF_RETURN_STRING(certificate_error, ECriticalSid)
       
  4957 	else EAP_IF_RETURN_STRING(certificate_error, ECriticalVid)
       
  4958 	else EAP_IF_RETURN_STRING(certificate_error, ECriticalCapabilities)
       
  4959 #endif // #if defined(USE_EAP_TRACE_STRINGS)
       
  4960 	{
       
  4961 		EAP_UNREFERENCED_PARAMETER(certificate_error);
       
  4962 		return EAPL("Unknown TValidationError");
       
  4963 	}
       
  4964 }
       
  4965 
       
  4966 #endif //#if defined(USE_EAP_DEBUG_TRACE)
       
  4967 
       
  4968 //--------------------------------------------------
  4798 
  4969 
  4799 void eap_am_type_tls_peap_symbian_c::complete_validate_chain(
  4970 void eap_am_type_tls_peap_symbian_c::complete_validate_chain(
  4800 	CPKIXValidationResult& aValidationResult, eap_status_e aStatus)
  4971 	CPKIXValidationResult& aValidationResult,
       
  4972 	eap_status_e aStatus)
  4801 {
  4973 {
  4802 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  4974 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  4803 	
  4975 	
       
  4976 	EAP_TRACE_DEBUG(
       
  4977 		m_am_tools,
       
  4978 		TRACE_FLAGS_DEFAULT, 
       
  4979 		(EAPL("eap_am_type_tls_peap_symbian_c::complete_validate_chain(): Certificate chain validation reason=%d=%s, status=%d=%s\n"), 
       
  4980 		aValidationResult.Error().iReason,
       
  4981 		get_certificate_error_string(aValidationResult.Error().iReason),
       
  4982 		aStatus,
       
  4983 		eap_status_string_c::get_status_string(aStatus)));
       
  4984 
  4804 	if(aStatus != eap_status_ok)
  4985 	if(aStatus != eap_status_ok)
  4805 	{
  4986 	{
  4806 		get_tls_am_partner()->complete_verify_certificate_chain(aStatus);
  4987 		get_tls_am_partner()->complete_verify_certificate_chain(aStatus);
  4807 		return;
  4988 		return;
  4808 	}
  4989 	}
  4809 	
  4990 	
  4810 	eap_status_e result;	
  4991 	eap_status_e result(eap_status_ok);
       
  4992 
  4811 	if (aValidationResult.Error().iReason == EValidatedOK) 
  4993 	if (aValidationResult.Error().iReason == EValidatedOK) 
  4812 	{
  4994 	{
  4813 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, 
  4995 		EAP_TRACE_DEBUG(
  4814 			(EAPL("Certificate chain validation OK. Reason: %d\n"), 
  4996 			m_am_tools,
  4815 			aValidationResult.Error().iReason));
  4997 			TRACE_FLAGS_DEFAULT, 
       
  4998 			(EAPL("Certificate chain validation OK. Reason: %d=%s\n"), 
       
  4999 			aValidationResult.Error().iReason,
       
  5000 			get_certificate_error_string(aValidationResult.Error().iReason)));
       
  5001 
  4816 		result = eap_status_ok;
  5002 		result = eap_status_ok;
  4817 	}
  5003 	}
  4818 	else
  5004 	else
  4819 	{
  5005 	{
  4820 		if (aValidationResult.Error().iReason == EDateOutOfRange)
  5006 		if (aValidationResult.Error().iReason == EDateOutOfRange)
  4826 		{
  5012 		{
  4827 			send_error_notification(eap_status_illegal_certificate);
  5013 			send_error_notification(eap_status_illegal_certificate);
  4828 			// Ignore error on purpose			
  5014 			// Ignore error on purpose			
  4829 		}
  5015 		}
  4830 
  5016 
  4831 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, 
  5017 		EAP_TRACE_DEBUG(
  4832 			(EAPL("ERROR: Certificate chain validation FAILED. Reason: %d\n"), 
  5018 			m_am_tools,
  4833 			aValidationResult.Error().iReason));
  5019 			TRACE_FLAGS_DEFAULT, 
       
  5020 			(EAPL("ERROR: Certificate chain validation FAILED. Reason: %d=%s\n"), 
       
  5021 			aValidationResult.Error().iReason,
       
  5022 			get_certificate_error_string(aValidationResult.Error().iReason)));
  4834 			
  5023 			
  4835 		result = eap_status_illegal_certificate;
  5024 		result = eap_status_illegal_certificate;
  4836 	}
  5025 	}
  4837 
  5026 
  4838 	// Copy the public key
  5027 	// Copy the public key
  4849 
  5038 
  4850 	get_tls_am_partner()->complete_verify_certificate_chain(result);
  5039 	get_tls_am_partner()->complete_verify_certificate_chain(result);
  4851 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5040 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4852 }
  5041 }
  4853 
  5042 
       
  5043 //--------------------------------------------------
       
  5044 
  4854 #if defined(USE_FAST_EAP_TYPE)
  5045 #if defined(USE_FAST_EAP_TYPE)
  4855 #if defined(USE_EAP_CONFIGURATION_TO_SKIP_USER_INTERACTIONS)
  5046 #if defined(USE_EAP_CONFIGURATION_TO_SKIP_USER_INTERACTIONS)
       
  5047 
  4856 eap_status_e eap_am_type_tls_peap_symbian_c::ReadFileConfig()
  5048 eap_status_e eap_am_type_tls_peap_symbian_c::ReadFileConfig()
  4857     {
  5049 {
  4858         eap_status_e status = eap_status_ok;
  5050 	eap_status_e status = eap_status_ok;
  4859         
  5051 
  4860         eap_am_file_input_symbian_c * const fileio = new eap_am_file_input_symbian_c(m_am_tools);
  5052 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  4861 
  5053 
  4862         eap_automatic_variable_c<eap_am_file_input_symbian_c> automatic_fileio(m_am_tools, fileio);
  5054 	status = EapConfigToolsSymbian::EapReadDefaultConfigFileSymbian(
  4863 
  5055 	m_am_tools,
  4864         if (fileio != 0
  5056 	&m_fileconfig);
  4865             && fileio->get_is_valid() == true)
  5057 	if (status != eap_status_ok)
  4866         {
  5058 	{
  4867             EAP_TRACE_DEBUG(
  5059 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4868                 m_am_tools,
  5060 		return EAP_STATUS_RETURN(m_am_tools, status);
  4869                 TRACE_FLAGS_DEFAULT,
  5061 	}
  4870                 (EAPL("Initialize file configuration.\n")));
  5062 
  4871 
  5063 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  4872             eap_variable_data_c file_name_c_data(m_am_tools);
  5064 
  4873 
  5065 
  4874              {
  5066 	eap_variable_data_c skip_user_interactions(m_am_tools);
  4875                 #if defined(EAPOL_SYMBIAN_VERSION_7_0_s)
  5067 
  4876                     eap_const_string const FILECONFIG_FILENAME_C
  5068 	if (m_fileconfig != 0
  4877                         = "c:\\system\\data\\eap.conf";
  5069 	&& m_fileconfig->get_is_valid() == true)
  4878                 #else
  5070 	{
  4879                     eap_const_string const FILECONFIG_FILENAME_C
  5071 		// Here we could try the final configuration option.
  4880                         = "c:\\private\\101F8EC5\\eap.conf";
  5072 		status = m_fileconfig->read_configure(
  4881                 #endif
  5073 			cf_str_EAP_skip_user_interactions_for_testing_purposes.get_field(),
  4882 
  5074 			&skip_user_interactions);
  4883                 status = file_name_c_data.set_copy_of_buffer(
  5075 	}
  4884                     FILECONFIG_FILENAME_C,
  5076 
  4885                     m_am_tools->strlen(FILECONFIG_FILENAME_C));
  5077 	if (status == eap_status_ok
  4886                 if (status != eap_status_ok)
  5078 	&& skip_user_interactions.get_is_valid_data() == true)
  4887                 {
  5079 	{
  4888                     EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5080 		u32_t *skip_user_interactions_flag = reinterpret_cast<u32_t *>(
  4889                     return EAP_STATUS_RETURN(m_am_tools, status);
  5081 			skip_user_interactions.get_data(sizeof(u32_t)));
  4890                 }
  5082 		if (skip_user_interactions_flag != 0)
  4891 
  5083 		{
  4892                 status = file_name_c_data.add_end_null();
  5084 			if (*skip_user_interactions_flag != 0)
  4893                 if (status != eap_status_ok)
  5085 			{
  4894                 {
  5086 				m_skip_user_interactions = true;
  4895                     EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5087 			}
  4896                     return EAP_STATUS_RETURN(m_am_tools, status);
  5088 			else
  4897                 }
  5089 			{
  4898             }
  5090 				m_skip_user_interactions = false;
  4899 
  5091 			}
  4900             eap_variable_data_c file_name_z_data(m_am_tools);
  5092 		}
  4901 
  5093 	}
  4902             {
  5094 
  4903                 #if defined(EAPOL_SYMBIAN_VERSION_7_0_s)
  5095 	iPacStoreDb->SkipUserActions(m_skip_user_interactions);        
  4904                     eap_const_string const FILECONFIG_FILENAME_Z
  5096 
  4905                         = "z:\\system\\data\\eap.conf";
  5097 	return status;
  4906                 #else
  5098 }
  4907                     eap_const_string const FILECONFIG_FILENAME_Z
  5099 
  4908                         = "z:\\private\\101F8EC5\\eap.conf";
       
  4909                 #endif
       
  4910 
       
  4911                 status = file_name_z_data.set_copy_of_buffer(
       
  4912                     FILECONFIG_FILENAME_Z,
       
  4913                     m_am_tools->strlen(FILECONFIG_FILENAME_Z));
       
  4914                 if (status != eap_status_ok)
       
  4915                 {
       
  4916                     EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  4917                     return EAP_STATUS_RETURN(m_am_tools, status);
       
  4918                 }
       
  4919 
       
  4920                 status = file_name_z_data.add_end_null();
       
  4921                 if (status != eap_status_ok)
       
  4922                 {
       
  4923                     EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  4924                     return EAP_STATUS_RETURN(m_am_tools, status);
       
  4925                 }
       
  4926             }
       
  4927 
       
  4928 
       
  4929 
       
  4930             if (status == eap_status_ok)
       
  4931             {
       
  4932                 // First try open from C: disk.
       
  4933                 status = fileio->file_open(
       
  4934                     &file_name_c_data,
       
  4935                     eap_file_io_direction_read);
       
  4936                 if (status == eap_status_ok)
       
  4937                 {
       
  4938                     EAP_TRACE_DEBUG(
       
  4939                         m_am_tools,
       
  4940                         TRACE_FLAGS_DEFAULT,
       
  4941                         (EAPL("Opens configure file %s\n"),
       
  4942                         file_name_c_data.get_data(file_name_c_data.get_data_length())));
       
  4943                 }
       
  4944                 else if (status != eap_status_ok)
       
  4945                 {
       
  4946                     // Second try open from Z: disk.
       
  4947                     status = fileio->file_open(
       
  4948                         &file_name_z_data,
       
  4949                         eap_file_io_direction_read);
       
  4950                     if (status == eap_status_ok)
       
  4951                     {
       
  4952                         EAP_TRACE_DEBUG(
       
  4953                             m_am_tools,
       
  4954                             TRACE_FLAGS_DEFAULT,
       
  4955                             (EAPL("Opens configure file %s\n"),
       
  4956                              file_name_z_data.get_data(file_name_z_data.get_data_length())));
       
  4957                     }
       
  4958                 }
       
  4959 
       
  4960                 if (status == eap_status_ok)
       
  4961                 {
       
  4962                     // Some of the files were opened.
       
  4963 
       
  4964                     m_fileconfig = new eap_file_config_c(m_am_tools);
       
  4965                     if (m_fileconfig != 0
       
  4966                         && m_fileconfig->get_is_valid() == true)
       
  4967                     {
       
  4968                         status = m_fileconfig->configure(fileio);
       
  4969                         if (status != eap_status_ok)
       
  4970                         {
       
  4971                             EAP_TRACE_DEBUG(
       
  4972                                 m_am_tools,
       
  4973                                 TRACE_FLAGS_DEFAULT,
       
  4974                                 (EAPL("ERROR: Configure read from %s failed.\n"),
       
  4975                                 file_name_c_data.get_data(file_name_c_data.get_data_length())));
       
  4976                         }
       
  4977                         else
       
  4978                         {
       
  4979                             EAP_TRACE_DEBUG(
       
  4980                                 m_am_tools,
       
  4981                                 TRACE_FLAGS_DEFAULT,
       
  4982                                 (EAPL("Configure read from %s\n"),
       
  4983                                 file_name_c_data.get_data(file_name_c_data.get_data_length())));
       
  4984                         }
       
  4985                     }
       
  4986                     else
       
  4987                     {
       
  4988                         // No file configuration.
       
  4989                         delete m_fileconfig;
       
  4990                         m_fileconfig = 0;
       
  4991 
       
  4992                         EAP_TRACE_DEBUG(
       
  4993                             m_am_tools,
       
  4994                             TRACE_FLAGS_DEFAULT,
       
  4995                             (EAPL("ERROR: Cannot create configure object for file %s\n"),
       
  4996                             file_name_c_data.get_data(file_name_c_data.get_data_length())));
       
  4997                     }
       
  4998                 }
       
  4999                 else
       
  5000                 {
       
  5001                     EAP_TRACE_DEBUG(
       
  5002                         m_am_tools,
       
  5003                         TRACE_FLAGS_DEFAULT,
       
  5004                         (EAPL("ERROR: Cannot open configure file neither %s nor %s\n"),
       
  5005                         file_name_c_data.get_data(file_name_c_data.get_data_length()),
       
  5006                         file_name_z_data.get_data(file_name_z_data.get_data_length())));
       
  5007                 }
       
  5008             }
       
  5009         }
       
  5010         else
       
  5011         {
       
  5012             EAP_TRACE_DEBUG(
       
  5013                 m_am_tools,
       
  5014                 TRACE_FLAGS_DEFAULT,
       
  5015                 (EAPL("Skips file configuration.\n")));
       
  5016         }
       
  5017 
       
  5018     eap_variable_data_c skip_user_interactions(m_am_tools);
       
  5019 
       
  5020     if (m_fileconfig != 0
       
  5021             && m_fileconfig->get_is_valid() == true)
       
  5022         {
       
  5023             // Here we could try the final configuration option.
       
  5024             status = m_fileconfig->read_configure(
       
  5025                     cf_str_EAP_skip_user_interactions_for_testing_purposes.get_field(),
       
  5026                     &skip_user_interactions);
       
  5027         }
       
  5028 
       
  5029     if (status == eap_status_ok
       
  5030         && skip_user_interactions.get_is_valid_data() == true)
       
  5031     {
       
  5032         u32_t *skip_user_interactions_flag = reinterpret_cast<u32_t *>(
       
  5033             skip_user_interactions.get_data(sizeof(u32_t)));
       
  5034         if (skip_user_interactions_flag != 0)
       
  5035         {
       
  5036             if (*skip_user_interactions_flag != 0)
       
  5037             {
       
  5038                 m_skip_user_interactions = true;
       
  5039             }
       
  5040             else
       
  5041             {
       
  5042                 m_skip_user_interactions = false;
       
  5043             }
       
  5044         }
       
  5045     }
       
  5046 
       
  5047     iPacStoreDb->SkipUserActions (m_skip_user_interactions);        
       
  5048     
       
  5049      return status;
       
  5050     }
       
  5051 #endif //#if defined(USE_EAP_CONFIGURATION_TO_SKIP_USER_INTERACTIONS)
  5100 #endif //#if defined(USE_EAP_CONFIGURATION_TO_SKIP_USER_INTERACTIONS)
  5052 #endif
  5101 #endif
  5053 
  5102 
  5054 
  5103 
  5055 //--------------------------------------------------
  5104 //--------------------------------------------------
  5070 	m_state = EHandlingChainQuery;
  5119 	m_state = EHandlingChainQuery;
  5071 	TInt err(KErrNone);
  5120 	TInt err(KErrNone);
  5072 
  5121 
  5073 	if (m_is_client)
  5122 	if (m_is_client)
  5074 	{
  5123 	{
  5075 		// Get the matching certificates
  5124 		// client
       
  5125 		// Get the matching certificates. This function call is completed asyncronously by complete_get_matching_certificates() function call.
  5076 		TRAPD(err, m_cert_if->GetMatchingCertificatesL(
  5126 		TRAPD(err, m_cert_if->GetMatchingCertificatesL(
  5077 			m_allowed_user_certs, 
  5127 			m_allowed_user_certs, 
  5078 			ETrue, 
  5128 			ETrue, 
  5079 			certificate_authorities, 
  5129 			certificate_authorities, 
  5080 			ETrue, 
  5130 			ETrue, 
  5085 		(void)EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(err));
  5135 		(void)EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(err));
  5086 	}
  5136 	}
  5087 	else
  5137 	else
  5088 	{
  5138 	{
  5089 		// server
  5139 		// server
       
  5140 		// Get the matching certificates. This function call is completed asyncronously by complete_get_matching_certificates() function call.
  5090 		TRAPD(err, m_cert_if->GetMatchingCertificatesL(
  5141 		TRAPD(err, m_cert_if->GetMatchingCertificatesL(
  5091 				m_allowed_user_certs, 
  5142 				m_allowed_user_certs, 
  5092 				EFalse, 
  5143 				EFalse, 
  5093 				0, 
  5144 				0, 
  5094 				EFalse, 
  5145 				EFalse, 
  5114 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5165 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5115 	return EAP_STATUS_RETURN(m_am_tools, status);
  5166 	return EAP_STATUS_RETURN(m_am_tools, status);
  5116 
  5167 
  5117 }
  5168 }
  5118 
  5169 
       
  5170 //--------------------------------------------------
       
  5171 
  5119 void eap_am_type_tls_peap_symbian_c::complete_get_matching_certificates(
  5172 void eap_am_type_tls_peap_symbian_c::complete_get_matching_certificates(
  5120 	CArrayFixFlat<SCertEntry>& aMatchingCerts,
  5173 	RPointerArray<EapCertificateEntry>& aMatchingCerts,
  5121 	eap_status_e aStatus)
  5174 	eap_status_e aStatus)
  5122 {
  5175 {
  5123 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  5176 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  5124 
  5177 
  5125 	EAP_UNREFERENCED_PARAMETER(aStatus);
  5178 	EAP_UNREFERENCED_PARAMETER(aStatus);
  5136 			TRACE_FLAGS_DEFAULT,
  5189 			TRACE_FLAGS_DEFAULT,
  5137 			(EAPL("eap_am_type_tls_peap_symbian_c::complete_get_matching_certificates(): EHandlingIdentityQuery\n")));
  5190 			(EAPL("eap_am_type_tls_peap_symbian_c::complete_get_matching_certificates(): EHandlingIdentityQuery\n")));
  5138 
  5191 
  5139 		// Add found certs to allowed certificate list.
  5192 		// Add found certs to allowed certificate list.
  5140 		// This list is updated here because there might be certificates that have been removed.
  5193 		// This list is updated here because there might be certificates that have been removed.
  5141 		m_allowed_user_certs.Reset();
  5194 		m_allowed_user_certs.ResetAndDestroy();
  5142 		for (TInt i = 0; i < aMatchingCerts.Count(); i++)
  5195 
  5143 		{
  5196 		for (TInt i = 0; i < aMatchingCerts.Count() && aMatchingCerts[i] != 0; i++)
  5144 			TRAPD(err, m_allowed_user_certs.AppendL(aMatchingCerts[i]));
  5197 		{
  5145 			if (err != KErrNone)
  5198 			EapCertificateEntry * const entry = aMatchingCerts[i]->Copy();
       
  5199 			if (entry == 0)
  5146 			{
  5200 			{
  5147 				EAP_TRACE_DEBUG(
  5201 				EAP_TRACE_DEBUG(
  5148 					m_am_tools,
  5202 					m_am_tools,
  5149 					TRACE_FLAGS_DEFAULT,
  5203 					TRACE_FLAGS_DEFAULT,
  5150 					(EAPL("ERROR: eap_am_type_tls_peap_symbian_c::complete_get_matching_certificates -EHandlingIdentityQuery- Error=%d\n"),
  5204 					(EAPL("ERROR: EAP-TLS: No memory.\n")));
  5151 					err));
  5205 
       
  5206 				get_am_partner()->complete_eap_identity_query(
       
  5207 					0, // 0 because identity query failed
       
  5208 					&m_receive_network_id,
       
  5209 					m_eap_identifier,
       
  5210 					eap_status_allocation_error, 
       
  5211 					false, 
       
  5212 					0, 
       
  5213 					false, 
       
  5214 					0);
       
  5215 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  5216 				return;	
       
  5217 			}
       
  5218 
       
  5219 			TInt error = m_allowed_user_certs.Append(entry->Copy());
       
  5220 			if (error != KErrNone)
       
  5221 			{
       
  5222 				EAP_TRACE_DEBUG(
       
  5223 					m_am_tools,
       
  5224 					TRACE_FLAGS_DEFAULT,
       
  5225 					(EAPL("ERROR: eap_am_type_tls_peap_symbian_c::complete_get_matching_certificates(): -EHandlingIdentityQuery- Error=%d\n"),
       
  5226 					error));
  5152 			
  5227 			
  5153 				get_am_partner()->complete_eap_identity_query(
  5228 				get_am_partner()->complete_eap_identity_query(
  5154 					0, // 0 because identity query failed
  5229 					0, // 0 because identity query failed
  5155 					&m_receive_network_id,
  5230 					&m_receive_network_id,
  5156 					m_eap_identifier,
  5231 					m_eap_identifier,
  5198 				// Since there is no user certificate or manual realm configured
  5273 				// Since there is no user certificate or manual realm configured
  5199 				// the realm needs to be dig out from the CA certificate.
  5274 				// the realm needs to be dig out from the CA certificate.
  5200 				EAP_TRACE_DEBUG(
  5275 				EAP_TRACE_DEBUG(
  5201 					m_am_tools, 
  5276 					m_am_tools, 
  5202 					TRACE_FLAGS_DEFAULT, 
  5277 					TRACE_FLAGS_DEFAULT, 
  5203 					(EAPL("eap_am_type_tls_peap_symbian_c: no manual realm - no user cert. Get realm from CA certificate.\n")));
  5278 					(EAPL("eap_am_type_tls_peap_symbian_c::complete_get_matching_certificates(): no manual realm - no user cert. Get realm from CA certificate.\n")));
  5204 				
  5279 				
  5205 				TInt allowed_ca_cert_count = m_allowed_ca_certs.Count();
  5280 				TInt allowed_ca_cert_count = m_allowed_ca_certs.Count();
  5206 				TInt err(KErrNone);
  5281 				TInt err(KErrNone);
  5207 				
  5282 
  5208 				if(allowed_ca_cert_count > 0)
  5283 				if(allowed_ca_cert_count > 0)
  5209 				{
  5284 				{
  5210 					TRAP(err, m_cert_if->ReadCACertificateL(m_allowed_ca_certs[0]));
  5285 					TRAP(err, m_cert_if->ReadCACertificateL(*m_allowed_ca_certs[0]));
  5211 				}
  5286 				}
  5212 				if (err != KErrNone || allowed_ca_cert_count <= 0)
  5287 
       
  5288 				if (err != KErrNone
       
  5289 					|| allowed_ca_cert_count <= 0)
  5213 				{
  5290 				{
  5214 					EAP_TRACE_DEBUG(
  5291 					if (m_use_automatic_ca_certificate == false)
  5215 					m_am_tools,
  5292 					{
  5216 					TRACE_FLAGS_DEFAULT,
  5293 						EAP_TRACE_DEBUG(
  5217 					(EAPL("ERROR: EAP-TLS: Cannot read user certificate or No CA cert configured, CA cert count=%d.\n"),
  5294 							m_am_tools,
  5218 					allowed_ca_cert_count));
  5295 							TRACE_FLAGS_DEFAULT,
  5219 
  5296 							(EAPL("ERROR: EAP-TLS: eap_am_type_tls_peap_symbian_c::complete_get_matching_certificates(): Cannot read user certificate and no CA cert configured, CA cert count=%d.\n"),
  5220 					get_am_partner()->complete_eap_identity_query(
  5297 							allowed_ca_cert_count));
  5221 						0, // 0 because identity query failed
  5298 
  5222 						&m_receive_network_id,
  5299 						get_am_partner()->complete_eap_identity_query(
  5223 						m_eap_identifier,
  5300 							0, // 0 because identity query failed
  5224 						eap_status_illegal_certificate, 
  5301 							&m_receive_network_id,
  5225 						false, 
  5302 							m_eap_identifier,
  5226 						0, 
  5303 							eap_status_illegal_certificate, 
  5227 						false, 
  5304 							false, 
  5228 						0);
  5305 							0, 
  5229 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5306 							false, 
  5230 					return;	
  5307 							0);
       
  5308 
       
  5309 						EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  5310 						return;
       
  5311 					}
       
  5312 					else
       
  5313 					{
       
  5314 						EAP_TRACE_DEBUG(
       
  5315 							m_am_tools,
       
  5316 							TRACE_FLAGS_DEFAULT,
       
  5317 							(EAPL("WARNING: EAP-TLS: eap_am_type_tls_peap_symbian_c::complete_get_matching_certificates(): Cannot read user certificate and automatic CA cert configured, CA cert count=%d.\n"),
       
  5318 							m_allowed_ca_certs.Count()));
       
  5319 
       
  5320 						get_am_partner()->complete_eap_identity_query(
       
  5321 							0, // 0 because certificate query failed
       
  5322 							&m_receive_network_id,
       
  5323 							m_eap_identifier,
       
  5324 							eap_status_ok, 
       
  5325 							false, 
       
  5326 							0, 
       
  5327 							false, 
       
  5328 							0);
       
  5329 					}
  5231 				}
  5330 				}
       
  5331 
  5232 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5332 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5233 				return;
  5333 				return;
  5234 			}
  5334 			}
  5235 			else
  5335 			else
  5236 			{
  5336 			{
  5238 					m_am_tools,
  5338 					m_am_tools,
  5239 					TRACE_FLAGS_DEFAULT,
  5339 					TRACE_FLAGS_DEFAULT,
  5240 					(EAPL("EAP-TLS: Uses manual realm.\n")));
  5340 					(EAPL("EAP-TLS: Uses manual realm.\n")));
  5241 
  5341 
  5242 				get_am_partner()->complete_eap_identity_query(
  5342 				get_am_partner()->complete_eap_identity_query(
  5243 						0, // 0 because certificate query failed
  5343 					0, // 0 because certificate query failed
  5244 						&m_receive_network_id,
  5344 					&m_receive_network_id,
  5245 						m_eap_identifier,
  5345 					m_eap_identifier,
  5246 						eap_status_ok, 
  5346 					eap_status_ok, 
  5247 						m_use_manual_username, 
  5347 					m_use_manual_username, 
  5248 						&m_manual_username, 
  5348 					&m_manual_username, 
  5249 						m_use_manual_realm, 
  5349 					m_use_manual_realm, 
  5250 						&m_manual_realm);
  5350 					&m_manual_realm);
  5251 
  5351 
  5252 			}
  5352 			}
  5253 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
  5353 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
  5254 			return;
  5354 			return;
  5255 		}
  5355 		}
  5263 	else if (m_state == EHandlingChainQuery)
  5363 	else if (m_state == EHandlingChainQuery)
  5264 	{
  5364 	{
  5265 		
  5365 		
  5266 		if (aMatchingCerts.Count() > 0)
  5366 		if (aMatchingCerts.Count() > 0)
  5267 		{
  5367 		{
  5268 				m_allowed_user_certs.Reset();
  5368 			TInt error;
  5269 			
  5369 
  5270 				for (TInt i = 0; i < aMatchingCerts.Count(); i++)
  5370 			m_allowed_user_certs.ResetAndDestroy();
       
  5371 		
       
  5372 			for (TInt i = 0; i < aMatchingCerts.Count(); i++)
       
  5373 			{
       
  5374 				EapCertificateEntry * const entry = aMatchingCerts[i]->Copy();
       
  5375 				if (entry != 0)
  5271 				{
  5376 				{
  5272 					TRAPD(err, m_allowed_user_certs.AppendL(aMatchingCerts[i]));
  5377 					TRAP(error, m_allowed_user_certs.AppendL(entry));
  5273 					if (err != KErrNone)
  5378 				}
  5274 					{
  5379 				else
  5275 						EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_tls_peap_symbian_c::complete_get_matching_certificates -EHandlingChainQuery- Error=%d\n"),
  5380 				{
  5276 						err));
  5381 					error = KErrNoMemory;
  5277 									
  5382 				}
  5278 						get_tls_am_partner()->complete_query_certificate_chain(0, eap_status_allocation_error);
  5383 
  5279 						EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);		
  5384 				if (error != KErrNone)
  5280 						return;					
  5385 				{
  5281 					} 
  5386 					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"),
       
  5387 						error));
       
  5388 								
       
  5389 					get_tls_am_partner()->complete_query_certificate_chain(0, eap_status_allocation_error);
       
  5390 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);		
       
  5391 					return;					
       
  5392 				} 
  5282 			}	
  5393 			}	
  5283 		}
  5394 		}
  5284 
  5395 
  5285 		if (m_allowed_user_certs.Count() == 0)
  5396 		if (m_allowed_user_certs.Count() == 0)
  5286 		{
  5397 		{
  5287 			// No matching or allowed certs and no pre-loaded cert.
  5398 			// No matching or allowed certs and no pre-loaded cert.
  5288 			// Could not find matching certificate
  5399 			// Could not find matching certificate
  5289 
  5400 
  5290 			EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("EAP-TLS: Could not find proper user certificate.\n")));
  5401 			EAP_TRACE_DEBUG(
       
  5402 				m_am_tools,
       
  5403 				TRACE_FLAGS_DEFAULT,
       
  5404 				(EAPL("EAP-TLS: Could not find proper user certificate.\n")));
  5291 
  5405 
  5292 			if (m_tls_peap_server_authenticates_client_policy_flag == true)
  5406 			if (m_tls_peap_server_authenticates_client_policy_flag == true)
  5293 			{
  5407 			{
       
  5408 				EAP_TRACE_DEBUG(
       
  5409 					m_am_tools,
       
  5410 					TRACE_FLAGS_DEFAULT,
       
  5411 					(EAPL("ERROR: EAP-TLS: Could not find proper user certificate and anonymous cliet is not allowed.\n")));
       
  5412 
  5294 				send_error_notification(eap_status_user_certificate_unknown);
  5413 				send_error_notification(eap_status_user_certificate_unknown);
  5295 			}
  5414 			}
  5296 
  5415 
  5297 			get_tls_am_partner()->complete_query_certificate_chain(0, eap_status_illegal_certificate);
  5416 			get_tls_am_partner()->complete_query_certificate_chain(0, eap_status_illegal_certificate);
  5298 
  5417 
  5311 	}
  5430 	}
  5312 	else
  5431 	else
  5313 	{
  5432 	{
  5314 		EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("EAP-TLS: Illegal state in complete_get_matching_certs.\n")));
  5433 		EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("EAP-TLS: Illegal state in complete_get_matching_certs.\n")));
  5315 	}
  5434 	}
       
  5435 
  5316 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
  5436 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
  5317 	return;
  5437 	return;
  5318 }
  5438 }
  5319 
  5439 
       
  5440 //--------------------------------------------------
  5320 
  5441 
  5321 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::query_certificate_authorities_and_types()
  5442 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::query_certificate_authorities_and_types()
  5322 {
  5443 {
  5323 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  5444 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  5324 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("\n")));
  5445 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("\n")));
  5555 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5676 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5556 	return EAP_STATUS_RETURN(m_am_tools, status);
  5677 	return EAP_STATUS_RETURN(m_am_tools, status);
  5557 }
  5678 }
  5558 
  5679 
  5559 //--------------------------------------------------
  5680 //--------------------------------------------------
  5560 
       
  5561 
  5681 
  5562 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::save_tls_session(
  5682 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::save_tls_session(
  5563 	const eap_variable_data_c * const session_id,
  5683 	const eap_variable_data_c * const session_id,
  5564 	const eap_variable_data_c * const master_secret,
  5684 	const eap_variable_data_c * const master_secret,
  5565 	const tls_cipher_suites_e used_cipher_suite
  5685 	const tls_cipher_suites_e used_cipher_suite
  5649 #endif //#if defined(USE_EAP_TLS_SESSION_TICKET)
  5769 #endif //#if defined(USE_EAP_TLS_SESSION_TICKET)
  5650 
  5770 
  5651 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5771 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5652 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
  5772 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
  5653 }
  5773 }
  5654 //--------------------------------------------------
  5774 
  5655 //--------------------------------------------------
  5775 //--------------------------------------------------
  5656 
  5776 
  5657 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::rsa_encrypt_with_public_key(
  5777 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::rsa_encrypt_with_public_key(
  5658 	const eap_variable_data_c * const premaster_secret)
  5778 	const eap_variable_data_c * const premaster_secret)
  5659 {
  5779 {
  5729 	TPtr8 ptr = data->Des();
  5849 	TPtr8 ptr = data->Des();
  5730 
  5850 
  5731 	ptr.Copy(encrypted_premaster_secret->get_data(encrypted_premaster_secret->get_data_length()), 
  5851 	ptr.Copy(encrypted_premaster_secret->get_data(encrypted_premaster_secret->get_data_length()), 
  5732 		encrypted_premaster_secret->get_data_length());
  5852 		encrypted_premaster_secret->get_data_length());
  5733 
  5853 
  5734 	TRAP(err, m_cert_if->DecryptL(m_own_certificate_info.iSubjectKeyId, *data));
  5854 	TRAP(err, m_cert_if->DecryptL(m_own_certificate_info.GetSubjectKeyId(), *data));
  5735 
  5855 
  5736 	if (err != KErrNone)
  5856 	if (err != KErrNone)
  5737 	{
  5857 	{
  5738 		status = m_am_tools->convert_am_error_to_eapol_error(err);
  5858 		status = m_am_tools->convert_am_error_to_eapol_error(err);
  5739 	}
  5859 	}
  5791 
  5911 
  5792 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5912 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5793 }
  5913 }
  5794 
  5914 
  5795 //--------------------------------------------------
  5915 //--------------------------------------------------
       
  5916 
  5796 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::sign_with_private_key(
  5917 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::sign_with_private_key(
  5797 	const eap_variable_data_c * const message_hash)
  5918 	const eap_variable_data_c * const message_hash)
  5798 {
  5919 {
  5799 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  5920 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  5800 
  5921 
  5849 		// public_key_data actually has the asn.1 header so it is a few bytes longer
  5970 		// public_key_data actually has the asn.1 header so it is a few bytes longer
  5850 		// than the actual signature.
  5971 		// than the actual signature.
  5851 		signature_length = public_key_data.Size();
  5972 		signature_length = public_key_data.Size();
  5852 	}
  5973 	}
  5853 
  5974 
  5854 	TRAP(err, m_cert_if->SignL(m_own_certificate_info.iSubjectKeyId, hash, signature_length));
  5975 	TRAP(err, m_cert_if->SignL(m_own_certificate_info.GetSubjectKeyId(), hash, signature_length));
  5855 	if (err != KErrNone)
  5976 	if (err != KErrNone)
  5856 	{
  5977 	{
  5857 		status = m_am_tools->convert_am_error_to_eapol_error(err);
  5978 		status = m_am_tools->convert_am_error_to_eapol_error(err);
  5858 	}
  5979 	}
  5859 	else
  5980 	else
  5865 
  5986 
  5866 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5987 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5867 	return EAP_STATUS_RETURN(m_am_tools, status);
  5988 	return EAP_STATUS_RETURN(m_am_tools, status);
  5868 		
  5989 		
  5869 }
  5990 }
       
  5991 
  5870 //--------------------------------------------------
  5992 //--------------------------------------------------
       
  5993 
  5871 void eap_am_type_tls_peap_symbian_c::complete_sign(
  5994 void eap_am_type_tls_peap_symbian_c::complete_sign(
  5872 	const RInteger& aR, const RInteger& aS, eap_status_e aStatus)
  5995 	const RInteger& aR, const RInteger& aS, eap_status_e aStatus)
  5873 {
  5996 {
  5874 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  5997 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  5875 
  5998 
  5885 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: complete_signL leaved.\n")));
  6008 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: complete_signL leaved.\n")));
  5886 		get_tls_am_partner()->complete_sign_with_private_key(0, m_am_tools->convert_am_error_to_eapol_error(err));
  6009 		get_tls_am_partner()->complete_sign_with_private_key(0, m_am_tools->convert_am_error_to_eapol_error(err));
  5887 	}
  6010 	}
  5888 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6011 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5889 }
  6012 }
       
  6013 
       
  6014 //--------------------------------------------------
  5890 
  6015 
  5891 void eap_am_type_tls_peap_symbian_c::complete_signL(
  6016 void eap_am_type_tls_peap_symbian_c::complete_signL(
  5892 	const RInteger& aR, const RInteger& aS, eap_status_e aStatus)
  6017 	const RInteger& aR, const RInteger& aS, eap_status_e aStatus)
  5893 {
  6018 {
  5894 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6019 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6047 			message_hash,
  6172 			message_hash,
  6048 			signed_message_hash);
  6173 			signed_message_hash);
  6049 	}
  6174 	}
  6050 	else
  6175 	else
  6051 	{
  6176 	{
  6052 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: Signing with private key failed.\n")));
  6177 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: Verify with private key failed.\n")));
  6053 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6178 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6054 		return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported);
  6179 		return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported);
  6055 	}
  6180 	}
  6056 
  6181 
  6057 	status = get_tls_am_partner()->complete_verify_with_public_key(status); 
  6182 	status = get_tls_am_partner()->complete_verify_with_public_key(status); 
  6063 	}
  6188 	}
  6064 
  6189 
  6065 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6190 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6066 	return EAP_STATUS_RETURN(m_am_tools, status);
  6191 	return EAP_STATUS_RETURN(m_am_tools, status);
  6067 }
  6192 }
       
  6193 
       
  6194 //--------------------------------------------------
  6068 
  6195 
  6069 void eap_am_type_tls_peap_symbian_c::read_dsa_parametersL()
  6196 void eap_am_type_tls_peap_symbian_c::read_dsa_parametersL()
  6070 {
  6197 {
  6071 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); 
  6198 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); 
  6072 	if (m_peer_certificate == 0)
  6199 	if (m_peer_certificate == 0)
  6121 }
  6248 }
  6122 
  6249 
  6123 //--------------------------------------------------
  6250 //--------------------------------------------------
  6124 // MODULE HANDLING FUNCTIONS
  6251 // MODULE HANDLING FUNCTIONS
  6125 //--------------------------------------------------
  6252 //--------------------------------------------------
       
  6253 
  6126 eap_status_e eap_am_type_tls_peap_symbian_c::load_module(
  6254 eap_status_e eap_am_type_tls_peap_symbian_c::load_module(
  6127 		const eap_type_value_e /*type*/,
  6255 		const eap_type_value_e /*type*/,
  6128 		const eap_type_value_e /* tunneling_type */,
  6256 		const eap_type_value_e /* tunneling_type */,
  6129 		abs_eap_base_type_c * const /*partner*/,
  6257 		abs_eap_base_type_c * const /*partner*/,
  6130 		eap_base_type_c ** const /*eap_type_if*/,
  6258 		eap_base_type_c ** const /*eap_type_if*/,
  6142 {
  6270 {
  6143 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6271 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6144 	
  6272 	
  6145 	eap_status_e status(eap_status_illegal_eap_type);
  6273 	eap_status_e status(eap_status_illegal_eap_type);
  6146 	
  6274 	
  6147 #ifdef USE_EAP_EXPANDED_TYPES
       
  6148 
       
  6149 	EAP_TRACE_DEBUG(m_am_tools, 
  6275 	EAP_TRACE_DEBUG(m_am_tools, 
  6150 		TRACE_FLAGS_DEFAULT, 
  6276 		TRACE_FLAGS_DEFAULT, 
  6151 		(EAPL("eap_am_type_tls_peap_symbian_c::check_is_valid_eap_type:Given EAP vendor ID=%x, type=%x\n"),
  6277 		(EAPL("eap_am_type_tls_peap_symbian_c::check_is_valid_eap_type:Given EAP-type=0xfe%06x%08x\n"),
  6152 		eap_type.get_vendor_id(), eap_type.get_vendor_type()));	
  6278 		eap_type.get_vendor_id(),
       
  6279 		eap_type.get_vendor_type()));	
  6153 		
  6280 		
  6154 	for (TInt i = 0; i < m_enabled_tunneling_exp_eap_array.Count(); i++)
  6281 	for (TInt i = 0; i < m_enabled_tunneling_exp_eap_array.Count(); i++)
  6155 	{
  6282 	{
  6156 		eap_expanded_type_c expEAPTmp;
  6283 		eap_expanded_type_c expEAPTmp;
  6157 		
  6284 		
  6158 		// This will read the expanded EAP from enabledEAPTypes[i]->iExpandedEAPType to expEAPTmp.
  6285 		TInt error = CEapConversion::ConvertExpandedEAPTypeToInternalType(
  6159 		// This makes easy to get the vendor type.
  6286 			m_enabled_tunneling_exp_eap_array[i],
  6160 		eap_expanded_type_c::read_type( m_am_tools,
  6287 			&expEAPTmp);
  6161 										0,
  6288 
  6162 										m_enabled_tunneling_exp_eap_array[i]->iExpandedEAPType.Ptr(),
  6289 		if (error != KErrNone)
  6163 										KExpandedEAPTypeSize,
  6290 		{
  6164 										&expEAPTmp);
  6291 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6165 		
  6292 			return EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(error));
       
  6293 		}
       
  6294 
  6166 		EAP_TRACE_DATA_DEBUG(
  6295 		EAP_TRACE_DATA_DEBUG(
  6167 			m_am_tools,
  6296 			m_am_tools,
  6168 			TRACE_FLAGS_DEFAULT,
  6297 			TRACE_FLAGS_DEFAULT,
  6169 			(EAPL("check_is_valid_eap_type:Checking with EAP type:"),
  6298 			(EAPL("check_is_valid_eap_type:Checking with EAP type:"),
  6170 	 		m_enabled_tunneling_exp_eap_array[i]->iExpandedEAPType.Ptr(),
  6299 	 		m_enabled_tunneling_exp_eap_array[i]->GetValue().Ptr(),
  6171 	 		m_enabled_tunneling_exp_eap_array[i]->iExpandedEAPType.Size()));	 			
  6300 	 		m_enabled_tunneling_exp_eap_array[i]->GetValue().Size()));	 			
  6172 		
  6301 		
  6173 		if (eap_type == expEAPTmp)
  6302 		if (eap_type == expEAPTmp)
  6174 		{
  6303 		{
  6175 			// This EAp type is one among the enabled ones. Hence a valid EAP type.
  6304 			// This EAp type is one among the enabled ones. Hence a valid EAP type.
  6176 			status = eap_status_ok;
  6305 			status = eap_status_ok;
  6177 			break;			
  6306 			break;			
  6178 		}
  6307 		}
  6179 	}
  6308 	}
  6180 
  6309 
  6181 #else // For normal EAP types.
       
  6182 	
       
  6183 	TEap *eapType = 0; 
       
  6184 	
       
  6185 	TInt i(0);
       
  6186 		
       
  6187 	for (i = 0; i < m_iap_eap_array.Count(); i++)
       
  6188 	{
       
  6189 		// Try next EAP type
       
  6190 		eapType = m_iap_eap_array[i];
       
  6191 		if (eapType->Enabled == 1)
       
  6192 		{	
       
  6193 			// Convert the string to integer
       
  6194 			TLex8 tmp(eapType->UID);
       
  6195 			TInt val(0);
       
  6196 			tmp.Val(val);
       
  6197 			if (val == eap_type)
       
  6198 			{
       
  6199 				// Allowed
       
  6200 				status = eap_status_ok;
       
  6201 				break;
       
  6202 			}	
       
  6203 		}
       
  6204 	}
       
  6205 	
       
  6206 #endif //#ifdef USE_EAP_EXPANDED_TYPES	
       
  6207 	
       
  6208 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6310 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6209 
       
  6210 	return EAP_STATUS_RETURN(m_am_tools, status);
  6311 	return EAP_STATUS_RETURN(m_am_tools, status);
  6211 }
  6312 }
  6212 
  6313 
  6213 //--------------------------------------------------
  6314 //--------------------------------------------------
  6214 
  6315 
  6221 		TRACE_FLAGS_DEFAULT, 
  6322 		TRACE_FLAGS_DEFAULT, 
  6222 		(EAPL("eap_am_type_tls_peap_symbian_c::get_eap_type_list - Start\n")));	
  6323 		(EAPL("eap_am_type_tls_peap_symbian_c::get_eap_type_list - Start\n")));	
  6223 
  6324 
  6224 	eap_status_e status(eap_status_illegal_eap_type);
  6325 	eap_status_e status(eap_status_illegal_eap_type);
  6225 
  6326 
  6226 #ifdef USE_EAP_EXPANDED_TYPES
       
  6227 
       
  6228 	// We need to return only the EAP types available as enabled types.
  6327 	// We need to return only the EAP types available as enabled types.
  6229 	// It means only the ones available in m_enabled_tunneling_exp_eap_array.
  6328 	// It means only the ones available in m_enabled_tunneling_exp_eap_array.
  6230 	
  6329 	
  6231 	for (TInt i = 0; i < m_enabled_tunneling_exp_eap_array.Count(); i++)
  6330 	for (TInt i = 0; i < m_enabled_tunneling_exp_eap_array.Count(); i++)
  6232 	{	
  6331 	{	
  6233 		TBuf8<KExpandedEAPTypeSize> tmpExpEAP(m_enabled_tunneling_exp_eap_array[i]->iExpandedEAPType);
       
  6234 
       
  6235 		EAP_TRACE_DEBUG(
  6332 		EAP_TRACE_DEBUG(
  6236 			m_am_tools, 
  6333 			m_am_tools, 
  6237 			TRACE_FLAGS_DEFAULT, 
  6334 			TRACE_FLAGS_DEFAULT, 
  6238 			(EAPL("eap_am_type_tls_peap_symbian_c::get_eap_type_list:Enabled expanded EAP type at index=%d\n"),
  6335 			(EAPL("eap_am_type_tls_peap_symbian_c::get_eap_type_list:Enabled expanded EAP type at index=%d\n"),
  6239 			 i));
  6336 			 i));
  6240 
  6337 
  6241 		EAP_TRACE_DATA_DEBUG(
  6338 		EAP_TRACE_DATA_DEBUG(
  6242 			m_am_tools,
  6339 			m_am_tools,
  6243 			TRACE_FLAGS_DEFAULT,
  6340 			TRACE_FLAGS_DEFAULT,
  6244 			(EAPL("Enabled expanded EAP type:"),
  6341 			(EAPL("Enabled expanded EAP type:"),
  6245 			tmpExpEAP.Ptr(),
  6342 			m_enabled_tunneling_exp_eap_array[i]->GetValue().Ptr(),
  6246 			tmpExpEAP.Size()));
  6343 			m_enabled_tunneling_exp_eap_array[i]->GetValue().Size()));
  6247 
  6344 
  6248 		// This is for one expanded EAP type (for the above one).
  6345 		// This is for one expanded EAP type (for the above one).
  6249 		eap_type_value_e * expandedEAPType = new eap_type_value_e();
  6346 		eap_type_value_e * expandedEAPType = new eap_type_value_e();
  6250 				
  6347 		
  6251 		// Read the expanded EAP type details from an item in m_enabled_tunneling_exp_eap_array.
  6348 		eap_automatic_variable_c<eap_type_value_e> automatic_expandedEAPType(
  6252 		status = eap_type_value_e::read_type(m_am_tools,
  6349 			m_am_tools,
  6253 												0,
  6350 			expandedEAPType);
  6254 												&tmpExpEAP,
  6351 
  6255 												tmpExpEAP.Length(),
  6352 		TInt error = CEapConversion::ConvertExpandedEAPTypeToInternalType(
  6256 												expandedEAPType);
  6353 			m_enabled_tunneling_exp_eap_array[i],
  6257 		if (status != eap_status_ok)
  6354 			expandedEAPType);
  6258 		{
  6355 
  6259 			delete expandedEAPType;
  6356 		if (error != KErrNone)
  6260 			expandedEAPType = 0;
  6357 		{
  6261 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6358 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6262 			return EAP_STATUS_RETURN(m_am_tools, status);
  6359 			return EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(error));
  6263 		}
  6360 		}
       
  6361 
       
  6362 		automatic_expandedEAPType.do_not_free_variable();
  6264 
  6363 
  6265 		// Add EAP-type to list.		
  6364 		// Add EAP-type to list.		
  6266 		status = eap_type_list->add_object(expandedEAPType, true);
  6365 		status = eap_type_list->add_object(expandedEAPType, true);
  6267 		if (status != eap_status_ok)
  6366 		if (status != eap_status_ok)
  6268 		{
  6367 		{
  6274 		EAP_UNREFERENCED_PARAMETER(eap_string);
  6373 		EAP_UNREFERENCED_PARAMETER(eap_string);
  6275 		
  6374 		
  6276 		EAP_TRACE_DEBUG(
  6375 		EAP_TRACE_DEBUG(
  6277 			m_am_tools,
  6376 			m_am_tools,
  6278 			TRACE_FLAGS_DEFAULT,
  6377 			TRACE_FLAGS_DEFAULT,
  6279 			(EAPL("get_eap_type_list():added EAP-type=0x%08x=%s\n"),
  6378 			(EAPL("get_eap_type_list():added EAP-type=0xfe%06x%08x=%s\n"),
       
  6379 			expandedEAPType->get_vendor_id(),
  6280 			expandedEAPType->get_vendor_type(),
  6380 			expandedEAPType->get_vendor_type(),
  6281 			eap_string.get_eap_type_string(*expandedEAPType)));			
  6381 			eap_header_string_c::get_eap_type_string(*expandedEAPType)));			
  6282 	
  6382 	
  6283 	}// for()
  6383 	}// for()
  6284 
       
  6285 #else // for normal EAP types.
       
  6286 
       
  6287 	TEap *eapType = 0; 
       
  6288 
       
  6289 	status = eap_type_list->reset();
       
  6290 	if (status != eap_status_ok)
       
  6291 	{
       
  6292 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  6293 		return EAP_STATUS_RETURN(m_am_tools, status);
       
  6294 	}
       
  6295 
       
  6296 
       
  6297 	for (TInt i = 0; i < m_iap_eap_array.Count(); i++)
       
  6298 	{
       
  6299 		// Check if type is enabled
       
  6300 		eapType = m_iap_eap_array[i];
       
  6301 		if (eapType->Enabled == 1)
       
  6302 		{	
       
  6303 			TLex8 tmp(eapType->UID);
       
  6304 			TInt val(0);
       
  6305 			tmp.Val(val);
       
  6306 
       
  6307 			eap_type_value_e * const eap_type = new eap_type_value_e(static_cast<eap_type_ietf_values_e>(val));
       
  6308 			if (eap_type == 0)
       
  6309 			{
       
  6310 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  6311 				return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  6312 			}
       
  6313 
       
  6314 			status = eap_type_list->add_object(eap_type, true);
       
  6315 			if (status != eap_status_ok)
       
  6316 			{
       
  6317 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  6318 				return EAP_STATUS_RETURN(m_am_tools, status);
       
  6319 			}
       
  6320 		}
       
  6321 	} // for()
       
  6322 
       
  6323 #endif // #ifdef USE_EAP_EXPANDED_TYPES
       
  6324 
  6384 
  6325 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6385 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6326 	return eap_status_ok;
  6386 	return eap_status_ok;
  6327 }
  6387 }
       
  6388 
       
  6389 //--------------------------------------------------
  6328 
  6390 
  6329 eap_status_e eap_am_type_tls_peap_symbian_c::unload_module(const eap_type_value_e /*type*/)
  6391 eap_status_e eap_am_type_tls_peap_symbian_c::unload_module(const eap_type_value_e /*type*/)
  6330 {
  6392 {
  6331 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6393 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6332 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6394 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6333 	return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported);
  6395 	return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported);
  6334 }
  6396 }
  6335 
  6397 
       
  6398 //--------------------------------------------------
  6336 
  6399 
  6337 void eap_am_type_tls_peap_symbian_c::send_error_notification(const eap_status_e error)
  6400 void eap_am_type_tls_peap_symbian_c::send_error_notification(const eap_status_e error)
  6338 {
  6401 {
  6339 	EAP_TRACE_DEBUG(m_am_tools, 
  6402 	EAP_TRACE_DEBUG(m_am_tools, 
  6340 		TRACE_FLAGS_DEFAULT, 
  6403 		TRACE_FLAGS_DEFAULT, 
  6369 	notification.set_authentication_error(error);
  6432 	notification.set_authentication_error(error);
  6370 
  6433 
  6371 	m_partner->state_notification(&notification);
  6434 	m_partner->state_notification(&notification);
  6372 }
  6435 }
  6373 
  6436 
       
  6437 //--------------------------------------------------
       
  6438 
  6374 eap_status_e eap_am_type_tls_peap_symbian_c::show_certificate_selection_dialog()
  6439 eap_status_e eap_am_type_tls_peap_symbian_c::show_certificate_selection_dialog()
  6375 {
  6440 {
  6376 	return eap_status_ok;
  6441 	return eap_status_ok;
  6377 }
  6442 }
       
  6443 
       
  6444 //--------------------------------------------------
  6378 
  6445 
  6379 eap_status_e eap_am_type_tls_peap_symbian_c::show_manual_identity_dialog()
  6446 eap_status_e eap_am_type_tls_peap_symbian_c::show_manual_identity_dialog()
  6380 {
  6447 {
  6381 	return eap_status_ok;
  6448 	return eap_status_ok;
  6382 }
  6449 }
  6383 
  6450 
  6384 //--------------------------------------------------
  6451 //--------------------------------------------------
  6385 // CANCELLATION FUNCTIONS
  6452 // CANCELLATION FUNCTIONS
  6386 //--------------------------------------------------
  6453 //--------------------------------------------------
       
  6454 
  6387 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::cancel_identity_query()
  6455 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::cancel_identity_query()
  6388 {
  6456 {
  6389 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6457 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6390 
  6458 
  6391 	EAP_TRACE_DEBUG(
  6459 	EAP_TRACE_DEBUG(
  6396 	m_cert_if->Cancel(); 
  6464 	m_cert_if->Cancel(); 
  6397 	
  6465 	
  6398 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6466 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6399 	return eap_status_ok;
  6467 	return eap_status_ok;
  6400 }
  6468 }
       
  6469 
       
  6470 //--------------------------------------------------
  6401 
  6471 
  6402 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::cancel_query_cipher_suites_and_previous_session()
  6472 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::cancel_query_cipher_suites_and_previous_session()
  6403 {
  6473 {
  6404 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6474 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6405 
  6475 
  6626 {
  6696 {
  6627 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6697 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6628 
  6698 
  6629 	EAP_TRACE_DEBUG(m_am_tools, 
  6699 	EAP_TRACE_DEBUG(m_am_tools, 
  6630 		TRACE_FLAGS_DEFAULT, (
  6700 		TRACE_FLAGS_DEFAULT, (
  6631 		EAPL("eap_am_type_tls_peap_symbian_c::is_session_valid - m_current_eap_vendor_type=%d \n"),
  6701 		EAPL("eap_am_type_tls_peap_symbian_c::is_session_valid - m_current_eap_vendor_type=0xfe%06x%08x\n"),
  6632 		m_current_eap_vendor_type));
  6702 		m_current_eap_type.get_vendor_id(),
       
  6703 		m_current_eap_type.get_vendor_type()));
  6633 
  6704 
  6634 	TPtrC maxSessionTimeString;
  6705 	TPtrC maxSessionTimeString;
  6635 	TPtrC lastFullAuthTimeString;
  6706 	TPtrC lastFullAuthTimeString;
  6636 
  6707 
  6637 	switch (m_current_eap_vendor_type)
  6708 	if (m_current_eap_type == eap_type_tls)
  6638 	{
  6709 	{
  6639 	case eap_type_tls:
  6710 		maxSessionTimeString.Set(cf_str_EAP_TLS_max_session_validity_time_literal);
  6640 		{
  6711 		lastFullAuthTimeString.Set(KTLSLastFullAuthTime);
  6641 			maxSessionTimeString.Set(cf_str_EAP_TLS_max_session_validity_time_literal);
  6712 	}
  6642 			lastFullAuthTimeString.Set(KTLSLastFullAuthTime);
  6713 	else if (m_current_eap_type == eap_type_peap)
  6643 		}
  6714 	{
  6644 		break;
  6715 		maxSessionTimeString.Set(cf_str_EAP_PEAP_max_session_validity_time_literal);
  6645 
  6716 		lastFullAuthTimeString.Set(KPEAPLastFullAuthTime);
  6646 	case eap_type_peap:
  6717 	}
  6647 		{
  6718 	else if (m_current_eap_type == eap_type_ttls)
  6648 			maxSessionTimeString.Set(cf_str_EAP_PEAP_max_session_validity_time_literal);
  6719 	{
  6649 			lastFullAuthTimeString.Set(KPEAPLastFullAuthTime);
  6720 		maxSessionTimeString.Set(cf_str_EAP_TTLS_max_session_validity_time_literal);
  6650 		}
  6721 		lastFullAuthTimeString.Set(KTTLSLastFullAuthTime);
  6651 		break;
  6722 	}
  6652 	
       
  6653 	case eap_type_ttls:
       
  6654 		{
       
  6655 			maxSessionTimeString.Set(cf_str_EAP_TTLS_max_session_validity_time_literal);
       
  6656 			lastFullAuthTimeString.Set(KTTLSLastFullAuthTime);
       
  6657 		}
       
  6658 		break;
       
  6659 
       
  6660 #if defined(USE_FAST_EAP_TYPE)		
  6723 #if defined(USE_FAST_EAP_TYPE)		
  6661 	case eap_type_fast:
  6724 	else if (m_current_eap_type == eap_type_fast)
  6662 		{
  6725 	{
  6663 			maxSessionTimeString.Set(cf_str_EAP_FAST_max_session_validity_time_literal);
  6726 		maxSessionTimeString.Set(cf_str_EAP_FAST_max_session_validity_time_literal);
  6664 			lastFullAuthTimeString.Set(KFASTLastFullAuthTime);
  6727 		lastFullAuthTimeString.Set(KFASTLastFullAuthTime);
  6665 		}
  6728 	}
  6666 		break;
       
  6667 #endif
  6729 #endif
  6668 		
  6730 	else if (m_current_eap_type == eap_type_ttls_plain_pap)
  6669 	case eap_type_ttls_plain_pap:
  6731 	{
  6670 	    {
  6732 	    // we should not come here, ttls pap has its own
  6671 	        // we should not come here, ttls pap has its own
  6733 	    // method for checking session validity
  6672 	        // method for checking session validity
  6734 	    EAP_TRACE_ERROR( m_am_tools, TRACE_FLAGS_DEFAULT, (
  6673 	        EAP_TRACE_ERROR( m_am_tools, TRACE_FLAGS_DEFAULT, (
  6735 	        EAPL( "ERROR: wrong eap type.\n" ) ) );
  6674 	            EAPL( "ERROR: wrong eap type.\n" ) ) );
  6736 	    return false;
  6675 	        return false;
  6737 	}
  6676 	    }
  6738 	else
  6677 	    
  6739 	{
  6678 	default:
  6740 		// Should never happen
  6679 		{
  6741 		EAP_TRACE_ERROR(m_am_tools, 
  6680 			// Should never happen
  6742 			TRACE_FLAGS_DEFAULT, (
  6681 			EAP_TRACE_ERROR(m_am_tools, 
  6743 			EAPL("Unsupported EAP type, m_current_eap_vendor_type=0xfe%06x%08x\n"),
  6682 				TRACE_FLAGS_DEFAULT, (
  6744 			m_current_eap_type.get_vendor_id(),
  6683 				EAPL("Unsupported EAP type, m_current_eap_vendor_type=%d \n"),
  6745 			m_current_eap_type.get_vendor_type()));
  6684 				m_current_eap_vendor_type));
  6746 			
  6685 				
  6747 		return false; // Treat this as Session invalid.
  6686 			return false; // Treat this as Session invalid.
  6748 	}
  6687 		}
       
  6688 	}	
       
  6689 
  6749 
  6690 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  6750 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  6691 	TPtr sqlStatement = buf->Des();
  6751 	TPtr sqlStatement = buf->Des();
  6692 	
  6752 	
  6693 	// Query all the relevant parameters
  6753 	// Query all the relevant parameters
  6694 	_LIT(KSQLQuery, "SELECT %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d");
  6754 	_LIT(KSQLQuery, "SELECT %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
  6695 	sqlStatement.Format(KSQLQuery, &maxSessionTimeString, &lastFullAuthTimeString, &m_db_table_name,
  6755 
  6696 						&KServiceType, m_index_type, 
  6756 	sqlStatement.Format(
  6697 						&KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);
  6757 		KSQLQuery,
       
  6758 		&maxSessionTimeString,
       
  6759 		&lastFullAuthTimeString,
       
  6760 		&m_db_table_name,
       
  6761 		&KServiceType,
       
  6762 		m_index_type, 
       
  6763 		&KServiceIndex,
       
  6764 		m_index,
       
  6765 		&KTunnelingTypeVendorId,
       
  6766 		m_tunneling_type.get_vendor_id(),
       
  6767 		&KTunnelingType, 
       
  6768 		m_tunneling_type.get_vendor_type());
  6698 
  6769 
  6699 	RDbView view;
  6770 	RDbView view;
  6700 	// Evaluate view
  6771 	// Evaluate view
  6701 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement)));
  6772 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement)));
  6702 	CleanupClosePushL(view);
  6773 	CleanupClosePushL(view);
  6804 {
  6875 {
  6805 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6876 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6806 	
  6877 	
  6807 	EAP_TRACE_DEBUG(m_am_tools, 
  6878 	EAP_TRACE_DEBUG(m_am_tools, 
  6808 		TRACE_FLAGS_DEFAULT, 
  6879 		TRACE_FLAGS_DEFAULT, 
  6809 		(EAPL("eap_am_type_tls_peap_symbian_c::store_authentication_timeL, index type=%d, index=%d, tunneling type=%d, current eap type=%d\n"),
  6880 		(EAPL("eap_am_type_tls_peap_symbian_c::store_authentication_timeL, index type=%d, index=%d, tunneling type=0xfe%06x%08x, current eap type=0xfe%06x%08x\n"),
  6810 		m_index_type, m_index, m_tunneling_vendor_type, m_current_eap_vendor_type));	
  6881 		m_index_type,
       
  6882 		m_index,
       
  6883 		m_tunneling_type.get_vendor_id(),
       
  6884 		m_tunneling_type.get_vendor_type(),
       
  6885 		m_current_eap_type.get_vendor_id(),
       
  6886 		m_current_eap_type.get_vendor_type()));
  6811 
  6887 
  6812 	TPtrC lastFullAuthTimeString;
  6888 	TPtrC lastFullAuthTimeString;
  6813 
  6889 
  6814 	switch (m_current_eap_vendor_type)
  6890 	if (m_current_eap_type == eap_type_tls)
  6815 	{
  6891 	{
  6816 	case eap_type_tls:
  6892 		lastFullAuthTimeString.Set(KTLSLastFullAuthTime);
  6817 		{
  6893 	}
  6818 			lastFullAuthTimeString.Set(KTLSLastFullAuthTime);
  6894 	else if (m_current_eap_type == eap_type_peap)
  6819 		}
  6895 	{
  6820 		break;
  6896 		lastFullAuthTimeString.Set(KPEAPLastFullAuthTime);
  6821 
  6897 	}
  6822 	case eap_type_peap:
  6898 	else if (m_current_eap_type == eap_type_ttls)
  6823 		{
  6899 	{
  6824 			lastFullAuthTimeString.Set(KPEAPLastFullAuthTime);
  6900 		lastFullAuthTimeString.Set(KTTLSLastFullAuthTime);
  6825 		}
  6901 	}
  6826 		break;
  6902 	else if (m_current_eap_type == eap_type_ttls_plain_pap)
  6827 
  6903 	{
  6828 	case eap_type_ttls:
       
  6829 		{
       
  6830 			lastFullAuthTimeString.Set(KTTLSLastFullAuthTime);
       
  6831 		}
       
  6832 		break;
       
  6833 		
       
  6834 	case eap_type_ttls_plain_pap:
       
  6835 		{
       
  6836 		lastFullAuthTimeString.Set( KTTLSPAPLastFullAuthTime );
  6904 		lastFullAuthTimeString.Set( KTTLSPAPLastFullAuthTime );
  6837 		}
  6905 	}
  6838 		break;
       
  6839 
       
  6840 #if defined(USE_FAST_EAP_TYPE)
  6906 #if defined(USE_FAST_EAP_TYPE)
  6841 	case eap_type_fast:
  6907 	else if (m_current_eap_type == eap_type_fast)
  6842 		{
  6908 	{
  6843 			lastFullAuthTimeString.Set(KFASTLastFullAuthTime);
  6909 		lastFullAuthTimeString.Set(KFASTLastFullAuthTime);
  6844 		}
  6910 	}
  6845 		break;
       
  6846 #endif
  6911 #endif
  6847 		
  6912 	else
  6848 	default:
  6913 	{
  6849 		{
  6914 		// Should never happen
  6850 			// Should never happen
  6915 		EAP_TRACE_ERROR(m_am_tools, 
  6851 			EAP_TRACE_ERROR(m_am_tools, 
  6916 			TRACE_FLAGS_DEFAULT, (
  6852 				TRACE_FLAGS_DEFAULT, (
  6917 			EAPL("Unsupported EAP type, m_current_eap_vendor_type=0xfe%06x%08x\n"),
  6853 				EAPL("Unsupported EAP type, m_current_eap_vendor_type=%d \n"),
  6918 			m_current_eap_type.get_vendor_id(),
  6854 				m_current_eap_vendor_type));
  6919 			m_current_eap_type.get_vendor_type()));
  6855 				
  6920 			
  6856 			User::Leave(KErrNotSupported);
  6921 		User::Leave(KErrNotSupported);
  6857 		}
  6922 	}
  6858 	}	
       
  6859 
  6923 
  6860 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  6924 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  6861 	TPtr sqlStatement = buf->Des();
  6925 	TPtr sqlStatement = buf->Des();
  6862 	
  6926 	
  6863 	// Query all the relevant parameters
  6927 	// Query all the relevant parameters
  6864 	_LIT(KSQLQuery, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d");
  6928 	_LIT(KSQLQuery, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
  6865 	sqlStatement.Format(KSQLQuery, &lastFullAuthTimeString, &m_db_table_name,
  6929 
  6866 						&KServiceType, m_index_type, 
  6930 	sqlStatement.Format(
  6867 						&KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);
  6931 		KSQLQuery,
       
  6932 		&lastFullAuthTimeString,
       
  6933 		&m_db_table_name,
       
  6934 		&KServiceType,
       
  6935 		m_index_type, 
       
  6936 		&KServiceIndex,
       
  6937 		m_index,
       
  6938 		&KTunnelingTypeVendorId,
       
  6939 		m_tunneling_type.get_vendor_id(),
       
  6940 		&KTunnelingType, 
       
  6941 		m_tunneling_type.get_vendor_type());
  6868 
  6942 
  6869 	RDbView view;
  6943 	RDbView view;
  6870 	// Evaluate view
  6944 	// Evaluate view
  6871 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  6945 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  6872 	CleanupClosePushL(view);
  6946 	CleanupClosePushL(view);
  6987 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  7061 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6988 	return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported);
  7062 	return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported);
  6989 }
  7063 }
  6990 
  7064 
  6991 #endif //#if defined(USE_EAP_CORE_SERVER)
  7065 #endif //#if defined(USE_EAP_CORE_SERVER)
       
  7066 
  6992 //--------------------------------------------------
  7067 //--------------------------------------------------
  6993 
       
  6994 
  7068 
  6995 // This is commented in eap_am_fast_pac_store_services_c::query_user_permission_for_A_ID().
  7069 // This is commented in eap_am_fast_pac_store_services_c::query_user_permission_for_A_ID().
  6996 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::query_user_permission_for_A_ID(
  7070 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::query_user_permission_for_A_ID(
  6997 	const eap_fast_pac_store_pending_operation_e in_pending_operation,
  7071 	const eap_fast_pac_store_pending_operation_e in_pending_operation,
  6998 	const eap_fast_variable_data_c * const in_pac_attribute_A_ID_info,
  7072 	const eap_fast_variable_data_c * const in_pac_attribute_A_ID_info,
  7044 //--------------------------------------------------
  7118 //--------------------------------------------------
  7045 
  7119 
  7046 eap_status_e eap_am_type_tls_peap_symbian_c::QueryUserPermissionForAIDL(
  7120 eap_status_e eap_am_type_tls_peap_symbian_c::QueryUserPermissionForAIDL(
  7047 		const eap_fast_variable_data_c * const in_pac_attribute_A_ID_info,
  7121 		const eap_fast_variable_data_c * const in_pac_attribute_A_ID_info,
  7048 		const eap_fast_variable_data_c * const in_pac_attribute_A_ID)
  7122 		const eap_fast_variable_data_c * const in_pac_attribute_A_ID)
  7049 	{
  7123 {
  7050 	eap_status_e status(eap_status_ok);
  7124 	eap_status_e status(eap_status_ok);
  7051 	
  7125 	
  7052 	HBufC8* A_ID_info8 = HBufC8::NewLC((in_pac_attribute_A_ID_info->get_data_length()));
  7126 	HBufC8* A_ID_info8 = HBufC8::NewLC((in_pac_attribute_A_ID_info->get_data_length()));
  7053 	TPtr8 A_ID_infoPtr8 = A_ID_info8->Des();
  7127 	TPtr8 A_ID_infoPtr8 = A_ID_info8->Des();
  7054 
  7128 
  7071  	EAP_TRACE_DATA_DEBUG_SYMBIAN(
  7145  	EAP_TRACE_DATA_DEBUG_SYMBIAN(
  7072 			("eap_am_type_tls_peap_symbian_c::query_user_permission_for_A_ID(): in_pac_attribute_A_ID",
  7146 			("eap_am_type_tls_peap_symbian_c::query_user_permission_for_A_ID(): in_pac_attribute_A_ID",
  7073 			(A_IDPtr.Ptr()),
  7147 			(A_IDPtr.Ptr()),
  7074 			(in_pac_attribute_A_ID->get_data_length())));
  7148 			(in_pac_attribute_A_ID->get_data_length())));
  7075 
  7149 
  7076  	if (A_ID_infoPtr.Size()>KMaxEapFastNotifierBufLength)
  7150  	if (A_ID_infoPtr.Size()>=KMaxNotifItemLength)
  7077 	{
  7151 	{
  7078   		CleanupStack::PopAndDestroy(3); // A_ID, A_ID_info
  7152   		CleanupStack::PopAndDestroy(3); // A_ID, A_ID_info
  7079   		status = m_am_tools->convert_am_error_to_eapol_error(KErrArgument);
  7153   		status = m_am_tools->convert_am_error_to_eapol_error(KErrArgument);
  7080 
  7154 
  7081  		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  7155  		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  7082  		return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7156  		return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7083 	}
  7157 	}
  7084 
  7158 
  7085  	TBool startedOk = ETrue;
  7159  	TBool startedOk = ETrue;
  7086  	
  7160  
  7087  	if (!iEapFastActiveNotes)
  7161     TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  7088          {
  7162     
  7089          TRAPD( err, iEapFastActiveNotes = CEapFastActive::NewL( this ) );
  7163     m_notifier_data_to_user->iPassword.Copy(A_ID_infoPtr);
  7090          
  7164     
  7091          if ( err != KErrNone )
  7165     if (iEapAuthNotifier == 0)
  7092              {
  7166     	{
  7093              status = eap_status_allocation_error;
  7167     	TRAPD(err, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
  7094              }   
  7168 	  	if (err)
  7095         }
  7169 	  		{
  7096  	if ( status == KErrNone )
  7170 	  			return eap_status_process_general_error;
  7097  		{
  7171 	  		}
  7098 	    //update buffer
  7172     	}
  7099  		iEapFastActiveNotes->UpdateInputBuf( A_ID_infoPtr );
  7173     else
  7100         // start query install dialog
  7174 	   	{
  7101  		// asynch. call, return immediately
  7175 		 	TRAPD(err1, iEapAuthNotifier->Cancel());
  7102  		startedOk = iEapFastActiveNotes->Start(
  7176 	  	if (err1)
  7103  		    CEapFastActive::EEapFastActiveInstallPacQueryDialog );
  7177 	  		{
  7104  		if ( startedOk == EFalse )
  7178 	  			return eap_status_process_general_error;
  7105  			{
  7179 	  		}
  7106  			status = eap_status_process_general_error;
  7180      	}
  7107  			}
  7181 
  7108  		}
  7182     TRAPD(err2, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastInstallPacQueryDialog, m_notifier_data_to_user, aEapType));
  7109  	else
  7183   	if (err2)
  7110  		{
  7184   		{
  7111  		status = eap_status_process_general_error;	
  7185   			return eap_status_process_general_error;
  7112  		}
  7186   		}
       
  7187  
       
  7188  
  7113 
  7189 
  7114  	CleanupStack::PopAndDestroy(3); // A_ID, A_ID_info
  7190  	CleanupStack::PopAndDestroy(3); // A_ID, A_ID_info
  7115  	
  7191  	
  7116  	return status;
  7192  	return status;
  7117 	}
  7193 }
  7118 
  7194 
       
  7195 //--------------------------------------------------
  7119 
  7196 
  7120 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::read_PAC_store_data(
  7197 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::read_PAC_store_data(
  7121 	const eap_fast_pac_store_pending_operation_e in_pending_operation,
  7198 	const eap_fast_pac_store_pending_operation_e in_pending_operation,
  7122 	EAP_TEMPLATE_CONST eap_array_c<eap_fast_pac_store_data_c> * const in_references)
  7199 	EAP_TEMPLATE_CONST eap_array_c<eap_fast_pac_store_data_c> * const in_references)
  7123 {
  7200 {
  7601 					dataType = eap_pac_store_data_type_PAC_data;
  7678 					dataType = eap_pac_store_data_type_PAC_data;
  7602 					break;		
  7679 					break;		
  7603 					}		
  7680 					}		
  7604 				}
  7681 				}
  7605 				
  7682 				
  7606 				TInt count = 0;
  7683 				m_info_array.ResetAndDestroy();
  7607 				
       
  7608 				m_info_array.Reset();
       
  7609 					
  7684 					
  7610 				iPacStoreDb->GetPacStoreDataL(dbTableName, m_info_array);
  7685 				iPacStoreDb->GetPacStoreDataL(dbTableName, m_info_array);
  7611 				
  7686 				
  7612 				EAP_TRACE_DEBUG_SYMBIAN(
  7687 				EAP_TRACE_DEBUG_SYMBIAN(
  7613 				(_L("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL:Number of entries in table %S=%d\n"),
  7688 					(_L("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL:Number of entries in table %S=%d\n"),
  7614 				&dbTableName, m_info_array.Count()));				
  7689 					&dbTableName, m_info_array.Count()));
  7615 				
  7690 				
  7616 				while (count < m_info_array.Count())
  7691 				TInt first_index = 0;
       
  7692 
       
  7693 				while (m_info_array.Count() > 0)
  7617 					{
  7694 					{
  7618 					TPtr8 infoDataPtr = m_info_array[count].iData->Des();
  7695 					if (m_info_array[first_index] != 0
  7619 					TPtr8 infoRefPtr = m_info_array[count].iReference->Des();
  7696 						&& m_info_array[first_index]->GetIsValid() != EFalse)
       
  7697 						{
       
  7698 						// Note this will get always the first object of array. After the first object is processed it is destryed and removed from array.
       
  7699 						TPtr8 infoDataPtr = m_info_array[first_index]->GetData()->Des();
       
  7700 						TPtr8 infoRefPtr = m_info_array[first_index]->GetReference()->Des();
       
  7701 						
       
  7702 						EAP_TRACE_DATA_DEBUG_SYMBIAN(
       
  7703 							("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL: BINARY value from PAC DB (reference)",
       
  7704 							infoRefPtr.Ptr(),
       
  7705 							infoRefPtr.Size()));
       
  7706 						
       
  7707 						EAP_TRACE_DATA_DEBUG_SYMBIAN(
       
  7708 							("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL: BINARY value from PAC DB (value)",
       
  7709 							infoDataPtr.Ptr(),
       
  7710 							infoDataPtr.Size()));					
       
  7711 						
       
  7712 						eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools);
       
  7713 
       
  7714 						eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
       
  7715 							m_am_tools, new_data);
       
  7716 
       
  7717 						if (new_data == 0)
       
  7718 						{
       
  7719 							m_eap_fast_completion_status = eap_status_allocation_error;
       
  7720 							(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
       
  7721 							break;
       
  7722 						}
       
  7723 
       
  7724 						new_data->set_type(dataType);					
       
  7725 
       
  7726 						// Set the reference.
       
  7727 						m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(infoRefPtr.Ptr(), infoRefPtr.Size());
       
  7728 						if (m_eap_fast_completion_status != eap_status_ok)
       
  7729 						{
       
  7730 							(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
       
  7731 							delete m_info_array[first_index];
       
  7732 							m_info_array.Remove(first_index);
       
  7733 							break;
       
  7734 						}
       
  7735 						
       
  7736 						m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(infoDataPtr.Ptr(), infoDataPtr.Size());
       
  7737 						if (m_eap_fast_completion_status != eap_status_ok)
       
  7738 						{
       
  7739 							(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
       
  7740 							delete m_info_array[first_index];
       
  7741 							m_info_array.Remove(first_index);
       
  7742 							break;
       
  7743 						}
       
  7744 
       
  7745 						automatic_new_data.do_not_free_variable();
       
  7746 
       
  7747 						m_eap_fast_completion_status = m_references_and_data_blocks.add_object(new_data, true);
       
  7748 						if (m_eap_fast_completion_status != eap_status_ok)
       
  7749 						{
       
  7750 							(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
       
  7751 							delete m_info_array[first_index];
       
  7752 							m_info_array.Remove(first_index);
       
  7753 							break;
       
  7754 						}
       
  7755 						EAP_TRACE_DATA_DEBUG_SYMBIAN(
       
  7756 							("For GROUP, AID, PAC INFOs - added data",
       
  7757 							(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
       
  7758 							(new_data->get_data())->get_data_length()));					
       
  7759 						}
       
  7760 							
       
  7761 					delete m_info_array[first_index];
       
  7762 					m_info_array.Remove(first_index);
  7620 					
  7763 					
  7621 					EAP_TRACE_DATA_DEBUG_SYMBIAN(
  7764 		
  7622 						("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL: BINARY value from PAC DB (reference)",
       
  7623 						infoRefPtr.Ptr(),
       
  7624 						infoRefPtr.Size()));
       
  7625 					
       
  7626 					EAP_TRACE_DATA_DEBUG_SYMBIAN(
       
  7627 						("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL: BINARY value from PAC DB (value)",
       
  7628 						infoDataPtr.Ptr(),
       
  7629 						infoDataPtr.Size()));					
       
  7630 					
       
  7631 					eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools);
       
  7632 
       
  7633 					eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
       
  7634 						m_am_tools, new_data);
       
  7635 
       
  7636 					if (new_data == 0)
       
  7637 					{
       
  7638 						m_eap_fast_completion_status = eap_status_allocation_error;
       
  7639 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
       
  7640 						break;
       
  7641 					}
       
  7642 
       
  7643 					new_data->set_type(dataType);					
       
  7644 
       
  7645 					// Set the reference.
       
  7646 					m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(infoRefPtr.Ptr(), infoRefPtr.Size());
       
  7647 					if (m_eap_fast_completion_status != eap_status_ok)
       
  7648 					{
       
  7649 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
       
  7650 						delete m_info_array[count].iData;
       
  7651 						delete m_info_array[count].iReference;
       
  7652 						break;
       
  7653 					}
       
  7654 					
       
  7655 					m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(infoDataPtr.Ptr(),infoDataPtr.Size() );
       
  7656 					if (m_eap_fast_completion_status != eap_status_ok)
       
  7657 					{
       
  7658 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
       
  7659 						delete m_info_array[count].iData;
       
  7660 						delete m_info_array[count].iReference;
       
  7661 						break;
       
  7662 					}
       
  7663 
       
  7664 					automatic_new_data.do_not_free_variable();
       
  7665 
       
  7666 					m_eap_fast_completion_status = m_references_and_data_blocks.add_object(new_data, true);
       
  7667 					if (m_eap_fast_completion_status != eap_status_ok)
       
  7668 					{
       
  7669 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
       
  7670 						delete m_info_array[count].iData;
       
  7671 						delete m_info_array[count].iReference;
       
  7672 						break;
       
  7673 					}					
       
  7674 							
       
  7675 					delete m_info_array[count].iData;
       
  7676 					delete m_info_array[count].iReference;
       
  7677 					
       
  7678 					EAP_TRACE_DATA_DEBUG_SYMBIAN(
       
  7679 						("For GROUP, AID, PAC INFOs - added data",
       
  7680 						(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
       
  7681 						(new_data->get_data())->get_data_length()));					
       
  7682 		
       
  7683 					count++;
       
  7684 					} // End: while
  7765 					} // End: while
  7685 					
  7766 					
  7686 				
  7767 				
  7687 					if (m_eap_fast_completion_status != eap_status_ok)
  7768 					if (m_eap_fast_completion_status != eap_status_ok)
  7688 					{
  7769 					{
  7729 
  7810 
  7730 						m_both_asked++;
  7811 						m_both_asked++;
  7731 
  7812 
  7732 						if(iPacStoreDb->IsMasterKeyPresentL())
  7813 						if(iPacStoreDb->IsMasterKeyPresentL())
  7733 							{
  7814 							{
  7734 							m_eap_fast_completion_status = ShowNotifierItemAndGetResponse(
  7815 				    TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  7735 								EEapFastNotifierPacStorePwQuery, ETrue );
  7816 				    
       
  7817 				    m_notifier_data_to_user->iPassword.Zero();
       
  7818 				    
       
  7819 				    if (iEapAuthNotifier == 0)
       
  7820 				    	{
       
  7821 				    	iEapAuthNotifier = CEapAuthNotifier::NewL( *this );
       
  7822 				    	}
       
  7823 				    else
       
  7824 					   	{
       
  7825 						 	iEapAuthNotifier->Cancel();
       
  7826 				     	}
       
  7827 				
       
  7828 				    iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastPacStorePwQueryDialog, m_notifier_data_to_user, aEapType);
       
  7829 
       
  7830 
  7736 							}
  7831 							}
  7737 						else
  7832 						else
  7738 							{
  7833 							{
  7739 							m_state =  EMasterkeyQuery; 
  7834 							m_state =  EMasterkeyQuery; 
  7740 				        	m_eap_fast_completion_status = ShowNotifierItemAndGetResponse(
  7835 					    TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  7741 				        		EEapFastNotifierCreateMasterkeyQuery, ETrue );
  7836 					    
       
  7837 					    m_notifier_data_to_user->iPassword.Zero();
       
  7838 					    
       
  7839 					    if (iEapAuthNotifier == 0)
       
  7840 					    	{
       
  7841 					    	iEapAuthNotifier = CEapAuthNotifier::NewL( *this );
       
  7842 					    	}
       
  7843 					    else
       
  7844 						   	{
       
  7845 							 	iEapAuthNotifier->Cancel();
       
  7846 					     	}
       
  7847 					
       
  7848 					    iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastCreateMasterkeyQueryDialog, m_notifier_data_to_user, aEapType);
       
  7849 
  7742 							}
  7850 							}
  7743 
  7851 
  7744 						break;
  7852 						break;
  7745 					}
  7853 					}
  7746 			
  7854 			
  7800 					
  7908 					
  7801 					// Create a device seed.
  7909 					// Create a device seed.
  7802 				
  7910 				
  7803 				    eap_variable_data_c m_PAC_store_device_seed(m_am_tools);
  7911 				    eap_variable_data_c m_PAC_store_device_seed(m_am_tools);
  7804 				    m_eap_fast_completion_status = m_PAC_store_device_seed.set_copy_of_buffer(
  7912 				    m_eap_fast_completion_status = m_PAC_store_device_seed.set_copy_of_buffer(
  7805 				    	iPacStoreDb->GetSeed() );
  7913 				    	iPacStoreDeviceSeed );
  7806 					if ( m_eap_fast_completion_status != eap_status_ok )
  7914 					if ( m_eap_fast_completion_status != eap_status_ok )
  7807 					    {
  7915 					    {
  7808 					    EAP_TRACE_DEBUG_SYMBIAN(
  7916 					    EAP_TRACE_DEBUG_SYMBIAN(
  7809 							(_L("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL: ERROR: seed data is not valid.")));	
  7917 							(_L("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL: ERROR: seed data is not valid.")));	
  7810 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7918 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8046 
  8154 
  8047 					m_state = EFilePasswordQuery;
  8155 					m_state = EFilePasswordQuery;
  8048 
  8156 
  8049 					m_both_asked++;
  8157 					m_both_asked++;
  8050 
  8158 
  8051 					m_eap_fast_completion_status = ShowNotifierItemAndGetResponse(
  8159 			    TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  8052 								EEapFastNotifierPacFilePwQuery, ETrue );
  8160 			    
  8053 					
  8161 			    m_notifier_data_to_user->iPassword.Zero();
       
  8162 			    
       
  8163 			    if (iEapAuthNotifier == 0)
       
  8164 			    	{
       
  8165 			    	iEapAuthNotifier = CEapAuthNotifier::NewL( *this );
       
  8166 			    	}
       
  8167 			    else
       
  8168 				   	{
       
  8169 					 	iEapAuthNotifier->Cancel();
       
  8170 			     	}
       
  8171 			
       
  8172 			    iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastPacFilePwQueryDialog, m_notifier_data_to_user, aEapType);
       
  8173 
  8054 					if (m_eap_fast_completion_status != eap_status_ok)
  8174 					if (m_eap_fast_completion_status != eap_status_ok)
  8055 						{
  8175 						{
  8056 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8176 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8057 						break;
  8177 						break;
  8058 						}
  8178 						}
  8074 				}
  8194 				}
  8075 				
  8195 				
  8076 			} // End: switch(pacStoreDataRefType)			
  8196 			} // End: switch(pacStoreDataRefType)			
  8077 		}
  8197 		}
  8078 	} // for ()
  8198 	} // for ()
       
  8199 
  8079 	if (m_both_asked)
  8200 	if (m_both_asked)
       
  8201 	{
  8080 		m_eap_fast_completion_status = eap_status_pending_request;
  8202 		m_eap_fast_completion_status = eap_status_pending_request;
  8081 	m_info_array.Reset();
  8203 	}
       
  8204 
       
  8205 	m_info_array.ResetAndDestroy();
       
  8206 
  8082 	EAP_TRACE_DEBUG_SYMBIAN(
  8207 	EAP_TRACE_DEBUG_SYMBIAN(
  8083 		(_L("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL-End, m_eap_fast_completion_status=%d"),
  8208 		(_L("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL-End, m_eap_fast_completion_status=%d"),
  8084 		m_eap_fast_completion_status));			
  8209 		m_eap_fast_completion_status));			
  8085 	
  8210 	
  8086 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
  8211 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
  8477  
  8602  
  8478    	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  8603    	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  8479 	return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8604 	return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8480 }
  8605 }
  8481 	
  8606 	
       
  8607 //--------------------------------------------------
       
  8608 
  8482 void eap_am_type_tls_peap_symbian_c::CompleteAddImportedPACFileL(
  8609 void eap_am_type_tls_peap_symbian_c::CompleteAddImportedPACFileL(
  8483 		const eap_variable_data_c * const in_imported_PAC_filename,
  8610 		const eap_variable_data_c * const in_imported_PAC_filename,
  8484 		const eap_variable_data_c * const out_used_group_reference)
  8611 		const eap_variable_data_c * const out_used_group_reference)
  8485 	{
  8612 {
  8486 	RFs aFs;
  8613 	RFs aFs;
  8487 	aFs.Connect( KFileServerDefaultMessageSlots );
  8614 	aFs.Connect( KFileServerDefaultMessageSlots );
  8488 
  8615 
  8489 	HBufC8* buf = HBufC8::NewLC(in_imported_PAC_filename->get_data_length());
  8616 	HBufC8* buf = HBufC8::NewLC(in_imported_PAC_filename->get_data_length());
  8490 	TPtr8 bufPtr = buf->Des();
  8617 	TPtr8 bufPtr = buf->Des();
  8553 		{
  8680 		{
  8554 		EAP_TRACE_DEBUG_SYMBIAN(
  8681 		EAP_TRACE_DEBUG_SYMBIAN(
  8555 				(_L("eap_am_type_tls_peap_symbian_c::complete_add_imported_PAC_file: NO GROUP REFERENCE !!!!")));	
  8682 				(_L("eap_am_type_tls_peap_symbian_c::complete_add_imported_PAC_file: NO GROUP REFERENCE !!!!")));	
  8556 
  8683 
  8557 		}
  8684 		}
  8558 	
  8685 
  8559 	HBufC* FilePath = HBufC::NewLC(KMaxFileName); // must be defined to correct maxs dir length
  8686 	HBufC* FilePath = HBufC::NewLC(KMaxFileName); // must be defined to correct maxs dir length
  8560 	TPtr FilePathPtr = FilePath->Des();
  8687 	TPtr FilePathPtr = FilePath->Des();
  8561 	HBufC8* FilePath8 = HBufC8::NewLC(KMaxFileName); // must be defined to correct maxs dir length
  8688 	HBufC8* FilePath8 = HBufC8::NewLC(KMaxFileName); // must be defined to correct maxs dir length
  8562 	TPtr8 FilePathPtr8 = FilePath8->Des();
  8689 	TPtr8 FilePathPtr8 = FilePath8->Des();
  8563 	
  8690 
  8564 	_LIT8(KPacStoreSourceDir, "c:\\private\\101f8ec5\\PACGroup\\"); // in dir are dirs where from files are read
       
  8565 	FilePathPtr8.Zero();
  8691 	FilePathPtr8.Zero();
  8566 	FilePathPtr8.Append(KPacStoreSourceDir);
       
  8567 	FilePathPtr8.Append(refPtr);
  8692 	FilePathPtr8.Append(refPtr);
  8568 	FilePathPtr8.Append(KSeparator);
  8693 	FilePathPtr8.Append(KSeparator);
  8569 	FilePathPtr8.Append(bufPtr);
  8694 	FilePathPtr8.Append(bufPtr);
  8570 
  8695 
       
  8696 	// Copy is the only function that takes TPtr8 type of parameter.
  8571 	FilePathPtr.Copy(FilePathPtr8);
  8697 	FilePathPtr.Copy(FilePathPtr8);
       
  8698 
       
  8699 	{
       
  8700 		TFileName aPrivateDatabasePathName;
       
  8701 
       
  8702 		EapPluginTools::GetPrivatePathL(
       
  8703 			aPrivateDatabasePathName);
       
  8704 
       
  8705 		aPrivateDatabasePathName.Append(KPacStoreSourceDir);
       
  8706 		aPrivateDatabasePathName.Append(FilePathPtr);
       
  8707 
       
  8708 		FilePathPtr.Copy(aPrivateDatabasePathName);
       
  8709 	}
  8572 
  8710 
  8573 	EAP_TRACE_DATA_DEBUG(
  8711 	EAP_TRACE_DATA_DEBUG(
  8574    		m_am_tools,
  8712    		m_am_tools,
  8575    		TRACE_FLAGS_DEFAULT,
  8713    		TRACE_FLAGS_DEFAULT,
  8576    		(EAPL("eap_am_type_tls_peap_symbian_c::complete_add_imported_PAC_file: Delete File"),
  8714    		(EAPL("eap_am_type_tls_peap_symbian_c::complete_add_imported_PAC_file: Delete File"),
  8593 	CleanupStack::PopAndDestroy(FilePath8); 
  8731 	CleanupStack::PopAndDestroy(FilePath8); 
  8594 	CleanupStack::PopAndDestroy(FilePath); 
  8732 	CleanupStack::PopAndDestroy(FilePath); 
  8595 	CleanupStack::PopAndDestroy(ref); 
  8733 	CleanupStack::PopAndDestroy(ref); 
  8596 	CleanupStack::PopAndDestroy(buf); 
  8734 	CleanupStack::PopAndDestroy(buf); 
  8597 	
  8735 	
  8598 	}
  8736 }
  8599 
  8737 
  8600 
  8738 
  8601 // ---------------------------------------------------------
  8739 // ---------------------------------------------------------
  8602 // eap_am_type_tls_peap_symbian_c::ContinueInitializePacStore()
  8740 // eap_am_type_tls_peap_symbian_c::ContinueInitializePacStore()
  8603 // ---------------------------------------------------------
  8741 // ---------------------------------------------------------
  8604 //
  8742 //
  8605 void eap_am_type_tls_peap_symbian_c::ContinueInitializePacStore()
  8743 void eap_am_type_tls_peap_symbian_c::ContinueInitializePacStore()
  8606 
  8744 {
  8607 	{
       
  8608 	EAP_TRACE_DEBUG_SYMBIAN(
  8745 	EAP_TRACE_DEBUG_SYMBIAN(
  8609 			(_L("eap_am_type_tls_peap_symbian_c::ContinueInitializePacStore()")));
  8746 			(_L("eap_am_type_tls_peap_symbian_c::ContinueInitializePacStore()")));
  8610 
  8747 
  8611 	TRAPD(error, CheckPasswordTimeValidityL());
  8748 	TRAPD(error, CheckPasswordTimeValidityL());
  8612 
  8749 
  8636 			this,
  8773 			this,
  8637 			KRemoveIAPReferenceTimerID, 
  8774 			KRemoveIAPReferenceTimerID, 
  8638 			0,
  8775 			0,
  8639 			1);
  8776 			1);
  8640 
  8777 
  8641 	}
  8778 }
  8642 
  8779 
  8643 //--------------------------------------------------
  8780 //--------------------------------------------------
  8644 
  8781 
  8645 // This is commented in eap_am_fast_pac_store_services_c::complete_remove_PAC().
  8782 // This is commented in eap_am_fast_pac_store_services_c::complete_remove_PAC().
  8646 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::complete_remove_PAC(
  8783 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::complete_remove_PAC(
  8749 		}
  8886 		}
  8750 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  8887 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  8751 	return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8888 	return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8752 }
  8889 }
  8753 
  8890 
       
  8891 //--------------------------------------------------
       
  8892 
  8754 // This is commented in eap_am_fast_pac_store_services_c::cancel_PAC_store_operations().
  8893 // This is commented in eap_am_fast_pac_store_services_c::cancel_PAC_store_operations().
  8755 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::cancel_PAC_store_operations()
  8894 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::cancel_PAC_store_operations()
  8756 {
  8895 {
  8757 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  8896 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  8758 	
  8897 	
  8773 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  8912 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  8774 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
  8913 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
  8775 }
  8914 }
  8776 
  8915 
  8777 //--------------------------------------------------
  8916 //--------------------------------------------------
  8778 
       
  8779 
  8917 
  8780 EAP_FUNC_EXPORT eap_status_e
  8918 EAP_FUNC_EXPORT eap_status_e
  8781 eap_am_type_tls_peap_symbian_c::initialize_PAC_store(
  8919 eap_am_type_tls_peap_symbian_c::initialize_PAC_store(
  8782 	const eap_fast_completion_operation_e aCompletionOperation,
  8920 	const eap_fast_completion_operation_e aCompletionOperation,
  8783 	const eap_fast_initialize_pac_store_completion_e aCompletion )
  8921 	const eap_fast_initialize_pac_store_completion_e aCompletion )
  8817 			        EAP_TRACE_DEBUG_SYMBIAN(
  8955 			        EAP_TRACE_DEBUG_SYMBIAN(
  8818 						(_L("eap_am_type_tls_peap_symbian_c::initialize_PAC_store(): ERROR: Leave in SetPacStoreInitValueL()")));	
  8956 						(_L("eap_am_type_tls_peap_symbian_c::initialize_PAC_store(): ERROR: Leave in SetPacStoreInitValueL()")));	
  8819 		    	    }
  8957 		    	    }
  8820         	    }
  8958         	    }
  8821 		    // asynch. call, return immediately
  8959 		    // asynch. call, return immediately
  8822 		    iPacStoreDb->CreateDeviceSeedAsynch();
  8960 		    CreateDeviceSeedAsync();
  8823 		    }
  8961 		    }
  8824     	else
  8962     	else
  8825     		{
  8963     		{
  8826 	        EAP_TRACE_DEBUG_SYMBIAN( ( _L(
  8964 	        EAP_TRACE_DEBUG_SYMBIAN( ( _L(
  8827 	        	"ERROR: eap_am_type_tls_peap_symbian_c::initialize_PAC_store(): Leave, IsInitializedL(), err=%d.\n"),
  8965 	        	"ERROR: eap_am_type_tls_peap_symbian_c::initialize_PAC_store(): Leave, IsInitializedL(), err=%d.\n"),
  8852 	{
  8990 	{
  8853 	eap_status_e status( eap_status_ok );
  8991 	eap_status_e status( eap_status_ok );
  8854 	m_provisioning_mode = provisioning_mode; // save provis. mode
  8992 	m_provisioning_mode = provisioning_mode; // save provis. mode
  8855 	
  8993 	
  8856 	TInt err = KErrNone;	
  8994 	TInt err = KErrNone;	
  8857 	if ( !iEapFastActiveWaitNote )
  8995 	
  8858 		{
  8996 
  8859 		TRAP( err, iEapFastActiveWaitNote = CEapFastActive::NewL( this ) );
  8997     TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  8860 		}
  8998     
  8861 	if ( !iEapFastActiveNotes )
  8999     m_notifier_data_to_user->iPassword.Zero();
  8862 		{
  9000     
  8863 		TRAP( err, iEapFastActiveNotes = CEapFastActive::NewL( this ) );
  9001     if (iEapAuthNotifier == 0)
  8864 		}
  9002     	{
  8865 	if ( err != KErrNone )
  9003     	TRAPD(err, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
  8866 		{
  9004     	if (err)
  8867 		status = eap_status_allocation_error;
  9005     		{
  8868 		}	
  9006     			return eap_status_process_general_error;
  8869 	/**
  9007     		}
  8870 	* The note is started in a separate active object.
  9008     	}
  8871 	* When user cancels waiting note,
  9009     else
  8872 	* SendErrorNotification( eap_status_user_cancel_authentication )
  9010 	   	{
  8873 	* will be called in iEapFastActiveWaitNote->RunL().
  9011 		 	TRAPD(err1, iEapAuthNotifier->Cancel());
  8874 	* Otherwise note is stopped using iEapFastActiveWaitNote.Start() method.
  9012     	if (err1)
  8875 	*/
  9013     		{
  8876 	TBool startedOk = ETrue;
  9014     			return eap_status_process_general_error;
  8877 	
  9015     		}
       
  9016      	}
       
  9017 
  8878 	if ( pac_type == eap_fast_pac_type_tunnel_pac
  9018 	if ( pac_type == eap_fast_pac_type_tunnel_pac
  8879 		 &&
  9019 		 && provisioning_mode == eap_fast_completion_operation_server_authenticated_provisioning_mode
  8880 		 provisioning_mode ==
  9020 		 && status == eap_status_ok )
  8881 		     eap_fast_completion_operation_server_authenticated_provisioning_mode
  9021 				{
  8882 		 &&
  9022     		TRAPD(err2, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastStartAuthProvWaitNote, m_notifier_data_to_user, aEapType));
  8883 		 status == eap_status_ok )
  9023 	    	if (err2)
  8884 		{
  9024 	    		{
  8885 		EAP_TRACE_DEBUG_SYMBIAN( ( _L("eap_am_type_tls_peap_symbian_c:: \
  9025 	    			return eap_status_process_general_error;
  8886 				indicates_eap_fast_provisioning_starts Authenticated provisioning!")));			
  9026 	    		}
  8887 		startedOk = iEapFastActiveWaitNote->Start(
  9027 				}
  8888 			CEapFastActive::EEapFastActiveStartAuthProvWaitNote );
       
  8889 		}
       
  8890 	else if (
  9028 	else if (
  8891 		pac_type == eap_fast_pac_type_tunnel_pac
  9029 		pac_type == eap_fast_pac_type_tunnel_pac
  8892 		&&
  9030 		&& provisioning_mode == eap_fast_completion_operation_server_unauthenticated_provisioning_mode_ADHP
  8893 		provisioning_mode ==
  9031 	  && status == eap_status_ok )
  8894 	        eap_fast_completion_operation_server_unauthenticated_provisioning_mode_ADHP
  9032 				{
  8895 	    &&
  9033     		TRAPD(err3, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastStartUnauthProvWaitNote, m_notifier_data_to_user, aEapType));
  8896 	    status == eap_status_ok )
  9034 	    	if (err3)
  8897 		{
  9035 	    		{
  8898 		EAP_TRACE_DEBUG_SYMBIAN(  (_L("eap_am_type_tls_peap_symbian_c:: \
  9036 	    			return eap_status_process_general_error;
  8899 			indicates_eap_fast_provisioning_starts UnAuthenticated provisioning!")));			
  9037 	    		}
  8900 		startedOk = iEapFastActiveWaitNote->Start(
  9038 				}
  8901         	CEapFastActive::EEapFastActiveStartUnauthProvWaitNote );        
  9039 
  8902 		}
  9040 
  8903 	if ( startedOk == EFalse )
  9041 
  8904         {
       
  8905         status = eap_status_process_general_error;
       
  8906         }
       
  8907 	if ( status != eap_status_ok )
       
  8908 		{
       
  8909 	    EAP_TRACE_DEBUG_SYMBIAN( (_L("eap_am_type_tls_peap_symbian_c:: \
       
  8910             indicates_eap_fast_provisioning_starts ERROR: status=%d."), status ) );
       
  8911 		}
       
  8912 	return status;
  9042 	return status;
  8913 	}
  9043 	}
  8914 
  9044 
  8915 // ---------------------------------------------------------------------------
  9045 // ---------------------------------------------------------------------------
  8916 // eap_am_type_tls_peap_symbian_c::indicates_eap_fast_provisioning_ends
  9046 // eap_am_type_tls_peap_symbian_c::indicates_eap_fast_provisioning_ends
  8930 	eap_status_e status( eap_status_ok );
  9060 	eap_status_e status( eap_status_ok );
  8931 	
  9061 	
  8932 	if ( pac_type == eap_fast_pac_type_tunnel_pac )
  9062 	if ( pac_type == eap_fast_pac_type_tunnel_pac )
  8933 		{
  9063 		{
  8934 	    // stop wait note;
  9064 	    // stop wait note;
  8935 		if ( iEapFastActiveWaitNote )
  9065     TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  8936 			{
  9066     
  8937 			if ( iEapFastActiveWaitNote->IsActive() )
  9067     m_notifier_data_to_user->iPassword.Zero();
  8938 				{
  9068     
  8939 				iEapFastActiveWaitNote->Cancel();
  9069     if (iEapAuthNotifier == 0)
  8940 				}
  9070     	{
  8941 			delete iEapFastActiveWaitNote;
  9071     	TRAPD(err, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
  8942 			iEapFastActiveWaitNote = NULL;
  9072     	if (err)
       
  9073     		{
       
  9074     			return eap_status_process_general_error;
       
  9075     		}
       
  9076     	}
       
  9077     else
       
  9078     	{
       
  9079     	TRAPD(err1, iEapAuthNotifier->Cancel());
       
  9080     	if (err1)
       
  9081     		{
       
  9082     			return eap_status_process_general_error;
       
  9083     		}
       
  9084     	}
       
  9085 
       
  9086     if( provisioning_successfull )
       
  9087 			{
       
  9088 			TRAPD(err2, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastShowProvSuccessNote, m_notifier_data_to_user, aEapType));
       
  9089     	if (err2)
       
  9090     		{
       
  9091     			return eap_status_process_general_error;
       
  9092     		}
  8943 			}
  9093 			}
  8944 
  9094 		else
  8945 	    if ( iEapFastActiveNotes )
  9095 			{
  8946 		    {	    
  9096 			TRAPD(err3, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastShowProvNotSuccessNote, m_notifier_data_to_user, aEapType));
  8947             if( provisioning_successfull )
  9097     	if (err3)
  8948 		        {
  9098     		{
  8949 		        // synch. call
  9099     			return eap_status_process_general_error;
  8950 		        iEapFastActiveNotes->Start( CEapFastActive::
  9100     		}
  8951 		            EEapFastActiveShowProvSuccessNote, ETrue );
  9101 			}
  8952 		        }
  9102 def 
  8953             else
       
  8954       	        {
       
  8955       	        // synch. call
       
  8956       	        iEapFastActiveNotes->Start( CEapFastActive::
       
  8957       	            EapFastActiveShowProvNotSuccessNote, ETrue );
       
  8958       	        }
       
  8959 		    }
       
  8960 		} // if ( pac_type == eap_fast_pac_type_tunnel_pac )
  9103 		} // if ( pac_type == eap_fast_pac_type_tunnel_pac )
  8961 
  9104 
  8962 	return status;
  9105 	return status;
  8963 	}
  9106 	}
  8964 
  9107 
  8965 #endif //#if defined(USE_FAST_EAP_TYPE)
  9108 #endif //#if defined(USE_FAST_EAP_TYPE)
       
  9109 
       
  9110 //--------------------------------------------------
  8966 
  9111 
  8967 #ifdef USE_PAC_STORE
  9112 #ifdef USE_PAC_STORE
  8968 	
  9113 	
  8969 void eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL(
  9114 void eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL(
  8970 	const eap_pac_store_data_type_e aPacStoreDataType,
  9115 	const eap_pac_store_data_type_e aPacStoreDataType,
  9232 	
  9377 	
  9233 #endif	// End: #ifdef USE_PAC_STORE
  9378 #endif	// End: #ifdef USE_PAC_STORE
  9234 
  9379 
  9235 //--------------------------------------------------
  9380 //--------------------------------------------------
  9236 
  9381 
  9237 #if defined(USE_FAST_EAP_TYPE)
  9382 #ifdef USE_FAST_EAP_TYPE
  9238 
       
  9239 eap_status_e eap_am_type_tls_peap_symbian_c::ShowNotifierItemAndGetResponse(
       
  9240 	EEapFastNotifierUiItem aNotifierUiItem, TBool aSetActive )
       
  9241 {
       
  9242 	EAP_TRACE_DEBUG_SYMBIAN(
       
  9243 		(_L("eap_am_type_tls_peap_symbian_c::ShowNotifierItem aNotifierUiItem=%d, ActiveStatus=%d "),
       
  9244 		aNotifierUiItem, IsActive()));
       
  9245 
       
  9246 	if ( aSetActive && IsActive() )
       
  9247 	{
       
  9248 		EAP_TRACE_DEBUG_SYMBIAN(
       
  9249 			(_L("ShowNotifierItemAndGetResponse: Already active when tried to show Notifier")));		
       
  9250 		
       
  9251 		return eap_status_device_busy;
       
  9252 	}
       
  9253 	
       
  9254 	eap_status_e status( eap_status_ok );
       
  9255 	
       
  9256 	if( !m_is_notifier_connected )
       
  9257 	{
       
  9258 		TInt error = m_notifier.Connect();
       
  9259 		
       
  9260 		EAP_TRACE_DEBUG_SYMBIAN(
       
  9261 			(_L("eap_am_type_tls_peap_symbian_c::ShowNotifierItem - m_notifier.Connect() returned error=%d\n"), error));
       
  9262 		
       
  9263 		if( error != KErrNone)
       
  9264 		{
       
  9265 			// Can not connect to notifier.
       
  9266 			return m_am_tools->convert_am_error_to_eapol_error(error);		
       
  9267 		}
       
  9268 		
       
  9269 		m_is_notifier_connected = ETrue; // Got connectted to notifier.
       
  9270 	}
       
  9271 	
       
  9272 	// Update the values needed for notifier.
       
  9273 	m_notifier_data_to_user->iEapFastNotifierUiItem = aNotifierUiItem;
       
  9274 			
       
  9275 	EAP_TRACE_DEBUG_SYMBIAN(
       
  9276 		(_L("m_notifier_data_pckg_to_user"),
       
  9277 		m_notifier_data_pckg_to_user->Ptr(),
       
  9278 		m_notifier_data_pckg_to_user->Size()));
       
  9279 			
       
  9280 	m_notifier_data_from_user->iEapFastNotifierBuffer.Delete(0,KMaxEapFastNotifierBufLength);
       
  9281 	
       
  9282 	EAP_TRACE_DEBUG_SYMBIAN(
       
  9283 		(_L("eap_am_type_tls_peap_symbian_c::ShowNotifierItem - StartNotifierAndGetResponse")));
       
  9284 
       
  9285 	m_notifier.StartNotifierAndGetResponse(
       
  9286 		iStatus, 
       
  9287 		KEapFastNotifierUid, 
       
  9288 		*m_notifier_data_pckg_to_user, 
       
  9289 		*m_notifier_data_pckg_from_user);
       
  9290 	
       
  9291 	if ( aSetActive )
       
  9292 		{
       
  9293 		m_notifier_complete = ETrue;
       
  9294 		SetActive();
       
  9295 		}
       
  9296 	    
       
  9297 	EAP_TRACE_DEBUG_SYMBIAN(
       
  9298 		(_L("eap_am_type_tls_peap_symbian_c::ShowNotifierItem - End")));
       
  9299 
       
  9300 	return status;
       
  9301 }
       
  9302 
       
  9303 //--------------------------------------------------
  9383 //--------------------------------------------------
  9304 
  9384 
  9305 eap_status_e eap_am_type_tls_peap_symbian_c::RemoveIAPReference()
  9385 eap_status_e eap_am_type_tls_peap_symbian_c::RemoveIAPReference()
  9306 	{
  9386 {
  9307 	EAP_TRACE_DEBUG_SYMBIAN(
  9387 	EAP_TRACE_DEBUG_SYMBIAN(
  9308 		(_L("eap_am_type_tls_peap_symbian_c::RemoveIAPReference - Start")));
  9388 		(_L("eap_am_type_tls_peap_symbian_c::RemoveIAPReference - Start")));
  9309 	m_eap_fast_completion_status = eap_status_ok;	
  9389 	m_eap_fast_completion_status = eap_status_ok;	
  9310 			
  9390 			
  9311 	eap_variable_data_c aIapReference(m_am_tools);
  9391 	eap_variable_data_c aIapReference(m_am_tools);
  9365 		}
  9445 		}
  9366 	EAP_TRACE_DEBUG_SYMBIAN(
  9446 	EAP_TRACE_DEBUG_SYMBIAN(
  9367 		(_L("eap_am_type_tls_peap_symbian_c::RemoveIAPReference - End")));
  9447 		(_L("eap_am_type_tls_peap_symbian_c::RemoveIAPReference - End")));
  9368 		
  9448 		
  9369 	return m_eap_fast_completion_status;
  9449 	return m_eap_fast_completion_status;
  9370 	}
  9450 }
       
  9451 
       
  9452 //--------------------------------------------------
  9371 
  9453 
  9372 eap_status_e eap_am_type_tls_peap_symbian_c::ImportFilesL()
  9454 eap_status_e eap_am_type_tls_peap_symbian_c::ImportFilesL()
  9373 	{
  9455 {
  9374 
  9456 
  9375 	EAP_TRACE_DEBUG_SYMBIAN(
  9457 	EAP_TRACE_DEBUG_SYMBIAN(
  9376 			(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL - Start")));
  9458 			(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL - Start")));
  9377 	
  9459 	
  9378 	CDir* files;
  9460 	CDir* files;
  9463 	TPtr8 PathPtr8 = Path8->Des();
  9545 	TPtr8 PathPtr8 = Path8->Des();
  9464 	HBufC8* readData = NULL;
  9546 	HBufC8* readData = NULL;
  9465 	TBool FileFound(EFalse);
  9547 	TBool FileFound(EFalse);
  9466 	
  9548 	
  9467 	PathPtr8.Zero();
  9549 	PathPtr8.Zero();
  9468 	PathPtr8.Append(KPacStoreSourceDir);
       
  9469 	PathPtr8.Append(group_referencePtr8);
  9550 	PathPtr8.Append(group_referencePtr8);
  9470 	PathPtr8.Append(KSeparator);
  9551 	PathPtr8.Append(KSeparator);
       
  9552 
  9471 	EAP_TRACE_DATA_DEBUG(
  9553 	EAP_TRACE_DATA_DEBUG(
  9472 			m_am_tools,
  9554 			m_am_tools,
  9473 			TRACE_FLAGS_DEFAULT,
  9555 			TRACE_FLAGS_DEFAULT,
  9474 			(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Path8"),
  9556 			(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Path8"),
  9475 			PathPtr8.Ptr(),
  9557 			PathPtr8.Ptr(),
  9476 			PathPtr8.Size()));
  9558 			PathPtr8.Size()));
       
  9559 
  9477 	PathPtr.Zero();
  9560 	PathPtr.Zero();
       
  9561 	// Copy is the only function that takes TPtr8 type of parameter.
  9478 	PathPtr.Copy(PathPtr8);
  9562 	PathPtr.Copy(PathPtr8);
  9479 	
  9563 	
       
  9564 	{
       
  9565 		TFileName aPrivateDatabasePathName;
       
  9566 
       
  9567 		EapPluginTools::GetPrivatePathL(
       
  9568 			aPrivateDatabasePathName);
       
  9569 
       
  9570 		aPrivateDatabasePathName.Append(KPacStoreSourceDir);
       
  9571 		aPrivateDatabasePathName.Append(PathPtr);
       
  9572 
       
  9573 		PathPtr.Copy(aPrivateDatabasePathName);
       
  9574 	}
       
  9575 
  9480 	EAP_TRACE_DATA_DEBUG(
  9576 	EAP_TRACE_DATA_DEBUG(
  9481 			m_am_tools,
  9577 			m_am_tools,
  9482 			TRACE_FLAGS_DEFAULT,
  9578 			TRACE_FLAGS_DEFAULT,
  9483 			(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Path"),
  9579 			(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Path"),
  9484 			PathPtr.Ptr(),
  9580 			PathPtr.Ptr(),
  9485 			PathPtr.Size()));
  9581 			PathPtr.Size()));
  9486 			
  9582 
  9487 	EAP_TRACE_DEBUG_SYMBIAN(
  9583 	EAP_TRACE_DEBUG_SYMBIAN(
  9488 			(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: Check directory availability")));					
  9584 			(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: Check directory availability")));					
  9489 
  9585 
  9490 	if (aFs.GetDir(PathPtr, KEntryAttNormal, ESortByName, files) == KErrNone)
  9586 	if (aFs.GetDir(PathPtr, KEntryAttNormal, ESortByName, files) == KErrNone)
  9491 		{
  9587 		{
  9554 					}
  9650 					}
  9555 				}
  9651 				}
  9556 			else if(directoryEmpty == false &&  directoryExists == true && FileFound != EFalse)
  9652 			else if(directoryEmpty == false &&  directoryExists == true && FileFound != EFalse)
  9557 				{
  9653 				{
  9558 				PathPtr8.Zero();
  9654 				PathPtr8.Zero();
  9559 				PathPtr8.Append(KPacStoreSourceDir);
       
  9560 				PathPtr8.Append(group_referencePtr8);
  9655 				PathPtr8.Append(group_referencePtr8);
  9561 				PathPtr8.Append(KSeparator);
  9656 				PathPtr8.Append(KSeparator);
  9562 				PathPtr8.Append(filenamePtr8);
  9657 				PathPtr8.Append(filenamePtr8);
       
  9658 
  9563 				EAP_TRACE_DATA_DEBUG(
  9659 				EAP_TRACE_DATA_DEBUG(
  9564 						m_am_tools,
  9660 						m_am_tools,
  9565 						TRACE_FLAGS_DEFAULT,
  9661 						TRACE_FLAGS_DEFAULT,
  9566 						(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Path8"),
  9662 						(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Path8"),
  9567 						PathPtr8.Ptr(),
  9663 						PathPtr8.Ptr(),
  9568 						PathPtr8.Size()));
  9664 						PathPtr8.Size()));
       
  9665 
  9569 				PathPtr.Zero();
  9666 				PathPtr.Zero();
  9570 				PathPtr.Copy(PathPtr8);
  9667 				PathPtr.Copy(PathPtr8);
       
  9668 
       
  9669 				{
       
  9670 					TFileName aPrivateDatabasePathName;
       
  9671 
       
  9672 					EapPluginTools::GetPrivatePathL(
       
  9673 						aPrivateDatabasePathName);
       
  9674 
       
  9675 					aPrivateDatabasePathName.Append(KPacStoreSourceDir);
       
  9676 					aPrivateDatabasePathName.Append(PathPtr);
       
  9677 
       
  9678 					PathPtr.Copy(aPrivateDatabasePathName);
       
  9679 				}
  9571 				
  9680 				
       
  9681 				EAP_TRACE_DATA_DEBUG(
       
  9682 						m_am_tools,
       
  9683 						TRACE_FLAGS_DEFAULT,
       
  9684 						(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: PathPtr"),
       
  9685 						PathPtr.Ptr(),
       
  9686 						PathPtr.Size()));
       
  9687 
  9572 				EAP_TRACE_DEBUG_SYMBIAN(
  9688 				EAP_TRACE_DEBUG_SYMBIAN(
  9573 						(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: Read file")));	
  9689 						(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: Read file")));	
  9574 				
  9690 				
  9575 				RFile file;
  9691 				RFile file;
       
  9692 
  9576 				if(file.Open(aFs, PathPtr, EFileRead)==KErrNone)
  9693 				if(file.Open(aFs, PathPtr, EFileRead)==KErrNone)
  9577 					{
  9694 					{
  9578 					readData= HBufC8::NewLC(filesize); 
  9695 					readData= HBufC8::NewLC(filesize); 
  9579 					TPtr8 readDataPtr = readData->Des();
  9696 					TPtr8 readDataPtr = readData->Des();
  9580 					file.Read(readDataPtr);
  9697 					file.Read(readDataPtr);
  9687 			    m_eap_fast_completion_status = eap_status_ok;
  9804 			    m_eap_fast_completion_status = eap_status_ok;
  9688 	        m_eap_fast_completion_status = m_partner->set_timer(
  9805 	        m_eap_fast_completion_status = m_partner->set_timer(
  9689 	                this,
  9806 	                this,
  9690 	                KHandleCompletePacstoreNokTimerID, 
  9807 	                KHandleCompletePacstoreNokTimerID, 
  9691 	                &m_eap_fast_completion_status,
  9808 	                &m_eap_fast_completion_status,
  9692 	                1);
  9809 	                0);
  9693 			}
  9810 			}
  9694 		else
  9811 		else
  9695 			{
  9812 			{
  9696 		       m_eap_fast_completion_status = m_partner->set_timer(
  9813 		       m_eap_fast_completion_status = m_partner->set_timer(
  9697 		                this,
  9814 		                this,
  9698 		                KHandleCompletePacstoreOkTimerID, 
  9815 		                KHandleCompletePacstoreOkTimerID, 
  9699 		                &m_eap_fast_completion_status,
  9816 		                &m_eap_fast_completion_status,
  9700 		                1);
  9817 		                0);
  9701 			}
  9818 			}
  9702 		}
  9819 		}
  9703 	EAP_TRACE_DEBUG_SYMBIAN(
  9820 	EAP_TRACE_DEBUG_SYMBIAN(
  9704 			(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL - End")));
  9821 			(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL - End")));
  9705 
  9822 
  9706 	return m_eap_fast_completion_status;
  9823 	return m_eap_fast_completion_status;
  9707 	}
  9824 }
  9708 
  9825 
  9709 // ----------------------------------------------------------------------------
  9826 // ----------------------------------------------------------------------------
       
  9827 
  9710 eap_status_e eap_am_type_tls_peap_symbian_c::PasswordQueryL()
  9828 eap_status_e eap_am_type_tls_peap_symbian_c::PasswordQueryL()
  9711 	{
  9829 {
  9712 
  9830 
  9713 	EAP_TRACE_DEBUG_SYMBIAN(
  9831 	EAP_TRACE_DEBUG_SYMBIAN(
  9714 			(_L("eap_am_type_tls_peap_symbian_c::PasswordQueryL")));
  9832 			(_L("eap_am_type_tls_peap_symbian_c::PasswordQueryL")));
  9715 
  9833 
  9716 	m_pacStorePWBuf8 = HBufC8::NewLC(m_userResponse.get_data_length());
  9834 	m_pacStorePWBuf8 = HBufC8::NewLC(m_userResponse.get_data_length());
  9757 
  9875 
  9758 		  if(m_verificationStatus == EFalse)
  9876 		  if(m_verificationStatus == EFalse)
  9759 	    	{
  9877 	    	{
  9760 	    	CleanupStack::PopAndDestroy(m_pacStorePWBuf8);
  9878 	    	CleanupStack::PopAndDestroy(m_pacStorePWBuf8);
  9761 	    	
  9879 	    	
  9762 	    	m_eap_fast_completion_status = ShowNotifierItemAndGetResponse(
  9880     TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  9763 	    		EEapFastNotifierWrongPacStorePwNote, ETrue );
  9881     
       
  9882     m_notifier_data_to_user->iPassword.Zero();
       
  9883     
       
  9884     if (iEapAuthNotifier == 0)
       
  9885     	{
       
  9886     	TRAPD(err, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
       
  9887     	if (err)
       
  9888     		{
       
  9889     			return eap_status_process_general_error;
       
  9890     		}
       
  9891     	}
       
  9892     else
       
  9893     	{
       
  9894     	TRAPD(err1, iEapAuthNotifier->Cancel());
       
  9895     	if (err1)
       
  9896     		{
       
  9897     			return eap_status_process_general_error;
       
  9898     		}
       
  9899     	}
       
  9900 
       
  9901 		TRAPD(err2, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastWrongPacStorePwNote, m_notifier_data_to_user, aEapType));
       
  9902     	if (err2)
       
  9903     		{
       
  9904     			return eap_status_process_general_error;
       
  9905     		}
       
  9906 		
       
  9907 	
       
  9908 
       
  9909 
  9764 			return m_eap_fast_completion_status;
  9910 			return m_eap_fast_completion_status;
  9765 			 	    
  9911 			 	    
  9766 	    	}
  9912 	    	}
  9767 		  else
  9913 		  else
  9768 	    	{
  9914 	    	{
  9787     					m_state, 
  9933     					m_state, 
  9788     					m_prev_state,
  9934     					m_prev_state,
  9789     					m_verificationStatus));
  9935     					m_verificationStatus));
  9790        	pacStorePWPtr8.Zero();
  9936        	pacStorePWPtr8.Zero();
  9791        	if (m_verificationStatus == EFalse)
  9937        	if (m_verificationStatus == EFalse)
  9792 			m_eap_fast_completion_status = ShowNotifierItemAndGetResponse(
  9938 					{
  9793 				EEapFastNotifierPacStorePwQuery, ETrue );
  9939     TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
       
  9940     if (iEapAuthNotifier == 0)
       
  9941     	{
       
  9942     	TRAPD(err3, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
       
  9943     	if (err3)
       
  9944     		{
       
  9945     			return eap_status_process_general_error;
       
  9946     		}
       
  9947     	}
       
  9948     else
       
  9949     	{
       
  9950     	TRAPD(err4, iEapAuthNotifier->Cancel();
       
  9951     	if (err4)
       
  9952     		{
       
  9953     			return eap_status_process_general_error;
       
  9954     		}
       
  9955     	}
       
  9956 
       
  9957 		TRAPD(err5, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastPacStorePwQueryDialog, m_notifier_data_to_user, aEapType);
       
  9958   	if (err5)
       
  9959   		{
       
  9960   			return eap_status_process_general_error;
       
  9961   		}
       
  9962  
       
  9963 
       
  9964 					}
  9794 		else
  9965 		else
  9795 			m_eap_fast_completion_status = m_partner->set_timer(
  9966 			m_eap_fast_completion_status = m_partner->set_timer(
  9796 				this,
  9967 				this,
  9797 				KHandleReadPacstoreTimerID, 
  9968 				KHandleReadPacstoreTimerID, 
  9798 				&m_eap_fast_completion_status,
  9969 				&m_eap_fast_completion_status,
  9810     		EAP_TRACE_DEBUG_SYMBIAN(
  9981     		EAP_TRACE_DEBUG_SYMBIAN(
  9811     			(_L("eap_am_type_tls_peap_symbian_c::PasswordQueryL - EMasterkeyQuery - OK")));
  9982     			(_L("eap_am_type_tls_peap_symbian_c::PasswordQueryL - EMasterkeyQuery - OK")));
  9812     		}
  9983     		}
  9813      	else // temporary before masterkey creation is done dynamically !!!
  9984      	else // temporary before masterkey creation is done dynamically !!!
  9814     		{
  9985     		{
  9815         	m_eap_fast_completion_status = ShowNotifierItemAndGetResponse(
  9986     TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  9816         			EEapFastNotifierCreateMasterkeyQuery, ETrue );
  9987     if (iEapAuthNotifier == 0)
  9817    		
  9988     	{
  9818 			}
  9989     	TRAPD(err, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
       
  9990 	  	if (err)
       
  9991 	  		{
       
  9992 	  			return eap_status_process_general_error;
       
  9993 	  		}
       
  9994     	}
       
  9995     else
       
  9996     	{
       
  9997     	TRAPD(err1, iEapAuthNotifier->Cancel());
       
  9998 	  	if (err1)
       
  9999 	  		{
       
 10000 	  			return eap_status_process_general_error;
       
 10001 	  		}
       
 10002     	}
       
 10003 
       
 10004 		TRAPD(err2, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastCreateMasterkeyQueryDialog, m_notifier_data_to_user, aEapType));
       
 10005   	if (err2)
       
 10006   		{
       
 10007   			return eap_status_process_general_error;
       
 10008   		}
       
 10009 			
       
 10010 
       
 10011 
       
 10012 				}
  9819     	}
 10013     	}
  9820 
 10014 
  9821     CleanupStack::PopAndDestroy(m_pacStorePWBuf8);
 10015     CleanupStack::PopAndDestroy(m_pacStorePWBuf8);
  9822     
 10016     
  9823 	return m_eap_fast_completion_status;
 10017 	return m_eap_fast_completion_status;
  9824 	}
 10018 }
       
 10019 
       
 10020 //--------------------------------------------------
  9825 
 10021 
  9826 eap_status_e eap_am_type_tls_peap_symbian_c::CompletePasswordQueryL()
 10022 eap_status_e eap_am_type_tls_peap_symbian_c::CompletePasswordQueryL()
  9827 	{
 10023 {
  9828 
 10024 
  9829 	EAP_TRACE_DEBUG_SYMBIAN(
 10025 	EAP_TRACE_DEBUG_SYMBIAN(
  9830 			(_L("eap_am_type_tls_peap_symbian_c::CompletePasswordQueryL")));
 10026 			(_L("eap_am_type_tls_peap_symbian_c::CompletePasswordQueryL")));
  9831 
 10027 
  9832 	// m_PAC_store_password should have the PW now. Proceed as normal case.	
 10028 	// m_PAC_store_password should have the PW now. Proceed as normal case.	
  9895 	}
 10091 	}
  9896 
 10092 
  9897 	m_both_completed++;
 10093 	m_both_completed++;
  9898 
 10094 
  9899 	return m_eap_fast_completion_status;
 10095 	return m_eap_fast_completion_status;
  9900 	}
 10096 }
       
 10097 
       
 10098 //--------------------------------------------------
  9901 
 10099 
  9902 eap_status_e eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL(eap_status_e status)
 10100 eap_status_e eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL(eap_status_e status)
  9903 	{
 10101 {
  9904 	EAP_TRACE_DEBUG_SYMBIAN(
 10102 	EAP_TRACE_DEBUG_SYMBIAN(
  9905 			(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL")));
 10103 			(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL")));
  9906 	if (status == eap_status_ok && (m_new_references_and_data_blocks.get_object_count()>0))
 10104 	if (status == eap_status_ok && (m_new_references_and_data_blocks.get_object_count()>0))
  9907 		{
 10105 		{
  9908 		for (u32_t ind = 0ul; ind < m_ready_references_array_index; ++ind)
 10106 		for (u32_t ind = 0ul; ind < m_ready_references_array_index; ++ind)
  9918 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10116 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  9919 	
 10117 	
  9920 				EAP_TRACE_DEBUG_SYMBIAN(
 10118 				EAP_TRACE_DEBUG_SYMBIAN(
  9921 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10119 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
  9922 				m_ready_references_and_data_blocks.reset();
 10120 				m_ready_references_and_data_blocks.reset();
  9923 				eap_status_e status = m_tls_application->complete_read_PAC_store_data(
 10121 				
       
 10122 				status = m_tls_application->complete_read_PAC_store_data(
  9924 					m_eap_fast_completion_status,
 10123 					m_eap_fast_completion_status,
  9925 					m_eap_fast_pac_store_pending_operation,
 10124 					m_eap_fast_pac_store_pending_operation,
  9926 					&m_references_and_data_blocks);
 10125 					&m_references_and_data_blocks);
  9927 				
 10126 				
  9928 				return status;
 10127 				return status;
  9936 			{
 10135 			{
  9937 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10136 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  9938 				EAP_TRACE_DEBUG_SYMBIAN(
 10137 				EAP_TRACE_DEBUG_SYMBIAN(
  9939 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10138 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
  9940 				m_ready_references_and_data_blocks.reset();
 10139 				m_ready_references_and_data_blocks.reset();
  9941 				eap_status_e status = m_tls_application->complete_read_PAC_store_data(
 10140 				
       
 10141 				status = m_tls_application->complete_read_PAC_store_data(
  9942 					m_eap_fast_completion_status,
 10142 					m_eap_fast_completion_status,
  9943 					m_eap_fast_pac_store_pending_operation,
 10143 					m_eap_fast_pac_store_pending_operation,
  9944 					&m_references_and_data_blocks);
 10144 					&m_references_and_data_blocks);
  9945 				
 10145 				
  9946 				return status;
 10146 				return status;
  9951 			{
 10151 			{
  9952 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10152 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  9953 				EAP_TRACE_DEBUG_SYMBIAN(
 10153 				EAP_TRACE_DEBUG_SYMBIAN(
  9954 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10154 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
  9955 				m_ready_references_and_data_blocks.reset();
 10155 				m_ready_references_and_data_blocks.reset();
  9956 				eap_status_e status = m_tls_application->complete_read_PAC_store_data(
 10156 				
       
 10157 				status = m_tls_application->complete_read_PAC_store_data(
  9957 					m_eap_fast_completion_status,
 10158 					m_eap_fast_completion_status,
  9958 					m_eap_fast_pac_store_pending_operation,
 10159 					m_eap_fast_pac_store_pending_operation,
  9959 					&m_references_and_data_blocks);
 10160 					&m_references_and_data_blocks);
  9960 				
 10161 				
  9961 				return status;
 10162 				return status;
  9968 			{
 10169 			{
  9969 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10170 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  9970 				EAP_TRACE_DEBUG_SYMBIAN(
 10171 				EAP_TRACE_DEBUG_SYMBIAN(
  9971 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10172 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
  9972 				m_ready_references_and_data_blocks.reset();
 10173 				m_ready_references_and_data_blocks.reset();
  9973 				eap_status_e status = m_tls_application->complete_read_PAC_store_data(
 10174 				
       
 10175 				status = m_tls_application->complete_read_PAC_store_data(
  9974 					m_eap_fast_completion_status,
 10176 					m_eap_fast_completion_status,
  9975 					m_eap_fast_pac_store_pending_operation,
 10177 					m_eap_fast_pac_store_pending_operation,
  9976 					&m_references_and_data_blocks);
 10178 					&m_references_and_data_blocks);
  9977 				
 10179 				
  9978 				return status;
 10180 				return status;
  9995 			m_eap_fast_completion_status = eap_status_allocation_error;
 10197 			m_eap_fast_completion_status = eap_status_allocation_error;
  9996 			(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10198 			(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  9997 			EAP_TRACE_DEBUG_SYMBIAN(
 10199 			EAP_TRACE_DEBUG_SYMBIAN(
  9998 					(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10200 					(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
  9999 			m_ready_references_and_data_blocks.reset();
 10201 			m_ready_references_and_data_blocks.reset();
 10000 			eap_status_e status = m_tls_application->complete_read_PAC_store_data(
 10202 			
       
 10203 			status = m_tls_application->complete_read_PAC_store_data(
 10001 				m_eap_fast_completion_status,
 10204 				m_eap_fast_completion_status,
 10002 				m_eap_fast_pac_store_pending_operation,
 10205 				m_eap_fast_pac_store_pending_operation,
 10003 				&m_references_and_data_blocks);
 10206 				&m_references_and_data_blocks);
 10004 			
 10207 			
 10005 			return status;
 10208 			return status;
 10013 		{
 10216 		{
 10014 			(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10217 			(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10015 			EAP_TRACE_DEBUG_SYMBIAN(
 10218 			EAP_TRACE_DEBUG_SYMBIAN(
 10016 					(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10219 					(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10017 			m_ready_references_and_data_blocks.reset();
 10220 			m_ready_references_and_data_blocks.reset();
 10018 			eap_status_e status = m_tls_application->complete_read_PAC_store_data(
 10221 			
       
 10222 			status = m_tls_application->complete_read_PAC_store_data(
 10019 				m_eap_fast_completion_status,
 10223 				m_eap_fast_completion_status,
 10020 				m_eap_fast_pac_store_pending_operation,
 10224 				m_eap_fast_pac_store_pending_operation,
 10021 				&m_references_and_data_blocks);
 10225 				&m_references_and_data_blocks);
 10022 			
 10226 			
 10023 			return status;
 10227 			return status;
 10028 		{
 10232 		{
 10029 			(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10233 			(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10030 			EAP_TRACE_DEBUG_SYMBIAN(
 10234 			EAP_TRACE_DEBUG_SYMBIAN(
 10031 					(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10235 					(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10032 			m_ready_references_and_data_blocks.reset();
 10236 			m_ready_references_and_data_blocks.reset();
 10033 			eap_status_e status = m_tls_application->complete_read_PAC_store_data(
 10237 			
       
 10238 			status = m_tls_application->complete_read_PAC_store_data(
 10034 				m_eap_fast_completion_status,
 10239 				m_eap_fast_completion_status,
 10035 				m_eap_fast_pac_store_pending_operation,
 10240 				m_eap_fast_pac_store_pending_operation,
 10036 				&m_references_and_data_blocks);
 10241 				&m_references_and_data_blocks);
 10037 			
 10242 			
 10038 			return status;
 10243 			return status;
 10045 		{
 10250 		{
 10046 			(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10251 			(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10047 			EAP_TRACE_DEBUG_SYMBIAN(
 10252 			EAP_TRACE_DEBUG_SYMBIAN(
 10048 					(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10253 					(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10049 			m_ready_references_and_data_blocks.reset();
 10254 			m_ready_references_and_data_blocks.reset();
 10050 			eap_status_e status = m_tls_application->complete_read_PAC_store_data(
 10255 			
       
 10256 			status = m_tls_application->complete_read_PAC_store_data(
 10051 				m_eap_fast_completion_status,
 10257 				m_eap_fast_completion_status,
 10052 				m_eap_fast_pac_store_pending_operation,
 10258 				m_eap_fast_pac_store_pending_operation,
 10053 				&m_references_and_data_blocks);
 10259 				&m_references_and_data_blocks);
 10054 			
 10260 			
 10055 			return status;
 10261 			return status;
 10073 				m_eap_fast_completion_status = eap_status_allocation_error;
 10279 				m_eap_fast_completion_status = eap_status_allocation_error;
 10074 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10280 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10075 				EAP_TRACE_DEBUG_SYMBIAN(
 10281 				EAP_TRACE_DEBUG_SYMBIAN(
 10076 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10282 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10077 				m_ready_references_and_data_blocks.reset();
 10283 				m_ready_references_and_data_blocks.reset();
 10078 				eap_status_e status = m_tls_application->complete_read_PAC_store_data(
 10284 				
       
 10285 				status = m_tls_application->complete_read_PAC_store_data(
 10079 					m_eap_fast_completion_status,
 10286 					m_eap_fast_completion_status,
 10080 					m_eap_fast_pac_store_pending_operation,
 10287 					m_eap_fast_pac_store_pending_operation,
 10081 					&m_references_and_data_blocks);
 10288 					&m_references_and_data_blocks);
 10082 				
 10289 				
 10083 				return status;
 10290 				return status;
 10091 			{
 10298 			{
 10092 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10299 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10093 				EAP_TRACE_DEBUG_SYMBIAN(
 10300 				EAP_TRACE_DEBUG_SYMBIAN(
 10094 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10301 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10095 				m_ready_references_and_data_blocks.reset();
 10302 				m_ready_references_and_data_blocks.reset();
 10096 				eap_status_e status = m_tls_application->complete_read_PAC_store_data(
 10303 				
       
 10304 				status = m_tls_application->complete_read_PAC_store_data(
 10097 					m_eap_fast_completion_status,
 10305 					m_eap_fast_completion_status,
 10098 					m_eap_fast_pac_store_pending_operation,
 10306 					m_eap_fast_pac_store_pending_operation,
 10099 					&m_references_and_data_blocks);
 10307 					&m_references_and_data_blocks);
 10100 				
 10308 				
 10101 				return status;
 10309 				return status;
 10106 			{
 10314 			{
 10107 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10315 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10108 				EAP_TRACE_DEBUG_SYMBIAN(
 10316 				EAP_TRACE_DEBUG_SYMBIAN(
 10109 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10317 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10110 				m_ready_references_and_data_blocks.reset();
 10318 				m_ready_references_and_data_blocks.reset();
 10111 				eap_status_e status = m_tls_application->complete_read_PAC_store_data(
 10319 				
       
 10320 				status = m_tls_application->complete_read_PAC_store_data(
 10112 					m_eap_fast_completion_status,
 10321 					m_eap_fast_completion_status,
 10113 					m_eap_fast_pac_store_pending_operation,
 10322 					m_eap_fast_pac_store_pending_operation,
 10114 					&m_references_and_data_blocks);
 10323 					&m_references_and_data_blocks);
 10115 				
 10324 				
 10116 				return status;
 10325 				return status;
 10123 			{
 10332 			{
 10124 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10333 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10125 				EAP_TRACE_DEBUG_SYMBIAN(
 10334 				EAP_TRACE_DEBUG_SYMBIAN(
 10126 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10335 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10127 				m_ready_references_and_data_blocks.reset();
 10336 				m_ready_references_and_data_blocks.reset();
 10128 				eap_status_e status = m_tls_application->complete_read_PAC_store_data(
 10337 				
       
 10338 				status = m_tls_application->complete_read_PAC_store_data(
 10129 					m_eap_fast_completion_status,
 10339 					m_eap_fast_completion_status,
 10130 					m_eap_fast_pac_store_pending_operation,
 10340 					m_eap_fast_pac_store_pending_operation,
 10131 					&m_references_and_data_blocks);
 10341 					&m_references_and_data_blocks);
 10132 				
 10342 				
 10133 				return status;
 10343 				return status;
 10158 		m_new_references_and_data_blocks.reset();
 10368 		m_new_references_and_data_blocks.reset();
 10159 
 10369 
 10160 		EAP_TRACE_DEBUG_SYMBIAN(
 10370 		EAP_TRACE_DEBUG_SYMBIAN(
 10161 				(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL Reset Done")));
 10371 				(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL Reset Done")));
 10162 		
 10372 		
 10163 		eap_status_e status = m_tls_application->complete_read_PAC_store_data(
 10373 		status = m_tls_application->complete_read_PAC_store_data(
 10164 			m_eap_fast_completion_status,
 10374 			m_eap_fast_completion_status,
 10165 			m_eap_fast_pac_store_pending_operation,
 10375 			m_eap_fast_pac_store_pending_operation,
 10166 			&m_ready_references_and_data_blocks);
 10376 			&m_ready_references_and_data_blocks);
 10167 		}
 10377 		}
 10168 	else
 10378 	else
 10170 		EAP_TRACE_DEBUG_SYMBIAN(
 10380 		EAP_TRACE_DEBUG_SYMBIAN(
 10171 				(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10381 				(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10172 		m_eap_fast_completion_status = eap_status_user_cancel_authentication;
 10382 		m_eap_fast_completion_status = eap_status_user_cancel_authentication;
 10173 		m_new_references_and_data_blocks.reset();
 10383 		m_new_references_and_data_blocks.reset();
 10174 		m_ready_references_and_data_blocks.reset();
 10384 		m_ready_references_and_data_blocks.reset();
 10175 		eap_status_e status = m_tls_application->complete_read_PAC_store_data(
 10385 		
       
 10386 		status = m_tls_application->complete_read_PAC_store_data(
 10176 			m_eap_fast_completion_status,
 10387 			m_eap_fast_completion_status,
 10177 			m_eap_fast_pac_store_pending_operation,
 10388 			m_eap_fast_pac_store_pending_operation,
 10178 			&m_references_and_data_blocks);
 10389 			&m_references_and_data_blocks);
 10179 		}
 10390 		}
 10180 		}
 10391 		}
 10183 	EAP_TRACE_DEBUG_SYMBIAN(
 10394 	EAP_TRACE_DEBUG_SYMBIAN(
 10184 			(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10395 			(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10185 	m_eap_fast_completion_status = eap_status_user_cancel_authentication;
 10396 	m_eap_fast_completion_status = eap_status_user_cancel_authentication;
 10186 	m_new_references_and_data_blocks.reset();
 10397 	m_new_references_and_data_blocks.reset();
 10187 	m_ready_references_and_data_blocks.reset();
 10398 	m_ready_references_and_data_blocks.reset();
 10188 	eap_status_e status = m_tls_application->complete_read_PAC_store_data(
 10399 	
       
 10400 	status = m_tls_application->complete_read_PAC_store_data(
 10189 		m_eap_fast_completion_status,
 10401 		m_eap_fast_completion_status,
 10190 		m_eap_fast_pac_store_pending_operation,
 10402 		m_eap_fast_pac_store_pending_operation,
 10191 		&m_references_and_data_blocks);
 10403 		&m_references_and_data_blocks);
 10192 	}
 10404 	}
 10193 	
 10405 	
 10205 }
 10417 }
 10206 
 10418 
 10207 //--------------------------------------------------
 10419 //--------------------------------------------------
 10208 
 10420 
 10209 eap_status_e eap_am_type_tls_peap_symbian_c::CompleteFilePasswordQueryL()
 10421 eap_status_e eap_am_type_tls_peap_symbian_c::CompleteFilePasswordQueryL()
 10210 	{
 10422 {
 10211 	eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools);
 10423 	eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools);
 10212 
 10424 
 10213 	eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
 10425 	eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
 10214 		m_am_tools, new_data);
 10426 		m_am_tools, new_data);
 10215 
 10427 
 10267 		(new_data->get_data())->get_data_length()));
 10479 		(new_data->get_data())->get_data_length()));
 10268 	
 10480 	
 10269 	m_both_completed++;
 10481 	m_both_completed++;
 10270 	return m_eap_fast_completion_status;
 10482 	return m_eap_fast_completion_status;
 10271 
 10483 
 10272 	}
 10484 }
 10273 
 10485 
 10274 // ---------------------------------------------------------
 10486 // ---------------------------------------------------------
 10275 // eap_am_type_tls_peap_symbian_c::CompleteNotifier
 10487 // eap_am_type_tls_peap_symbian_c::CompleteNotifier
 10276 // ---------------------------------------------------------
 10488 // ---------------------------------------------------------
 10277 //    
 10489 //    
 10278 eap_status_e eap_am_type_tls_peap_symbian_c::CompleteNotifierL()
 10490 eap_status_e eap_am_type_tls_peap_symbian_c::CompleteNotifierL()
 10279 	{
 10491 {
 10280 	eap_status_e status( eap_status_ok );
 10492 	eap_status_e status( eap_status_ok );
 10281 	switch ( m_state )
 10493 	switch ( m_state )
 10282 	    {
 10494 	    {
 10283 	    case EPasswordCancel:
 10495 	    case EPasswordCancel:
 10284 	    case EPasswordQuery:
 10496 	    case EPasswordQuery:
 10285 	    case EWrongPassword:
 10497 	    case EWrongPassword:
 10286 	    case EFilePasswordQuery:
 10498 	    case EFilePasswordQuery:
 10287 	    case EMasterkeyQuery:
 10499 	    case EMasterkeyQuery:
 10288 	    	{
 10500 	    	{
 10289 	    	EAP_TRACE_DEBUG_SYMBIAN(
 10501 
 10290 	    			(_L("m_notifier_data_pckg_from_user"),
       
 10291 	    			m_notifier_data_pckg_from_user->Ptr(),
       
 10292 	    			m_notifier_data_pckg_from_user->Size()));	    		
       
 10293 	    	if ( iStatus.Int() == KErrCancel )
       
 10294 	    		{
       
 10295 	    		EAP_TRACE_DEBUG_SYMBIAN(
       
 10296 	    				(_L("eap_am_type_tls_peap_symbian_c::CompleteNotifierL - User cancelled the notifier item")));
       
 10297 	    		m_userAction = EEapFastNotifierUserActionCancel;	
       
 10298 	    		}		
       
 10299 	    	else if( iStatus.Int() != KErrNone )
       
 10300 	    		{
       
 10301 	    		EAP_TRACE_DEBUG_SYMBIAN(
       
 10302 	    			(_L("eap_am_type_tls_peap_symbian_c::CompleteNotifierL - ERROR: Notifier error=%d"),
       
 10303 	    			iStatus.Int()));	
       
 10304 	    		return m_am_tools->convert_am_error_to_eapol_error(iStatus.Int());		
       
 10305 	    		}
       
 10306     		EAP_TRACE_DEBUG_SYMBIAN(
       
 10307     			(_L("CompleteNotifierL - Notifier return UiItem=%d, UserAction=%d"),
       
 10308     			m_notifier_data_from_user->iEapFastNotifierUiItem,
       
 10309     			m_notifier_data_from_user->iEapFastNotifierUserAction));
       
 10310 	    		
       
 10311     		EAP_TRACE_DATA_DEBUG_SYMBIAN(
       
 10312     			("CompleteNotifierL:UserInput:",
       
 10313     			m_notifier_data_from_user->iEapFastNotifierBuffer.Ptr(), 
       
 10314     			m_notifier_data_from_user->iEapFastNotifierBuffer.Size()));
       
 10315 	    			    		
       
 10316 	    	if ( m_notifier_data_from_user->iEapFastNotifierBuffer.Size() > 0 )
       
 10317 	    		{
       
 10318     			HBufC8* notifier_data8 = HBufC8::NewLC(m_notifier_data_from_user->iEapFastNotifierBuffer.Size());
       
 10319     			TPtr8 notifier_dataPtr8 = notifier_data8->Des();
       
 10320     			
       
 10321     			notifier_dataPtr8.Copy(m_notifier_data_from_user->iEapFastNotifierBuffer); // Unicode -> ascii.
       
 10322     			EAP_TRACE_DEBUG_SYMBIAN(
       
 10323    					(_L("eap_am_type_tls_peap_symbian_c::CompleteNotifierL ShowNotifierItem - Data copy done")));
       
 10324     		    
       
 10325     			EAP_TRACE_DATA_DEBUG_SYMBIAN(
       
 10326 	    			("eap_am_type_tls_peap_symbian_c::CompleteNotifierL ShowNotifierItem:PW from UI (8bits)",
       
 10327    					notifier_dataPtr8.Ptr(), 
       
 10328    					notifier_dataPtr8.Size()));	    
       
 10329     		    
       
 10330     			status = m_userResponse.set_copy_of_buffer(
       
 10331    					notifier_dataPtr8.Ptr(),
       
 10332    					notifier_dataPtr8.Size());
       
 10333     			
       
 10334 	    		CleanupStack::PopAndDestroy( notifier_data8 );
       
 10335 	    		}
       
 10336 	    	break;
 10502 	    	break;
       
 10503 
 10337 	    	}
 10504 	    	}
 10338 	    default:
 10505 	    default:
 10339 	    	{
 10506 	    	{
 10340 	    	EAP_TRACE_DEBUG_SYMBIAN(
 10507 	    	EAP_TRACE_DEBUG_SYMBIAN(
 10341 	    	    ( _L( "eap_am_type_tls_peap_symbian_c::CompleteNotifierL() m_state = %d not supported." ),
 10508 	    	    ( _L( "eap_am_type_tls_peap_symbian_c::CompleteNotifierL() m_state = %d not supported." ),
 10342 	    	    m_state ) );
 10509 	    	    m_state ) );
 10343 	    	}
 10510 	    	}
 10344 	    }
 10511 	    }
 10345 	return status;
 10512 	return status;
 10346 	}
 10513 }
 10347 
 10514 
 10348 //--------------------------------------------------
 10515 //--------------------------------------------------
 10349 
 10516 
 10350 void eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL(const TDesC16& aFromUnicode, TDes8& aToAscii)
 10517 void eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL(const TDesC16& aFromUnicode, TDes8& aToAscii)
 10351 	{
 10518 {
 10352 		EAP_TRACE_DATA_DEBUG_SYMBIAN(
 10519 	EAP_TRACE_DATA_DEBUG_SYMBIAN(
 10353 			("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL:From TEXT",
 10520 		("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL:From TEXT",
 10354 			aFromUnicode.Ptr(), 
 10521 		aFromUnicode.Ptr(), 
 10355 			aFromUnicode.Size()));	
 10522 		aFromUnicode.Size()));	
 10356 		
 10523 	
 10357 		if(aFromUnicode.Length() <= 0)
 10524 	if(aFromUnicode.Length() <= 0)
 10358 		{
 10525 	{
 10359 			EAP_TRACE_DEBUG_SYMBIAN(
       
 10360 			(_L("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL: Return: NOTHING TO CONVERT")));
       
 10361 			
       
 10362 			return;
       
 10363 		}	
       
 10364 		
       
 10365 		EAP_TRACE_DEBUG_SYMBIAN(
 10526 		EAP_TRACE_DEBUG_SYMBIAN(
 10366 			(_L("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL, aFromUnicode.Length=%d, aFromUnicode.Size=%d"),
 10527 		(_L("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL: Return: NOTHING TO CONVERT")));
 10367 			aFromUnicode.Length(), aFromUnicode.Size()));	
 10528 		
 10368 		
 10529 		return;
 10369 		// Convert from Unicode to ascii.
 10530 	}	
 10370 		HBufC8* aFromUnicodeBuf8 = HBufC8::NewLC(aFromUnicode.Length()); // Half times size of source (or length) is enough here.
 10531 	
 10371 		TPtr8 aFromUnicodePtr8 = aFromUnicodeBuf8->Des();
 10532 	EAP_TRACE_DEBUG_SYMBIAN(
 10372 		
 10533 		(_L("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL, aFromUnicode.Length=%d, aFromUnicode.Size=%d"),
 10373 		EAP_TRACE_DEBUG_SYMBIAN(
 10534 		aFromUnicode.Length(), aFromUnicode.Size()));	
 10374 			(_L("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL, aFromUnicodePtr8.Length=%d, aFromUnicodePtr8.Size=%d, aFromUnicodePtr8.MaxLength=%d, aFromUnicodePtr8.MaxSize=%d"),
 10535 	
 10375 			aFromUnicodePtr8.Length(), aFromUnicodePtr8.Size(), aFromUnicodePtr8.MaxLength(), aFromUnicodePtr8.MaxSize()));				
 10536 	// Convert from Unicode to ascii.
 10376 		
 10537 	HBufC8* aFromUnicodeBuf8 = HBufC8::NewLC(aFromUnicode.Length()); // Half times size of source (or length) is enough here.
 10377 		aFromUnicodePtr8.Copy(aFromUnicode); // Unicode -> ascii.
 10538 	TPtr8 aFromUnicodePtr8 = aFromUnicodeBuf8->Des();
 10378 		
 10539 	
 10379 		aToAscii = aFromUnicodePtr8;	
 10540 	EAP_TRACE_DEBUG_SYMBIAN(
 10380 
 10541 		(_L("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL, aFromUnicodePtr8.Length=%d, aFromUnicodePtr8.Size=%d, aFromUnicodePtr8.MaxLength=%d, aFromUnicodePtr8.MaxSize=%d"),
 10381 		CleanupStack::PopAndDestroy(aFromUnicodeBuf8); // Delete aFromUnicodeBuf8.	
 10542 		aFromUnicodePtr8.Length(), aFromUnicodePtr8.Size(), aFromUnicodePtr8.MaxLength(), aFromUnicodePtr8.MaxSize()));				
 10382 
 10543 	
 10383 		EAP_TRACE_DATA_DEBUG_SYMBIAN(
 10544 	aFromUnicodePtr8.Copy(aFromUnicode); // Unicode -> ascii.
 10384 			("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL:To ASCII",
 10545 	
 10385 			aToAscii.Ptr(), 
 10546 	aToAscii = aFromUnicodePtr8;	
 10386 			aToAscii.Size()));	
 10547 
 10387 	}
 10548 	CleanupStack::PopAndDestroy(aFromUnicodeBuf8); // Delete aFromUnicodeBuf8.	
       
 10549 
       
 10550 	EAP_TRACE_DATA_DEBUG_SYMBIAN(
       
 10551 		("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL:To ASCII",
       
 10552 		aToAscii.Ptr(), 
       
 10553 		aToAscii.Size()));	
       
 10554 }
 10388 
 10555 
 10389 
 10556 
 10390 // ---------------------------------------------------------
 10557 // ---------------------------------------------------------
 10391 // eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL()
 10558 // eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL()
 10392 // ---------------------------------------------------------
 10559 // ---------------------------------------------------------
 10393 //
 10560 //
 10394 void eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL()
 10561 void eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL()
 10395 	{
 10562 {
 10396 	/* Check validity of password against timelimit */
 10563 	/* Check validity of password against timelimit */
 10397 	
 10564 	
 10398 	EAP_TRACE_DEBUG(m_am_tools, 
 10565 	EAP_TRACE_DEBUG(m_am_tools, 
 10399 			TRACE_FLAGS_DEFAULT, (
 10566 			TRACE_FLAGS_DEFAULT, (
 10400 			EAPL("CheckPasswordTimeValidityL - Start\n")));
 10567 			EAPL("CheckPasswordTimeValidityL - Start\n")));
 10403 	TInt64 fullAuthTime = 0;
 10570 	TInt64 fullAuthTime = 0;
 10404 	
 10571 	
 10405     // get max session time
 10572     // get max session time
 10406 	HBufC* buf = HBufC::NewLC( KMaxSqlQueryLength );
 10573 	HBufC* buf = HBufC::NewLC( KMaxSqlQueryLength );
 10407 	TPtr sqlStatement = buf->Des();	
 10574 	TPtr sqlStatement = buf->Des();	
 10408 	_LIT( KSqlQuery, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d" );
 10575 
       
 10576 	_LIT( KSqlQuery, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d" );
       
 10577 
 10409 	sqlStatement.Format(
 10578 	sqlStatement.Format(
 10410 		KSqlQuery,
 10579 		KSqlQuery,
 10411 		&cf_str_EAP_FAST_max_session_validity_time_literal,
 10580 		&cf_str_EAP_FAST_max_session_validity_time_literal,
 10412 		&KFastGeneralSettingsDBTableName,
 10581 		&KFastGeneralSettingsDBTableName,
 10413 		&KServiceType, m_index_type, 
 10582 		&KServiceType,
 10414 		&KServiceIndex, m_index,
 10583 		m_index_type, 
 10415 		&KTunnelingType, m_tunneling_vendor_type );	
 10584 		&KServiceIndex,
       
 10585 		m_index,
       
 10586 		&KTunnelingTypeVendorId,
       
 10587 		m_tunneling_type.get_vendor_id(),
       
 10588 		&KTunnelingType, 
       
 10589 		m_tunneling_type.get_vendor_type());
       
 10590 
 10416 	TRAPD( err,  maxSessionTime =  ReadIntDbValueL(
 10591 	TRAPD( err,  maxSessionTime =  ReadIntDbValueL(
 10417 		m_database,
 10592 		m_database,
 10418 		cf_str_EAP_FAST_max_session_validity_time_literal,
 10593 		cf_str_EAP_FAST_max_session_validity_time_literal,
 10419 		sqlStatement ) );
 10594 		sqlStatement ) );
 10420 	if ( err != KErrNone )
 10595 	if ( err != KErrNone )
 10584 				error));
 10759 				error));
 10585 		
 10760 		
 10586 			}
 10761 			}
 10587 		}
 10762 		}
 10588 	
 10763 	
 10589 	} // eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL()
 10764 } // eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL()
 10590 
 10765 
 10591 
 10766 
 10592 // ---------------------------------------------------------
 10767 // ---------------------------------------------------------
 10593 // eap_am_type_tls_peap_symbian_c::AlterTableL()
 10768 // eap_am_type_tls_peap_symbian_c::AlterTableL()
 10594 // ---------------------------------------------------------
 10769 // ---------------------------------------------------------
 10597 	RDbNamedDatabase& aDb,
 10772 	RDbNamedDatabase& aDb,
 10598 	TAlterTableCmd aCmd,
 10773 	TAlterTableCmd aCmd,
 10599 	const TDesC& aTableName,
 10774 	const TDesC& aTableName,
 10600 	const TDesC& aColumnName,
 10775 	const TDesC& aColumnName,
 10601 	const TDesC& aColumnDef )
 10776 	const TDesC& aColumnDef )
 10602 	{
 10777 {
 10603 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
 10778 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
 10604 		"eap_am_type_tls_peap_symbian_c::AlterTableL() IN\n" ) ) );
 10779 		"eap_am_type_tls_peap_symbian_c::AlterTableL() IN\n" ) ) );
 10605 	
 10780 	
 10606 	CDbColSet* colSet = aDb.ColSetL( aTableName );
 10781 	CDbColSet* colSet = aDb.ColSetL( aTableName );
 10607 	User::LeaveIfNull( colSet );
 10782 	User::LeaveIfNull( colSet );
 10673 	delete alteredColSet;
 10848 	delete alteredColSet;
 10674 		
 10849 		
 10675 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
 10850 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
 10676 	    "eap_am_type_tls_peap_symbian_c::AlterTableL() OUT\n" ) ) );
 10851 	    "eap_am_type_tls_peap_symbian_c::AlterTableL() OUT\n" ) ) );
 10677 
 10852 
 10678 	} // eap_am_type_tls_peap_symbian_c::AlterTableL()
 10853 } // eap_am_type_tls_peap_symbian_c::AlterTableL()
 10679 
 10854 
 10680 
 10855 
 10681 // ---------------------------------------------------------
 10856 // ---------------------------------------------------------
 10682 // eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL()
 10857 // eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL()
 10683 // ---------------------------------------------------------
 10858 // ---------------------------------------------------------
 10684 //
 10859 //
 10685 void eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL()
 10860 void eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL()
 10686 	{
 10861 {
 10687 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
 10862 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
 10688 	    "eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL() IN" ) ) );	
 10863 	    "eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL() IN" ) ) );	
 10689 	
 10864 	
 10690 	// remove password identity time from fast table	
 10865 	// remove password identity time from fast table	
 10691 	_LIT( KColumnDef, "BIGINT" );
 10866 	_LIT( KColumnDef, "BIGINT" );
 10714 	// update password identity time
 10889 	// update password identity time
 10715 	UpdatePasswordTimeL();
 10890 	UpdatePasswordTimeL();
 10716 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
 10891 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
 10717 	    "eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL() OUT" ) ) );
 10892 	    "eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL() OUT" ) ) );
 10718 	
 10893 	
 10719 	} // eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL()
 10894 } // eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL()
 10720 
 10895 
 10721 
 10896 
 10722 // ---------------------------------------------------------
 10897 // ---------------------------------------------------------
 10723 // eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL()
 10898 // eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL()
 10724 // ---------------------------------------------------------
 10899 // ---------------------------------------------------------
 10725 //
 10900 //
 10726 void eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL()
 10901 void eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL()
 10727 	{
 10902 {
 10728 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
 10903 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
 10729 		"eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL() IN\n" ) ) );
 10904 		"eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL() IN\n" ) ) );
 10730 	
 10905 	
 10731 #ifdef USE_PAC_STORE
 10906 #ifdef USE_PAC_STORE
 10732 	
 10907 	
 10750 #endif
 10925 #endif
 10751 		
 10926 		
 10752 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
 10927 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
 10753 	    "eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL() OUT\n" ) ) );
 10928 	    "eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL() OUT\n" ) ) );
 10754 
 10929 
 10755 	} // eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL()
 10930 } // eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL()
 10756 
 10931 
 10757 
 10932 
 10758 // ---------------------------------------------------------
 10933 // ---------------------------------------------------------
 10759 // eap_am_type_tls_peap_symbian_c::ReadIntDbValue()
 10934 // eap_am_type_tls_peap_symbian_c::ReadIntDbValue()
 10760 // ---------------------------------------------------------
 10935 // ---------------------------------------------------------
 10761 //
 10936 //
 10762 TInt64 eap_am_type_tls_peap_symbian_c::ReadIntDbValueL(
 10937 TInt64 eap_am_type_tls_peap_symbian_c::ReadIntDbValueL(
 10763 	RDbNamedDatabase& aDb,
 10938 	RDbNamedDatabase& aDb,
 10764 	const TDesC& aColumnName,
 10939 	const TDesC& aColumnName,
 10765 	const TDesC& aSqlStatement )
 10940 	const TDesC& aSqlStatement )
 10766     {
 10941 {
 10767 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (
 10942 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (
 10768 			EAPL( "eap_am_type_tls_peap_symbian_c::ReadIntDbValueL()\n" ) ) );
 10943 			EAPL( "eap_am_type_tls_peap_symbian_c::ReadIntDbValueL()\n" ) ) );
 10769     TPtrC columnName;    
 10944     TPtrC columnName;    
 10770 	columnName.Set( aColumnName );
 10945 	columnName.Set( aColumnName );
 10771 	
 10946 	
 10790 
 10965 
 10791 	CleanupStack::PopAndDestroy( colSet ); // Delete colSet.
 10966 	CleanupStack::PopAndDestroy( colSet ); // Delete colSet.
 10792 	CleanupStack::PopAndDestroy( &view ); // Close view.
 10967 	CleanupStack::PopAndDestroy( &view ); // Close view.
 10793 
 10968 
 10794 	return retVal;
 10969 	return retVal;
 10795     } // eap_am_type_tls_peap_symbian_c::ReadIntDbValueL
 10970 } // eap_am_type_tls_peap_symbian_c::ReadIntDbValueL
 10796 
 10971 
 10797 
 10972 
 10798 // ---------------------------------------------------------
 10973 // ---------------------------------------------------------
 10799 // eap_am_type_tls_peap_symbian_c::UpdatePasswordTimeL()
 10974 // eap_am_type_tls_peap_symbian_c::UpdatePasswordTimeL()
 10800 // ---------------------------------------------------------
 10975 // ---------------------------------------------------------
 10801 //
 10976 //
 10802 void eap_am_type_tls_peap_symbian_c::UpdatePasswordTimeL()
 10977 void eap_am_type_tls_peap_symbian_c::UpdatePasswordTimeL()
 10803 	{
 10978 {
 10804 	/* update last password time */
 10979 	/* update last password time */
 10805 	TPtrC lastFullPasswordTimeString;
 10980 	TPtrC lastFullPasswordTimeString;
 10806 	
 10981 	
 10807 	EAP_TRACE_DEBUG(m_am_tools, 
 10982 	EAP_TRACE_DEBUG(m_am_tools, 
 10808 			TRACE_FLAGS_DEFAULT, (
 10983 			TRACE_FLAGS_DEFAULT, (
 10884 	CleanupStack::PopAndDestroy(&view); // Close view.
 11059 	CleanupStack::PopAndDestroy(&view); // Close view.
 10885 	CleanupStack::PopAndDestroy(buf); // Delete buf.
 11060 	CleanupStack::PopAndDestroy(buf); // Delete buf.
 10886 	
 11061 	
 10887 	/* update end */	
 11062 	/* update end */	
 10888 	
 11063 	
 10889 	} // eap_am_type_tls_peap_symbian_c::UpdatePasswordTimeL()
 11064 } // eap_am_type_tls_peap_symbian_c::UpdatePasswordTimeL()
 10890 
 11065 
       
 11066 //--------------------------------------------------
 10891 
 11067 
 10892 eap_status_e eap_am_type_tls_peap_symbian_c::CreateMasterkeyL()
 11068 eap_status_e eap_am_type_tls_peap_symbian_c::CreateMasterkeyL()
 10893 	{
 11069 {
 10894 	HBufC8* password = HBufC8::NewLC(m_userResponse.get_data_length());
 11070 	HBufC8* password = HBufC8::NewLC(m_userResponse.get_data_length());
 10895 	TPtr8 passwordPtr = password->Des();
 11071 	TPtr8 passwordPtr = password->Des();
 10896 	m_PAC_store_password.set_copy_of_buffer(&m_userResponse);
 11072 	m_PAC_store_password.set_copy_of_buffer(&m_userResponse);
 10897 	passwordPtr.Copy(m_userResponse.get_data(), m_userResponse.get_data_length());
 11073 	passwordPtr.Copy(m_userResponse.get_data(), m_userResponse.get_data_length());
 10898 	m_eap_fast_completion_status = m_am_tools->convert_am_error_to_eapol_error(iPacStoreDb->CreateAndSaveMasterKeyL(passwordPtr));
 11074 	m_eap_fast_completion_status = m_am_tools->convert_am_error_to_eapol_error(iPacStoreDb->CreateAndSaveMasterKeyL(passwordPtr));
 10899 	CleanupStack::PopAndDestroy(password);
 11075 	CleanupStack::PopAndDestroy(password);
 10900 	return m_eap_fast_completion_status;
 11076 	return m_eap_fast_completion_status;
 10901 	}
 11077 }
       
 11078 
 10902 #endif //#if defined(USE_FAST_EAP_TYPE)
 11079 #endif //#if defined(USE_FAST_EAP_TYPE)
 10903 
 11080 
 10904 
 11081 
 10905 
 11082 
 10906 // ================= TTLS-PAP public exported =======================
 11083 // ================= TTLS-PAP public exported =======================
 10907 
 11084 
 10908 // ------------------------------------------------------------------------
 11085 // ------------------------------------------------------------------------
 10909 // eap_am_type_tls_peap_symbian_c::is_ttls_pap_session_valid()
 11086 // eap_am_type_tls_peap_symbian_c::is_ttls_pap_session_valid()
 10910 // ------------------------------------------------------------------------
 11087 // ------------------------------------------------------------------------
 10911 //
 11088 //
 10912 EAP_FUNC_EXPORT
 11089 EAP_FUNC_EXPORT bool eap_am_type_tls_peap_symbian_c::is_ttls_pap_session_valid()
 10913 bool eap_am_type_tls_peap_symbian_c::is_ttls_pap_session_valid()
 11090 {
 10914 	{
 11091     EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::is_ttls_pap_session_valid()" )));    
 10915     DEBUG( "eap_am_type_tls_peap_symbian_c::is_ttls_pap_session_valid()" );    
       
 10916 
 11092 
 10917     TBool isValid = EFalse;
 11093     TBool isValid = EFalse;
 10918     TInt err = KErrNone;
 11094     TInt err = KErrNone;
 10919     bool retVal = false;
 11095     bool retVal = false;
 10920 	
 11096 	
 10921     TRAP( err, isValid = IsTtlsPapSessionValidL() );
 11097     TRAP( err, isValid = IsTtlsPapSessionValidL() );
 10922     if ( err != KErrNone )
 11098     if ( err != KErrNone )
 10923 	    {
 11099 	    {
 10924 	    DEBUG1( "eap_am_type_tls_peap_symbian_c::is_ttls_pap_session_valid() ERROR: \
 11100 	    EAP_TRACE_DEBUG_SYMBIAN((_L("ERROR: eap_am_type_tls_peap_symbian_c::is_ttls_pap_session_valid(): Leave, err==%d."), err ));
 10925 	        Leave, err==%d.", err );
       
 10926 	    retVal = false;
 11101 	    retVal = false;
 10927 	    }
 11102 	    }
 10928     else
 11103     else
 10929     	{
 11104     	{
 10930     	retVal = ( isValid ) ? true : false;
 11105     	retVal = ( isValid ) ? true : false;
 10931     	}
 11106     	}
 10932     return retVal;
 11107     return retVal;
 10933 	}
 11108 }
 10934 
 11109 
 10935 // ------------------------------------------------------------------------
 11110 // ------------------------------------------------------------------------
 10936 // eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password()
 11111 // eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password()
 10937 // ------------------------------------------------------------------------
 11112 // ------------------------------------------------------------------------
 10938 //    
 11113 //    
 10939 EAP_FUNC_EXPORT eap_status_e
 11114 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password(
 10940 eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password(
       
 10941 	const eap_variable_data_c * const aInSrvChallengeUtf8 )
 11115 	const eap_variable_data_c * const aInSrvChallengeUtf8 )
 10942     {
 11116 {
 10943     DEBUG( "eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password()" );    
 11117     EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password()" )));    
 10944 	
 11118 	
 10945     eap_status_e status( eap_status_pending_request );
 11119     eap_status_e status( eap_status_pending_request );
 10946 
 11120     TEapExpandedType aEapType(*EapExpandedTypeTtlsPap.GetType());
 10947     if ( !iEapTtlsPapActive )
 11121     
       
 11122     m_notifier_data_to_user->iUsername.Zero();
       
 11123     m_notifier_data_to_user->iPassword.Zero();
       
 11124     m_notifier_data_to_user->iUidata.Zero();
       
 11125     
       
 11126     if (aInSrvChallengeUtf8 != NULL)
 10948     	{
 11127     	{
 10949     	TRAPD( err, iEapTtlsPapActive = CEapTtlsPapActive::NewL(
 11128 			const TPtrC8 utf8(
 10950     		this, m_am_tools ) );
 11129 				aInSrvChallengeUtf8->get_data(), aInSrvChallengeUtf8->get_data_length()*2); // Length in bytes
 10951     	if ( err != KErrNone )
 11130 		
 10952     		{
 11131 			TPtr16 unicode(reinterpret_cast<unsigned short *>(&m_notifier_data_to_user->iUidata), m_notifier_data_to_user->iUidata.Size());
 10953             DEBUG1( "eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password() \
 11132 			CnvUtfConverter::ConvertToUnicodeFromUtf8(unicode, utf8);
 10954             	ERROR: CEapTtlsPapActive::NewL(), err=%d.", err );    
 11133 
 10955     	    return ConvertAmErrorToEapolError( err );
 11134 			m_state = EPapChallenge;
 10956     		}
 11135 	    TEapExpandedType aEapType(*EapExpandedTypeTtlsPap.GetType());
 10957     	}
 11136 	    
 10958     if ( aInSrvChallengeUtf8 != NULL )
 11137 	    if (iEapAuthNotifier == 0)
 10959     	{
 11138 	    	{
 10960         iEapTtlsPapActive->UpdateSrvChallenge( *aInSrvChallengeUtf8 );
 11139 	    	TRAPD(err, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
 10961     	}
 11140 		  	if (err)
 10962     TBool startedOk = iEapTtlsPapActive->Start(
 11141 		  		{
 10963     	CEapTtlsPapActive::EEapTtlsPapActiveQueryUserNameAndPassword );
 11142 		  			return eap_status_process_general_error;
 10964 	if ( !startedOk )
 11143 		  		}
 10965         {
 11144 	    	}
 10966         status = eap_status_process_general_error;
 11145 	    TRAPD(err1, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypePapChallengeReplyQueryDialog, m_notifier_data_to_user, aEapType));
 10967         }
 11146 	  	if (err1)
 10968 	if ( status != eap_status_pending_request )
 11147 	  		{
 10969 		{
 11148 	  			return eap_status_process_general_error;
 10970         DEBUG( "eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password() \
 11149 	  		}
 10971         	ERROR: status != eap_status_pending_request" );    
 11150 	   	}
 10972 		}
 11151 		else
       
 11152 			{
       
 11153 			m_state = EPapUserNameAndPassword;
       
 11154 		
       
 11155 			TTtlsPapDbInfo aInDbInfo;
       
 11156 			TRAPD(err2, ReadTtlsPapDbL(aInDbInfo));
       
 11157 	  	if (err2)
       
 11158 	  		{
       
 11159 	  			return eap_status_process_general_error;
       
 11160 	  		}
       
 11161 
       
 11162 	    m_notifier_data_to_user->iPasswordPromptEnabled = aInDbInfo.iUsrPwdInfo.iPasswordPromptEnabled;
       
 11163 			if (m_notifier_data_to_user->iPasswordPromptEnabled ||
       
 11164 				 (aInDbInfo.iUsrPwdInfo.iUserName.Size() == 0 &&
       
 11165 				  aInDbInfo.iUsrPwdInfo.iPassword.Size() == 0))
       
 11166 				{
       
 11167 	  	  m_notifier_data_to_user->iUsername.Zero();
       
 11168 	   		m_notifier_data_to_user->iPassword.Zero();
       
 11169 	   		TRAPD(err3,SetTtlsPapColumnToNullL( cf_str_EAP_TLS_PEAP_ttls_pap_password_literal ));
       
 11170 		  	if (err3)
       
 11171 		  		{
       
 11172 		  			return eap_status_process_general_error;
       
 11173 		  		}
       
 11174 	   		
       
 11175 		    if (iEapAuthNotifier == 0)
       
 11176 		    	{
       
 11177 		    	TRAPD(err4, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
       
 11178 			  	if (err4)
       
 11179 			  		{
       
 11180 			  			return eap_status_process_general_error;
       
 11181 			  		}
       
 11182 		    	}
       
 11183 		    else
       
 11184 		    	{
       
 11185 		    	TRAPD(err5,iEapAuthNotifier->Cancel());
       
 11186 			  	if (err5)
       
 11187 			  		{
       
 11188 			  			return eap_status_process_general_error;
       
 11189 			  		}
       
 11190 		    	}
       
 11191 				TRAPD(err6, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypePapAuthQueryDialog, m_notifier_data_to_user, aEapType));
       
 11192 		  	if (err6)
       
 11193 		  		{
       
 11194 		  			return eap_status_process_general_error;
       
 11195 		  		}
       
 11196 				}
       
 11197 			else
       
 11198 				{
       
 11199 		    m_notifier_data_to_user->iUsername = aInDbInfo.iUsrPwdInfo.iUserName;
       
 11200 	  	  m_notifier_data_to_user->iPassword = aInDbInfo.iUsrPwdInfo.iPassword;
       
 11201 				DlgComplete(KErrNone);
       
 11202 				}
       
 11203 			}
       
 11204 
 10973 	return status;
 11205 	return status;
 10974     }
 11206 }
 10975 
 11207 
 10976 // ================= TTLS-PAP public not exported =======================
 11208 // ================= TTLS-PAP public not exported =======================
 10977 
 11209 
 10978 // ------------------------------------------------------------------------
 11210 // ------------------------------------------------------------------------
 10979 // eap_am_type_tls_peap_symbian_c::verify_ttls_pap_username_and_password()
 11211 // eap_am_type_tls_peap_symbian_c::verify_ttls_pap_username_and_password()
 10980 // ------------------------------------------------------------------------
 11212 // ------------------------------------------------------------------------
 10981 //    
 11213 //    
 10982 eap_status_e
 11214 eap_status_e eap_am_type_tls_peap_symbian_c::verify_ttls_pap_username_and_password(
 10983 eap_am_type_tls_peap_symbian_c::verify_ttls_pap_username_and_password(
       
 10984 	const eap_variable_data_c * const /*aUserName*/,
 11215 	const eap_variable_data_c * const /*aUserName*/,
 10985 	const eap_variable_data_c * const /*aUserPassword*/ )
 11216 	const eap_variable_data_c * const /*aUserPassword*/ )
 10986 	{
 11217 {
 10987 	DEBUG( "eap_am_type_tls_peap_symbian_c::verify_ttls_pap_username_and_password()" );
 11218 	EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::verify_ttls_pap_username_and_password()" )));
 10988 	return eap_status_not_supported;
 11219 	return eap_status_not_supported;
 10989 	}
 11220 }
 10990 
 11221 
 10991 // ================= TTLS-PAP public new =======================
 11222 // ================= TTLS-PAP public new =======================
 10992 
 11223 
 10993 // ------------------------------------------------------------------------
 11224 // ------------------------------------------------------------------------
 10994 // eap_am_type_tls_peap_symbian_c::CompleteQueryTtlsPapUserNameAndPassword()
 11225 // eap_am_type_tls_peap_symbian_c::CompleteQueryTtlsPapUserNameAndPassword()
 10995 // ------------------------------------------------------------------------
 11226 // ------------------------------------------------------------------------
 10996 //    
 11227 //    
 10997 eap_status_e
 11228 eap_status_e eap_am_type_tls_peap_symbian_c::CompleteQueryTtlsPapUserNameAndPassword(
 10998 eap_am_type_tls_peap_symbian_c::CompleteQueryTtlsPapUserNameAndPassword(
       
 10999 	eap_status_e aStatus,
 11229 	eap_status_e aStatus,
 11000 	const TDesC8& aUserNameUtf8,
 11230 	const TDesC8& aUserNameUtf8,
 11001 	const TDesC8& aPasswordUtf8 )
 11231 	const TDesC8& aPasswordUtf8 )
 11002 	{
 11232 {
 11003 	DEBUG( "eap_am_type_tls_peap_symbian_c::CompleteQueryTtlsPapUserNameAndPassword()" );
 11233 	EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::CompleteQueryTtlsPapUserNameAndPassword()" )));
 11004 	
 11234 	
 11005 	eap_status_e retStatus = aStatus;
 11235 	eap_status_e retStatus = aStatus;
 11006 	eap_status_e tmpStatus = eap_status_ok;
 11236 	eap_status_e tmpStatus = eap_status_ok;
 11007 	
 11237 	
 11008 	eap_variable_data_c userNameUtf8( m_am_tools );
 11238 	eap_variable_data_c userNameUtf8( m_am_tools );
 11020 		{
 11250 		{
 11021 		retStatus = tmpStatus;
 11251 		retStatus = tmpStatus;
 11022 		}
 11252 		}
 11023 	if ( m_tls_am_partner == NULL )
 11253 	if ( m_tls_am_partner == NULL )
 11024 		{
 11254 		{
 11025 		DEBUG( "eap_am_type_tls_peap_symbian_c::CompleteQueryTtlsPapUserNameAndPassword() \
 11255 		EAP_TRACE_DEBUG_SYMBIAN((_L( "ERROR: eap_am_type_tls_peap_symbian_c::CompleteQueryTtlsPapUserNameAndPassword(): m_tls_am_partner is NULL." )));
 11026 			ERROR: m_tls_am_partner is NULL." );
       
 11027         return eap_status_process_general_error;
 11256         return eap_status_process_general_error;
 11028 		}
 11257 		}
 11029 	retStatus = m_tls_am_partner->
 11258 	retStatus = m_tls_am_partner->
 11030 	    complete_query_ttls_pap_username_and_password(
 11259 	    complete_query_ttls_pap_username_and_password(
 11031 		    &userNameUtf8, &passwordUtf8, retStatus );	
 11260 		    &userNameUtf8, &passwordUtf8, retStatus );	
 11032 	return retStatus;
 11261 	return retStatus;
 11033 	} // eap_am_type_tls_peap_symbian_c::CompleteQueryTtlsPapUserNameAndPassword(
 11262 } // eap_am_type_tls_peap_symbian_c::CompleteQueryTtlsPapUserNameAndPassword(
 11034 
 11263 
 11035 
 11264 
 11036 // ------------------------------------------------------------------------
 11265 // ------------------------------------------------------------------------
 11037 // eap_am_type_tls_peap_symbian_c::ConvertAmErrorToEapolError()
 11266 // eap_am_type_tls_peap_symbian_c::ConvertAmErrorToEapolError()
 11038 // ------------------------------------------------------------------------
 11267 // ------------------------------------------------------------------------
 11039 //    
 11268 //    
 11040 eap_status_e
 11269 eap_status_e
 11041 eap_am_type_tls_peap_symbian_c::ConvertAmErrorToEapolError( TInt aErr )
 11270 eap_am_type_tls_peap_symbian_c::ConvertAmErrorToEapolError( TInt aErr )
 11042 	{
 11271 {
 11043 	DEBUG( "eap_am_type_tls_peap_symbian_c::ConvertAmErrorToEapolError()" );
 11272 	EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::ConvertAmErrorToEapolError()" )));
 11044     if ( m_am_tools )
 11273     if ( m_am_tools )
 11045     	{
 11274     	{
 11046     	return m_am_tools->convert_am_error_to_eapol_error( aErr );
 11275     	return m_am_tools->convert_am_error_to_eapol_error( aErr );
 11047     	}
 11276     	}
 11048 	return eap_status_process_general_error;
 11277 	return eap_status_process_general_error;
 11049 	}
 11278 }
 11050 
 11279 
 11051 
 11280 
 11052 // ------------------------------------------------------------------------
 11281 // ------------------------------------------------------------------------
 11053 // eap_am_type_tls_peap_symbian_c::ReadTtlsPapDbL()
 11282 // eap_am_type_tls_peap_symbian_c::ReadTtlsPapDbL()
 11054 // ------------------------------------------------------------------------
 11283 // ------------------------------------------------------------------------
 11058 //| EAP_TLS_PEAP_ttls_pap_password                      | VARCHAR(128)      | cf_str_EAP_TLS_PEAP_ttls_pap_password_literal                  |//
 11287 //| EAP_TLS_PEAP_ttls_pap_password                      | VARCHAR(128)      | cf_str_EAP_TLS_PEAP_ttls_pap_password_literal                  |//
 11059 //| EAP_TLS_PEAP_ttls_pap_max_session_validity_time		| BIGINT		   	| cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time_literal |//
 11288 //| EAP_TLS_PEAP_ttls_pap_max_session_validity_time		| BIGINT		   	| cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time_literal |//
 11060 //| EAP_TLS_PEAP_ttls_pap_last_full_authentication_time	| BIGINT		   	| KTTLSPAPLastFullAuthTime	                             |//
 11289 //| EAP_TLS_PEAP_ttls_pap_last_full_authentication_time	| BIGINT		   	| KTTLSPAPLastFullAuthTime	                             |//
 11061 void eap_am_type_tls_peap_symbian_c::ReadTtlsPapDbL(
 11290 void eap_am_type_tls_peap_symbian_c::ReadTtlsPapDbL(
 11062 	TTtlsPapDbInfo& aOutDbInfo )
 11291 	TTtlsPapDbInfo& aOutDbInfo )
 11063 	{
 11292 {
 11064 	DEBUG( "eap_am_type_tls_peap_symbian_c::ReadTtlsPapDbL()" );
 11293 	EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::ReadTtlsPapDbL()" )));
 11065 	
 11294 	
 11066 	HBufC* buf = HBufC::NewLC( KMaxSqlQueryLength );
 11295 	HBufC* buf = HBufC::NewLC( KMaxSqlQueryLength );
 11067 	TPtr sqlStatement = buf->Des();
 11296 	TPtr sqlStatement = buf->Des();
 11068 	
 11297 	
 11069 	// Query all the relevant parameters
 11298 	// Query all the relevant parameters
 11114 			CleanupStack::PopAndDestroy( colSet ); // Delete colSet.
 11343 			CleanupStack::PopAndDestroy( colSet ); // Delete colSet.
 11115 	}
 11344 	}
 11116 	CleanupStack::PopAndDestroy( &view ); // Close view.
 11345 	CleanupStack::PopAndDestroy( &view ); // Close view.
 11117 	CleanupStack::PopAndDestroy( buf ); // Delete buf.
 11346 	CleanupStack::PopAndDestroy( buf ); // Delete buf.
 11118 	
 11347 	
 11119 	} // eap_am_type_tls_peap_symbian_c::ReadTtlsPapDbL()
 11348 } // eap_am_type_tls_peap_symbian_c::ReadTtlsPapDbL()
 11120 
 11349 
 11121 
 11350 
 11122 // ------------------------------------------------------------------------
 11351 // ------------------------------------------------------------------------
 11123 // eap_am_type_tls_peap_symbian_c::WriteTtlsPapDbL()
 11352 // eap_am_type_tls_peap_symbian_c::WriteTtlsPapDbL()
 11124 // ------------------------------------------------------------------------
 11353 // ------------------------------------------------------------------------
 11128 //| EAP_TLS_PEAP_ttls_pap_password                      | VARCHAR(128)      | cf_str_EAP_TLS_PEAP_ttls_pap_password_literal                  |//
 11357 //| EAP_TLS_PEAP_ttls_pap_password                      | VARCHAR(128)      | cf_str_EAP_TLS_PEAP_ttls_pap_password_literal                  |//
 11129 //| EAP_TLS_PEAP_ttls_pap_max_session_validity_time		| BIGINT		   	| cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time_literal |//
 11358 //| EAP_TLS_PEAP_ttls_pap_max_session_validity_time		| BIGINT		   	| cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time_literal |//
 11130 //| EAP_TLS_PEAP_ttls_pap_last_full_authentication_time	| BIGINT		   	| KTTLSPAPLastFullAuthTime	                             |//
 11359 //| EAP_TLS_PEAP_ttls_pap_last_full_authentication_time	| BIGINT		   	| KTTLSPAPLastFullAuthTime	                             |//
 11131 void eap_am_type_tls_peap_symbian_c::WriteTtlsPapDbL(
 11360 void eap_am_type_tls_peap_symbian_c::WriteTtlsPapDbL(
 11132 	const TTtlsPapDbInfo& aInDbInfo )
 11361 	const TTtlsPapDbInfo& aInDbInfo )
 11133 	{
 11362 {
 11134 	DEBUG( "eap_am_type_tls_peap_symbian_c::WriteTtlsPapDbL()" );
 11363 	EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::WriteTtlsPapDbL()" )));
 11135 	
 11364 	
 11136 	
 11365 	
 11137 	HBufC* buf = HBufC::NewLC( KMaxSqlQueryLength );
 11366 	HBufC* buf = HBufC::NewLC( KMaxSqlQueryLength );
 11138 	TPtr sqlStatement = buf->Des();
 11367 	TPtr sqlStatement = buf->Des();
 11139 	
 11368 	
 11140 	// Query all the relevant parameters
 11369 	// Query all the relevant parameters
 11141 	_LIT( KSQLQuery,
 11370 	_LIT( KSQLQuery,
 11142 		"SELECT %S, %S, %S, %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d" );
 11371 		"SELECT %S, %S, %S, %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d" );
 11143 	sqlStatement.Format( KSQLQuery,
 11372 
       
 11373 	sqlStatement.Format(
       
 11374 		KSQLQuery,
 11144 		&cf_str_EAP_TLS_PEAP_ttls_pap_password_prompt_literal,           // select´
 11375 		&cf_str_EAP_TLS_PEAP_ttls_pap_password_prompt_literal,           // select´
 11145 		&cf_str_EAP_TLS_PEAP_ttls_pap_username_literal,                  // select
 11376 		&cf_str_EAP_TLS_PEAP_ttls_pap_username_literal,                  // select
 11146 		&cf_str_EAP_TLS_PEAP_ttls_pap_password_literal,                  // select
 11377 		&cf_str_EAP_TLS_PEAP_ttls_pap_password_literal,                  // select
 11147 		&cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time_literal, // select
 11378 		&cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time_literal, // select
 11148 		&KTTLSPAPLastFullAuthTime,                                       // select
 11379 		&KTTLSPAPLastFullAuthTime,                                       // select
 11149 		&KTtlsDatabaseTableName,                                         // from
 11380 		&KTtlsDatabaseTableName,                                         // from
 11150 		&KServiceType, m_index_type,                                     // where %S=%d
 11381 		&KServiceType,
 11151 		&KServiceIndex, m_index,                                         // where %S=%d
 11382 		m_index_type,
 11152 		&KTunnelingType, m_tunneling_vendor_type );                      // where %S=%d
 11383 		&KServiceIndex,
       
 11384 		m_index,
       
 11385 		&KTunnelingTypeVendorId,
       
 11386 		m_tunneling_type.get_vendor_id(),
       
 11387 		&KTunnelingType,
       
 11388 		m_tunneling_type.get_vendor_type());
 11153 	
 11389 	
 11154 	RDbView view;
 11390 	RDbView view;
 11155 	// Evaluate view
 11391 	// Evaluate view
 11156 	User::LeaveIfError( view.Prepare( m_database, TDbQuery( sqlStatement ) ) );
 11392 	User::LeaveIfError( view.Prepare( m_database, TDbQuery( sqlStatement ) ) );
 11157 	CleanupClosePushL( view );
 11393 	CleanupClosePushL( view );
 11193 	}
 11429 	}
 11194 	
 11430 	
 11195 	CleanupStack::PopAndDestroy( &view ); // Close view.
 11431 	CleanupStack::PopAndDestroy( &view ); // Close view.
 11196 	CleanupStack::PopAndDestroy( buf ); // Delete buf.
 11432 	CleanupStack::PopAndDestroy( buf ); // Delete buf.
 11197 	
 11433 	
 11198 	} // eap_am_type_tls_peap_symbian_c::WriteTtlsPapDbL()
 11434 } // eap_am_type_tls_peap_symbian_c::WriteTtlsPapDbL()
 11199 
 11435 
 11200 
 11436 
 11201 // ------------------------------------------------------------------------
 11437 // ------------------------------------------------------------------------
 11202 // eap_am_type_tls_peap_symbian_c::SetTtlsPapColumnToNullL
 11438 // eap_am_type_tls_peap_symbian_c::SetTtlsPapColumnToNullL
 11203 // ------------------------------------------------------------------------
 11439 // ------------------------------------------------------------------------
 11204 //
 11440 //
 11205 void eap_am_type_tls_peap_symbian_c::SetTtlsPapColumnToNullL( const TDesC& aColName )
 11441 void eap_am_type_tls_peap_symbian_c::SetTtlsPapColumnToNullL( const TDesC& aColName )
 11206 	{
 11442 {
 11207 	DEBUG( "eap_am_type_tls_peap_symbian_c::SetColumnNullL()" );
 11443 	EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::SetColumnNullL()" )));
 11208 
 11444 
 11209 	HBufC* buf = HBufC::NewLC( KMaxSqlQueryLength );
 11445 	HBufC* buf = HBufC::NewLC( KMaxSqlQueryLength );
 11210 	TPtr sqlStatement = buf->Des();
 11446 	TPtr sqlStatement = buf->Des();
 11211 	
 11447 	
 11212 	// Query all the relevant parameters
 11448 	// Query all the relevant parameters
 11213 	_LIT( KSQLQuery,
 11449 	_LIT( KSQLQuery,
 11214 		"SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d" );
 11450 		"SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d" );
 11215 	sqlStatement.Format( KSQLQuery,
 11451 
       
 11452 	sqlStatement.Format(
       
 11453 		KSQLQuery,
 11216 		&aColName,                                  // select´
 11454 		&aColName,                                  // select´
 11217 		&KTtlsDatabaseTableName,                    // from
 11455 		&KTtlsDatabaseTableName,                    // from
 11218 		&KServiceType, m_index_type,                // where %S=%d
 11456 		&KServiceType,
 11219 		&KServiceIndex, m_index,                    // where %S=%d
 11457 		m_index_type,
 11220 		&KTunnelingType, m_tunneling_vendor_type ); // where %S=%d
 11458 		&KServiceIndex,
       
 11459 		m_index,
       
 11460 		&KTunnelingTypeVendorId,
       
 11461 		m_tunneling_type.get_vendor_id(),
       
 11462 		&KTunnelingType,
       
 11463 		m_tunneling_type.get_vendor_type());
 11221 	
 11464 	
 11222 	RDbView view;
 11465 	RDbView view;
 11223 	// Evaluate view
 11466 	// Evaluate view
 11224 	User::LeaveIfError( view.Prepare( m_database, TDbQuery( sqlStatement ) ) );
 11467 	User::LeaveIfError( view.Prepare( m_database, TDbQuery( sqlStatement ) ) );
 11225 	CleanupClosePushL( view );
 11468 	CleanupClosePushL( view );
 11243 	}
 11486 	}
 11244 	
 11487 	
 11245 	CleanupStack::PopAndDestroy( &view ); // Close view.
 11488 	CleanupStack::PopAndDestroy( &view ); // Close view.
 11246 	CleanupStack::PopAndDestroy( buf ); // Delete buf.
 11489 	CleanupStack::PopAndDestroy( buf ); // Delete buf.
 11247 	
 11490 	
 11248 	} // eap_am_type_tls_peap_symbian_c::SetTtlsPapColumnToNullL()
 11491 } // eap_am_type_tls_peap_symbian_c::SetTtlsPapColumnToNullL()
 11249 
 11492 
 11250 
 11493 
 11251 // ================= TTLS-PAP private =======================
 11494 // ================= TTLS-PAP private =======================
 11252 
 11495 
 11253 // ------------------------------------------------------------------------
 11496 // ------------------------------------------------------------------------
 11254 // eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL()
 11497 // eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL()
 11255 // ------------------------------------------------------------------------
 11498 // ------------------------------------------------------------------------
 11256 //
 11499 //
 11257 TBool eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL()
 11500 TBool eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL()
 11258 	{
 11501 {
 11259 	DEBUG( "eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL()" );
 11502 	EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL()" )));
 11260 
 11503 
 11261 	TTtlsPapDbInfo dbInfo;
 11504 	TTtlsPapDbInfo dbInfo;
 11262 	TInt err = KErrNone;
 11505 	TInt err = KErrNone;
 11263 	TBool retValue = EFalse;
 11506 	TBool retValue = EFalse;
 11264 	
 11507 	
 11265 	TRAP( err, ReadTtlsPapDbL( dbInfo ) );
 11508 	TRAP( err, ReadTtlsPapDbL( dbInfo ) );
 11266 	
 11509 	
 11267     if 	( err != KErrNone )
 11510     if 	( err != KErrNone )
 11268         {
 11511         {
 11269         DEBUG1( "eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL() ERROR: \
 11512         EAP_TRACE_DEBUG_SYMBIAN((_L("ERROR: eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL(): Leave happened, err=%d."), err ));
 11270         	Leave happened, err=%d.", err );
       
 11271         retValue = EFalse;
 11513         retValue = EFalse;
 11272         }
 11514         }
 11273     else
 11515     else
 11274     	{
 11516     	{
 11275 	    if ( dbInfo.iUsrPwdInfo.iPasswordPromptEnabled )
 11517 	    if ( dbInfo.iUsrPwdInfo.iPasswordPromptEnabled )
 11276 		    {
 11518 		    {
 11277 			// If the max session time from DB is zero then we use the 
 11519 			// If the max session time from DB is zero then we use the 
 11278 			// one read from configuration file.
 11520 			// one read from configuration file.
 11279 		    if( dbInfo.iMaxSessionTime == 0 )
 11521 		    if( dbInfo.iMaxSessionTime == 0 )
 11280 	            {
 11522 	            {
 11281 	            DEBUG( "eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL() \
 11523 	            EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL() Using max TTLS PAP session validity time from config file." )));
 11282 	                	Using max TTLS PAP session validity time from config file." );
       
 11283 			
 11524 			
 11284 				// use value from config file
 11525 				// use value from config file
 11285 				dbInfo.iMaxSessionTime = iEapTtlsPapMaxSessionConfigTime;
 11526 				dbInfo.iMaxSessionTime = iEapTtlsPapMaxSessionConfigTime;
 11286 			    }
 11527 			    }
 11287 
 11528 
 11288 		    retValue = CheckTtlsPapSessionValidity( dbInfo.iMaxSessionTime,
 11529 		    retValue = CheckTtlsPapSessionValidity( dbInfo.iMaxSessionTime,
 11289 		    	dbInfo.iLastFullAuthTime );
 11530 		    	dbInfo.iLastFullAuthTime );
 11290 		    }
 11531 		    }
 11291     	}	
 11532     	}	
 11292 	return retValue;
 11533 	return retValue;
 11293 	}  // eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL()
 11534 }  // eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL()
 11294 
 11535 
 11295 
 11536 
 11296 // ------------------------------------------------------------------------
 11537 // ------------------------------------------------------------------------
 11297 // eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity()
 11538 // eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity()
 11298 // ------------------------------------------------------------------------
 11539 // ------------------------------------------------------------------------
 11299 //
 11540 //
 11300 TBool eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity(
 11541 TBool eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity(
 11301 	const TInt64& aInMaxSessionTime,
 11542 	const TInt64& aInMaxSessionTime,
 11302 	const TInt64& aInLastFullAuthTime )
 11543 	const TInt64& aInLastFullAuthTime )
 11303 	{
 11544 {
 11304 	DEBUG( "eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity()" );
 11545 	EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity()" )));
 11305 	
 11546 	
 11306 	// Get the current time.
 11547 	// Get the current time.
 11307 	TTime currentTime;
 11548 	TTime currentTime;
 11308 	currentTime.UniversalTime();
 11549 	currentTime.UniversalTime();
 11309 	
 11550 	
 11369 			( EAPL( "eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity - Session NOT Valid \n" ) ) );
 11610 			( EAPL( "eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity - Session NOT Valid \n" ) ) );
 11370 		EAP_TRACE_END( m_am_tools, TRACE_FLAGS_DEFAULT );			
 11611 		EAP_TRACE_END( m_am_tools, TRACE_FLAGS_DEFAULT );			
 11371 		
 11612 		
 11372 		return EFalse;	
 11613 		return EFalse;	
 11373 	    }
 11614 	    }
 11374 	} // eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity
 11615 } // eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity
 11375 
 11616 
       
 11617 //--------------------------------------------------
       
 11618 #if defined(USE_FAST_EAP_TYPE)
       
 11619 
       
 11620 TInt eap_am_type_tls_peap_symbian_c::CreateMMETelConnectionL()
       
 11621 {
       
 11622     EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
 11623     EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Creating MMETel connection.\n")));
       
 11624 
       
 11625     TInt errorCode = KErrNone;
       
 11626     
       
 11627     // MMETel need to be connected only once.    
       
 11628     if( !iMMETELConnectionStatus )
       
 11629     {
       
 11630         RTelServer::TPhoneInfo phoneInfo;
       
 11631         TInt phoneCount = 0;
       
 11632 
       
 11633         // Connect to ETel server
       
 11634         User::LeaveIfError( iServer.Connect() );    
       
 11635         
       
 11636         EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Connected to ETel server.\n")));    
       
 11637 
       
 11638         // This function loads an ETel TSY module, mmtsy.
       
 11639         errorCode = iServer.LoadPhoneModule( KMmTsyModuleName );    
       
 11640         
       
 11641         EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Loaded phone module.\n")));     
       
 11642         
       
 11643         if ( errorCode != KErrNone && errorCode != KErrAlreadyExists )
       
 11644         {
       
 11645             User::Leave( errorCode );
       
 11646         }
       
 11647 
       
 11648         iServer.SetExtendedErrorGranularity( RTelServer::EErrorExtended );
       
 11649 
       
 11650         // This function retrieves the total number of phones supported by all 
       
 11651         // the currently loaded ETel (TSY) modules.
       
 11652         User::LeaveIfError( iServer.EnumeratePhones( phoneCount ) );    
       
 11653         
       
 11654         EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Number of phones supported by the loaded ETel = %d.\n"), phoneCount));
       
 11655         
       
 11656         // This function retrieves information associated with the specified phone
       
 11657         while ( ( phoneCount-- ) && ( phoneInfo.iName != KMmTsyPhoneName ) ) 
       
 11658         { 
       
 11659             User::LeaveIfError( iServer.GetPhoneInfo( phoneCount, phoneInfo ) );        
       
 11660             
       
 11661             EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Got phone info.\n")));
       
 11662         } 
       
 11663 
       
 11664         // This function opens a phone subsession by name. ("DefaultPhone").
       
 11665         User::LeaveIfError( iPhone.Open( iServer, phoneInfo.iName ) );  
       
 11666         
       
 11667         EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Opened phone subsession.\n")));
       
 11668         
       
 11669         // MMETel connected and the phone module loaded fine.   
       
 11670         iMMETELConnectionStatus = ETrue;    
       
 11671     }
       
 11672     else
       
 11673     {
       
 11674         // MMETel already connected.
       
 11675         EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("MMETel connected once already.\n")));
       
 11676     }
       
 11677         
       
 11678     EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
 11679     
       
 11680     return errorCode;   
       
 11681 }
       
 11682 
       
 11683 //--------------------------------------------------
       
 11684 
       
 11685 void eap_am_type_tls_peap_symbian_c::DisconnectMMETel()
       
 11686 {
       
 11687     if( iMMETELConnectionStatus )
       
 11688     {
       
 11689         EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Closing RMobilePhone and MMETEL.\n")));
       
 11690         
       
 11691         iPhone.Close();
       
 11692         iServer.Close(); // Phone module is unloaded automatically when RTelServer session is closed
       
 11693         
       
 11694         iMMETELConnectionStatus = EFalse;
       
 11695     }
       
 11696     else
       
 11697     {
       
 11698         EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("RMobilePhone and MMETEL already closed.\n")));      
       
 11699     }   
       
 11700 }
       
 11701 #endif
       
 11702 //--------------------------------------------------
 11376 
 11703 
 11377 // End of file.
 11704 // End of file.