eapol/eapol_framework/eapol_symbian/am/type/aka/symbian/eap_am_type_aka_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: 46.1.10 %
    19 * %version: 49 %
    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
    34 #include "eap_am_tools_symbian.h"
    34 #include "eap_am_tools_symbian.h"
    35 #include "eap_state_notification.h"
    35 #include "eap_state_notification.h"
    36 #include "EapAkaDbDefaults.h"
    36 #include "EapAkaDbDefaults.h"
    37 #include "EapAkaDbParameterNames.h"
    37 #include "EapAkaDbParameterNames.h"
    38 #include "EapAkaDbUtils.h"
    38 #include "EapAkaDbUtils.h"
    39 #include "EapTraceSymbian.h"
    39 #include "eap_am_trace_symbian.h"
    40 
    40 
    41 #include <d32dbms.h>	// For DBMS
    41 #include <d32dbms.h>	// For DBMS
    42 #include <s32strm.h> 	// For RReadStream
    42 #include <s32strm.h> 	// For RReadStream
    43 
    43 
    44 #if defined (USE_EAP_TYPE_SERVER_AKA)
    44 #if defined (USE_EAP_TYPE_SERVER_AKA)
   152 , m_AUTN(tools)
   152 , m_AUTN(tools)
   153 , m_max_session_time(0)
   153 , m_max_session_time(0)
   154 {
   154 {
   155 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   155 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   156 
   156 
       
   157 #ifdef USE_EAP_EXPANDED_TYPES
       
   158 
       
   159 	m_tunneling_vendor_type = m_tunneling_type.get_vendor_type();
       
   160 
       
   161 #else
       
   162 
       
   163 	m_tunneling_vendor_type = static_cast<TUint>(m_tunneling_type);
       
   164 
       
   165 #endif //#ifdef USE_EAP_EXPANDED_TYPES
       
   166 
   157 	if (receive_network_id != 0
   167 	if (receive_network_id != 0
   158 		&& receive_network_id->get_is_valid_data() == true)
   168 		&& receive_network_id->get_is_valid_data() == true)
   159 	{
   169 	{
   160 		eap_status_e status = m_receive_network_id.set_copy_of_network_id(
   170 		eap_status_e status = m_receive_network_id.set_copy_of_network_id(
   161 			receive_network_id);
   171 			receive_network_id);
   193 		m_aka_algorithm = 0;
   203 		m_aka_algorithm = 0;
   194 		return;
   204 		return;
   195 	}
   205 	}
   196 #endif // #if defined (USE_EAP_TYPE_SERVER_AKA)	
   206 #endif // #if defined (USE_EAP_TYPE_SERVER_AKA)	
   197 
   207 
   198 	TInt error = m_session.Connect();
       
   199 	EAP_TRACE_DEBUG_SYMBIAN((_L("eap_am_type_aka_symbian_c::ConstructL(): - m_session.Connect(), error=%d\n"), error));
       
   200 	User::LeaveIfError(error);
       
   201 
       
   202 	// Open/create database
   208 	// Open/create database
   203 	EapAkaDbUtils::OpenDatabaseL(m_database, m_session, m_index_type, m_index, m_tunneling_type);	
   209 	EapAkaDbUtils::OpenDatabaseL(m_database, m_session, m_index_type, m_index, m_tunneling_type);	
   204 		
   210 		
   205 	// SIM IMSI, RES, CK, IK and AUTS are queried from SIM using AKA interface. 
   211 	// SIM IMSI, RES, CK, IK and AUTS are queried from SIM using AKA interface. 
   206 	// If this is not used then Nokia test algorithms and test values are used.
   212 	// If this is not used then Nokia test algorithms and test values are used.
   217 #endif //#if defined (USE_EAP_AKA_INTERFACE)	&& !defined(__WINS__)
   223 #endif //#if defined (USE_EAP_AKA_INTERFACE)	&& !defined(__WINS__)
   218 }
   224 }
   219 
   225 
   220 //--------------------------------------------------
   226 //--------------------------------------------------
   221 
   227 
   222 EAP_FUNC_EXPORT eap_am_type_aka_symbian_c* eap_am_type_aka_symbian_c::NewL(
   228 eap_am_type_aka_symbian_c* eap_am_type_aka_symbian_c::NewL(
   223 	abs_eap_am_tools_c * const aTools,
   229 	abs_eap_am_tools_c * const aTools,
   224 	abs_eap_base_type_c * const aPartner,
   230 	abs_eap_base_type_c * const aPartner,
   225 	const TIndexType aIndexType,
   231 	const TIndexType aIndexType,
   226 	const TInt aIndex,
   232 	const TInt aIndex,
   227 	const eap_type_value_e aTunnelingType,
   233 	const eap_type_value_e aTunnelingType,
   306 
   312 
   307 	{
   313 	{
   308 		// Read Maximum Session Validity Time from the config file
   314 		// Read Maximum Session Validity Time from the config file
   309 		eap_variable_data_c sessionTimeFromFile(m_am_tools);
   315 		eap_variable_data_c sessionTimeFromFile(m_am_tools);
   310 		
   316 		
   311 		eap_status_e status = type_configure_read(
   317 		eap_status_e status = m_partner->read_configure(
   312 			cf_str_EAP_AKA_max_session_validity_time.get_field(),
   318 			cf_str_EAP_AKA_max_session_validity_time.get_field(),
   313 			&sessionTimeFromFile);
   319 			&sessionTimeFromFile);
   314 		
   320 		
   315 		if (status == eap_status_ok
   321 		if (status == eap_status_ok
   316 			&& sessionTimeFromFile.get_is_valid_data() == true
   322 			&& sessionTimeFromFile.get_is_valid_data() == true
   329 #if defined (USE_EAP_TYPE_SERVER_AKA)
   335 #if defined (USE_EAP_TYPE_SERVER_AKA)
   330 
   336 
   331 	// We have to set the values for K, OP and AMF in simulator.
   337 	// We have to set the values for K, OP and AMF in simulator.
   332 	
   338 	
   333 	{
   339 	{
   334 		eap_status_e status = type_configure_read(
   340 		eap_status_e status = m_partner->read_configure(
   335 			cf_str_EAP_AKA_simulator_aka_k.get_field(),
   341 			cf_str_EAP_AKA_simulator_aka_k.get_field(),
   336 			&m_simulator_aka_K);
   342 			&m_simulator_aka_K);
   337 		if (status == eap_status_ok
   343 		if (status == eap_status_ok
   338 			&& m_simulator_aka_K.get_is_valid_data() == true
   344 			&& m_simulator_aka_K.get_is_valid_data() == true
   339 			&& m_simulator_aka_K.get_data_length() > 0ul
   345 			&& m_simulator_aka_K.get_data_length() > 0ul
   358 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_field);
   364 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_field);
   359 		}
   365 		}
   360 	}
   366 	}
   361 
   367 
   362 	{
   368 	{
   363 		eap_status_e status = type_configure_read(
   369 		eap_status_e status = m_partner->read_configure(
   364 			cf_str_EAP_AKA_simulator_aka_op.get_field(),
   370 			cf_str_EAP_AKA_simulator_aka_op.get_field(),
   365 			&m_simulator_aka_OP);
   371 			&m_simulator_aka_OP);
   366 		if (status == eap_status_ok
   372 		if (status == eap_status_ok
   367 			&& m_simulator_aka_OP.get_is_valid_data() == true
   373 			&& m_simulator_aka_OP.get_is_valid_data() == true
   368 			&& m_simulator_aka_OP.get_data_length() > 0ul
   374 			&& m_simulator_aka_OP.get_data_length() > 0ul
   387 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_field);
   393 			return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_field);
   388 		}
   394 		}
   389 	}
   395 	}
   390 
   396 
   391 	{
   397 	{
   392 		eap_status_e status = type_configure_read(
   398 		eap_status_e status = m_partner->read_configure(
   393 			cf_str_EAP_AKA_simulator_aka_amf.get_field(),
   399 			cf_str_EAP_AKA_simulator_aka_amf.get_field(),
   394 			&m_simulator_aka_AMF);
   400 			&m_simulator_aka_AMF);
   395 		if (status == eap_status_ok
   401 		if (status == eap_status_ok
   396 			&& m_simulator_aka_AMF.get_is_valid_data() == true
   402 			&& m_simulator_aka_AMF.get_is_valid_data() == true
   397 			&& m_simulator_aka_AMF.get_data_length() == sizeof(u16_t)
   403 			&& m_simulator_aka_AMF.get_data_length() == sizeof(u16_t)
   574 
   580 
   575 	// Form the insertion command
   581 	// Form the insertion command
   576 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
   582 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
   577 	TPtr sqlStatement = buf->Des();
   583 	TPtr sqlStatement = buf->Des();
   578 
   584 
   579 	_LIT(KSQLInsert, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
   585 	_LIT(KSQLInsert, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d");
   580 	sqlStatement.Format(
   586 	sqlStatement.Format(KSQLInsert, &KPseudonymId, &KAkaTableName, 
   581 		KSQLInsert,
   587 		&KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);
   582 		&KPseudonymId,
       
   583 		&KAkaTableName, 
       
   584 		&KServiceType,
       
   585 		m_index_type,
       
   586 		&KServiceIndex,
       
   587 		m_index,
       
   588 		&KTunnelingTypeVendorId,
       
   589 		m_tunneling_type.get_vendor_id(),
       
   590 		&KTunnelingType, 
       
   591 		m_tunneling_type.get_vendor_type());
       
   592 
   588 
   593 	// Evaluate view
   589 	// Evaluate view
   594 	RDbView view;
   590 	RDbView view;
   595 	User::LeaveIfError(view.Prepare(m_database,TDbQuery(sqlStatement), TDbWindow::EUnlimited));
   591 	User::LeaveIfError(view.Prepare(m_database,TDbQuery(sqlStatement), TDbWindow::EUnlimited));
   596 	CleanupClosePushL(view);
   592 	CleanupClosePushL(view);
   686 
   682 
   687 	// Form the insertion command
   683 	// Form the insertion command
   688 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
   684 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
   689 	TPtr sqlStatement = buf->Des();
   685 	TPtr sqlStatement = buf->Des();
   690 
   686 
   691 	_LIT(KSQLInsert, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
   687 	_LIT(KSQLInsert, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d");
   692 	sqlStatement.Format(
   688 	sqlStatement.Format(KSQLInsert, &KReauthId, &KAkaTableName, 
   693 		KSQLInsert,
   689 		&KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);
   694 		&KReauthId,
       
   695 		&KAkaTableName, 
       
   696 		&KServiceType,
       
   697 		m_index_type,
       
   698 		&KServiceIndex,
       
   699 		m_index,
       
   700 		&KTunnelingTypeVendorId,
       
   701 		m_tunneling_type.get_vendor_id(),
       
   702 		&KTunnelingType, 
       
   703 		m_tunneling_type.get_vendor_type());
       
   704 		
   690 		
   705 	// Evaluate view
   691 	// Evaluate view
   706 	RDbView view;
   692 	RDbView view;
   707 	User::LeaveIfError(view.Prepare(m_database,TDbQuery(sqlStatement), TDbWindow::EUnlimited));
   693 	User::LeaveIfError(view.Prepare(m_database,TDbQuery(sqlStatement), TDbWindow::EUnlimited));
   708 	CleanupClosePushL(view);
   694 	CleanupClosePushL(view);
   824 
   810 
   825 	// Form the insertion command
   811 	// Form the insertion command
   826 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
   812 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
   827 	TPtr sqlStatement = buf->Des();
   813 	TPtr sqlStatement = buf->Des();
   828 
   814 
   829 	_LIT(KSQLInsert, "SELECT %S, %S, %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
   815 	_LIT(KSQLInsert, "SELECT %S, %S, %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d");
   830 	sqlStatement.Format(
   816 	sqlStatement.Format(KSQLInsert, &KXKey, &KK_aut, &KK_encr, &KReauthCounter, &KAkaTableName, 
   831 		KSQLInsert,
   817 		&KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);
   832 		&KXKey,
       
   833 		&KK_aut,
       
   834 		&KK_encr,
       
   835 		&KReauthCounter,
       
   836 		&KAkaTableName, 
       
   837 		&KServiceType,
       
   838 		m_index_type,
       
   839 		&KServiceIndex,
       
   840 		m_index,
       
   841 		&KTunnelingTypeVendorId,
       
   842 		m_tunneling_type.get_vendor_id(),
       
   843 		&KTunnelingType, 
       
   844 		m_tunneling_type.get_vendor_type());
       
   845 		
   818 		
   846 	// Evaluate view
   819 	// Evaluate view
   847 	RDbView view;
   820 	RDbView view;
   848 	User::LeaveIfError(view.Prepare(m_database,TDbQuery(sqlStatement), TDbWindow::EUnlimited));
   821 	User::LeaveIfError(view.Prepare(m_database,TDbQuery(sqlStatement), TDbWindow::EUnlimited));
   849 	CleanupClosePushL(view);
   822 	CleanupClosePushL(view);
   978 
   951 
   979 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
   952 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
   980 	TPtr sqlStatement = buf->Des();
   953 	TPtr sqlStatement = buf->Des();
   981 
   954 
   982 	// Form the query
   955 	// Form the query
   983 	_LIT(KSQLQuery, "SELECT %S, %S, %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
   956 	_LIT(KSQLQuery, "SELECT %S, %S, %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d");
   984 	sqlStatement.Format(
   957 	sqlStatement.Format(KSQLQuery, &KXKey, &KK_aut, &KK_encr, &KReauthCounter, &KAkaTableName, 
   985 		KSQLQuery,
   958 		&KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);
   986 		&KXKey,
       
   987 		&KK_aut,
       
   988 		&KK_encr,
       
   989 		&KReauthCounter,
       
   990 		&KAkaTableName, 
       
   991 		&KServiceType,
       
   992 		m_index_type,
       
   993 		&KServiceIndex,
       
   994 		m_index,
       
   995 		&KTunnelingTypeVendorId,
       
   996 		m_tunneling_type.get_vendor_id(),
       
   997 		&KTunnelingType, 
       
   998 		m_tunneling_type.get_vendor_type());
       
   999 		
   959 		
  1000 	RDbView view;
   960 	RDbView view;
  1001 	// Evaluate view
   961 	// Evaluate view
  1002 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement)));
   962 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement)));
  1003 	CleanupClosePushL(view);
   963 	CleanupClosePushL(view);
  1102 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  1062 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  1103 		
  1063 		
  1104 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  1064 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  1105 	TPtr sqlStatement = buf->Des();
  1065 	TPtr sqlStatement = buf->Des();
  1106 
  1066 
  1107 	_LIT(KSQLInsert, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
  1067 	_LIT(KSQLInsert, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d");
  1108 	sqlStatement.Format(
  1068 	sqlStatement.Format(KSQLInsert, &KReauthCounter, &KAkaTableName, 
  1109 		KSQLInsert,
  1069 		&KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);
  1110 		&KReauthCounter,
       
  1111 		&KAkaTableName, 
       
  1112 		&KServiceType,
       
  1113 		m_index_type,
       
  1114 		&KServiceIndex,
       
  1115 		m_index,
       
  1116 		&KTunnelingTypeVendorId,
       
  1117 		m_tunneling_type.get_vendor_id(),
       
  1118 		&KTunnelingType, 
       
  1119 		m_tunneling_type.get_vendor_type());
       
  1120 		
  1070 		
  1121 	// Evaluate view
  1071 	// Evaluate view
  1122 	RDbView view;
  1072 	RDbView view;
  1123 	User::LeaveIfError(view.Prepare(m_database,TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  1073 	User::LeaveIfError(view.Prepare(m_database,TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  1124 	CleanupClosePushL(view);
  1074 	CleanupClosePushL(view);
  1227 	automatic_realm->reset();
  1177 	automatic_realm->reset();
  1228 	m_stored_pseudonym.reset();
  1178 	m_stored_pseudonym.reset();
  1229 	m_stored_reauth_id.reset();
  1179 	m_stored_reauth_id.reset();
  1230 	m_previous_imsi.reset();
  1180 	m_previous_imsi.reset();
  1231 
  1181 
  1232 	_LIT(KSQLQuery, "SELECT %S, %S, %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
  1182 	_LIT(KSQLQuery, "SELECT %S, %S, %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d");
  1233 	sqlStatement.Format(
  1183 	sqlStatement.Format(KSQLQuery, &KReauthId, &KReauthCounter, &KPseudonymId,
  1234 		KSQLQuery,
  1184 						&KPreviousIMSI, &KAkaTableName,
  1235 		&KReauthId,
  1185 						&KServiceType, m_index_type, 
  1236 		&KReauthCounter,
  1186 						&KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);
  1237 		&KPseudonymId,
       
  1238 		&KPreviousIMSI,
       
  1239 		&KAkaTableName,
       
  1240 		&KServiceType,
       
  1241 		m_index_type, 
       
  1242 		&KServiceIndex,
       
  1243 		m_index,
       
  1244 		&KTunnelingTypeVendorId,
       
  1245 		m_tunneling_type.get_vendor_id(),
       
  1246 		&KTunnelingType, 
       
  1247 		m_tunneling_type.get_vendor_type());
       
  1248 
  1187 
  1249 	RDbView view;
  1188 	RDbView view;
  1250 	// Evaluate view
  1189 	// Evaluate view
  1251 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement)));
  1190 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement)));
  1252 	CleanupClosePushL(view);
  1191 	CleanupClosePushL(view);
  1445 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
  1384 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);	
  1446 }
  1385 }
  1447 
  1386 
  1448 //--------------------------------------------------
  1387 //--------------------------------------------------
  1449 
  1388 
  1450 EAP_FUNC_EXPORT eap_status_e eap_am_type_aka_symbian_c::complete_AKA_imsi_L(
  1389 eap_status_e eap_am_type_aka_symbian_c::complete_AKA_imsi_L(
  1451 	const eap_variable_data_c * const IMSI,
  1390 	const eap_variable_data_c * const IMSI,
  1452 	const eap_status_e completion_status )
  1391 	const eap_status_e completion_status )
  1453 {
  1392 {
  1454 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  1393 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  1455 	eap_status_e status(eap_status_process_general_error);
  1394 	eap_status_e status(eap_status_process_general_error);
  1603 	
  1542 	
  1604 	// Form the insertion command
  1543 	// Form the insertion command
  1605 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  1544 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  1606 	TPtr sqlStatement = buf->Des();
  1545 	TPtr sqlStatement = buf->Des();
  1607 
  1546 
  1608 	_LIT(KSQLInsert, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
  1547 	_LIT(KSQLInsert, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d");
  1609 	sqlStatement.Format(
  1548 	sqlStatement.Format(KSQLInsert, &KPreviousIMSI, &KAkaTableName, 
  1610 		KSQLInsert,
  1549 		&KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);
  1611 		&KPreviousIMSI,
       
  1612 		&KAkaTableName, 
       
  1613 		&KServiceType,
       
  1614 		m_index_type,
       
  1615 		&KServiceIndex,
       
  1616 		m_index,
       
  1617 		&KTunnelingTypeVendorId,
       
  1618 		m_tunneling_type.get_vendor_id(),
       
  1619 		&KTunnelingType, 
       
  1620 		m_tunneling_type.get_vendor_type());
       
  1621 		
  1550 		
  1622 	// Evaluate view
  1551 	// Evaluate view
  1623 	RDbView view;
  1552 	RDbView view;
  1624 	
  1553 	
  1625 	User::LeaveIfError(view.Prepare(m_database,TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  1554 	User::LeaveIfError(view.Prepare(m_database,TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  1769 	return EAP_STATUS_RETURN(m_am_tools, status);
  1698 	return EAP_STATUS_RETURN(m_am_tools, status);
  1770 }
  1699 }
  1771 
  1700 
  1772 //--------------------------------------------------
  1701 //--------------------------------------------------
  1773 
  1702 
  1774 EAP_FUNC_EXPORT eap_status_e eap_am_type_aka_symbian_c::complete_AKA_RES_L(
  1703 eap_status_e eap_am_type_aka_symbian_c::complete_AKA_RES_L(
  1775 	eap_variable_data_c * const aRES, 
  1704 	eap_variable_data_c * const aRES, 
  1776 	eap_variable_data_c * const aCK,
  1705 	eap_variable_data_c * const aCK,
  1777 	eap_variable_data_c * const aIK,
  1706 	eap_variable_data_c * const aIK,
  1778 	eap_variable_data_c * const aAUTS,
  1707 	eap_variable_data_c * const aAUTS,
  1779 	eap_status_e authenticationStatus,
  1708 	eap_status_e authenticationStatus,
  2674 
  2603 
  2675 #endif // #if defined (USE_EAP_TYPE_SERVER_AKA)		
  2604 #endif // #if defined (USE_EAP_TYPE_SERVER_AKA)		
  2676 
  2605 
  2677 //--------------------------------------------------
  2606 //--------------------------------------------------
  2678 
  2607 
  2679 EAP_FUNC_EXPORT eap_status_e eap_am_type_aka_symbian_c::generate_reauthentication_id(
  2608 eap_status_e eap_am_type_aka_symbian_c::generate_reauthentication_id(
  2680 	const eap_am_network_id_c * const send_network_id,
  2609 	const eap_am_network_id_c * const send_network_id,
  2681 	const eap_variable_data_c * const imsi,
  2610 	const eap_variable_data_c * const imsi,
  2682 	eap_variable_data_c * const reauthentication_identity,
  2611 	eap_variable_data_c * const reauthentication_identity,
  2683 	const u32_t maximum_reauthentication_identity_length)
  2612 	const u32_t maximum_reauthentication_identity_length)
  2684 {
  2613 {
  2887 	
  2816 	
  2888 	// Now do the database query
  2817 	// Now do the database query
  2889 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  2818 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  2890 	TPtr sqlStatement = buf->Des();
  2819 	TPtr sqlStatement = buf->Des();
  2891 
  2820 
  2892 	_LIT(KSQLQueryRow, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
  2821 	_LIT(KSQLQueryRow, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d");
  2893 	sqlStatement.Format(
  2822 	sqlStatement.Format(KSQLQueryRow, &unicodeString, &KAkaTableName, 
  2894 		KSQLQueryRow,
  2823 		&KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);
  2895 		&unicodeString,
       
  2896 		&KAkaTableName, 
       
  2897 		&KServiceType,
       
  2898 		m_index_type,
       
  2899 		&KServiceIndex,
       
  2900 		m_index,
       
  2901 		&KTunnelingTypeVendorId,
       
  2902 		m_tunneling_type.get_vendor_id(),
       
  2903 		&KTunnelingType, 
       
  2904 		m_tunneling_type.get_vendor_type());
       
  2905 	
  2824 	
  2906 	RDbView view;
  2825 	RDbView view;
  2907 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  2826 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  2908 	CleanupClosePushL(view);
  2827 	CleanupClosePushL(view);
  2909 	User::LeaveIfError(view.EvaluateAll());	
  2828 	User::LeaveIfError(view.EvaluateAll());	
  3061 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
  2980 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
  3062 }
  2981 }
  3063 
  2982 
  3064 //--------------------------------------------------
  2983 //--------------------------------------------------
  3065 
  2984 
  3066 EAP_FUNC_EXPORT bool eap_am_type_aka_symbian_c::is_session_valid()
  2985 bool eap_am_type_aka_symbian_c::is_session_valid()
  3067 {
  2986 {
  3068 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  2987 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  3069 	
  2988 	
  3070 	bool sessionValidity(false);
  2989 	bool sessionValidity(false);
  3071 	
  2990 	
  3095 
  3014 
  3096 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  3015 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  3097 	TPtr sqlStatement = buf->Des();
  3016 	TPtr sqlStatement = buf->Des();
  3098 	
  3017 	
  3099 	// Query all the relevant parameters
  3018 	// Query all the relevant parameters
  3100 	_LIT(KSQLQuery, "SELECT %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
  3019 	_LIT(KSQLQuery, "SELECT %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d");
  3101 	sqlStatement.Format(
  3020 	sqlStatement.Format(KSQLQuery, &cf_str_EAP_AKA_max_session_validity_time_literal,
  3102 		KSQLQuery,
  3021 						&KAKALastFullAuthTime, &KAkaTableName,
  3103 		&cf_str_EAP_AKA_max_session_validity_time_literal,
  3022 						&KServiceType, m_index_type, 
  3104 		&KAKALastFullAuthTime,
  3023 						&KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);
  3105 		&KAkaTableName,
       
  3106 		&KServiceType,
       
  3107 		m_index_type, 
       
  3108 		&KServiceIndex,
       
  3109 		m_index,
       
  3110 		&KTunnelingTypeVendorId,
       
  3111 		m_tunneling_type.get_vendor_id(),
       
  3112 		&KTunnelingType, 
       
  3113 		m_tunneling_type.get_vendor_type());
       
  3114 
  3024 
  3115 	RDbView view;
  3025 	RDbView view;
  3116 	// Evaluate view
  3026 	// Evaluate view
  3117 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement)));
  3027 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement)));
  3118 	CleanupClosePushL(view);
  3028 	CleanupClosePushL(view);
  3226 
  3136 
  3227 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  3137 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
  3228 	TPtr sqlStatement = buf->Des();
  3138 	TPtr sqlStatement = buf->Des();
  3229 	
  3139 	
  3230 	// Query all the relevant parameters
  3140 	// Query all the relevant parameters
  3231 	_LIT(KSQLQuery, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d");
  3141 	_LIT(KSQLQuery, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d");
  3232 	sqlStatement.Format(
  3142 	sqlStatement.Format(KSQLQuery, &KAKALastFullAuthTime, &KAkaTableName,
  3233 		KSQLQuery,
  3143 						&KServiceType, m_index_type, 
  3234 		&KAKALastFullAuthTime,
  3144 						&KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type);
  3235 		&KAkaTableName,
       
  3236 		&KServiceType,
       
  3237 		m_index_type, 
       
  3238 		&KServiceIndex,
       
  3239 		m_index,
       
  3240 		&KTunnelingTypeVendorId,
       
  3241 		m_tunneling_type.get_vendor_id(),
       
  3242 		&KTunnelingType, 
       
  3243 		m_tunneling_type.get_vendor_type());
       
  3244 
  3145 
  3245 	RDbView view;
  3146 	RDbView view;
  3246 	// Evaluate view
  3147 	// Evaluate view
  3247 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  3148 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  3248 	CleanupClosePushL(view);
  3149 	CleanupClosePushL(view);