eapol/eapol_framework/eapol_symbian/am/type/securid/symbian/eap_am_type_securid_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: 29.1.36 %
    19 * %version: 32 %
    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
    37 #include "eap_am_memory.h"
    37 #include "eap_am_memory.h"
    38 #include "eap_tools.h"
    38 #include "eap_tools.h"
    39 #include "eap_am_type_securid_symbian.h"
    39 #include "eap_am_type_securid_symbian.h"
    40 #include "EapSecurIDDbParameterNames.h"
    40 #include "EapSecurIDDbParameterNames.h"
    41 #include "EapSecurIDDbUtils.h"
    41 #include "EapSecurIDDbUtils.h"
    42 #include "EapPluginDbDefaults.h"
    42 #include "EapSecurIDNotifierStructs.h"
    43 #include "eap_auth_notifier.h"
       
    44 
       
    45 
       
    46 #include "EapGtcDbParameterNames.h"
    43 #include "EapGtcDbParameterNames.h"
    47 #include "EapGtcDbUtils.h"
    44 #include "EapGtcDbUtils.h"
    48 #include "EapSecurIDNotifierUids.h"
    45 #include "EapSecurIDNotifierUids.h"
    49 #include "eap_configuration_field.h"
    46 #include "eap_configuration_field.h"
    50 #include "eap_state_notification.h"
    47 #include "eap_state_notification.h"
    51 
    48 
    52 #include "EapTraceSymbian.h"
    49 #include "eap_am_trace_symbian.h"
    53 
    50 
    54 const TUint KMaxSqlQueryLength = 256;
    51 const TUint KMaxSqlQueryLength = 256;
    55 const TUint KMaxDBFieldNameLength = 255;
    52 const TUint KMaxDBFieldNameLength = 255;
    56 const char EAP_GTC_USERNAME_HANDLE_KEY[] = "eap_type_securid_c GTC username";
    53 const char EAP_GTC_USERNAME_HANDLE_KEY[] = "eap_type_securid_c GTC username";
    57 const TInt 	KDefaultColumnInView_One = 1; // For DB view.
    54 const TInt 	KDefaultColumnInView_One = 1; // For DB view.
    76 
    73 
    77 	delete m_dialog_data_ptr;
    74 	delete m_dialog_data_ptr;
    78 	delete m_dialog_data_pckg_ptr;
    75 	delete m_dialog_data_pckg_ptr;
    79 	delete m_message_buf;
    76 	delete m_message_buf;
    80 
    77 
    81 	delete iEapAuthNotifier;
       
    82 	iEapAuthNotifier = 0;
       
    83 
       
    84 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
    78 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
    85 }
    79 }
    86 
    80 
    87 //--------------------------------------------------
    81 //--------------------------------------------------
    88 
    82 
    94 		m_am_tools, 
    88 		m_am_tools, 
    95 		TRACE_FLAGS_DEFAULT, 
    89 		TRACE_FLAGS_DEFAULT, 
    96 		(EAPL("eap_am_type_securid_symbian_c::shutdown(): this = 0x%08x\n"),
    90 		(EAPL("eap_am_type_securid_symbian_c::shutdown(): this = 0x%08x\n"),
    97 		this));
    91 		this));
    98 
    92 
    99 
    93 	if( IsActive() )
       
    94 	{
       
    95 		Cancel(); // Cancel only if active.
       
    96 	}  
       
    97 	else
       
    98 	{
       
    99 		if( m_is_notifier_connected )
       
   100 		{
       
   101 	EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::shutdown - calling m_notifier.CancelNotifier(..)\n")));
       
   102 	
       
   103 			TInt error = m_notifier.CancelNotifier(KEapSecurIDIdentityQueryUid);
       
   104 			
       
   105 	EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::shutdown - CancelNotifier(KEapSecurIDIdentityQueryUid) error=%d\n"), error));
       
   106 
       
   107 
       
   108 			error = m_notifier.CancelNotifier(KEapSecurIDPasscodeQueryUid);
       
   109 			
       
   110 	EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::shutdown - CancelNotifier(KEapSecurIDPasscodeQueryUid) error=%d\n"), error));
       
   111 
       
   112 
       
   113 			error = m_notifier.CancelNotifier(KEapSecurIDPincodeQueryUid);
       
   114 			
       
   115 	EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::shutdown - CancelNotifier(KEapSecurIDPincodeQueryUid) error=%d\n"), error));
       
   116 
       
   117 
       
   118 			error = m_notifier.CancelNotifier(KEapGtcIdentityQueryUid);
       
   119 			
       
   120 	EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::shutdown - CancelNotifier(KEapGtcIdentityQueryUid) error=%d\n"), error));
       
   121 
       
   122 
       
   123 			error = m_notifier.CancelNotifier(KEapGtcUserInputQueryUid);
       
   124 			
       
   125 	EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::shutdown - CancelNotifier(KEapGtcUserInputQueryUid) error=%d\n"), error));
       
   126 
       
   127 
       
   128 	
       
   129 	EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::shutdown - calling m_notifier.Close(), prev error=%d\n"), error));
       
   130 
       
   131 			m_notifier.Close(); // Call close only if it is connected.	
       
   132 			
       
   133 			m_is_notifier_connected = false;
       
   134 		}
       
   135 	}
       
   136 	
   100 	m_shutdown_was_called = true;
   137 	m_shutdown_was_called = true;
   101 
   138 
   102 	m_partner->cancel_timer(this, EHandlingTimerCall);
       
   103 	
       
   104 	EAP_TRACE_DEBUG(
   139 	EAP_TRACE_DEBUG(
   105 		m_am_tools, 
   140 		m_am_tools, 
   106 		TRACE_FLAGS_DEFAULT, 
   141 		TRACE_FLAGS_DEFAULT, 
   107 		(EAPL("eap_am_type_securid_symbian_c::shutdown(): this = 0x%08x returns\n"),
   142 		(EAPL("eap_am_type_securid_symbian_c::shutdown(): this = 0x%08x returns\n"),
   108 		this));
   143 		this));
   134 		, m_is_client(aIsClient)
   169 		, m_is_client(aIsClient)
   135 		, m_is_valid(false)
   170 		, m_is_valid(false)
   136 		, m_shutdown_was_called(false)
   171 		, m_shutdown_was_called(false)
   137 		, m_eap_type(aEapType)
   172 		, m_eap_type(aEapType)
   138 		, m_is_notifier_connected(false)
   173 		, m_is_notifier_connected(false)
   139 		, m_max_session_time(0)
   174 		, m_max_session_time(0)	
   140 		, iEapAuthNotifier(0)	
       
   141 
       
   142 {
   175 {
   143 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   176 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   177 
       
   178 #ifdef USE_EAP_EXPANDED_TYPES
       
   179 
       
   180 	m_tunneling_vendor_type = m_tunneling_type.get_vendor_type();
       
   181 	m_eap_vendor_type = m_eap_type.get_vendor_type();
       
   182 
       
   183 #else
       
   184 
       
   185 	m_tunneling_vendor_type = static_cast<TUint>(m_tunneling_type);
       
   186 	m_eap_vendor_type = static_cast<TUint>(m_eap_type);	
       
   187 
       
   188 #endif //#ifdef USE_EAP_EXPANDED_TYPES
   144 
   189 
   145 	if (receive_network_id != 0
   190 	if (receive_network_id != 0
   146 		&& receive_network_id->get_is_valid_data() == true)
   191 		&& receive_network_id->get_is_valid_data() == true)
   147 	{
   192 	{
   148 		eap_status_e status = m_receive_network_id.set_copy_of_network_id(
   193 		eap_status_e status = m_receive_network_id.set_copy_of_network_id(
   198 
   243 
   199 //--------------------------------------------------
   244 //--------------------------------------------------
   200 
   245 
   201 void eap_am_type_securid_symbian_c::ConstructL()
   246 void eap_am_type_securid_symbian_c::ConstructL()
   202 {
   247 {
   203 	TInt error = m_session.Connect();
       
   204 	EAP_TRACE_DEBUG_SYMBIAN((_L("eap_am_type_securid_symbian_c::ConstructL(): - m_session.Connect(), error=%d\n"), error));
       
   205 	User::LeaveIfError(error);
       
   206 
       
   207 	// Open/create database
   248 	// Open/create database
   208 	if (m_eap_type == eap_type_generic_token_card)
   249 	if (m_eap_type == eap_type_generic_token_card)
   209 	{
   250 	{
   210 		EapGtcDbUtils::OpenDatabaseL(m_database, m_session, m_index_type, m_index, m_tunneling_type);
   251 		EapGtcDbUtils::OpenDatabaseL(m_database, m_session, m_index_type, m_index, m_tunneling_type);
   211 	}
   252 	}
   212 	else
   253 	else
   213 	{
   254 	{
   214 		EapSecurIDDbUtils::OpenDatabaseL(m_database, m_session, m_index_type, m_index, m_tunneling_type);
   255 		EapSecurIDDbUtils::OpenDatabaseL(m_database, m_session, m_index_type, m_index, m_tunneling_type);
   215 	}
   256 	}
   216 
   257 
   217 	m_dialog_data_ptr = new(ELeave) CEapAuthNotifier::TEapDialogInfo;
   258 	m_dialog_data_ptr = new(ELeave) TEapSecurIDStruct;
   218 	m_dialog_data_pckg_ptr = new(ELeave) TPckg<CEapAuthNotifier::TEapDialogInfo> (*m_dialog_data_ptr);
   259 	m_dialog_data_pckg_ptr = new(ELeave) TPckg<TEapSecurIDStruct> (*m_dialog_data_ptr);
   219 
   260 
   220 	CActiveScheduler::Add(this);
   261 	CActiveScheduler::Add(this);
   221 }
   262 }
   222 
   263 
   223 //--------------------------------------------------
   264 //--------------------------------------------------
   279 		TRACE_FLAGS_DEFAULT,
   320 		TRACE_FLAGS_DEFAULT,
   280 		(EAPL("eap_am_type_securid_symbian_c::RunL - start")
   321 		(EAPL("eap_am_type_securid_symbian_c::RunL - start")
   281 		 EAPL("m_state, iStatus.Int()=%d\n"),
   322 		 EAPL("m_state, iStatus.Int()=%d\n"),
   282 		 m_state, iStatus.Int()));
   323 		 m_state, iStatus.Int()));
   283 
   324 
       
   325 	if (iStatus.Int() == KErrCancel)
       
   326 	{
       
   327 		delete m_message_buf;
       
   328 		m_message_buf = NULL;
       
   329 		get_am_partner()->finish_unsuccessful_authentication(true);
       
   330 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
   331 		return;
       
   332 	}
       
   333 	
       
   334 	if (iStatus.Int() != KErrNone)
       
   335 	{
       
   336 		delete m_message_buf;
       
   337 		m_message_buf = NULL;
       
   338 		// Something is very wrong...
       
   339 
       
   340 		EAP_TRACE_ERROR(
       
   341 			m_am_tools,
       
   342 			TRACE_FLAGS_DEFAULT,
       
   343 			(EAPL("ERROR: EAP - SecurID notifier or dialog\n")));
       
   344 
       
   345 		send_error_notification(eap_status_authentication_failure);
       
   346 
       
   347 		get_am_partner()->finish_unsuccessful_authentication(false);
       
   348 
       
   349 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
   350 		return;
       
   351 	}
       
   352 
       
   353 	switch (m_state)
       
   354 	{
       
   355 	case EHandlingIdentityQuery:
       
   356 		{
       
   357 			EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::RunL(): EHandlingIdentityQuery\n")));
       
   358 
       
   359 			eap_variable_data_c identity(m_am_tools);
       
   360 
       
   361 			eap_status_e status = identity.set_copy_of_buffer(
       
   362 				m_dialog_data_ptr->iIdentity.Ptr(),
       
   363 				m_dialog_data_ptr->iIdentity.Size());
       
   364 			if (status != eap_status_ok)
       
   365 			{
       
   366 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
   367 				(void)EAP_STATUS_RETURN(m_am_tools, status);
       
   368 				return;
       
   369 			}
       
   370 
       
   371 			eap_variable_data_c identity_utf8(m_am_tools);
       
   372 			status = m_am_tools->convert_unicode_to_utf8(identity_utf8, identity);
       
   373 			if (status != eap_status_ok)
       
   374 			{
       
   375 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
   376 				(void)EAP_STATUS_RETURN(m_am_tools, status);
       
   377 				return;
       
   378 			}
       
   379 
       
   380 			status = get_am_partner()->complete_eap_identity_query(&identity_utf8);
       
   381 		}
       
   382 		break;
       
   383 
       
   384 	case EHandlingPasscodeQuery:
       
   385 		{
       
   386 			EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::RunL(): EHandlingPasscodeQuery\n")));
       
   387 
       
   388 			eap_variable_data_c passcode(m_am_tools);
       
   389 
       
   390 			eap_status_e status = passcode.set_copy_of_buffer(
       
   391 				m_dialog_data_ptr->iPasscode.Ptr(),
       
   392 				m_dialog_data_ptr->iPasscode.Size());
       
   393 			if (status != eap_status_ok)
       
   394 			{
       
   395 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
   396 				(void)EAP_STATUS_RETURN(m_am_tools, status);
       
   397 				return;
       
   398 			}
       
   399 
       
   400 			eap_variable_data_c passcode_utf8(m_am_tools);
       
   401 			status = m_am_tools->convert_unicode_to_utf8(passcode_utf8, passcode);
       
   402 			if (status != eap_status_ok)
       
   403 			{
       
   404 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
   405 				(void)EAP_STATUS_RETURN(m_am_tools, status);
       
   406 				return;
       
   407 			}
       
   408 
       
   409 			status = get_am_partner()->client_securid_complete_passcode_query(&passcode_utf8);
       
   410 		}
       
   411 		break;
       
   412 
       
   413 	case EHandlingPincodeQuery:
       
   414 		{
       
   415 			EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::RunL(): EHandlingPincodeQuery\n")));
       
   416 
       
   417 			eap_variable_data_c pincode(m_am_tools);
       
   418 
       
   419 			eap_status_e status = pincode.set_copy_of_buffer(
       
   420 				m_dialog_data_ptr->iPincode.Ptr(),
       
   421 				m_dialog_data_ptr->iPincode.Size());
       
   422 			if (status != eap_status_ok)
       
   423 			{
       
   424 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
   425 				(void)EAP_STATUS_RETURN(m_am_tools, status);
       
   426 				return;
       
   427 			}
       
   428 
       
   429 			eap_variable_data_c passcode(m_am_tools);
       
   430 
       
   431 			status = passcode.set_copy_of_buffer(
       
   432 				m_dialog_data_ptr->iPasscode.Ptr(),
       
   433 				m_dialog_data_ptr->iPasscode.Size());
       
   434 			if (status != eap_status_ok)
       
   435 			{
       
   436 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
   437 				(void)EAP_STATUS_RETURN(m_am_tools, status);
       
   438 				return;
       
   439 			}
       
   440 
       
   441 
       
   442 			eap_variable_data_c pincode_utf8(m_am_tools);
       
   443 			status = m_am_tools->convert_unicode_to_utf8(pincode_utf8, pincode);
       
   444 			if (status != eap_status_ok)
       
   445 			{
       
   446 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
   447 				(void)EAP_STATUS_RETURN(m_am_tools, status);
       
   448 				return;
       
   449 			}
       
   450 
       
   451 			eap_variable_data_c passcode_utf8(m_am_tools);
       
   452 			status = m_am_tools->convert_unicode_to_utf8(passcode_utf8, passcode);
       
   453 			if (status != eap_status_ok)
       
   454 			{
       
   455 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
   456 				(void)EAP_STATUS_RETURN(m_am_tools, status);
       
   457 				return;
       
   458 			}
       
   459 
       
   460 			status = get_am_partner()->client_securid_complete_pincode_query(&passcode_utf8, &passcode_utf8);
       
   461 		}
       
   462 		break;
       
   463 
       
   464 	case EHandlingGTCQuery:
       
   465 		{
       
   466 			EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::RunL(): EHandlingGTCQuery\n")));
       
   467 
       
   468 			delete m_message_buf;
       
   469 			m_message_buf = NULL;
       
   470 
       
   471 			eap_variable_data_c passcode(m_am_tools);
       
   472 
       
   473 			eap_status_e status = passcode.set_copy_of_buffer(
       
   474 				m_dialog_data_ptr->iPasscode.Ptr(),
       
   475 				m_dialog_data_ptr->iPasscode.Size());
       
   476 			if (status != eap_status_ok)
       
   477 			{
       
   478 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
   479 				(void)EAP_STATUS_RETURN(m_am_tools, status);
       
   480 				return;
       
   481 			}
       
   482 
       
   483 			eap_variable_data_c passcode_utf8(m_am_tools);
       
   484 			status = m_am_tools->convert_unicode_to_utf8(passcode_utf8, passcode);
       
   485 			if (status != eap_status_ok)
       
   486 			{
       
   487 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
   488 				(void)EAP_STATUS_RETURN(m_am_tools, status);
       
   489 				return;
       
   490 			}
       
   491 			
       
   492 			// User must have entered some password and pressed OK.
       
   493 			// Treat this as a full authentication and update the Last Auth Time.
       
   494 			status = store_authentication_time();
       
   495 			if (status != eap_status_ok)
       
   496 			{
       
   497 				// Storing failed. Don't care.
       
   498 				EAP_TRACE_ERROR(m_am_tools, 
       
   499 					TRACE_FLAGS_DEFAULT, (
       
   500 					EAPL("eap_am_type_securid_symbian_c:Storing Last Full Authentication time failed, status=%d, but continuing\n"), 
       
   501 					status));
       
   502 
       
   503 				status = eap_status_ok;
       
   504 			}			
       
   505 
       
   506 			status = get_am_partner()->client_gtc_complete_user_input_query(&passcode_utf8);
       
   507 		}
       
   508 		break;
       
   509 
       
   510 	default:
       
   511 		EAP_TRACE_ERROR(
       
   512 			m_am_tools,
       
   513 			TRACE_FLAGS_DEFAULT,
       
   514 			(EAPL("ERROR: EAP - SecurID illegal state in RunL.\n")));
       
   515 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
   516 		return;		
       
   517 	}
   284 
   518 
   285 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
   519 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
   286 }
   520 }
   287 
   521 
   288 //--------------------------------------------------
   522 //--------------------------------------------------
   289 
   523 
   290 void eap_am_type_securid_symbian_c::DoCancel()
   524 void eap_am_type_securid_symbian_c::DoCancel()
   291 {
   525 {
   292 	iEapAuthNotifier->Cancel();
   526 	if( m_is_notifier_connected )
   293 
   527 	{
       
   528 	EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::DoCancel - calling m_notifier.CancelNotifier(..)\n")));
       
   529 		
       
   530 		TInt error = m_notifier.CancelNotifier(KEapSecurIDIdentityQueryUid);
       
   531 		
       
   532 	EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::DoCancel - CancelNotifier(KEapSecurIDIdentityQueryUid) error=%d\n"), error));
       
   533 
       
   534 		error = m_notifier.CancelNotifier(KEapSecurIDPasscodeQueryUid);
       
   535 		
       
   536 	EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::DoCancel - CancelNotifier(KEapSecurIDPasscodeQueryUid) error=%d\n"), error));
       
   537 
       
   538 		error = m_notifier.CancelNotifier(KEapSecurIDPincodeQueryUid);
       
   539 		
       
   540 	EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::DoCancel - CancelNotifier(KEapSecurIDPincodeQueryUid) error=%d\n"), error));
       
   541 
       
   542 		error = m_notifier.CancelNotifier(KEapGtcIdentityQueryUid);
       
   543 		
       
   544 	EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::DoCancel - CancelNotifier(KEapGtcIdentityQueryUid) error=%d\n"), error));
       
   545 
       
   546 		error = m_notifier.CancelNotifier(KEapGtcUserInputQueryUid);
       
   547 		
       
   548 	EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::DoCancel - CancelNotifier(KEapGtcUserInputQueryUid) error=%d\n"), error));
       
   549 
       
   550 		m_notifier.Close(); // Call close only if it is connected.	
       
   551 		
       
   552 		m_is_notifier_connected = false;
       
   553 	}
   294 }
   554 }
   295 
   555 
   296 //--------------------------------------------------
   556 //--------------------------------------------------
   297 
   557 
   298 
   558 
   300 	const eap_configuration_field_c * const field,
   560 	const eap_configuration_field_c * const field,
   301 	eap_variable_data_c * const data)
   561 	eap_variable_data_c * const data)
   302 {
   562 {
   303 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   563 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   304 	EAP_ASSERT(data != 0);
   564 	EAP_ASSERT(data != 0);
   305 
       
   306 	// Trap must be set here because the OS independent portion of EAP SecurID
   565 	// Trap must be set here because the OS independent portion of EAP SecurID
   307 	// that calls this function does not know anything about Symbian.	
   566 	// that calls this function does not know anything about Symbian.	
   308 	eap_status_e status(eap_status_ok);
   567 	eap_status_e status(eap_status_ok);
   309 
       
   310 	TRAPD(err, type_configure_readL(
   568 	TRAPD(err, type_configure_readL(
   311 		field->get_field(),
   569 		field->get_field(),
   312 		field->get_field_length(),
   570 		field->get_field_length(),
   313 		data));
   571 		data));
   314 	if (err != KErrNone) 
   572 	if (err != KErrNone) 
   334 	eap_config_string field,
   592 	eap_config_string field,
   335 	const u32_t field_length,
   593 	const u32_t field_length,
   336 	eap_variable_data_c * const data)
   594 	eap_variable_data_c * const data)
   337 {
   595 {
   338 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   596 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   339 	EAP_TRACE_DEBUG(
       
   340 		m_am_tools, 
       
   341 		TRACE_FLAGS_DEFAULT,
       
   342 		(EAPL("eap_am_type_securid_symbian_c::type_configure_readL(): m_index_type=%d, m_index=%d, m_tunneling_type=0xfe%06x%08x\n"),
       
   343 		m_index_type,
       
   344 		m_index,
       
   345 		m_tunneling_type.get_vendor_id(),
       
   346 		m_tunneling_type.get_vendor_type()));
       
   347 
       
   348 	EAP_UNREFERENCED_PARAMETER(field_length);
   597 	EAP_UNREFERENCED_PARAMETER(field_length);
   349 
   598 
   350 	// Create a buffer for the ascii strings - initialised with the argument
   599 	// Create a buffer for the ascii strings - initialised with the argument
   351 	HBufC16* unicodeBuf = HBufC16::NewLC(KMaxDBFieldNameLength);
   600 	HBufC16* unicodeBuf = HBufC16::NewLC(KMaxDBFieldNameLength);
   352 	TPtr16 unicodeString = unicodeBuf->Des();
   601 	TPtr16 unicodeString = unicodeBuf->Des();
   358 	// Now do the database query
   607 	// Now do the database query
   359 	
   608 	
   360 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
   609 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
   361 	TPtr sqlStatement = buf->Des();
   610 	TPtr sqlStatement = buf->Des();
   362 
   611 
   363 	_LIT(KSQLQueryRow, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
   612 	_LIT(KSQLQueryRow, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d");
   364 	if (m_eap_type == eap_type_securid)
   613 	if (m_eap_type == eap_type_securid)
   365 	{
   614 	{
   366 		sqlStatement.Format(
   615 		sqlStatement.Format(KSQLQueryRow, &unicodeString, &KSecurIDTableName, 
   367 			KSQLQueryRow,
   616 			&KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);
   368 			&unicodeString,
       
   369 			&KSecurIDTableName, 
       
   370 			&KServiceType,
       
   371 			m_index_type,
       
   372 			&KServiceIndex,
       
   373 			m_index,
       
   374 			&KTunnelingTypeVendorId,
       
   375 			m_tunneling_type.get_vendor_id(),
       
   376 			&KTunnelingType, 
       
   377 			m_tunneling_type.get_vendor_type());
       
   378 	}
   617 	}
   379 	else
   618 	else
   380 	{
   619 	{
   381 		sqlStatement.Format(
   620 		sqlStatement.Format(KSQLQueryRow, &unicodeString, &KGtcTableName, 
   382 			KSQLQueryRow,
   621 			&KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);
   383 			&unicodeString,
   622 	}	
   384 			&KGtcTableName, 
       
   385 			&KServiceType,
       
   386 			m_index_type,
       
   387 			&KServiceIndex,
       
   388 			m_index,
       
   389 			&KTunnelingTypeVendorId,
       
   390 			m_tunneling_type.get_vendor_id(),
       
   391 			&KTunnelingType, 
       
   392 			m_tunneling_type.get_vendor_type());
       
   393 	}
       
   394 
       
   395 	RDbView view;
   623 	RDbView view;
   396 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));
   624 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));
   397 	CleanupClosePushL(view);
   625 	CleanupClosePushL(view);
   398 	
   626 	
   399 	User::LeaveIfError(view.EvaluateAll());	
   627 	User::LeaveIfError(view.EvaluateAll());	
   499 
   727 
   500 	{
   728 	{
   501 		// Read Maximum Session Validity Time from the config file
   729 		// Read Maximum Session Validity Time from the config file
   502 		eap_variable_data_c sessionTimeFromFile(m_am_tools);
   730 		eap_variable_data_c sessionTimeFromFile(m_am_tools);
   503 		
   731 		
   504 		eap_status_e status = type_configure_read(
   732 		eap_status_e status = m_partner->read_configure(
   505 			cf_str_EAP_GTC_max_session_validity_time.get_field(),
   733 			cf_str_EAP_GTC_max_session_validity_time.get_field(),
   506 			&sessionTimeFromFile);
   734 			&sessionTimeFromFile);
   507 		
   735 		
   508 		if (status == eap_status_ok
   736 		if (status == eap_status_ok
   509 			&& sessionTimeFromFile.get_is_valid_data() == true
   737 			&& sessionTimeFromFile.get_is_valid_data() == true
   561 
   789 
   562 eap_status_e eap_am_type_securid_symbian_c::show_passcode_query_dialog(
   790 eap_status_e eap_am_type_securid_symbian_c::show_passcode_query_dialog(
   563 	eap_variable_data_c * const /*passcode*/,
   791 	eap_variable_data_c * const /*passcode*/,
   564 	bool is_first_query)
   792 	bool is_first_query)
   565 {
   793 {
   566 	EAP_TRACE_DEBUG(
   794 	if (!IsActive())
   567 		m_am_tools, 
   795 	{
   568 		TRACE_FLAGS_DEFAULT,
   796 		m_state = EHandlingPasscodeQuery;
   569 		(EAPL("eap_am_type_securid_symbian_c::show_passcode_query_dialog(): is_first_query=%d\n"),
   797 		
   570 		is_first_query));
   798 		if (is_first_query == true)
   571 
   799 		{
   572 	eap_status_e status = eap_status_pending_request;
   800 			m_dialog_data_ptr->iIsFirstQuery = ETrue;
   573 	
   801 		}
   574 	m_state = EHandlingPasscodeQuery;
       
   575 
       
   576 	TInt err1 = KErrNone;
       
   577 	
       
   578 	TRAPD(err, err1 = IsDlgReadyToCompleteL());
       
   579 	
       
   580 	EAP_TRACE_DEBUG(
       
   581 		m_am_tools, 
       
   582 		TRACE_FLAGS_DEFAULT,
       
   583 		(EAPL("eap_am_type_securid_symbian_c::show_passcode_query_dialog(): err=%d result=%d\n"),
       
   584 		err, err1));
       
   585 
       
   586 	if ((err1 == KErrCancel) || err)
       
   587 		{
       
   588 		TEapExpandedType aEapType(*EapExpandedTypeGtc.GetType());
       
   589 		
       
   590 		if (iEapAuthNotifier == 0)
       
   591 		    {
       
   592 		    TRAPD(err, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
       
   593 		  	if (err)
       
   594 		  		{
       
   595 		  			return EAP_STATUS_RETURN(m_am_tools, eap_status_authentication_failure);
       
   596 		  		}
       
   597 		    }
       
   598 
       
   599 		if (is_first_query != true)
       
   600 			{
       
   601 			TRAPD(err1, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeGtcChallengeDialog, m_dialog_data_ptr, aEapType));
       
   602 			if (err1)
       
   603 				{
       
   604 				return EAP_STATUS_RETURN(m_am_tools, eap_status_authentication_failure);
       
   605 				}
       
   606 			}
       
   607 		else
   802 		else
   608 			{
   803 		{
   609 			TRAPD(err2, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeGTCQueryDialog, m_dialog_data_ptr, aEapType));
   804 			m_dialog_data_ptr->iIsFirstQuery = EFalse;
   610 			if (err2)
   805 		}
   611 				{
   806 
   612 				return EAP_STATUS_RETURN(m_am_tools, eap_status_authentication_failure);
   807 		if( !m_is_notifier_connected )
   613 				}
   808 		{
   614 			}
   809 			TInt error = m_notifier.Connect();
   615 
   810 			
   616 		}
   811 			EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::show_passcode_query_dialog - m_notifier.Connect() returned error=%d\n"), error));
       
   812 			
       
   813 			if( error != KErrNone)
       
   814 			{
       
   815 				// Can not connect to notifier.
       
   816 				return EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(error));		
       
   817 			}
       
   818 			
       
   819 			m_is_notifier_connected = true; // Got connectted to notifier.
       
   820 		}
       
   821 
       
   822 		EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::show_passcode_query_dialog - StartNotifierAndGetResponse - KEapSecurIDPasscodeQueryUid \n")));
       
   823 
       
   824 		m_notifier.StartNotifierAndGetResponse(
       
   825 			iStatus, 
       
   826 			KEapSecurIDPasscodeQueryUid, 
       
   827 			*m_dialog_data_pckg_ptr, 
       
   828 			*m_dialog_data_pckg_ptr);
       
   829 
       
   830 		SetActive();
       
   831 	} 
   617 	else
   832 	else
   618 		{
   833 	{
   619 		EAP_TRACE_DEBUG(
   834 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c: Already active when tried to show passcode query dialog.\n")));
   620 			m_am_tools, 
   835 		return eap_status_process_general_error;
   621 			TRACE_FLAGS_DEFAULT,
   836 	}
   622 			(EAPL("eap_am_type_securid_symbian_c::show_passcode_query_dialog(): EHandlingTimerCall\n")));
   837 
   623 
   838 	return eap_status_pending_request;
   624 		if(m_partner->set_timer(this,EHandlingTimerCall,0 /*data*/,2 /*time ms*/) != eap_status_ok)
       
   625 			status = eap_status_process_general_error;	
       
   626 		}
       
   627 
       
   628 
       
   629 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   630 }
   839 }
   631 
   840 
   632 //--------------------------------------------------
   841 //--------------------------------------------------
   633 
   842 
   634 eap_status_e eap_am_type_securid_symbian_c::show_gtc_query_dialog(
   843 eap_status_e eap_am_type_securid_symbian_c::show_gtc_query_dialog(
   642 		TRACE_FLAGS_DEFAULT,
   851 		TRACE_FLAGS_DEFAULT,
   643 		(EAPL("eap_am_type_securid_symbian_c::show_gtc_query_dialog: message"),
   852 		(EAPL("eap_am_type_securid_symbian_c::show_gtc_query_dialog: message"),
   644 		message,
   853 		message,
   645 		message_length));
   854 		message_length));
   646 
   855 
   647 	eap_status_e status = eap_status_pending_request;
   856 	if (!IsActive())
   648 	
   857 	{
   649 	m_state = EHandlingGTCQuery;
   858 		m_state = EHandlingGTCQuery;
   650 	
   859 
   651 	TInt err1 = KErrNone;
       
   652 	
       
   653 	TRAPD(err, err1 = IsDlgReadyToCompleteL());
       
   654 	
       
   655 	EAP_TRACE_DEBUG(
       
   656 		m_am_tools, 
       
   657 		TRACE_FLAGS_DEFAULT,
       
   658 		(EAPL("eap_am_type_securid_symbian_c::show_gtc_query_dialog(): err=%d, result=%d, is_first_query=%d\n"),
       
   659 		err,
       
   660 		err1,
       
   661 		is_first_query));
       
   662 
       
   663 	if ((err1 == KErrCancel) || err)
       
   664 		{
       
   665 		eap_variable_data_c message_utf8(m_am_tools);
   860 		eap_variable_data_c message_utf8(m_am_tools);
   666 		eap_status_e status = message_utf8.set_buffer(message, message_length, false, false);
   861 		eap_status_e status = message_utf8.set_buffer(message, message_length, false, false);
   667 		if (status != eap_status_ok)
   862 		if (status != eap_status_ok)
   668 			{
   863 		{
   669 			return EAP_STATUS_RETURN(m_am_tools, status);
   864 			return EAP_STATUS_RETURN(m_am_tools, status);
   670 			}
   865 		}
   671 
   866 
   672 		eap_variable_data_c message_unicode(m_am_tools);
   867 		eap_variable_data_c message_unicode(m_am_tools);
   673 		status = m_am_tools->convert_utf8_to_unicode(message_unicode, message_utf8);
   868 		status = m_am_tools->convert_utf8_to_unicode(message_unicode, message_utf8);
   674 		if (status != eap_status_ok)
   869 		if (status != eap_status_ok)
   675 			{
   870 		{
   676 			return EAP_STATUS_RETURN(m_am_tools, status);
   871 			return EAP_STATUS_RETURN(m_am_tools, status);
   677 			}
   872 		}
   678 
   873 
   679 		m_dialog_data_ptr->iUidata.Copy((TText *)message_unicode.get_data(), message_unicode.get_data_length());
   874 		TRAPD(err, m_message_buf = HBufC8::NewL(message_unicode.get_data_length()));
   680 
   875 		if (err != KErrNone)
   681 		m_dialog_data_ptr->iPassword.Zero();
   876 		{
   682 
   877 			return eap_status_allocation_error;
   683 		TEapExpandedType aEapType(*EapExpandedTypeGtc.GetType());
   878 		}
   684 		
   879 		TPtr8 messageBufPtr = m_message_buf->Des();
   685 		if (iEapAuthNotifier == 0)
   880 		messageBufPtr.Copy(message_unicode.get_data(), message_unicode.get_data_length());
   686 		    {
   881 
   687 		    TRAPD(err, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
   882 		if (is_first_query == true)
   688 		  	if (err)
   883 		{
   689 		  		{
   884 			m_dialog_data_ptr->iIsFirstQuery = ETrue;
   690 		  			return EAP_STATUS_RETURN(m_am_tools, eap_status_authentication_failure);
   885 		}
   691 		  		}
       
   692 		    }
       
   693 
       
   694 		if (is_first_query != true)
       
   695 			{
       
   696 			TRAPD(err1, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeGtcChallengeDialog, m_dialog_data_ptr, aEapType));
       
   697 			if (err1)
       
   698 				{
       
   699 					return EAP_STATUS_RETURN(m_am_tools, eap_status_authentication_failure);
       
   700 				}
       
   701 			}
       
   702 		else
   886 		else
   703 			{
   887 		{
   704 			TRAPD(err2, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeGTCUsernamePasswordDialog, m_dialog_data_ptr, aEapType));
   888 			m_dialog_data_ptr->iIsFirstQuery = EFalse;
   705 			if (err2)
   889 		}
   706 				{
   890 		
   707 					return EAP_STATUS_RETURN(m_am_tools, eap_status_authentication_failure);
   891 		EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::show_gtc_query_dialog - before m_notifier.Connect(), m_is_notifier_connected=%d\n"), m_is_notifier_connected));
   708 				}
   892 
   709 			}
   893 		if( !m_is_notifier_connected )
   710 		
   894 		{
   711 		}
   895 			TInt error = m_notifier.Connect();
       
   896 			
       
   897 			EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::show_gtc_query_dialog - m_notifier.Connect() returned error=%d\n"), error));
       
   898 			
       
   899 			if( error != KErrNone)
       
   900 			{
       
   901 				// Can not connect to notifier.
       
   902 				return EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(error));		
       
   903 			}
       
   904 			
       
   905 			m_is_notifier_connected = true; // Got connectted to notifier.
       
   906 		}
       
   907 
       
   908 		EAP_TRACE_DATA_DEBUG(
       
   909 			m_am_tools,
       
   910 			TRACE_FLAGS_DEFAULT,
       
   911 			(EAPL("eap_am_type_securid_symbian_c::show_gtc_query_dialog: m_message_buf"),
       
   912 			m_message_buf->Ptr(),
       
   913 			m_message_buf->Size()));
       
   914 
       
   915 		m_notifier.StartNotifierAndGetResponse(
       
   916 			iStatus, 
       
   917 			KEapGtcUserInputQueryUid, 
       
   918 			*m_message_buf, 
       
   919 			*m_dialog_data_pckg_ptr);
       
   920 
       
   921 		SetActive();
       
   922 	} 
   712 	else
   923 	else
   713 		{
   924 	{
   714 		EAP_TRACE_DEBUG(
   925 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c: Already active when tried to show GTC query dialog.\n")));
   715 			m_am_tools, 
   926 		return eap_status_process_general_error;
   716 			TRACE_FLAGS_DEFAULT,
   927 	}
   717 			(EAPL("eap_am_type_securid_symbian_c::show_gtc_query_dialog(): EHandlingTimerCall\n")));
   928 
   718 
   929 	return eap_status_pending_request;
   719 		if(m_partner->set_timer(this,EHandlingTimerCall, 0 /*data*/, 2 /*time ms*/) != eap_status_ok)
       
   720 			status = eap_status_process_general_error;	
       
   721 		}
       
   722 
       
   723 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   724 }
   930 }
   725 
   931 
   726 //--------------------------------------------------
   932 //--------------------------------------------------
   727 
   933 
   728 eap_status_e eap_am_type_securid_symbian_c::show_pincode_query_dialog(
   934 eap_status_e eap_am_type_securid_symbian_c::show_pincode_query_dialog(
   730 	eap_variable_data_c * const /*pincode*/,
   936 	eap_variable_data_c * const /*pincode*/,
   731 	bool is_first_query)
   937 	bool is_first_query)
   732 {
   938 {
   733 	EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::_pincode_query_dialog - start - is_first_query=%d\n"), is_first_query));
   939 	EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::_pincode_query_dialog - start - is_first_query=%d\n"), is_first_query));
   734 	
   940 	
   735 	eap_status_e status = eap_status_pending_request;
   941 	if (!IsActive())
   736 	
   942 	{
   737 	TEapExpandedType aEapType(*EapExpandedTypeGtc.GetType());
   943 		m_state = EHandlingPincodeQuery;
   738 	
   944 
   739 	m_state = EHandlingPincodeQuery;
   945 		if (is_first_query == true)
   740 
   946 		{
   741 	TInt err1 = KErrNone;
   947 			m_dialog_data_ptr->iIsFirstQuery = ETrue;
   742 	
   948 		}
   743 	TRAPD(err, err1 = IsDlgReadyToCompleteL());
       
   744 	
       
   745 	EAP_TRACE_DEBUG(
       
   746 		m_am_tools, 
       
   747 		TRACE_FLAGS_DEFAULT,
       
   748 		(EAPL("eap_am_type_securid_symbian_c::show_pincode_query_dialog(): err=%d, result= %d is_first_query=%d\n"),
       
   749 		err,
       
   750 		err1,
       
   751 		is_first_query));
       
   752 
       
   753 	if ((err1 == KErrCancel) || err)
       
   754 		{
       
   755 
       
   756 	    if (iEapAuthNotifier == 0)
       
   757 	    	{
       
   758 		    TRAPD(err, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
       
   759 		  	if (err)
       
   760 		  		{
       
   761 	  			return EAP_STATUS_RETURN(m_am_tools, eap_status_authentication_failure);
       
   762 	  			}
       
   763 	    	}
       
   764 
       
   765 		if (is_first_query != true)
       
   766 			{
       
   767 			TRAPD(err1, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeGtcChallengeDialog, m_dialog_data_ptr, aEapType));
       
   768 			if (err1)
       
   769 		  		{
       
   770 		  		return EAP_STATUS_RETURN(m_am_tools, eap_status_authentication_failure);
       
   771 		  		}
       
   772 			}
       
   773 		else
   949 		else
   774 			{
   950 		{
   775 			TRAPD(err2, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeGTCQueryDialog, m_dialog_data_ptr, aEapType));
   951 			m_dialog_data_ptr->iIsFirstQuery = EFalse;
   776 			if (err2)
   952 		}
   777 		  		{
   953 
   778 		  		return EAP_STATUS_RETURN(m_am_tools, eap_status_authentication_failure);
   954 		if( !m_is_notifier_connected )
   779 		  		}
   955 		{
   780 			}
   956 			TInt error = m_notifier.Connect();
   781 
   957 			
   782 		}
   958 			EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::show_pincode_query_dialog - m_notifier.Connect() returned error=%d\n"), error));
       
   959 			
       
   960 			if( error != KErrNone)
       
   961 			{
       
   962 				// Can not connect to notifier.
       
   963 				return EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(error));		
       
   964 			}
       
   965 			
       
   966 			m_is_notifier_connected = true; // Got connectted to notifier.
       
   967 		}
       
   968 
       
   969 		EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::show_pincode_query_dialog - StartNotifierAndGetResponse - KEapSecurIDPincodeQueryUid \n")));
       
   970 
       
   971 		m_notifier.StartNotifierAndGetResponse(
       
   972 			iStatus, 
       
   973 			KEapSecurIDPincodeQueryUid, 
       
   974 			*m_dialog_data_pckg_ptr, 
       
   975 			*m_dialog_data_pckg_ptr);
       
   976 
       
   977 		SetActive();
       
   978 	} 
   783 	else
   979 	else
   784 		{
   980 	{
   785 		if(m_partner->set_timer(this,EHandlingTimerCall, 0 /*data*/, 2 /*time ms*/) != eap_status_ok)
   981 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c: Already active when tried to show identity query dialog.\n")));
   786 			status = eap_status_process_general_error;	
   982 		return eap_status_process_general_error;
   787 		}
   983 	}
   788 
   984 
   789 
   985 	return eap_status_pending_request;
   790 
       
   791 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   792 }
       
   793 
       
   794 //--------------------------------------------------
       
   795 
       
   796 TInt eap_am_type_securid_symbian_c::IsDlgReadyToCompleteL()
       
   797 	{
       
   798 
       
   799 	EAP_TRACE_DEBUG(
       
   800 		m_am_tools, 
       
   801 		TRACE_FLAGS_DEFAULT,
       
   802 		(EAPL("eap_am_type_securid_symbian_c::IsDlgReadyToCompleteL(): m_index_type=%d, m_index=%d, m_tunneling_type=0xfe%06x%08x\n"),
       
   803 		m_index_type,
       
   804 		m_index,
       
   805 		m_tunneling_type.get_vendor_id(),
       
   806 		m_tunneling_type.get_vendor_type()));
       
   807 
       
   808 	TInt status = KErrNone;
       
   809 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
       
   810 	TPtr sqlStatement = buf->Des();
       
   811 	
       
   812 	// Query all the relevant parameters
       
   813 	_LIT(KSQLQuery, "SELECT %S, %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
       
   814 	
       
   815 	sqlStatement.Format(
       
   816 		KSQLQuery,
       
   817 		&cf_str_EAP_GTC_passcode_prompt_literal,
       
   818 		&cf_str_EAP_GTC_identity_literal,
       
   819 		&cf_str_EAP_GTC_passcode_literal,
       
   820 		&KGtcTableName,
       
   821 		&KServiceType,
       
   822 		m_index_type, 
       
   823 		&KServiceIndex,
       
   824 		m_index,
       
   825 		&KTunnelingTypeVendorId,
       
   826 		m_tunneling_type.get_vendor_id(),
       
   827 		&KTunnelingType, 
       
   828 		m_tunneling_type.get_vendor_type());
       
   829 	
       
   830 
       
   831 	EAP_TRACE_DEBUG(
       
   832 		m_am_tools, 
       
   833 		TRACE_FLAGS_DEFAULT,
       
   834 		(EAPL("eap_am_type_securid_symbian_c::IsDlgReadyToCompleteL(): Reads database\n")));
       
   835 
       
   836 	RDbView view;
       
   837 	// Evaluate view
       
   838 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));
       
   839 	CleanupClosePushL(view);
       
   840 	
       
   841 	User::LeaveIfError(view.EvaluateAll());
       
   842 	
       
   843 	// Get the first (and only) row
       
   844 	view.FirstL();
       
   845 	view.GetL();
       
   846 	
       
   847 	// Get column set so we get the correct column numbers
       
   848 	CDbColSet* colSet = view.ColSetL();
       
   849 	CleanupStack::PushL(colSet);
       
   850 
       
   851 	EAP_TRACE_DEBUG(
       
   852 		m_am_tools, 
       
   853 		TRACE_FLAGS_DEFAULT,
       
   854 		(EAPL("eap_am_type_securid_symbian_c::IsDlgReadyToCompleteL(): Reads database\n")));
       
   855 
       
   856 	TPtrC username = view.ColDes(colSet->ColNo( cf_str_EAP_GTC_identity_literal ) );
       
   857 
       
   858 	EAP_TRACE_DATA_DEBUG(
       
   859 		m_am_tools,
       
   860 		TRACE_FLAGS_DEFAULT,
       
   861 		(EAPL("eap_am_type_securid_symbian_c::IsDlgReadyToCompleteL(): username"),
       
   862 		username.Ptr(),
       
   863 		username.Size()));
       
   864 
       
   865 	TPtrC password = view.ColDes(colSet->ColNo( cf_str_EAP_GTC_passcode_literal ) );
       
   866 
       
   867 	EAP_TRACE_DATA_DEBUG(
       
   868 		m_am_tools,
       
   869 		TRACE_FLAGS_DEFAULT,
       
   870 		(EAPL("eap_am_type_securid_symbian_c::IsDlgReadyToCompleteL(): password"),
       
   871 		password.Ptr(),
       
   872 		password.Size()));
       
   873 
       
   874 	TUint prompt = view.ColUint(colSet->ColNo(cf_str_EAP_GTC_passcode_prompt_literal));
       
   875 
       
   876 	EAP_TRACE_DEBUG(
       
   877 		m_am_tools, 
       
   878 		TRACE_FLAGS_DEFAULT,
       
   879 		(EAPL("eap_am_type_securid_symbian_c::IsDlgReadyToCompleteL(): prompt=%d\n"),
       
   880 		prompt));
       
   881 
       
   882 
       
   883 	if ((EEapDbFalse != prompt)
       
   884 		 || (username.Size() == 0) 
       
   885 		 || (password.Size() == 0))
       
   886 		{
       
   887 
       
   888 		if (username.Size() == 0)
       
   889 			{
       
   890 			m_dialog_data_ptr->iUsername.Zero();
       
   891 			}
       
   892 		else
       
   893 			{
       
   894 			m_dialog_data_ptr->iUsername.Copy(username);
       
   895 			}
       
   896 
       
   897 		status = KErrCancel;
       
   898 		}
       
   899 	else
       
   900 		{
       
   901 		status = KErrNone;	
       
   902 		m_dialog_data_ptr->iUsername.Copy(username);
       
   903 		m_dialog_data_ptr->iPassword.Copy(password);
       
   904 		}
       
   905 		
       
   906 	CleanupStack::PopAndDestroy(colSet); // Delete colSet.
       
   907 	CleanupStack::PopAndDestroy(&view); // Close view.
       
   908 	CleanupStack::PopAndDestroy(buf); // Delete buf.
       
   909 		
       
   910 	EAP_TRACE_DEBUG(
       
   911 		m_am_tools, 
       
   912 		TRACE_FLAGS_DEFAULT,
       
   913 		(EAPL("eap_am_type_securid_symbian_c::IsDlgReadyToCompleteL(): status=%d\n"),
       
   914 		status));
       
   915 
       
   916 	return status;
       
   917 	}
       
   918 	
       
   919 EAP_FUNC_EXPORT eap_status_e eap_am_type_securid_symbian_c::timer_expired(
       
   920 		const u32_t id , void * data)
       
   921 	{
       
   922 	EAP_UNREFERENCED_PARAMETER(id); // in release
       
   923 	EAP_UNREFERENCED_PARAMETER(data); // in release
       
   924 	
       
   925 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("TIMER: [0x%08x]->eap_am_type_securid_symbian_c::timer_expired(id 0x%02x, data 0x%08x).\n"),
       
   926 		this, id, data));
       
   927 	
       
   928 	DlgComplete(KErrNone);
       
   929 	return eap_status_ok;	
       
   930 	}
       
   931 
       
   932 EAP_FUNC_EXPORT eap_status_e eap_am_type_securid_symbian_c::timer_delete_data(
       
   933 		const u32_t id, void *data)
       
   934 	{
       
   935 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   936 	EAP_UNREFERENCED_PARAMETER(id); // in release
       
   937 	EAP_UNREFERENCED_PARAMETER(data); // in release
       
   938 
       
   939 	eap_status_e status = eap_status_ok;
       
   940 
       
   941 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("TIMER: [0x%08x]->eap_am_type_securid_symbian_c::timer_delete_data(id 0x%02x, data 0x%08x).\n"),
       
   942 		this, id, data));
       
   943 
       
   944 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
   945 	return EAP_STATUS_RETURN(m_am_tools, status);
       
   946 			
       
   947 	}
       
   948 
       
   949 //--------------------------------------------------
       
   950 
       
   951 EAP_FUNC_EXPORT void eap_am_type_securid_symbian_c::DlgComplete( TInt aStatus )  
       
   952 {
       
   953 	EAP_TRACE_DEBUG(
       
   954 		m_am_tools, 
       
   955 		TRACE_FLAGS_DEFAULT,
       
   956 		(EAPL("eap_am_type_securid_symbian_c::DlgComplete(): m_index_type=%d, m_index=%d, m_tunneling_type=0xfe%06x%08x\n"),
       
   957 		m_index_type,
       
   958 		m_index,
       
   959 		m_tunneling_type.get_vendor_id(),
       
   960 		m_tunneling_type.get_vendor_type()));
       
   961 
       
   962 	if (aStatus == KErrCancel)
       
   963 	{
       
   964 		delete m_message_buf;
       
   965 		m_message_buf = NULL;
       
   966 		get_am_partner()->finish_unsuccessful_authentication(true);
       
   967 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
   968 		return;
       
   969 	}
       
   970 	
       
   971 	if (aStatus != KErrNone)
       
   972 	{
       
   973 		delete m_message_buf;
       
   974 		m_message_buf = NULL;
       
   975 		// Something is very wrong...
       
   976 
       
   977 		EAP_TRACE_ERROR(
       
   978 			m_am_tools,
       
   979 			TRACE_FLAGS_DEFAULT,
       
   980 			(EAPL("ERROR: EAP - SecurID notifier or dialog\n")));
       
   981 
       
   982 		send_error_notification(eap_status_authentication_failure);
       
   983 
       
   984 		get_am_partner()->finish_unsuccessful_authentication(false);
       
   985 
       
   986 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
   987 		return;
       
   988 	}
       
   989 
       
   990 	switch (m_state)
       
   991 	{
       
   992 	case EHandlingIdentityQuery:
       
   993 		{
       
   994 			EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::DlgComplete(): EHandlingIdentityQuery\n")));
       
   995 
       
   996 			eap_variable_data_c identity(m_am_tools);
       
   997 
       
   998 			eap_status_e status = identity.set_copy_of_buffer(
       
   999 				m_dialog_data_ptr->iUsername.Ptr(),
       
  1000 				m_dialog_data_ptr->iUsername.Size());
       
  1001 			if (status != eap_status_ok)
       
  1002 			{
       
  1003 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
  1004 				(void)EAP_STATUS_RETURN(m_am_tools, status);
       
  1005 				return;
       
  1006 			}
       
  1007 
       
  1008 			eap_variable_data_c identity_utf8(m_am_tools);
       
  1009 			status = m_am_tools->convert_unicode_to_utf8(identity_utf8, identity);
       
  1010 			if (status != eap_status_ok)
       
  1011 			{
       
  1012 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
  1013 				(void)EAP_STATUS_RETURN(m_am_tools, status);
       
  1014 				return;
       
  1015 			}
       
  1016 
       
  1017 			status = get_am_partner()->complete_eap_identity_query(&identity_utf8);
       
  1018 		}
       
  1019 		break;
       
  1020 
       
  1021 	case EHandlingPasscodeQuery:
       
  1022 		{
       
  1023 			EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::DlgComplete(): EHandlingPasscodeQuery\n")));
       
  1024 
       
  1025 			eap_variable_data_c passcode(m_am_tools);
       
  1026 
       
  1027 			eap_status_e status = passcode.set_copy_of_buffer(
       
  1028 				m_dialog_data_ptr->iPassword.Ptr(),
       
  1029 				m_dialog_data_ptr->iPassword.Size());
       
  1030 			if (status != eap_status_ok)
       
  1031 			{
       
  1032 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
  1033 				(void)EAP_STATUS_RETURN(m_am_tools, status);
       
  1034 				return;
       
  1035 			}
       
  1036 
       
  1037 			eap_variable_data_c passcode_utf8(m_am_tools);
       
  1038 			status = m_am_tools->convert_unicode_to_utf8(passcode_utf8, passcode);
       
  1039 			if (status != eap_status_ok)
       
  1040 			{
       
  1041 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
  1042 				(void)EAP_STATUS_RETURN(m_am_tools, status);
       
  1043 				return;
       
  1044 			}
       
  1045 
       
  1046 			status = get_am_partner()->client_securid_complete_passcode_query(&passcode_utf8);
       
  1047 		}
       
  1048 		break;
       
  1049 
       
  1050 	case EHandlingPincodeQuery:
       
  1051 		{
       
  1052 			EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::DlgComplete(): EHandlingPincodeQuery\n")));
       
  1053 
       
  1054 			eap_variable_data_c pincode(m_am_tools);
       
  1055 
       
  1056 			eap_status_e status = pincode.set_copy_of_buffer(
       
  1057 				m_dialog_data_ptr->iUsername.Ptr(),
       
  1058 				m_dialog_data_ptr->iUsername.Size());
       
  1059 			if (status != eap_status_ok)
       
  1060 			{
       
  1061 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
  1062 				(void)EAP_STATUS_RETURN(m_am_tools, status);
       
  1063 				return;
       
  1064 			}
       
  1065 
       
  1066 			eap_variable_data_c passcode(m_am_tools);
       
  1067 
       
  1068 			status = passcode.set_copy_of_buffer(
       
  1069 				m_dialog_data_ptr->iPassword.Ptr(),
       
  1070 				m_dialog_data_ptr->iPassword.Size());
       
  1071 			if (status != eap_status_ok)
       
  1072 			{
       
  1073 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
  1074 				(void)EAP_STATUS_RETURN(m_am_tools, status);
       
  1075 				return;
       
  1076 			}
       
  1077 
       
  1078 
       
  1079 			eap_variable_data_c pincode_utf8(m_am_tools);
       
  1080 			status = m_am_tools->convert_unicode_to_utf8(pincode_utf8, pincode);
       
  1081 			if (status != eap_status_ok)
       
  1082 			{
       
  1083 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
  1084 				(void)EAP_STATUS_RETURN(m_am_tools, status);
       
  1085 				return;
       
  1086 			}
       
  1087 
       
  1088 			eap_variable_data_c passcode_utf8(m_am_tools);
       
  1089 			status = m_am_tools->convert_unicode_to_utf8(passcode_utf8, passcode);
       
  1090 			if (status != eap_status_ok)
       
  1091 			{
       
  1092 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
  1093 				(void)EAP_STATUS_RETURN(m_am_tools, status);
       
  1094 				return;
       
  1095 			}
       
  1096 
       
  1097 			status = get_am_partner()->client_securid_complete_pincode_query(&passcode_utf8, &passcode_utf8);
       
  1098 		}
       
  1099 		break;
       
  1100 
       
  1101 	case EHandlingGTCQuery:
       
  1102 		{
       
  1103 			EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::DlgComplete(): EHandlingGTCQuery\n")));
       
  1104 
       
  1105 			delete m_message_buf;
       
  1106 			m_message_buf = NULL;
       
  1107 
       
  1108 			eap_variable_data_c passcode(m_am_tools);
       
  1109 
       
  1110 			eap_status_e status = passcode.set_copy_of_buffer(
       
  1111 				m_dialog_data_ptr->iPassword.Ptr(),
       
  1112 				m_dialog_data_ptr->iPassword.Size());
       
  1113 			if (status != eap_status_ok)
       
  1114 			{
       
  1115 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
  1116 				(void)EAP_STATUS_RETURN(m_am_tools, status);
       
  1117 				return;
       
  1118 			}
       
  1119 
       
  1120 			eap_variable_data_c passcode_utf8(m_am_tools);
       
  1121 			status = m_am_tools->convert_unicode_to_utf8(passcode_utf8, passcode);
       
  1122 			if (status != eap_status_ok)
       
  1123 			{
       
  1124 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
  1125 				(void)EAP_STATUS_RETURN(m_am_tools, status);
       
  1126 				return;
       
  1127 			}
       
  1128 			
       
  1129 			// User must have entered some password and pressed OK.
       
  1130 			// Treat this as a full authentication and update the Last Auth Time.
       
  1131 			status = store_authentication_time();
       
  1132 			if (status != eap_status_ok)
       
  1133 			{
       
  1134 				// Storing failed. Don't care.
       
  1135 				EAP_TRACE_ERROR(m_am_tools, 
       
  1136 					TRACE_FLAGS_DEFAULT, (
       
  1137 					EAPL("eap_am_type_securid_symbian_c:Storing Last Full Authentication time failed, status=%d, but continuing\n"), 
       
  1138 					status));
       
  1139 
       
  1140 				status = eap_status_ok;
       
  1141 			}			
       
  1142 
       
  1143 			status = get_am_partner()->client_gtc_complete_user_input_query(&passcode_utf8);
       
  1144 		}
       
  1145 		break;
       
  1146 
       
  1147 	default:
       
  1148 		EAP_TRACE_ERROR(
       
  1149 			m_am_tools,
       
  1150 			TRACE_FLAGS_DEFAULT,
       
  1151 			(EAPL("ERROR: EAP - SecurID illegal state in DlgComplete().\n")));
       
  1152 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
       
  1153 		return;		
       
  1154 	}
       
  1155 }
   986 }
  1156 
   987 
  1157 //--------------------------------------------------
   988 //--------------------------------------------------
  1158 
   989 
  1159 EAP_FUNC_EXPORT eap_status_e eap_am_type_securid_symbian_c::read_auth_failure_string(
   990 EAP_FUNC_EXPORT eap_status_e eap_am_type_securid_symbian_c::read_auth_failure_string(
  1222 	{
  1053 	{
  1223 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1054 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1224 		return EAP_STATUS_RETURN(m_am_tools, status);
  1055 		return EAP_STATUS_RETURN(m_am_tools, status);
  1225 	}
  1056 	}
  1226 
  1057 
  1227 	{
  1058 	status = memory_store_key->add_data(
  1228 		u32_t vendor_id = m_tunneling_type.get_vendor_id();
  1059 		&m_tunneling_vendor_type,
  1229 
  1060 		sizeof(m_tunneling_vendor_type));
  1230 		status = memory_store_key->add_data(
  1061 	if (status != eap_status_ok)
  1231 			&vendor_id,
  1062 	{
  1232 			sizeof(vendor_id));
  1063 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1233 		if (status != eap_status_ok)
  1064 		return EAP_STATUS_RETURN(m_am_tools, status);
  1234 		{
       
  1235 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1236 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1237 		}
       
  1238 	}
       
  1239 
       
  1240 	{
       
  1241 		u32_t vendor_type = m_tunneling_type.get_vendor_type();
       
  1242 		status = memory_store_key->add_data(
       
  1243 			&vendor_type,
       
  1244 			sizeof(vendor_type));
       
  1245 		if (status != eap_status_ok)
       
  1246 		{
       
  1247 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  1248 			return EAP_STATUS_RETURN(m_am_tools, status);
       
  1249 		}
       
  1250 	}
  1065 	}
  1251 
  1066 
  1252 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1067 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  1253 	return EAP_STATUS_RETURN(m_am_tools, status);
  1068 	return EAP_STATUS_RETURN(m_am_tools, status);
  1254 }
  1069 }
  1263 	
  1078 	
  1264 	TRAPD(err, sessionValidity = is_session_validL());
  1079 	TRAPD(err, sessionValidity = is_session_validL());
  1265 	if (err != KErrNone) 
  1080 	if (err != KErrNone) 
  1266 	{
  1081 	{
  1267 		EAP_TRACE_ERROR(m_am_tools, 
  1082 		EAP_TRACE_ERROR(m_am_tools, 
  1268 			TRACE_FLAGS_DEFAULT,
  1083 			TRACE_FLAGS_DEFAULT, (
  1269 			(EAPL("eap_am_type_securid_symbian_c::is_session_valid(): LEAVE - error=%d, Assuming session is invalid \n"),
  1084 			EAPL("eap_am_type_securid_symbian_c::is_session_valid - LEAVE - error=%d, Assuming session is invalid \n"),
  1270 			err));
  1085 			err));
  1271 			
  1086 			
  1272 		sessionValidity = false;
  1087 		sessionValidity = false;
  1273 	}
  1088 	}
  1274 	 		
  1089 	 		
  1281 
  1096 
  1282 bool eap_am_type_securid_symbian_c::is_session_validL()
  1097 bool eap_am_type_securid_symbian_c::is_session_validL()
  1283 {
  1098 {
  1284 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  1099 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  1285 
  1100 
  1286 	EAP_TRACE_DEBUG(
  1101 	EAP_TRACE_DEBUG(m_am_tools, 
  1287 		m_am_tools, 
  1102 		TRACE_FLAGS_DEFAULT, (
  1288 		TRACE_FLAGS_DEFAULT,
  1103 		EAPL("eap_am_type_securid_symbian_c::is_session_valid: EAP vendor type=%d\n"),
  1289 		(EAPL("eap_am_type_securid_symbian_c::is_session_valid(): EAP-tunneling type=0xfe%06x%08x\n"),
  1104 		m_eap_vendor_type));
  1290 		m_tunneling_type.get_vendor_id(),
       
  1291 		m_tunneling_type.get_vendor_type()));
       
  1292 
  1105 
  1293 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  1106 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  1294 	TPtr sqlStatement = buf->Des();
  1107 	TPtr sqlStatement = buf->Des();
  1295 	
  1108 	
  1296 	// Query all the relevant parameters
  1109 	// Query all the relevant parameters
  1297 	_LIT(KSQLQuery, "SELECT %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
  1110 	_LIT(KSQLQuery, "SELECT %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d");
  1298 	
  1111 	
  1299 	if (m_eap_type == eap_type_generic_token_card)
  1112 	if (m_eap_type == eap_type_generic_token_card)
  1300 	{
  1113 	{
  1301 		sqlStatement.Format(
  1114 		sqlStatement.Format(KSQLQuery, &cf_str_EAP_GTC_max_session_validity_time_literal,
  1302 			KSQLQuery,
  1115 							&KGTCLastFullAuthTime, &KGtcTableName,
  1303 			&cf_str_EAP_GTC_max_session_validity_time_literal,
  1116 							&KServiceType, m_index_type, 
  1304 			&KGTCLastFullAuthTime,
  1117 							&KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);
  1305 			&KGtcTableName,
       
  1306 			&KServiceType,
       
  1307 			m_index_type, 
       
  1308 			&KServiceIndex,
       
  1309 			m_index,
       
  1310 			&KTunnelingTypeVendorId,
       
  1311 			m_tunneling_type.get_vendor_id(),
       
  1312 			&KTunnelingType, 
       
  1313 			m_tunneling_type.get_vendor_type());
       
  1314 	}
  1118 	}
  1315 	else
  1119 	else
  1316 	{
  1120 	{
  1317 		// Secure ID is not supported at the moment.
  1121 		// Secure ID is not supported at the moment.
  1318 		// Treat this as session invalid.
  1122 		// Treat this as session invalid.
  1322 	}
  1126 	}
  1323 	
  1127 	
  1324 
  1128 
  1325 	RDbView view;
  1129 	RDbView view;
  1326 	// Evaluate view
  1130 	// Evaluate view
  1327 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  1131 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement)));
  1328 	CleanupClosePushL(view);
  1132 	CleanupClosePushL(view);
  1329 	
  1133 	
  1330 	User::LeaveIfError(view.EvaluateAll());
  1134 	User::LeaveIfError(view.EvaluateAll());
  1331 	
  1135 	
  1332 	// Get the first (and only) row
  1136 	// Get the first (and only) row
  1452 {
  1256 {
  1453 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  1257 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  1454 	
  1258 	
  1455 	EAP_TRACE_DEBUG(m_am_tools, 
  1259 	EAP_TRACE_DEBUG(m_am_tools, 
  1456 		TRACE_FLAGS_DEFAULT, (
  1260 		TRACE_FLAGS_DEFAULT, (
  1457 		EAPL("eap_am_type_securid_symbian_c::store_authentication_timeL: EAP-tunneling type=0xfe%06x%08x\n"),
  1261 		EAPL("eap_am_type_securid_symbian_c::store_authentication_timeL: EAP Vendor Type=%d\n"),
  1458 		m_tunneling_type.get_vendor_id(),
  1262 		m_eap_vendor_type));	
  1459 		m_tunneling_type.get_vendor_type()));	
       
  1460 
  1263 
  1461 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  1264 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  1462 	TPtr sqlStatement = buf->Des();
  1265 	TPtr sqlStatement = buf->Des();
  1463 	
  1266 	
  1464 	// Query all the relevant parameters
  1267 	// Query all the relevant parameters
  1465 	_LIT(KSQLQuery, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
  1268 	_LIT(KSQLQuery, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d");
  1466 	
  1269 	
  1467 	if (m_eap_type == eap_type_generic_token_card)
  1270 	if (m_eap_type == eap_type_generic_token_card)
  1468 	{
  1271 	{
  1469 		sqlStatement.Format(
  1272 		sqlStatement.Format(KSQLQuery, &KGTCLastFullAuthTime, &KGtcTableName,
  1470 			KSQLQuery,
  1273 							&KServiceType, m_index_type, 
  1471 			&KGTCLastFullAuthTime,
  1274 							&KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);
  1472 			&KGtcTableName,
       
  1473 			&KServiceType,
       
  1474 			m_index_type, 
       
  1475 			&KServiceIndex,
       
  1476 			m_index,
       
  1477 			&KTunnelingTypeVendorId,
       
  1478 			m_tunneling_type.get_vendor_id(),
       
  1479 			&KTunnelingType, 
       
  1480 			m_tunneling_type.get_vendor_type());
       
  1481 	}
  1275 	}
  1482 	else
  1276 	else
  1483 	{
  1277 	{
  1484 		// Secure ID is not supported at the moment.
  1278 		// Secure ID is not supported at the moment.
  1485 		// Leave with error.
  1279 		// Leave with error.
  1486 
  1280 
  1487 		CleanupStack::PopAndDestroy(buf); // Delete buf.
  1281 		CleanupStack::PopAndDestroy(buf); // Delete buf.
  1488 		User::Leave(KErrNotSupported);		
  1282 		User::Leave(KErrNotSupported);		
  1489 	}
  1283 	}
  1490 
  1284 		
  1491 	RDbView view;
  1285 	RDbView view;
  1492 	// Evaluate view
  1286 	// Evaluate view
  1493 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  1287 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  1494 	CleanupClosePushL(view);
  1288 	CleanupClosePushL(view);
  1495 	
  1289