eapol/eapol_framework/eapol_symbian/am/type/tls_peap/symbian/eap_am_type_tls_peap_symbian.cpp
branchRCL_3
changeset 46 c74b3d9f6b9e
parent 45 bad0cc58d154
equal deleted inserted replaced
45:bad0cc58d154 46:c74b3d9f6b9e
    14 * Description:  EAP and WLAN authentication protocols.
    14 * Description:  EAP and WLAN authentication protocols.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: 256 %
    19 * %version: 253 %
    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 "EapTraceSymbian.h"
    56 #include "eap_am_trace_symbian.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 #include <utf.h>
    68 
    69 
    69 #include "eap_ttls_pap_active.h"
    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
    76 #include "eap_header_string.h"
    77 #include "eap_header_string.h"
       
    78 #endif //#ifdef USE_EAP_EXPANDED_TYPES
    77 
    79 
    78 #if defined(USE_EAP_CONFIGURATION_TO_SKIP_USER_INTERACTIONS)
    80 #if defined(USE_EAP_CONFIGURATION_TO_SKIP_USER_INTERACTIONS)
    79 	#include "eap_config.h"
    81 #include "eap_config.h"
    80 	#include "eap_file_config.h"
    82 #include "eap_file_config.h"
    81 	#include "eap_am_file_input_symbian.h"
    83 #include "eap_am_file_input_symbian.h"
    82 #endif
    84 #endif
    83 
       
    84 #include "EapConfigToolsSymbian.h"
       
    85 #include "EapConversion.h"
       
    86 #include "EapPluginTools.h"
       
    87 
       
    88 #include <mmtsy_names.h>
       
    89 
       
    90 
    85 
    91 const TUint KMaxSqlQueryLength = 512;
    86 const TUint KMaxSqlQueryLength = 512;
    92 const TUint KMaxDBFieldNameLength = 255;
    87 const TUint KMaxDBFieldNameLength = 255;
    93 const TUint KDSASignatureLength = 40;
    88 const TUint KDSASignatureLength = 40;
    94 const TInt 	KDefaultColumnInView_One = 1; // For DB view.
    89 const TInt 	KDefaultColumnInView_One = 1; // For DB view.
    95 const TInt 	KMicroSecsInASecond = 1000000; // 1000000 micro seconds is 1 second.
    90 const TInt 	KMicroSecsInASecond = 1000000; // 1000000 micro seconds is 1 second.
    96 
    91 		
    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	
       
   104 /**
    92 /**
   105  * Length of the MAC address
    93  * Length of the MAC address
   106  */
    94  */
   107 #ifdef USE_FAST_EAP_TYPE
    95 #ifdef USE_FAST_EAP_TYPE
   108 	const TUint8 KMacAddressLength = 6;
    96  const TUint8 KMacAddressLength = 6;
   109 #endif
    97 #endif
   110 
       
   111 //--------------------------------------------------
    98 //--------------------------------------------------
   112 
    99 
   113 eap_am_type_tls_peap_symbian_c::eap_am_type_tls_peap_symbian_c(
   100 eap_am_type_tls_peap_symbian_c::eap_am_type_tls_peap_symbian_c(
   114 	abs_eap_am_tools_c * const aTools,
   101 	abs_eap_am_tools_c * const aTools,
   115 	abs_eap_base_type_c * const aPartner,
   102 	abs_eap_base_type_c * const aPartner,
   127 	  , m_am_tools(static_cast<eap_am_tools_symbian_c*> (aTools))
   114 	  , m_am_tools(static_cast<eap_am_tools_symbian_c*> (aTools))
   128 	  , m_tls_am_partner(0)
   115 	  , m_tls_am_partner(0)
   129 #if defined(USE_FAST_EAP_TYPE)
   116 #if defined(USE_FAST_EAP_TYPE)
   130 	  , m_tls_application(0)
   117 	  , m_tls_application(0)
   131 	  //, iWaitNoteCancelled( EFalse )
   118 	  //, iWaitNoteCancelled( EFalse )
   132 
   119       , iEapFastActiveWaitNote( NULL )
       
   120       , iEapFastActiveNotes( NULL )
   133 #endif //#if defined(USE_FAST_EAP_TYPE)
   121 #endif //#if defined(USE_FAST_EAP_TYPE)
   134 	  , m_is_valid(false)
   122 	  , m_is_valid(false)
   135 	  , m_is_client(aIsClient)
   123 	  , m_is_client(aIsClient)
   136 	  , m_current_eap_type(aEapType)
   124 	  , m_current_eap_type(aEapType)
   137 	  , m_max_count_of_session_resumes(0ul)
   125 	  , m_max_count_of_session_resumes(0ul)
   148 	  , m_peer_public_key(aTools)
   136 	  , m_peer_public_key(aTools)
   149 	  , m_param_p(aTools)
   137 	  , m_param_p(aTools)
   150 	  , m_param_q(aTools)
   138 	  , m_param_q(aTools)
   151 	  , m_param_g(aTools)
   139 	  , m_param_g(aTools)
   152 	  , m_shutdown_was_called(false)
   140 	  , m_shutdown_was_called(false)
   153 
   141 	  , m_identity_info(0)
   154 	  , m_tunneled_type(eap_type_none)
   142 	  , m_tunneled_type(eap_type_none)
   155 	  , m_verify_certificate_realm(true)
   143 	  , m_verify_certificate_realm(true)
   156 	  , m_allow_subdomain_matching(false)
   144 	  , m_allow_subdomain_matching(false)
   157 	  , m_latest_alert_description(tls_alert_description_none)
   145 	  , m_latest_alert_description(tls_alert_description_none)
   158 	  , m_use_manual_username(false)
   146 	  , m_use_manual_username(false)
   159 	  , m_manual_username(aTools)
   147 	  , m_manual_username(aTools)
   160 	  , m_use_manual_realm(false)
   148 	  , m_use_manual_realm(false)
   161 	  , m_manual_realm(aTools)
   149 	  , m_manual_realm(aTools)
   162 	  , m_tls_peap_server_authenticates_client_policy_flag(true)
   150 	  , m_tls_peap_server_authenticates_client_policy_flag(true)
   163 	  , m_use_automatic_ca_certificate(false)
       
   164 	  , m_configured(false)
   151 	  , m_configured(false)
   165 	  , m_max_session_time(0)
   152 	  , m_max_session_time(0)
   166 #if defined(USE_EAP_TLS_SESSION_TICKET)
   153 #if defined(USE_EAP_TLS_SESSION_TICKET)
   167 	  , m_use_session_ticket(false)
   154 	  , m_use_session_ticket(false)
   168 #endif //#if defined(USE_EAP_TLS_SESSION_TICKET)
   155 #endif //#if defined(USE_EAP_TLS_SESSION_TICKET)
   187 	, m_references_and_data_blocks(aTools)
   174 	, m_references_and_data_blocks(aTools)
   188 	, m_new_references_and_data_blocks(aTools)
   175 	, m_new_references_and_data_blocks(aTools)
   189 	, m_ready_references_and_data_blocks(aTools)
   176 	, m_ready_references_and_data_blocks(aTools)
   190 	, m_serv_unauth_prov_mode(false)
   177 	, m_serv_unauth_prov_mode(false)
   191 	, m_serv_auth_prov_mode(false)
   178 	, m_serv_auth_prov_mode(false)
   192 
   179 	, m_is_notifier_connected(false)
   193 	, m_notifier_data_to_user(NULL)
   180 	, m_notifier_data_to_user(NULL)
   194 	, m_notifier_data_pckg_to_user(NULL)
   181 	, m_notifier_data_pckg_to_user(NULL)
   195 
   182 	, m_notifier_data_from_user(NULL)
   196 	, iMMETELConnectionStatus(false)
   183 	, m_notifier_data_pckg_from_user(NULL)
   197 	, m_completed_with_zero(false)
   184 	, m_completed_with_zero(false)
   198 	, m_verificationStatus(false)
   185 	, m_verificationStatus(false)
   199 	, m_pacStorePWBuf8(0)
       
   200 	, m_userAction(EEapFastNotifierUserActionOk)
       
   201 	, m_pacStoreDataRefType(eap_pac_store_data_type_none)
       
   202 	, m_data_reference(m_am_tools)
   186 	, m_data_reference(m_am_tools)
       
   187 	, m_notifier_complete(false)
   203 	, m_userResponse(m_am_tools)
   188 	, m_userResponse(m_am_tools)
   204 	, m_pending_operation(eap_fast_pac_store_pending_operation_none)
       
   205 	, m_both_completed(0)
   189 	, m_both_completed(0)
   206 	, m_both_asked(0)
   190 	, 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)
       
   211 #endif //#if defined(USE_FAST_EAP_TYPE)
   191 #endif //#if defined(USE_FAST_EAP_TYPE)
   212 
       
   213 	, m_notifier_complete(false)
       
   214 
   192 
   215 #ifdef USE_PAC_STORE
   193 #ifdef USE_PAC_STORE
   216 	,iPacStoreDb(NULL)
   194 	,iPacStoreDb(NULL)
   217 #endif    
   195 #endif    
   218 	
   196 	
   219 #ifdef USE_EAP_CONFIGURATION_TO_SKIP_USER_INTERACTIONS
   197 #ifdef USE_EAP_CONFIGURATION_TO_SKIP_USER_INTERACTIONS
   220 	, m_skip_user_interactions(false)
   198 , m_skip_user_interactions(false)
   221 	, m_fileconfig(0)
   199 , m_fileconfig(0)
   222 #endif
   200 #endif
   223 
   201 	
   224   , iEapTtlsPapMaxSessionConfigTime( 0 )
   202 	
   225 
   203 	
   226 
   204     , iEapTtlsPapMaxSessionConfigTime( 0 )
   227 
   205     , iEapTtlsPapActive( NULL )
   228   , iPacStoreDeviceSeed(0)
   206     
   229 
       
   230 	, iEapAuthNotifier(0)	
       
   231 
       
   232 {
   207 {
   233 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   208 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   234 
   209 
       
   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 
   235 	// Set the database table name based on the type
   222 	// Set the database table name based on the type
   236 	if (m_current_eap_type == eap_type_tls)
   223 	switch (m_current_eap_vendor_type)
   237 	{
   224 	{
   238 		m_db_table_name = KTlsDatabaseTableName;
   225 		case eap_type_tls:
   239 		m_db_user_cert_table_name = KTlsAllowedUserCertsDatabaseTableName;
   226 			m_db_table_name = KTlsDatabaseTableName;
   240 		m_db_ca_cert_table_name = KTlsAllowedCACertsDatabaseTableName;
   227 			m_db_user_cert_table_name = KTlsAllowedUserCertsDatabaseTableName;
   241 		m_db_cipher_suite_table_name = KTlsAllowedCipherSuitesDatabaseTableName;
   228 			m_db_ca_cert_table_name = KTlsAllowedCACertsDatabaseTableName;
   242 		m_db_name = KTlsDatabaseName;	
   229 			m_db_cipher_suite_table_name = KTlsAllowedCipherSuitesDatabaseTableName;
   243 	}
   230 			m_db_name = KTlsDatabaseName;	
   244 	else if (m_current_eap_type == eap_type_peap)
   231 			break;
   245 	{
   232 		
   246 		m_db_table_name = KPeapDatabaseTableName;
   233 		case eap_type_peap:
   247 		m_db_user_cert_table_name = KPeapAllowedUserCertsDatabaseTableName;
   234 			m_db_table_name = KPeapDatabaseTableName;
   248 		m_db_ca_cert_table_name = KPeapAllowedCACertsDatabaseTableName;
   235 			m_db_user_cert_table_name = KPeapAllowedUserCertsDatabaseTableName;
   249 		m_db_cipher_suite_table_name = KPeapAllowedCipherSuitesDatabaseTableName;
   236 			m_db_ca_cert_table_name = KPeapAllowedCACertsDatabaseTableName;
   250 		m_db_name = KPeapDatabaseName;	
   237 			m_db_cipher_suite_table_name = KPeapAllowedCipherSuitesDatabaseTableName;
   251 	}
   238 			m_db_name = KPeapDatabaseName;	
   252 	else if (m_current_eap_type == eap_expanded_type_ttls_plain_pap.get_type()
   239 			break;
   253 			|| m_current_eap_type == eap_type_ttls)
   240 			
   254 	{
   241 		case eap_type_ttls_plain_pap:
   255 		m_db_table_name = KTtlsDatabaseTableName;
   242 		    // use the same case as for eap_type_ttls;
   256 		m_db_user_cert_table_name = KTtlsAllowedUserCertsDatabaseTableName;
   243 		    // break is not needed
   257 		m_db_ca_cert_table_name = KTtlsAllowedCACertsDatabaseTableName;
   244 		
   258 		m_db_cipher_suite_table_name = KTtlsAllowedCipherSuitesDatabaseTableName;
   245 		case eap_type_ttls:
   259 		m_db_name = KTtlsDatabaseName;
   246 			m_db_table_name = KTtlsDatabaseTableName;
   260 	}
   247 			m_db_user_cert_table_name = KTtlsAllowedUserCertsDatabaseTableName;
       
   248 			m_db_ca_cert_table_name = KTtlsAllowedCACertsDatabaseTableName;
       
   249 			m_db_cipher_suite_table_name = KTtlsAllowedCipherSuitesDatabaseTableName;
       
   250 			m_db_name = KTtlsDatabaseName;
       
   251 			break;
   261 			
   252 			
   262 #if defined (USE_FAST_EAP_TYPE)
   253 #if defined (USE_FAST_EAP_TYPE)
   263 	else if (m_current_eap_type == eap_type_fast)
   254 			case eap_type_fast:
   264 	{
   255 			m_db_table_name = KFastGeneralSettingsDBTableName; // General settings
   265 		m_db_table_name = KFastGeneralSettingsDBTableName; // General settings
   256 			m_db_fast_special_table_name = KFastSpecialSettingsDBTableName; // Special settings  for only FAST
   266 		m_db_fast_special_table_name = KFastSpecialSettingsDBTableName; // Special settings  for only FAST
   257 			m_db_user_cert_table_name = KFastAllowedUserCertsDatabaseTableName;
   267 		m_db_user_cert_table_name = KFastAllowedUserCertsDatabaseTableName;
   258 			m_db_ca_cert_table_name = KFastAllowedCACertsDatabaseTableName;
   268 		m_db_ca_cert_table_name = KFastAllowedCACertsDatabaseTableName;
   259 			m_db_cipher_suite_table_name = KFastAllowedCipherSuitesDatabaseTableName;
   269 		m_db_cipher_suite_table_name = KFastAllowedCipherSuitesDatabaseTableName;
   260 			m_db_name = KFastDatabaseName;
   270 		m_db_name = KFastDatabaseName;
   261 			break;
   271 	}
       
   272 #endif // #if defined (USE_FAST_EAP_TYPE)			
   262 #endif // #if defined (USE_FAST_EAP_TYPE)			
   273 	else
   263 		default:
   274 	{
   264 			{
   275 		// Unsupported type		
   265 				// Unsupported type		
   276 		// Should never happen
   266 				// Should never happen
   277 		EAP_TRACE_ERROR(m_am_tools, 
   267 				EAP_TRACE_ERROR(m_am_tools, 
   278 			TRACE_FLAGS_DEFAULT,
   268 					TRACE_FLAGS_DEFAULT, (
   279 			(EAPL("Unsupported EAP type, m_current_eap_vendor_type=0xfe%06x%08x\n"),
   269 					EAPL("Unsupported EAP type, m_current_eap_vendor_type=%d \n"),
   280 			m_current_eap_type.get_vendor_id(),
   270 					m_current_eap_vendor_type));
   281 			m_current_eap_type.get_vendor_type()));
   271 		
   282 
   272 				return;
   283 		return;
   273 			}
   284 	}
   274 	}
   285 
   275 
   286 	if (receive_network_id != 0
   276 	if (receive_network_id != 0
   287 		&& receive_network_id->get_is_valid_data() == true)
   277 		&& receive_network_id->get_is_valid_data() == true)
   288 	{
   278 	{
   318 		&& aEapType != eap_type_peap
   308 		&& aEapType != eap_type_peap
   319 #if defined(USE_TTLS_EAP_TYPE)
   309 #if defined(USE_TTLS_EAP_TYPE)
   320 		&& aEapType != eap_type_ttls
   310 		&& aEapType != eap_type_ttls
   321 #endif // #if defined(USE_TTLS_EAP_TYPE)
   311 #endif // #if defined(USE_TTLS_EAP_TYPE)
   322 
   312 
   323 	    && aEapType != eap_expanded_type_ttls_plain_pap.get_type()
   313 	    && aEapType != eap_type_ttls_plain_pap
   324 		
   314 		
   325 #if defined (USE_FAST_EAP_TYPE)
   315 #if defined (USE_FAST_EAP_TYPE)
   326 		&& aEapType != eap_type_fast
   316 		&& aEapType != eap_type_fast
   327 #endif // #if defined (USE_FAST_EAP_TYPE)	
   317 #endif // #if defined (USE_FAST_EAP_TYPE)	
   328 		)
   318 		)
   356 //--------------------------------------------------
   346 //--------------------------------------------------
   357 
   347 
   358 //
   348 //
   359 void eap_am_type_tls_peap_symbian_c::ConstructL()
   349 void eap_am_type_tls_peap_symbian_c::ConstructL()
   360 {
   350 {
   361 	TInt error = m_session.Connect();
       
   362 	EAP_TRACE_DEBUG_SYMBIAN((_L("eap_am_type_tls_peap_symbian_c::ConstructL(): - m_session.Connect(), error=%d\n"), error));
       
   363 	User::LeaveIfError(error);
       
   364 
       
   365 	// Open/create database
   351 	// Open/create database
   366 	EapTlsPeapUtils::OpenDatabaseL(m_database, m_session, m_index_type, m_index, m_tunneling_type, m_current_eap_type);
   352 	EapTlsPeapUtils::OpenDatabaseL(m_database, m_session, m_index_type, m_index, m_tunneling_type, m_current_eap_type);
   367 
   353 
   368 	m_cert_if = CEapTlsPeapCertInterface::NewL(m_am_tools, this);
   354 	m_cert_if = CEapTlsPeapCertInterface::NewL(m_am_tools, this);
   369 
   355 
   384 		iPacStoreDb->OpenPacStoreL();
   370 		iPacStoreDb->OpenPacStoreL();
   385 		
   371 		
   386 		EAP_TRACE_DEBUG_SYMBIAN(
   372 		EAP_TRACE_DEBUG_SYMBIAN(
   387 			(_L("eap_am_type_tls_peap_symbian_c::ConstructL Opened PAC store")));		
   373 			(_L("eap_am_type_tls_peap_symbian_c::ConstructL Opened PAC store")));		
   388 	}
   374 	}
   389 	m_info_array.ResetAndDestroy();
   375 	m_info_array.Reset();
   390 	
   376 	
   391 #endif	// End: #ifdef USE_FAST_EAP_TYPE
   377 #endif	// End: #ifdef USE_FAST_EAP_TYPE
   392 #endif // End: 	#ifdef USE_PAC_STORE
   378 #endif // End: 	#ifdef USE_PAC_STORE
   393 
   379 
   394 	m_notifier_data_to_user = new(ELeave) CEapAuthNotifier::TEapDialogInfo;
   380 #ifdef USE_FAST_EAP_TYPE
   395 	m_notifier_data_pckg_to_user = new(ELeave) TPckg<CEapAuthNotifier::TEapDialogInfo> (*m_notifier_data_to_user);
   381 	
       
   382 	if(m_current_eap_type == eap_type_fast)
       
   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(
       
   388 			m_am_tools,
       
   389 			TRACE_FLAGS_DEFAULT,
       
   390 			(EAPL("eap_am_type_tls_peap_symbian_c::ConstructL m_notifier_data_pckg_to_user"),
       
   391 			m_notifier_data_pckg_to_user->Ptr(),
       
   392 			m_notifier_data_pckg_to_user->Size()));	
       
   393 		
       
   394 		m_notifier_data_from_user = new(ELeave) TEapFastNotifierStruct;
       
   395 		m_notifier_data_pckg_from_user = new(ELeave) TPckg<TEapFastNotifierStruct> (*m_notifier_data_from_user);		
       
   396 	}	
       
   397 #endif	// End: #ifdef USE_FAST_EAP_TYPE	
       
   398 	
   396 
   399 
   397 }
   400 }
   398 
   401 
   399 //--------------------------------------------------
   402 //--------------------------------------------------
   400 
   403 
   419 		if(m_cert_if->IsActive())
   422 		if(m_cert_if->IsActive())
   420 		{
   423 		{
   421 			m_cert_if->Cancel();
   424 			m_cert_if->Cancel();
   422 		}		
   425 		}		
   423 	}
   426 	}
   424 
   427 	
   425 	if (iEapAuthNotifier != 0)
   428 	if ( iEapTtlsPapActive )
   426 		{
   429 		{
   427 		iEapAuthNotifier->Cancel();
   430 		if ( iEapTtlsPapActive->IsActive() )
   428 		}
   431 			{
   429 
   432 			EAP_TRACE_DEBUG_SYMBIAN(
   430 	
   433 				( _L( " eap_am_type_tls_peap_symbian_c::shutdown() \
   431 
   434 				Cancelling iEapTtlsPapActive." ) ) );
   432 	
   435 			iEapTtlsPapActive->Cancel();
   433 #if defined(USE_FAST_EAP_TYPE)
   436 			}
   434 
   437 		EAP_TRACE_DEBUG_SYMBIAN(
   435 
   438 			( _L( " eap_am_type_tls_peap_symbian_c::shutdown() \
   436 
   439 			Deleting iEapTtlsPapActive." ) ) );
   437 #endif 
   440 		delete iEapTtlsPapActive;
       
   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 )	
   438 
   463 
   439 		if (m_partner != NULL)
   464 		if (m_partner != NULL)
   440 		    {
   465 		    {
   441 		    EAP_TRACE_DEBUG_SYMBIAN(
   466 		    EAP_TRACE_DEBUG_SYMBIAN(
   442 				(_L(" eap_am_type_tls_peap_symbian_c::shutdown - Cancel timers ...")));
   467 				(_L(" eap_am_type_tls_peap_symbian_c::shutdown - Cancel timers ...")));
   443 
   468 
   444 #if defined(USE_FAST_EAP_TYPE)
       
   445 		    m_partner->cancel_timer(
   469 		    m_partner->cancel_timer(
   446 				this, 
   470 				this, 
   447 				KRemoveIAPReferenceTimerID);
   471 				KRemoveIAPReferenceTimerID);
   448 
   472 
   449 		    m_partner->cancel_timer(
   473 		    m_partner->cancel_timer(
   456 
   480 
   457 		    m_partner->cancel_timer(
   481 		    m_partner->cancel_timer(
   458 				this, 
   482 				this, 
   459 				KHandleReadPacstoreTimerID);
   483 				KHandleReadPacstoreTimerID);
   460 
   484 
   461 		    m_partner->cancel_timer(
       
   462 				this, 
       
   463 				KHandleCompletePacstoreNokTimerID);
       
   464 
       
   465 		    m_partner->cancel_timer(
       
   466 				this, 
       
   467 				KHandleCompletePacstoreOkTimerID);
       
   468 				
       
   469 #endif
       
   470 		    EAP_TRACE_DEBUG_SYMBIAN(
   485 		    EAP_TRACE_DEBUG_SYMBIAN(
   471 				(_L(" eap_am_type_tls_peap_symbian_c::shutdown - Timers canceled")));
   486 				(_L(" eap_am_type_tls_peap_symbian_c::shutdown - Timers canceled")));
   472 		    }
   487 		    }
   473 		
   488 		
   474 #if defined(USE_FAST_EAP_TYPE)
   489 		if ( iEapFastActiveWaitNote )
   475 
   490 			{
       
   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 			}
   476 #endif // #if defined(USE_FAST_EAP_TYPE)
   508 #endif // #if defined(USE_FAST_EAP_TYPE)
   477 	
   509 	
   478 
   510 
   479 	m_allowed_server_certs.ResetAndDestroy();
   511 	m_allowed_server_certs.Reset();
   480 	m_allowed_ca_certs.ResetAndDestroy();			
   512 	m_allowed_ca_certs.Close();			
   481 	m_allowed_cipher_suites.Close();			
   513 	m_allowed_cipher_suites.Close();			
   482 	m_allowed_user_certs.ResetAndDestroy();			
   514 	m_allowed_user_certs.Reset();			
   483 
   515 
   484 #ifdef USE_PAC_STORE
   516 #ifdef USE_PAC_STORE
   485 #ifdef USE_FAST_EAP_TYPE
   517 #ifdef USE_FAST_EAP_TYPE
   486 	
   518 	
   487 	if(m_current_eap_type == eap_type_fast && iPacStoreDb != NULL)
   519 	if(m_current_eap_type == eap_type_fast && iPacStoreDb != NULL)
   488 	{
   520 	{
   489 		iPacStoreDb->Close();
   521 		iPacStoreDb->Close();
   490 	}
   522 	}
   491 	
   523 	
   492 	m_info_array.ResetAndDestroy();
   524 	TInt count=0;
       
   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();
   493 
   531 
   494 	EAP_TRACE_DEBUG_SYMBIAN(
   532 	EAP_TRACE_DEBUG_SYMBIAN(
   495 			(_L(" eap_am_type_tls_peap_symbian_c::shutdown - Arrays cleared")));
   533 			(_L(" eap_am_type_tls_peap_symbian_c::shutdown - Arrays cleared")));
   496 
   534 
   497 #endif	// End: #ifdef USE_FAST_EAP_TYPE	
   535 #endif	// End: #ifdef USE_FAST_EAP_TYPE	
   511 		 (m_is_client == true ? "client": "server")));
   549 		 (m_is_client == true ? "client": "server")));
   512 
   550 
   513 	return eap_status_ok;
   551 	return eap_status_ok;
   514 }
   552 }
   515 
   553 
       
   554 
   516 //--------------------------------------------------
   555 //--------------------------------------------------
   517 
   556 
   518 EAP_FUNC_EXPORT eap_am_type_tls_peap_symbian_c::~eap_am_type_tls_peap_symbian_c()
   557 EAP_FUNC_EXPORT eap_am_type_tls_peap_symbian_c::~eap_am_type_tls_peap_symbian_c()
   519 {
   558 {
   520 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   559 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   530 	EAP_ASSERT(m_shutdown_was_called == true);	
   569 	EAP_ASSERT(m_shutdown_was_called == true);	
   531 
   570 
   532 	m_database.Close();
   571 	m_database.Close();
   533 	m_session.Close();
   572 	m_session.Close();
   534 
   573 
   535 	delete m_notifier_data_to_user;
   574 #ifdef USE_FAST_EAP_TYPE
   536 	delete m_notifier_data_pckg_to_user;
   575 	
       
   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	
   537 		
   585 		
   538 	delete m_cert_if;
   586 	delete m_cert_if;
   539 
   587 
   540 	delete m_ca_certificate;
   588 	delete m_ca_certificate;
   541 	delete m_own_certificate;
   589 	delete m_own_certificate;
   542 	delete m_peer_certificate;
   590 	delete m_peer_certificate;
       
   591 	delete m_identity_info;
       
   592 
       
   593 #ifdef USE_EAP_EXPANDED_TYPES
   543 
   594 
   544 	m_enabled_tunneling_exp_eap_array.ResetAndDestroy();
   595 	m_enabled_tunneling_exp_eap_array.ResetAndDestroy();
   545 	m_disabled_tunneling_exp_eap_array.ResetAndDestroy();
   596 	m_disabled_tunneling_exp_eap_array.ResetAndDestroy();
   546 
   597 
   547 	EAP_TRACE_DEBUG(
   598 	EAP_TRACE_DEBUG(
   548 			m_am_tools,
   599 			m_am_tools,
   549 			TRACE_FLAGS_DEFAULT,
   600 			TRACE_FLAGS_DEFAULT,
   550 			(EAPL("eap_am_type_tls_peap_symbian_c::~eap_am_type_tls_peap_symbian_c() tunneling done.\n")));
   601 			(EAPL("eap_am_type_tls_peap_symbian_c::~eap_am_type_tls_peap_symbian_c() tunneling done.\n")));
   551 
   602 
       
   603 #else
       
   604 
       
   605 	m_iap_eap_array.ResetAndDestroy();
       
   606 
       
   607 #endif  // #ifdef USE_EAP_EXPANDED_TYPES
       
   608 
   552 #ifdef USE_PAC_STORE
   609 #ifdef USE_PAC_STORE
   553 	
   610 	
   554 	delete iPacStoreDb;
   611 	delete iPacStoreDb;
   555 	
   612 	
   556 #endif // #ifdef USE_PAC_STORE	
   613 #endif	// End: #ifdef USE_PAC_STORE	
   557 
   614 	
   558 	delete iEapAuthNotifier;
       
   559 	iEapAuthNotifier = 0;
       
   560 
       
   561 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   615 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   562 }
   616 }
   563 //--------------------------------------------------
   617 //--------------------------------------------------
   564 
   618 
   565 EAP_FUNC_EXPORT void eap_am_type_tls_peap_symbian_c::DlgComplete( TInt aStatus )
       
   566 {
       
   567 	EAP_TRACE_DEBUG(
       
   568 		m_am_tools,
       
   569 		TRACE_FLAGS_DEFAULT,
       
   570 		(EAPL("TLS: function: eap_am_type_tls_peap_symbian_c::DlgComplete(): m_notifier_complete=%d, m_state=%d\n"),
       
   571 		m_notifier_complete,
       
   572 		m_state));
       
   573 
       
   574 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_type_tls_peap_symbian_c::DlgComplete()");
       
   575 
       
   576 #ifdef USE_FAST_EAP_TYPE
       
   577 	m_userAction = EEapFastNotifierUserActionOk;
       
   578 #endif
       
   579 
       
   580 	eap_status_e status = m_am_tools->convert_am_error_to_eapol_error(aStatus);
       
   581 
       
   582 	if(m_notifier_complete)
       
   583 	{
       
   584 		EAP_TRACE_DATA_DEBUG(
       
   585 			m_am_tools,
       
   586 			TRACE_FLAGS_DEFAULT,
       
   587 			(EAPL( "m_notifier_data_pckg_to_user" ),
       
   588 			m_notifier_data_pckg_to_user->Ptr(),
       
   589 			m_notifier_data_pckg_to_user->Size() ) );
       
   590 
       
   591 		if ( aStatus == KErrCancel )
       
   592 		{
       
   593 			EAP_TRACE_DEBUG(
       
   594 				m_am_tools,
       
   595 				TRACE_FLAGS_DEFAULT,
       
   596 				(EAPL("TLS: function: eap_am_type_tls_peap_symbian_c::DlgComplete(): User cancelled the dialog\n")));
       
   597 
       
   598 #ifdef USE_FAST_EAP_TYPE
       
   599 			m_userAction = EEapFastNotifierUserActionCancel;	
       
   600 #endif
       
   601 		}		
       
   602 		else if( aStatus != KErrNone )
       
   603 		{
       
   604 			EAP_TRACE_DEBUG(
       
   605 				m_am_tools,
       
   606 				TRACE_FLAGS_DEFAULT,
       
   607 				(EAPL("ERROR: TLS: function: eap_am_type_tls_peap_symbian_c::DlgComplete(): dialog error=%d\n"),
       
   608 				aStatus));
       
   609 
       
   610 			TBuf8<KMaxNotifItemLength> userNameUtf8;
       
   611 			TBuf8<KMaxUiDataLength> challengeUtf8;
       
   612 			userNameUtf8.Zero();
       
   613 			challengeUtf8.Zero();
       
   614 
       
   615 			CompleteQueryTtlsPapUserNameAndPassword(
       
   616 				status, userNameUtf8, challengeUtf8 );
       
   617 
       
   618 			return; // m_am_tools->convert_am_error_to_eapol_error(aStatus);		
       
   619 		}
       
   620 
       
   621 		if ( m_notifier_data_to_user->iPassword.Size() > 0 )
       
   622 		{
       
   623 			HBufC8* notifier_data8 = NULL;
       
   624 			TRAPD(err, notifier_data8 = HBufC8::NewL(m_notifier_data_to_user->iPassword.Size()));
       
   625 			if (err)
       
   626 			{
       
   627 				return;	
       
   628 			}
       
   629 			TPtr8 notifier_dataPtr8 = notifier_data8->Des();
       
   630 
       
   631 			notifier_dataPtr8.Copy(m_notifier_data_to_user->iPassword); // Unicode -> ascii.
       
   632 
       
   633 			EAP_TRACE_DATA_DEBUG(
       
   634 				m_am_tools,
       
   635 				TRACE_FLAGS_DEFAULT,
       
   636 				(EAPL( "eap_am_type_tls_peap_symbian_c::DlgComplete PW from UI (8bits)" ),
       
   637 				notifier_dataPtr8.Ptr(), 
       
   638 				notifier_dataPtr8.Size() ) );
       
   639 
       
   640 #ifdef USE_FAST_EAP_TYPE
       
   641 			status = m_userResponse.set_copy_of_buffer(
       
   642 				notifier_dataPtr8.Ptr(),
       
   643 				notifier_dataPtr8.Size());
       
   644 #endif			
       
   645 			CleanupStack::PopAndDestroy( notifier_data8 );
       
   646 		}
       
   647 	}
       
   648 
       
   649 	m_notifier_complete = 0;
       
   650 
       
   651 	if ( m_state == EPapChallenge)
       
   652 	{
       
   653 		EAP_TRACE_DEBUG(
       
   654 			m_am_tools,
       
   655 			TRACE_FLAGS_DEFAULT,
       
   656 			(EAPL("TLS: function: eap_am_type_tls_peap_symbian_c::DlgComplete(): EPapChallenge\n")));
       
   657 
       
   658 		m_state = EPapUserNameAndPassword;
       
   659 		TEapExpandedType aEapType(*EapExpandedTypeTtlsPap.GetType());
       
   660 
       
   661 		if (iEapAuthNotifier == 0)
       
   662 		{
       
   663 			TRAPD(err, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
       
   664 			if (err)
       
   665 			{
       
   666 			eap_variable_data_c userNameUtf8( m_am_tools );
       
   667 			eap_variable_data_c passwordUtf8( m_am_tools );
       
   668 		
       
   669 			(void) m_tls_am_partner->
       
   670 			    complete_query_ttls_pap_username_and_password(
       
   671 				    &userNameUtf8, &passwordUtf8, eap_status_process_general_error);	
       
   672 				return;
       
   673 			}
       
   674 		}
       
   675 
       
   676 
       
   677 		TTtlsPapDbInfo aInDbInfo;
       
   678 		TRAPD(err2, ReadTtlsPapDbL(aInDbInfo));
       
   679 		if (err2)
       
   680 		{
       
   681 			eap_variable_data_c userNameUtf8( m_am_tools );
       
   682 			eap_variable_data_c passwordUtf8( m_am_tools );
       
   683 		
       
   684 			(void) m_tls_am_partner->
       
   685 			    complete_query_ttls_pap_username_and_password(
       
   686 				    &userNameUtf8, &passwordUtf8, eap_status_process_general_error);	
       
   687 			return;
       
   688 		}
       
   689 
       
   690 		m_notifier_data_to_user->iPasswordPromptEnabled = aInDbInfo.iUsrPwdInfo.iPasswordPromptEnabled;
       
   691 
       
   692 		if (m_notifier_data_to_user->iPasswordPromptEnabled ||
       
   693 		(aInDbInfo.iUsrPwdInfo.iUserName.Size() == 0 &&
       
   694 		aInDbInfo.iUsrPwdInfo.iPassword.Size() == 0))
       
   695 		{
       
   696 			m_notifier_data_to_user->iUsername.Zero();
       
   697 			m_notifier_data_to_user->iPassword.Zero();
       
   698 
       
   699 			TRAPD(err3,SetTtlsPapColumnToNullL( cf_str_EAP_TLS_PEAP_ttls_pap_password_literal ));
       
   700 			if (err3)
       
   701 			{
       
   702 			eap_variable_data_c userNameUtf8( m_am_tools );
       
   703 			eap_variable_data_c passwordUtf8( m_am_tools );
       
   704 		
       
   705 			(void) m_tls_am_partner->
       
   706 			    complete_query_ttls_pap_username_and_password(
       
   707 				    &userNameUtf8, &passwordUtf8, eap_status_process_general_error);	
       
   708 			return;
       
   709 			}
       
   710 
       
   711 			if (iEapAuthNotifier == 0)
       
   712 			{
       
   713 				TRAPD(err4, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
       
   714 				if (err4)
       
   715 				{
       
   716 				eap_variable_data_c userNameUtf8( m_am_tools );
       
   717 				eap_variable_data_c passwordUtf8( m_am_tools );
       
   718 			
       
   719 				(void) m_tls_am_partner->
       
   720 				    complete_query_ttls_pap_username_and_password(
       
   721 					    &userNameUtf8, &passwordUtf8, eap_status_process_general_error);	
       
   722 				return;
       
   723 				}
       
   724 			}
       
   725 			else
       
   726 			{
       
   727 				TRAPD(err5,iEapAuthNotifier->Cancel());
       
   728 				if (err5)
       
   729 				{
       
   730 				eap_variable_data_c userNameUtf8( m_am_tools );
       
   731 				eap_variable_data_c passwordUtf8( m_am_tools );
       
   732 			
       
   733 				(void) m_tls_am_partner->
       
   734 				    complete_query_ttls_pap_username_and_password(
       
   735 					    &userNameUtf8, &passwordUtf8, eap_status_process_general_error);	
       
   736 				return;
       
   737 				}
       
   738 			}
       
   739 
       
   740 			TRAPD(err6, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypePapAuthQueryDialog, m_notifier_data_to_user, aEapType));
       
   741 			if (err6)
       
   742 			{
       
   743 			eap_variable_data_c userNameUtf8( m_am_tools );
       
   744 			eap_variable_data_c passwordUtf8( m_am_tools );
       
   745 		
       
   746 			(void) m_tls_am_partner->
       
   747 			    complete_query_ttls_pap_username_and_password(
       
   748 				    &userNameUtf8, &passwordUtf8, eap_status_process_general_error);	
       
   749 			return;
       
   750 			}
       
   751 		}
       
   752 		else
       
   753 		{
       
   754 			m_notifier_data_to_user->iUsername = aInDbInfo.iUsrPwdInfo.iUserName;
       
   755 
       
   756 			EAP_TRACE_DATA_DEBUG(
       
   757 				m_am_tools,
       
   758 				TRACE_FLAGS_DEFAULT,
       
   759 				(EAPL("eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password(): iUserName"),
       
   760 				m_notifier_data_to_user->iUsername.Ptr(),
       
   761 				m_notifier_data_to_user->iUsername.Size()));
       
   762 
       
   763 			m_notifier_data_to_user->iPassword = aInDbInfo.iUsrPwdInfo.iPassword;
       
   764 
       
   765 			EAP_TRACE_DATA_DEBUG(
       
   766 				m_am_tools,
       
   767 				TRACE_FLAGS_DEFAULT,
       
   768 				(EAPL("eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password(): iPassword"),
       
   769 				m_notifier_data_to_user->iPassword.Ptr(),
       
   770 				m_notifier_data_to_user->iPassword.Size()));
       
   771 
       
   772 			DlgComplete(KErrNone);
       
   773 		}
       
   774 		 
       
   775 	}
       
   776 	else if ( m_state == EPapUserNameAndPassword )
       
   777 	{
       
   778 		EAP_TRACE_DEBUG(
       
   779 			m_am_tools,
       
   780 			TRACE_FLAGS_DEFAULT,
       
   781 			(EAPL("TLS: function: eap_am_type_tls_peap_symbian_c::DlgComplete(): EPapUserNameAndPassword\n")));
       
   782 
       
   783 		TBuf8<KMaxNotifItemLength> userNameUtf8;
       
   784 		TBuf8<KMaxNotifItemLength> passwordUtf8;
       
   785 		userNameUtf8.Zero();
       
   786 		passwordUtf8.Zero();
       
   787 
       
   788 		if (m_notifier_data_to_user->iUsername.Size()>0)
       
   789 		{
       
   790 			CnvUtfConverter::ConvertFromUnicodeToUtf8( userNameUtf8, m_notifier_data_to_user->iUsername );
       
   791 
       
   792 			EAP_TRACE_DATA_DEBUG(
       
   793 				m_am_tools,
       
   794 				TRACE_FLAGS_DEFAULT,
       
   795 				(EAPL( "userNameUtf8" ),
       
   796 				userNameUtf8.Ptr(),
       
   797 				userNameUtf8.Size() ) );
       
   798 		}
       
   799 
       
   800 		if (m_notifier_data_to_user->iPassword.Size()>0)
       
   801 		{
       
   802 			CnvUtfConverter::ConvertFromUnicodeToUtf8( passwordUtf8, m_notifier_data_to_user->iPassword );   	
       
   803 		}
       
   804 
       
   805 		EAP_TRACE_DATA_DEBUG(
       
   806 			m_am_tools,
       
   807 			TRACE_FLAGS_DEFAULT,
       
   808 			(EAPL( "passwordUtf8" ),
       
   809 			passwordUtf8.Ptr(),
       
   810 			passwordUtf8.Size() ) );
       
   811 
       
   812 		CompleteQueryTtlsPapUserNameAndPassword(
       
   813 			status, userNameUtf8, passwordUtf8 );  
       
   814 
       
   815 		TTtlsPapDbInfo aInDbInfo;
       
   816 		aInDbInfo.iUsrPwdInfo.iPasswordPromptEnabled = m_notifier_data_to_user->iPasswordPromptEnabled;
       
   817 		aInDbInfo.iUsrPwdInfo.iUserName.Copy(userNameUtf8);
       
   818 		aInDbInfo.iUsrPwdInfo.iPassword.Copy(passwordUtf8);
       
   819 
       
   820 		TRAPD(err1, WriteTtlsPapDbL( aInDbInfo));
       
   821 		if (err1)
       
   822 		{
       
   823 			// continue
       
   824 		}
       
   825 	}
       
   826 #ifdef USE_FAST_EAP_TYPE
       
   827 	else if ( m_state == EPasswordCancel
       
   828 		|| m_state == EMasterkeyQuery
       
   829 		|| m_state == EPasswordQuery
       
   830 		|| m_state == EWrongPassword
       
   831 		|| m_state == EFilePasswordQuery )
       
   832 	{
       
   833 		EAP_TRACE_DEBUG(
       
   834 			m_am_tools,
       
   835 			TRACE_FLAGS_DEFAULT,
       
   836 			(EAPL("TLS: function: eap_am_type_tls_peap_symbian_c::DlgComplete(): else\n")));
       
   837 
       
   838 		m_eap_fast_completion_status = m_partner->set_timer(
       
   839 			this,
       
   840 			KHandleReadPacstoreTimerID, 
       
   841 			&aStatus,
       
   842 			0);
       
   843 		return;
       
   844 	}
       
   845 #endif //#ifdef USE_FAST_EAP_TYPE
       
   846 
       
   847 }
       
   848 
       
   849 //--------------------------------------------------
       
   850 
       
   851 //
   619 //
       
   620 
   852 void eap_am_type_tls_peap_symbian_c::RunL()
   621 void eap_am_type_tls_peap_symbian_c::RunL()
   853 {
   622 {
   854 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);		
   623 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);		
   855 	
   624 	
   856 	EAP_TRACE_DEBUG_SYMBIAN(
   625 	EAP_TRACE_DEBUG_SYMBIAN(
   857 		(_L("eap_am_type_tls_peap_symbian_c::RunL - iStatus.Int()=%d, m_state=%d "),
   626 		(_L("eap_am_type_tls_peap_symbian_c::RunL - iStatus.Int()=%d, m_state=%d "),
   858 		iStatus.Int() , m_state));
   627 		iStatus.Int() , m_state));
   859 	
   628 	
   860 #ifdef USE_FAST_EAP_TYPE
   629 #ifdef USE_FAST_EAP_TYPE
       
   630 	eap_status_e status(eap_status_ok);
       
   631 
       
   632 	if (m_notifier_complete)
       
   633 	{
       
   634 	
       
   635 		TRAPD(err, CompleteNotifierL());// Only for the notifiers.
       
   636 		if (err != KErrNone)
       
   637 			{
       
   638 			EAP_TRACE_ERROR(m_am_tools, 
       
   639 					TRACE_FLAGS_DEFAULT, (
       
   640 					EAPL("eap_am_type_tls_peap_symbian_c::RunL LEAVE from CompleteNotifierL, Error =%d \n"),
       
   641 					err));
       
   642 			}
       
   643 
       
   644 		m_notifier_complete = EFalse;
       
   645 	}
       
   646 
       
   647 	if ( m_state == EPasswordCancel ||
       
   648 		 m_state == EMasterkeyQuery ||
       
   649 		 m_state == EPasswordQuery ||
       
   650 		 m_state == EWrongPassword ||
       
   651 		 m_state == EFilePasswordQuery )
       
   652 		{
       
   653 		m_eap_fast_completion_status = m_partner->set_timer(
       
   654 				this,
       
   655 				KHandleReadPacstoreTimerID, 
       
   656 				&status,
       
   657 				0);
       
   658 		return;
       
   659 		}
   861 	if (m_state == ENone)
   660 	if (m_state == ENone)
   862 		{
   661 		{
   863 		return;		
   662 		return;		
   864 		}
   663 		}
   865 
   664 
   866 		if ( m_state == EHandlingDeviceSeedQuery)
       
   867 			{
       
   868 		  CompleteCreateDeviceSeedL( iStatus.Int() );     
       
   869 
       
   870 		  return;
       
   871 			}
       
   872 #endif // #ifdef USE_FAST_EAP_TYPE
   665 #endif // #ifdef USE_FAST_EAP_TYPE
   873 
   666 
   874 	if (iStatus.Int() != KErrNone)
   667 	if (iStatus.Int() != KErrNone)
   875 	{
   668 	{
   876 		// Notifier was cancelled or something went wrong
   669 		// Notifier was cancelled or something went wrong
   906 			// Notifier was cancelled or something went wrong		
   699 			// Notifier was cancelled or something went wrong		
   907 			get_tls_am_partner()->complete_query_certificate_chain(
   700 			get_tls_am_partner()->complete_query_certificate_chain(
   908 				0, 
   701 				0, 
   909 				eap_status_process_general_error);			
   702 				eap_status_process_general_error);			
   910 			return;
   703 			return;
   911 			
       
   912 		default:
   704 		default:
   913 			return;
   705 			return;
   914 		}
   706 		}
   915 	} // (iStatus.Int() != KErrNone)
   707 	}
   916 
   708 
   917 	if (m_state == EHandlingIdentityQuery
   709 	if (m_state == EHandlingIdentityQuery
   918 		|| m_state == EHandlingChainQuery)
   710 		|| m_state == EHandlingChainQuery)
   919 	{
   711 	{
   920 		TUint index(0);
   712 		TUint index(0);
   929 			index = 0;
   721 			index = 0;
   930 		}
   722 		}
   931 		
   723 		
   932 		if(m_allowed_user_certs.Count() > 0)
   724 		if(m_allowed_user_certs.Count() > 0)
   933 		{
   725 		{
   934 			m_own_certificate_info = *m_allowed_user_certs[index];			
   726 			m_own_certificate_info = m_allowed_user_certs[index];			
   935 		}
   727 		}
   936 		
   728 		
   937 		TBool retrieve_chain;
   729 		TBool retrieve_chain;
   938 
   730 
   939 		if (m_state == EHandlingChainQuery)
   731 		if (m_state == EHandlingChainQuery)
   948 		TInt allowed_user_cert_count = m_allowed_user_certs.Count();
   740 		TInt allowed_user_cert_count = m_allowed_user_certs.Count();
   949 		TInt err(KErrNone);
   741 		TInt err(KErrNone);
   950 		
   742 		
   951 		if(allowed_user_cert_count > 0)
   743 		if(allowed_user_cert_count > 0)
   952 		{
   744 		{
   953 			TRAP(err, m_cert_if->ReadCertificateL(*m_allowed_user_certs[index], retrieve_chain));			
   745 			TRAP(err, m_cert_if->ReadCertificateL(m_allowed_user_certs[index], retrieve_chain));			
   954 		}
   746 		}
   955 		if (err != KErrNone || allowed_user_cert_count <= 0)
   747 		if (err != KErrNone || allowed_user_cert_count <= 0)
   956 		{
   748 		{
   957 			EAP_TRACE_ERROR(
   749 			EAP_TRACE_ERROR(
   958 			m_am_tools,
   750 			m_am_tools,
   988 			default:
   780 			default:
   989 				return;
   781 				return;
   990 			}
   782 			}
   991 		}
   783 		}
   992 	}
   784 	}
       
   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 	}
   993 
   873 
   994 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
   874 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
   995 }
   875 }
   996 
   876 
   997 //--------------------------------------------------
   877 //--------------------------------------------------
   998 #ifdef USE_FAST_EAP_TYPE
   878 
   999 //
   879 //
  1000 // ---------------------------------------------------------
   880 
  1001 // eap_am_type_tls_peap_symbian_c::CreateDeviceSeedAsync()
       
  1002 // ---------------------------------------------------------
       
  1003 //
       
  1004 eap_status_e eap_am_type_tls_peap_symbian_c::CreateDeviceSeedAsync()
       
  1005 {   
       
  1006     EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1007 
       
  1008     EAP_TRACE_DEBUG_SYMBIAN(
       
  1009         (_L("eap_am_type_tls_peap_symbian_c::CreateDeviceSeedAsync-Start ActiveStatus=%d"),
       
  1010         IsActive()));       
       
  1011     
       
  1012     if ( IsActive() )
       
  1013     {
       
  1014         EAP_TRACE_DEBUG_SYMBIAN(
       
  1015             (_L("CreateDeviceSeedAsync: Already active when tried to create device seed")));       
       
  1016         
       
  1017         return eap_status_device_busy;
       
  1018     }
       
  1019 
       
  1020     eap_status_e status(eap_status_ok); 
       
  1021     
       
  1022     m_state = EHandlingDeviceSeedQuery;
       
  1023         
       
  1024     // Create MMETEL connection.
       
  1025     TRAPD(error, CreateMMETelConnectionL());
       
  1026     if(error !=KErrNone)
       
  1027     {
       
  1028         return m_am_tools->convert_am_error_to_eapol_error(error);
       
  1029     }
       
  1030     
       
  1031     iPhone.GetPhoneId( iStatus, iDeviceId ); 
       
  1032 
       
  1033     SetActive();
       
  1034     return status;
       
  1035 } // eap_am_type_tls_peap_symbian_c::CreateDeviceSeedAsynch()
       
  1036 
       
  1037 //--------------------------------------------------
       
  1038 
       
  1039 void eap_am_type_tls_peap_symbian_c::CompleteCreateDeviceSeedL( TInt aStatus )
       
  1040 {
       
  1041     EAP_TRACE_DEBUG_SYMBIAN(
       
  1042             (_L("eap_am_type_tls_peap_symbian_c::CompleteCreateDeviceSeedL aStatus=%d"),
       
  1043             iStatus.Int()));
       
  1044     if ( aStatus != KErrNone )
       
  1045         {
       
  1046         EAP_TRACE_DEBUG_SYMBIAN(
       
  1047                 (_L("eap_am_type_tls_peap_symbian_c::CompleteCreateDeviceSeedL ERROR: aStatus=%d"),
       
  1048                 iStatus.Int()));        
       
  1049         }
       
  1050     EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Manufacturer"),
       
  1051         iDeviceId.iManufacturer.Ptr(),
       
  1052         iDeviceId.iManufacturer.Size()));
       
  1053     EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Model"),
       
  1054         iDeviceId.iModel.Ptr(),
       
  1055         iDeviceId.iModel.Size()));
       
  1056     EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Revision"),
       
  1057         iDeviceId.iRevision.Ptr(),
       
  1058         iDeviceId.iRevision.Size()));
       
  1059     EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("SerialNumber"),
       
  1060         iDeviceId.iSerialNumber.Ptr(),
       
  1061         iDeviceId.iSerialNumber.Size()));
       
  1062         
       
  1063     // Combine all the above four items.            
       
  1064     TBuf<KMaxDeviceSeedLength> deviceSeed16;    
       
  1065     deviceSeed16 += iDeviceId.iManufacturer;
       
  1066     deviceSeed16 += iDeviceId.iModel;
       
  1067     deviceSeed16 += iDeviceId.iSerialNumber;
       
  1068         
       
  1069     TBuf8<KMaxDeviceSeedSize> deviceSeed8;
       
  1070     deviceSeed8.Copy(deviceSeed16);     
       
  1071 
       
  1072     if ( iPacStoreDeviceSeed == NULL )
       
  1073         {
       
  1074         iPacStoreDeviceSeed  = new  eap_variable_data_c(m_am_tools);
       
  1075         if ( iPacStoreDeviceSeed == NULL )
       
  1076             {
       
  1077             User::Leave( KErrNoMemory );
       
  1078             }
       
  1079         }
       
  1080 
       
  1081 #if defined(USE_EAP_CONFIGURATION_TO_SKIP_USER_INTERACTIONS)
       
  1082     const char DUMMY_SEED[]="empty";
       
  1083  
       
  1084 
       
  1085     if (m_skip_user_interactions == true)
       
  1086         {
       
  1087         iPacStoreDeviceSeed->set_copy_of_buffer(DUMMY_SEED, sizeof(DUMMY_SEED));
       
  1088         }
       
  1089     else
       
  1090 #endif //#if defined(USE_EAP_CONFIGURATION_TO_SKIP_USER_INTERACTIONS)
       
  1091         {
       
  1092         
       
  1093         if ( iPacStoreDeviceSeed != NULL )
       
  1094             {
       
  1095             if( deviceSeed8.Size() > 0)
       
  1096                 {
       
  1097                 iPacStoreDeviceSeed->set_copy_of_buffer(
       
  1098                     deviceSeed8.Ptr(),
       
  1099                     deviceSeed8.Size());
       
  1100                 }
       
  1101             }
       
  1102         }
       
  1103     DisconnectMMETel();
       
  1104     
       
  1105     ContinueInitializePacStore();
       
  1106 
       
  1107 } // eap_am_type_tls_peap_symbian_c::CompleteCreateDeviceSeedL()
       
  1108 
       
  1109 #endif
       
  1110 //--------------------------------------------------
       
  1111 
   881 
  1112 void eap_am_type_tls_peap_symbian_c::DoCancel()
   882 void eap_am_type_tls_peap_symbian_c::DoCancel()
  1113 {
   883 {
  1114 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);	
   884 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);	
  1115     
   885     
  1117 
   887 
  1118 	if(m_cert_if->IsActive())
   888 	if(m_cert_if->IsActive())
  1119 	{
   889 	{
  1120 		m_cert_if->Cancel();		
   890 		m_cert_if->Cancel();		
  1121 	}
   891 	}
  1122 	if (iEapAuthNotifier != 0)
   892 
  1123 		{
   893 	if ( iEapTtlsPapActive )
  1124 		iEapAuthNotifier->Cancel();
   894 		{
  1125 		}
   895 		if ( iEapTtlsPapActive->IsActive() )
  1126 
   896 			{
  1127 
   897 			EAP_TRACE_DEBUG_SYMBIAN(
       
   898 				( _L( " eap_am_type_tls_peap_symbian_c::DoCancel() \
       
   899 				Cancelling iEapTtlsPapActive." ) ) );
       
   900 			iEapTtlsPapActive->Cancel();
       
   901 			}
       
   902 		}
       
   903 	
  1128 #if defined(USE_FAST_EAP_TYPE)
   904 #if defined(USE_FAST_EAP_TYPE)
  1129 
   905 
  1130 	m_partner->cancel_timer(
   906 	m_partner->cancel_timer(
  1131 			this, 
   907 			this, 
  1132 			KRemoveIAPReferenceTimerID);
   908 			KRemoveIAPReferenceTimerID);
  1141 
   917 
  1142 	m_partner->cancel_timer(
   918 	m_partner->cancel_timer(
  1143 			this, 
   919 			this, 
  1144 			KHandleReadPacstoreTimerID);
   920 			KHandleReadPacstoreTimerID);
  1145 
   921 
       
   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 )		
  1146 
   939 
  1147 #endif // #if defined(USE_FAST_EAP_TYPE)
   940 #endif // #if defined(USE_FAST_EAP_TYPE)
  1148 	
   941 	
  1149 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
   942 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
  1150 }
   943 }
  1151 
   944 
  1152 //--------------------------------------------------
   945 //--------------------------------------------------
  1153 
   946 
  1154 //
   947 //
       
   948 
  1155 eap_status_e eap_am_type_tls_peap_symbian_c::SaveManualIdentityL( 
   949 eap_status_e eap_am_type_tls_peap_symbian_c::SaveManualIdentityL( 
  1156 	const TBool use_manual_username,
   950 	const TBool use_manual_username,
  1157 	TDesC& manual_username,
   951 	TDesC& manual_username,
  1158 	const TBool use_manual_realm,
   952 	const TBool use_manual_realm,
  1159 	TDesC& manual_realm)
   953 	TDesC& manual_realm)
  1160 {
   954 {
  1161 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   955 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  1162 	
   956 	
  1163 	// Validate length.
   957 	// Validate length.
  1164 	if(manual_username.Length() > KMaxUsernameLengthInDB
   958 	if(manual_username.Length() > KMaxManualUsernameLengthInDB
  1165 		|| manual_realm.Length() > KMaxRealmLengthInDB)
   959 		|| manual_realm.Length() > KMaxManualRealmLengthInDB)
  1166 	{
   960 	{
  1167 		// Username or realm too long. Can not be stored in DB.
   961 		// Username or realm too long. Can not be stored in DB.
  1168 		EAP_TRACE_DEBUG_SYMBIAN((_L("eap_am_type_tls_peap_symbian_c::SaveManualIdentityL: Too long username or realm. Length: manual_username=%d, manual_realm=%d\n"),
   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"),
  1169 		manual_username.Length(), manual_realm.Length()));
   963 		manual_username.Length(), manual_realm.Length()));
  1170 		
   964 		
  1171 		User::Leave(KErrArgument);
   965 		User::Leave(KErrArgument);
  1172 	}
   966 	}
  1173 		
   967 		
  1174 	HBufC* sqlbuf = HBufC::NewLC(KMaxSqlQueryLength);
   968 	HBufC* sqlbuf = HBufC::NewLC(KMaxSqlQueryLength);
  1175 	TPtr sqlStatement = sqlbuf->Des();
   969 	TPtr sqlStatement = sqlbuf->Des();
  1176 
   970 
  1177 	RDbView view;
   971 	RDbView view;
  1178 
   972 
  1179 	_LIT(KSQL, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
   973 	_LIT(KSQL, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d");
  1180 	
   974 	
  1181 	sqlStatement.Format(
   975 	sqlStatement.Format(KSQL, &m_db_table_name, 
  1182 		KSQL,
   976 		&KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);
  1183 		&m_db_table_name, 
       
  1184 		&KServiceType,
       
  1185 		m_index_type,
       
  1186 		&KServiceIndex,
       
  1187 		m_index,
       
  1188 		&KTunnelingTypeVendorId,
       
  1189 		m_tunneling_type.get_vendor_id(),
       
  1190 		&KTunnelingType, 
       
  1191 		m_tunneling_type.get_vendor_type());
       
  1192 	
   977 	
  1193 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));	
   978 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));	
  1194 	CleanupClosePushL(view);
   979 	CleanupClosePushL(view);
  1195 	User::LeaveIfError(view.EvaluateAll());
   980 	User::LeaveIfError(view.EvaluateAll());
  1196 
   981 
  1264 // eap_am_type_tls_peap_symbian_c::SendErrorNotification()
  1049 // eap_am_type_tls_peap_symbian_c::SendErrorNotification()
  1265 // ---------------------------------------------------------
  1050 // ---------------------------------------------------------
  1266 //
  1051 //
  1267 void eap_am_type_tls_peap_symbian_c::SendErrorNotification(
  1052 void eap_am_type_tls_peap_symbian_c::SendErrorNotification(
  1268 	const eap_status_e aError )
  1053 	const eap_status_e aError )
  1269 {
  1054 	{
  1270 	send_error_notification( aError );
  1055 	send_error_notification( aError );
  1271 }
  1056 	}
  1272 
       
  1273 //--------------------------------------------------
  1057 //--------------------------------------------------
  1274 
  1058 
  1275 #if defined(USE_FAST_EAP_TYPE)
  1059 #if defined(USE_FAST_EAP_TYPE)
  1276 
  1060 
  1277 EAP_FUNC_EXPORT void eap_am_type_tls_peap_symbian_c::set_tls_application(
  1061 EAP_FUNC_EXPORT void eap_am_type_tls_peap_symbian_c::set_tls_application(
  1281 
  1065 
  1282 	m_tls_application = tls_application;
  1066 	m_tls_application = tls_application;
  1283 
  1067 
  1284 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1068 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1285 }
  1069 }
       
  1070 
       
  1071 
       
  1072 
  1286 
  1073 
  1287 // ---------------------------------------------------------
  1074 // ---------------------------------------------------------
  1288 // eap_am_type_tls_peap_symbian_c::IsProvisioningMode()
  1075 // eap_am_type_tls_peap_symbian_c::IsProvisioningMode()
  1289 // ---------------------------------------------------------
  1076 // ---------------------------------------------------------
  1290 //
  1077 //
  1291 TBool eap_am_type_tls_peap_symbian_c::IsProvisioningMode()
  1078 TBool eap_am_type_tls_peap_symbian_c::IsProvisioningMode()
  1292 {
  1079 	{
  1293 	return ( m_provisioning_mode ==
  1080 	return ( m_provisioning_mode ==
  1294         eap_fast_completion_operation_server_authenticated_provisioning_mode ) ? ETrue : EFalse;
  1081         eap_fast_completion_operation_server_authenticated_provisioning_mode ) ? ETrue : EFalse;
  1295 }
  1082 	}
       
  1083 
  1296 
  1084 
  1297 // ---------------------------------------------------------
  1085 // ---------------------------------------------------------
  1298 // eap_am_type_tls_peap_symbian_c::CompleteQueryUserPermissionForAid()
  1086 // eap_am_type_tls_peap_symbian_c::CompleteQueryUserPermissionForAid()
  1299 // ---------------------------------------------------------
  1087 // ---------------------------------------------------------
  1300 //
  1088 //
  1301 eap_status_e
  1089 eap_status_e
  1302 eap_am_type_tls_peap_symbian_c::CompleteQueryUserPermissionForAid(
  1090 eap_am_type_tls_peap_symbian_c::CompleteQueryUserPermissionForAid(
  1303 	EEapFastNotifierUserAction aUserAction )
  1091 	EEapFastNotifierUserAction aUserAction )
  1304 {
  1092 	{
  1305 	EAP_TRACE_DEBUG_SYMBIAN(
  1093 	EAP_TRACE_DEBUG_SYMBIAN(
  1306 			(_L("eap_am_type_tls_peap_symbian_c::CompleteQueryUserPermissionForAid")));
  1094 			(_L("eap_am_type_tls_peap_symbian_c::CompleteQueryUserPermissionForAid")));
  1307 	if ( aUserAction == EEapFastNotifierUserActionOk )
  1095 	if ( aUserAction == EEapFastNotifierUserActionOk )
  1308 		{
  1096 		{
  1309 		EAP_TRACE_DEBUG_SYMBIAN(
  1097 		EAP_TRACE_DEBUG_SYMBIAN(
  1323   		    complete_query_user_permission_for_A_ID(
  1111   		    complete_query_user_permission_for_A_ID(
  1324   			    eap_status_user_cancel_authentication,
  1112   			    eap_status_user_cancel_authentication,
  1325   		        m_pending_operation );
  1113   		        m_pending_operation );
  1326   		} 
  1114   		} 
  1327 	return m_eap_fast_completion_status;
  1115 	return m_eap_fast_completion_status;
  1328 }
  1116 	}
       
  1117 
  1329 
  1118 
  1330 #endif //#if defined(USE_FAST_EAP_TYPE)
  1119 #endif //#if defined(USE_FAST_EAP_TYPE)
  1331 
  1120 
  1332 //--------------------------------------------------
  1121 //--------------------------------------------------
  1333 
  1122 
  1334 //
  1123 //
  1335 EAP_FUNC_EXPORT void eap_am_type_tls_peap_symbian_c::notify_configuration_error(
  1124 void eap_am_type_tls_peap_symbian_c::notify_configuration_error(
  1336 	const eap_status_e configuration_status)
  1125 	const eap_status_e configuration_status)
  1337 {
  1126 {
  1338 	if (m_is_client == true)
  1127 	if (m_is_client == true)
  1339 	{
  1128 	{
  1340 		EAP_UNREFERENCED_PARAMETER(configuration_status); // in release
  1129 		EAP_UNREFERENCED_PARAMETER(configuration_status); // in release
  1407 
  1196 
  1408 		if (err != KErrNone)
  1197 		if (err != KErrNone)
  1409 		{
  1198 		{
  1410 			EAP_TRACE_ERROR(m_am_tools, 
  1199 			EAP_TRACE_ERROR(m_am_tools, 
  1411 				TRACE_FLAGS_DEFAULT, (
  1200 				TRACE_FLAGS_DEFAULT, (
  1412 				EAPL("eap_am_type_tls_peap_symbian_c::configure(): ReadCertRowsToArrayL, User cert, Error =%d \n"),
  1201 				EAPL("eap_am_type_tls_peap_symbian_c::configure - ReadCertRowsToArrayL, User cert, Error =%d \n"),
  1413 				err));
  1202 				err));
  1414 		
  1203 		
  1415 			// Convert the leave error code to EAPOL stack error code.
  1204 			// Convert the leave error code to EAPOL stack error code.
  1416 			status = m_am_tools->convert_am_error_to_eapol_error(err);
  1205 			status = m_am_tools->convert_am_error_to_eapol_error(err);
  1417 			return EAP_STATUS_RETURN(m_am_tools, status);
  1206 			return EAP_STATUS_RETURN(m_am_tools, status);
  1433 			m_allowed_ca_certs));
  1222 			m_allowed_ca_certs));
  1434 		if (err != KErrNone)
  1223 		if (err != KErrNone)
  1435 		{
  1224 		{
  1436 			EAP_TRACE_ERROR(m_am_tools, 
  1225 			EAP_TRACE_ERROR(m_am_tools, 
  1437 				TRACE_FLAGS_DEFAULT, (
  1226 				TRACE_FLAGS_DEFAULT, (
  1438 				EAPL("eap_am_type_tls_peap_symbian_c::configure(): ReadCertRowsToArrayL, CA cert, Error =%d \n"),
  1227 				EAPL("eap_am_type_tls_peap_symbian_c::configure - ReadCertRowsToArrayL, CA cert, Error =%d \n"),
  1439 				err));
  1228 				err));
  1440 		
  1229 		
  1441 			// Convert the leave error code to EAPOL stack error code.
  1230 			// Convert the leave error code to EAPOL stack error code.
  1442 			status = m_am_tools->convert_am_error_to_eapol_error(err);			
  1231 			status = m_am_tools->convert_am_error_to_eapol_error(err);			
  1443 			return EAP_STATUS_RETURN(m_am_tools, status);
  1232 			return EAP_STATUS_RETURN(m_am_tools, status);
  1460 			m_allowed_cipher_suites));
  1249 			m_allowed_cipher_suites));
  1461 		if (err != KErrNone)
  1250 		if (err != KErrNone)
  1462 		{
  1251 		{
  1463 			EAP_TRACE_ERROR(m_am_tools, 
  1252 			EAP_TRACE_ERROR(m_am_tools, 
  1464 				TRACE_FLAGS_DEFAULT, (
  1253 				TRACE_FLAGS_DEFAULT, (
  1465 				EAPL("eap_am_type_tls_peap_symbian_c::configure(): ReadUintRowsToArrayL, CipherSuit, Error =%d \n"),
  1254 				EAPL("eap_am_type_tls_peap_symbian_c::configure - ReadUintRowsToArrayL, CipherSuit, Error =%d \n"),
  1466 				err));
  1255 				err));
  1467 
  1256 
  1468 			// Convert the leave error code to EAPOL stack error code.
  1257 			// Convert the leave error code to EAPOL stack error code.
  1469 			status = m_am_tools->convert_am_error_to_eapol_error(err);			
  1258 			status = m_am_tools->convert_am_error_to_eapol_error(err);			
  1470 			return EAP_STATUS_RETURN(m_am_tools, status);
  1259 			return EAP_STATUS_RETURN(m_am_tools, status);
  1483 #endif
  1272 #endif
  1484 
  1273 
  1485 		
  1274 		
  1486 		)
  1275 		)
  1487 	{
  1276 	{
       
  1277 #ifdef USE_EAP_EXPANDED_TYPES
       
  1278 
  1488 		TRAPD(err, EapTlsPeapUtils::GetTunnelingExpandedEapDataL(
  1279 		TRAPD(err, EapTlsPeapUtils::GetTunnelingExpandedEapDataL(
  1489 			m_database,
  1280 			m_database,
  1490 			m_am_tools,
  1281 			m_am_tools,
  1491 			m_enabled_tunneling_exp_eap_array,
  1282 			m_enabled_tunneling_exp_eap_array,
  1492 			m_disabled_tunneling_exp_eap_array,
  1283 			m_disabled_tunneling_exp_eap_array,
  1493 			m_index_type,
  1284 			m_index_type,
  1494 			m_index,
  1285 			m_index,
  1495 			m_tunneling_type,
  1286 			m_tunneling_type,
  1496 			m_current_eap_type));
  1287 			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
  1497 	
  1300 	
  1498 		if (err != KErrNone)
  1301 		if (err != KErrNone)
  1499 		{
  1302 		{
  1500 			EAP_TRACE_ERROR(m_am_tools, 
  1303 			EAP_TRACE_ERROR(m_am_tools, 
  1501 				TRACE_FLAGS_DEFAULT, (
  1304 				TRACE_FLAGS_DEFAULT, (
  1502 				EAPL("eap_am_type_tls_peap_symbian_c::configure(): GetEapDataL or GetTunnelingExpandedEapDataL, Error =%d \n"),
  1305 				EAPL("eap_am_type_tls_peap_symbian_c::configure - GetEapDataL or GetTunnelingExpandedEapDataL, Error =%d \n"),
  1503 				err));
  1306 				err));
  1504 
  1307 
  1505 			// Convert the leave error code to EAPOL stack error code.
  1308 			// Convert the leave error code to EAPOL stack error code.
  1506 			status = m_am_tools->convert_am_error_to_eapol_error(err);			
  1309 			status = m_am_tools->convert_am_error_to_eapol_error(err);			
  1507 			return EAP_STATUS_RETURN(m_am_tools, status);
  1310 			return EAP_STATUS_RETURN(m_am_tools, status);
  1562 		}
  1365 		}
  1563 	}
  1366 	}
  1564 
  1367 
  1565 	//----------------------------------------------------------
  1368 	//----------------------------------------------------------
  1566 
  1369 
  1567 	if (m_is_client == true)
       
  1568 	{
       
  1569 		eap_variable_data_c use_automatic_ca_certificate(m_am_tools);
       
  1570 
       
  1571 		eap_status_e status = type_configure_read(
       
  1572 			cf_str_EAP_TLS_PEAP_use_automatic_ca_certificate.get_field(),
       
  1573 			&use_automatic_ca_certificate);
       
  1574 		if (status == eap_status_ok
       
  1575 			&& use_automatic_ca_certificate.get_is_valid_data() == true)
       
  1576 		{
       
  1577 			u32_t *use_automatic_ca_certificate_flag = reinterpret_cast<u32_t *>(
       
  1578 				use_automatic_ca_certificate.get_data(sizeof(u32_t)));
       
  1579 			if (use_automatic_ca_certificate_flag != 0
       
  1580 				&& *use_automatic_ca_certificate_flag != 0)
       
  1581 			{
       
  1582 				m_use_automatic_ca_certificate = true;
       
  1583 			}
       
  1584 		}
       
  1585 	}
       
  1586 
       
  1587 	//----------------------------------------------------------
       
  1588 
       
  1589 	// This is only for server
  1370 	// This is only for server
  1590 	{
  1371 	{
  1591 		eap_variable_data_c cipher_suite(m_am_tools);
  1372 		eap_variable_data_c cipher_suite(m_am_tools);
  1592 
  1373 
  1593 		eap_status_e status = type_configure_read(
  1374 		eap_status_e status = type_configure_read(
  1605 		}
  1386 		}
  1606 	}
  1387 	}
  1607 	
  1388 	
  1608 	//----------------------------------------------------------
  1389 	//----------------------------------------------------------
  1609 
  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 	//----------------------------------------------------------
       
  1459 
  1610 	{
  1460 	{
  1611 		eap_variable_data_c use_manual_username(m_am_tools);
  1461 		eap_variable_data_c use_manual_username(m_am_tools);
  1612 
  1462 
  1613 		eap_status_e status = type_configure_read(
  1463 		eap_status_e status = type_configure_read(
  1614 			cf_str_EAP_TLS_PEAP_use_manual_username.get_field(),
  1464 			cf_str_EAP_TLS_PEAP_use_manual_username.get_field(),
  1680 
  1530 
  1681 #if defined(USE_EAP_TLS_SESSION_TICKET)
  1531 #if defined(USE_EAP_TLS_SESSION_TICKET)
  1682 	{
  1532 	{
  1683 		eap_variable_data_c use_session_ticket(m_am_tools);
  1533 		eap_variable_data_c use_session_ticket(m_am_tools);
  1684 
  1534 
  1685 		eap_status_e status = type_configure_read(
  1535 		eap_status_e status = m_partner->read_configure(
  1686 			cf_str_EAP_TLS_PEAP_use_session_ticket.get_field(),
  1536 			cf_str_EAP_TLS_PEAP_use_session_ticket.get_field(),
  1687 			&use_session_ticket);
  1537 			&use_session_ticket);
  1688 		if (status == eap_status_ok
  1538 		if (status == eap_status_ok
  1689 			&& use_session_ticket.get_is_valid_data() == true)
  1539 			&& use_session_ticket.get_is_valid_data() == true)
  1690 		{
  1540 		{
  1751 		// Read Maximum Session Validity Time from the config file
  1601 		// Read Maximum Session Validity Time from the config file
  1752 		eap_variable_data_c sessionTimeFromFile(m_am_tools);
  1602 		eap_variable_data_c sessionTimeFromFile(m_am_tools);
  1753 		
  1603 		
  1754 		eap_status_e status(eap_status_ok);
  1604 		eap_status_e status(eap_status_ok);
  1755 
  1605 
  1756 		if (m_current_eap_type == eap_type_tls)
  1606 		switch (m_current_eap_vendor_type)
  1757 		{
  1607 		{
  1758 			status = type_configure_read(
  1608 		case eap_type_tls:
  1759 				cf_str_EAP_TLS_max_session_validity_time.get_field(),
  1609 			{
  1760 				&sessionTimeFromFile);
  1610 				status = m_partner->read_configure(
  1761 		}
  1611 					cf_str_EAP_TLS_max_session_validity_time.get_field(),
  1762 		else if (m_current_eap_type == eap_type_peap)
  1612 					&sessionTimeFromFile);
  1763 		{
  1613 			}
  1764 			status = type_configure_read(
  1614 			break;
  1765 				cf_str_EAP_PEAP_max_session_validity_time.get_field(),
  1615 
  1766 				&sessionTimeFromFile);
  1616 		case eap_type_peap:
  1767 		}
  1617 			{
  1768 		else if (m_current_eap_type == eap_type_ttls)
  1618 				status = m_partner->read_configure(
  1769 		{
  1619 					cf_str_EAP_PEAP_max_session_validity_time.get_field(),
  1770 			status = type_configure_read(
  1620 					&sessionTimeFromFile);
  1771 				cf_str_EAP_TTLS_max_session_validity_time.get_field(),
  1621 			}
  1772 				&sessionTimeFromFile);
  1622 			break;
  1773 		}
  1623 
  1774 		else if (m_current_eap_type == eap_expanded_type_ttls_plain_pap.get_type())
  1624 		case eap_type_ttls:
  1775 		{
  1625 			{
       
  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 			{
  1776 			// read PAP session time
  1634 			// read PAP session time
  1777 			status = type_configure_read(
  1635 			status = m_partner->read_configure(
  1778 				cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time.get_field(),
  1636 				cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time.get_field(),
  1779 				&sessionTimeFromFile );
  1637 				&sessionTimeFromFile );
  1780 		}
  1638 			}
       
  1639 			break;
       
  1640 			
  1781 #if defined(USE_FAST_EAP_TYPE)
  1641 #if defined(USE_FAST_EAP_TYPE)
  1782 		else if (m_current_eap_type == eap_type_fast)
  1642 		case eap_type_fast:
  1783 		{
  1643 			{
  1784 			status = type_configure_read(
  1644 				status = m_partner->read_configure(
  1785 				cf_str_EAP_FAST_max_session_validity_time.get_field(),
  1645 					cf_str_EAP_FAST_max_session_validity_time.get_field(),
  1786 				&sessionTimeFromFile);
  1646 					&sessionTimeFromFile);
  1787 		}
  1647 			}
       
  1648 			break;
  1788 #endif
  1649 #endif
  1789 		else
  1650 			
  1790 		{
  1651 		default:
  1791 			// Should never happen
  1652 			{
  1792 			EAP_TRACE_ERROR(m_am_tools, 
  1653 				// Should never happen
  1793 				TRACE_FLAGS_DEFAULT, (
  1654 				EAP_TRACE_ERROR(m_am_tools, 
  1794 				EAPL("eap_am_type_tls_peap_symbian_c::configure(): Unsupported EAP type, m_current_eap_vendor_type=0xfe%06x%08x\n"),
  1655 					TRACE_FLAGS_DEFAULT, (
  1795 				m_current_eap_type.get_vendor_id(),
  1656 					EAPL("eap_am_type_tls_peap_symbian_c::configure - Unsupported EAP type, m_current_eap_vendor_type=%d \n"),
  1796 				m_current_eap_type.get_vendor_type()));
  1657 					m_current_eap_vendor_type));
  1797 		}
  1658 			}
       
  1659 		}	
  1798 
  1660 
  1799 		// set m_max_session_time
  1661 		// set m_max_session_time
  1800 		if (status == eap_status_ok
  1662 		if (status == eap_status_ok
  1801 			&& sessionTimeFromFile.get_is_valid_data() == true
  1663 			&& sessionTimeFromFile.get_is_valid_data() == true
  1802 			&& sessionTimeFromFile.get_data_length() == sizeof(u32_t))
  1664 			&& sessionTimeFromFile.get_data_length() == sizeof(u32_t))
  1893 	
  1755 	
  1894 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - -	
  1756 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - -	
  1895 	
  1757 	
  1896 	status = eap_status_ok;
  1758 	status = eap_status_ok;
  1897 
  1759 
  1898 	if (m_use_automatic_ca_certificate == false)
  1760 	if (m_allowed_ca_certs.Count() == 0)
  1899 	{
  1761 	{		
  1900 		if (m_allowed_ca_certs.Count() == 0)
  1762 	// needed because of nonworking wrong settings
  1901 		{
       
  1902 			// needed because of nonworking wrong settings
       
  1903 #if defined(USE_FAST_EAP_TYPE)
  1763 #if defined(USE_FAST_EAP_TYPE)
  1904 			if(m_current_eap_type == eap_type_fast
  1764 		if(m_current_eap_type == eap_type_fast &&
  1905 				&& m_serv_auth_prov_mode != true)
  1765 			m_serv_auth_prov_mode != true)
  1906 			{
  1766 		{
  1907 				// In the case of EAP-FAST, CA cert is must if m_serv_auth_prov_mode is TRUE.
  1767 			// In the case of EAP-FAST, CA cert is must if m_serv_auth_prov_mode is TRUE.
  1908 				status = eap_status_ok;
  1768 			status = eap_status_ok;
  1909 				
  1769 			
  1910 				EAP_TRACE_DEBUG(
  1770 			EAP_TRACE_DEBUG(m_am_tools, 
  1911 					m_am_tools, 
  1771 				TRACE_FLAGS_DEFAULT, (
  1912 					TRACE_FLAGS_DEFAULT,
  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")));				
  1913 					(EAPL("eap_am_type_tls_peap_symbian_c::configure(): No CA certificate but exception for EAP-FAST as m_serv_auth_prov_mode is FALSE and for all m_serv_unauth_prov_mode \n")));
  1773 		}
  1914 			}
  1774 		else	
  1915 			else	
       
  1916 #endif // #if defined(USE_FAST_EAP_TYPE)
  1775 #endif // #if defined(USE_FAST_EAP_TYPE)
  1917 			{
  1776 		{
  1918 				EAP_TRACE_ERROR(
  1777 			EAP_TRACE_ERROR(m_am_tools, 
  1919 					m_am_tools, 
  1778 				TRACE_FLAGS_DEFAULT, (
  1920 					TRACE_FLAGS_DEFAULT,
  1779 				EAPL("eap_am_type_tls_peap_symbian_c::configure - Error - No CA certificate\n")));
  1921 					(EAPL("eap_am_type_tls_peap_symbian_c::configure(): Error - No CA certificate\n")));
  1780 		
  1922 			
  1781 			// No root certificate selected. Cannot continue.
  1923 				// No root certificate selected. Cannot continue.
  1782 			status = eap_status_ca_certificate_unknown;
  1924 				status = eap_status_ca_certificate_unknown;
  1783 			send_error_notification(status);
  1925 				send_error_notification(status);
  1784 		}			
  1926 			}			
  1785 	}
  1927 		}
  1786 	
  1928 		else
       
  1929 		{
       
  1930 			EAP_TRACE_DEBUG(
       
  1931 				m_am_tools, 
       
  1932 				TRACE_FLAGS_DEFAULT,
       
  1933 				(EAPL("eap_am_type_tls_peap_symbian_c::configure(): %d CA certificates selected.\n"),
       
  1934 				m_allowed_ca_certs.Count()));
       
  1935 		}
       
  1936 	}
       
  1937 	else
       
  1938 	{
       
  1939 		EAP_TRACE_DEBUG(
       
  1940 			m_am_tools, 
       
  1941 			TRACE_FLAGS_DEFAULT,
       
  1942 			(EAPL("eap_am_type_tls_peap_symbian_c::configure(): %d CA certificate selected in automatic CA selection.\n"),
       
  1943 			m_allowed_ca_certs.Count()));
       
  1944 	}
       
  1945 	
       
  1946 
       
  1947 	if(m_allowed_user_certs.Count() == 0)
  1787 	if(m_allowed_user_certs.Count() == 0)
  1948 	{
  1788 		{
  1949 #if defined(USE_FAST_EAP_TYPE)
  1789 #if defined(USE_FAST_EAP_TYPE)
  1950 		if(m_current_eap_type == eap_type_fast)
  1790 		if(m_current_eap_type == eap_type_fast)
  1951 		{
  1791 			{
  1952 			m_use_manual_realm = true;
  1792 			m_use_manual_realm = true;
  1953 
  1793 
  1954 			if (m_use_manual_username == false)
  1794 			if (m_use_manual_username == false)
  1955 			{
  1795 				{
  1956 				TRAPD(err, status=ConfigureL());
  1796 				TRAPD(err, status=ConfigureL());
  1957 				if (err != KErrNone)
  1797 				if (err != KErrNone)
  1958 				{
  1798 					{
  1959 					EAP_TRACE_ERROR(m_am_tools, 
  1799 					EAP_TRACE_ERROR(m_am_tools, 
  1960 							TRACE_FLAGS_DEFAULT, (
  1800 							TRACE_FLAGS_DEFAULT, (
  1961 							EAPL("eap_am_type_tls_peap_symbian_c::configure LEAVE from ConfigureL, Error =%d \n"),
  1801 							EAPL("eap_am_type_tls_peap_symbian_c::configure LEAVE from ConfigureL, Error =%d \n"),
  1962 							err));
  1802 							err));
       
  1803 					}
  1963 				}
  1804 				}
  1964 			}
  1805 			}
  1965 		}
       
  1966 #endif // #if defined(USE_FAST_EAP_TYPE)
  1806 #endif // #if defined(USE_FAST_EAP_TYPE)
  1967 	}
  1807 		}
  1968 	else
       
  1969 	{
       
  1970 		EAP_TRACE_DEBUG(
       
  1971 			m_am_tools, 
       
  1972 			TRACE_FLAGS_DEFAULT,
       
  1973 			(EAPL("eap_am_type_tls_peap_symbian_c::configure(): %d user certificates selected.\n"),
       
  1974 			m_allowed_user_certs.Count()));
       
  1975 	}
       
  1976 
       
  1977 
       
  1978 	if (m_tls_peap_server_authenticates_client_policy_flag == true
  1808 	if (m_tls_peap_server_authenticates_client_policy_flag == true
  1979 		&& m_allowed_user_certs.Count() == 0)
  1809 		&& m_allowed_user_certs.Count() == 0)
  1980 	{
  1810 	{
  1981 #if defined(USE_FAST_EAP_TYPE)
  1811 #if defined(USE_FAST_EAP_TYPE)
  1982 		if (m_current_eap_type == eap_type_fast)
  1812     if (m_current_eap_type == eap_type_fast)
  1983 		{
  1813         {
  1984 			EAP_TRACE_DEBUG(
  1814         EAP_TRACE_DEBUG(m_am_tools, 
  1985 				m_am_tools, 
  1815             TRACE_FLAGS_DEFAULT, 
  1986 				TRACE_FLAGS_DEFAULT, 
  1816             (EAPL("eap_am_type_tls_peap_symbian_c::configure - No USER certificate, but in eap_fast it's not mandatory\n")));  
  1987 				(EAPL("eap_am_type_tls_peap_symbian_c::configure(): No USER certificate, but in eap_fast it's not mandatory\n")));
  1817     
  1988 		}
  1818         }
  1989 		else
  1819 	else
  1990 #endif // #if defined(USE_FAST_EAP_TYPE)
  1820 #endif // #if defined(USE_FAST_EAP_TYPE)
  1991 	    {
  1821 	    {
  1992 			EAP_TRACE_ERROR(
  1822 	    EAP_TRACE_ERROR(m_am_tools, 
  1993 				m_am_tools, 
  1823 			TRACE_FLAGS_DEFAULT, (
  1994 				TRACE_FLAGS_DEFAULT,
  1824 			EAPL("eap_am_type_tls_peap_symbian_c::configure - Error - No USER certificate\n")));
  1995 				(EAPL("eap_am_type_tls_peap_symbian_c::configure(): Error - No USER certificate\n")));
  1825 	
  1996 		
  1826 		// No user certificate selected. Cannot continue.
  1997 			// No user certificate selected. Cannot continue.
  1827 		status = eap_status_user_certificate_unknown;
  1998 			status = eap_status_user_certificate_unknown;
  1828 		send_error_notification(status);
  1999 			send_error_notification(status);
       
  2000 	    }
  1829 	    }
  2001 	}
  1830 	}
  2002 
  1831 
  2003 	if (m_allowed_cipher_suites.Count() == 0)
  1832 	if (m_allowed_cipher_suites.Count() == 0)
  2004 	{
  1833 	{
  2005 		EAP_TRACE_ERROR(
  1834 		EAP_TRACE_ERROR(m_am_tools, 
  2006 			m_am_tools, 
  1835 			TRACE_FLAGS_DEFAULT, (
  2007 			TRACE_FLAGS_DEFAULT,
  1836 			EAPL("eap_am_type_tls_peap_symbian_c::configure - Error - No cipher suit\n")));
  2008 			(EAPL("eap_am_type_tls_peap_symbian_c::configure(): Error - No cipher suit\n")));
       
  2009 
  1837 
  2010 		// No sipher suites selected. Cannot continue.
  1838 		// No sipher suites selected. Cannot continue.
  2011 		status = eap_status_illegal_cipher_suite;
  1839 		status = eap_status_illegal_cipher_suite;
  2012 		send_error_notification(status);
  1840 		send_error_notification(status);
  2013 	}
  1841 	}
  2014 	else
       
  2015 	{
       
  2016 		EAP_TRACE_DEBUG(
       
  2017 			m_am_tools, 
       
  2018 			TRACE_FLAGS_DEFAULT,
       
  2019 			(EAPL("eap_am_type_tls_peap_symbian_c::configure(): %d cipher suites selected.\n"),
       
  2020 			m_allowed_cipher_suites.Count()));
       
  2021 	}
       
  2022 
  1842 
  2023 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1843 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2024 
  1844 
  2025 	if (status != eap_status_ok)
  1845 	if (status != eap_status_ok)
  2026 	{
  1846 	{
  2027 		notify_configuration_error(status);
  1847 		notify_configuration_error(status);
  2028 	}
  1848 	}
  2029 	
  1849 	
  2030 	m_configured = true;
  1850 	m_configured = true;
  2031 	
  1851 	
  2032 	EAP_TRACE_DEBUG(
  1852 	EAP_TRACE_DEBUG(m_am_tools, 
  2033 		m_am_tools, 
       
  2034 		TRACE_FLAGS_DEFAULT, 
  1853 		TRACE_FLAGS_DEFAULT, 
  2035 		(EAPL("eap_am_type_tls_peap_symbian_c::configure(): END \n")));
  1854 		(EAPL("eap_am_type_tls_peap_symbian_c::configure - END \n")));	
  2036 	
  1855 	
  2037 
  1856 
  2038 	return EAP_STATUS_RETURN(m_am_tools, status);
  1857 	return EAP_STATUS_RETURN(m_am_tools, status);
  2039 }
  1858 }
  2040 
  1859 
  2041 //--------------------------------------------------
  1860 //--------------------------------------------------
  2042 
       
  2043 #if defined(USE_FAST_EAP_TYPE)
  1861 #if defined(USE_FAST_EAP_TYPE)
  2044 
  1862 
  2045 eap_status_e eap_am_type_tls_peap_symbian_c::ConfigureL()
  1863 eap_status_e eap_am_type_tls_peap_symbian_c::ConfigureL()
  2046 {
  1864 	{
  2047 	
  1865 	
  2048 	eap_status_e status(eap_status_ok);
  1866 	eap_status_e status(eap_status_ok);
  2049 	
  1867 	
  2050 	_LIT(KTempUserName, "EAP-FAST-");
  1868 	_LIT(KTempUserName, "EAP-FAST-");
  2051 	TBuf8<10> TempUserName;	
  1869 	TBuf8<10> TempUserName;	
  2052 
  1870 
  2053 	TempUserName.Copy(KTempUserName);
  1871 	TempUserName.Copy(KTempUserName);
  2054 	
  1872 	
  2055   HBufC8* buf = HBufC8::NewLC(KMaxNotifItemLength);
  1873 	HBufC8* buf = HBufC8::NewLC(KIdentityFieldLength);
  2056 
       
  2057 	TPtr8 bufPtr = buf->Des();
  1874 	TPtr8 bufPtr = buf->Des();
  2058 
  1875 
  2059 	HBufC8* tempUserBuf8 = HBufC8::NewLC(KMacAddressLength);
  1876 	HBufC8* tempUserBuf8 = HBufC8::NewLC(KMacAddressLength);
  2060 	TPtr8 tempUserBufPtr8 = tempUserBuf8->Des();
  1877 	TPtr8 tempUserBufPtr8 = tempUserBuf8->Des();
  2061 
  1878 
  2131 	CleanupStack::PopAndDestroy(buf);
  1948 	CleanupStack::PopAndDestroy(buf);
  2132 
  1949 
  2133 	m_use_manual_username = true;
  1950 	m_use_manual_username = true;
  2134 	
  1951 	
  2135 	return status;
  1952 	return status;
  2136 }
  1953 	}
  2137 
  1954 
  2138 #endif // #if defined(USE_FAST_EAP_TYPE)
  1955 #endif // #if defined(USE_FAST_EAP_TYPE)
  2139 
  1956 
  2140 //--------------------------------------------------
  1957 //--------------------------------------------------
  2141 
  1958 
  2142 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::reset()
  1959 eap_status_e eap_am_type_tls_peap_symbian_c::reset()
  2143 {
  1960 {
  2144 
  1961 
  2145 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
  1962 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
  2146 }
  1963 }
  2147 
  1964 
  2170 	}
  1987 	}
  2171 
  1988 
  2172 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1989 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2173 	return EAP_STATUS_RETURN(m_am_tools, status);
  1990 	return EAP_STATUS_RETURN(m_am_tools, status);
  2174 }
  1991 }
  2175 
       
  2176 //--------------------------------------------------
       
  2177 
  1992 
  2178 void eap_am_type_tls_peap_symbian_c::authentication_finishedL(
  1993 void eap_am_type_tls_peap_symbian_c::authentication_finishedL(
  2179 	const bool true_when_successful,
  1994 	const bool true_when_successful,
  2180 	const tls_session_type_e tls_session_type)
  1995 	const tls_session_type_e tls_session_type)
  2181 {
  1996 {
  2278 	m_state = EHandlingIdentityQuery;
  2093 	m_state = EHandlingIdentityQuery;
  2279 		
  2094 		
  2280 	// Get the own certificate only if it has already been retrieved
  2095 	// Get the own certificate only if it has already been retrieved
  2281 	if (m_own_certificate == 0)
  2096 	if (m_own_certificate == 0)
  2282 	{
  2097 	{
  2283 		// Get the matching certificates. This function call is completed asyncronously by complete_get_matching_certificates() function call.
       
  2284 		TRAPD(err, m_cert_if->GetMatchingCertificatesL(
  2098 		TRAPD(err, m_cert_if->GetMatchingCertificatesL(
  2285 			m_allowed_user_certs, 
  2099 			m_allowed_user_certs, 
  2286 			EFalse, 
  2100 			EFalse, 
  2287 			0, 
  2101 			0, 
  2288 			EFalse, 
  2102 			EFalse, 
  2315 		
  2129 		
  2316 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2130 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2317 	return EAP_STATUS_RETURN(m_am_tools, status);
  2131 	return EAP_STATUS_RETURN(m_am_tools, status);
  2318 }
  2132 }
  2319 
  2133 
  2320 //--------------------------------------------------
       
  2321 
  2134 
  2322 eap_status_e eap_am_type_tls_peap_symbian_c::complete_read_own_certificate(
  2135 eap_status_e eap_am_type_tls_peap_symbian_c::complete_read_own_certificate(
  2323 	const RPointerArray<CX509Certificate>& aCertChain, eap_status_e aStatus)
  2136 	const RPointerArray<CX509Certificate>& aCertChain, eap_status_e aStatus)
  2324 {
  2137 {
  2325 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);	
  2138 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);	
  2578 	
  2391 	
  2579 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2392 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2580 	return EAP_STATUS_RETURN(m_am_tools, status);
  2393 	return EAP_STATUS_RETURN(m_am_tools, status);
  2581 }
  2394 }
  2582 
  2395 
  2583 //--------------------------------------------------
       
  2584 
       
  2585 eap_status_e eap_am_type_tls_peap_symbian_c::complete_read_ca_certificate(
  2396 eap_status_e eap_am_type_tls_peap_symbian_c::complete_read_ca_certificate(
  2586 		const RPointerArray<CX509Certificate>& aCertChain, eap_status_e aStatus)
  2397 		const RPointerArray<CX509Certificate>& aCertChain, eap_status_e aStatus)
  2587 {
  2398 {
  2588 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  2399 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  2589 
  2400 
  2769 
  2580 
  2770 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2581 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2771 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);	
  2582 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);	
  2772 }
  2583 }
  2773 
  2584 
  2774 //--------------------------------------------------
       
  2775 
       
  2776 void eap_am_type_tls_peap_symbian_c::get_identities_from_distinguished_namesL(
  2585 void eap_am_type_tls_peap_symbian_c::get_identities_from_distinguished_namesL(
  2777 	const CX509Certificate * const aCertificate, 
  2586 	const CX509Certificate * const aCertificate, 
  2778 	eap_variable_data_c * const aSubjectIdentity,
  2587 	eap_variable_data_c * const aSubjectIdentity,
  2779 	eap_variable_data_c * const aIssuerIdentity)
  2588 	eap_variable_data_c * const aIssuerIdentity)
  2780 {
  2589 {
  2873 			CleanupStack::PopAndDestroy(value);
  2682 			CleanupStack::PopAndDestroy(value);
  2874 		}				
  2683 		}				
  2875 	}
  2684 	}
  2876 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2685 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2877 }
  2686 }
  2878 
       
  2879 //--------------------------------------------------
       
  2880 
  2687 
  2881 void eap_am_type_tls_peap_symbian_c::get_identity_from_alternative_nameL(
  2688 void eap_am_type_tls_peap_symbian_c::get_identity_from_alternative_nameL(
  2882 	const CX509Certificate * const aCertificate, 
  2689 	const CX509Certificate * const aCertificate, 
  2883 	eap_variable_data_c * const aIdentity)
  2690 	eap_variable_data_c * const aIdentity)
  2884 {
  2691 {
  3074 		User::Leave(KErrNotFound);
  2881 		User::Leave(KErrNotFound);
  3075 	}
  2882 	}
  3076 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  2883 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3077 }
  2884 }
  3078 
  2885 
       
  2886 //--------------------------------------------------
       
  2887 
       
  2888 //
  3079 //--------------------------------------------------
  2889 //--------------------------------------------------
  3080 
  2890 
  3081 //
  2891 //
  3082 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::timer_expired(
  2892 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::timer_expired(
  3083 	const u32_t id, void *data)
  2893 	const u32_t id, void *data)
  3347 	
  3157 	
  3348 	EAP_TRACE_DEBUG(m_am_tools, 
  3158 	EAP_TRACE_DEBUG(m_am_tools, 
  3349 		TRACE_FLAGS_DEFAULT, 
  3159 		TRACE_FLAGS_DEFAULT, 
  3350 		(EAPL("eap_am_type_tls_peap_symbian_c::type_configure_read - Start\n")));
  3160 		(EAPL("eap_am_type_tls_peap_symbian_c::type_configure_read - Start\n")));
  3351 	
  3161 	
  3352 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_type_tls_peap_symbian_c::type_configure_read()");
       
  3353 
       
  3354 
       
  3355 	if (m_current_eap_type == eap_type_peap
  3162 	if (m_current_eap_type == eap_type_peap
  3356 #if defined(USE_TTLS_EAP_TYPE)
  3163 #if defined(USE_TTLS_EAP_TYPE)
  3357 		|| m_current_eap_type == eap_type_ttls
  3164 		|| m_current_eap_type == eap_type_ttls
  3358 #endif // #if defined(USE_TTLS_EAP_TYPE)
  3165 #endif // #if defined(USE_TTLS_EAP_TYPE)
  3359 #if defined(USE_FAST_EAP_TYPE)
  3166 #if defined(USE_FAST_EAP_TYPE)
  3360 		|| m_current_eap_type == eap_type_fast
  3167 		|| m_current_eap_type == eap_type_fast
  3361 #endif
  3168 #endif
  3362 
  3169 
  3363 		|| m_current_eap_type == eap_expanded_type_ttls_plain_pap.get_type()
  3170 		|| m_current_eap_type == eap_type_ttls_plain_pap
  3364 	
  3171 	
  3365 		)
  3172 		)
  3366 	{
  3173 	{
  3367 		// Check if the wanted parameter is default type
  3174 		// Check if the wanted parameter is default type
  3368 		eap_variable_data_c wanted_field(m_am_tools);
  3175 		eap_variable_data_c wanted_field(m_am_tools);
  3421 
  3228 
  3422 		if (!wanted_field.compare(&type_field))
  3229 		if (!wanted_field.compare(&type_field))
  3423 		{
  3230 		{
  3424 			// We are asked to return cf_str_PEAP_tunneled_eap_type_hex_data
  3231 			// We are asked to return cf_str_PEAP_tunneled_eap_type_hex_data
  3425 			
  3232 			
       
  3233 #ifdef USE_EAP_EXPANDED_TYPES
       
  3234 	
  3426 			// We need to return here the next ENABLED tunneled EAP type we should try. 
  3235 			// We need to return here the next ENABLED tunneled EAP type we should try. 
  3427 	
  3236 	
  3428 			if (0 == m_enabled_tunneling_exp_eap_array.Count())
  3237 			if (0 == m_enabled_tunneling_exp_eap_array.Count())
  3429 			{
  3238 			{
  3430 				// No EAP types are ENABLED as tunneling type.
  3239 				// No EAP types are ENABLED as tunneling type.
  3438 			}
  3247 			}
  3439 			else
  3248 			else
  3440 			{
  3249 			{
  3441 				// Get the first enabled EAP type (tunneling).
  3250 				// Get the first enabled EAP type (tunneling).
  3442 
  3251 
       
  3252 				TBuf8<KExpandedEAPTypeSize> tmpExpEAP(m_enabled_tunneling_exp_eap_array[0]->iExpandedEAPType); //first item.
       
  3253 
  3443 				EAP_TRACE_DATA_DEBUG(
  3254 				EAP_TRACE_DATA_DEBUG(
  3444 					m_am_tools,
  3255 					m_am_tools,
  3445 					TRACE_FLAGS_DEFAULT,
  3256 					TRACE_FLAGS_DEFAULT,
  3446 					(EAPL("type_configure_read:Enabled expanded tunneling EAP type:"),
  3257 					(EAPL("type_configure_read:Enabled expanded tunneling EAP type:"),
  3447 					m_enabled_tunneling_exp_eap_array[0]->GetValue().Ptr(),
  3258 					tmpExpEAP.Ptr(),
  3448 					m_enabled_tunneling_exp_eap_array[0]->GetValue().Length()));
  3259 					tmpExpEAP.Size()));
  3449 					
  3260 					
  3450 				status = data->set_copy_of_buffer(
  3261 					status = data->set_copy_of_buffer(tmpExpEAP.Ptr(), KExpandedEAPTypeSize);
  3451 					m_enabled_tunneling_exp_eap_array[0]->GetValue().Ptr(),
  3262 					if (status != eap_status_ok)
  3452 					m_enabled_tunneling_exp_eap_array[0]->GetValue().Length());
  3263 					{
  3453 				if (status != eap_status_ok)
  3264 						EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3454 				{
  3265 						return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);			
  3455 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3266 					}
  3456 					return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);			
       
  3457 				}
       
  3458 					
  3267 					
  3459 				EAP_TRACE_DATA_DEBUG(
  3268 				EAP_TRACE_DATA_DEBUG(
  3460 					m_am_tools,
  3269 					m_am_tools,
  3461 					TRACE_FLAGS_DEFAULT,
  3270 					TRACE_FLAGS_DEFAULT,
  3462 					(EAPL("EAP-PEAP or EAP-TTLS: Trying encapsulated EAP type:"),
  3271 					(EAPL("EAP-PEAP or EAP-TTLS: Trying encapsulated EAP type:"),
  3463 					m_enabled_tunneling_exp_eap_array[0]->GetValue().Ptr(),
  3272 					tmpExpEAP.Ptr(),
  3464 					m_enabled_tunneling_exp_eap_array[0]->GetValue().Length()));
  3273 					tmpExpEAP.Size()));
  3465 			}
  3274 			}
  3466 
  3275 	
       
  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 					
  3467 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3314 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3468 			return EAP_STATUS_RETURN(m_am_tools, status);
  3315 			return EAP_STATUS_RETURN(m_am_tools, status);
  3469 		
  3316 		
  3470 		} // End of  if (!wanted_field.compare(&type_field))
  3317 		} // End of  if (!wanted_field.compare(&type_field))
  3471 		
  3318 		
       
  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.
  3472 
  3354 
  3473 		// cf_str_PEAP_accepted_tunneled_client_types_u32array is available only for normal EAP types.
  3355 		// cf_str_PEAP_accepted_tunneled_client_types_u32array is available only for normal EAP types.
  3474 		// So for cf_str_PEAP_accepted_tunneled_client_types_u32array and eap_configure_type_u32array
  3356 		// So for cf_str_PEAP_accepted_tunneled_client_types_u32array and eap_configure_type_u32array
  3475 		// we should return eap_status_illegal_configure_field.
  3357 		// we should return eap_status_illegal_configure_field.
  3476 		
  3358 		
  3495 			{
  3377 			{
  3496 				// This field is used only for Normal EAP types. This is illegal here.
  3378 				// This field is used only for Normal EAP types. This is illegal here.
  3497 				return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_type);
  3379 				return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_type);
  3498 			}
  3380 			}
  3499 		}
  3381 		}
       
  3382 		
       
  3383 #endif // End of #if !defined(USE_EAP_EXPANDED_TYPES)
       
  3384 		
  3500 	} // End of if (m_current_eap_type == eap_type_peap
  3385 	} // End of if (m_current_eap_type == eap_type_peap
  3501 
  3386 	
  3502 	TRAPD(err, type_configure_readL(
  3387 	TRAPD(err, type_configure_readL(
  3503 		field->get_field(),
  3388 		field->get_field(),
  3504 		field->get_field_length(),
  3389 		field->get_field_length(),
  3505 		data));
  3390 		data));
  3506 	if (err != KErrNone) 
  3391 	if (err != KErrNone) 
  3507 	{	
  3392 	{	
  3508 		status = m_partner->read_configure(field, data);
  3393 		status = m_am_tools->convert_am_error_to_eapol_error(err);
  3509 	}
  3394 	}
  3510 
  3395 
  3511 	m_am_tools->trace_configuration(
  3396 	m_am_tools->trace_configuration(
  3512 		status,
  3397 		status,
  3513 		field,
  3398 		field,
  3514 		data);
  3399 		data);
       
  3400         
       
  3401 	EAP_TRACE_DEBUG(m_am_tools, 
       
  3402 		TRACE_FLAGS_DEFAULT, 
       
  3403 		(EAPL("eap_am_type_tls_peap_symbian_c::type_configure_read - End\n")));
  3515 
  3404 
  3516 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3405 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3517 	return EAP_STATUS_RETURN(m_am_tools, status);
  3406 	return EAP_STATUS_RETURN(m_am_tools, status);
  3518 }
  3407 }
  3519 
  3408 
  3520 //--------------------------------------------------
  3409 //--------------------------------------------------
  3521 
       
  3522 void eap_am_type_tls_peap_symbian_c::type_configure_readL(
  3410 void eap_am_type_tls_peap_symbian_c::type_configure_readL(
  3523 	eap_config_string field,
  3411 	eap_config_string field,
  3524 	const u32_t field_length,
  3412 	const u32_t field_length,
  3525 	eap_variable_data_c * const data)
  3413 	eap_variable_data_c * const data)
  3526 {
  3414 {
  3547 	
  3435 	
  3548 	// Now do the database query
  3436 	// Now do the database query
  3549 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  3437 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  3550 	TPtr sqlStatement = buf->Des();
  3438 	TPtr sqlStatement = buf->Des();
  3551 	
  3439 	
  3552 	_LIT(KSQLQueryRow, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");	
  3440 	_LIT(KSQLQueryRow, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d");	
  3553 	
  3441 	
  3554 #if defined(USE_FAST_EAP_TYPE)
  3442 #if defined(USE_FAST_EAP_TYPE)
  3555 	
  3443 	
  3556 	// Unlike other EAP types, EAP-FAST has some settings in special settings table
  3444 	// Unlike other EAP types, EAP-FAST has some settings in special settings table
  3557 	// (m_db_fast_special_table_name)
  3445 	// (m_db_fast_special_table_name)
  3558 	
  3446 	
  3559 	if(m_current_eap_type == eap_type_fast
  3447 	if(m_current_eap_type == eap_type_fast
  3560 	   && ((unicodeString.Compare(cf_str_EAP_FAST_allow_server_authenticated_provisioning_mode_literal) == 0)
  3448 	   && ((unicodeString.Compare(cf_str_EAP_FAST_allow_server_authenticated_provisioning_mode_literal) == 0)
  3561 	   || (unicodeString.Compare(cf_str_EAP_FAST_allow_server_unauthenticated_provisioning_mode_ADHP_literal) == 0)
  3449 	   || (unicodeString.Compare(cf_str_EAP_FAST_allow_server_unauthenticated_provisioning_mode_ADHP_literal) == 0)
  3562 	   || (unicodeString.Compare(KFASTWarnADHPNoPAC) == 0)
  3450 	   || (unicodeString.Compare(cf_str_EAP_FAST_warn_ADHP_no_PAC_literal) == 0)
  3563 	   || (unicodeString.Compare(KFASTWarnADHPNoMatchingPAC) == 0)
  3451 	   || (unicodeString.Compare(cf_str_EAP_FAST_warn_ADHP_no_matching_PAC_literal) == 0)
  3564 	   || (unicodeString.Compare(KFASTWarnNotDefaultServer) == 0)
  3452 	   || (unicodeString.Compare(cf_str_EAP_FAST_warn_ADHP_not_default_server_literal) == 0)
  3565 	   || (unicodeString.Compare(KFASTPACGroupImportReferenceCollection) == 0)
  3453 	   || (unicodeString.Compare(KFASTPACGroupImportReferenceCollection) == 0)
  3566 	   || (unicodeString.Compare(KFASTPACGroupDBReferenceCollection) == 0)))
  3454 	   || (unicodeString.Compare(KFASTPACGroupDBReferenceCollection) == 0)))
  3567 	{
  3455 	    {
       
  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             }
  3568 		EAP_TRACE_DEBUG(m_am_tools, 
  3468 		EAP_TRACE_DEBUG(m_am_tools, 
  3569 			TRACE_FLAGS_DEFAULT, 
  3469 			TRACE_FLAGS_DEFAULT, 
  3570 			(EAPL("eap_am_type_tls_peap_symbian_c::type_configure_readL This field will be read from EAP-FAST's special table\n")));
  3470 			(EAPL("eap_am_type_tls_peap_symbian_c::type_configure_readL This field will be read from EAP-FAST's special table\n")));
  3571 		
  3471 		
  3572 		sqlStatement.Format(
  3472 		sqlStatement.Format(KSQLQueryRow, &unicodeString, &m_db_fast_special_table_name, 
  3573 			KSQLQueryRow,
  3473 			&KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);		
  3574 			&unicodeString,
  3474 	    }
  3575 			&m_db_fast_special_table_name, 
       
  3576 			&KServiceType,
       
  3577 			m_index_type,
       
  3578 			&KServiceIndex,
       
  3579 			m_index,
       
  3580 			&KTunnelingTypeVendorId,
       
  3581 			m_tunneling_type.get_vendor_id(),
       
  3582 			&KTunnelingType, 
       
  3583 			m_tunneling_type.get_vendor_type());
       
  3584 	}
       
  3585 	else
  3475 	else
  3586 	{
  3476 	    {
  3587 		sqlStatement.Format(
  3477 		sqlStatement.Format(KSQLQueryRow, &unicodeString, &m_db_table_name, 
  3588 			KSQLQueryRow,
  3478 			&KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);		
  3589 			&unicodeString,
  3479 	    }
  3590 			&m_db_table_name, 
       
  3591 			&KServiceType,
       
  3592 			m_index_type,
       
  3593 			&KServiceIndex,
       
  3594 			m_index,
       
  3595 			&KTunnelingTypeVendorId,
       
  3596 			m_tunneling_type.get_vendor_id(),
       
  3597 			&KTunnelingType, 
       
  3598 			m_tunneling_type.get_vendor_type());
       
  3599 	}
       
  3600 	
  3480 	
  3601 #else
  3481 #else
  3602 
  3482 
  3603 	sqlStatement.Format(
  3483 	sqlStatement.Format(KSQLQueryRow, &unicodeString, &m_db_table_name, 
  3604 		KSQLQueryRow,
  3484 		&KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);
  3605 		&unicodeString,
       
  3606 		&m_db_table_name, 
       
  3607 		&KServiceType,
       
  3608 		m_index_type,
       
  3609 		&KServiceIndex,
       
  3610 		m_index,
       
  3611 		&KTunnelingTypeVendorId,
       
  3612 		m_tunneling_type.get_vendor_id(),
       
  3613 		&KTunnelingType, 
       
  3614 		m_tunneling_type.get_vendor_type());
       
  3615 		
  3485 		
  3616 #endif // End: #if defined(USE_FAST_EAP_TYPE)
  3486 #endif // End: #if defined(USE_FAST_EAP_TYPE)
  3617 
  3487 	
  3618 	RDbView view;
  3488 	RDbView view;
  3619 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  3489 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  3620 	CleanupClosePushL(view);
  3490 	CleanupClosePushL(view);
  3621 	User::LeaveIfError(view.EvaluateAll());	
  3491 	User::LeaveIfError(view.EvaluateAll());	
  3622 	if (view.FirstL())
  3492 	if (view.FirstL())
  3688 	// Close database
  3558 	// Close database
  3689 	CleanupStack::PopAndDestroy(4); // view
  3559 	CleanupStack::PopAndDestroy(4); // view
  3690 
  3560 
  3691 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3561 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3692 }
  3562 }
  3693 
       
  3694 //--------------------------------------------------
  3563 //--------------------------------------------------
  3695 
  3564 
  3696 //
  3565 //
       
  3566 
  3697 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::type_configure_write(
  3567 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::type_configure_write(
  3698 	const eap_configuration_field_c * const field,
  3568 	const eap_configuration_field_c * const field,
  3699 	eap_variable_data_c * const data)
  3569 	eap_variable_data_c * const data)
  3700 {
  3570 {
  3701 	// Here configuration data must be read from type spesific database.
  3571 	// Here configuration data must be read from type spesific database.
  3728 	field_name.Copy(p);
  3598 	field_name.Copy(p);
  3729 	
  3599 	
  3730 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  3600 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  3731 	TPtr sqlStatement = buf->Des();
  3601 	TPtr sqlStatement = buf->Des();
  3732 	
  3602 	
  3733 	_LIT(KSQLInsert, "SELECT %s FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
  3603 	_LIT(KSQLInsert, "SELECT %s FROM %S WHERE %S=%d AND %S=%d AND %S=%d");
  3734 
  3604 	sqlStatement.Format(KSQLInsert, field_name.PtrZ(), &m_db_table_name, 
  3735 	sqlStatement.Format(
  3605 		&KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);
  3736 		KSQLInsert,
       
  3737 		field_name.PtrZ(),
       
  3738 		&m_db_table_name, 
       
  3739 		&KServiceType,
       
  3740 		m_index_type,
       
  3741 		&KServiceIndex,
       
  3742 		m_index,
       
  3743 		&KTunnelingTypeVendorId,
       
  3744 		m_tunneling_type.get_vendor_id(),
       
  3745 		&KTunnelingType, 
       
  3746 		m_tunneling_type.get_vendor_type());
       
  3747 
       
  3748 	// Evaluate view
  3606 	// Evaluate view
  3749 	RDbView view;
  3607 	RDbView view;
  3750 	User::LeaveIfError(view.Prepare(m_database,TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  3608 	User::LeaveIfError(view.Prepare(m_database,TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  3751 	CleanupClosePushL(view);
  3609 	CleanupClosePushL(view);
  3752 	User::LeaveIfError(view.EvaluateAll());
  3610 	User::LeaveIfError(view.EvaluateAll());
  3770 	CleanupStack::PopAndDestroy(3); // view, 2 strings
  3628 	CleanupStack::PopAndDestroy(3); // view, 2 strings
  3771 
  3629 
  3772 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
  3630 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
  3773 }
  3631 }
  3774 
  3632 
  3775 //--------------------------------------------------
       
  3776 
       
  3777 void eap_am_type_tls_peap_symbian_c::WriteIntParamL(
  3633 void eap_am_type_tls_peap_symbian_c::WriteIntParamL(
  3778 	eap_config_string field,
  3634 	eap_config_string field,
  3779 	const u32_t field_length,
  3635 	const u32_t field_length,
  3780 	eap_variable_data_c * const data)
  3636 	eap_variable_data_c * const data)
  3781 {
  3637 {
  3790 	
  3646 	
  3791 	// Form the insertion command
  3647 	// Form the insertion command
  3792 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  3648 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  3793 	TPtr sqlStatement = buf->Des();
  3649 	TPtr sqlStatement = buf->Des();
  3794 
  3650 
  3795 	_LIT(KSQLInsert, "SELECT %s FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
  3651 	_LIT(KSQLInsert, "SELECT %s FROM %S WHERE %S=%d AND %S=%d AND %S=%d");
  3796 
  3652 	sqlStatement.Format(KSQLInsert, field_name.PtrZ(), &m_db_table_name, 
  3797 	sqlStatement.Format(
  3653 		&KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);
  3798 		KSQLInsert,
       
  3799 		field_name.PtrZ(),
       
  3800 		&m_db_table_name, 
       
  3801 		&KServiceType,
       
  3802 		m_index_type,
       
  3803 		&KServiceIndex,
       
  3804 		m_index,
       
  3805 		&KTunnelingTypeVendorId,
       
  3806 		m_tunneling_type.get_vendor_id(),
       
  3807 		&KTunnelingType, 
       
  3808 		m_tunneling_type.get_vendor_type());
       
  3809 	
  3654 	
  3810 	// Evaluate view
  3655 	// Evaluate view
  3811 	RDbView view;
  3656 	RDbView view;
  3812 	User::LeaveIfError(view.Prepare(m_database,TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  3657 	User::LeaveIfError(view.Prepare(m_database,TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  3813 	CleanupClosePushL(view);
  3658 	CleanupClosePushL(view);
  3830 	// Close database
  3675 	// Close database
  3831 	CleanupStack::PopAndDestroy(3); // view, buf, 2nd buf
  3676 	CleanupStack::PopAndDestroy(3); // view, buf, 2nd buf
  3832 
  3677 
  3833 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3678 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3834 }
  3679 }
  3835 
       
  3836 //--------------------------------------------------
       
  3837 
  3680 
  3838 void eap_am_type_tls_peap_symbian_c::WriteIntParamL(
  3681 void eap_am_type_tls_peap_symbian_c::WriteIntParamL(
  3839 	eap_config_string field,
  3682 	eap_config_string field,
  3840 	const u32_t field_length,
  3683 	const u32_t field_length,
  3841 	const u32_t value)
  3684 	const u32_t value)
  3851 	
  3694 	
  3852 	// Form the insertion command
  3695 	// Form the insertion command
  3853 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  3696 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  3854 	TPtr sqlStatement = buf->Des();
  3697 	TPtr sqlStatement = buf->Des();
  3855 
  3698 
  3856 	_LIT(KSQLInsert, "SELECT %s FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
  3699 	_LIT(KSQLInsert, "SELECT %s FROM %S WHERE %S=%d AND %S=%d AND %S=%d");
  3857 
  3700 	sqlStatement.Format(KSQLInsert, field_name.PtrZ(), &m_db_table_name, 
  3858 	sqlStatement.Format(
  3701 		&KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);
  3859 		KSQLInsert,
       
  3860 		field_name.PtrZ(),
       
  3861 		&m_db_table_name, 
       
  3862 		&KServiceType,
       
  3863 		m_index_type,
       
  3864 		&KServiceIndex,
       
  3865 		m_index,
       
  3866 		&KTunnelingTypeVendorId,
       
  3867 		m_tunneling_type.get_vendor_id(),
       
  3868 		&KTunnelingType, 
       
  3869 		m_tunneling_type.get_vendor_type());
       
  3870 	
  3702 	
  3871 	// Evaluate view
  3703 	// Evaluate view
  3872 	RDbView view;
  3704 	RDbView view;
  3873 	User::LeaveIfError(view.Prepare(m_database,TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  3705 	User::LeaveIfError(view.Prepare(m_database,TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  3874 	CleanupClosePushL(view);
  3706 	CleanupClosePushL(view);
  3954 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
  3786 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
  3955 }
  3787 }
  3956 
  3788 
  3957 //--------------------------------------------------
  3789 //--------------------------------------------------
  3958 
  3790 
  3959 eap_status_e eap_am_type_tls_peap_symbian_c::select_cipher_suite(
       
  3960 	const bool select_all_cipher_suites,
       
  3961 	const tls_cipher_suites_e test_cipher_suite,
       
  3962 	const TAlgorithmId testcertAlgorithm,
       
  3963 	const TAlgorithmId certAlgorithm,
       
  3964 	eap_array_c<u16_t> * cipher_suites)
       
  3965 {
       
  3966 	EAP_TRACE_DEBUG(
       
  3967 		m_am_tools,
       
  3968 		TRACE_FLAGS_DEFAULT,
       
  3969 		(EAPL("eap_am_type_tls_peap_symbian_c::select_cipher_suite(), select_all_cipher_suites=%d, test_cipher_suite=%d, testcertAlgorithm=%d, certAlgorithm=%d\n"),
       
  3970 		select_all_cipher_suites,
       
  3971 		test_cipher_suite,
       
  3972 		testcertAlgorithm,
       
  3973 		certAlgorithm));
       
  3974 
       
  3975 	eap_status_e status(eap_status_ok);
       
  3976 
       
  3977 	// Cipher suite must be allowed AND the algorithm must match the certificates algorithm.
       
  3978 	// Also select_all_cipher_suites can be used to add all cipher suites to the list.
       
  3979 
       
  3980 	TInt found = m_allowed_cipher_suites.Find(test_cipher_suite);
       
  3981 
       
  3982 	EAP_TRACE_DEBUG(
       
  3983 		m_am_tools,
       
  3984 		TRACE_FLAGS_DEFAULT,
       
  3985 		(EAPL("eap_am_type_tls_peap_symbian_c::select_cipher_suite(), found=%d, cipher suite=%d, KErrNotFound=%d\n"),
       
  3986 		found,
       
  3987 		test_cipher_suite,
       
  3988 		KErrNotFound));
       
  3989 
       
  3990 	if (found != KErrNotFound
       
  3991 		&& (select_all_cipher_suites == true
       
  3992 			|| testcertAlgorithm == certAlgorithm))
       
  3993 	{
       
  3994 		u16_t *tmp_object = new u16_t;
       
  3995 		if (tmp_object == 0)
       
  3996 		{
       
  3997 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3998 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  3999 		}
       
  4000 		*tmp_object = eap_htons(test_cipher_suite);
       
  4001 		
       
  4002 		EAP_TRACE_DEBUG(
       
  4003 			m_am_tools,
       
  4004 			TRACE_FLAGS_DEFAULT,
       
  4005 			(EAPL("eap_am_type_tls_peap_symbian_c::select_cipher_suite(), adds cipher suite=%d\n"),
       
  4006 			test_cipher_suite));
       
  4007 
       
  4008 		status = cipher_suites->add_object(tmp_object, true);
       
  4009 	}
       
  4010 
       
  4011 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  4012 }
       
  4013 
       
  4014 //--------------------------------------------------
       
  4015 
  3791 
  4016 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::query_cipher_suites_and_previous_session()
  3792 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::query_cipher_suites_and_previous_session()
  4017 {
  3793 {
  4018 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  3794 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  4019 
  3795 
  4022 		(m_is_client == true ? "client": "server")));
  3798 		(m_is_client == true ? "client": "server")));
  4023 
  3799 
  4024 	EAP_ASSERT_ALWAYS(m_is_client == true);
  3800 	EAP_ASSERT_ALWAYS(m_is_client == true);
  4025 
  3801 
  4026 	eap_status_e status(eap_status_process_general_error);
  3802 	eap_status_e status(eap_status_process_general_error);
  4027 
  3803 	
  4028 	TAlgorithmId certAlgorithm(ERSA);
  3804 	TAlgorithmId certAlgorithm(ERSA);
  4029 
  3805 
  4030 	bool select_all_cipher_suites = false;
  3806 	bool select_all_cipher_suites = false;
  4031 
  3807 	
  4032 	eap_variable_data_c session_id(m_am_tools);
  3808 	eap_variable_data_c session_id(m_am_tools);
  4033 	eap_variable_data_c master_secret(m_am_tools);
  3809 	eap_variable_data_c master_secret(m_am_tools);
  4034 	tls_cipher_suites_e used_cipher_suite(tls_cipher_suites_TLS_NULL_WITH_NULL_NULL);
  3810 	tls_cipher_suites_e used_cipher_suite(tls_cipher_suites_TLS_NULL_WITH_NULL_NULL);
  4035 	tls_session_type_e tls_session_type(tls_session_type_full_authentication);	
  3811 	tls_session_type_e tls_session_type(tls_session_type_full_authentication);	
  4036 
  3812 
  4037 	eap_array_c<u16_t> cipher_suites(m_am_tools);
  3813 	eap_array_c<u16_t> cipher_suites(m_am_tools);
  4038 
  3814 		
  4039 #if defined(USE_FAST_EAP_TYPE)
  3815 #if defined(USE_FAST_EAP_TYPE)
  4040 		
  3816 		
  4041 	if(m_current_eap_type == eap_type_fast &&
  3817 	if(m_current_eap_type == eap_type_fast &&
  4042 	   m_serv_unauth_prov_mode == true)
  3818 	   m_serv_unauth_prov_mode == true)
  4043 	{
  3819 	{
  4079 			// Since there is no user certificate and CA cert has not been read yet
  3855 			// Since there is no user certificate and CA cert has not been read yet
  4080 			// we need to read the CA cert.
  3856 			// we need to read the CA cert.
  4081 			EAP_TRACE_DEBUG(
  3857 			EAP_TRACE_DEBUG(
  4082 				m_am_tools, 
  3858 				m_am_tools, 
  4083 				TRACE_FLAGS_DEFAULT, 
  3859 				TRACE_FLAGS_DEFAULT, 
  4084 				(EAPL("query_cipher_suites_and_previous_session(): No user or CA certificate. Read CA certificate. m_allowed_ca_certs.Count()=%d\n"),
  3860 				(EAPL("query_cipher_suites_and_previous_session(): No user or CA certificate. Read CA certificate.\n")));
  4085 				m_allowed_ca_certs.Count()));
       
  4086 			
  3861 			
  4087 			if (m_allowed_ca_certs.Count() != 0)
  3862 			if (m_allowed_ca_certs.Count() != 0)
  4088 			{		
  3863 			{		
  4089 #if defined(USE_FAST_EAP_TYPE)
  3864 #if defined(USE_FAST_EAP_TYPE)
  4090 				
  3865 				
  4099 				else	
  3874 				else	
  4100 #endif // #if defined(USE_FAST_EAP_TYPE)
  3875 #endif // #if defined(USE_FAST_EAP_TYPE)
  4101 				{
  3876 				{
  4102 					m_state = EHandlingCipherSuiteQuery;
  3877 					m_state = EHandlingCipherSuiteQuery;
  4103 					
  3878 					
  4104 					TRAPD(err, m_cert_if->ReadCACertificateL(*m_allowed_ca_certs[0]));
  3879 					TRAPD(err, m_cert_if->ReadCACertificateL(m_allowed_ca_certs[0]));
  4105 					if (err != KErrNone)
  3880 					if (err != KErrNone)
  4106 					{
  3881 					{
  4107 						// Error occurred. Just select all cipher suites.
  3882 						// Error occurred. Just select all cipher suites.
  4108 						select_all_cipher_suites = true;
  3883 						select_all_cipher_suites = true;
  4109 					}
  3884 					}
  4112 						EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3887 						EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4113 						return EAP_STATUS_RETURN(m_am_tools, eap_status_pending_request);
  3888 						return EAP_STATUS_RETURN(m_am_tools, eap_status_pending_request);
  4114 					}
  3889 					}
  4115 				}
  3890 				}
  4116 			} // End: if (m_allowed_ca_certs.Count() != 0)
  3891 			} // End: if (m_allowed_ca_certs.Count() != 0)
  4117 			else
       
  4118 			{
       
  4119 				EAP_TRACE_DEBUG(
       
  4120 					m_am_tools, 
       
  4121 					TRACE_FLAGS_DEFAULT, 
       
  4122 					(EAPL("query_cipher_suites_and_previous_session(): No allowed CA certificates. Sends all cipher suites and hopes best.\n"),
       
  4123 					m_allowed_ca_certs.Count()));
       
  4124 
       
  4125 				select_all_cipher_suites = true;
       
  4126 			}
       
  4127 		}
  3892 		}
  4128 		else if (m_own_certificate != 0)
  3893 		else if (m_own_certificate != 0)
  4129 		{
  3894 		{
  4130 			EAP_TRACE_DEBUG(
  3895 			EAP_TRACE_DEBUG(
  4131 				m_am_tools, 
  3896 				m_am_tools, 
  4149 			
  3914 			
  4150 			const CSubjectPublicKeyInfo& public_key = m_ca_certificate->PublicKey();
  3915 			const CSubjectPublicKeyInfo& public_key = m_ca_certificate->PublicKey();
  4151 
  3916 
  4152 			certAlgorithm = public_key.AlgorithmId();				
  3917 			certAlgorithm = public_key.AlgorithmId();				
  4153 		}
  3918 		}
  4154 
  3919 		
  4155 
  3920 			// IF cipher suite is allowed
  4156 		status = select_cipher_suite(
  3921 		if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_RSA_WITH_3DES_EDE_CBC_SHA) != KErrNotFound
  4157 			select_all_cipher_suites,
  3922 			// AND the algorithm matches the certificates algorithm
  4158 			tls_cipher_suites_TLS_RSA_WITH_3DES_EDE_CBC_SHA,
  3923 			&& (select_all_cipher_suites == true
  4159 			certAlgorithm,
  3924 				|| certAlgorithm == ERSA))
  4160 			ERSA,
  3925 			// THEN add it to list.
  4161 			&cipher_suites);
  3926 		{
  4162 		if (status != eap_status_ok)
  3927 			u16_t *tmp_object = new u16_t;
  4163 		{
  3928 			if (tmp_object == 0)
  4164 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3929 			{
  4165 			return EAP_STATUS_RETURN(m_am_tools, status);
  3930 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4166 		}
  3931 				return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
  4167 
  3932 			}
  4168 		status = select_cipher_suite(
  3933 			*tmp_object = eap_htons(tls_cipher_suites_TLS_RSA_WITH_3DES_EDE_CBC_SHA);
  4169 			select_all_cipher_suites,
  3934 			
  4170 			tls_cipher_suites_TLS_RSA_WITH_AES_128_CBC_SHA,
  3935 			status = cipher_suites.add_object(tmp_object, true);
  4171 			certAlgorithm,
  3936 			if (status != eap_status_ok)
  4172 			ERSA,
  3937 			{
  4173 			&cipher_suites);
  3938 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4174 		if (status != eap_status_ok)
  3939 				return EAP_STATUS_RETURN(m_am_tools, status);
  4175 		{
  3940 			}
  4176 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3941 		}
  4177 			return EAP_STATUS_RETURN(m_am_tools, status);
  3942 		if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_RSA_WITH_AES_128_CBC_SHA) != KErrNotFound
  4178 		}
  3943 			// AND the algorithm matches the certificates algorithm
  4179 
  3944 			&& (select_all_cipher_suites == true
  4180 		status = select_cipher_suite(
  3945 				|| certAlgorithm == ERSA))
  4181 			select_all_cipher_suites,
  3946 			// THEN add it to list.
  4182 			tls_cipher_suites_TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA,
  3947 		{
  4183 			certAlgorithm,
  3948 			u16_t *tmp_object = new u16_t;
  4184 			EDSA,
  3949 			if (tmp_object == 0)
  4185 			&cipher_suites);
  3950 			{
  4186 		if (status != eap_status_ok)
  3951 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4187 		{
  3952 				return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
  4188 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3953 			}
  4189 			return EAP_STATUS_RETURN(m_am_tools, status);
  3954 			*tmp_object = eap_htons(tls_cipher_suites_TLS_RSA_WITH_AES_128_CBC_SHA);
  4190 		}
  3955 			
  4191 
  3956 			status = cipher_suites.add_object(tmp_object, true);
  4192 		status = select_cipher_suite(
  3957 			if (status != eap_status_ok)
  4193 			select_all_cipher_suites,
  3958 			{
  4194 			tls_cipher_suites_TLS_DHE_DSS_WITH_AES_128_CBC_SHA,
  3959 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4195 			certAlgorithm,
  3960 				return EAP_STATUS_RETURN(m_am_tools, status);
  4196 			EDSA,
  3961 			}
  4197 			&cipher_suites);
  3962 		}
  4198 		if (status != eap_status_ok)
  3963 		if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA) != KErrNotFound
  4199 		{
  3964 			// AND the algorithm matches the certificates algorithm
  4200 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3965 			&& (select_all_cipher_suites == true
  4201 			return EAP_STATUS_RETURN(m_am_tools, status);
  3966 				|| certAlgorithm == EDSA))
  4202 		}
  3967 			// THEN add it to list.
  4203 
  3968 		{
  4204 		status = select_cipher_suite(
  3969 			u16_t *tmp_object = new u16_t;
  4205 			select_all_cipher_suites,
  3970 			if (tmp_object == 0)
  4206 			tls_cipher_suites_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA,
  3971 			{
  4207 			certAlgorithm,
  3972 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4208 			ERSA,
  3973 				return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
  4209 			&cipher_suites);
  3974 			}
  4210 		if (status != eap_status_ok)
  3975 			*tmp_object = eap_htons(tls_cipher_suites_TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA);
  4211 		{
  3976 			
  4212 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3977 			status = cipher_suites.add_object(tmp_object, true);
  4213 			return EAP_STATUS_RETURN(m_am_tools, status);
  3978 			if (status != eap_status_ok)
  4214 		}
  3979 			{
  4215 
  3980 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4216 		status = select_cipher_suite(
  3981 				return EAP_STATUS_RETURN(m_am_tools, status);
  4217 			select_all_cipher_suites,
  3982 			}
  4218 			tls_cipher_suites_TLS_DHE_RSA_WITH_AES_128_CBC_SHA,
  3983 		}
  4219 			certAlgorithm,
  3984 		if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_DHE_DSS_WITH_AES_128_CBC_SHA) != KErrNotFound
  4220 			ERSA,
  3985 			// AND the algorithm matches the certificates algorithm
  4221 			&cipher_suites);
  3986 			&& (select_all_cipher_suites == true
  4222 		if (status != eap_status_ok)
  3987 				|| certAlgorithm == EDSA))
  4223 		{
  3988 			// THEN add it to list.
  4224 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3989 		{
  4225 			return EAP_STATUS_RETURN(m_am_tools, status);
  3990 			u16_t *tmp_object = new u16_t;
  4226 		}
  3991 			if (tmp_object == 0)
  4227 
  3992 			{
  4228 		status = select_cipher_suite(
  3993 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4229 			select_all_cipher_suites,
  3994 				return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
  4230 			tls_cipher_suites_TLS_RSA_WITH_RC4_128_MD5,
  3995 			}
  4231 			certAlgorithm,
  3996 			*tmp_object = eap_htons(tls_cipher_suites_TLS_DHE_DSS_WITH_AES_128_CBC_SHA);
  4232 			ERSA,
  3997 			
  4233 			&cipher_suites);
  3998 			status = cipher_suites.add_object(tmp_object, true);
  4234 		if (status != eap_status_ok)
  3999 			if (status != eap_status_ok)
  4235 		{
  4000 			{
  4236 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4001 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4237 			return EAP_STATUS_RETURN(m_am_tools, status);
  4002 				return EAP_STATUS_RETURN(m_am_tools, status);
  4238 		}
  4003 			}
  4239 
  4004 		}
  4240 		status = select_cipher_suite(
  4005 		if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA) != KErrNotFound
  4241 			select_all_cipher_suites,
  4006 			// AND the algorithm matches the certificates algorithm
  4242 			tls_cipher_suites_TLS_RSA_WITH_RC4_128_SHA,
  4007 			&& (select_all_cipher_suites == true
  4243 			certAlgorithm,
  4008 				|| certAlgorithm == ERSA))
  4244 			ERSA,
  4009 			// THEN add it to list.
  4245 			&cipher_suites);
  4010 		{
  4246 		if (status != eap_status_ok)
  4011 			u16_t *tmp_object = new u16_t;
  4247 		{
  4012 			if (tmp_object == 0)
  4248 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4013 			{
  4249 			return EAP_STATUS_RETURN(m_am_tools, status);
  4014 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4250 		}
  4015 				return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
  4251 
  4016 			}
  4252 
  4017 			*tmp_object = eap_htons(tls_cipher_suites_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA);
       
  4018 			
       
  4019 			status = cipher_suites.add_object(tmp_object, true);
       
  4020 			if (status != eap_status_ok)
       
  4021 			{
       
  4022 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  4023 				return EAP_STATUS_RETURN(m_am_tools, status);
       
  4024 			}
       
  4025 		}
       
  4026 		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
       
  4028 			&& (select_all_cipher_suites == true
       
  4029 				|| certAlgorithm == ERSA))
       
  4030 			// THEN add it to list.
       
  4031 		{
       
  4032 			u16_t *tmp_object = new u16_t;
       
  4033 			if (tmp_object == 0)
       
  4034 			{
       
  4035 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  4036 				return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  4037 			}
       
  4038 			*tmp_object = eap_htons(tls_cipher_suites_TLS_DHE_RSA_WITH_AES_128_CBC_SHA);
       
  4039 			
       
  4040 			status = cipher_suites.add_object(tmp_object, true);
       
  4041 			if (status != eap_status_ok)
       
  4042 			{
       
  4043 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  4044 				return EAP_STATUS_RETURN(m_am_tools, status);
       
  4045 			}
       
  4046 		}
       
  4047 		if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_RSA_WITH_RC4_128_MD5) != KErrNotFound
       
  4048 			// AND the algorithm matches the certificates algorithm
       
  4049 			&& (select_all_cipher_suites == true
       
  4050 				|| certAlgorithm == ERSA))
       
  4051 			// THEN add it to list.
       
  4052 		{
       
  4053 			u16_t *tmp_object = new u16_t;
       
  4054 			if (tmp_object == 0)
       
  4055 			{
       
  4056 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  4057 				return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  4058 			}
       
  4059 			*tmp_object = eap_htons(tls_cipher_suites_TLS_RSA_WITH_RC4_128_MD5);
       
  4060 			
       
  4061 			status = cipher_suites.add_object(tmp_object, true);
       
  4062 			if (status != eap_status_ok)
       
  4063 			{
       
  4064 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  4065 				return EAP_STATUS_RETURN(m_am_tools, status);
       
  4066 			}
       
  4067 		}
       
  4068 		if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_RSA_WITH_RC4_128_SHA) != KErrNotFound
       
  4069 			// AND the algorithm matches the certificates algorithm
       
  4070 			&& (select_all_cipher_suites == true
       
  4071 				|| certAlgorithm == ERSA))
       
  4072 			// THEN add it to list.)
       
  4073 		{
       
  4074 			u16_t *tmp_object = new u16_t;
       
  4075 			if (tmp_object == 0)
       
  4076 			{
       
  4077 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  4078 				return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  4079 			}
       
  4080 			*tmp_object = eap_htons(tls_cipher_suites_TLS_RSA_WITH_RC4_128_SHA);
       
  4081 			
       
  4082 			status = cipher_suites.add_object(tmp_object, true);
       
  4083 			if (status != eap_status_ok)
       
  4084 			{
       
  4085 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  4086 				return EAP_STATUS_RETURN(m_am_tools, status);
       
  4087 			}
       
  4088 		}
  4253 		
  4089 		
  4254 		if (is_session_valid())
  4090 		if (is_session_valid())
  4255 		{
  4091 		{
  4256 			EAP_TRACE_DEBUG(
  4092 			EAP_TRACE_DEBUG(
  4257 				m_am_tools,
  4093 				m_am_tools,
  4345 	  //		m_serv_unauth_prov_mode == true)
  4181 	  //		m_serv_unauth_prov_mode == true)
  4346  
  4182  
  4347 
  4183 
  4348 	// Compression methods. TLS supports only null compression at the moment.
  4184 	// Compression methods. TLS supports only null compression at the moment.
  4349 	eap_array_c<u8_t> compression_methods(m_am_tools);
  4185 	eap_array_c<u8_t> compression_methods(m_am_tools);
  4350 
       
  4351 	{
  4186 	{
  4352 		u8_t *tmp_object = new u8_t;
  4187 		u8_t *tmp_object = new u8_t;
  4353 		if (tmp_object == 0)
  4188 		if (tmp_object == 0)
  4354 		{
  4189 		{
  4355 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4190 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4356 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
  4191 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
  4357 		}
  4192 		}
  4358 		*tmp_object = tls_compression_method_null;
  4193 		*tmp_object = tls_compression_method_null;
  4359 
       
  4360 		status = compression_methods.add_object(tmp_object, true);
  4194 		status = compression_methods.add_object(tmp_object, true);
  4361 		if (status != eap_status_ok)
  4195 		if (status != eap_status_ok)
  4362 		{
  4196 		{
  4363 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4197 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4364 			return EAP_STATUS_RETURN(m_am_tools, status);
  4198 			return EAP_STATUS_RETURN(m_am_tools, status);
  4365 		}
  4199 		}
  4366 	}
  4200 	}
  4367 
       
  4368 
  4201 
  4369 	status = get_tls_am_partner()->complete_query_cipher_suites_and_previous_session(
  4202 	status = get_tls_am_partner()->complete_query_cipher_suites_and_previous_session(
  4370 		tls_session_type,
  4203 		tls_session_type,
  4371 		&cipher_suites,
  4204 		&cipher_suites,
  4372 		&compression_methods,
  4205 		&compression_methods,
  4609 	EAP_TEMPLATE_CONST eap_array_c<eap_variable_data_c> * const certificate_chain,
  4442 	EAP_TEMPLATE_CONST eap_array_c<eap_variable_data_c> * const certificate_chain,
  4610 	const tls_cipher_suites_e required_cipher_suite)
  4443 	const tls_cipher_suites_e required_cipher_suite)
  4611 {
  4444 {
  4612 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  4445 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  4613 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("\n")));
  4446 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("\n")));
  4614 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("TLS: %s: message_function: verify_certificate_chain()\n"),
  4447 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("TLS: %s: message_function: verify_certificate_chain_and_query_public_key()\n"),
  4615 		(m_is_client == true ? "client": "server")));
  4448 		(m_is_client == true ? "client": "server")));
  4616 
       
  4617 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_type_tls_peap_symbian_c::verify_certificate_chain()");
       
  4618 
  4449 
  4619 	EAP_ASSERT_ALWAYS(certificate_chain->get_object_count() > 0);
  4450 	EAP_ASSERT_ALWAYS(certificate_chain->get_object_count() > 0);
  4620 
  4451 
  4621 	eap_status_e status(eap_status_ok);
  4452 	eap_status_e status(eap_status_ok);
  4622 
  4453 
  4634 	}
  4465 	}
  4635 
  4466 
  4636 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4467 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4637 	return EAP_STATUS_RETURN(m_am_tools, status);
  4468 	return EAP_STATUS_RETURN(m_am_tools, status);
  4638 }
  4469 }
  4639 
       
  4640 //--------------------------------------------------
       
  4641 
  4470 
  4642 void eap_am_type_tls_peap_symbian_c::verify_certificate_chainL(
  4471 void eap_am_type_tls_peap_symbian_c::verify_certificate_chainL(
  4643 	EAP_TEMPLATE_CONST eap_array_c<eap_variable_data_c> * const certificate_chain,
  4472 	EAP_TEMPLATE_CONST eap_array_c<eap_variable_data_c> * const certificate_chain,
  4644 	const tls_cipher_suites_e required_cipher_suite)
  4473 	const tls_cipher_suites_e required_cipher_suite)
  4645 {
  4474 {
  4646 	EAP_TRACE_DEBUG(
  4475 	EAP_TRACE_DEBUG(m_am_tools, 
  4647 		m_am_tools, 
  4476 	TRACE_FLAGS_DEFAULT, 
  4648 		TRACE_FLAGS_DEFAULT, 
  4477 	(EAPL("eap_am_type_tls_peap_symbian_c::verify_certificate_chainL: Number of certificates in chain=%d\n"),
  4649 		(EAPL("eap_am_type_tls_peap_symbian_c::verify_certificate_chainL(): Number of certificates in chain=%d\n"),
       
  4650 		certificate_chain->get_object_count()));
  4478 		certificate_chain->get_object_count()));
  4651 
       
  4652 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_type_tls_peap_symbian_c::verify_certificate_chainL()");
       
  4653 
  4479 
  4654 	eap_status_e status(eap_status_process_general_error);
  4480 	eap_status_e status(eap_status_process_general_error);
  4655 	if (m_is_client)
  4481 	if (m_is_client)
  4656 	{
  4482 	{
  4657 		m_cipher_suite = required_cipher_suite;
  4483 		m_cipher_suite = required_cipher_suite;
  4664 		&& m_verify_certificate_realm == true
  4490 		&& m_verify_certificate_realm == true
  4665 		&& (m_own_certificate != 0
  4491 		&& (m_own_certificate != 0
  4666 			|| (m_use_manual_realm == true
  4492 			|| (m_use_manual_realm == true
  4667 				&& m_manual_realm.get_is_valid_data() == true)))
  4493 				&& m_manual_realm.get_is_valid_data() == true)))
  4668 	{
  4494 	{
  4669 		EAP_TRACE_DEBUG(
       
  4670 			m_am_tools, 
       
  4671 			TRACE_FLAGS_DEFAULT, 
       
  4672 			(EAPL("eap_am_type_tls_peap_symbian_c::verify_certificate_chainL(): Does server certificate realm verification\n")));
       
  4673 
       
  4674 		eap_variable_data_c client_subject_realm(m_am_tools);
  4495 		eap_variable_data_c client_subject_realm(m_am_tools);
  4675 		eap_variable_data_c manual_client_subject_realm(m_am_tools);
  4496 		eap_variable_data_c manual_client_subject_realm(m_am_tools);
  4676 		eap_variable_data_c client_issuer_realm(m_am_tools);
  4497 		eap_variable_data_c client_issuer_realm(m_am_tools);
  4677 
  4498 
  4678 		if (m_own_certificate != 0)
  4499 		if (m_own_certificate != 0)
  4882 
  4703 
  4883 					User::Leave(KErrArgument);
  4704 					User::Leave(KErrArgument);
  4884 				}
  4705 				}
  4885 			}
  4706 			}
  4886 		}
  4707 		}
  4887 
       
  4888 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Server certificate realm verification OK.\n")));
  4708 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Server certificate realm verification OK.\n")));
  4889 	}
  4709 	}
  4890 	else
  4710 
  4891 	{
  4711 	HBufC8* chain = HBufC8::NewL(0);
  4892 		EAP_TRACE_DEBUG(
       
  4893 			m_am_tools, 
       
  4894 			TRACE_FLAGS_DEFAULT, 
       
  4895 			(EAPL("eap_am_type_tls_peap_symbian_c::verify_certificate_chainL(): No server certificate realm verification\n")));
       
  4896 	}
       
  4897 
       
  4898 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       
  4899 
       
  4900 	HBufC8* chain = HBufC8::NewL(1);
       
  4901 
       
  4902 	EAP_TRACE_DEBUG(
       
  4903 		m_am_tools, 
       
  4904 		TRACE_FLAGS_DEFAULT, 
       
  4905 		(EAPL("eap_am_type_tls_peap_symbian_c::verify_certificate_chainL(): Calls CleanupStack::PushL(chain)\n")));
       
  4906 
       
  4907 	CleanupStack::PushL(chain);
       
  4908 	chain->Des().SetLength(0);
       
  4909 
       
  4910 	HBufC8* temp;
  4712 	HBufC8* temp;
  4911 	eap_variable_data_c* cert;
  4713 	eap_variable_data_c* cert;
  4912 	
  4714 	
  4913 	for (u32_t i = 0; i < certificate_chain->get_object_count(); i++)
  4715 	for (u32_t i = 0; i < certificate_chain->get_object_count(); i++)
  4914 	{
  4716 	{
  4924 			User::Leave(KErrArgument);		
  4726 			User::Leave(KErrArgument);		
  4925 		}
  4727 		}
  4926 	
  4728 	
  4927 #if defined(_DEBUG) || defined(DEBUG)
  4729 #if defined(_DEBUG) || defined(DEBUG)
  4928 
  4730 
  4929 		{
  4731 		TPtr8 certPtr(
  4930 			TPtr8 certPtr(
  4732 			cert->get_data(cert->get_data_length()), 
  4931 				cert->get_data(cert->get_data_length()), 
  4733 			cert->get_data_length(),
  4932 				cert->get_data_length(),
  4734 			cert->get_data_length());
  4933 				cert->get_data_length());
  4735 		CX509Certificate* x509Cert = CX509Certificate::NewL(certPtr);
  4934 
  4736 
  4935 			CX509Certificate* x509Cert = CX509Certificate::NewL(certPtr);
  4737 		if( x509Cert != NULL )
  4936 
  4738 		{				
  4937 			if( x509Cert != NULL )
  4739 			CleanupStack::PushL(x509Cert);
  4938 			{				
  4740 
  4939 				CleanupStack::PushL(x509Cert);
  4741 			TKeyIdentifier KeyIdentifier = x509Cert->KeyIdentifierL();
  4940 
  4742 			
  4941 				TKeyIdentifier KeyIdentifier = x509Cert->KeyIdentifierL();
  4743 			EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Key identifier is"),
       
  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()));					
  4942 				
  4758 				
  4943 				EAP_TRACE_DATA_DEBUG(
  4759 				CleanupStack::PopAndDestroy(); // subKeyExt					
  4944 					m_am_tools,
  4760 			}
  4945 					TRACE_FLAGS_DEFAULT,
  4761 			else
  4946 					(EAPL("Key identifier is"),
  4762 			{
  4947 					KeyIdentifier.Ptr(),
  4763 				EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: verify_certificate_chainL - No extension for this certificate\n")));			
  4948 					KeyIdentifier.Size()));
  4764 			}
  4949 									
  4765 			
  4950 				// This is for subject key id.
  4766 			CleanupStack::PopAndDestroy(x509Cert);
  4951 				const CX509CertExtension* certExt = x509Cert->Extension(KSubjectKeyId);
  4767 		}
  4952 				
  4768 
  4953 				if (certExt)
       
  4954 				{
       
  4955 					const CX509SubjectKeyIdExt* subKeyExt = CX509SubjectKeyIdExt::NewLC(certExt->Data());
       
  4956 					EAP_UNREFERENCED_PARAMETER(subKeyExt);
       
  4957 
       
  4958 					EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("The Subject key Id is:"),
       
  4959 						subKeyExt->KeyId().Ptr(),
       
  4960 						subKeyExt->KeyId().Size()));					
       
  4961 					
       
  4962 					CleanupStack::PopAndDestroy();
       
  4963 				}
       
  4964 				else
       
  4965 				{
       
  4966 					EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: verify_certificate_chainL - No extension for this certificate\n")));			
       
  4967 				}
       
  4968 				
       
  4969 				CleanupStack::PopAndDestroy();
       
  4970 			}
       
  4971 		}
       
  4972 #endif
  4769 #endif
  4973 
  4770 
       
  4771 		CleanupStack::PushL(chain);
  4974 		temp = chain->ReAllocL(chain->Length() + cert->get_data_length());
  4772 		temp = chain->ReAllocL(chain->Length() + cert->get_data_length());
  4975 
       
  4976 		CleanupStack::Pop(chain);
       
  4977 
       
  4978 		chain = temp;
  4773 		chain = temp;
  4979 
       
  4980 		CleanupStack::PushL(chain);
       
  4981 
       
  4982 		TPtr8 ptr = chain->Des();
  4774 		TPtr8 ptr = chain->Des();
  4983 
       
  4984 		ptr.Append(cert->get_data(cert->get_data_length()), cert->get_data_length());
  4775 		ptr.Append(cert->get_data(cert->get_data_length()), cert->get_data_length());
  4985 		if (i == 0)
  4776 		if (i == 0)
  4986 		{
  4777 		{
  4987 			// This is the peer certificate. Save it.
  4778 			// This is the peer certificate. Save it.
  4988 			if (m_peer_certificate != 0)
  4779 			if (m_peer_certificate != 0)
  4989 			{
  4780 			{
  4990 				delete m_peer_certificate;
  4781 				delete m_peer_certificate;
  4991 			}
  4782 			}
  4992 			m_peer_certificate = CX509Certificate::NewL(ptr);
  4783 			m_peer_certificate = CX509Certificate::NewL(ptr);
  4993 		}
  4784 		}
  4994 
  4785 		CleanupStack::Pop();
  4995 	} // for()
  4786 	}
  4996 
  4787 	CleanupStack::PushL(chain);
  4997 
       
  4998 	EAP_TRACE_DEBUG(
       
  4999 		m_am_tools, 
       
  5000 		TRACE_FLAGS_DEFAULT, 
       
  5001 		(EAPL("eap_am_type_tls_peap_symbian_c::verify_certificate_chainL(): calls chain->Des()\n")));
       
  5002 
       
  5003 	TPtr8 certChain = chain->Des();
  4788 	TPtr8 certChain = chain->Des();
  5004 	TBool aUseAutomaticCaCertificate = (m_use_automatic_ca_certificate == true) ? ETrue : EFalse;
  4789 	m_cert_if->ValidateChainL(certChain, m_allowed_ca_certs);
  5005 
  4790 	
  5006 	EAP_TRACE_DEBUG(
  4791 	CleanupStack::PopAndDestroy();
  5007 		m_am_tools, 
       
  5008 		TRACE_FLAGS_DEFAULT, 
       
  5009 		(EAPL("eap_am_type_tls_peap_symbian_c::verify_certificate_chainL(): calls m_cert_if->ValidateChainL()\n")));
       
  5010 
       
  5011 	m_cert_if->ValidateChainL(certChain, m_allowed_ca_certs, aUseAutomaticCaCertificate);
       
  5012 	
       
  5013 	CleanupStack::PopAndDestroy(chain);
       
  5014 
       
  5015 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4792 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5016 
       
  5017 	// This returns eap_status_pending_request
  4793 	// This returns eap_status_pending_request
  5018 	User::Leave(KErrCompletion);
  4794 	User::Leave(KErrCompletion);
  5019 
  4795 
  5020 }
  4796 }
  5021 
  4797 
  5022 //--------------------------------------------------
       
  5023 
       
  5024 #if defined(USE_EAP_DEBUG_TRACE)
       
  5025 
       
  5026 static eap_const_string get_certificate_error_string(const enum TValidationError certificate_error)
       
  5027 {
       
  5028 #if defined(USE_EAP_TRACE_STRINGS)
       
  5029 	EAP_IF_RETURN_STRING(certificate_error, EValidatedOK)
       
  5030 	else EAP_IF_RETURN_STRING(certificate_error, EChainHasNoRoot)
       
  5031 	else EAP_IF_RETURN_STRING(certificate_error, ESignatureInvalid)
       
  5032 	else EAP_IF_RETURN_STRING(certificate_error, EDateOutOfRange)
       
  5033 	else EAP_IF_RETURN_STRING(certificate_error, ENameIsExcluded)
       
  5034 	else EAP_IF_RETURN_STRING(certificate_error, ENameNotPermitted)
       
  5035 	else EAP_IF_RETURN_STRING(certificate_error, ENotCACert)
       
  5036 	else EAP_IF_RETURN_STRING(certificate_error, ECertificateRevoked)
       
  5037 	else EAP_IF_RETURN_STRING(certificate_error, EUnrecognizedCriticalExtension)
       
  5038 	else EAP_IF_RETURN_STRING(certificate_error, ENoBasicConstraintInCACert)
       
  5039 	else EAP_IF_RETURN_STRING(certificate_error, ENoAcceptablePolicy)
       
  5040 	else EAP_IF_RETURN_STRING(certificate_error, EPathTooLong)
       
  5041 	else EAP_IF_RETURN_STRING(certificate_error, ENegativePathLengthSpecified)
       
  5042 	else EAP_IF_RETURN_STRING(certificate_error, ENamesDontChain)
       
  5043 	else EAP_IF_RETURN_STRING(certificate_error, ERequiredPolicyNotFound)
       
  5044 	else EAP_IF_RETURN_STRING(certificate_error, EBadKeyUsage)
       
  5045 	else EAP_IF_RETURN_STRING(certificate_error, ERootCertNotSelfSigned)
       
  5046 	else EAP_IF_RETURN_STRING(certificate_error, ECriticalExtendedKeyUsage)
       
  5047 	else EAP_IF_RETURN_STRING(certificate_error, ECriticalCertPoliciesWithQualifiers)
       
  5048 	else EAP_IF_RETURN_STRING(certificate_error, ECriticalPolicyMapping)
       
  5049 	else EAP_IF_RETURN_STRING(certificate_error, ECriticalDeviceId)
       
  5050 	else EAP_IF_RETURN_STRING(certificate_error, ECriticalSid)
       
  5051 	else EAP_IF_RETURN_STRING(certificate_error, ECriticalVid)
       
  5052 	else EAP_IF_RETURN_STRING(certificate_error, ECriticalCapabilities)
       
  5053 #endif // #if defined(USE_EAP_TRACE_STRINGS)
       
  5054 	{
       
  5055 		EAP_UNREFERENCED_PARAMETER(certificate_error);
       
  5056 		return EAPL("Unknown TValidationError");
       
  5057 	}
       
  5058 }
       
  5059 
       
  5060 #endif //#if defined(USE_EAP_DEBUG_TRACE)
       
  5061 
       
  5062 //--------------------------------------------------
       
  5063 
  4798 
  5064 void eap_am_type_tls_peap_symbian_c::complete_validate_chain(
  4799 void eap_am_type_tls_peap_symbian_c::complete_validate_chain(
  5065 	const CPKIXValidationResult * const aValidationResult,
  4800 	CPKIXValidationResult& aValidationResult, eap_status_e aStatus)
  5066 	const eap_status_e aStatus)
       
  5067 {
  4801 {
  5068 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  4802 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  5069 
  4803 	
  5070 	TValidationError validationError(EBadKeyUsage);
       
  5071 
       
  5072 	if (aValidationResult != 0)
       
  5073 	{
       
  5074 		validationError = aValidationResult->Error().iReason;
       
  5075 	}
       
  5076 
       
  5077 	EAP_TRACE_DEBUG(
       
  5078 		m_am_tools,
       
  5079 		TRACE_FLAGS_DEFAULT,
       
  5080 		(EAPL("eap_am_type_tls_peap_symbian_c::complete_validate_chain(): Certificate chain validation reason=%d=%s, status=%d=%s\n"),
       
  5081 		validationError,
       
  5082 		get_certificate_error_string(validationError),
       
  5083 		aStatus,
       
  5084 		eap_status_string_c::get_status_string(aStatus)));
       
  5085 
       
  5086 	if(aStatus != eap_status_ok)
  4804 	if(aStatus != eap_status_ok)
  5087 	{
  4805 	{
  5088 		get_tls_am_partner()->complete_verify_certificate_chain(aStatus);
  4806 		get_tls_am_partner()->complete_verify_certificate_chain(aStatus);
  5089 		return;
  4807 		return;
  5090 	}
  4808 	}
  5091 
  4809 	
  5092 	eap_status_e result(eap_status_ok);
  4810 	eap_status_e result;	
  5093 
  4811 	if (aValidationResult.Error().iReason == EValidatedOK) 
  5094 	if (validationError == EValidatedOK)
  4812 	{
  5095 	{
  4813 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, 
  5096 		EAP_TRACE_DEBUG(
  4814 			(EAPL("Certificate chain validation OK. Reason: %d\n"), 
  5097 			m_am_tools,
  4815 			aValidationResult.Error().iReason));
  5098 			TRACE_FLAGS_DEFAULT,
       
  5099 			(EAPL("Certificate chain validation OK. Reason: %d=%s\n"),
       
  5100 			validationError,
       
  5101 			get_certificate_error_string(validationError)));
       
  5102 
       
  5103 		result = eap_status_ok;
  4816 		result = eap_status_ok;
  5104 	}
  4817 	}
  5105 	else
  4818 	else
  5106 	{
  4819 	{
  5107 		if (validationError == EDateOutOfRange)
  4820 		if (aValidationResult.Error().iReason == EDateOutOfRange)
  5108 		{
  4821 		{
  5109 			send_error_notification(eap_status_certificate_expired);
  4822 			send_error_notification(eap_status_certificate_expired);
  5110 			// Ignore error on purpose
  4823 			// Ignore error on purpose
  5111 		}
  4824 		}
  5112 		else
  4825 		else
  5113 		{
  4826 		{
  5114 			send_error_notification(eap_status_illegal_certificate);
  4827 			send_error_notification(eap_status_illegal_certificate);
  5115 			// Ignore error on purpose			
  4828 			// Ignore error on purpose			
  5116 		}
  4829 		}
  5117 
  4830 
  5118 		EAP_TRACE_DEBUG(
  4831 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, 
  5119 			m_am_tools,
  4832 			(EAPL("ERROR: Certificate chain validation FAILED. Reason: %d\n"), 
  5120 			TRACE_FLAGS_DEFAULT, 
  4833 			aValidationResult.Error().iReason));
  5121 			(EAPL("ERROR: Certificate chain validation FAILED. Reason: %d=%s\n"), 
       
  5122 			validationError,
       
  5123 			get_certificate_error_string(validationError)));
       
  5124 			
  4834 			
  5125 		result = eap_status_illegal_certificate;
  4835 		result = eap_status_illegal_certificate;
  5126 	}
  4836 	}
  5127 
  4837 
  5128 	// Copy the public key
  4838 	// Copy the public key
  5139 
  4849 
  5140 	get_tls_am_partner()->complete_verify_certificate_chain(result);
  4850 	get_tls_am_partner()->complete_verify_certificate_chain(result);
  5141 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4851 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5142 }
  4852 }
  5143 
  4853 
  5144 //--------------------------------------------------
       
  5145 
       
  5146 #if defined(USE_FAST_EAP_TYPE)
  4854 #if defined(USE_FAST_EAP_TYPE)
  5147 #if defined(USE_EAP_CONFIGURATION_TO_SKIP_USER_INTERACTIONS)
  4855 #if defined(USE_EAP_CONFIGURATION_TO_SKIP_USER_INTERACTIONS)
  5148 
       
  5149 eap_status_e eap_am_type_tls_peap_symbian_c::ReadFileConfig()
  4856 eap_status_e eap_am_type_tls_peap_symbian_c::ReadFileConfig()
  5150 {
  4857     {
  5151 	eap_status_e status = eap_status_ok;
  4858         eap_status_e status = eap_status_ok;
  5152 
  4859         
  5153 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  4860         eap_am_file_input_symbian_c * const fileio = new eap_am_file_input_symbian_c(m_am_tools);
  5154 
  4861 
  5155 	status = EapConfigToolsSymbian::EapReadDefaultConfigFileSymbian(
  4862         eap_automatic_variable_c<eap_am_file_input_symbian_c> automatic_fileio(m_am_tools, fileio);
  5156 	m_am_tools,
  4863 
  5157 	&m_fileconfig);
  4864         if (fileio != 0
  5158 	if (status != eap_status_ok)
  4865             && fileio->get_is_valid() == true)
  5159 	{
  4866         {
  5160 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4867             EAP_TRACE_DEBUG(
  5161 		return EAP_STATUS_RETURN(m_am_tools, status);
  4868                 m_am_tools,
  5162 	}
  4869                 TRACE_FLAGS_DEFAULT,
  5163 
  4870                 (EAPL("Initialize file configuration.\n")));
  5164 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  4871 
  5165 
  4872             eap_variable_data_c file_name_c_data(m_am_tools);
  5166 
  4873 
  5167 	eap_variable_data_c skip_user_interactions(m_am_tools);
  4874              {
  5168 
  4875                 #if defined(EAPOL_SYMBIAN_VERSION_7_0_s)
  5169 	if (m_fileconfig != 0
  4876                     eap_const_string const FILECONFIG_FILENAME_C
  5170 	&& m_fileconfig->get_is_valid() == true)
  4877                         = "c:\\system\\data\\eap.conf";
  5171 	{
  4878                 #else
  5172 		// Here we could try the final configuration option.
  4879                     eap_const_string const FILECONFIG_FILENAME_C
  5173 		status = m_fileconfig->read_configure(
  4880                         = "c:\\private\\101F8EC5\\eap.conf";
  5174 			cf_str_EAP_skip_user_interactions_for_testing_purposes.get_field(),
  4881                 #endif
  5175 			&skip_user_interactions);
  4882 
  5176 	}
  4883                 status = file_name_c_data.set_copy_of_buffer(
  5177 
  4884                     FILECONFIG_FILENAME_C,
  5178 	if (status == eap_status_ok
  4885                     m_am_tools->strlen(FILECONFIG_FILENAME_C));
  5179 	&& skip_user_interactions.get_is_valid_data() == true)
  4886                 if (status != eap_status_ok)
  5180 	{
  4887                 {
  5181 		u32_t *skip_user_interactions_flag = reinterpret_cast<u32_t *>(
  4888                     EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5182 			skip_user_interactions.get_data(sizeof(u32_t)));
  4889                     return EAP_STATUS_RETURN(m_am_tools, status);
  5183 		if (skip_user_interactions_flag != 0)
  4890                 }
  5184 		{
  4891 
  5185 			if (*skip_user_interactions_flag != 0)
  4892                 status = file_name_c_data.add_end_null();
  5186 			{
  4893                 if (status != eap_status_ok)
  5187 				m_skip_user_interactions = true;
  4894                 {
  5188 			}
  4895                     EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5189 			else
  4896                     return EAP_STATUS_RETURN(m_am_tools, status);
  5190 			{
  4897                 }
  5191 				m_skip_user_interactions = false;
  4898             }
  5192 			}
  4899 
  5193 		}
  4900             eap_variable_data_c file_name_z_data(m_am_tools);
  5194 	}
  4901 
  5195 
  4902             {
  5196 	iPacStoreDb->SkipUserActions(m_skip_user_interactions);        
  4903                 #if defined(EAPOL_SYMBIAN_VERSION_7_0_s)
  5197 
  4904                     eap_const_string const FILECONFIG_FILENAME_Z
  5198 	return status;
  4905                         = "z:\\system\\data\\eap.conf";
  5199 }
  4906                 #else
  5200 
  4907                     eap_const_string const FILECONFIG_FILENAME_Z
       
  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     }
  5201 #endif //#if defined(USE_EAP_CONFIGURATION_TO_SKIP_USER_INTERACTIONS)
  5051 #endif //#if defined(USE_EAP_CONFIGURATION_TO_SKIP_USER_INTERACTIONS)
  5202 #endif
  5052 #endif
  5203 
  5053 
  5204 
  5054 
  5205 //--------------------------------------------------
  5055 //--------------------------------------------------
  5220 	m_state = EHandlingChainQuery;
  5070 	m_state = EHandlingChainQuery;
  5221 	TInt err(KErrNone);
  5071 	TInt err(KErrNone);
  5222 
  5072 
  5223 	if (m_is_client)
  5073 	if (m_is_client)
  5224 	{
  5074 	{
  5225 		// client
  5075 		// Get the matching certificates
  5226 		// Get the matching certificates. This function call is completed asyncronously by complete_get_matching_certificates() function call.
       
  5227 		TRAPD(err, m_cert_if->GetMatchingCertificatesL(
  5076 		TRAPD(err, m_cert_if->GetMatchingCertificatesL(
  5228 			m_allowed_user_certs, 
  5077 			m_allowed_user_certs, 
  5229 			ETrue, 
  5078 			ETrue, 
  5230 			certificate_authorities, 
  5079 			certificate_authorities, 
  5231 			ETrue, 
  5080 			ETrue, 
  5236 		(void)EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(err));
  5085 		(void)EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(err));
  5237 	}
  5086 	}
  5238 	else
  5087 	else
  5239 	{
  5088 	{
  5240 		// server
  5089 		// server
  5241 		// Get the matching certificates. This function call is completed asyncronously by complete_get_matching_certificates() function call.
       
  5242 		TRAPD(err, m_cert_if->GetMatchingCertificatesL(
  5090 		TRAPD(err, m_cert_if->GetMatchingCertificatesL(
  5243 				m_allowed_user_certs, 
  5091 				m_allowed_user_certs, 
  5244 				EFalse, 
  5092 				EFalse, 
  5245 				0, 
  5093 				0, 
  5246 				EFalse, 
  5094 				EFalse, 
  5266 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5114 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5267 	return EAP_STATUS_RETURN(m_am_tools, status);
  5115 	return EAP_STATUS_RETURN(m_am_tools, status);
  5268 
  5116 
  5269 }
  5117 }
  5270 
  5118 
  5271 //--------------------------------------------------
       
  5272 
       
  5273 void eap_am_type_tls_peap_symbian_c::complete_get_matching_certificates(
  5119 void eap_am_type_tls_peap_symbian_c::complete_get_matching_certificates(
  5274 	RPointerArray<EapCertificateEntry>& aMatchingCerts,
  5120 	CArrayFixFlat<SCertEntry>& aMatchingCerts,
  5275 	eap_status_e aStatus)
  5121 	eap_status_e aStatus)
  5276 {
  5122 {
  5277 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  5123 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  5278 
  5124 
  5279 	EAP_UNREFERENCED_PARAMETER(aStatus);
  5125 	EAP_UNREFERENCED_PARAMETER(aStatus);
  5290 			TRACE_FLAGS_DEFAULT,
  5136 			TRACE_FLAGS_DEFAULT,
  5291 			(EAPL("eap_am_type_tls_peap_symbian_c::complete_get_matching_certificates(): EHandlingIdentityQuery\n")));
  5137 			(EAPL("eap_am_type_tls_peap_symbian_c::complete_get_matching_certificates(): EHandlingIdentityQuery\n")));
  5292 
  5138 
  5293 		// Add found certs to allowed certificate list.
  5139 		// Add found certs to allowed certificate list.
  5294 		// This list is updated here because there might be certificates that have been removed.
  5140 		// This list is updated here because there might be certificates that have been removed.
  5295 		m_allowed_user_certs.ResetAndDestroy();
  5141 		m_allowed_user_certs.Reset();
  5296 
  5142 		for (TInt i = 0; i < aMatchingCerts.Count(); i++)
  5297 		for (TInt i = 0; i < aMatchingCerts.Count() && aMatchingCerts[i] != 0; i++)
  5143 		{
  5298 		{
  5144 			TRAPD(err, m_allowed_user_certs.AppendL(aMatchingCerts[i]));
  5299 			EapCertificateEntry * const entry = aMatchingCerts[i]->Copy();
  5145 			if (err != KErrNone)
  5300 			if (entry == 0)
       
  5301 			{
  5146 			{
  5302 				EAP_TRACE_DEBUG(
  5147 				EAP_TRACE_DEBUG(
  5303 					m_am_tools,
  5148 					m_am_tools,
  5304 					TRACE_FLAGS_DEFAULT,
  5149 					TRACE_FLAGS_DEFAULT,
  5305 					(EAPL("ERROR: EAP-TLS: No memory.\n")));
  5150 					(EAPL("ERROR: eap_am_type_tls_peap_symbian_c::complete_get_matching_certificates -EHandlingIdentityQuery- Error=%d\n"),
  5306 
  5151 					err));
       
  5152 			
  5307 				get_am_partner()->complete_eap_identity_query(
  5153 				get_am_partner()->complete_eap_identity_query(
  5308 					0, // 0 because identity query failed
  5154 					0, // 0 because identity query failed
  5309 					&m_receive_network_id,
  5155 					&m_receive_network_id,
  5310 					m_eap_identifier,
  5156 					m_eap_identifier,
  5311 					eap_status_allocation_error, 
  5157 					eap_status_allocation_error, 
  5312 					false, 
  5158 					false, 
  5313 					0, 
  5159 					0, 
  5314 					false, 
  5160 					false, 
  5315 					0);
  5161 					0);
  5316 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  5317 				return;	
       
  5318 			}
       
  5319 
       
  5320 			TInt error = m_allowed_user_certs.Append(entry);
       
  5321 			if (error != KErrNone)
       
  5322 			{
       
  5323 				EAP_TRACE_DEBUG(
       
  5324 					m_am_tools,
       
  5325 					TRACE_FLAGS_DEFAULT,
       
  5326 					(EAPL("ERROR: eap_am_type_tls_peap_symbian_c::complete_get_matching_certificates(): -EHandlingIdentityQuery- Error=%d\n"),
       
  5327 					error));
       
  5328 			
       
  5329 				get_am_partner()->complete_eap_identity_query(
       
  5330 					0, // 0 because identity query failed
       
  5331 					&m_receive_network_id,
       
  5332 					m_eap_identifier,
       
  5333 					eap_status_allocation_error, 
       
  5334 					false, 
       
  5335 					0, 
       
  5336 					false, 
       
  5337 					0);
       
  5338 
       
  5339 				delete entry;
       
  5340 				
  5162 				
  5341 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
  5163 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
  5342 				return;		
  5164 				return;		
  5343 			}
  5165 			}
  5344 		}
  5166 		}
  5376 				// Since there is no user certificate or manual realm configured
  5198 				// Since there is no user certificate or manual realm configured
  5377 				// the realm needs to be dig out from the CA certificate.
  5199 				// the realm needs to be dig out from the CA certificate.
  5378 				EAP_TRACE_DEBUG(
  5200 				EAP_TRACE_DEBUG(
  5379 					m_am_tools, 
  5201 					m_am_tools, 
  5380 					TRACE_FLAGS_DEFAULT, 
  5202 					TRACE_FLAGS_DEFAULT, 
  5381 					(EAPL("eap_am_type_tls_peap_symbian_c::complete_get_matching_certificates(): no manual realm - no user cert. Get realm from CA certificate.\n")));
  5203 					(EAPL("eap_am_type_tls_peap_symbian_c: no manual realm - no user cert. Get realm from CA certificate.\n")));
  5382 				
  5204 				
  5383 				TInt allowed_ca_cert_count = m_allowed_ca_certs.Count();
  5205 				TInt allowed_ca_cert_count = m_allowed_ca_certs.Count();
  5384 				TInt err(KErrNone);
  5206 				TInt err(KErrNone);
  5385 
  5207 				
  5386 				if(allowed_ca_cert_count > 0)
  5208 				if(allowed_ca_cert_count > 0)
  5387 				{
  5209 				{
  5388 					TRAP(err, m_cert_if->ReadCACertificateL(*m_allowed_ca_certs[0]));
  5210 					TRAP(err, m_cert_if->ReadCACertificateL(m_allowed_ca_certs[0]));
  5389 				}
  5211 				}
  5390 
  5212 				if (err != KErrNone || allowed_ca_cert_count <= 0)
  5391 				if (err != KErrNone
       
  5392 					|| allowed_ca_cert_count <= 0)
       
  5393 				{
  5213 				{
  5394 					if (m_use_automatic_ca_certificate == false)
  5214 					EAP_TRACE_DEBUG(
  5395 					{
  5215 					m_am_tools,
  5396 						EAP_TRACE_DEBUG(
  5216 					TRACE_FLAGS_DEFAULT,
  5397 							m_am_tools,
  5217 					(EAPL("ERROR: EAP-TLS: Cannot read user certificate or No CA cert configured, CA cert count=%d.\n"),
  5398 							TRACE_FLAGS_DEFAULT,
  5218 					allowed_ca_cert_count));
  5399 							(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"),
  5219 
  5400 							allowed_ca_cert_count));
  5220 					get_am_partner()->complete_eap_identity_query(
  5401 
  5221 						0, // 0 because identity query failed
  5402 						get_am_partner()->complete_eap_identity_query(
  5222 						&m_receive_network_id,
  5403 							0, // 0 because identity query failed
  5223 						m_eap_identifier,
  5404 							&m_receive_network_id,
  5224 						eap_status_illegal_certificate, 
  5405 							m_eap_identifier,
  5225 						false, 
  5406 							eap_status_illegal_certificate, 
  5226 						0, 
  5407 							false, 
  5227 						false, 
  5408 							0, 
  5228 						0);
  5409 							false, 
  5229 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5410 							0);
  5230 					return;	
  5411 
       
  5412 						EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  5413 						return;
       
  5414 					}
       
  5415 					else
       
  5416 					{
       
  5417 						EAP_TRACE_DEBUG(
       
  5418 							m_am_tools,
       
  5419 							TRACE_FLAGS_DEFAULT,
       
  5420 							(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"),
       
  5421 							m_allowed_ca_certs.Count()));
       
  5422 
       
  5423 						get_am_partner()->complete_eap_identity_query(
       
  5424 							0, // 0 because certificate query failed
       
  5425 							&m_receive_network_id,
       
  5426 							m_eap_identifier,
       
  5427 							eap_status_ok, 
       
  5428 							false, 
       
  5429 							0, 
       
  5430 							false, 
       
  5431 							0);
       
  5432 					}
       
  5433 				}
  5231 				}
  5434 
       
  5435 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5232 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5436 				return;
  5233 				return;
  5437 			}
  5234 			}
  5438 			else
  5235 			else
  5439 			{
  5236 			{
  5441 					m_am_tools,
  5238 					m_am_tools,
  5442 					TRACE_FLAGS_DEFAULT,
  5239 					TRACE_FLAGS_DEFAULT,
  5443 					(EAPL("EAP-TLS: Uses manual realm.\n")));
  5240 					(EAPL("EAP-TLS: Uses manual realm.\n")));
  5444 
  5241 
  5445 				get_am_partner()->complete_eap_identity_query(
  5242 				get_am_partner()->complete_eap_identity_query(
  5446 					0, // 0 because certificate query failed
  5243 						0, // 0 because certificate query failed
  5447 					&m_receive_network_id,
  5244 						&m_receive_network_id,
  5448 					m_eap_identifier,
  5245 						m_eap_identifier,
  5449 					eap_status_ok, 
  5246 						eap_status_ok, 
  5450 					m_use_manual_username, 
  5247 						m_use_manual_username, 
  5451 					&m_manual_username, 
  5248 						&m_manual_username, 
  5452 					m_use_manual_realm, 
  5249 						m_use_manual_realm, 
  5453 					&m_manual_realm);
  5250 						&m_manual_realm);
  5454 
  5251 
  5455 			}
  5252 			}
  5456 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
  5253 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
  5457 			return;
  5254 			return;
  5458 		}
  5255 		}
  5466 	else if (m_state == EHandlingChainQuery)
  5263 	else if (m_state == EHandlingChainQuery)
  5467 	{
  5264 	{
  5468 		
  5265 		
  5469 		if (aMatchingCerts.Count() > 0)
  5266 		if (aMatchingCerts.Count() > 0)
  5470 		{
  5267 		{
  5471 			TInt error;
  5268 				m_allowed_user_certs.Reset();
  5472 
  5269 			
  5473 			m_allowed_user_certs.ResetAndDestroy();
  5270 				for (TInt i = 0; i < aMatchingCerts.Count(); i++)
  5474 		
       
  5475 			for (TInt i = 0; i < aMatchingCerts.Count(); i++)
       
  5476 			{
       
  5477 				EapCertificateEntry * const entry = aMatchingCerts[i]->Copy();
       
  5478 				if (entry != 0)
       
  5479 				{
  5271 				{
  5480 					TRAP(error, m_allowed_user_certs.AppendL(entry));
  5272 					TRAPD(err, m_allowed_user_certs.AppendL(aMatchingCerts[i]));
  5481 				}
  5273 					if (err != KErrNone)
  5482 				else
  5274 					{
  5483 				{
  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"),
  5484 					error = KErrNoMemory;
  5276 						err));
  5485 				}
  5277 									
  5486 
  5278 						get_tls_am_partner()->complete_query_certificate_chain(0, eap_status_allocation_error);
  5487 				if (error != KErrNone)
  5279 						EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);		
  5488 				{
  5280 						return;					
  5489 					EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: eap_am_type_tls_peap_symbian_c::complete_get_matching_certificates -EHandlingChainQuery- Error=%d\n"),
  5281 					} 
  5490 						error));
       
  5491 								
       
  5492 					get_tls_am_partner()->complete_query_certificate_chain(0, eap_status_allocation_error);
       
  5493 					EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);		
       
  5494 					return;					
       
  5495 				} 
       
  5496 			}	
  5282 			}	
  5497 		}
  5283 		}
  5498 
  5284 
  5499 		if (m_allowed_user_certs.Count() == 0)
  5285 		if (m_allowed_user_certs.Count() == 0)
  5500 		{
  5286 		{
  5501 			// No matching or allowed certs and no pre-loaded cert.
  5287 			// No matching or allowed certs and no pre-loaded cert.
  5502 			// Could not find matching certificate
  5288 			// Could not find matching certificate
  5503 
  5289 
  5504 			EAP_TRACE_DEBUG(
  5290 			EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("EAP-TLS: Could not find proper user certificate.\n")));
  5505 				m_am_tools,
       
  5506 				TRACE_FLAGS_DEFAULT,
       
  5507 				(EAPL("EAP-TLS: Could not find proper user certificate.\n")));
       
  5508 
  5291 
  5509 			if (m_tls_peap_server_authenticates_client_policy_flag == true)
  5292 			if (m_tls_peap_server_authenticates_client_policy_flag == true)
  5510 			{
  5293 			{
  5511 				EAP_TRACE_DEBUG(
       
  5512 					m_am_tools,
       
  5513 					TRACE_FLAGS_DEFAULT,
       
  5514 					(EAPL("ERROR: EAP-TLS: Could not find proper user certificate and anonymous cliet is not allowed.\n")));
       
  5515 
       
  5516 				send_error_notification(eap_status_user_certificate_unknown);
  5294 				send_error_notification(eap_status_user_certificate_unknown);
  5517 			}
  5295 			}
  5518 
  5296 
  5519 			get_tls_am_partner()->complete_query_certificate_chain(0, eap_status_illegal_certificate);
  5297 			get_tls_am_partner()->complete_query_certificate_chain(0, eap_status_illegal_certificate);
  5520 
  5298 
  5533 	}
  5311 	}
  5534 	else
  5312 	else
  5535 	{
  5313 	{
  5536 		EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("EAP-TLS: Illegal state in complete_get_matching_certs.\n")));
  5314 		EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("EAP-TLS: Illegal state in complete_get_matching_certs.\n")));
  5537 	}
  5315 	}
  5538 
       
  5539 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
  5316 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
  5540 	return;
  5317 	return;
  5541 }
  5318 }
  5542 
  5319 
  5543 //--------------------------------------------------
       
  5544 
  5320 
  5545 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::query_certificate_authorities_and_types()
  5321 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::query_certificate_authorities_and_types()
  5546 {
  5322 {
  5547 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  5323 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  5548 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("\n")));
  5324 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("\n")));
  5553 
  5329 
  5554 	eap_status_e status;
  5330 	eap_status_e status;
  5555 	eap_array_c<eap_variable_data_c> certificate_authorities(m_am_tools);
  5331 	eap_array_c<eap_variable_data_c> certificate_authorities(m_am_tools);
  5556 	eap_variable_data_c ca_dn(m_am_tools);
  5332 	eap_variable_data_c ca_dn(m_am_tools);
  5557 	
  5333 	
  5558 	// TEST CODE: Implementation do not support yet a proper CA DN.
  5334 	// TEST CODE: This is not a proper CA DN.
  5559 	_LIT8(KTestCA, "ca.eapsim.foo");
  5335 	_LIT8(KTestCA, "ca.eapsim.foo");
  5560 	status = ca_dn.add_data(KTestCA().Ptr(), KTestCA().Size());
  5336 	status = ca_dn.add_data(KTestCA().Ptr(), KTestCA().Size());
  5561 	if (status != eap_status_ok)
  5337 	if (status != eap_status_ok)
  5562 	{
  5338 	{
  5563 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5339 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5743 	TPtr8 ptr(
  5519 	TPtr8 ptr(
  5744 		subject_identity.get_data(subject_identity.get_data_length()), 
  5520 		subject_identity.get_data(subject_identity.get_data_length()), 
  5745 		subject_identity.get_data_length(),
  5521 		subject_identity.get_data_length(),
  5746 		subject_identity.get_data_length());		
  5522 		subject_identity.get_data_length());		
  5747 
  5523 
  5748 	status = subject_realm->set_copy_of_buffer((ptr.Mid(offset + KOffsetCorrection)).Ptr(), ptr.Length() - offset - KOffsetCorrection);
  5524 	status = subject_realm->set_copy_of_buffer((ptr.Mid(offset + 1)).Ptr(), ptr.Length() - offset - 1);
  5749 	if (status != eap_status_ok)
  5525 	if (status != eap_status_ok)
  5750 	{
  5526 	{
  5751 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5527 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5752 		return EAP_STATUS_RETURN(m_am_tools, status);
  5528 		return EAP_STATUS_RETURN(m_am_tools, status);
  5753 	}	
  5529 	}	
  5754 
  5530 	
  5755 	// ISSUER
  5531 	// ISSUER
  5756 	// Check DN
  5532 	// Check DN
  5757 	TRAP(err, get_identities_from_distinguished_namesL(certificate, &subject_identity, &issuer_identity));	
  5533 	TRAP(err, get_identities_from_distinguished_namesL(certificate, &subject_identity, &issuer_identity));	
  5758 	if (err != KErrNone)
  5534 	if (err != KErrNone)
  5759 	{
  5535 	{
  5764 	// Parse realm from identity
  5540 	// Parse realm from identity
  5765 	TPtr8 ptr2(
  5541 	TPtr8 ptr2(
  5766 		issuer_identity.get_data(issuer_identity.get_data_length()), 
  5542 		issuer_identity.get_data(issuer_identity.get_data_length()), 
  5767 		issuer_identity.get_data_length(),
  5543 		issuer_identity.get_data_length(),
  5768 		issuer_identity.get_data_length());		
  5544 		issuer_identity.get_data_length());		
  5769 
  5545 		
  5770 	offset = ptr2.Find(KAt);
  5546 	offset = ptr2.Find(KAt);
  5771 
  5547 
  5772 	status = issuer_realm->set_copy_of_buffer((ptr2.Mid(offset + KOffsetCorrection)).Ptr(), ptr2.Length() - offset - KOffsetCorrection);
  5548 	status = issuer_realm->set_copy_of_buffer((ptr2.Mid(offset + 1)).Ptr(), ptr2.Length() - offset - 1);
  5773 	if (status != eap_status_ok)
  5549 	if (status != eap_status_ok)
  5774 	{
  5550 	{
  5775 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5551 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5776 		return EAP_STATUS_RETURN(m_am_tools, status);
  5552 		return EAP_STATUS_RETURN(m_am_tools, status);
  5777 	}
  5553 	}
  5779 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5555 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5780 	return EAP_STATUS_RETURN(m_am_tools, status);
  5556 	return EAP_STATUS_RETURN(m_am_tools, status);
  5781 }
  5557 }
  5782 
  5558 
  5783 //--------------------------------------------------
  5559 //--------------------------------------------------
       
  5560 
  5784 
  5561 
  5785 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::save_tls_session(
  5562 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::save_tls_session(
  5786 	const eap_variable_data_c * const session_id,
  5563 	const eap_variable_data_c * const session_id,
  5787 	const eap_variable_data_c * const master_secret,
  5564 	const eap_variable_data_c * const master_secret,
  5788 	const tls_cipher_suites_e used_cipher_suite
  5565 	const tls_cipher_suites_e used_cipher_suite
  5872 #endif //#if defined(USE_EAP_TLS_SESSION_TICKET)
  5649 #endif //#if defined(USE_EAP_TLS_SESSION_TICKET)
  5873 
  5650 
  5874 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5651 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5875 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
  5652 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
  5876 }
  5653 }
  5877 
  5654 //--------------------------------------------------
  5878 //--------------------------------------------------
  5655 //--------------------------------------------------
  5879 
  5656 
  5880 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::rsa_encrypt_with_public_key(
  5657 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::rsa_encrypt_with_public_key(
  5881 	const eap_variable_data_c * const premaster_secret)
  5658 	const eap_variable_data_c * const premaster_secret)
  5882 {
  5659 {
  5952 	TPtr8 ptr = data->Des();
  5729 	TPtr8 ptr = data->Des();
  5953 
  5730 
  5954 	ptr.Copy(encrypted_premaster_secret->get_data(encrypted_premaster_secret->get_data_length()), 
  5731 	ptr.Copy(encrypted_premaster_secret->get_data(encrypted_premaster_secret->get_data_length()), 
  5955 		encrypted_premaster_secret->get_data_length());
  5732 		encrypted_premaster_secret->get_data_length());
  5956 
  5733 
  5957 	TRAP(err, m_cert_if->DecryptL(m_own_certificate_info.GetSubjectKeyId(), *data));
  5734 	TRAP(err, m_cert_if->DecryptL(m_own_certificate_info.iSubjectKeyId, *data));
  5958 
  5735 
  5959 	if (err != KErrNone)
  5736 	if (err != KErrNone)
  5960 	{
  5737 	{
  5961 		status = m_am_tools->convert_am_error_to_eapol_error(err);
  5738 		status = m_am_tools->convert_am_error_to_eapol_error(err);
  5962 	}
  5739 	}
  6014 
  5791 
  6015 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5792 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6016 }
  5793 }
  6017 
  5794 
  6018 //--------------------------------------------------
  5795 //--------------------------------------------------
  6019 
       
  6020 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::sign_with_private_key(
  5796 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::sign_with_private_key(
  6021 	const eap_variable_data_c * const message_hash)
  5797 	const eap_variable_data_c * const message_hash)
  6022 {
  5798 {
  6023 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  5799 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6024 
  5800 
  6073 		// public_key_data actually has the asn.1 header so it is a few bytes longer
  5849 		// public_key_data actually has the asn.1 header so it is a few bytes longer
  6074 		// than the actual signature.
  5850 		// than the actual signature.
  6075 		signature_length = public_key_data.Size();
  5851 		signature_length = public_key_data.Size();
  6076 	}
  5852 	}
  6077 
  5853 
  6078 	TRAP(err, m_cert_if->SignL(m_own_certificate_info.GetSubjectKeyId(), hash, signature_length));
  5854 	TRAP(err, m_cert_if->SignL(m_own_certificate_info.iSubjectKeyId, hash, signature_length));
  6079 	if (err != KErrNone)
  5855 	if (err != KErrNone)
  6080 	{
  5856 	{
  6081 		status = m_am_tools->convert_am_error_to_eapol_error(err);
  5857 		status = m_am_tools->convert_am_error_to_eapol_error(err);
  6082 	}
  5858 	}
  6083 	else
  5859 	else
  6089 
  5865 
  6090 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5866 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6091 	return EAP_STATUS_RETURN(m_am_tools, status);
  5867 	return EAP_STATUS_RETURN(m_am_tools, status);
  6092 		
  5868 		
  6093 }
  5869 }
  6094 
       
  6095 //--------------------------------------------------
  5870 //--------------------------------------------------
  6096 
       
  6097 void eap_am_type_tls_peap_symbian_c::complete_sign(
  5871 void eap_am_type_tls_peap_symbian_c::complete_sign(
  6098 	const RInteger& aR, const RInteger& aS, eap_status_e aStatus)
  5872 	const RInteger& aR, const RInteger& aS, eap_status_e aStatus)
  6099 {
  5873 {
  6100 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  5874 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6101 
  5875 
  6111 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: complete_signL leaved.\n")));
  5885 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: complete_signL leaved.\n")));
  6112 		get_tls_am_partner()->complete_sign_with_private_key(0, m_am_tools->convert_am_error_to_eapol_error(err));
  5886 		get_tls_am_partner()->complete_sign_with_private_key(0, m_am_tools->convert_am_error_to_eapol_error(err));
  6113 	}
  5887 	}
  6114 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5888 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6115 }
  5889 }
  6116 
       
  6117 //--------------------------------------------------
       
  6118 
  5890 
  6119 void eap_am_type_tls_peap_symbian_c::complete_signL(
  5891 void eap_am_type_tls_peap_symbian_c::complete_signL(
  6120 	const RInteger& aR, const RInteger& aS, eap_status_e aStatus)
  5892 	const RInteger& aR, const RInteger& aS, eap_status_e aStatus)
  6121 {
  5893 {
  6122 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  5894 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6275 			message_hash,
  6047 			message_hash,
  6276 			signed_message_hash);
  6048 			signed_message_hash);
  6277 	}
  6049 	}
  6278 	else
  6050 	else
  6279 	{
  6051 	{
  6280 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: Verify with private key failed.\n")));
  6052 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: Signing with private key failed.\n")));
  6281 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6053 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6282 		return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported);
  6054 		return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported);
  6283 	}
  6055 	}
  6284 
  6056 
  6285 	status = get_tls_am_partner()->complete_verify_with_public_key(status); 
  6057 	status = get_tls_am_partner()->complete_verify_with_public_key(status); 
  6291 	}
  6063 	}
  6292 
  6064 
  6293 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6065 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6294 	return EAP_STATUS_RETURN(m_am_tools, status);
  6066 	return EAP_STATUS_RETURN(m_am_tools, status);
  6295 }
  6067 }
  6296 
       
  6297 //--------------------------------------------------
       
  6298 
  6068 
  6299 void eap_am_type_tls_peap_symbian_c::read_dsa_parametersL()
  6069 void eap_am_type_tls_peap_symbian_c::read_dsa_parametersL()
  6300 {
  6070 {
  6301 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); 
  6071 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); 
  6302 	if (m_peer_certificate == 0)
  6072 	if (m_peer_certificate == 0)
  6351 }
  6121 }
  6352 
  6122 
  6353 //--------------------------------------------------
  6123 //--------------------------------------------------
  6354 // MODULE HANDLING FUNCTIONS
  6124 // MODULE HANDLING FUNCTIONS
  6355 //--------------------------------------------------
  6125 //--------------------------------------------------
  6356 
       
  6357 eap_status_e eap_am_type_tls_peap_symbian_c::load_module(
  6126 eap_status_e eap_am_type_tls_peap_symbian_c::load_module(
  6358 		const eap_type_value_e /*type*/,
  6127 		const eap_type_value_e /*type*/,
  6359 		const eap_type_value_e /* tunneling_type */,
  6128 		const eap_type_value_e /* tunneling_type */,
  6360 		abs_eap_base_type_c * const /*partner*/,
  6129 		abs_eap_base_type_c * const /*partner*/,
  6361 		eap_base_type_c ** const /*eap_type_if*/,
  6130 		eap_base_type_c ** const /*eap_type_if*/,
  6373 {
  6142 {
  6374 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6143 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6375 	
  6144 	
  6376 	eap_status_e status(eap_status_illegal_eap_type);
  6145 	eap_status_e status(eap_status_illegal_eap_type);
  6377 	
  6146 	
       
  6147 #ifdef USE_EAP_EXPANDED_TYPES
       
  6148 
  6378 	EAP_TRACE_DEBUG(m_am_tools, 
  6149 	EAP_TRACE_DEBUG(m_am_tools, 
  6379 		TRACE_FLAGS_DEFAULT, 
  6150 		TRACE_FLAGS_DEFAULT, 
  6380 		(EAPL("eap_am_type_tls_peap_symbian_c::check_is_valid_eap_type:Given EAP-type=0xfe%06x%08x\n"),
  6151 		(EAPL("eap_am_type_tls_peap_symbian_c::check_is_valid_eap_type:Given EAP vendor ID=%x, type=%x\n"),
  6381 		eap_type.get_vendor_id(),
  6152 		eap_type.get_vendor_id(), eap_type.get_vendor_type()));	
  6382 		eap_type.get_vendor_type()));	
       
  6383 		
  6153 		
  6384 	for (TInt i = 0; i < m_enabled_tunneling_exp_eap_array.Count(); i++)
  6154 	for (TInt i = 0; i < m_enabled_tunneling_exp_eap_array.Count(); i++)
  6385 	{
  6155 	{
  6386 		eap_expanded_type_c expEAPTmp;
  6156 		eap_expanded_type_c expEAPTmp;
  6387 		
  6157 		
  6388 		TInt error = CEapConversion::ConvertExpandedEAPTypeToInternalType(
  6158 		// This will read the expanded EAP from enabledEAPTypes[i]->iExpandedEAPType to expEAPTmp.
  6389 			m_enabled_tunneling_exp_eap_array[i],
  6159 		// This makes easy to get the vendor type.
  6390 			&expEAPTmp);
  6160 		eap_expanded_type_c::read_type( m_am_tools,
  6391 
  6161 										0,
  6392 		if (error != KErrNone)
  6162 										m_enabled_tunneling_exp_eap_array[i]->iExpandedEAPType.Ptr(),
  6393 		{
  6163 										KExpandedEAPTypeSize,
  6394 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6164 										&expEAPTmp);
  6395 			return EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(error));
  6165 		
  6396 		}
       
  6397 
       
  6398 		EAP_TRACE_DATA_DEBUG(
  6166 		EAP_TRACE_DATA_DEBUG(
  6399 			m_am_tools,
  6167 			m_am_tools,
  6400 			TRACE_FLAGS_DEFAULT,
  6168 			TRACE_FLAGS_DEFAULT,
  6401 			(EAPL("check_is_valid_eap_type:Checking with EAP type:"),
  6169 			(EAPL("check_is_valid_eap_type:Checking with EAP type:"),
  6402 	 		m_enabled_tunneling_exp_eap_array[i]->GetValue().Ptr(),
  6170 	 		m_enabled_tunneling_exp_eap_array[i]->iExpandedEAPType.Ptr(),
  6403 	 		m_enabled_tunneling_exp_eap_array[i]->GetValue().Size()));	 			
  6171 	 		m_enabled_tunneling_exp_eap_array[i]->iExpandedEAPType.Size()));	 			
  6404 		
  6172 		
  6405 		if (eap_type == expEAPTmp)
  6173 		if (eap_type == expEAPTmp)
  6406 		{
  6174 		{
  6407 			// This EAp type is one among the enabled ones. Hence a valid EAP type.
  6175 			// This EAp type is one among the enabled ones. Hence a valid EAP type.
  6408 			status = eap_status_ok;
  6176 			status = eap_status_ok;
  6409 			break;			
  6177 			break;			
  6410 		}
  6178 		}
  6411 	}
  6179 	}
  6412 
  6180 
       
  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 	
  6413 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6208 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  6209 
  6414 	return EAP_STATUS_RETURN(m_am_tools, status);
  6210 	return EAP_STATUS_RETURN(m_am_tools, status);
  6415 }
  6211 }
  6416 
  6212 
  6417 //--------------------------------------------------
  6213 //--------------------------------------------------
  6418 
  6214 
  6425 		TRACE_FLAGS_DEFAULT, 
  6221 		TRACE_FLAGS_DEFAULT, 
  6426 		(EAPL("eap_am_type_tls_peap_symbian_c::get_eap_type_list - Start\n")));	
  6222 		(EAPL("eap_am_type_tls_peap_symbian_c::get_eap_type_list - Start\n")));	
  6427 
  6223 
  6428 	eap_status_e status(eap_status_illegal_eap_type);
  6224 	eap_status_e status(eap_status_illegal_eap_type);
  6429 
  6225 
       
  6226 #ifdef USE_EAP_EXPANDED_TYPES
       
  6227 
  6430 	// We need to return only the EAP types available as enabled types.
  6228 	// We need to return only the EAP types available as enabled types.
  6431 	// It means only the ones available in m_enabled_tunneling_exp_eap_array.
  6229 	// It means only the ones available in m_enabled_tunneling_exp_eap_array.
  6432 	
  6230 	
  6433 	for (TInt i = 0; i < m_enabled_tunneling_exp_eap_array.Count(); i++)
  6231 	for (TInt i = 0; i < m_enabled_tunneling_exp_eap_array.Count(); i++)
  6434 	{	
  6232 	{	
       
  6233 		TBuf8<KExpandedEAPTypeSize> tmpExpEAP(m_enabled_tunneling_exp_eap_array[i]->iExpandedEAPType);
       
  6234 
  6435 		EAP_TRACE_DEBUG(
  6235 		EAP_TRACE_DEBUG(
  6436 			m_am_tools, 
  6236 			m_am_tools, 
  6437 			TRACE_FLAGS_DEFAULT, 
  6237 			TRACE_FLAGS_DEFAULT, 
  6438 			(EAPL("eap_am_type_tls_peap_symbian_c::get_eap_type_list:Enabled expanded EAP type at index=%d\n"),
  6238 			(EAPL("eap_am_type_tls_peap_symbian_c::get_eap_type_list:Enabled expanded EAP type at index=%d\n"),
  6439 			 i));
  6239 			 i));
  6440 
  6240 
  6441 		EAP_TRACE_DATA_DEBUG(
  6241 		EAP_TRACE_DATA_DEBUG(
  6442 			m_am_tools,
  6242 			m_am_tools,
  6443 			TRACE_FLAGS_DEFAULT,
  6243 			TRACE_FLAGS_DEFAULT,
  6444 			(EAPL("Enabled expanded EAP type:"),
  6244 			(EAPL("Enabled expanded EAP type:"),
  6445 			m_enabled_tunneling_exp_eap_array[i]->GetValue().Ptr(),
  6245 			tmpExpEAP.Ptr(),
  6446 			m_enabled_tunneling_exp_eap_array[i]->GetValue().Size()));
  6246 			tmpExpEAP.Size()));
  6447 
  6247 
  6448 		// This is for one expanded EAP type (for the above one).
  6248 		// This is for one expanded EAP type (for the above one).
  6449 		eap_type_value_e * expandedEAPType = new eap_type_value_e();
  6249 		eap_type_value_e * expandedEAPType = new eap_type_value_e();
  6450 		
  6250 				
  6451 		eap_automatic_variable_c<eap_type_value_e> automatic_expandedEAPType(
  6251 		// Read the expanded EAP type details from an item in m_enabled_tunneling_exp_eap_array.
  6452 			m_am_tools,
  6252 		status = eap_type_value_e::read_type(m_am_tools,
  6453 			expandedEAPType);
  6253 												0,
  6454 
  6254 												&tmpExpEAP,
  6455 		TInt error = CEapConversion::ConvertExpandedEAPTypeToInternalType(
  6255 												tmpExpEAP.Length(),
  6456 			m_enabled_tunneling_exp_eap_array[i],
  6256 												expandedEAPType);
  6457 			expandedEAPType);
  6257 		if (status != eap_status_ok)
  6458 
  6258 		{
  6459 		if (error != KErrNone)
  6259 			delete expandedEAPType;
  6460 		{
  6260 			expandedEAPType = 0;
  6461 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6261 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6462 			return EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(error));
  6262 			return EAP_STATUS_RETURN(m_am_tools, status);
  6463 		}
  6263 		}
  6464 
       
  6465 		automatic_expandedEAPType.do_not_free_variable();
       
  6466 
  6264 
  6467 		// Add EAP-type to list.		
  6265 		// Add EAP-type to list.		
  6468 		status = eap_type_list->add_object(expandedEAPType, true);
  6266 		status = eap_type_list->add_object(expandedEAPType, true);
  6469 		if (status != eap_status_ok)
  6267 		if (status != eap_status_ok)
  6470 		{
  6268 		{
  6476 		EAP_UNREFERENCED_PARAMETER(eap_string);
  6274 		EAP_UNREFERENCED_PARAMETER(eap_string);
  6477 		
  6275 		
  6478 		EAP_TRACE_DEBUG(
  6276 		EAP_TRACE_DEBUG(
  6479 			m_am_tools,
  6277 			m_am_tools,
  6480 			TRACE_FLAGS_DEFAULT,
  6278 			TRACE_FLAGS_DEFAULT,
  6481 			(EAPL("get_eap_type_list():added EAP-type=0xfe%06x%08x=%s\n"),
  6279 			(EAPL("get_eap_type_list():added EAP-type=0x%08x=%s\n"),
  6482 			expandedEAPType->get_vendor_id(),
       
  6483 			expandedEAPType->get_vendor_type(),
  6280 			expandedEAPType->get_vendor_type(),
  6484 			eap_header_string_c::get_eap_type_string(*expandedEAPType)));			
  6281 			eap_string.get_eap_type_string(*expandedEAPType)));			
  6485 	
  6282 	
  6486 	}// for()
  6283 	}// 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
  6487 
  6324 
  6488 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6325 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6489 	return eap_status_ok;
  6326 	return eap_status_ok;
  6490 }
  6327 }
  6491 
       
  6492 //--------------------------------------------------
       
  6493 
  6328 
  6494 eap_status_e eap_am_type_tls_peap_symbian_c::unload_module(const eap_type_value_e /*type*/)
  6329 eap_status_e eap_am_type_tls_peap_symbian_c::unload_module(const eap_type_value_e /*type*/)
  6495 {
  6330 {
  6496 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6331 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6497 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6332 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6498 	return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported);
  6333 	return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported);
  6499 }
  6334 }
  6500 
  6335 
  6501 //--------------------------------------------------
       
  6502 
  6336 
  6503 void eap_am_type_tls_peap_symbian_c::send_error_notification(const eap_status_e error)
  6337 void eap_am_type_tls_peap_symbian_c::send_error_notification(const eap_status_e error)
  6504 {
  6338 {
  6505 	EAP_TRACE_DEBUG(m_am_tools, 
  6339 	EAP_TRACE_DEBUG(m_am_tools, 
  6506 		TRACE_FLAGS_DEFAULT, 
  6340 		TRACE_FLAGS_DEFAULT, 
  6535 	notification.set_authentication_error(error);
  6369 	notification.set_authentication_error(error);
  6536 
  6370 
  6537 	m_partner->state_notification(&notification);
  6371 	m_partner->state_notification(&notification);
  6538 }
  6372 }
  6539 
  6373 
       
  6374 eap_status_e eap_am_type_tls_peap_symbian_c::show_certificate_selection_dialog()
       
  6375 {
       
  6376 	return eap_status_ok;
       
  6377 }
       
  6378 
       
  6379 eap_status_e eap_am_type_tls_peap_symbian_c::show_manual_identity_dialog()
       
  6380 {
       
  6381 	return eap_status_ok;
       
  6382 }
       
  6383 
  6540 //--------------------------------------------------
  6384 //--------------------------------------------------
  6541 // CANCELLATION FUNCTIONS
  6385 // CANCELLATION FUNCTIONS
  6542 //--------------------------------------------------
  6386 //--------------------------------------------------
  6543 
       
  6544 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::cancel_identity_query()
  6387 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::cancel_identity_query()
  6545 {
  6388 {
  6546 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6389 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6547 
  6390 
  6548 	EAP_TRACE_DEBUG(
  6391 	EAP_TRACE_DEBUG(
  6554 	
  6397 	
  6555 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6398 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6556 	return eap_status_ok;
  6399 	return eap_status_ok;
  6557 }
  6400 }
  6558 
  6401 
  6559 //--------------------------------------------------
       
  6560 
       
  6561 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::cancel_query_cipher_suites_and_previous_session()
  6402 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::cancel_query_cipher_suites_and_previous_session()
  6562 {
  6403 {
  6563 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6404 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6564 
  6405 
  6565 	EAP_TRACE_DEBUG(
  6406 	EAP_TRACE_DEBUG(
  6785 {
  6626 {
  6786 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6627 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6787 
  6628 
  6788 	EAP_TRACE_DEBUG(m_am_tools, 
  6629 	EAP_TRACE_DEBUG(m_am_tools, 
  6789 		TRACE_FLAGS_DEFAULT, (
  6630 		TRACE_FLAGS_DEFAULT, (
  6790 		EAPL("eap_am_type_tls_peap_symbian_c::is_session_valid - m_current_eap_vendor_type=0xfe%06x%08x\n"),
  6631 		EAPL("eap_am_type_tls_peap_symbian_c::is_session_valid - m_current_eap_vendor_type=%d \n"),
  6791 		m_current_eap_type.get_vendor_id(),
  6632 		m_current_eap_vendor_type));
  6792 		m_current_eap_type.get_vendor_type()));
       
  6793 
  6633 
  6794 	TPtrC maxSessionTimeString;
  6634 	TPtrC maxSessionTimeString;
  6795 	TPtrC lastFullAuthTimeString;
  6635 	TPtrC lastFullAuthTimeString;
  6796 
  6636 
  6797 	if (m_current_eap_type == eap_type_tls)
  6637 	switch (m_current_eap_vendor_type)
  6798 	{
  6638 	{
  6799 		maxSessionTimeString.Set(cf_str_EAP_TLS_max_session_validity_time_literal);
  6639 	case eap_type_tls:
  6800 		lastFullAuthTimeString.Set(KTLSLastFullAuthTime);
  6640 		{
  6801 	}
  6641 			maxSessionTimeString.Set(cf_str_EAP_TLS_max_session_validity_time_literal);
  6802 	else if (m_current_eap_type == eap_type_peap)
  6642 			lastFullAuthTimeString.Set(KTLSLastFullAuthTime);
  6803 	{
  6643 		}
  6804 		maxSessionTimeString.Set(cf_str_EAP_PEAP_max_session_validity_time_literal);
  6644 		break;
  6805 		lastFullAuthTimeString.Set(KPEAPLastFullAuthTime);
  6645 
  6806 	}
  6646 	case eap_type_peap:
  6807 	else if (m_current_eap_type == eap_type_ttls)
  6647 		{
  6808 	{
  6648 			maxSessionTimeString.Set(cf_str_EAP_PEAP_max_session_validity_time_literal);
  6809 		maxSessionTimeString.Set(cf_str_EAP_TTLS_max_session_validity_time_literal);
  6649 			lastFullAuthTimeString.Set(KPEAPLastFullAuthTime);
  6810 		lastFullAuthTimeString.Set(KTTLSLastFullAuthTime);
  6650 		}
  6811 	}
  6651 		break;
       
  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 
  6812 #if defined(USE_FAST_EAP_TYPE)		
  6660 #if defined(USE_FAST_EAP_TYPE)		
  6813 	else if (m_current_eap_type == eap_type_fast)
  6661 	case eap_type_fast:
  6814 	{
  6662 		{
  6815 		maxSessionTimeString.Set(cf_str_EAP_FAST_max_session_validity_time_literal);
  6663 			maxSessionTimeString.Set(cf_str_EAP_FAST_max_session_validity_time_literal);
  6816 		lastFullAuthTimeString.Set(KFASTLastFullAuthTime);
  6664 			lastFullAuthTimeString.Set(KFASTLastFullAuthTime);
  6817 	}
  6665 		}
       
  6666 		break;
  6818 #endif
  6667 #endif
  6819 	else if (m_current_eap_type == eap_expanded_type_ttls_plain_pap.get_type())
  6668 		
  6820 	{
  6669 	case eap_type_ttls_plain_pap:
  6821 	    // we should not come here, ttls pap has its own
  6670 	    {
  6822 	    // method for checking session validity
  6671 	        // we should not come here, ttls pap has its own
  6823 	    EAP_TRACE_ERROR( m_am_tools, TRACE_FLAGS_DEFAULT, (
  6672 	        // method for checking session validity
  6824 	        EAPL( "ERROR: wrong eap type.\n" ) ) );
  6673 	        EAP_TRACE_ERROR( m_am_tools, TRACE_FLAGS_DEFAULT, (
  6825 	    return false;
  6674 	            EAPL( "ERROR: wrong eap type.\n" ) ) );
  6826 	}
  6675 	        return false;
  6827 	else
  6676 	    }
  6828 	{
  6677 	    
  6829 		// Should never happen
  6678 	default:
  6830 		EAP_TRACE_ERROR(m_am_tools, 
  6679 		{
  6831 			TRACE_FLAGS_DEFAULT, (
  6680 			// Should never happen
  6832 			EAPL("Unsupported EAP type, m_current_eap_vendor_type=0xfe%06x%08x\n"),
  6681 			EAP_TRACE_ERROR(m_am_tools, 
  6833 			m_current_eap_type.get_vendor_id(),
  6682 				TRACE_FLAGS_DEFAULT, (
  6834 			m_current_eap_type.get_vendor_type()));
  6683 				EAPL("Unsupported EAP type, m_current_eap_vendor_type=%d \n"),
  6835 			
  6684 				m_current_eap_vendor_type));
  6836 		return false; // Treat this as Session invalid.
  6685 				
  6837 	}
  6686 			return false; // Treat this as Session invalid.
       
  6687 		}
       
  6688 	}	
  6838 
  6689 
  6839 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  6690 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  6840 	TPtr sqlStatement = buf->Des();
  6691 	TPtr sqlStatement = buf->Des();
  6841 	
  6692 	
  6842 	// Query all the relevant parameters
  6693 	// Query all the relevant parameters
  6843 	_LIT(KSQLQuery, "SELECT %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
  6694 	_LIT(KSQLQuery, "SELECT %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d");
  6844 
  6695 	sqlStatement.Format(KSQLQuery, &maxSessionTimeString, &lastFullAuthTimeString, &m_db_table_name,
  6845 	sqlStatement.Format(
  6696 						&KServiceType, m_index_type, 
  6846 		KSQLQuery,
  6697 						&KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);
  6847 		&maxSessionTimeString,
       
  6848 		&lastFullAuthTimeString,
       
  6849 		&m_db_table_name,
       
  6850 		&KServiceType,
       
  6851 		m_index_type, 
       
  6852 		&KServiceIndex,
       
  6853 		m_index,
       
  6854 		&KTunnelingTypeVendorId,
       
  6855 		m_tunneling_type.get_vendor_id(),
       
  6856 		&KTunnelingType, 
       
  6857 		m_tunneling_type.get_vendor_type());
       
  6858 
  6698 
  6859 	RDbView view;
  6699 	RDbView view;
  6860 	// Evaluate view
  6700 	// Evaluate view
  6861 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement)));
  6701 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement)));
  6862 	CleanupClosePushL(view);
  6702 	CleanupClosePushL(view);
  6964 {
  6804 {
  6965 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6805 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  6966 	
  6806 	
  6967 	EAP_TRACE_DEBUG(m_am_tools, 
  6807 	EAP_TRACE_DEBUG(m_am_tools, 
  6968 		TRACE_FLAGS_DEFAULT, 
  6808 		TRACE_FLAGS_DEFAULT, 
  6969 		(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"),
  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"),
  6970 		m_index_type,
  6810 		m_index_type, m_index, m_tunneling_vendor_type, m_current_eap_vendor_type));	
  6971 		m_index,
       
  6972 		m_tunneling_type.get_vendor_id(),
       
  6973 		m_tunneling_type.get_vendor_type(),
       
  6974 		m_current_eap_type.get_vendor_id(),
       
  6975 		m_current_eap_type.get_vendor_type()));
       
  6976 
  6811 
  6977 	TPtrC lastFullAuthTimeString;
  6812 	TPtrC lastFullAuthTimeString;
  6978 
  6813 
  6979 	if (m_current_eap_type == eap_type_tls)
  6814 	switch (m_current_eap_vendor_type)
  6980 	{
  6815 	{
  6981 		lastFullAuthTimeString.Set(KTLSLastFullAuthTime);
  6816 	case eap_type_tls:
  6982 	}
  6817 		{
  6983 	else if (m_current_eap_type == eap_type_peap)
  6818 			lastFullAuthTimeString.Set(KTLSLastFullAuthTime);
  6984 	{
  6819 		}
  6985 		lastFullAuthTimeString.Set(KPEAPLastFullAuthTime);
  6820 		break;
  6986 	}
  6821 
  6987 	else if (m_current_eap_type == eap_type_ttls)
  6822 	case eap_type_peap:
  6988 	{
  6823 		{
  6989 		lastFullAuthTimeString.Set(KTTLSLastFullAuthTime);
  6824 			lastFullAuthTimeString.Set(KPEAPLastFullAuthTime);
  6990 	}
  6825 		}
  6991 	else if (m_current_eap_type == eap_expanded_type_ttls_plain_pap.get_type())
  6826 		break;
  6992 	{
  6827 
       
  6828 	case eap_type_ttls:
       
  6829 		{
       
  6830 			lastFullAuthTimeString.Set(KTTLSLastFullAuthTime);
       
  6831 		}
       
  6832 		break;
       
  6833 		
       
  6834 	case eap_type_ttls_plain_pap:
       
  6835 		{
  6993 		lastFullAuthTimeString.Set( KTTLSPAPLastFullAuthTime );
  6836 		lastFullAuthTimeString.Set( KTTLSPAPLastFullAuthTime );
  6994 	}
  6837 		}
       
  6838 		break;
       
  6839 
  6995 #if defined(USE_FAST_EAP_TYPE)
  6840 #if defined(USE_FAST_EAP_TYPE)
  6996 	else if (m_current_eap_type == eap_type_fast)
  6841 	case eap_type_fast:
  6997 	{
  6842 		{
  6998 		lastFullAuthTimeString.Set(KFASTLastFullAuthTime);
  6843 			lastFullAuthTimeString.Set(KFASTLastFullAuthTime);
  6999 	}
  6844 		}
       
  6845 		break;
  7000 #endif
  6846 #endif
  7001 	else
  6847 		
  7002 	{
  6848 	default:
  7003 		// Should never happen
  6849 		{
  7004 		EAP_TRACE_ERROR(m_am_tools, 
  6850 			// Should never happen
  7005 			TRACE_FLAGS_DEFAULT, (
  6851 			EAP_TRACE_ERROR(m_am_tools, 
  7006 			EAPL("Unsupported EAP type, m_current_eap_vendor_type=0xfe%06x%08x\n"),
  6852 				TRACE_FLAGS_DEFAULT, (
  7007 			m_current_eap_type.get_vendor_id(),
  6853 				EAPL("Unsupported EAP type, m_current_eap_vendor_type=%d \n"),
  7008 			m_current_eap_type.get_vendor_type()));
  6854 				m_current_eap_vendor_type));
  7009 			
  6855 				
  7010 		User::Leave(KErrNotSupported);
  6856 			User::Leave(KErrNotSupported);
  7011 	}
  6857 		}
       
  6858 	}	
  7012 
  6859 
  7013 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  6860 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  7014 	TPtr sqlStatement = buf->Des();
  6861 	TPtr sqlStatement = buf->Des();
  7015 	
  6862 	
  7016 	// Query all the relevant parameters
  6863 	// Query all the relevant parameters
  7017 	_LIT(KSQLQuery, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
  6864 	_LIT(KSQLQuery, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d");
  7018 
  6865 	sqlStatement.Format(KSQLQuery, &lastFullAuthTimeString, &m_db_table_name,
  7019 	sqlStatement.Format(
  6866 						&KServiceType, m_index_type, 
  7020 		KSQLQuery,
  6867 						&KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);
  7021 		&lastFullAuthTimeString,
       
  7022 		&m_db_table_name,
       
  7023 		&KServiceType,
       
  7024 		m_index_type, 
       
  7025 		&KServiceIndex,
       
  7026 		m_index,
       
  7027 		&KTunnelingTypeVendorId,
       
  7028 		m_tunneling_type.get_vendor_id(),
       
  7029 		&KTunnelingType, 
       
  7030 		m_tunneling_type.get_vendor_type());
       
  7031 
  6868 
  7032 	RDbView view;
  6869 	RDbView view;
  7033 	// Evaluate view
  6870 	// Evaluate view
  7034 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  6871 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  7035 	CleanupClosePushL(view);
  6872 	CleanupClosePushL(view);
  7036 	User::LeaveIfError(view.EvaluateAll());
  6873 	User::LeaveIfError(view.EvaluateAll());
  7037 	
  6874 	
  7038 	// Get the first (and only) row for update.
  6875 	// Get the first (and only) row for updation.
  7039 	view.FirstL();
  6876 	view.FirstL();
  7040 	view.UpdateL();
  6877 	view.UpdateL();
  7041 	
  6878 	
  7042 	// Get column set so we get the correct column numbers
  6879 	// Get column set so we get the correct column numbers
  7043 	CDbColSet* colSet = view.ColSetL();
  6880 	CDbColSet* colSet = view.ColSetL();
  7150 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  6987 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  7151 	return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported);
  6988 	return EAP_STATUS_RETURN(m_am_tools, eap_status_not_supported);
  7152 }
  6989 }
  7153 
  6990 
  7154 #endif //#if defined(USE_EAP_CORE_SERVER)
  6991 #endif //#if defined(USE_EAP_CORE_SERVER)
  7155 
       
  7156 //--------------------------------------------------
  6992 //--------------------------------------------------
       
  6993 
  7157 
  6994 
  7158 // This is commented in eap_am_fast_pac_store_services_c::query_user_permission_for_A_ID().
  6995 // This is commented in eap_am_fast_pac_store_services_c::query_user_permission_for_A_ID().
  7159 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_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(
  7160 	const eap_fast_pac_store_pending_operation_e in_pending_operation,
  6997 	const eap_fast_pac_store_pending_operation_e in_pending_operation,
  7161 	const eap_fast_variable_data_c * const in_pac_attribute_A_ID_info,
  6998 	const eap_fast_variable_data_c * const in_pac_attribute_A_ID_info,
  7207 //--------------------------------------------------
  7044 //--------------------------------------------------
  7208 
  7045 
  7209 eap_status_e eap_am_type_tls_peap_symbian_c::QueryUserPermissionForAIDL(
  7046 eap_status_e eap_am_type_tls_peap_symbian_c::QueryUserPermissionForAIDL(
  7210 		const eap_fast_variable_data_c * const in_pac_attribute_A_ID_info,
  7047 		const eap_fast_variable_data_c * const in_pac_attribute_A_ID_info,
  7211 		const eap_fast_variable_data_c * const in_pac_attribute_A_ID)
  7048 		const eap_fast_variable_data_c * const in_pac_attribute_A_ID)
  7212 {
  7049 	{
  7213 	eap_status_e status(eap_status_ok);
  7050 	eap_status_e status(eap_status_ok);
  7214 	
  7051 	
  7215 	HBufC8* A_ID_info8 = HBufC8::NewLC((in_pac_attribute_A_ID_info->get_data_length()));
  7052 	HBufC8* A_ID_info8 = HBufC8::NewLC((in_pac_attribute_A_ID_info->get_data_length()));
  7216 	TPtr8 A_ID_infoPtr8 = A_ID_info8->Des();
  7053 	TPtr8 A_ID_infoPtr8 = A_ID_info8->Des();
  7217 
  7054 
  7234  	EAP_TRACE_DATA_DEBUG_SYMBIAN(
  7071  	EAP_TRACE_DATA_DEBUG_SYMBIAN(
  7235 			("eap_am_type_tls_peap_symbian_c::query_user_permission_for_A_ID(): in_pac_attribute_A_ID",
  7072 			("eap_am_type_tls_peap_symbian_c::query_user_permission_for_A_ID(): in_pac_attribute_A_ID",
  7236 			(A_IDPtr.Ptr()),
  7073 			(A_IDPtr.Ptr()),
  7237 			(in_pac_attribute_A_ID->get_data_length())));
  7074 			(in_pac_attribute_A_ID->get_data_length())));
  7238 
  7075 
  7239  	if (A_ID_infoPtr.Size()>=KMaxNotifItemLength)
  7076  	if (A_ID_infoPtr.Size()>KMaxEapFastNotifierBufLength)
  7240 	{
  7077 	{
  7241   		CleanupStack::PopAndDestroy(3); // A_ID, A_ID_info
  7078   		CleanupStack::PopAndDestroy(3); // A_ID, A_ID_info
  7242   		status = m_am_tools->convert_am_error_to_eapol_error(KErrArgument);
  7079   		status = m_am_tools->convert_am_error_to_eapol_error(KErrArgument);
  7243 
  7080 
  7244  		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  7081  		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  7245  		return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7082  		return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7246 	}
  7083 	}
  7247  
  7084 
  7248     TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  7085  	TBool startedOk = ETrue;
  7249     
  7086  	
  7250     m_notifier_data_to_user->iPassword.Copy(A_ID_infoPtr);
  7087  	if (!iEapFastActiveNotes)
  7251     
  7088          {
  7252     if (iEapAuthNotifier == 0)
  7089          TRAPD( err, iEapFastActiveNotes = CEapFastActive::NewL( this ) );
  7253     	{
  7090          
  7254     	TRAPD(err, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
  7091          if ( err != KErrNone )
  7255 	  	if (err)
  7092              {
  7256 	  		{
  7093              status = eap_status_allocation_error;
  7257 	  			return eap_status_process_general_error;
  7094              }   
  7258 	  		}
  7095         }
  7259     	}
  7096  	if ( status == KErrNone )
  7260     else
  7097  		{
  7261 	   	{
  7098 	    //update buffer
  7262 		 	TRAPD(err1, iEapAuthNotifier->Cancel());
  7099  		iEapFastActiveNotes->UpdateInputBuf( A_ID_infoPtr );
  7263 	  	if (err1)
  7100         // start query install dialog
  7264 	  		{
  7101  		// asynch. call, return immediately
  7265 	  			return eap_status_process_general_error;
  7102  		startedOk = iEapFastActiveNotes->Start(
  7266 	  		}
  7103  		    CEapFastActive::EEapFastActiveInstallPacQueryDialog );
  7267      	}
  7104  		if ( startedOk == EFalse )
  7268 
  7105  			{
  7269     TRAPD(err2, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastInstallPacQueryDialog, m_notifier_data_to_user, aEapType));
  7106  			status = eap_status_process_general_error;
  7270   	if (err2)
  7107  			}
  7271   		{
  7108  		}
  7272   			return eap_status_process_general_error;
  7109  	else
  7273   		}
  7110  		{
  7274  
  7111  		status = eap_status_process_general_error;	
  7275  
  7112  		}
  7276 
  7113 
  7277  	CleanupStack::PopAndDestroy(3); // A_ID, A_ID_info
  7114  	CleanupStack::PopAndDestroy(3); // A_ID, A_ID_info
  7278  	
  7115  	
  7279  	return status;
  7116  	return status;
  7280 }
  7117 	}
  7281 
  7118 
  7282 //--------------------------------------------------
       
  7283 
  7119 
  7284 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::read_PAC_store_data(
  7120 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::read_PAC_store_data(
  7285 	const eap_fast_pac_store_pending_operation_e in_pending_operation,
  7121 	const eap_fast_pac_store_pending_operation_e in_pending_operation,
  7286 	EAP_TEMPLATE_CONST eap_array_c<eap_fast_pac_store_data_c> * const in_references)
  7122 	EAP_TEMPLATE_CONST eap_array_c<eap_fast_pac_store_data_c> * const in_references)
  7287 {
  7123 {
  7765 					dataType = eap_pac_store_data_type_PAC_data;
  7601 					dataType = eap_pac_store_data_type_PAC_data;
  7766 					break;		
  7602 					break;		
  7767 					}		
  7603 					}		
  7768 				}
  7604 				}
  7769 				
  7605 				
  7770 				m_info_array.ResetAndDestroy();
  7606 				TInt count = 0;
       
  7607 				
       
  7608 				m_info_array.Reset();
  7771 					
  7609 					
  7772 				iPacStoreDb->GetPacStoreDataL(dbTableName, m_info_array);
  7610 				iPacStoreDb->GetPacStoreDataL(dbTableName, m_info_array);
  7773 				
  7611 				
  7774 				EAP_TRACE_DEBUG_SYMBIAN(
  7612 				EAP_TRACE_DEBUG_SYMBIAN(
  7775 					(_L("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL:Number of entries in table %S=%d\n"),
  7613 				(_L("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL:Number of entries in table %S=%d\n"),
  7776 					&dbTableName, m_info_array.Count()));
  7614 				&dbTableName, m_info_array.Count()));				
  7777 				
  7615 				
  7778 				TInt first_index = 0;
  7616 				while (count < m_info_array.Count())
  7779 
       
  7780 				while (m_info_array.Count() > 0)
       
  7781 					{
  7617 					{
  7782 					if (m_info_array[first_index] != 0
  7618 					TPtr8 infoDataPtr = m_info_array[count].iData->Des();
  7783 						&& m_info_array[first_index]->GetIsValid() != EFalse)
  7619 					TPtr8 infoRefPtr = m_info_array[count].iReference->Des();
  7784 						{
  7620 					
  7785 						// Note this will get always the first object of array. After the first object is processed it is destryed and removed from array.
  7621 					EAP_TRACE_DATA_DEBUG_SYMBIAN(
  7786 						TPtr8 infoDataPtr = m_info_array[first_index]->GetData()->Des();
  7622 						("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL: BINARY value from PAC DB (reference)",
  7787 						TPtr8 infoRefPtr = m_info_array[first_index]->GetReference()->Des();
  7623 						infoRefPtr.Ptr(),
  7788 						
  7624 						infoRefPtr.Size()));
  7789 						EAP_TRACE_DATA_DEBUG_SYMBIAN(
  7625 					
  7790 							("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL: BINARY value from PAC DB (reference)",
  7626 					EAP_TRACE_DATA_DEBUG_SYMBIAN(
  7791 							infoRefPtr.Ptr(),
  7627 						("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL: BINARY value from PAC DB (value)",
  7792 							infoRefPtr.Size()));
  7628 						infoDataPtr.Ptr(),
  7793 						
  7629 						infoDataPtr.Size()));					
  7794 						EAP_TRACE_DATA_DEBUG_SYMBIAN(
  7630 					
  7795 							("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL: BINARY value from PAC DB (value)",
  7631 					eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools);
  7796 							infoDataPtr.Ptr(),
  7632 
  7797 							infoDataPtr.Size()));					
  7633 					eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
  7798 						
  7634 						m_am_tools, new_data);
  7799 						eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools);
  7635 
  7800 
  7636 					if (new_data == 0)
  7801 						eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
  7637 					{
  7802 							m_am_tools, new_data);
  7638 						m_eap_fast_completion_status = eap_status_allocation_error;
  7803 
  7639 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7804 						if (new_data == 0)
  7640 						break;
  7805 						{
  7641 					}
  7806 							m_eap_fast_completion_status = eap_status_allocation_error;
  7642 
  7807 							(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7643 					new_data->set_type(dataType);					
  7808 							break;
  7644 
  7809 						}
  7645 					// Set the reference.
  7810 
  7646 					m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(infoRefPtr.Ptr(), infoRefPtr.Size());
  7811 						new_data->set_type(dataType);					
  7647 					if (m_eap_fast_completion_status != eap_status_ok)
  7812 
  7648 					{
  7813 						// Set the reference.
  7649 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7814 						m_eap_fast_completion_status = new_data->get_writable_reference()->set_copy_of_buffer(infoRefPtr.Ptr(), infoRefPtr.Size());
  7650 						delete m_info_array[count].iData;
  7815 						if (m_eap_fast_completion_status != eap_status_ok)
  7651 						delete m_info_array[count].iReference;
  7816 						{
  7652 						break;
  7817 							(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7653 					}
  7818 							delete m_info_array[first_index];
  7654 					
  7819 							m_info_array.Remove(first_index);
  7655 					m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(infoDataPtr.Ptr(),infoDataPtr.Size() );
  7820 							break;
  7656 					if (m_eap_fast_completion_status != eap_status_ok)
  7821 						}
  7657 					{
  7822 						
  7658 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7823 						m_eap_fast_completion_status = new_data->get_writable_data()->set_copy_of_buffer(infoDataPtr.Ptr(), infoDataPtr.Size());
  7659 						delete m_info_array[count].iData;
  7824 						if (m_eap_fast_completion_status != eap_status_ok)
  7660 						delete m_info_array[count].iReference;
  7825 						{
  7661 						break;
  7826 							(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7662 					}
  7827 							delete m_info_array[first_index];
  7663 
  7828 							m_info_array.Remove(first_index);
  7664 					automatic_new_data.do_not_free_variable();
  7829 							break;
  7665 
  7830 						}
  7666 					m_eap_fast_completion_status = m_references_and_data_blocks.add_object(new_data, true);
  7831 
  7667 					if (m_eap_fast_completion_status != eap_status_ok)
  7832 						automatic_new_data.do_not_free_variable();
  7668 					{
  7833 
  7669 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7834 						m_eap_fast_completion_status = m_references_and_data_blocks.add_object(new_data, true);
  7670 						delete m_info_array[count].iData;
  7835 						if (m_eap_fast_completion_status != eap_status_ok)
  7671 						delete m_info_array[count].iReference;
  7836 						{
  7672 						break;
  7837 							(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7673 					}					
  7838 							delete m_info_array[first_index];
       
  7839 							m_info_array.Remove(first_index);
       
  7840 							break;
       
  7841 						}
       
  7842 						EAP_TRACE_DATA_DEBUG_SYMBIAN(
       
  7843 							("For GROUP, AID, PAC INFOs - added data",
       
  7844 							(new_data->get_data())->get_data((new_data->get_data())->get_data_length()), 
       
  7845 							(new_data->get_data())->get_data_length()));					
       
  7846 						}
       
  7847 							
  7674 							
  7848 					delete m_info_array[first_index];
  7675 					delete m_info_array[count].iData;
  7849 					m_info_array.Remove(first_index);
  7676 					delete m_info_array[count].iReference;
  7850 					
  7677 					
  7851 		
  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++;
  7852 					} // End: while
  7684 					} // End: while
  7853 					
  7685 					
  7854 				
  7686 				
  7855 					if (m_eap_fast_completion_status != eap_status_ok)
  7687 					if (m_eap_fast_completion_status != eap_status_ok)
  7856 					{
  7688 					{
  7897 
  7729 
  7898 						m_both_asked++;
  7730 						m_both_asked++;
  7899 
  7731 
  7900 						if(iPacStoreDb->IsMasterKeyPresentL())
  7732 						if(iPacStoreDb->IsMasterKeyPresentL())
  7901 							{
  7733 							{
  7902 				    TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  7734 							m_eap_fast_completion_status = ShowNotifierItemAndGetResponse(
  7903 				    
  7735 								EEapFastNotifierPacStorePwQuery, ETrue );
  7904 				    m_notifier_data_to_user->iPassword.Zero();
       
  7905 				    
       
  7906 				    if (iEapAuthNotifier == 0)
       
  7907 				    	{
       
  7908 				    	iEapAuthNotifier = CEapAuthNotifier::NewL( *this );
       
  7909 				    	}
       
  7910 				    else
       
  7911 					   	{
       
  7912 						 	iEapAuthNotifier->Cancel();
       
  7913 				     	}
       
  7914 				
       
  7915 				    iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastPacStorePwQueryDialog, m_notifier_data_to_user, aEapType);
       
  7916 
       
  7917 
       
  7918 							}
  7736 							}
  7919 						else
  7737 						else
  7920 							{
  7738 							{
  7921 							m_state =  EMasterkeyQuery; 
  7739 							m_state =  EMasterkeyQuery; 
  7922 					    TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  7740 				        	m_eap_fast_completion_status = ShowNotifierItemAndGetResponse(
  7923 					    
  7741 				        		EEapFastNotifierCreateMasterkeyQuery, ETrue );
  7924 					    m_notifier_data_to_user->iPassword.Zero();
       
  7925 					    
       
  7926 					    if (iEapAuthNotifier == 0)
       
  7927 					    	{
       
  7928 					    	iEapAuthNotifier = CEapAuthNotifier::NewL( *this );
       
  7929 					    	}
       
  7930 					    else
       
  7931 						   	{
       
  7932 							 	iEapAuthNotifier->Cancel();
       
  7933 					     	}
       
  7934 					
       
  7935 					    iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastCreateMasterkeyQueryDialog, m_notifier_data_to_user, aEapType);
       
  7936 
       
  7937 							}
  7742 							}
  7938 
  7743 
  7939 						break;
  7744 						break;
  7940 					}
  7745 					}
  7941 			
  7746 			
  7995 					
  7800 					
  7996 					// Create a device seed.
  7801 					// Create a device seed.
  7997 				
  7802 				
  7998 				    eap_variable_data_c m_PAC_store_device_seed(m_am_tools);
  7803 				    eap_variable_data_c m_PAC_store_device_seed(m_am_tools);
  7999 				    m_eap_fast_completion_status = m_PAC_store_device_seed.set_copy_of_buffer(
  7804 				    m_eap_fast_completion_status = m_PAC_store_device_seed.set_copy_of_buffer(
  8000 				    	iPacStoreDeviceSeed );
  7805 				    	iPacStoreDb->GetSeed() );
  8001 					if ( m_eap_fast_completion_status != eap_status_ok )
  7806 					if ( m_eap_fast_completion_status != eap_status_ok )
  8002 					    {
  7807 					    {
  8003 					    EAP_TRACE_DEBUG_SYMBIAN(
  7808 					    EAP_TRACE_DEBUG_SYMBIAN(
  8004 							(_L("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL: ERROR: seed data is not valid.")));	
  7809 							(_L("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL: ERROR: seed data is not valid.")));	
  8005 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7810 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8241 
  8046 
  8242 					m_state = EFilePasswordQuery;
  8047 					m_state = EFilePasswordQuery;
  8243 
  8048 
  8244 					m_both_asked++;
  8049 					m_both_asked++;
  8245 
  8050 
  8246 			    TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  8051 					m_eap_fast_completion_status = ShowNotifierItemAndGetResponse(
  8247 			    
  8052 								EEapFastNotifierPacFilePwQuery, ETrue );
  8248 			    m_notifier_data_to_user->iPassword.Zero();
  8053 					
  8249 			    
       
  8250 			    if (iEapAuthNotifier == 0)
       
  8251 			    	{
       
  8252 			    	iEapAuthNotifier = CEapAuthNotifier::NewL( *this );
       
  8253 			    	}
       
  8254 			    else
       
  8255 				   	{
       
  8256 					 	iEapAuthNotifier->Cancel();
       
  8257 			     	}
       
  8258 			
       
  8259 			    iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastPacFilePwQueryDialog, m_notifier_data_to_user, aEapType);
       
  8260 
       
  8261 					if (m_eap_fast_completion_status != eap_status_ok)
  8054 					if (m_eap_fast_completion_status != eap_status_ok)
  8262 						{
  8055 						{
  8263 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8056 						(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8264 						break;
  8057 						break;
  8265 						}
  8058 						}
  8281 				}
  8074 				}
  8282 				
  8075 				
  8283 			} // End: switch(pacStoreDataRefType)			
  8076 			} // End: switch(pacStoreDataRefType)			
  8284 		}
  8077 		}
  8285 	} // for ()
  8078 	} // for ()
  8286 
       
  8287 	if (m_both_asked)
  8079 	if (m_both_asked)
  8288 	{
       
  8289 		m_eap_fast_completion_status = eap_status_pending_request;
  8080 		m_eap_fast_completion_status = eap_status_pending_request;
  8290 	}
  8081 	m_info_array.Reset();
  8291 
       
  8292 	m_info_array.ResetAndDestroy();
       
  8293 
       
  8294 	EAP_TRACE_DEBUG_SYMBIAN(
  8082 	EAP_TRACE_DEBUG_SYMBIAN(
  8295 		(_L("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL-End, m_eap_fast_completion_status=%d"),
  8083 		(_L("eap_am_type_tls_peap_symbian_c::ReadPACStoredataL-End, m_eap_fast_completion_status=%d"),
  8296 		m_eap_fast_completion_status));			
  8084 		m_eap_fast_completion_status));			
  8297 	
  8085 	
  8298 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
  8086 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
  8488 						isNewEntry = EFalse;
  8276 						isNewEntry = EFalse;
  8489 						
  8277 						
  8490 						break;		
  8278 						break;		
  8491 					}		
  8279 					}		
  8492 					case eap_pac_store_data_type_PAC_store_password:
  8280 					case eap_pac_store_data_type_PAC_store_password:
       
  8281 					{
       
  8282 						//This is not saved anywhere.
       
  8283 						break;		
       
  8284 					}		
  8493 					case eap_pac_store_data_type_PAC_store_device_seed:
  8285 					case eap_pac_store_data_type_PAC_store_device_seed:
       
  8286 					{
       
  8287 						//This is not saved anywhere.
       
  8288 						break;		
       
  8289 					}		
  8494 					case eap_pac_store_data_type_PAC_store_IAP_reference:
  8290 					case eap_pac_store_data_type_PAC_store_IAP_reference:
  8495 					{
  8291 					{
  8496 						//These are not saved anywhere.
  8292 						//This is not saved anywhere.
  8497 						break;		
  8293 						break;		
  8498 					}		
  8294 					}		
  8499 					case eap_pac_store_data_type_PAC_store_group_reference:
  8295 					case eap_pac_store_data_type_PAC_store_group_reference:
  8500 					{
  8296 					{
  8501 						// This should be saved in FAST special settings table in EAP DB, not in PAC store.
  8297 						// This should be saved in FAST special settings table in EAP DB, not in PAC store.
  8681  
  8477  
  8682    	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  8478    	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  8683 	return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8479 	return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8684 }
  8480 }
  8685 	
  8481 	
  8686 //--------------------------------------------------
       
  8687 
       
  8688 void eap_am_type_tls_peap_symbian_c::CompleteAddImportedPACFileL(
  8482 void eap_am_type_tls_peap_symbian_c::CompleteAddImportedPACFileL(
  8689 		const eap_variable_data_c * const in_imported_PAC_filename,
  8483 		const eap_variable_data_c * const in_imported_PAC_filename,
  8690 		const eap_variable_data_c * const out_used_group_reference)
  8484 		const eap_variable_data_c * const out_used_group_reference)
  8691 {
  8485 	{
  8692 	RFs aFs;
  8486 	RFs aFs;
  8693 	aFs.Connect( KFileServerDefaultMessageSlots );
  8487 	aFs.Connect( KFileServerDefaultMessageSlots );
  8694 
  8488 
  8695 	HBufC8* buf = HBufC8::NewLC(in_imported_PAC_filename->get_data_length());
  8489 	HBufC8* buf = HBufC8::NewLC(in_imported_PAC_filename->get_data_length());
  8696 	TPtr8 bufPtr = buf->Des();
  8490 	TPtr8 bufPtr = buf->Des();
  8759 		{
  8553 		{
  8760 		EAP_TRACE_DEBUG_SYMBIAN(
  8554 		EAP_TRACE_DEBUG_SYMBIAN(
  8761 				(_L("eap_am_type_tls_peap_symbian_c::complete_add_imported_PAC_file: NO GROUP REFERENCE !!!!")));	
  8555 				(_L("eap_am_type_tls_peap_symbian_c::complete_add_imported_PAC_file: NO GROUP REFERENCE !!!!")));	
  8762 
  8556 
  8763 		}
  8557 		}
  8764 
  8558 	
  8765 	HBufC* FilePath = HBufC::NewLC(KMaxFileName); // must be defined to correct maxs dir length
  8559 	HBufC* FilePath = HBufC::NewLC(KMaxFileName); // must be defined to correct maxs dir length
  8766 	TPtr FilePathPtr = FilePath->Des();
  8560 	TPtr FilePathPtr = FilePath->Des();
  8767 	HBufC8* FilePath8 = HBufC8::NewLC(KMaxFileName); // must be defined to correct maxs dir length
  8561 	HBufC8* FilePath8 = HBufC8::NewLC(KMaxFileName); // must be defined to correct maxs dir length
  8768 	TPtr8 FilePathPtr8 = FilePath8->Des();
  8562 	TPtr8 FilePathPtr8 = FilePath8->Des();
  8769 
  8563 	
       
  8564 	_LIT8(KPacStoreSourceDir, "c:\\private\\101f8ec5\\PACGroup\\"); // in dir are dirs where from files are read
  8770 	FilePathPtr8.Zero();
  8565 	FilePathPtr8.Zero();
       
  8566 	FilePathPtr8.Append(KPacStoreSourceDir);
  8771 	FilePathPtr8.Append(refPtr);
  8567 	FilePathPtr8.Append(refPtr);
  8772 	FilePathPtr8.Append(KSeparator);
  8568 	FilePathPtr8.Append(KSeparator);
  8773 	FilePathPtr8.Append(bufPtr);
  8569 	FilePathPtr8.Append(bufPtr);
  8774 
  8570 
  8775 	// Copy is the only function that takes TPtr8 type of parameter.
       
  8776 	FilePathPtr.Copy(FilePathPtr8);
  8571 	FilePathPtr.Copy(FilePathPtr8);
  8777 
       
  8778 	{
       
  8779 		TFileName aPrivateDatabasePathName;
       
  8780 
       
  8781 		EapPluginTools::GetPrivatePathL(
       
  8782 			aPrivateDatabasePathName);
       
  8783 
       
  8784 		aPrivateDatabasePathName.Append(KPacStoreSourceDir);
       
  8785 		aPrivateDatabasePathName.Append(FilePathPtr);
       
  8786 
       
  8787 		FilePathPtr.Copy(aPrivateDatabasePathName);
       
  8788 	}
       
  8789 
  8572 
  8790 	EAP_TRACE_DATA_DEBUG(
  8573 	EAP_TRACE_DATA_DEBUG(
  8791    		m_am_tools,
  8574    		m_am_tools,
  8792    		TRACE_FLAGS_DEFAULT,
  8575    		TRACE_FLAGS_DEFAULT,
  8793    		(EAPL("eap_am_type_tls_peap_symbian_c::complete_add_imported_PAC_file: Delete File"),
  8576    		(EAPL("eap_am_type_tls_peap_symbian_c::complete_add_imported_PAC_file: Delete File"),
  8810 	CleanupStack::PopAndDestroy(FilePath8); 
  8593 	CleanupStack::PopAndDestroy(FilePath8); 
  8811 	CleanupStack::PopAndDestroy(FilePath); 
  8594 	CleanupStack::PopAndDestroy(FilePath); 
  8812 	CleanupStack::PopAndDestroy(ref); 
  8595 	CleanupStack::PopAndDestroy(ref); 
  8813 	CleanupStack::PopAndDestroy(buf); 
  8596 	CleanupStack::PopAndDestroy(buf); 
  8814 	
  8597 	
  8815 }
  8598 	}
  8816 
  8599 
  8817 
  8600 
  8818 // ---------------------------------------------------------
  8601 // ---------------------------------------------------------
  8819 // eap_am_type_tls_peap_symbian_c::ContinueInitializePacStore()
  8602 // eap_am_type_tls_peap_symbian_c::ContinueInitializePacStore()
  8820 // ---------------------------------------------------------
  8603 // ---------------------------------------------------------
  8821 //
  8604 //
  8822 void eap_am_type_tls_peap_symbian_c::ContinueInitializePacStore()
  8605 void eap_am_type_tls_peap_symbian_c::ContinueInitializePacStore()
  8823 {
  8606 
       
  8607 	{
  8824 	EAP_TRACE_DEBUG_SYMBIAN(
  8608 	EAP_TRACE_DEBUG_SYMBIAN(
  8825 			(_L("eap_am_type_tls_peap_symbian_c::ContinueInitializePacStore()")));
  8609 			(_L("eap_am_type_tls_peap_symbian_c::ContinueInitializePacStore()")));
  8826 
  8610 
  8827 	TRAPD(error, CheckPasswordTimeValidityL());
  8611 	TRAPD(error, CheckPasswordTimeValidityL());
  8828 
  8612 
  8852 			this,
  8636 			this,
  8853 			KRemoveIAPReferenceTimerID, 
  8637 			KRemoveIAPReferenceTimerID, 
  8854 			0,
  8638 			0,
  8855 			1);
  8639 			1);
  8856 
  8640 
  8857 }
  8641 	}
  8858 
  8642 
  8859 //--------------------------------------------------
  8643 //--------------------------------------------------
  8860 
  8644 
  8861 // This is commented in eap_am_fast_pac_store_services_c::complete_remove_PAC().
  8645 // This is commented in eap_am_fast_pac_store_services_c::complete_remove_PAC().
  8862 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::complete_remove_PAC(
  8646 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::complete_remove_PAC(
  8965 		}
  8749 		}
  8966 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  8750 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  8967 	return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8751 	return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  8968 }
  8752 }
  8969 
  8753 
  8970 //--------------------------------------------------
       
  8971 
       
  8972 // This is commented in eap_am_fast_pac_store_services_c::cancel_PAC_store_operations().
  8754 // This is commented in eap_am_fast_pac_store_services_c::cancel_PAC_store_operations().
  8973 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::cancel_PAC_store_operations()
  8755 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::cancel_PAC_store_operations()
  8974 {
  8756 {
  8975 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  8757 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  8976 	
  8758 	
  8992 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
  8774 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
  8993 }
  8775 }
  8994 
  8776 
  8995 //--------------------------------------------------
  8777 //--------------------------------------------------
  8996 
  8778 
  8997 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::initialize_PAC_store(
  8779 
       
  8780 EAP_FUNC_EXPORT eap_status_e
       
  8781 eap_am_type_tls_peap_symbian_c::initialize_PAC_store(
  8998 	const eap_fast_completion_operation_e aCompletionOperation,
  8782 	const eap_fast_completion_operation_e aCompletionOperation,
  8999 	const eap_fast_initialize_pac_store_completion_e aCompletion )
  8783 	const eap_fast_initialize_pac_store_completion_e aCompletion )
  9000 {
  8784 {
  9001     EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  8785     EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  9002     EAP_TRACE_DEBUG(m_am_tools, 
  8786     EAP_TRACE_DEBUG(m_am_tools, 
  9033 			        EAP_TRACE_DEBUG_SYMBIAN(
  8817 			        EAP_TRACE_DEBUG_SYMBIAN(
  9034 						(_L("eap_am_type_tls_peap_symbian_c::initialize_PAC_store(): ERROR: Leave in SetPacStoreInitValueL()")));	
  8818 						(_L("eap_am_type_tls_peap_symbian_c::initialize_PAC_store(): ERROR: Leave in SetPacStoreInitValueL()")));	
  9035 		    	    }
  8819 		    	    }
  9036         	    }
  8820         	    }
  9037 		    // asynch. call, return immediately
  8821 		    // asynch. call, return immediately
  9038 		    CreateDeviceSeedAsync();
  8822 		    iPacStoreDb->CreateDeviceSeedAsynch();
  9039 		    }
  8823 		    }
  9040     	else
  8824     	else
  9041     		{
  8825     		{
  9042 	        EAP_TRACE_DEBUG_SYMBIAN( ( _L(
  8826 	        EAP_TRACE_DEBUG_SYMBIAN( ( _L(
  9043 	        	"ERROR: eap_am_type_tls_peap_symbian_c::initialize_PAC_store(): Leave, IsInitializedL(), err=%d.\n"),
  8827 	        	"ERROR: eap_am_type_tls_peap_symbian_c::initialize_PAC_store(): Leave, IsInitializedL(), err=%d.\n"),
  9059 
  8843 
  9060 // ---------------------------------------------------------------------------
  8844 // ---------------------------------------------------------------------------
  9061 // eap_am_type_tls_peap_symbian_c::indicates_eap_fast_provisioning_starts
  8845 // eap_am_type_tls_peap_symbian_c::indicates_eap_fast_provisioning_starts
  9062 // ---------------------------------------------------------------------------
  8846 // ---------------------------------------------------------------------------
  9063 //  
  8847 //  
  9064 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::indicates_eap_fast_provisioning_starts(
  8848 EAP_FUNC_EXPORT
       
  8849 eap_status_e eap_am_type_tls_peap_symbian_c::indicates_eap_fast_provisioning_starts(
  9065 	const eap_fast_completion_operation_e provisioning_mode,
  8850 	const eap_fast_completion_operation_e provisioning_mode,
  9066 	const eap_fast_pac_type_e pac_type )
  8851 	const eap_fast_pac_type_e pac_type )
  9067 {
  8852 	{
  9068 	eap_status_e status( eap_status_ok );
  8853 	eap_status_e status( eap_status_ok );
  9069 	m_provisioning_mode = provisioning_mode; // save provis. mode
  8854 	m_provisioning_mode = provisioning_mode; // save provis. mode
  9070 
  8855 	
  9071 	TInt error(KErrNone);
  8856 	TInt err = KErrNone;	
  9072 
  8857 	if ( !iEapFastActiveWaitNote )
  9073 	TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  8858 		{
  9074 
  8859 		TRAP( err, iEapFastActiveWaitNote = CEapFastActive::NewL( this ) );
  9075 	m_notifier_data_to_user->iPassword.Zero();
  8860 		}
  9076 
  8861 	if ( !iEapFastActiveNotes )
  9077 	if (iEapAuthNotifier == 0)
  8862 		{
  9078 	{
  8863 		TRAP( err, iEapFastActiveNotes = CEapFastActive::NewL( this ) );
  9079 		TRAP(error, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
  8864 		}
  9080 		if (error)
  8865 	if ( err != KErrNone )
  9081 		{
  8866 		{
  9082 			return m_am_tools->convert_am_error_to_eapol_error(error);
  8867 		status = eap_status_allocation_error;
  9083 		}
  8868 		}	
  9084 	}
  8869 	/**
  9085 	else
  8870 	* The note is started in a separate active object.
  9086 	{
  8871 	* When user cancels waiting note,
  9087 		TRAP(error, iEapAuthNotifier->Cancel());
  8872 	* SendErrorNotification( eap_status_user_cancel_authentication )
  9088 		if (error)
  8873 	* will be called in iEapFastActiveWaitNote->RunL().
  9089 		{
  8874 	* Otherwise note is stopped using iEapFastActiveWaitNote.Start() method.
  9090 			return m_am_tools->convert_am_error_to_eapol_error(error);
  8875 	*/
  9091 		}
  8876 	TBool startedOk = ETrue;
  9092 	}
  8877 	
  9093 
       
  9094 	if ( pac_type == eap_fast_pac_type_tunnel_pac
  8878 	if ( pac_type == eap_fast_pac_type_tunnel_pac
  9095 		 && provisioning_mode == eap_fast_completion_operation_server_authenticated_provisioning_mode
  8879 		 &&
  9096 		 && status == eap_status_ok )
  8880 		 provisioning_mode ==
  9097 	{
  8881 		     eap_fast_completion_operation_server_authenticated_provisioning_mode
  9098 		TRAP(error, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastStartAuthProvWaitNote, m_notifier_data_to_user, aEapType));
  8882 		 &&
  9099 		if (error)
  8883 		 status == eap_status_ok )
  9100 		{
  8884 		{
  9101 			return m_am_tools->convert_am_error_to_eapol_error(error);
  8885 		EAP_TRACE_DEBUG_SYMBIAN( ( _L("eap_am_type_tls_peap_symbian_c:: \
  9102 		}
  8886 				indicates_eap_fast_provisioning_starts Authenticated provisioning!")));			
  9103 	}
  8887 		startedOk = iEapFastActiveWaitNote->Start(
       
  8888 			CEapFastActive::EEapFastActiveStartAuthProvWaitNote );
       
  8889 		}
  9104 	else if (
  8890 	else if (
  9105 		pac_type == eap_fast_pac_type_tunnel_pac
  8891 		pac_type == eap_fast_pac_type_tunnel_pac
  9106 		&& provisioning_mode == eap_fast_completion_operation_server_unauthenticated_provisioning_mode_ADHP
  8892 		&&
  9107 	  && status == eap_status_ok )
  8893 		provisioning_mode ==
  9108 	{
  8894 	        eap_fast_completion_operation_server_unauthenticated_provisioning_mode_ADHP
  9109 		TRAP(error, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastStartUnauthProvWaitNote, m_notifier_data_to_user, aEapType));
  8895 	    &&
  9110 		if (error)
  8896 	    status == eap_status_ok )
  9111 		{
  8897 		{
  9112 			return m_am_tools->convert_am_error_to_eapol_error(error);
  8898 		EAP_TRACE_DEBUG_SYMBIAN(  (_L("eap_am_type_tls_peap_symbian_c:: \
  9113 		}
  8899 			indicates_eap_fast_provisioning_starts UnAuthenticated provisioning!")));			
  9114 	}
  8900 		startedOk = iEapFastActiveWaitNote->Start(
  9115 
  8901         	CEapFastActive::EEapFastActiveStartUnauthProvWaitNote );        
  9116 
  8902 		}
  9117 
  8903 	if ( startedOk == EFalse )
       
  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 		}
  9118 	return status;
  8912 	return status;
  9119 }
  8913 	}
  9120 
  8914 
  9121 // ---------------------------------------------------------------------------
  8915 // ---------------------------------------------------------------------------
  9122 // eap_am_type_tls_peap_symbian_c::indicates_eap_fast_provisioning_ends
  8916 // eap_am_type_tls_peap_symbian_c::indicates_eap_fast_provisioning_ends
  9123 // ---------------------------------------------------------------------------
  8917 // ---------------------------------------------------------------------------
  9124 //  
  8918 //  
  9125 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::indicates_eap_fast_provisioning_ends(
  8919 EAP_FUNC_EXPORT
       
  8920 eap_status_e eap_am_type_tls_peap_symbian_c::indicates_eap_fast_provisioning_ends(
  9126     const bool provisioning_successfull,
  8921     const bool provisioning_successfull,
  9127     const eap_fast_completion_operation_e provisioning_mode,
  8922     const eap_fast_completion_operation_e provisioning_mode,
  9128     const eap_fast_pac_type_e pac_type )
  8923     const eap_fast_pac_type_e pac_type )
  9129 {	
  8924 	{	
  9130 	EAP_TRACE_DEBUG_SYMBIAN( (_L("eap_am_type_tls_peap_symbian_c::indicates_eap_fast_provisioning_ends()")));
  8925 	EAP_TRACE_DEBUG_SYMBIAN( (_L("eap_am_type_tls_peap_symbian_c:: \
       
  8926 	    indicates_eap_fast_provisioning_ends()")));
  9131 
  8927 
  9132 	EAP_UNREFERENCED_PARAMETER(provisioning_mode);
  8928 	EAP_UNREFERENCED_PARAMETER(provisioning_mode);
  9133 
  8929 
  9134 	TInt error(KErrNone);
       
  9135 
       
  9136 	eap_status_e status( eap_status_ok );
  8930 	eap_status_e status( eap_status_ok );
  9137 
  8931 	
  9138 	if ( pac_type == eap_fast_pac_type_tunnel_pac )
  8932 	if ( pac_type == eap_fast_pac_type_tunnel_pac )
  9139 	{
  8933 		{
  9140 		// stop wait note;
  8934 	    // stop wait note;
  9141 		TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  8935 		if ( iEapFastActiveWaitNote )
  9142 
  8936 			{
  9143 		m_notifier_data_to_user->iPassword.Zero();
  8937 			if ( iEapFastActiveWaitNote->IsActive() )
  9144 
  8938 				{
  9145 		if (iEapAuthNotifier == 0)
  8939 				iEapFastActiveWaitNote->Cancel();
  9146 		{
  8940 				}
  9147 			TRAP(error, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
  8941 			delete iEapFastActiveWaitNote;
  9148 			if (error)
  8942 			iEapFastActiveWaitNote = NULL;
  9149 			{
  8943 			}
  9150 				return m_am_tools->convert_am_error_to_eapol_error(error);
  8944 
  9151 			}
  8945 	    if ( iEapFastActiveNotes )
  9152 		}
  8946 		    {	    
  9153 		else
  8947             if( provisioning_successfull )
  9154 		{
  8948 		        {
  9155 			TRAP(error, iEapAuthNotifier->Cancel());
  8949 		        // synch. call
  9156 			if (error)
  8950 		        iEapFastActiveNotes->Start( CEapFastActive::
  9157 			{
  8951 		            EEapFastActiveShowProvSuccessNote, ETrue );
  9158 				return m_am_tools->convert_am_error_to_eapol_error(error);
  8952 		        }
  9159 			}
  8953             else
  9160 		}
  8954       	        {
  9161 
  8955       	        // synch. call
  9162 		if( !provisioning_successfull )
  8956       	        iEapFastActiveNotes->Start( CEapFastActive::
  9163 		{
  8957       	            EapFastActiveShowProvNotSuccessNote, ETrue );
  9164 			TRAP(error, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastShowProvNotSuccessNote, m_notifier_data_to_user, aEapType));
  8958       	        }
  9165 			if (error)
  8959 		    }
  9166 			{
  8960 		} // if ( pac_type == eap_fast_pac_type_tunnel_pac )
  9167 				return m_am_tools->convert_am_error_to_eapol_error(error);
       
  9168 			}
       
  9169 		}
       
  9170 	} // if ( pac_type == eap_fast_pac_type_tunnel_pac )
       
  9171 
  8961 
  9172 	return status;
  8962 	return status;
  9173 }
  8963 	}
  9174 
  8964 
  9175 #endif //#if defined(USE_FAST_EAP_TYPE)
  8965 #endif //#if defined(USE_FAST_EAP_TYPE)
  9176 
       
  9177 //--------------------------------------------------
       
  9178 
  8966 
  9179 #ifdef USE_PAC_STORE
  8967 #ifdef USE_PAC_STORE
  9180 	
  8968 	
  9181 void eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL(
  8969 void eap_am_type_tls_peap_symbian_c::GetPacStoreDbDataL(
  9182 	const eap_pac_store_data_type_e aPacStoreDataType,
  8970 	const eap_pac_store_data_type_e aPacStoreDataType,
  9444 	
  9232 	
  9445 #endif	// End: #ifdef USE_PAC_STORE
  9233 #endif	// End: #ifdef USE_PAC_STORE
  9446 
  9234 
  9447 //--------------------------------------------------
  9235 //--------------------------------------------------
  9448 
  9236 
  9449 #ifdef USE_FAST_EAP_TYPE
  9237 #if defined(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 
  9450 //--------------------------------------------------
  9303 //--------------------------------------------------
  9451 
  9304 
  9452 eap_status_e eap_am_type_tls_peap_symbian_c::RemoveIAPReference()
  9305 eap_status_e eap_am_type_tls_peap_symbian_c::RemoveIAPReference()
  9453 {
  9306 	{
  9454 	EAP_TRACE_DEBUG_SYMBIAN(
  9307 	EAP_TRACE_DEBUG_SYMBIAN(
  9455 		(_L("eap_am_type_tls_peap_symbian_c::RemoveIAPReference - Start")));
  9308 		(_L("eap_am_type_tls_peap_symbian_c::RemoveIAPReference - Start")));
  9456 	m_eap_fast_completion_status = eap_status_ok;	
  9309 	m_eap_fast_completion_status = eap_status_ok;	
  9457 			
  9310 			
  9458 	eap_variable_data_c aIapReference(m_am_tools);
  9311 	eap_variable_data_c aIapReference(m_am_tools);
  9512 		}
  9365 		}
  9513 	EAP_TRACE_DEBUG_SYMBIAN(
  9366 	EAP_TRACE_DEBUG_SYMBIAN(
  9514 		(_L("eap_am_type_tls_peap_symbian_c::RemoveIAPReference - End")));
  9367 		(_L("eap_am_type_tls_peap_symbian_c::RemoveIAPReference - End")));
  9515 		
  9368 		
  9516 	return m_eap_fast_completion_status;
  9369 	return m_eap_fast_completion_status;
  9517 }
  9370 	}
  9518 
       
  9519 //--------------------------------------------------
       
  9520 
  9371 
  9521 eap_status_e eap_am_type_tls_peap_symbian_c::ImportFilesL()
  9372 eap_status_e eap_am_type_tls_peap_symbian_c::ImportFilesL()
  9522 {
  9373 	{
  9523 
  9374 
  9524 	EAP_TRACE_DEBUG_SYMBIAN(
  9375 	EAP_TRACE_DEBUG_SYMBIAN(
  9525 			(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL - Start")));
  9376 			(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL - Start")));
  9526 	
  9377 	
  9527 	CDir* files;
  9378 	CDir* files;
  9612 	TPtr8 PathPtr8 = Path8->Des();
  9463 	TPtr8 PathPtr8 = Path8->Des();
  9613 	HBufC8* readData = NULL;
  9464 	HBufC8* readData = NULL;
  9614 	TBool FileFound(EFalse);
  9465 	TBool FileFound(EFalse);
  9615 	
  9466 	
  9616 	PathPtr8.Zero();
  9467 	PathPtr8.Zero();
       
  9468 	PathPtr8.Append(KPacStoreSourceDir);
  9617 	PathPtr8.Append(group_referencePtr8);
  9469 	PathPtr8.Append(group_referencePtr8);
  9618 	PathPtr8.Append(KSeparator);
  9470 	PathPtr8.Append(KSeparator);
  9619 
       
  9620 	EAP_TRACE_DATA_DEBUG(
  9471 	EAP_TRACE_DATA_DEBUG(
  9621 			m_am_tools,
  9472 			m_am_tools,
  9622 			TRACE_FLAGS_DEFAULT,
  9473 			TRACE_FLAGS_DEFAULT,
  9623 			(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Path8"),
  9474 			(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Path8"),
  9624 			PathPtr8.Ptr(),
  9475 			PathPtr8.Ptr(),
  9625 			PathPtr8.Size()));
  9476 			PathPtr8.Size()));
  9626 
       
  9627 	PathPtr.Zero();
  9477 	PathPtr.Zero();
  9628 	// Copy is the only function that takes TPtr8 type of parameter.
       
  9629 	PathPtr.Copy(PathPtr8);
  9478 	PathPtr.Copy(PathPtr8);
  9630 	
  9479 	
  9631 	{
       
  9632 		TFileName aPrivateDatabasePathName;
       
  9633 
       
  9634 		EapPluginTools::GetPrivatePathL(
       
  9635 			aPrivateDatabasePathName);
       
  9636 
       
  9637 		aPrivateDatabasePathName.Append(KPacStoreSourceDir);
       
  9638 		aPrivateDatabasePathName.Append(PathPtr);
       
  9639 
       
  9640 		PathPtr.Copy(aPrivateDatabasePathName);
       
  9641 	}
       
  9642 
       
  9643 	EAP_TRACE_DATA_DEBUG(
  9480 	EAP_TRACE_DATA_DEBUG(
  9644 			m_am_tools,
  9481 			m_am_tools,
  9645 			TRACE_FLAGS_DEFAULT,
  9482 			TRACE_FLAGS_DEFAULT,
  9646 			(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Path"),
  9483 			(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Path"),
  9647 			PathPtr.Ptr(),
  9484 			PathPtr.Ptr(),
  9648 			PathPtr.Size()));
  9485 			PathPtr.Size()));
  9649 
  9486 			
  9650 	EAP_TRACE_DEBUG_SYMBIAN(
  9487 	EAP_TRACE_DEBUG_SYMBIAN(
  9651 			(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: Check directory availability")));					
  9488 			(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: Check directory availability")));					
  9652 
  9489 
  9653 	if (aFs.GetDir(PathPtr, KEntryAttNormal, ESortByName, files) == KErrNone)
  9490 	if (aFs.GetDir(PathPtr, KEntryAttNormal, ESortByName, files) == KErrNone)
  9654 		{
  9491 		{
  9663 			EAP_TRACE_DEBUG_SYMBIAN(
  9500 			EAP_TRACE_DEBUG_SYMBIAN(
  9664 					(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: Get directory contents")));					
  9501 					(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: Get directory contents")));					
  9665 
  9502 
  9666 			directoryEmpty = false;
  9503 			directoryEmpty = false;
  9667 
  9504 
  9668 			while( fileCounter < files->Count())
  9505 			while( fileCounter < files->Count() || (!FileFound))
  9669 				{
  9506 				{
  9670 				if (!((*files)[fileCounter].IsDir()))
  9507 				if (!((*files)[fileCounter].IsDir()))
  9671 					{
  9508 					{
  9672 					filesize = (*files)[fileCounter].iSize;
  9509 					filesize = (*files)[fileCounter].iSize;
  9673 					EAP_TRACE_DEBUG_SYMBIAN(
  9510 					EAP_TRACE_DEBUG_SYMBIAN(
  9706 				           m_eap_fast_completion_status = m_partner->set_timer(
  9543 				           m_eap_fast_completion_status = m_partner->set_timer(
  9707 				                    this,
  9544 				                    this,
  9708 				                    KHandleCompletePacstoreOkTimerID, 
  9545 				                    KHandleCompletePacstoreOkTimerID, 
  9709 				                    &m_eap_fast_completion_status,
  9546 				                    &m_eap_fast_completion_status,
  9710 				                    1);
  9547 				                    1);
       
  9548 					   	if (readData != NULL)
       
  9549 					   		CleanupStack::PopAndDestroy(readData);
  9711 					   	CleanupStack::PopAndDestroy(5); // Path, Path8, filename, buf2, group_reference8
  9550 					   	CleanupStack::PopAndDestroy(5); // Path, Path8, filename, buf2, group_reference8
  9712 						EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  9551 						EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  9713 						return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  9552 						return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  9714 				   		}
  9553 				   		}
  9715 					}
  9554 					}
  9716 				}
  9555 				}
  9717 			else if(directoryEmpty == false &&  directoryExists == true && FileFound != EFalse)
  9556 			else if(directoryEmpty == false &&  directoryExists == true && FileFound != EFalse)
  9718 				{
  9557 				{
  9719 				PathPtr8.Zero();
  9558 				PathPtr8.Zero();
       
  9559 				PathPtr8.Append(KPacStoreSourceDir);
  9720 				PathPtr8.Append(group_referencePtr8);
  9560 				PathPtr8.Append(group_referencePtr8);
  9721 				PathPtr8.Append(KSeparator);
  9561 				PathPtr8.Append(KSeparator);
  9722 				PathPtr8.Append(filenamePtr8);
  9562 				PathPtr8.Append(filenamePtr8);
  9723 
       
  9724 				EAP_TRACE_DATA_DEBUG(
  9563 				EAP_TRACE_DATA_DEBUG(
  9725 						m_am_tools,
  9564 						m_am_tools,
  9726 						TRACE_FLAGS_DEFAULT,
  9565 						TRACE_FLAGS_DEFAULT,
  9727 						(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Path8"),
  9566 						(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: Path8"),
  9728 						PathPtr8.Ptr(),
  9567 						PathPtr8.Ptr(),
  9729 						PathPtr8.Size()));
  9568 						PathPtr8.Size()));
  9730 
       
  9731 				PathPtr.Zero();
  9569 				PathPtr.Zero();
  9732 				PathPtr.Copy(PathPtr8);
  9570 				PathPtr.Copy(PathPtr8);
  9733 
       
  9734 				{
       
  9735 					TFileName aPrivateDatabasePathName;
       
  9736 
       
  9737 					EapPluginTools::GetPrivatePathL(
       
  9738 						aPrivateDatabasePathName);
       
  9739 
       
  9740 					aPrivateDatabasePathName.Append(KPacStoreSourceDir);
       
  9741 					aPrivateDatabasePathName.Append(PathPtr);
       
  9742 
       
  9743 					PathPtr.Copy(aPrivateDatabasePathName);
       
  9744 				}
       
  9745 				
  9571 				
  9746 				EAP_TRACE_DATA_DEBUG(
       
  9747 						m_am_tools,
       
  9748 						TRACE_FLAGS_DEFAULT,
       
  9749 						(EAPL("eap_am_type_tls_peap_symbian_c::ImportFilesL: PathPtr"),
       
  9750 						PathPtr.Ptr(),
       
  9751 						PathPtr.Size()));
       
  9752 
       
  9753 				EAP_TRACE_DEBUG_SYMBIAN(
  9572 				EAP_TRACE_DEBUG_SYMBIAN(
  9754 						(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: Read file")));	
  9573 						(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: Read file")));	
  9755 				
  9574 				
  9756 				RFile file;
  9575 				RFile file;
  9757 
       
  9758 				if(file.Open(aFs, PathPtr, EFileRead)==KErrNone)
  9576 				if(file.Open(aFs, PathPtr, EFileRead)==KErrNone)
  9759 					{
  9577 					{
  9760 					readData= HBufC8::NewLC(filesize); 
  9578 					readData= HBufC8::NewLC(filesize); 
  9761 					TPtr8 readDataPtr = readData->Des();
  9579 					TPtr8 readDataPtr = readData->Des();
  9762 					file.Read(readDataPtr);
  9580 					file.Read(readDataPtr);
  9869 			    m_eap_fast_completion_status = eap_status_ok;
  9687 			    m_eap_fast_completion_status = eap_status_ok;
  9870 	        m_eap_fast_completion_status = m_partner->set_timer(
  9688 	        m_eap_fast_completion_status = m_partner->set_timer(
  9871 	                this,
  9689 	                this,
  9872 	                KHandleCompletePacstoreNokTimerID, 
  9690 	                KHandleCompletePacstoreNokTimerID, 
  9873 	                &m_eap_fast_completion_status,
  9691 	                &m_eap_fast_completion_status,
  9874 	                0);
  9692 	                1);
  9875 			}
  9693 			}
  9876 		else
  9694 		else
  9877 			{
  9695 			{
  9878 		       m_eap_fast_completion_status = m_partner->set_timer(
  9696 		       m_eap_fast_completion_status = m_partner->set_timer(
  9879 		                this,
  9697 		                this,
  9880 		                KHandleCompletePacstoreOkTimerID, 
  9698 		                KHandleCompletePacstoreOkTimerID, 
  9881 		                &m_eap_fast_completion_status,
  9699 		                &m_eap_fast_completion_status,
  9882 		                0);
  9700 		                1);
  9883 			}
  9701 			}
  9884 		}
  9702 		}
  9885 	EAP_TRACE_DEBUG_SYMBIAN(
  9703 	EAP_TRACE_DEBUG_SYMBIAN(
  9886 			(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL - End")));
  9704 			(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL - End")));
  9887 
  9705 
  9888 	return m_eap_fast_completion_status;
  9706 	return m_eap_fast_completion_status;
  9889 }
  9707 	}
  9890 
  9708 
  9891 // ----------------------------------------------------------------------------
  9709 // ----------------------------------------------------------------------------
  9892 
       
  9893 eap_status_e eap_am_type_tls_peap_symbian_c::PasswordQueryL()
  9710 eap_status_e eap_am_type_tls_peap_symbian_c::PasswordQueryL()
  9894 {
  9711 	{
  9895 
  9712 
  9896 	EAP_TRACE_DEBUG_SYMBIAN(
  9713 	EAP_TRACE_DEBUG_SYMBIAN(
  9897 			(_L("eap_am_type_tls_peap_symbian_c::PasswordQueryL")));
  9714 			(_L("eap_am_type_tls_peap_symbian_c::PasswordQueryL")));
  9898 
  9715 
  9899 	m_pacStorePWBuf8 = HBufC8::NewLC(m_userResponse.get_data_length());
  9716 	m_pacStorePWBuf8 = HBufC8::NewLC(m_userResponse.get_data_length());
  9940 
  9757 
  9941 		  if(m_verificationStatus == EFalse)
  9758 		  if(m_verificationStatus == EFalse)
  9942 	    	{
  9759 	    	{
  9943 	    	CleanupStack::PopAndDestroy(m_pacStorePWBuf8);
  9760 	    	CleanupStack::PopAndDestroy(m_pacStorePWBuf8);
  9944 	    	
  9761 	    	
  9945 		    TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  9762 	    	m_eap_fast_completion_status = ShowNotifierItemAndGetResponse(
  9946 		    
  9763 	    		EEapFastNotifierWrongPacStorePwNote, ETrue );
  9947 		    m_notifier_data_to_user->iPassword.Zero();
       
  9948 	
       
  9949 			return m_eap_fast_completion_status;
  9764 			return m_eap_fast_completion_status;
  9950 			 	    
  9765 			 	    
  9951 	    	}
  9766 	    	}
  9952 		  else
  9767 		  else
  9953 	    	{
  9768 	    	{
  9972     					m_state, 
  9787     					m_state, 
  9973     					m_prev_state,
  9788     					m_prev_state,
  9974     					m_verificationStatus));
  9789     					m_verificationStatus));
  9975        	pacStorePWPtr8.Zero();
  9790        	pacStorePWPtr8.Zero();
  9976        	if (m_verificationStatus == EFalse)
  9791        	if (m_verificationStatus == EFalse)
  9977 					{
  9792 			m_eap_fast_completion_status = ShowNotifierItemAndGetResponse(
  9978     TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  9793 				EEapFastNotifierPacStorePwQuery, ETrue );
  9979     if (iEapAuthNotifier == 0)
       
  9980     	{
       
  9981     	TRAPD(err3, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
       
  9982     	if (err3)
       
  9983     		{
       
  9984     			return eap_status_process_general_error;
       
  9985     		}
       
  9986     	}
       
  9987     else
       
  9988     	{
       
  9989     	TRAPD(err4, iEapAuthNotifier->Cancel());
       
  9990     	if (err4)
       
  9991     		{
       
  9992     			return eap_status_process_general_error;
       
  9993     		}
       
  9994     	}
       
  9995 
       
  9996 		TRAPD(err5, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastPacStorePwQueryDialog, m_notifier_data_to_user, aEapType));
       
  9997   	if (err5)
       
  9998   		{
       
  9999   			return eap_status_process_general_error;
       
 10000   		}
       
 10001  
       
 10002 
       
 10003 					}
       
 10004 		else
  9794 		else
 10005 			m_eap_fast_completion_status = m_partner->set_timer(
  9795 			m_eap_fast_completion_status = m_partner->set_timer(
 10006 				this,
  9796 				this,
 10007 				KHandleReadPacstoreTimerID, 
  9797 				KHandleReadPacstoreTimerID, 
 10008 				&m_eap_fast_completion_status,
  9798 				&m_eap_fast_completion_status,
 10020     		EAP_TRACE_DEBUG_SYMBIAN(
  9810     		EAP_TRACE_DEBUG_SYMBIAN(
 10021     			(_L("eap_am_type_tls_peap_symbian_c::PasswordQueryL - EMasterkeyQuery - OK")));
  9811     			(_L("eap_am_type_tls_peap_symbian_c::PasswordQueryL - EMasterkeyQuery - OK")));
 10022     		}
  9812     		}
 10023      	else // temporary before masterkey creation is done dynamically !!!
  9813      	else // temporary before masterkey creation is done dynamically !!!
 10024     		{
  9814     		{
 10025     TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  9815         	m_eap_fast_completion_status = ShowNotifierItemAndGetResponse(
 10026     if (iEapAuthNotifier == 0)
  9816         			EEapFastNotifierCreateMasterkeyQuery, ETrue );
 10027     	{
  9817    		
 10028     	TRAPD(err, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
  9818 			}
 10029 	  	if (err)
       
 10030 	  		{
       
 10031 	  			return eap_status_process_general_error;
       
 10032 	  		}
       
 10033     	}
       
 10034     else
       
 10035     	{
       
 10036     	TRAPD(err1, iEapAuthNotifier->Cancel());
       
 10037 	  	if (err1)
       
 10038 	  		{
       
 10039 	  			return eap_status_process_general_error;
       
 10040 	  		}
       
 10041     	}
       
 10042 
       
 10043 		TRAPD(err2, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastCreateMasterkeyQueryDialog, m_notifier_data_to_user, aEapType));
       
 10044   	if (err2)
       
 10045   		{
       
 10046   			return eap_status_process_general_error;
       
 10047   		}
       
 10048 			
       
 10049 
       
 10050 
       
 10051 				}
       
 10052     	}
  9819     	}
 10053 
  9820 
 10054     CleanupStack::PopAndDestroy(m_pacStorePWBuf8);
  9821     CleanupStack::PopAndDestroy(m_pacStorePWBuf8);
 10055     
  9822     
 10056 	return m_eap_fast_completion_status;
  9823 	return m_eap_fast_completion_status;
 10057 }
  9824 	}
 10058 
       
 10059 //--------------------------------------------------
       
 10060 
  9825 
 10061 eap_status_e eap_am_type_tls_peap_symbian_c::CompletePasswordQueryL()
  9826 eap_status_e eap_am_type_tls_peap_symbian_c::CompletePasswordQueryL()
 10062 {
  9827 	{
 10063 
  9828 
 10064 	EAP_TRACE_DEBUG_SYMBIAN(
  9829 	EAP_TRACE_DEBUG_SYMBIAN(
 10065 			(_L("eap_am_type_tls_peap_symbian_c::CompletePasswordQueryL")));
  9830 			(_L("eap_am_type_tls_peap_symbian_c::CompletePasswordQueryL")));
 10066 
  9831 
 10067 	// m_PAC_store_password should have the PW now. Proceed as normal case.	
  9832 	// m_PAC_store_password should have the PW now. Proceed as normal case.	
 10130 	}
  9895 	}
 10131 
  9896 
 10132 	m_both_completed++;
  9897 	m_both_completed++;
 10133 
  9898 
 10134 	return m_eap_fast_completion_status;
  9899 	return m_eap_fast_completion_status;
 10135 }
  9900 	}
 10136 
       
 10137 //--------------------------------------------------
       
 10138 
  9901 
 10139 eap_status_e eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL(eap_status_e status)
  9902 eap_status_e eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL(eap_status_e status)
 10140 {
  9903 	{
 10141 	EAP_TRACE_DEBUG_SYMBIAN(
  9904 	EAP_TRACE_DEBUG_SYMBIAN(
 10142 			(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL")));
  9905 			(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL")));
 10143 	if (status == eap_status_ok && (m_new_references_and_data_blocks.get_object_count()>0))
  9906 	if (status == eap_status_ok && (m_new_references_and_data_blocks.get_object_count()>0))
 10144 		{
  9907 		{
 10145 		for (u32_t ind = 0ul; ind < m_ready_references_array_index; ++ind)
  9908 		for (u32_t ind = 0ul; ind < m_ready_references_array_index; ++ind)
 10155 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  9918 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10156 	
  9919 	
 10157 				EAP_TRACE_DEBUG_SYMBIAN(
  9920 				EAP_TRACE_DEBUG_SYMBIAN(
 10158 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
  9921 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10159 				m_ready_references_and_data_blocks.reset();
  9922 				m_ready_references_and_data_blocks.reset();
 10160 				
  9923 				eap_status_e status = m_tls_application->complete_read_PAC_store_data(
 10161 				status = m_tls_application->complete_read_PAC_store_data(
       
 10162 					m_eap_fast_completion_status,
  9924 					m_eap_fast_completion_status,
 10163 					m_eap_fast_pac_store_pending_operation,
  9925 					m_eap_fast_pac_store_pending_operation,
 10164 					&m_references_and_data_blocks);
  9926 					&m_references_and_data_blocks);
 10165 				
  9927 				
 10166 				return status;
  9928 				return status;
 10174 			{
  9936 			{
 10175 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  9937 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10176 				EAP_TRACE_DEBUG_SYMBIAN(
  9938 				EAP_TRACE_DEBUG_SYMBIAN(
 10177 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
  9939 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10178 				m_ready_references_and_data_blocks.reset();
  9940 				m_ready_references_and_data_blocks.reset();
 10179 				
  9941 				eap_status_e status = m_tls_application->complete_read_PAC_store_data(
 10180 				status = m_tls_application->complete_read_PAC_store_data(
       
 10181 					m_eap_fast_completion_status,
  9942 					m_eap_fast_completion_status,
 10182 					m_eap_fast_pac_store_pending_operation,
  9943 					m_eap_fast_pac_store_pending_operation,
 10183 					&m_references_and_data_blocks);
  9944 					&m_references_and_data_blocks);
 10184 				
  9945 				
 10185 				return status;
  9946 				return status;
 10190 			{
  9951 			{
 10191 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  9952 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10192 				EAP_TRACE_DEBUG_SYMBIAN(
  9953 				EAP_TRACE_DEBUG_SYMBIAN(
 10193 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
  9954 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10194 				m_ready_references_and_data_blocks.reset();
  9955 				m_ready_references_and_data_blocks.reset();
 10195 				
  9956 				eap_status_e status = m_tls_application->complete_read_PAC_store_data(
 10196 				status = m_tls_application->complete_read_PAC_store_data(
       
 10197 					m_eap_fast_completion_status,
  9957 					m_eap_fast_completion_status,
 10198 					m_eap_fast_pac_store_pending_operation,
  9958 					m_eap_fast_pac_store_pending_operation,
 10199 					&m_references_and_data_blocks);
  9959 					&m_references_and_data_blocks);
 10200 				
  9960 				
 10201 				return status;
  9961 				return status;
 10208 			{
  9968 			{
 10209 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  9969 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10210 				EAP_TRACE_DEBUG_SYMBIAN(
  9970 				EAP_TRACE_DEBUG_SYMBIAN(
 10211 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
  9971 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10212 				m_ready_references_and_data_blocks.reset();
  9972 				m_ready_references_and_data_blocks.reset();
 10213 				
  9973 				eap_status_e status = m_tls_application->complete_read_PAC_store_data(
 10214 				status = m_tls_application->complete_read_PAC_store_data(
       
 10215 					m_eap_fast_completion_status,
  9974 					m_eap_fast_completion_status,
 10216 					m_eap_fast_pac_store_pending_operation,
  9975 					m_eap_fast_pac_store_pending_operation,
 10217 					&m_references_and_data_blocks);
  9976 					&m_references_and_data_blocks);
 10218 				
  9977 				
 10219 				return status;
  9978 				return status;
 10236 			m_eap_fast_completion_status = eap_status_allocation_error;
  9995 			m_eap_fast_completion_status = eap_status_allocation_error;
 10237 			(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  9996 			(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10238 			EAP_TRACE_DEBUG_SYMBIAN(
  9997 			EAP_TRACE_DEBUG_SYMBIAN(
 10239 					(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
  9998 					(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10240 			m_ready_references_and_data_blocks.reset();
  9999 			m_ready_references_and_data_blocks.reset();
 10241 			
 10000 			eap_status_e status = m_tls_application->complete_read_PAC_store_data(
 10242 			status = m_tls_application->complete_read_PAC_store_data(
       
 10243 				m_eap_fast_completion_status,
 10001 				m_eap_fast_completion_status,
 10244 				m_eap_fast_pac_store_pending_operation,
 10002 				m_eap_fast_pac_store_pending_operation,
 10245 				&m_references_and_data_blocks);
 10003 				&m_references_and_data_blocks);
 10246 			
 10004 			
 10247 			return status;
 10005 			return status;
 10255 		{
 10013 		{
 10256 			(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10014 			(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10257 			EAP_TRACE_DEBUG_SYMBIAN(
 10015 			EAP_TRACE_DEBUG_SYMBIAN(
 10258 					(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10016 					(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10259 			m_ready_references_and_data_blocks.reset();
 10017 			m_ready_references_and_data_blocks.reset();
 10260 			
 10018 			eap_status_e status = m_tls_application->complete_read_PAC_store_data(
 10261 			status = m_tls_application->complete_read_PAC_store_data(
       
 10262 				m_eap_fast_completion_status,
 10019 				m_eap_fast_completion_status,
 10263 				m_eap_fast_pac_store_pending_operation,
 10020 				m_eap_fast_pac_store_pending_operation,
 10264 				&m_references_and_data_blocks);
 10021 				&m_references_and_data_blocks);
 10265 			
 10022 			
 10266 			return status;
 10023 			return status;
 10271 		{
 10028 		{
 10272 			(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10029 			(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10273 			EAP_TRACE_DEBUG_SYMBIAN(
 10030 			EAP_TRACE_DEBUG_SYMBIAN(
 10274 					(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10031 					(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10275 			m_ready_references_and_data_blocks.reset();
 10032 			m_ready_references_and_data_blocks.reset();
 10276 			
 10033 			eap_status_e status = m_tls_application->complete_read_PAC_store_data(
 10277 			status = m_tls_application->complete_read_PAC_store_data(
       
 10278 				m_eap_fast_completion_status,
 10034 				m_eap_fast_completion_status,
 10279 				m_eap_fast_pac_store_pending_operation,
 10035 				m_eap_fast_pac_store_pending_operation,
 10280 				&m_references_and_data_blocks);
 10036 				&m_references_and_data_blocks);
 10281 			
 10037 			
 10282 			return status;
 10038 			return status;
 10289 		{
 10045 		{
 10290 			(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10046 			(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10291 			EAP_TRACE_DEBUG_SYMBIAN(
 10047 			EAP_TRACE_DEBUG_SYMBIAN(
 10292 					(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10048 					(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10293 			m_ready_references_and_data_blocks.reset();
 10049 			m_ready_references_and_data_blocks.reset();
 10294 			
 10050 			eap_status_e status = m_tls_application->complete_read_PAC_store_data(
 10295 			status = m_tls_application->complete_read_PAC_store_data(
       
 10296 				m_eap_fast_completion_status,
 10051 				m_eap_fast_completion_status,
 10297 				m_eap_fast_pac_store_pending_operation,
 10052 				m_eap_fast_pac_store_pending_operation,
 10298 				&m_references_and_data_blocks);
 10053 				&m_references_and_data_blocks);
 10299 			
 10054 			
 10300 			return status;
 10055 			return status;
 10318 				m_eap_fast_completion_status = eap_status_allocation_error;
 10073 				m_eap_fast_completion_status = eap_status_allocation_error;
 10319 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10074 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10320 				EAP_TRACE_DEBUG_SYMBIAN(
 10075 				EAP_TRACE_DEBUG_SYMBIAN(
 10321 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10076 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10322 				m_ready_references_and_data_blocks.reset();
 10077 				m_ready_references_and_data_blocks.reset();
 10323 				
 10078 				eap_status_e status = m_tls_application->complete_read_PAC_store_data(
 10324 				status = m_tls_application->complete_read_PAC_store_data(
       
 10325 					m_eap_fast_completion_status,
 10079 					m_eap_fast_completion_status,
 10326 					m_eap_fast_pac_store_pending_operation,
 10080 					m_eap_fast_pac_store_pending_operation,
 10327 					&m_references_and_data_blocks);
 10081 					&m_references_and_data_blocks);
 10328 				
 10082 				
 10329 				return status;
 10083 				return status;
 10337 			{
 10091 			{
 10338 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10092 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10339 				EAP_TRACE_DEBUG_SYMBIAN(
 10093 				EAP_TRACE_DEBUG_SYMBIAN(
 10340 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10094 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10341 				m_ready_references_and_data_blocks.reset();
 10095 				m_ready_references_and_data_blocks.reset();
 10342 				
 10096 				eap_status_e status = m_tls_application->complete_read_PAC_store_data(
 10343 				status = m_tls_application->complete_read_PAC_store_data(
       
 10344 					m_eap_fast_completion_status,
 10097 					m_eap_fast_completion_status,
 10345 					m_eap_fast_pac_store_pending_operation,
 10098 					m_eap_fast_pac_store_pending_operation,
 10346 					&m_references_and_data_blocks);
 10099 					&m_references_and_data_blocks);
 10347 				
 10100 				
 10348 				return status;
 10101 				return status;
 10353 			{
 10106 			{
 10354 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10107 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10355 				EAP_TRACE_DEBUG_SYMBIAN(
 10108 				EAP_TRACE_DEBUG_SYMBIAN(
 10356 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10109 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10357 				m_ready_references_and_data_blocks.reset();
 10110 				m_ready_references_and_data_blocks.reset();
 10358 				
 10111 				eap_status_e status = m_tls_application->complete_read_PAC_store_data(
 10359 				status = m_tls_application->complete_read_PAC_store_data(
       
 10360 					m_eap_fast_completion_status,
 10112 					m_eap_fast_completion_status,
 10361 					m_eap_fast_pac_store_pending_operation,
 10113 					m_eap_fast_pac_store_pending_operation,
 10362 					&m_references_and_data_blocks);
 10114 					&m_references_and_data_blocks);
 10363 				
 10115 				
 10364 				return status;
 10116 				return status;
 10371 			{
 10123 			{
 10372 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10124 				(void) EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
 10373 				EAP_TRACE_DEBUG_SYMBIAN(
 10125 				EAP_TRACE_DEBUG_SYMBIAN(
 10374 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10126 						(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10375 				m_ready_references_and_data_blocks.reset();
 10127 				m_ready_references_and_data_blocks.reset();
 10376 				
 10128 				eap_status_e status = m_tls_application->complete_read_PAC_store_data(
 10377 				status = m_tls_application->complete_read_PAC_store_data(
       
 10378 					m_eap_fast_completion_status,
 10129 					m_eap_fast_completion_status,
 10379 					m_eap_fast_pac_store_pending_operation,
 10130 					m_eap_fast_pac_store_pending_operation,
 10380 					&m_references_and_data_blocks);
 10131 					&m_references_and_data_blocks);
 10381 				
 10132 				
 10382 				return status;
 10133 				return status;
 10407 		m_new_references_and_data_blocks.reset();
 10158 		m_new_references_and_data_blocks.reset();
 10408 
 10159 
 10409 		EAP_TRACE_DEBUG_SYMBIAN(
 10160 		EAP_TRACE_DEBUG_SYMBIAN(
 10410 				(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL Reset Done")));
 10161 				(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL Reset Done")));
 10411 		
 10162 		
 10412 		status = m_tls_application->complete_read_PAC_store_data(
 10163 		eap_status_e status = m_tls_application->complete_read_PAC_store_data(
 10413 			m_eap_fast_completion_status,
 10164 			m_eap_fast_completion_status,
 10414 			m_eap_fast_pac_store_pending_operation,
 10165 			m_eap_fast_pac_store_pending_operation,
 10415 			&m_ready_references_and_data_blocks);
 10166 			&m_ready_references_and_data_blocks);
 10416 		}
 10167 		}
 10417 	else
 10168 	else
 10419 		EAP_TRACE_DEBUG_SYMBIAN(
 10170 		EAP_TRACE_DEBUG_SYMBIAN(
 10420 				(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10171 				(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10421 		m_eap_fast_completion_status = eap_status_user_cancel_authentication;
 10172 		m_eap_fast_completion_status = eap_status_user_cancel_authentication;
 10422 		m_new_references_and_data_blocks.reset();
 10173 		m_new_references_and_data_blocks.reset();
 10423 		m_ready_references_and_data_blocks.reset();
 10174 		m_ready_references_and_data_blocks.reset();
 10424 		
 10175 		eap_status_e status = m_tls_application->complete_read_PAC_store_data(
 10425 		status = m_tls_application->complete_read_PAC_store_data(
       
 10426 			m_eap_fast_completion_status,
 10176 			m_eap_fast_completion_status,
 10427 			m_eap_fast_pac_store_pending_operation,
 10177 			m_eap_fast_pac_store_pending_operation,
 10428 			&m_references_and_data_blocks);
 10178 			&m_references_and_data_blocks);
 10429 		}
 10179 		}
 10430 		}
 10180 		}
 10433 	EAP_TRACE_DEBUG_SYMBIAN(
 10183 	EAP_TRACE_DEBUG_SYMBIAN(
 10434 			(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10184 			(_L("eap_am_type_tls_peap_symbian_c::FinalCompleteReadPACStoreDataL:status nok")));
 10435 	m_eap_fast_completion_status = eap_status_user_cancel_authentication;
 10185 	m_eap_fast_completion_status = eap_status_user_cancel_authentication;
 10436 	m_new_references_and_data_blocks.reset();
 10186 	m_new_references_and_data_blocks.reset();
 10437 	m_ready_references_and_data_blocks.reset();
 10187 	m_ready_references_and_data_blocks.reset();
 10438 	
 10188 	eap_status_e status = m_tls_application->complete_read_PAC_store_data(
 10439 	status = m_tls_application->complete_read_PAC_store_data(
       
 10440 		m_eap_fast_completion_status,
 10189 		m_eap_fast_completion_status,
 10441 		m_eap_fast_pac_store_pending_operation,
 10190 		m_eap_fast_pac_store_pending_operation,
 10442 		&m_references_and_data_blocks);
 10191 		&m_references_and_data_blocks);
 10443 	}
 10192 	}
 10444 	
 10193 	
 10456 }
 10205 }
 10457 
 10206 
 10458 //--------------------------------------------------
 10207 //--------------------------------------------------
 10459 
 10208 
 10460 eap_status_e eap_am_type_tls_peap_symbian_c::CompleteFilePasswordQueryL()
 10209 eap_status_e eap_am_type_tls_peap_symbian_c::CompleteFilePasswordQueryL()
 10461 {
 10210 	{
 10462 	eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools);
 10211 	eap_fast_pac_store_data_c * const new_data = new eap_fast_pac_store_data_c(m_am_tools);
 10463 
 10212 
 10464 	eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
 10213 	eap_automatic_variable_c<eap_fast_pac_store_data_c> automatic_new_data(
 10465 		m_am_tools, new_data);
 10214 		m_am_tools, new_data);
 10466 
 10215 
 10518 		(new_data->get_data())->get_data_length()));
 10267 		(new_data->get_data())->get_data_length()));
 10519 	
 10268 	
 10520 	m_both_completed++;
 10269 	m_both_completed++;
 10521 	return m_eap_fast_completion_status;
 10270 	return m_eap_fast_completion_status;
 10522 
 10271 
 10523 }
 10272 	}
       
 10273 
       
 10274 // ---------------------------------------------------------
       
 10275 // eap_am_type_tls_peap_symbian_c::CompleteNotifier
       
 10276 // ---------------------------------------------------------
       
 10277 //    
       
 10278 eap_status_e eap_am_type_tls_peap_symbian_c::CompleteNotifierL()
       
 10279 	{
       
 10280 	eap_status_e status( eap_status_ok );
       
 10281 	switch ( m_state )
       
 10282 	    {
       
 10283 	    case EPasswordCancel:
       
 10284 	    case EPasswordQuery:
       
 10285 	    case EWrongPassword:
       
 10286 	    case EFilePasswordQuery:
       
 10287 	    case EMasterkeyQuery:
       
 10288 	    	{
       
 10289 	    	EAP_TRACE_DEBUG_SYMBIAN(
       
 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;
       
 10337 	    	}
       
 10338 	    default:
       
 10339 	    	{
       
 10340 	    	EAP_TRACE_DEBUG_SYMBIAN(
       
 10341 	    	    ( _L( "eap_am_type_tls_peap_symbian_c::CompleteNotifierL() m_state = %d not supported." ),
       
 10342 	    	    m_state ) );
       
 10343 	    	}
       
 10344 	    }
       
 10345 	return status;
       
 10346 	}
 10524 
 10347 
 10525 //--------------------------------------------------
 10348 //--------------------------------------------------
 10526 
 10349 
 10527 void eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL(const TDesC16& aFromUnicode, TDes8& aToAscii)
 10350 void eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL(const TDesC16& aFromUnicode, TDes8& aToAscii)
 10528 {
 10351 	{
 10529 	EAP_TRACE_DATA_DEBUG_SYMBIAN(
 10352 		EAP_TRACE_DATA_DEBUG_SYMBIAN(
 10530 		("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL:From TEXT",
 10353 			("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL:From TEXT",
 10531 		aFromUnicode.Ptr(), 
 10354 			aFromUnicode.Ptr(), 
 10532 		aFromUnicode.Size()));	
 10355 			aFromUnicode.Size()));	
 10533 	
 10356 		
 10534 	if(aFromUnicode.Length() <= 0)
 10357 		if(aFromUnicode.Length() <= 0)
 10535 	{
 10358 		{
       
 10359 			EAP_TRACE_DEBUG_SYMBIAN(
       
 10360 			(_L("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL: Return: NOTHING TO CONVERT")));
       
 10361 			
       
 10362 			return;
       
 10363 		}	
       
 10364 		
 10536 		EAP_TRACE_DEBUG_SYMBIAN(
 10365 		EAP_TRACE_DEBUG_SYMBIAN(
 10537 		(_L("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL: Return: NOTHING TO CONVERT")));
 10366 			(_L("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL, aFromUnicode.Length=%d, aFromUnicode.Size=%d"),
 10538 		
 10367 			aFromUnicode.Length(), aFromUnicode.Size()));	
 10539 		return;
 10368 		
 10540 	}	
 10369 		// Convert from Unicode to ascii.
 10541 	
 10370 		HBufC8* aFromUnicodeBuf8 = HBufC8::NewLC(aFromUnicode.Length()); // Half times size of source (or length) is enough here.
 10542 	EAP_TRACE_DEBUG_SYMBIAN(
 10371 		TPtr8 aFromUnicodePtr8 = aFromUnicodeBuf8->Des();
 10543 		(_L("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL, aFromUnicode.Length=%d, aFromUnicode.Size=%d"),
 10372 		
 10544 		aFromUnicode.Length(), aFromUnicode.Size()));	
 10373 		EAP_TRACE_DEBUG_SYMBIAN(
 10545 	
 10374 			(_L("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL, aFromUnicodePtr8.Length=%d, aFromUnicodePtr8.Size=%d, aFromUnicodePtr8.MaxLength=%d, aFromUnicodePtr8.MaxSize=%d"),
 10546 	// Convert from Unicode to ascii.
 10375 			aFromUnicodePtr8.Length(), aFromUnicodePtr8.Size(), aFromUnicodePtr8.MaxLength(), aFromUnicodePtr8.MaxSize()));				
 10547 	HBufC8* aFromUnicodeBuf8 = HBufC8::NewLC(aFromUnicode.Length()); // Half times size of source (or length) is enough here.
 10376 		
 10548 	TPtr8 aFromUnicodePtr8 = aFromUnicodeBuf8->Des();
 10377 		aFromUnicodePtr8.Copy(aFromUnicode); // Unicode -> ascii.
 10549 	
 10378 		
 10550 	EAP_TRACE_DEBUG_SYMBIAN(
 10379 		aToAscii = aFromUnicodePtr8;	
 10551 		(_L("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL, aFromUnicodePtr8.Length=%d, aFromUnicodePtr8.Size=%d, aFromUnicodePtr8.MaxLength=%d, aFromUnicodePtr8.MaxSize=%d"),
 10380 
 10552 		aFromUnicodePtr8.Length(), aFromUnicodePtr8.Size(), aFromUnicodePtr8.MaxLength(), aFromUnicodePtr8.MaxSize()));				
 10381 		CleanupStack::PopAndDestroy(aFromUnicodeBuf8); // Delete aFromUnicodeBuf8.	
 10553 	
 10382 
 10554 	aFromUnicodePtr8.Copy(aFromUnicode); // Unicode -> ascii.
 10383 		EAP_TRACE_DATA_DEBUG_SYMBIAN(
 10555 	
 10384 			("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL:To ASCII",
 10556 	aToAscii = aFromUnicodePtr8;	
 10385 			aToAscii.Ptr(), 
 10557 
 10386 			aToAscii.Size()));	
 10558 	CleanupStack::PopAndDestroy(aFromUnicodeBuf8); // Delete aFromUnicodeBuf8.	
 10387 	}
 10559 
       
 10560 	EAP_TRACE_DATA_DEBUG_SYMBIAN(
       
 10561 		("eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL:To ASCII",
       
 10562 		aToAscii.Ptr(), 
       
 10563 		aToAscii.Size()));	
       
 10564 }
       
 10565 
 10388 
 10566 
 10389 
 10567 // ---------------------------------------------------------
 10390 // ---------------------------------------------------------
 10568 // eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL()
 10391 // eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL()
 10569 // ---------------------------------------------------------
 10392 // ---------------------------------------------------------
 10570 //
 10393 //
 10571 void eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL()
 10394 void eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL()
 10572 {
 10395 	{
 10573 	/* Check validity of password against timelimit */
 10396 	/* Check validity of password against timelimit */
 10574 	
 10397 	
 10575 	EAP_TRACE_DEBUG(m_am_tools, 
 10398 	EAP_TRACE_DEBUG(m_am_tools, 
 10576 			TRACE_FLAGS_DEFAULT, (
 10399 			TRACE_FLAGS_DEFAULT, (
 10577 			EAPL("CheckPasswordTimeValidityL - Start\n")));
 10400 			EAPL("CheckPasswordTimeValidityL - Start\n")));
 10580 	TInt64 fullAuthTime = 0;
 10403 	TInt64 fullAuthTime = 0;
 10581 	
 10404 	
 10582     // get max session time
 10405     // get max session time
 10583 	HBufC* buf = HBufC::NewLC( KMaxSqlQueryLength );
 10406 	HBufC* buf = HBufC::NewLC( KMaxSqlQueryLength );
 10584 	TPtr sqlStatement = buf->Des();	
 10407 	TPtr sqlStatement = buf->Des();	
 10585 
 10408 	_LIT( KSqlQuery, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d" );
 10586 	_LIT( KSqlQuery, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d" );
       
 10587 
       
 10588 	sqlStatement.Format(
 10409 	sqlStatement.Format(
 10589 		KSqlQuery,
 10410 		KSqlQuery,
 10590 		&cf_str_EAP_FAST_max_session_validity_time_literal,
 10411 		&cf_str_EAP_FAST_max_session_validity_time_literal,
 10591 		&KFastGeneralSettingsDBTableName,
 10412 		&KFastGeneralSettingsDBTableName,
 10592 		&KServiceType,
 10413 		&KServiceType, m_index_type, 
 10593 		m_index_type, 
 10414 		&KServiceIndex, m_index,
 10594 		&KServiceIndex,
 10415 		&KTunnelingType, m_tunneling_vendor_type );	
 10595 		m_index,
       
 10596 		&KTunnelingTypeVendorId,
       
 10597 		m_tunneling_type.get_vendor_id(),
       
 10598 		&KTunnelingType, 
       
 10599 		m_tunneling_type.get_vendor_type());
       
 10600 
       
 10601 	TRAPD( err,  maxSessionTime =  ReadIntDbValueL(
 10416 	TRAPD( err,  maxSessionTime =  ReadIntDbValueL(
 10602 		m_database,
 10417 		m_database,
 10603 		cf_str_EAP_FAST_max_session_validity_time_literal,
 10418 		cf_str_EAP_FAST_max_session_validity_time_literal,
 10604 		sqlStatement ) );
 10419 		sqlStatement ) );
 10605 	if ( err != KErrNone )
 10420 	if ( err != KErrNone )
 10769 				error));
 10584 				error));
 10770 		
 10585 		
 10771 			}
 10586 			}
 10772 		}
 10587 		}
 10773 	
 10588 	
 10774 } // eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL()
 10589 	} // eap_am_type_tls_peap_symbian_c::CheckPasswordTimeValidityL()
 10775 
 10590 
 10776 
 10591 
 10777 // ---------------------------------------------------------
 10592 // ---------------------------------------------------------
 10778 // eap_am_type_tls_peap_symbian_c::AlterTableL()
 10593 // eap_am_type_tls_peap_symbian_c::AlterTableL()
 10779 // ---------------------------------------------------------
 10594 // ---------------------------------------------------------
 10782 	RDbNamedDatabase& aDb,
 10597 	RDbNamedDatabase& aDb,
 10783 	TAlterTableCmd aCmd,
 10598 	TAlterTableCmd aCmd,
 10784 	const TDesC& aTableName,
 10599 	const TDesC& aTableName,
 10785 	const TDesC& aColumnName,
 10600 	const TDesC& aColumnName,
 10786 	const TDesC& aColumnDef )
 10601 	const TDesC& aColumnDef )
 10787 {
 10602 	{
 10788 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
 10603 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
 10789 		"eap_am_type_tls_peap_symbian_c::AlterTableL() IN\n" ) ) );
 10604 		"eap_am_type_tls_peap_symbian_c::AlterTableL() IN\n" ) ) );
 10790 	
 10605 	
 10791 	CDbColSet* colSet = aDb.ColSetL( aTableName );
 10606 	CDbColSet* colSet = aDb.ColSetL( aTableName );
 10792 	User::LeaveIfNull( colSet );
 10607 	User::LeaveIfNull( colSet );
 10858 	delete alteredColSet;
 10673 	delete alteredColSet;
 10859 		
 10674 		
 10860 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
 10675 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
 10861 	    "eap_am_type_tls_peap_symbian_c::AlterTableL() OUT\n" ) ) );
 10676 	    "eap_am_type_tls_peap_symbian_c::AlterTableL() OUT\n" ) ) );
 10862 
 10677 
 10863 } // eap_am_type_tls_peap_symbian_c::AlterTableL()
 10678 	} // eap_am_type_tls_peap_symbian_c::AlterTableL()
 10864 
 10679 
 10865 
 10680 
 10866 // ---------------------------------------------------------
 10681 // ---------------------------------------------------------
 10867 // eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL()
 10682 // eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL()
 10868 // ---------------------------------------------------------
 10683 // ---------------------------------------------------------
 10869 //
 10684 //
 10870 void eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL()
 10685 void eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL()
 10871 {
 10686 	{
 10872 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
 10687 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
 10873 	    "eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL() IN" ) ) );	
 10688 	    "eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL() IN" ) ) );	
 10874 	
 10689 	
 10875 	// remove password identity time from fast table	
 10690 	// remove password identity time from fast table	
 10876 	_LIT( KColumnDef, "BIGINT" );
 10691 	_LIT( KColumnDef, "BIGINT" );
 10899 	// update password identity time
 10714 	// update password identity time
 10900 	UpdatePasswordTimeL();
 10715 	UpdatePasswordTimeL();
 10901 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
 10716 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
 10902 	    "eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL() OUT" ) ) );
 10717 	    "eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL() OUT" ) ) );
 10903 	
 10718 	
 10904 } // eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL()
 10719 	} // eap_am_type_tls_peap_symbian_c::FixOldTablesForPwdIdentityTimeL()
 10905 
 10720 
 10906 
 10721 
 10907 // ---------------------------------------------------------
 10722 // ---------------------------------------------------------
 10908 // eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL()
 10723 // eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL()
 10909 // ---------------------------------------------------------
 10724 // ---------------------------------------------------------
 10910 //
 10725 //
 10911 void eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL()
 10726 void eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL()
 10912 {
 10727 	{
 10913 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
 10728 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
 10914 		"eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL() IN\n" ) ) );
 10729 		"eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL() IN\n" ) ) );
 10915 	
 10730 	
 10916 #ifdef USE_PAC_STORE
 10731 #ifdef USE_PAC_STORE
 10917 	
 10732 	
 10935 #endif
 10750 #endif
 10936 		
 10751 		
 10937 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
 10752 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, ( EAPL(
 10938 	    "eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL() OUT\n" ) ) );
 10753 	    "eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL() OUT\n" ) ) );
 10939 
 10754 
 10940 } // eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL()
 10755 	} // eap_am_type_tls_peap_symbian_c::FixOldTableForPacStoreInitL()
 10941 
 10756 
 10942 
 10757 
 10943 // ---------------------------------------------------------
 10758 // ---------------------------------------------------------
 10944 // eap_am_type_tls_peap_symbian_c::ReadIntDbValue()
 10759 // eap_am_type_tls_peap_symbian_c::ReadIntDbValue()
 10945 // ---------------------------------------------------------
 10760 // ---------------------------------------------------------
 10946 //
 10761 //
 10947 TInt64 eap_am_type_tls_peap_symbian_c::ReadIntDbValueL(
 10762 TInt64 eap_am_type_tls_peap_symbian_c::ReadIntDbValueL(
 10948 	RDbNamedDatabase& aDb,
 10763 	RDbNamedDatabase& aDb,
 10949 	const TDesC& aColumnName,
 10764 	const TDesC& aColumnName,
 10950 	const TDesC& aSqlStatement )
 10765 	const TDesC& aSqlStatement )
 10951 {
 10766     {
 10952 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (
 10767 	EAP_TRACE_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (
 10953 			EAPL( "eap_am_type_tls_peap_symbian_c::ReadIntDbValueL()\n" ) ) );
 10768 			EAPL( "eap_am_type_tls_peap_symbian_c::ReadIntDbValueL()\n" ) ) );
 10954     TPtrC columnName;    
 10769     TPtrC columnName;    
 10955 	columnName.Set( aColumnName );
 10770 	columnName.Set( aColumnName );
 10956 	
 10771 	
 10975 
 10790 
 10976 	CleanupStack::PopAndDestroy( colSet ); // Delete colSet.
 10791 	CleanupStack::PopAndDestroy( colSet ); // Delete colSet.
 10977 	CleanupStack::PopAndDestroy( &view ); // Close view.
 10792 	CleanupStack::PopAndDestroy( &view ); // Close view.
 10978 
 10793 
 10979 	return retVal;
 10794 	return retVal;
 10980 } // eap_am_type_tls_peap_symbian_c::ReadIntDbValueL
 10795     } // eap_am_type_tls_peap_symbian_c::ReadIntDbValueL
 10981 
 10796 
 10982 
 10797 
 10983 // ---------------------------------------------------------
 10798 // ---------------------------------------------------------
 10984 // eap_am_type_tls_peap_symbian_c::UpdatePasswordTimeL()
 10799 // eap_am_type_tls_peap_symbian_c::UpdatePasswordTimeL()
 10985 // ---------------------------------------------------------
 10800 // ---------------------------------------------------------
 10986 //
 10801 //
 10987 void eap_am_type_tls_peap_symbian_c::UpdatePasswordTimeL()
 10802 void eap_am_type_tls_peap_symbian_c::UpdatePasswordTimeL()
 10988 {
 10803 	{
 10989 	/* update last password time */
 10804 	/* update last password time */
 10990 	TPtrC lastFullPasswordTimeString;
 10805 	TPtrC lastFullPasswordTimeString;
 10991 	
 10806 	
 10992 	EAP_TRACE_DEBUG(m_am_tools, 
 10807 	EAP_TRACE_DEBUG(m_am_tools, 
 10993 			TRACE_FLAGS_DEFAULT, (
 10808 			TRACE_FLAGS_DEFAULT, (
 11034 	EAP_TRACE_DEBUG(m_am_tools, 
 10849 	EAP_TRACE_DEBUG(m_am_tools, 
 11035 			TRACE_FLAGS_DEFAULT, (
 10850 			TRACE_FLAGS_DEFAULT, (
 11036 			EAPL("UpdatePasswordTimeL - evaluate view\n")));
 10851 			EAPL("UpdatePasswordTimeL - evaluate view\n")));
 11037 	User::LeaveIfError(view.EvaluateAll());
 10852 	User::LeaveIfError(view.EvaluateAll());
 11038 	
 10853 	
 11039 	// Get the first (and only) row.
 10854 	// Get the first (and only) row for updation.
 11040 	view.FirstL();
 10855 	view.FirstL();
 11041 	view.UpdateL();
 10856 	view.UpdateL();
 11042 	
 10857 	
 11043 	// Get column set so we get the correct column numbers
 10858 	// Get column set so we get the correct column numbers
 11044 	CDbColSet* colSet = view.ColSetL();
 10859 	CDbColSet* colSet = view.ColSetL();
 11069 	CleanupStack::PopAndDestroy(&view); // Close view.
 10884 	CleanupStack::PopAndDestroy(&view); // Close view.
 11070 	CleanupStack::PopAndDestroy(buf); // Delete buf.
 10885 	CleanupStack::PopAndDestroy(buf); // Delete buf.
 11071 	
 10886 	
 11072 	/* update end */	
 10887 	/* update end */	
 11073 	
 10888 	
 11074 } // eap_am_type_tls_peap_symbian_c::UpdatePasswordTimeL()
 10889 	} // eap_am_type_tls_peap_symbian_c::UpdatePasswordTimeL()
 11075 
 10890 
 11076 //--------------------------------------------------
       
 11077 
 10891 
 11078 eap_status_e eap_am_type_tls_peap_symbian_c::CreateMasterkeyL()
 10892 eap_status_e eap_am_type_tls_peap_symbian_c::CreateMasterkeyL()
 11079 {
 10893 	{
 11080 	HBufC8* password = HBufC8::NewLC(m_userResponse.get_data_length());
 10894 	HBufC8* password = HBufC8::NewLC(m_userResponse.get_data_length());
 11081 	TPtr8 passwordPtr = password->Des();
 10895 	TPtr8 passwordPtr = password->Des();
 11082 	m_PAC_store_password.set_copy_of_buffer(&m_userResponse);
 10896 	m_PAC_store_password.set_copy_of_buffer(&m_userResponse);
 11083 	passwordPtr.Copy(m_userResponse.get_data(), m_userResponse.get_data_length());
 10897 	passwordPtr.Copy(m_userResponse.get_data(), m_userResponse.get_data_length());
 11084 	m_eap_fast_completion_status = m_am_tools->convert_am_error_to_eapol_error(iPacStoreDb->CreateAndSaveMasterKeyL(passwordPtr));
 10898 	m_eap_fast_completion_status = m_am_tools->convert_am_error_to_eapol_error(iPacStoreDb->CreateAndSaveMasterKeyL(passwordPtr));
 11085 	CleanupStack::PopAndDestroy(password);
 10899 	CleanupStack::PopAndDestroy(password);
 11086 	return m_eap_fast_completion_status;
 10900 	return m_eap_fast_completion_status;
 11087 }
 10901 	}
 11088 
       
 11089 #endif //#if defined(USE_FAST_EAP_TYPE)
 10902 #endif //#if defined(USE_FAST_EAP_TYPE)
 11090 
 10903 
 11091 
 10904 
 11092 
 10905 
 11093 // ================= TTLS-PAP public exported =======================
 10906 // ================= TTLS-PAP public exported =======================
 11094 
 10907 
 11095 // ------------------------------------------------------------------------
 10908 // ------------------------------------------------------------------------
 11096 // eap_am_type_tls_peap_symbian_c::is_ttls_pap_session_valid()
 10909 // eap_am_type_tls_peap_symbian_c::is_ttls_pap_session_valid()
 11097 // ------------------------------------------------------------------------
 10910 // ------------------------------------------------------------------------
 11098 //
 10911 //
 11099 EAP_FUNC_EXPORT bool eap_am_type_tls_peap_symbian_c::is_ttls_pap_session_valid()
 10912 EAP_FUNC_EXPORT
 11100 {
 10913 bool eap_am_type_tls_peap_symbian_c::is_ttls_pap_session_valid()
 11101     EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::is_ttls_pap_session_valid()" )));    
 10914 	{
       
 10915     DEBUG( "eap_am_type_tls_peap_symbian_c::is_ttls_pap_session_valid()" );    
 11102 
 10916 
 11103     TBool isValid = EFalse;
 10917     TBool isValid = EFalse;
 11104     TInt err = KErrNone;
 10918     TInt err = KErrNone;
 11105     bool retVal = false;
 10919     bool retVal = false;
 11106 	
 10920 	
 11107     TRAP( err, isValid = IsTtlsPapSessionValidL() );
 10921     TRAP( err, isValid = IsTtlsPapSessionValidL() );
 11108     if ( err != KErrNone )
 10922     if ( err != KErrNone )
 11109 	    {
 10923 	    {
 11110 	    EAP_TRACE_DEBUG_SYMBIAN((_L("ERROR: eap_am_type_tls_peap_symbian_c::is_ttls_pap_session_valid(): Leave, err==%d."), err ));
 10924 	    DEBUG1( "eap_am_type_tls_peap_symbian_c::is_ttls_pap_session_valid() ERROR: \
       
 10925 	        Leave, err==%d.", err );
 11111 	    retVal = false;
 10926 	    retVal = false;
 11112 	    }
 10927 	    }
 11113     else
 10928     else
 11114     	{
 10929     	{
 11115     	retVal = ( isValid ) ? true : false;
 10930     	retVal = ( isValid ) ? true : false;
 11116     	}
 10931     	}
 11117     return retVal;
 10932     return retVal;
 11118 }
 10933 	}
 11119 
 10934 
 11120 // ------------------------------------------------------------------------
 10935 // ------------------------------------------------------------------------
 11121 // eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password()
 10936 // eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password()
 11122 // ------------------------------------------------------------------------
 10937 // ------------------------------------------------------------------------
 11123 //    
 10938 //    
 11124 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password(
 10939 EAP_FUNC_EXPORT eap_status_e
       
 10940 eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password(
 11125 	const eap_variable_data_c * const aInSrvChallengeUtf8 )
 10941 	const eap_variable_data_c * const aInSrvChallengeUtf8 )
 11126 {
 10942     {
 11127 	EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password()" )));    
 10943     DEBUG( "eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password()" );    
 11128 
 10944 	
 11129 	eap_status_e status( eap_status_pending_request );
 10945     eap_status_e status( eap_status_pending_request );
 11130 	TEapExpandedType aEapType(*EapExpandedTypeTtlsPap.GetType());
 10946 
 11131 
 10947     if ( !iEapTtlsPapActive )
 11132 	m_notifier_data_to_user->iUsername.Zero();
 10948     	{
 11133 	m_notifier_data_to_user->iPassword.Zero();
 10949     	TRAPD( err, iEapTtlsPapActive = CEapTtlsPapActive::NewL(
 11134 	m_notifier_data_to_user->iUidata.Zero();
 10950     		this, m_am_tools ) );
 11135 
 10951     	if ( err != KErrNone )
 11136 	if ((aInSrvChallengeUtf8 != NULL) && (aInSrvChallengeUtf8->get_data_length() != 0))
 10952     		{
 11137 	{
 10953             DEBUG1( "eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password() \
 11138 		const TPtrC8 utf8(
 10954             	ERROR: CEapTtlsPapActive::NewL(), err=%d.", err );    
 11139 			aInSrvChallengeUtf8->get_data(),
 10955     	    return ConvertAmErrorToEapolError( err );
 11140 			aInSrvChallengeUtf8->get_data_length()*2); // Length in bytes
 10956     		}
 11141 
 10957     	}
 11142 		CnvUtfConverter::ConvertToUnicodeFromUtf8(m_notifier_data_to_user->iUidata, utf8);
 10958     if ( aInSrvChallengeUtf8 != NULL )
 11143 
 10959     	{
 11144 		EAP_TRACE_DATA_DEBUG(
 10960         iEapTtlsPapActive->UpdateSrvChallenge( *aInSrvChallengeUtf8 );
 11145 			m_am_tools,
 10961     	}
 11146 			TRACE_FLAGS_DEFAULT,
 10962     TBool startedOk = iEapTtlsPapActive->Start(
 11147 			(EAPL("eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password(): iUidata"),
 10963     	CEapTtlsPapActive::EEapTtlsPapActiveQueryUserNameAndPassword );
 11148 			m_notifier_data_to_user->iUidata.Ptr(),
 10964 	if ( !startedOk )
 11149 			m_notifier_data_to_user->iUidata.Size()));
 10965         {
 11150 
 10966         status = eap_status_process_general_error;
 11151 		m_state = EPapChallenge;
 10967         }
 11152 		TEapExpandedType aEapType(*EapExpandedTypeTtlsPap.GetType());
 10968 	if ( status != eap_status_pending_request )
 11153 
 10969 		{
 11154 		if (iEapAuthNotifier == 0)
 10970         DEBUG( "eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password() \
 11155 		{
 10971         	ERROR: status != eap_status_pending_request" );    
 11156 			TRAPD(err, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
 10972 		}
 11157 			if (err)
       
 11158 			{
       
 11159 				return eap_status_process_general_error;
       
 11160 			}
       
 11161 		}
       
 11162 
       
 11163 		TRAPD(err1, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypePapChallengeDialog, m_notifier_data_to_user, aEapType));
       
 11164 		if (err1)
       
 11165 		{
       
 11166 			return eap_status_process_general_error;
       
 11167 		}
       
 11168 	}
       
 11169 	else
       
 11170 	{
       
 11171 		m_state = EPapUserNameAndPassword;
       
 11172 
       
 11173 		TTtlsPapDbInfo aInDbInfo;
       
 11174 		TRAPD(err2, ReadTtlsPapDbL(aInDbInfo));
       
 11175 		if (err2)
       
 11176 		{
       
 11177 			return eap_status_process_general_error;
       
 11178 		}
       
 11179 
       
 11180 		m_notifier_data_to_user->iPasswordPromptEnabled = aInDbInfo.iUsrPwdInfo.iPasswordPromptEnabled;
       
 11181 
       
 11182 		if (m_notifier_data_to_user->iPasswordPromptEnabled
       
 11183 			|| aInDbInfo.iUsrPwdInfo.iUserName.Size() == 0
       
 11184 			|| aInDbInfo.iUsrPwdInfo.iPassword.Size() == 0)
       
 11185 		{
       
 11186 			if (aInDbInfo.iUsrPwdInfo.iUserName.Size() == 0)
       
 11187 			{
       
 11188 				m_notifier_data_to_user->iUsername.Zero();
       
 11189 			}
       
 11190 			else
       
 11191 			{
       
 11192 				m_notifier_data_to_user->iUsername = aInDbInfo.iUsrPwdInfo.iUserName;
       
 11193 			}
       
 11194 
       
 11195 			m_notifier_data_to_user->iPassword.Zero();
       
 11196 
       
 11197 			TRAPD(err3,SetTtlsPapColumnToNullL( cf_str_EAP_TLS_PEAP_ttls_pap_password_literal ));
       
 11198 			if (err3)
       
 11199 			{
       
 11200 				return eap_status_process_general_error;
       
 11201 			}
       
 11202 
       
 11203 			if (iEapAuthNotifier == 0)
       
 11204 			{
       
 11205 				TRAPD(err4, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
       
 11206 				if (err4)
       
 11207 				{
       
 11208 					return eap_status_process_general_error;
       
 11209 				}
       
 11210 			}
       
 11211 			else
       
 11212 			{
       
 11213 				TRAPD(err5,iEapAuthNotifier->Cancel());
       
 11214 				if (err5)
       
 11215 				{
       
 11216 					return eap_status_process_general_error;
       
 11217 				}
       
 11218 			}
       
 11219 
       
 11220 			TRAPD(err6, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypePapUsernamePasswordDialog, m_notifier_data_to_user, aEapType));
       
 11221 			if (err6)
       
 11222 			{
       
 11223 				return eap_status_process_general_error;
       
 11224 			}
       
 11225 		}
       
 11226 		else
       
 11227 		{
       
 11228 			m_notifier_data_to_user->iUsername = aInDbInfo.iUsrPwdInfo.iUserName;
       
 11229 
       
 11230 			EAP_TRACE_DATA_DEBUG(
       
 11231 				m_am_tools,
       
 11232 				TRACE_FLAGS_DEFAULT,
       
 11233 				(EAPL("eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password(): iUserName"),
       
 11234 				m_notifier_data_to_user->iUsername.Ptr(),
       
 11235 				m_notifier_data_to_user->iUsername.Size()));
       
 11236 
       
 11237 			m_notifier_data_to_user->iPassword = aInDbInfo.iUsrPwdInfo.iPassword;
       
 11238 
       
 11239 			EAP_TRACE_DATA_DEBUG(
       
 11240 				m_am_tools,
       
 11241 				TRACE_FLAGS_DEFAULT,
       
 11242 				(EAPL("eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password(): iPassword"),
       
 11243 				m_notifier_data_to_user->iPassword.Ptr(),
       
 11244 				m_notifier_data_to_user->iPassword.Size()));
       
 11245 
       
 11246 			DlgComplete(KErrNone);
       
 11247 		}
       
 11248 	}
       
 11249 
       
 11250 	return status;
 10973 	return status;
 11251 }
 10974     }
 11252 
 10975 
 11253 // ================= TTLS-PAP public not exported =======================
 10976 // ================= TTLS-PAP public not exported =======================
 11254 
 10977 
 11255 // ------------------------------------------------------------------------
 10978 // ------------------------------------------------------------------------
 11256 // eap_am_type_tls_peap_symbian_c::verify_ttls_pap_username_and_password()
 10979 // eap_am_type_tls_peap_symbian_c::verify_ttls_pap_username_and_password()
 11257 // ------------------------------------------------------------------------
 10980 // ------------------------------------------------------------------------
 11258 //    
 10981 //    
 11259 eap_status_e eap_am_type_tls_peap_symbian_c::verify_ttls_pap_username_and_password(
 10982 eap_status_e
       
 10983 eap_am_type_tls_peap_symbian_c::verify_ttls_pap_username_and_password(
 11260 	const eap_variable_data_c * const /*aUserName*/,
 10984 	const eap_variable_data_c * const /*aUserName*/,
 11261 	const eap_variable_data_c * const /*aUserPassword*/ )
 10985 	const eap_variable_data_c * const /*aUserPassword*/ )
 11262 {
 10986 	{
 11263 	EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::verify_ttls_pap_username_and_password()" )));
 10987 	DEBUG( "eap_am_type_tls_peap_symbian_c::verify_ttls_pap_username_and_password()" );
 11264 	return eap_status_not_supported;
 10988 	return eap_status_not_supported;
 11265 }
 10989 	}
 11266 
 10990 
 11267 // ================= TTLS-PAP public new =======================
 10991 // ================= TTLS-PAP public new =======================
 11268 
 10992 
 11269 // ------------------------------------------------------------------------
 10993 // ------------------------------------------------------------------------
 11270 // eap_am_type_tls_peap_symbian_c::CompleteQueryTtlsPapUserNameAndPassword()
 10994 // eap_am_type_tls_peap_symbian_c::CompleteQueryTtlsPapUserNameAndPassword()
 11271 // ------------------------------------------------------------------------
 10995 // ------------------------------------------------------------------------
 11272 //    
 10996 //    
 11273 eap_status_e eap_am_type_tls_peap_symbian_c::CompleteQueryTtlsPapUserNameAndPassword(
 10997 eap_status_e
       
 10998 eap_am_type_tls_peap_symbian_c::CompleteQueryTtlsPapUserNameAndPassword(
 11274 	eap_status_e aStatus,
 10999 	eap_status_e aStatus,
 11275 	const TDesC8& aUserNameUtf8,
 11000 	const TDesC8& aUserNameUtf8,
 11276 	const TDesC8& aPasswordUtf8 )
 11001 	const TDesC8& aPasswordUtf8 )
 11277 {
 11002 	{
 11278 	EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::CompleteQueryTtlsPapUserNameAndPassword()" )));
 11003 	DEBUG( "eap_am_type_tls_peap_symbian_c::CompleteQueryTtlsPapUserNameAndPassword()" );
 11279 	
 11004 	
 11280 	eap_status_e retStatus = aStatus;
 11005 	eap_status_e retStatus = aStatus;
 11281 	eap_status_e tmpStatus = eap_status_ok;
 11006 	eap_status_e tmpStatus = eap_status_ok;
 11282 	
 11007 	
 11283 	eap_variable_data_c userNameUtf8( m_am_tools );
 11008 	eap_variable_data_c userNameUtf8( m_am_tools );
 11295 		{
 11020 		{
 11296 		retStatus = tmpStatus;
 11021 		retStatus = tmpStatus;
 11297 		}
 11022 		}
 11298 	if ( m_tls_am_partner == NULL )
 11023 	if ( m_tls_am_partner == NULL )
 11299 		{
 11024 		{
 11300 		EAP_TRACE_DEBUG_SYMBIAN((_L( "ERROR: eap_am_type_tls_peap_symbian_c::CompleteQueryTtlsPapUserNameAndPassword(): m_tls_am_partner is NULL." )));
 11025 		DEBUG( "eap_am_type_tls_peap_symbian_c::CompleteQueryTtlsPapUserNameAndPassword() \
       
 11026 			ERROR: m_tls_am_partner is NULL." );
 11301         return eap_status_process_general_error;
 11027         return eap_status_process_general_error;
 11302 		}
 11028 		}
 11303 	retStatus = m_tls_am_partner->
 11029 	retStatus = m_tls_am_partner->
 11304 	    complete_query_ttls_pap_username_and_password(
 11030 	    complete_query_ttls_pap_username_and_password(
 11305 		    &userNameUtf8, &passwordUtf8, retStatus );	
 11031 		    &userNameUtf8, &passwordUtf8, retStatus );	
 11306 	return retStatus;
 11032 	return retStatus;
 11307 } // eap_am_type_tls_peap_symbian_c::CompleteQueryTtlsPapUserNameAndPassword(
 11033 	} // eap_am_type_tls_peap_symbian_c::CompleteQueryTtlsPapUserNameAndPassword(
 11308 
 11034 
 11309 
 11035 
 11310 // ------------------------------------------------------------------------
 11036 // ------------------------------------------------------------------------
 11311 // eap_am_type_tls_peap_symbian_c::ConvertAmErrorToEapolError()
 11037 // eap_am_type_tls_peap_symbian_c::ConvertAmErrorToEapolError()
 11312 // ------------------------------------------------------------------------
 11038 // ------------------------------------------------------------------------
 11313 //    
 11039 //    
 11314 eap_status_e
 11040 eap_status_e
 11315 eap_am_type_tls_peap_symbian_c::ConvertAmErrorToEapolError( TInt aErr )
 11041 eap_am_type_tls_peap_symbian_c::ConvertAmErrorToEapolError( TInt aErr )
 11316 {
 11042 	{
 11317 	EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::ConvertAmErrorToEapolError()" )));
 11043 	DEBUG( "eap_am_type_tls_peap_symbian_c::ConvertAmErrorToEapolError()" );
 11318     if ( m_am_tools )
 11044     if ( m_am_tools )
 11319     	{
 11045     	{
 11320     	return m_am_tools->convert_am_error_to_eapol_error( aErr );
 11046     	return m_am_tools->convert_am_error_to_eapol_error( aErr );
 11321     	}
 11047     	}
 11322 	return eap_status_process_general_error;
 11048 	return eap_status_process_general_error;
 11323 }
 11049 	}
 11324 
 11050 
 11325 
 11051 
 11326 // ------------------------------------------------------------------------
 11052 // ------------------------------------------------------------------------
 11327 // eap_am_type_tls_peap_symbian_c::ReadTtlsPapDbL()
 11053 // eap_am_type_tls_peap_symbian_c::ReadTtlsPapDbL()
 11328 // ------------------------------------------------------------------------
 11054 // ------------------------------------------------------------------------
 11332 //| EAP_TLS_PEAP_ttls_pap_password                      | VARCHAR(128)      | cf_str_EAP_TLS_PEAP_ttls_pap_password_literal                  |//
 11058 //| EAP_TLS_PEAP_ttls_pap_password                      | VARCHAR(128)      | cf_str_EAP_TLS_PEAP_ttls_pap_password_literal                  |//
 11333 //| EAP_TLS_PEAP_ttls_pap_max_session_validity_time		| BIGINT		   	| cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time_literal |//
 11059 //| EAP_TLS_PEAP_ttls_pap_max_session_validity_time		| BIGINT		   	| cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time_literal |//
 11334 //| EAP_TLS_PEAP_ttls_pap_last_full_authentication_time	| BIGINT		   	| KTTLSPAPLastFullAuthTime	                             |//
 11060 //| EAP_TLS_PEAP_ttls_pap_last_full_authentication_time	| BIGINT		   	| KTTLSPAPLastFullAuthTime	                             |//
 11335 void eap_am_type_tls_peap_symbian_c::ReadTtlsPapDbL(
 11061 void eap_am_type_tls_peap_symbian_c::ReadTtlsPapDbL(
 11336 	TTtlsPapDbInfo& aOutDbInfo )
 11062 	TTtlsPapDbInfo& aOutDbInfo )
 11337 {
 11063 	{
 11338 	EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::ReadTtlsPapDbL()" )));
 11064 	DEBUG( "eap_am_type_tls_peap_symbian_c::ReadTtlsPapDbL()" );
 11339 	
 11065 	
 11340 	HBufC* buf = HBufC::NewLC( KMaxSqlQueryLength );
 11066 	HBufC* buf = HBufC::NewLC( KMaxSqlQueryLength );
 11341 	TPtr sqlStatement = buf->Des();
 11067 	TPtr sqlStatement = buf->Des();
 11342 	
 11068 	
 11343 	// Query all the relevant parameters
 11069 	// Query all the relevant parameters
 11370 			CleanupStack::PushL( colSet );
 11096 			CleanupStack::PushL( colSet );
 11371 			
 11097 			
 11372 			// columns reading	
 11098 			// columns reading	
 11373 			aOutDbInfo.iUsrPwdInfo.iPasswordPromptEnabled = view.ColUint(
 11099 			aOutDbInfo.iUsrPwdInfo.iPasswordPromptEnabled = view.ColUint(
 11374 				colSet->ColNo( cf_str_EAP_TLS_PEAP_ttls_pap_password_prompt_literal ) );
 11100 				colSet->ColNo( cf_str_EAP_TLS_PEAP_ttls_pap_password_prompt_literal ) );
 11375 
 11101 			
 11376 			{
 11102 			aOutDbInfo.iUsrPwdInfo.iUserName = view.ColDes(
 11377 				TPtrC username = view.ColDes(
 11103 				colSet->ColNo( cf_str_EAP_TLS_PEAP_ttls_pap_username_literal ) );
 11378 					colSet->ColNo( cf_str_EAP_TLS_PEAP_ttls_pap_username_literal ) );
 11104 			
 11379 
 11105 			aOutDbInfo.iUsrPwdInfo.iPassword = view.ColDes(
 11380 				aOutDbInfo.iUsrPwdInfo.iUserName.Copy(username); 
 11106 				colSet->ColNo( cf_str_EAP_TLS_PEAP_ttls_pap_password_literal ) );
 11381 
       
 11382 				EAP_TRACE_DATA_DEBUG(
       
 11383 					m_am_tools,
       
 11384 					TRACE_FLAGS_DEFAULT,
       
 11385 					(EAPL("eap_am_type_tls_peap_symbian_c::ReadTtlsPapDbL(): iUserName"),
       
 11386 					aOutDbInfo.iUsrPwdInfo.iUserName.Ptr(),
       
 11387 					aOutDbInfo.iUsrPwdInfo.iUserName.Size()));
       
 11388 			}
       
 11389 			
       
 11390 			{
       
 11391 				TPtrC password = view.ColDes(
       
 11392 					colSet->ColNo( cf_str_EAP_TLS_PEAP_ttls_pap_password_literal ) );
       
 11393 
       
 11394 				 aOutDbInfo.iUsrPwdInfo.iPassword.Copy(password);
       
 11395 
       
 11396 
       
 11397 				EAP_TRACE_DATA_DEBUG(
       
 11398 					m_am_tools,
       
 11399 					TRACE_FLAGS_DEFAULT,
       
 11400 					(EAPL("eap_am_type_tls_peap_symbian_c::ReadTtlsPapDbL(): iPassword"),
       
 11401 					aOutDbInfo.iUsrPwdInfo.iPassword.Ptr(),
       
 11402 					aOutDbInfo.iUsrPwdInfo.iPassword.Size()));
       
 11403 			}
       
 11404 			
 11107 			
 11405 			aOutDbInfo.iMaxSessionTime = view.ColInt64(
 11108 			aOutDbInfo.iMaxSessionTime = view.ColInt64(
 11406 				colSet->ColNo( cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time_literal ) );
 11109 				colSet->ColNo( cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time_literal ) );
 11407 			
 11110 			
 11408 			aOutDbInfo.iLastFullAuthTime = view.ColInt64(
 11111 			aOutDbInfo.iLastFullAuthTime = view.ColInt64(
 11411 			CleanupStack::PopAndDestroy( colSet ); // Delete colSet.
 11114 			CleanupStack::PopAndDestroy( colSet ); // Delete colSet.
 11412 	}
 11115 	}
 11413 	CleanupStack::PopAndDestroy( &view ); // Close view.
 11116 	CleanupStack::PopAndDestroy( &view ); // Close view.
 11414 	CleanupStack::PopAndDestroy( buf ); // Delete buf.
 11117 	CleanupStack::PopAndDestroy( buf ); // Delete buf.
 11415 	
 11118 	
 11416 } // eap_am_type_tls_peap_symbian_c::ReadTtlsPapDbL()
 11119 	} // eap_am_type_tls_peap_symbian_c::ReadTtlsPapDbL()
 11417 
 11120 
 11418 
 11121 
 11419 // ------------------------------------------------------------------------
 11122 // ------------------------------------------------------------------------
 11420 // eap_am_type_tls_peap_symbian_c::WriteTtlsPapDbL()
 11123 // eap_am_type_tls_peap_symbian_c::WriteTtlsPapDbL()
 11421 // ------------------------------------------------------------------------
 11124 // ------------------------------------------------------------------------
 11425 //| EAP_TLS_PEAP_ttls_pap_password                      | VARCHAR(128)      | cf_str_EAP_TLS_PEAP_ttls_pap_password_literal                  |//
 11128 //| EAP_TLS_PEAP_ttls_pap_password                      | VARCHAR(128)      | cf_str_EAP_TLS_PEAP_ttls_pap_password_literal                  |//
 11426 //| EAP_TLS_PEAP_ttls_pap_max_session_validity_time		| BIGINT		   	| cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time_literal |//
 11129 //| EAP_TLS_PEAP_ttls_pap_max_session_validity_time		| BIGINT		   	| cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time_literal |//
 11427 //| EAP_TLS_PEAP_ttls_pap_last_full_authentication_time	| BIGINT		   	| KTTLSPAPLastFullAuthTime	                             |//
 11130 //| EAP_TLS_PEAP_ttls_pap_last_full_authentication_time	| BIGINT		   	| KTTLSPAPLastFullAuthTime	                             |//
 11428 void eap_am_type_tls_peap_symbian_c::WriteTtlsPapDbL(
 11131 void eap_am_type_tls_peap_symbian_c::WriteTtlsPapDbL(
 11429 	const TTtlsPapDbInfo& aInDbInfo )
 11132 	const TTtlsPapDbInfo& aInDbInfo )
 11430 {
 11133 	{
 11431 	EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::WriteTtlsPapDbL()" )));
 11134 	DEBUG( "eap_am_type_tls_peap_symbian_c::WriteTtlsPapDbL()" );
 11432 	
 11135 	
 11433 	
 11136 	
 11434 	HBufC* buf = HBufC::NewLC( KMaxSqlQueryLength );
 11137 	HBufC* buf = HBufC::NewLC( KMaxSqlQueryLength );
 11435 	TPtr sqlStatement = buf->Des();
 11138 	TPtr sqlStatement = buf->Des();
 11436 	
 11139 	
 11437 	// Query all the relevant parameters
 11140 	// Query all the relevant parameters
 11438 	_LIT( KSQLQuery,
 11141 	_LIT( KSQLQuery,
 11439 		"SELECT %S, %S, %S, %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d" );
 11142 		"SELECT %S, %S, %S, %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d" );
 11440 
 11143 	sqlStatement.Format( KSQLQuery,
 11441 	sqlStatement.Format(
       
 11442 		KSQLQuery,
       
 11443 		&cf_str_EAP_TLS_PEAP_ttls_pap_password_prompt_literal,           // select´
 11144 		&cf_str_EAP_TLS_PEAP_ttls_pap_password_prompt_literal,           // select´
 11444 		&cf_str_EAP_TLS_PEAP_ttls_pap_username_literal,                  // select
 11145 		&cf_str_EAP_TLS_PEAP_ttls_pap_username_literal,                  // select
 11445 		&cf_str_EAP_TLS_PEAP_ttls_pap_password_literal,                  // select
 11146 		&cf_str_EAP_TLS_PEAP_ttls_pap_password_literal,                  // select
 11446 		&cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time_literal, // select
 11147 		&cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time_literal, // select
 11447 		&KTTLSPAPLastFullAuthTime,                                       // select
 11148 		&KTTLSPAPLastFullAuthTime,                                       // select
 11448 		&KTtlsDatabaseTableName,                                         // from
 11149 		&KTtlsDatabaseTableName,                                         // from
 11449 		&KServiceType,
 11150 		&KServiceType, m_index_type,                                     // where %S=%d
 11450 		m_index_type,
 11151 		&KServiceIndex, m_index,                                         // where %S=%d
 11451 		&KServiceIndex,
 11152 		&KTunnelingType, m_tunneling_vendor_type );                      // where %S=%d
 11452 		m_index,
       
 11453 		&KTunnelingTypeVendorId,
       
 11454 		m_tunneling_type.get_vendor_id(),
       
 11455 		&KTunnelingType,
       
 11456 		m_tunneling_type.get_vendor_type());
       
 11457 	
 11153 	
 11458 	RDbView view;
 11154 	RDbView view;
 11459 	// Evaluate view
 11155 	// Evaluate view
 11460 	User::LeaveIfError( view.Prepare( m_database, TDbQuery( sqlStatement ) ) );
 11156 	User::LeaveIfError( view.Prepare( m_database, TDbQuery( sqlStatement ) ) );
 11461 	CleanupClosePushL( view );
 11157 	CleanupClosePushL( view );
 11473 		// columns updating
 11169 		// columns updating
 11474 		view.SetColL( colSet->ColNo(
 11170 		view.SetColL( colSet->ColNo(
 11475 			cf_str_EAP_TLS_PEAP_ttls_pap_password_prompt_literal ),
 11171 			cf_str_EAP_TLS_PEAP_ttls_pap_password_prompt_literal ),
 11476 			aInDbInfo.iUsrPwdInfo.iPasswordPromptEnabled );
 11172 			aInDbInfo.iUsrPwdInfo.iPasswordPromptEnabled );
 11477 
 11173 
 11478 		EAP_TRACE_DATA_DEBUG(
       
 11479 			m_am_tools,
       
 11480 			TRACE_FLAGS_DEFAULT,
       
 11481 			(EAPL( "eap_am_type_tls_peap_symbian_c::WriteTtlsPapDbL(): iUserName" ),
       
 11482 			aInDbInfo.iUsrPwdInfo.iUserName.Ptr(),
       
 11483 			aInDbInfo.iUsrPwdInfo.iUserName.Size() ) );
       
 11484 
       
 11485 		view.SetColL( colSet->ColNo(
 11174 		view.SetColL( colSet->ColNo(
 11486 			cf_str_EAP_TLS_PEAP_ttls_pap_username_literal ),
 11175 			cf_str_EAP_TLS_PEAP_ttls_pap_username_literal ),
 11487 			aInDbInfo.iUsrPwdInfo.iUserName );
 11176 			aInDbInfo.iUsrPwdInfo.iUserName );
 11488 
 11177 
 11489 		EAP_TRACE_DATA_DEBUG(
       
 11490 			m_am_tools,
       
 11491 			TRACE_FLAGS_DEFAULT,
       
 11492 			(EAPL( "eap_am_type_tls_peap_symbian_c::WriteTtlsPapDbL(): iPassword" ),
       
 11493 			aInDbInfo.iUsrPwdInfo.iPassword.Ptr(),
       
 11494 			aInDbInfo.iUsrPwdInfo.iPassword.Size() ) );
       
 11495 
       
 11496 		view.SetColL( colSet->ColNo(
 11178 		view.SetColL( colSet->ColNo(
 11497 			cf_str_EAP_TLS_PEAP_ttls_pap_password_literal ),
 11179 			cf_str_EAP_TLS_PEAP_ttls_pap_password_literal ),
 11498 			aInDbInfo.iUsrPwdInfo.iPassword );
 11180 			aInDbInfo.iUsrPwdInfo.iPassword );
 11499 
 11181 
 11500 		view.SetColL( colSet->ColNo(
 11182 		view.SetColL( colSet->ColNo(
 11511 	}
 11193 	}
 11512 	
 11194 	
 11513 	CleanupStack::PopAndDestroy( &view ); // Close view.
 11195 	CleanupStack::PopAndDestroy( &view ); // Close view.
 11514 	CleanupStack::PopAndDestroy( buf ); // Delete buf.
 11196 	CleanupStack::PopAndDestroy( buf ); // Delete buf.
 11515 	
 11197 	
 11516 } // eap_am_type_tls_peap_symbian_c::WriteTtlsPapDbL()
 11198 	} // eap_am_type_tls_peap_symbian_c::WriteTtlsPapDbL()
 11517 
 11199 
 11518 
 11200 
 11519 // ------------------------------------------------------------------------
 11201 // ------------------------------------------------------------------------
 11520 // eap_am_type_tls_peap_symbian_c::SetTtlsPapColumnToNullL
 11202 // eap_am_type_tls_peap_symbian_c::SetTtlsPapColumnToNullL
 11521 // ------------------------------------------------------------------------
 11203 // ------------------------------------------------------------------------
 11522 //
 11204 //
 11523 void eap_am_type_tls_peap_symbian_c::SetTtlsPapColumnToNullL( const TDesC& aColName )
 11205 void eap_am_type_tls_peap_symbian_c::SetTtlsPapColumnToNullL( const TDesC& aColName )
 11524 {
 11206 	{
 11525 	EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::SetColumnNullL()" )));
 11207 	DEBUG( "eap_am_type_tls_peap_symbian_c::SetColumnNullL()" );
 11526 
 11208 
 11527 	HBufC* buf = HBufC::NewLC( KMaxSqlQueryLength );
 11209 	HBufC* buf = HBufC::NewLC( KMaxSqlQueryLength );
 11528 	TPtr sqlStatement = buf->Des();
 11210 	TPtr sqlStatement = buf->Des();
 11529 	
 11211 	
 11530 	// Query all the relevant parameters
 11212 	// Query all the relevant parameters
 11531 	_LIT( KSQLQuery,
 11213 	_LIT( KSQLQuery,
 11532 		"SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d" );
 11214 		"SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d" );
 11533 
 11215 	sqlStatement.Format( KSQLQuery,
 11534 	sqlStatement.Format(
       
 11535 		KSQLQuery,
       
 11536 		&aColName,                                  // select´
 11216 		&aColName,                                  // select´
 11537 		&KTtlsDatabaseTableName,                    // from
 11217 		&KTtlsDatabaseTableName,                    // from
 11538 		&KServiceType,
 11218 		&KServiceType, m_index_type,                // where %S=%d
 11539 		m_index_type,
 11219 		&KServiceIndex, m_index,                    // where %S=%d
 11540 		&KServiceIndex,
 11220 		&KTunnelingType, m_tunneling_vendor_type ); // where %S=%d
 11541 		m_index,
       
 11542 		&KTunnelingTypeVendorId,
       
 11543 		m_tunneling_type.get_vendor_id(),
       
 11544 		&KTunnelingType,
       
 11545 		m_tunneling_type.get_vendor_type());
       
 11546 	
 11221 	
 11547 	RDbView view;
 11222 	RDbView view;
 11548 	// Evaluate view
 11223 	// Evaluate view
 11549 	User::LeaveIfError( view.Prepare( m_database, TDbQuery( sqlStatement ) ) );
 11224 	User::LeaveIfError( view.Prepare( m_database, TDbQuery( sqlStatement ) ) );
 11550 	CleanupClosePushL( view );
 11225 	CleanupClosePushL( view );
 11568 	}
 11243 	}
 11569 	
 11244 	
 11570 	CleanupStack::PopAndDestroy( &view ); // Close view.
 11245 	CleanupStack::PopAndDestroy( &view ); // Close view.
 11571 	CleanupStack::PopAndDestroy( buf ); // Delete buf.
 11246 	CleanupStack::PopAndDestroy( buf ); // Delete buf.
 11572 	
 11247 	
 11573 } // eap_am_type_tls_peap_symbian_c::SetTtlsPapColumnToNullL()
 11248 	} // eap_am_type_tls_peap_symbian_c::SetTtlsPapColumnToNullL()
 11574 
 11249 
 11575 
 11250 
 11576 // ================= TTLS-PAP private =======================
 11251 // ================= TTLS-PAP private =======================
 11577 
 11252 
 11578 // ------------------------------------------------------------------------
 11253 // ------------------------------------------------------------------------
 11579 // eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL()
 11254 // eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL()
 11580 // ------------------------------------------------------------------------
 11255 // ------------------------------------------------------------------------
 11581 //
 11256 //
 11582 TBool eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL()
 11257 TBool eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL()
 11583 {
 11258 	{
 11584 	EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL()" )));
 11259 	DEBUG( "eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL()" );
 11585 
 11260 
 11586 	TTtlsPapDbInfo dbInfo;
 11261 	TTtlsPapDbInfo dbInfo;
 11587 	TInt err = KErrNone;
 11262 	TInt err = KErrNone;
 11588 	TBool retValue = EFalse;
 11263 	TBool retValue = EFalse;
 11589 	
 11264 	
 11590 	TRAP( err, ReadTtlsPapDbL( dbInfo ) );
 11265 	TRAP( err, ReadTtlsPapDbL( dbInfo ) );
 11591 	
 11266 	
 11592     if 	( err != KErrNone )
 11267     if 	( err != KErrNone )
 11593         {
 11268         {
 11594         EAP_TRACE_DEBUG_SYMBIAN((_L("ERROR: eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL(): Leave happened, err=%d."), err ));
 11269         DEBUG1( "eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL() ERROR: \
       
 11270         	Leave happened, err=%d.", err );
 11595         retValue = EFalse;
 11271         retValue = EFalse;
 11596         }
 11272         }
 11597     else
 11273     else
 11598     	{
 11274     	{
 11599 	    if ( dbInfo.iUsrPwdInfo.iPasswordPromptEnabled )
 11275 	    if ( dbInfo.iUsrPwdInfo.iPasswordPromptEnabled )
 11600 		    {
 11276 		    {
 11601 			// If the max session time from DB is zero then we use the 
 11277 			// If the max session time from DB is zero then we use the 
 11602 			// one read from configuration file.
 11278 			// one read from configuration file.
 11603 		    if( dbInfo.iMaxSessionTime == 0 )
 11279 		    if( dbInfo.iMaxSessionTime == 0 )
 11604 	            {
 11280 	            {
 11605 	            EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL() Using max TTLS PAP session validity time from config file." )));
 11281 	            DEBUG( "eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL() \
       
 11282 	                	Using max TTLS PAP session validity time from config file." );
 11606 			
 11283 			
 11607 				// use value from config file
 11284 				// use value from config file
 11608 				dbInfo.iMaxSessionTime = iEapTtlsPapMaxSessionConfigTime;
 11285 				dbInfo.iMaxSessionTime = iEapTtlsPapMaxSessionConfigTime;
 11609 			    }
 11286 			    }
 11610 
 11287 
 11611 		    retValue = CheckTtlsPapSessionValidity( dbInfo.iMaxSessionTime,
 11288 		    retValue = CheckTtlsPapSessionValidity( dbInfo.iMaxSessionTime,
 11612 		    	dbInfo.iLastFullAuthTime );
 11289 		    	dbInfo.iLastFullAuthTime );
 11613 		    }
 11290 		    }
 11614     	}	
 11291     	}	
 11615 	return retValue;
 11292 	return retValue;
 11616 }  // eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL()
 11293 	}  // eap_am_type_tls_peap_symbian_c::IsTtlsPapSessionValidL()
 11617 
 11294 
 11618 
 11295 
 11619 // ------------------------------------------------------------------------
 11296 // ------------------------------------------------------------------------
 11620 // eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity()
 11297 // eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity()
 11621 // ------------------------------------------------------------------------
 11298 // ------------------------------------------------------------------------
 11622 //
 11299 //
 11623 TBool eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity(
 11300 TBool eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity(
 11624 	const TInt64& aInMaxSessionTime,
 11301 	const TInt64& aInMaxSessionTime,
 11625 	const TInt64& aInLastFullAuthTime )
 11302 	const TInt64& aInLastFullAuthTime )
 11626 {
 11303 	{
 11627 	EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity()" )));
 11304 	DEBUG( "eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity()" );
 11628 	
 11305 	
 11629 	// Get the current time.
 11306 	// Get the current time.
 11630 	TTime currentTime;
 11307 	TTime currentTime;
 11631 	currentTime.UniversalTime();
 11308 	currentTime.UniversalTime();
 11632 	
 11309 	
 11692 			( EAPL( "eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity - Session NOT Valid \n" ) ) );
 11369 			( EAPL( "eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity - Session NOT Valid \n" ) ) );
 11693 		EAP_TRACE_END( m_am_tools, TRACE_FLAGS_DEFAULT );			
 11370 		EAP_TRACE_END( m_am_tools, TRACE_FLAGS_DEFAULT );			
 11694 		
 11371 		
 11695 		return EFalse;	
 11372 		return EFalse;	
 11696 	    }
 11373 	    }
 11697 } // eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity
 11374 	} // eap_am_type_tls_peap_symbian_c::CheckTtlsPapSessionValidity
 11698 
 11375 
 11699 //--------------------------------------------------
       
 11700 #if defined(USE_FAST_EAP_TYPE)
       
 11701 
       
 11702 TInt eap_am_type_tls_peap_symbian_c::CreateMMETelConnectionL()
       
 11703 {
       
 11704     EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
 11705     EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Creating MMETel connection.\n")));
       
 11706 
       
 11707     TInt errorCode = KErrNone;
       
 11708     
       
 11709     // MMETel need to be connected only once.    
       
 11710     if( !iMMETELConnectionStatus )
       
 11711     {
       
 11712         RTelServer::TPhoneInfo phoneInfo;
       
 11713         TInt phoneCount = 0;
       
 11714 
       
 11715         // Connect to ETel server
       
 11716         User::LeaveIfError( iServer.Connect() );    
       
 11717         
       
 11718         EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Connected to ETel server.\n")));    
       
 11719 
       
 11720         // This function loads an ETel TSY module, mmtsy.
       
 11721         errorCode = iServer.LoadPhoneModule( KMmTsyModuleName );    
       
 11722         
       
 11723         EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Loaded phone module.\n")));     
       
 11724         
       
 11725         if ( errorCode != KErrNone && errorCode != KErrAlreadyExists )
       
 11726         {
       
 11727             User::Leave( errorCode );
       
 11728         }
       
 11729 
       
 11730         iServer.SetExtendedErrorGranularity( RTelServer::EErrorExtended );
       
 11731 
       
 11732         // This function retrieves the total number of phones supported by all 
       
 11733         // the currently loaded ETel (TSY) modules.
       
 11734         User::LeaveIfError( iServer.EnumeratePhones( phoneCount ) );    
       
 11735         
       
 11736         EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Number of phones supported by the loaded ETel = %d.\n"), phoneCount));
       
 11737         
       
 11738         // This function retrieves information associated with the specified phone
       
 11739         while ( ( phoneCount-- ) && ( phoneInfo.iName != KMmTsyPhoneName ) ) 
       
 11740         { 
       
 11741             User::LeaveIfError( iServer.GetPhoneInfo( phoneCount, phoneInfo ) );        
       
 11742             
       
 11743             EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Got phone info.\n")));
       
 11744         } 
       
 11745 
       
 11746         // This function opens a phone subsession by name. ("DefaultPhone").
       
 11747         User::LeaveIfError( iPhone.Open( iServer, phoneInfo.iName ) );  
       
 11748         
       
 11749         EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Opened phone subsession.\n")));
       
 11750         
       
 11751         // MMETel connected and the phone module loaded fine.   
       
 11752         iMMETELConnectionStatus = ETrue;    
       
 11753     }
       
 11754     else
       
 11755     {
       
 11756         // MMETel already connected.
       
 11757         EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("MMETel connected once already.\n")));
       
 11758     }
       
 11759         
       
 11760     EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
 11761     
       
 11762     return errorCode;   
       
 11763 }
       
 11764 
       
 11765 //--------------------------------------------------
       
 11766 
       
 11767 void eap_am_type_tls_peap_symbian_c::DisconnectMMETel()
       
 11768 {
       
 11769     if( iMMETELConnectionStatus )
       
 11770     {
       
 11771         EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("Closing RMobilePhone and MMETEL.\n")));
       
 11772         
       
 11773         iPhone.Close();
       
 11774         iServer.Close(); // Phone module is unloaded automatically when RTelServer session is closed
       
 11775         
       
 11776         iMMETELConnectionStatus = EFalse;
       
 11777     }
       
 11778     else
       
 11779     {
       
 11780         EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("RMobilePhone and MMETEL already closed.\n")));      
       
 11781     }   
       
 11782 }
       
 11783 #endif
       
 11784 //--------------------------------------------------
       
 11785 
 11376 
 11786 // End of file.
 11377 // End of file.