eapol/eapol_framework/eapol_symbian/am/type/securid/symbian/plugin/src/EapSecurID.cpp
changeset 0 c8830336c852
child 2 1c7bc153c08e
equal deleted inserted replaced
-1:000000000000 0:c8830336c852
       
     1 /*
       
     2 * Copyright (c) 2001-2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  EAP and WLAN authentication protocols.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // This is enumeration of EAPOL source code.
       
    20 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
       
    21 	#undef EAP_FILE_NUMBER_ENUM
       
    22 	#define EAP_FILE_NUMBER_ENUM 347 
       
    23 	#undef EAP_FILE_NUMBER_DATE 
       
    24 	#define EAP_FILE_NUMBER_DATE 1127594498 
       
    25 #endif //#if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
       
    26 
       
    27 
       
    28 // INCLUDE FILES
       
    29 
       
    30 #include "EapSecurID.h"
       
    31 #include "eap_am_type_securid_symbian.h"
       
    32 #include "eap_type_securid.h"
       
    33 #include "EapSecurIDGlobal.h"
       
    34 #include <EapTypeInfo.h>
       
    35 #include "EapGtcDbUtils.h"
       
    36 
       
    37 #include <EapGtcUiConnection.h>
       
    38 #include "EapGtcUi.h"
       
    39 
       
    40 #include "eap_am_tools_symbian.h"
       
    41 
       
    42 // LOCAL CONSTANTS
       
    43 
       
    44 // The version number of this interface.
       
    45 const TUint KInterfaceVersion = 1;
       
    46 
       
    47 // ================= MEMBER FUNCTIONS =======================
       
    48 
       
    49 CEapSecurID::CEapSecurID(
       
    50 	const TIndexType aIndexType,	
       
    51 	const TInt aIndex,
       
    52 	const eap_type_value_e aEapType)
       
    53 	: iIndexType(aIndexType)
       
    54 	, iIndex(aIndex)
       
    55 	, iEapType(aEapType)
       
    56 	, iTunnelingType(eap_type_none)
       
    57 {
       
    58 }
       
    59 
       
    60 // ----------------------------------------------------------
       
    61 
       
    62 CEapSecurID* CEapSecurID::NewSecurIdL(SIapInfo *aIapInfo)
       
    63 {
       
    64 	return new(ELeave) CEapSecurID(aIapInfo->indexType, aIapInfo->index, eap_type_securid);
       
    65 }
       
    66 
       
    67 // ----------------------------------------------------------
       
    68 
       
    69 CEapSecurID* CEapSecurID::NewGtcL(SIapInfo *aIapInfo)
       
    70 {
       
    71 	return new(ELeave) CEapSecurID(aIapInfo->indexType, aIapInfo->index, eap_type_generic_token_card);
       
    72 }
       
    73 
       
    74 // ----------------------------------------------------------
       
    75 
       
    76 CEapSecurID::~CEapSecurID()
       
    77 {
       
    78 }
       
    79 
       
    80 // ----------------------------------------------------------
       
    81 
       
    82 #ifdef USE_EAP_SIMPLE_CONFIG
       
    83 
       
    84 eap_base_type_c* CEapSecurID::GetStackInterfaceL(abs_eap_am_tools_c* const aTools, 
       
    85 											   abs_eap_base_type_c* const aPartner,
       
    86 											   const bool is_client_when_true,
       
    87 											   const eap_am_network_id_c * const receive_network_id,
       
    88 											   abs_eap_configuration_if_c * const /*configuration_if*/)
       
    89 	
       
    90 #else
       
    91 	
       
    92 eap_base_type_c* CEapSecurID::GetStackInterfaceL(abs_eap_am_tools_c* const aTools, 
       
    93 											abs_eap_base_type_c* const aPartner,
       
    94 											const bool is_client_when_true,
       
    95 											const eap_am_network_id_c * const receive_network_id)
       
    96 	
       
    97 #endif // #ifdef USE_EAP_SIMPLE_CONFIG
       
    98 {
       
    99 	// Create AM
       
   100 	eap_am_type_securid_symbian_c* amEapType = eap_am_type_securid_symbian_c::NewL(
       
   101 		aTools, 
       
   102 		aPartner, 
       
   103 		iIndexType, 
       
   104 		iIndex, 
       
   105 		iTunnelingType, 
       
   106 		iEapType,
       
   107 		is_client_when_true,
       
   108 		receive_network_id);
       
   109 	if (amEapType->get_is_valid() == false)
       
   110 	{
       
   111 		amEapType->shutdown();
       
   112 		delete amEapType;
       
   113 		User::Leave(KErrGeneral);
       
   114 	}	
       
   115 	eap_base_type_c* type = 0;
       
   116 
       
   117 	type = new eap_type_securid_c(
       
   118 		aTools,
       
   119 		aPartner,
       
   120 		amEapType,
       
   121 		true /* free_am */,
       
   122 		iEapType,
       
   123 		is_client_when_true,
       
   124 		receive_network_id);
       
   125 	
       
   126 	if (type == 0)
       
   127 	{
       
   128 		// Out of memory
       
   129 		amEapType->shutdown();
       
   130 		delete amEapType;
       
   131 		User::Leave(KErrNoMemory);
       
   132 	}
       
   133 	else if (type->get_is_valid() == false) 
       
   134 	{		
       
   135 		type->shutdown();
       
   136 		// amEapType is freed by eap_type_securid_c
       
   137 		delete type;		
       
   138 		User::Leave(KErrGeneral);
       
   139 	}
       
   140 	return type;
       
   141 }
       
   142 
       
   143 // ----------------------------------------------------------
       
   144 
       
   145 TUint CEapSecurID::GetInterfaceVersion() 
       
   146 { 
       
   147 	return KInterfaceVersion; 
       
   148 }
       
   149 
       
   150 // ----------------------------------------------------------
       
   151 
       
   152 TInt CEapSecurID::InvokeUiL()
       
   153 {
       
   154 	TInt buttonId(0);
       
   155 
       
   156 #ifdef USE_EAP_EXPANDED_TYPES
       
   157 
       
   158     CEapGtcUiConnection uiConn(iIndexType, iIndex, iTunnelingType.get_vendor_type());
       
   159 	
       
   160 #else
       
   161 
       
   162     CEapGtcUiConnection uiConn(iIndexType, iIndex, iTunnelingType);
       
   163 
       
   164 #endif //#ifdef USE_EAP_EXPANDED_TYPES
       
   165 	
       
   166 	CEapGtcUi* ui = CEapGtcUi::NewL(&uiConn);
       
   167 	CleanupStack::PushL(ui);
       
   168 	buttonId = ui->InvokeUiL();
       
   169 	CleanupStack::PopAndDestroy(ui);
       
   170 	return buttonId;
       
   171 }
       
   172 
       
   173 // ----------------------------------------------------------
       
   174 
       
   175 CEapTypeInfo* CEapSecurID::GetInfoLC()
       
   176 {
       
   177 	CEapTypeInfo* info = new(ELeave) CEapTypeInfo(
       
   178 		(TDesC&) KReleaseDate,
       
   179 		(TDesC&) KEapTypeVersion,
       
   180 		(TDesC&) KManufacturer);
       
   181 	CleanupStack::PushL(info);
       
   182 	return info;
       
   183 }
       
   184 
       
   185 // ----------------------------------------------------------
       
   186 
       
   187 void CEapSecurID::DeleteConfigurationL()
       
   188 {
       
   189 	EapGtcDbUtils::DeleteConfigurationL(iIndexType, iIndex, iTunnelingType);
       
   190 }
       
   191 
       
   192 // ----------------------------------------------------------
       
   193 
       
   194 void CEapSecurID::SetTunnelingType(const TInt aTunnelingType)
       
   195 {
       
   196 #ifdef USE_EAP_EXPANDED_TYPES
       
   197 
       
   198 	// Vendor id is eap_type_vendor_id_ietf always in this plugin.
       
   199 	iTunnelingType.set_eap_type_values(eap_type_vendor_id_ietf, aTunnelingType);
       
   200 
       
   201 #else
       
   202 
       
   203 	iTunnelingType = static_cast<eap_type_value_e>(aTunnelingType);
       
   204 
       
   205 #endif //#ifdef USE_EAP_EXPANDED_TYPES
       
   206 }
       
   207 
       
   208 // ----------------------------------------------------------
       
   209 void CEapSecurID::SetIndexL(
       
   210 		const TIndexType aIndexType, 
       
   211 		const TInt aIndex)
       
   212 {		
       
   213 		// First delete the target configuration
       
   214 	TIndexType tmpIndexType = iIndexType;
       
   215 	TInt tmpIndex = iIndex;
       
   216 		
       
   217 	iIndexType = aIndexType;
       
   218 	iIndex = aIndex;
       
   219 	
       
   220 	TInt err(KErrNone);
       
   221 	TRAP(err, DeleteConfigurationL());
       
   222 	// Ignore error on purpose
       
   223 	
       
   224 	// Return the indices
       
   225 	iIndexType = tmpIndexType;
       
   226 	iIndex = tmpIndex;
       
   227 
       
   228 	RDbNamedDatabase db;
       
   229 
       
   230 	RDbs session;
       
   231 	
       
   232 	EapGtcDbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
       
   233 	
       
   234 	CleanupClosePushL(session);
       
   235 	CleanupClosePushL(db);
       
   236 		
       
   237 	EapGtcDbUtils::SetIndexL(
       
   238 		db, 
       
   239 		iIndexType, 
       
   240 		iIndex, 
       
   241 		iTunnelingType, 
       
   242 		aIndexType, 
       
   243 		aIndex, 
       
   244 		iTunnelingType);
       
   245 	
       
   246 	iIndexType = aIndexType;
       
   247 	iIndex = aIndex;
       
   248 
       
   249 	CleanupStack::PopAndDestroy(2); // db
       
   250 	
       
   251 		
       
   252 }
       
   253 
       
   254 void CEapSecurID::SetConfigurationL(const EAPSettings& aSettings)
       
   255 {
       
   256 	RDbNamedDatabase db;
       
   257 
       
   258 	RDbs session;	
       
   259 	
       
   260 	// This also creates the IAP entry if it doesn't exist
       
   261 	EapGtcDbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
       
   262 	
       
   263 	CleanupClosePushL(session);
       
   264 	CleanupClosePushL(db);
       
   265 
       
   266 	EapGtcDbUtils::SetConfigurationL(
       
   267 		db,
       
   268 		aSettings, 
       
   269 		iIndexType,
       
   270 		iIndex,
       
   271 		iTunnelingType);		
       
   272 		
       
   273 	CleanupStack::PopAndDestroy(2); // db, session
       
   274 }
       
   275 
       
   276 void CEapSecurID::GetConfigurationL(EAPSettings& aSettings)
       
   277 {
       
   278 	RDbNamedDatabase db;
       
   279 
       
   280 	RDbs session;
       
   281 	
       
   282 	// This also creates the IAP entry if it doesn't exist
       
   283 	EapGtcDbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
       
   284 	
       
   285 	CleanupClosePushL(session);
       
   286 	CleanupClosePushL(db);
       
   287 
       
   288 	EapGtcDbUtils::GetConfigurationL(
       
   289 		db,
       
   290 		aSettings, 
       
   291 		iIndexType,
       
   292 		iIndex,
       
   293 		iTunnelingType);
       
   294 		
       
   295 	CleanupStack::PopAndDestroy(2); // db, session
       
   296 }
       
   297 
       
   298 void CEapSecurID::CopySettingsL(
       
   299 	const TIndexType aDestinationIndexType,
       
   300 	const TInt aDestinationIndex)
       
   301 {
       
   302 	// First delete the target configuration
       
   303 	TIndexType tmpIndexType = iIndexType;
       
   304 	TInt tmpIndex = iIndex;
       
   305 		
       
   306 	iIndexType = aDestinationIndexType;
       
   307 	iIndex = aDestinationIndex;
       
   308 	
       
   309 	TInt err(KErrNone);
       
   310 	TRAP(err, DeleteConfigurationL());
       
   311 	// Ignore error on purpose
       
   312 	
       
   313 	// Return the indices
       
   314 	iIndexType = tmpIndexType;
       
   315 	iIndex = tmpIndex;
       
   316 
       
   317 	RDbNamedDatabase db;
       
   318 
       
   319 	RDbs session;
       
   320 	
       
   321 	EapGtcDbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType);
       
   322 	
       
   323 	CleanupClosePushL(session);
       
   324 	CleanupClosePushL(db);
       
   325 		
       
   326 	EapGtcDbUtils::CopySettingsL(
       
   327 		db,
       
   328 		iIndexType,
       
   329 		iIndex,
       
   330 		iTunnelingType, 
       
   331 		aDestinationIndexType, 
       
   332 		aDestinationIndex, 
       
   333 		iTunnelingType);
       
   334 		
       
   335 	CleanupStack::PopAndDestroy(2); // db
       
   336 	
       
   337 }
       
   338 
       
   339 
       
   340 // End of File