eapol/eapol_framework/eapol_symbian/am/type/tls_peap/symbian/plugin/src/EapTlsPeapUiDataConnection.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 430 
       
    23 	#undef EAP_FILE_NUMBER_DATE 
       
    24 	#define EAP_FILE_NUMBER_DATE 1127594498 
       
    25 #endif //#if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
       
    26 
       
    27 #include <e32base.h>
       
    28 #include "EapTlsPeapUtils.h"
       
    29 #include "EapTlsPeapDbParameterNames.h"
       
    30 #include "EapTlsPeapDbDefaults.h"
       
    31 #include <EapTlsPeapUiConnection.h>
       
    32 #include <EapTlsPeapUiDataConnection.h>
       
    33 #include <EapTlsPeapUiTlsPeapData.h>
       
    34 #include "eap_am_trace_symbian.h"
       
    35 
       
    36 #ifdef USE_PAC_STORE
       
    37 #include "pac_store_db_symbian.h"
       
    38 #endif
       
    39 
       
    40 const TUint KMaxSqlQueryLength = 256;
       
    41 
       
    42 // ---------------------------------------------------------
       
    43 // CEapTlsPeapUiDataConnection::CEapTlsPeapUiDataConnection()
       
    44 // ---------------------------------------------------------
       
    45 // 
       
    46 CEapTlsPeapUiDataConnection::CEapTlsPeapUiDataConnection(CEapTlsPeapUiConnection * aUiConn)
       
    47 : iIsOpened(EFalse)
       
    48 , iUiConn(aUiConn)
       
    49 , iColSet(NULL)
       
    50 , iDataPtr(NULL)
       
    51 , iFastSpecificColSet(NULL)
       
    52 {
       
    53 }
       
    54 
       
    55 
       
    56 // ---------------------------------------------------------
       
    57 // CEapTlsPeapUiDataConnection::~CEapTlsPeapUiDataConnection()
       
    58 // ---------------------------------------------------------
       
    59 // 
       
    60 CEapTlsPeapUiDataConnection::~CEapTlsPeapUiDataConnection()
       
    61 {
       
    62     if (iUiConn)
       
    63     {
       
    64         Close();
       
    65         iUiConn = NULL;
       
    66     }
       
    67 }
       
    68 
       
    69 
       
    70 // ---------------------------------------------------------
       
    71 // CEapTlsPeapUiDataConnection::Open()
       
    72 // ---------------------------------------------------------
       
    73 // 
       
    74 TInt CEapTlsPeapUiDataConnection::Open()
       
    75 {
       
    76 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiDataConnection::Open: Start EAP-Type=%d\n"),
       
    77 		iUiConn->GetEapType()));
       
    78 
       
    79     if (iIsOpened)
       
    80     {
       
    81         return KErrAlreadyExists;
       
    82     }
       
    83 
       
    84     TInt err = iUiConn->GetDatabase(iDatabase);
       
    85     if (err != KErrNone)
       
    86     {
       
    87         return err;
       
    88     }
       
    89     
       
    90     iIsOpened = ETrue;
       
    91 
       
    92 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiDataConnection::Open: End\n")));
       
    93 	
       
    94     return KErrNone;
       
    95 }
       
    96 
       
    97 
       
    98 // ---------------------------------------------------------
       
    99 // CEapTlsPeapUiDataConnection::GetData()
       
   100 // ---------------------------------------------------------
       
   101 // 
       
   102 TInt CEapTlsPeapUiDataConnection::GetData(CEapTlsPeapUiTlsPeapData ** aDataPtr)
       
   103 {
       
   104 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiDataConnection::GetData: Start EAP-Type=%d\n"),
       
   105 		iUiConn->GetEapType()));
       
   106 
       
   107     if (aDataPtr == NULL)
       
   108     {
       
   109         return KErrArgument;
       
   110     }
       
   111     
       
   112     if (iIsOpened == EFalse)
       
   113     {
       
   114 		EAP_TRACE_DEBUG_SYMBIAN(
       
   115 			(_L("CEapTlsPeapUiDataConnection::GetData: Data Connection not opened\n")));
       
   116     
       
   117         return KErrSessionClosed;
       
   118     }
       
   119     
       
   120     if (iDataPtr != 0)
       
   121     {
       
   122     	*aDataPtr = iDataPtr;
       
   123     	return KErrNone;
       
   124     }
       
   125     
       
   126     iDataPtr = new CEapTlsPeapUiTlsPeapData();
       
   127     if (!iDataPtr)
       
   128     {
       
   129 		EAP_TRACE_DEBUG_SYMBIAN(
       
   130 			(_L("CEapTlsPeapUiDataConnection::GetData: ERROR: NO MEMORY!\n")));    	
       
   131 		
       
   132         return KErrNoMemory;
       
   133     }
       
   134 
       
   135     TRAPD(err, FetchDataL());
       
   136     if (err != KErrNone)
       
   137     {
       
   138         delete iDataPtr;
       
   139         iDataPtr = NULL;
       
   140         
       
   141         delete iColSet;
       
   142         iColSet = NULL;
       
   143         
       
   144 		delete iFastSpecificColSet;
       
   145 		iFastSpecificColSet = NULL;
       
   146         
       
   147         iView.Close();
       
   148         iFastSpecificView.Close();
       
   149         
       
   150         return err;
       
   151     }
       
   152 
       
   153     *aDataPtr = iDataPtr;
       
   154 
       
   155 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiDataConnection::GetData: End\n")));
       
   156 	
       
   157     return KErrNone;
       
   158 } // CEapTlsPeapUiDataConnection::GetData()
       
   159 
       
   160 
       
   161 // ---------------------------------------------------------
       
   162 // CEapTlsPeapUiDataConnection::Update()
       
   163 // ---------------------------------------------------------
       
   164 // 
       
   165 TInt CEapTlsPeapUiDataConnection::Update()
       
   166 {
       
   167 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiDataConnection::Update: Start EAP-Type=%d\n"),
       
   168 		iUiConn->GetEapType()));
       
   169     
       
   170     // Do the length checks first.
       
   171 	// Check if length of username and realm are less than the max length possible in DB.
       
   172 	if(iDataPtr->GetManualUsername().Length() > KMaxManualUsernameLengthInDB
       
   173 		|| iDataPtr->GetManualRealm().Length() > KMaxManualRealmLengthInDB)
       
   174 	{
       
   175 		// Username or realm too long. Can not be stored in DB.
       
   176 		EAP_TRACE_DEBUG_SYMBIAN(
       
   177 			(_L("CEapTlsPeapUiDataConnection::Update: Too long username or realm. Length: UN=%d, Realm=%d\n"),
       
   178 			iDataPtr->GetManualUsername().Length(),
       
   179 			iDataPtr->GetManualRealm().Length()));
       
   180 		
       
   181 		return KErrOverflow;
       
   182 	}
       
   183 
       
   184 #ifdef USE_FAST_EAP_TYPE	
       
   185 	// Check the length of PAC store password.
       
   186 
       
   187 	if(iDataPtr->GetPacStorePassword().Size() > KMaxPasswordLengthInDB)
       
   188 	{
       
   189 		// PAC store password too long. Can not be stored in DB.
       
   190 		EAP_TRACE_DEBUG_SYMBIAN(
       
   191 			(_L("CEapTlsPeapUiDataConnection::Update: Too long PAC store PW. Size:%d\n"),
       
   192 			iDataPtr->GetPacStorePassword().Size()));
       
   193 		
       
   194 		return KErrOverflow;
       
   195 	}
       
   196 
       
   197 #endif 
       
   198 	
       
   199     TRAPD(err, UpdateDataL());
       
   200 
       
   201 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiDataConnection::Update: End, err=%d\n"),
       
   202 		err));    
       
   203 
       
   204 	return err;
       
   205 } // CEapTlsPeapUiDataConnection::Update()
       
   206 
       
   207 
       
   208 // ---------------------------------------------------------
       
   209 // CEapTlsPeapUiDataConnection::Close()
       
   210 // ---------------------------------------------------------
       
   211 // 
       
   212 TInt CEapTlsPeapUiDataConnection::Close()
       
   213 {
       
   214     if (iIsOpened == EFalse)
       
   215     {
       
   216         return KErrNone;
       
   217     }
       
   218 
       
   219     delete iDataPtr;
       
   220     iDataPtr = NULL;
       
   221     
       
   222     delete iColSet;
       
   223     iColSet = NULL;
       
   224 
       
   225     delete iFastSpecificColSet;
       
   226     iFastSpecificColSet = NULL;
       
   227     
       
   228     iView.Close();    
       
   229     
       
   230     iFastSpecificView.Close();
       
   231 
       
   232     iUiConn = NULL;
       
   233     
       
   234     return KErrNone;
       
   235 } // CEapTlsPeapUiDataConnection::Close()
       
   236 
       
   237 
       
   238 // ---------------------------------------------------------
       
   239 // CEapTlsPeapUiDataConnection::FetchDataL()
       
   240 // ---------------------------------------------------------
       
   241 // 
       
   242 void CEapTlsPeapUiDataConnection::FetchDataL()
       
   243 {
       
   244 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiDataConnection::FetchDataL: Start EAP-Type=%d\n"),
       
   245 		iUiConn->GetEapType()));
       
   246 
       
   247 	HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
       
   248 	TPtr sqlStatement = buf->Des();
       
   249 
       
   250 	// Form the general query for TLS, PEAP, TTLS and FAST. Query everything.
       
   251 	_LIT(KSQLQuery, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d");
       
   252 
       
   253 	if (iUiConn->GetEapType() == eap_type_tls)
       
   254 	{
       
   255 		sqlStatement.Format(KSQLQuery,
       
   256 							&KTlsDatabaseTableName,
       
   257 							&KServiceType,
       
   258 							iUiConn->GetIndexType(),
       
   259 							&KServiceIndex,
       
   260 							iUiConn->GetIndex(),
       
   261 							&KTunnelingType, 
       
   262 							iUiConn->GetTunnelingType());
       
   263 	}
       
   264 	else if (iUiConn->GetEapType() == eap_type_peap)
       
   265 	{
       
   266 		sqlStatement.Format(KSQLQuery,
       
   267 							&KPeapDatabaseTableName,
       
   268 							&KServiceType,
       
   269 							iUiConn->GetIndexType(),
       
   270 							&KServiceIndex,
       
   271 							iUiConn->GetIndex(),
       
   272 							&KTunnelingType, 
       
   273 							iUiConn->GetTunnelingType());
       
   274 	}
       
   275 	else if (iUiConn->GetEapType() == eap_type_ttls || iUiConn->GetEapType() == eap_type_ttls_plain_pap)
       
   276 	{
       
   277 		sqlStatement.Format(KSQLQuery,
       
   278 							&KTtlsDatabaseTableName,
       
   279 							&KServiceType,
       
   280 							iUiConn->GetIndexType(),
       
   281 							&KServiceIndex,
       
   282 							iUiConn->GetIndex(),
       
   283 							&KTunnelingType, 
       
   284 							iUiConn->GetTunnelingType());
       
   285 	}
       
   286 	
       
   287 #ifdef USE_FAST_EAP_TYPE	
       
   288 	else if (iUiConn->GetEapType() == eap_type_fast)
       
   289 	{
       
   290 		// Unlike other EAP types, EAP-FAST has two settings tables. 
       
   291 		// General settings and special settings
       
   292 		
       
   293 		// This is for the General settings. The special settings are read below.
       
   294 		
       
   295 		sqlStatement.Format(KSQLQuery,
       
   296 							&KFastGeneralSettingsDBTableName,
       
   297 							&KServiceType,
       
   298 							iUiConn->GetIndexType(),
       
   299 							&KServiceIndex,
       
   300 							iUiConn->GetIndex(),
       
   301 							&KTunnelingType, 
       
   302 							iUiConn->GetTunnelingType());							
       
   303 	}	
       
   304 #endif
       
   305 	else
       
   306 	{
       
   307 		// Unknown EAP type
       
   308 		EAP_TRACE_DEBUG_SYMBIAN((_L("EAP-Type=%d - ERROR: Unknown EAP type!\n"),
       
   309 			iUiConn->GetEapType()));
       
   310 			
       
   311 		User::Leave(KErrNotSupported);
       
   312 	}	
       
   313 		
       
   314 	// Evaluate view
       
   315 	User::LeaveIfError(iView.Prepare(iDatabase, TDbQuery(sqlStatement)));
       
   316 	User::LeaveIfError(iView.EvaluateAll());
       
   317 		
       
   318 	// Get the first (and only) row
       
   319 	iView.FirstL();
       
   320 	iView.GetL();
       
   321 	
       
   322 	// Get column set so we get the correct column numbers
       
   323 	delete iColSet;
       
   324 	iColSet = NULL;
       
   325 	iColSet = iView.ColSetL();
       
   326 
       
   327 	// Start fetching the values
       
   328 
       
   329 	
       
   330 	/**************** only for TTLS PAP ****************/
       
   331 	
       
   332 	if ( iUiConn->GetEapType() == eap_type_ttls_plain_pap )
       
   333 		{
       
   334 		// Prompt password
       
   335 		TUint intValue = iView.ColUint( iColSet->ColNo(
       
   336 			cf_str_EAP_TLS_PEAP_ttls_pap_password_prompt_literal ) );
       
   337 	    if ( intValue == 0 )
       
   338 	        {
       
   339 	        *( iDataPtr->GetPapPasswordPrompt() ) = EFalse;
       
   340 	        }
       
   341 	    else
       
   342 	        {
       
   343 	        *( iDataPtr->GetPapPasswordPrompt() ) = ETrue;
       
   344 	        }
       
   345 
       
   346 		// username
       
   347 	    iDataPtr->GetPapUserName().Copy( iView.ColDes16( iColSet->ColNo(
       
   348 	    	cf_str_EAP_TLS_PEAP_ttls_pap_username_literal ) ) );
       
   349 
       
   350 		// password
       
   351 		iDataPtr->GetPapPassword().Copy( iView.ColDes16( iColSet->ColNo(
       
   352 			cf_str_EAP_TLS_PEAP_ttls_pap_password_literal ) ) );
       
   353 
       
   354 	    CleanupStack::PopAndDestroy(buf);
       
   355 
       
   356 		EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiDataConnection::FetchDataL: Return\n")));
       
   357         return;
       
   358 		}
       
   359 		
       
   360 	// Get use manual username
       
   361 	TUint intValue = iView.ColUint(iColSet->ColNo(cf_str_EAP_TLS_PEAP_use_manual_username_literal));
       
   362     if (intValue == 0)
       
   363     {
       
   364         *(iDataPtr->GetUseManualUsername()) = EFalse;
       
   365     }
       
   366     else
       
   367     {
       
   368         *(iDataPtr->GetUseManualUsername()) = ETrue;
       
   369     }
       
   370 
       
   371 	// Get use manual realm
       
   372 	intValue = iView.ColUint(iColSet->ColNo(cf_str_EAP_TLS_PEAP_use_manual_realm_literal));
       
   373     if (intValue == 0)
       
   374     {
       
   375         *(iDataPtr->GetUseManualRealm()) = EFalse;
       
   376     }
       
   377     else
       
   378     {
       
   379         *(iDataPtr->GetUseManualRealm()) = ETrue;
       
   380     }
       
   381 
       
   382 	// Get Username
       
   383     iDataPtr->GetManualUsername().Copy(iView.ColDes16(iColSet->ColNo(cf_str_EAP_TLS_PEAP_manual_username_literal)));
       
   384 
       
   385 	// Get Realm
       
   386     iDataPtr->GetManualRealm().Copy(iView.ColDes16(iColSet->ColNo(cf_str_EAP_TLS_PEAP_manual_realm_literal)));
       
   387 
       
   388 	// Get PEAP/TTLS versions
       
   389 	if (iUiConn->GetEapType() == eap_type_peap
       
   390 		|| iUiConn->GetEapType() == eap_type_ttls
       
   391 #ifdef USE_FAST_EAP_TYPE
       
   392 		|| iUiConn->GetEapType() == eap_type_fast
       
   393 #endif
       
   394 		)
       
   395 	{
       
   396 		TPtrC8 binaryValue = iView.ColDes8(iColSet->ColNo(cf_str_EAP_TLS_PEAP_accepted_PEAP_versions_literal));
       
   397 	
       
   398 		const TInt* allowedVersions = reinterpret_cast<const TInt *>(binaryValue.Ptr());
       
   399 
       
   400 		TInt i;
       
   401 		for (i = 0; i < static_cast<TInt>(binaryValue.Length() / sizeof(TInt)); i++)
       
   402 		{
       
   403 			switch(allowedVersions[i])
       
   404 			{
       
   405 			case 0:
       
   406 				*(iDataPtr->GetAllowVersion0()) = ETrue;
       
   407 				break;
       
   408 			case 1:
       
   409 				*(iDataPtr->GetAllowVersion1()) = ETrue;
       
   410 				break;
       
   411 			case 2:
       
   412 				*(iDataPtr->GetAllowVersion2()) = ETrue;
       
   413 				break;		
       
   414 			}
       
   415 		}
       
   416 	}
       
   417 
       
   418 
       
   419 	intValue = iView.ColUint(iColSet->ColNo(cf_str_EAP_TLS_PEAP_use_identity_privacy_literal));
       
   420 
       
   421     if (intValue == 0)
       
   422     {
       
   423         *(iDataPtr->GetTlsPrivacy()) = EFalse;
       
   424     }
       
   425     else
       
   426     {
       
   427         *(iDataPtr->GetTlsPrivacy()) = ETrue;
       
   428     }
       
   429 
       
   430 	
       
   431 #ifdef USE_FAST_EAP_TYPE
       
   432 	
       
   433 	EAP_TRACE_DEBUG_SYMBIAN((_L("Fetching EAP-FAST specific Special settings!\n")));
       
   434 
       
   435 	if(iUiConn->GetEapType() == eap_type_fast)
       
   436 	{		
       
   437 		// This is for the EAP-FAST specific Special settings.
       
   438 		
       
   439 		sqlStatement.Format(KSQLQuery,
       
   440 							&KFastSpecialSettingsDBTableName,
       
   441 							&KServiceType,
       
   442 							iUiConn->GetIndexType(),
       
   443 							&KServiceIndex,
       
   444 							iUiConn->GetIndex(),
       
   445 							&KTunnelingType, 
       
   446 							iUiConn->GetTunnelingType());
       
   447 							
       
   448 		// Evaluate view
       
   449 		User::LeaveIfError(iFastSpecificView.Prepare(iDatabase, TDbQuery(sqlStatement)));
       
   450 		User::LeaveIfError(iFastSpecificView.EvaluateAll());
       
   451 			
       
   452 		// Get the first (and only) row
       
   453 		iFastSpecificView.FirstL();
       
   454 		iFastSpecificView.GetL();
       
   455 		
       
   456 		// Get column set so we get the correct column numbers
       
   457 		delete iFastSpecificColSet;
       
   458 		iFastSpecificColSet = NULL;
       
   459 		iFastSpecificColSet = iFastSpecificView.ColSetL();
       
   460 
       
   461 		// Start fetching the values							
       
   462 	    // The below uses EAP-FAST Specific settings table. So use the specific view and colset.
       
   463 		
       
   464 		// Get provisioning modes
       
   465 		intValue = iFastSpecificView.ColUint(iFastSpecificColSet->ColNo(cf_str_EAP_FAST_allow_server_authenticated_provisioning_mode_literal));
       
   466 	    if (intValue == 0)
       
   467 	    {
       
   468 	        *(iDataPtr->GetAuthProvModeAllowed()) = EFalse;
       
   469 	    }
       
   470 	    else
       
   471 	    {
       
   472 	        *(iDataPtr->GetAuthProvModeAllowed()) = ETrue;
       
   473 	    }
       
   474 	
       
   475 		intValue = iFastSpecificView.ColUint(iFastSpecificColSet->ColNo(cf_str_EAP_FAST_allow_server_unauthenticated_provisioning_mode_ADHP_literal));
       
   476 	    if (intValue == 0)
       
   477 	    {
       
   478 	        *(iDataPtr->GetUnauthProvModeAllowed()) = EFalse;
       
   479 	    }
       
   480 	    else
       
   481 	    {
       
   482 	        *(iDataPtr->GetUnauthProvModeAllowed()) = ETrue;
       
   483 	    } 
       
   484 
       
   485 #ifdef USE_PAC_STORE	    
       
   486 		// Get PAC store Password
       
   487 	    // PAC store password is in a different database, pac store db.
       
   488 	    // We can use the PacStoreDbUtils to get the PAC store password.
       
   489 	    
       
   490 	    TBuf8<KMaxPasswordLengthInDB> tmpPacStorePw8;
       
   491 
       
   492 	    iUiConn->GetPacStoreDb()->GetPacStoreDataL(
       
   493 	    		cf_str_EAP_FAST_PAC_store_password_literal(),
       
   494 	    		tmpPacStorePw8);	    	
       
   495 	    
       
   496 		EAP_TRACE_DATA_DEBUG_SYMBIAN(
       
   497 		("CEapTlsPeapUiDataConnection::FetchDataL: PW from PAC store DB(8 bits)",
       
   498 		tmpPacStorePw8.Ptr(), 
       
   499 		tmpPacStorePw8.Size()));
       
   500 	    
       
   501 	    /***** Convert the 8 bit password to 16 bits for the UI ***************/	    
       
   502 	    
       
   503 		iDataPtr->GetPacStorePassword().Copy(tmpPacStorePw8);  // This takes care of the conversion automatically.
       
   504 		
       
   505 		EAP_TRACE_DATA_DEBUG_SYMBIAN(
       
   506 		("CEapTlsPeapUiDataConnection::FetchDataL: PW to UI (16 bits)",
       
   507 		iDataPtr->GetPacStorePassword().Ptr(), 
       
   508 		iDataPtr->GetPacStorePassword().Size()));
       
   509 		
       
   510 		/*****************TEST*************/
       
   511 
       
   512 #endif // End: #ifdef USE_PAC_STORE
       
   513 	    
       
   514 	} // End: if(iUiConn->GetEapType() == eap_type_fast)
       
   515     
       
   516 #endif // End: #ifdef USE_FAST_EAP_TYPE	
       
   517 	
       
   518     CleanupStack::PopAndDestroy(buf);
       
   519 
       
   520 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiDataConnection::FetchDataL: End\n")));
       
   521 
       
   522 } // CEapTlsPeapUiDataConnection::FetchDataL()
       
   523 
       
   524 
       
   525 // ---------------------------------------------------------
       
   526 // CEapTlsPeapUiDataConnection::UpdateDataL()
       
   527 // ---------------------------------------------------------
       
   528 // 
       
   529 void CEapTlsPeapUiDataConnection::UpdateDataL()
       
   530 {
       
   531 	EAP_TRACE_DEBUG_SYMBIAN(
       
   532 		(_L("CEapTlsPeapUiDataConnection::UpdateDataL: Start\n")));
       
   533 	
       
   534     iView.UpdateL();
       
   535 	
       
   536     iView.SetColL(
       
   537     	iColSet->ColNo(cf_str_EAP_TLS_PEAP_manual_username_literal),
       
   538     	iDataPtr->GetManualUsername());
       
   539 
       
   540     iView.SetColL(
       
   541     	iColSet->ColNo(cf_str_EAP_TLS_PEAP_manual_realm_literal),
       
   542     	iDataPtr->GetManualRealm());
       
   543 
       
   544     if (*(iDataPtr->GetUseManualUsername()))
       
   545     {
       
   546         iView.SetColL(
       
   547         	iColSet->ColNo(cf_str_EAP_TLS_PEAP_use_manual_username_literal),
       
   548         	ETLSPEAPUseManualUsernameYes);
       
   549     }
       
   550     else
       
   551     {
       
   552         iView.SetColL(
       
   553         	iColSet->ColNo(cf_str_EAP_TLS_PEAP_use_manual_username_literal),
       
   554         	ETLSPEAPUseManualUsernameNo);
       
   555     }
       
   556 	
       
   557     if (*(iDataPtr->GetUseManualRealm()))
       
   558     {
       
   559         iView.SetColL(
       
   560         	iColSet->ColNo(cf_str_EAP_TLS_PEAP_use_manual_realm_literal),
       
   561         	ETLSPEAPUseManualRealmYes);
       
   562     }
       
   563     else
       
   564     {
       
   565         iView.SetColL(
       
   566         	iColSet->ColNo(cf_str_EAP_TLS_PEAP_use_manual_realm_literal),
       
   567         	ETLSPEAPUseManualRealmNo);
       
   568     }
       
   569 	
       
   570 	// PEAP/TTLS versions
       
   571 	if (iUiConn->GetEapType() == eap_type_peap
       
   572 		|| iUiConn->GetEapType() == eap_type_ttls
       
   573 #ifdef USE_FAST_EAP_TYPE	
       
   574 		|| iUiConn->GetEapType() == eap_type_fast
       
   575 #endif		
       
   576 		)
       
   577 	{
       
   578 		TBuf8<KMaxPEAPVersionsStringLengthInDB> acceptedVersions;
       
   579 		
       
   580 		if (*(iDataPtr->GetAllowVersion0()))
       
   581 		{
       
   582 			TInt tmp(0);
       
   583 			acceptedVersions.Append(reinterpret_cast<const TUint8*>(&tmp), sizeof(TInt));
       
   584 		}
       
   585 		if (*(iDataPtr->GetAllowVersion1()))
       
   586 		{
       
   587 			TInt tmp(1);
       
   588 			acceptedVersions.Append(reinterpret_cast<const TUint8*>(&tmp), sizeof(TInt));
       
   589 		}
       
   590 		if (*(iDataPtr->GetAllowVersion2()))
       
   591 		{
       
   592 			TInt tmp(2);
       
   593 			acceptedVersions.Append(reinterpret_cast<const TUint8*>(&tmp), sizeof(TInt));
       
   594 		}
       
   595 
       
   596 		iView.SetColL(
       
   597 			iColSet->ColNo(cf_str_EAP_TLS_PEAP_accepted_PEAP_versions_literal),
       
   598 			acceptedVersions);
       
   599 	}	
       
   600 
       
   601 	// Last full authentication time should be made zero when EAP configurations are modified.
       
   602 	// This makes sure that the next authentication with this EAP would be full authentication
       
   603 	// instead of reauthentication even if the session is still valid.
       
   604 	
       
   605 	TPtrC lastFullAuthTimeString;
       
   606 
       
   607 	switch (iUiConn->GetEapType())
       
   608 	{
       
   609 	case eap_type_tls:
       
   610 		{
       
   611 			lastFullAuthTimeString.Set(KTLSLastFullAuthTime);
       
   612 		}
       
   613 		break;
       
   614 
       
   615 	case eap_type_peap:
       
   616 		{
       
   617 			lastFullAuthTimeString.Set(KPEAPLastFullAuthTime);
       
   618 		}
       
   619 		break;
       
   620 
       
   621 	case eap_type_ttls:
       
   622 		{
       
   623 			lastFullAuthTimeString.Set(KTTLSLastFullAuthTime);
       
   624 		}
       
   625 		break;
       
   626 
       
   627 #ifdef USE_FAST_EAP_TYPE	
       
   628 	case eap_type_fast:
       
   629 		{
       
   630 			lastFullAuthTimeString.Set(KFASTLastFullAuthTime);
       
   631 		}
       
   632 		break;
       
   633 #endif		
       
   634 
       
   635 	case eap_type_ttls_plain_pap:
       
   636 		{
       
   637 			lastFullAuthTimeString.Set( KTTLSPAPLastFullAuthTime );
       
   638 		}
       
   639 		break;
       
   640 
       
   641 	default:
       
   642 		{
       
   643 			// Should never happen. Don't return error here as this is just to reset the auth time only.
       
   644 			EAP_TRACE_DEBUG_SYMBIAN(
       
   645 				(_L("Session Validity: EAP-Type=%d - ERROR: Unknown EAP type!\n"),
       
   646 				iUiConn->GetEapType() ));
       
   647 		}
       
   648 	}
       
   649 	
       
   650 	iView.SetColL(
       
   651 		iColSet->ColNo(lastFullAuthTimeString),
       
   652 		default_FullAuthTime);
       
   653 
       
   654 	EAP_TRACE_DEBUG_SYMBIAN(
       
   655 		(_L("Session Validity: EAP-Type=%d, Resetting Full Auth Time since settings are modified\n"),
       
   656 		iUiConn->GetEapType() ));
       
   657 	
       
   658 
       
   659 	// Update TLS Privacy
       
   660     if (*(iDataPtr->GetTlsPrivacy()))
       
   661     	{
       
   662     	iView.SetColL(
       
   663     	iColSet->ColNo(cf_str_EAP_TLS_PEAP_use_identity_privacy_literal),
       
   664         ETLSPEAPTLSPrivacyYes);
       
   665         }
       
   666         else
       
   667         {
       
   668         iView.SetColL(
       
   669         iColSet->ColNo(cf_str_EAP_TLS_PEAP_use_identity_privacy_literal),
       
   670         ETLSPEAPTLSPrivacyNo);
       
   671         }
       
   672 	
       
   673 	
       
   674 
       
   675 	
       
   676 	/************** only for TTLS PAP **************/
       
   677 	
       
   678 	if( iUiConn->GetEapType() == eap_type_ttls_plain_pap )
       
   679 		{
       
   680         // PAP user name
       
   681         iView.SetColL( iColSet->ColNo( cf_str_EAP_TLS_PEAP_ttls_pap_username_literal ),
       
   682         	iDataPtr->GetPapUserName() );
       
   683         // PAP password
       
   684         iView.SetColL( iColSet->ColNo( cf_str_EAP_TLS_PEAP_ttls_pap_password_literal ),
       
   685         	iDataPtr->GetPapPassword() );
       
   686         // PAP password prompt
       
   687         if ( *( iDataPtr->GetPapPasswordPrompt() ) )
       
   688             {
       
   689             iView.SetColL( iColSet->ColNo( cf_str_EAP_TLS_PEAP_ttls_pap_password_prompt_literal ),
       
   690             	EPapPasswordPromptOn );
       
   691             }
       
   692         else
       
   693             {
       
   694             iView.SetColL( iColSet->ColNo( cf_str_EAP_TLS_PEAP_ttls_pap_password_prompt_literal ),
       
   695             	EPapPasswordPromptOff );
       
   696             }
       
   697     
       
   698 		} // if( iUiConn->GetEapType() == eap_type_ttls_plain_pap )
       
   699 
       
   700 	
       
   701 	
       
   702 	// Now put all the updated values in DB table.
       
   703 	iView.PutL();	
       
   704 
       
   705 #ifdef USE_FAST_EAP_TYPE
       
   706 
       
   707 	if(iUiConn->GetEapType() == eap_type_fast)
       
   708 	{
       
   709 		// Make the view ready for updation. This is important!
       
   710 	    iFastSpecificView.UpdateL();
       
   711    	
       
   712 		// Update Authentication modes
       
   713 	    if (*(iDataPtr->GetAuthProvModeAllowed()))
       
   714         {
       
   715             iFastSpecificView.SetColL(
       
   716             	iFastSpecificColSet->ColNo(cf_str_EAP_FAST_allow_server_authenticated_provisioning_mode_literal),
       
   717             	EFASTAuthProvModeAllowedYes);
       
   718         }
       
   719         else
       
   720         {
       
   721             iFastSpecificView.SetColL(
       
   722             	iFastSpecificColSet->ColNo(cf_str_EAP_FAST_allow_server_authenticated_provisioning_mode_literal),
       
   723             	EFASTAuthProvModeAllowedNo);
       
   724         }
       
   725 	    
       
   726 	    if (*(iDataPtr->GetUnauthProvModeAllowed()))
       
   727         {
       
   728             iFastSpecificView.SetColL(
       
   729             	iFastSpecificColSet->ColNo(cf_str_EAP_FAST_allow_server_unauthenticated_provisioning_mode_ADHP_literal),
       
   730             	EFASTUnauthProvModeAllowedYes);
       
   731         }
       
   732         else
       
   733         {
       
   734             iFastSpecificView.SetColL(
       
   735             	iFastSpecificColSet->ColNo(cf_str_EAP_FAST_allow_server_unauthenticated_provisioning_mode_ADHP_literal),
       
   736             	EFASTUnauthProvModeAllowedNo);
       
   737         }
       
   738 	    
       
   739 	   	// Now put all the updated values in DB table.
       
   740 		iFastSpecificView.PutL();	    
       
   741 	
       
   742 	    
       
   743 #ifdef USE_PAC_STORE
       
   744 	    
       
   745 		// Update PAC store password.
       
   746 	    // PAC store password should be stored in a different database, pac store db.
       
   747 	    // We can use the UI connection to save the PAC store password.
       
   748 
       
   749 		EAP_TRACE_DATA_DEBUG_SYMBIAN(
       
   750 		("CEapTlsPeapUiDataConnection::UpdateDataL: PW from UI(16 bits)",
       
   751 		iDataPtr->GetPacStorePassword().Ptr(), 
       
   752 		iDataPtr->GetPacStorePassword().Size()));
       
   753 		
       
   754 		TBuf8<KMaxPasswordLengthInDB> tmpSetPacStorePw8;
       
   755 		tmpSetPacStorePw8.Copy(iDataPtr->GetPacStorePassword());		
       
   756 		
       
   757 		EAP_TRACE_DATA_DEBUG_SYMBIAN(
       
   758 		("CEapTlsPeapUiDataConnection::UpdateDataL: PW to PAC store DB(8 bits)",
       
   759 		tmpSetPacStorePw8.Ptr(), 
       
   760 		tmpSetPacStorePw8.Size()));
       
   761 
       
   762 	    iUiConn->GetPacStoreDb()->SetPacStoreDataL(
       
   763 	    	cf_str_EAP_FAST_PAC_store_password_literal(),
       
   764 	    	tmpSetPacStorePw8);	    
       
   765 			    
       
   766 /*****************TEST*************/
       
   767 	    
       
   768 #ifdef   PAC_STORE_DATA_HACK
       
   769 
       
   770 		TBuf<4> tmpSetPacStoreData1;
       
   771 		TBuf<4> tmpSetPacStoreData2;
       
   772 		TBuf<4> tmpSetPacStoreData3;
       
   773 		TBuf<4> tmpSetPacStoreData4;
       
   774 		TBuf<4> tmpSetPacStoreData5;
       
   775 		TBuf<4> tmpSetPacStoreData6;
       
   776 		RArray<SInfoEntry> infoarray1;
       
   777 		RArray<SInfoEntry> infoarray2;
       
   778 
       
   779 		tmpSetPacStoreData1.Copy(iDataPtr->GetUsePAC_Store_Group_Reference());		
       
   780 		tmpSetPacStoreData2.Copy(iDataPtr->GetUsePAC_Store_Group_Value());		
       
   781 		tmpSetPacStoreData3.Copy(iDataPtr->GetUsePAC_Store_AID_Reference());		
       
   782 		tmpSetPacStoreData4.Copy(iDataPtr->GetUsePAC_Store_AID_Value());		
       
   783 		tmpSetPacStoreData6.Copy(iDataPtr->GetUsePAC_Store_PAC_Reference());		
       
   784 		tmpSetPacStoreData6.Copy(iDataPtr->GetUsePAC_Store_PAC_Value());		
       
   785 		
       
   786 			EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiDataConnection::UpdateDataL: tmpSetPacStoreData=%S\n"),
       
   787 					&tmpSetPacStorePw));
       
   788 
       
   789 	    iUiConn->GetPacStoreDb()->SetPacStoreDataL(
       
   790 	    		KPacStoreGroupReference,
       
   791 	    		tmpSetPacStoreData1,
       
   792 	    		KPacStoreGroupReference);	    
       
   793 	    iUiConn->GetPacStoreDb()->SetPacStoreDataL(
       
   794 	    		KPacStoreGroupValue,
       
   795 	    		tmpSetPacStoreData2,
       
   796 	    		KPacStoreGroupReference);	    
       
   797 	    iUiConn->GetPacStoreDb()->SetPacStoreDataL(
       
   798 	    		KPacStoreAIDReference,
       
   799 	    		tmpSetPacStoreData3,
       
   800 	    		KPacStoreAIDReference);	    
       
   801 	    iUiConn->GetPacStoreDb()->SetPacStoreDataL(
       
   802 	    		KPacStoreAIDValue,
       
   803 	    		tmpSetPacStoreData4,
       
   804 	    		KPacStoreAIDReference);	    
       
   805 	    iUiConn->GetPacStoreDb()->SetPacStoreDataL(
       
   806 	    		KPacStorePACReference,
       
   807 	    		tmpSetPacStoreData5,
       
   808 	    		KPacStorePACValue);	    
       
   809 	    iUiConn->GetPacStoreDb()->SetPacStoreDataL(
       
   810 	    		KPacStorePACValue,
       
   811 	    		tmpSetPacStoreData6,
       
   812 	    		KPacStorePACReference);	    
       
   813 		
       
   814 #endif
       
   815 	    
       
   816 		/*****************TEST*************/	    
       
   817 	    
       
   818 #endif // End: #ifdef USE_PAC_STORE	    
       
   819 	    
       
   820 	} // End: if(iUiConn->GetEapType() == eap_type_fast)    
       
   821     
       
   822 #endif // End: #ifdef USE_FAST_EAP_TYPE
       
   823 
       
   824 	EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiDataConnection::UpdateDataL: End\n")));    
       
   825 
       
   826 } // CEapTlsPeapUiDataConnection::UpdateDataL()
       
   827 
       
   828 // End of file