eapol/eapol_framework/eapol_symbian/am/type/tls_peap/symbian/eap_am_type_tls_peap_symbian.cpp
changeset 34 ad1f037f1ac2
parent 26 9abfd4f00d37
child 36 c98682f98478
equal deleted inserted replaced
31:372d2d6c5cf9 34:ad1f037f1ac2
    14 * Description:  EAP and WLAN authentication protocols.
    14 * Description:  EAP and WLAN authentication protocols.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: 247.2.42 %
    19 * %version: 247.2.68 %
    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
    81 	#include "eap_am_file_input_symbian.h"
    81 	#include "eap_am_file_input_symbian.h"
    82 #endif
    82 #endif
    83 
    83 
    84 #include "EapConfigToolsSymbian.h"
    84 #include "EapConfigToolsSymbian.h"
    85 #include "EapConversion.h"
    85 #include "EapConversion.h"
    86 
    86 #include "EapPluginTools.h"
    87 #include <EapPluginTools.h>
    87 
    88 #include <mmtsy_names.h>
    88 #include <mmtsy_names.h>
    89 
    89 
    90 
    90 
    91 const TUint KMaxSqlQueryLength = 512;
    91 const TUint KMaxSqlQueryLength = 512;
    92 const TUint KMaxDBFieldNameLength = 255;
    92 const TUint KMaxDBFieldNameLength = 255;
   356 //--------------------------------------------------
   356 //--------------------------------------------------
   357 
   357 
   358 //
   358 //
   359 void eap_am_type_tls_peap_symbian_c::ConstructL()
   359 void eap_am_type_tls_peap_symbian_c::ConstructL()
   360 {
   360 {
       
   361 	TInt error = m_session.Connect();
       
   362 	EAP_TRACE_DEBUG_SYMBIAN((_L("eap_am_type_tls_peap_symbian_c::ConstructL(): - m_session.Connect(), error=%d\n"), error));
       
   363 	User::LeaveIfError(error);
       
   364 
   361 	// Open/create database
   365 	// Open/create database
   362 	EapTlsPeapUtils::OpenDatabaseL(m_database, m_session, m_index_type, m_index, m_tunneling_type, m_current_eap_type);
   366 	EapTlsPeapUtils::OpenDatabaseL(m_database, m_session, m_index_type, m_index, m_tunneling_type, m_current_eap_type);
   363 
   367 
   364 	m_cert_if = CEapTlsPeapCertInterface::NewL(m_am_tools, this);
   368 	m_cert_if = CEapTlsPeapCertInterface::NewL(m_am_tools, this);
   365 
   369 
   387 #endif	// End: #ifdef USE_FAST_EAP_TYPE
   391 #endif	// End: #ifdef USE_FAST_EAP_TYPE
   388 #endif // End: 	#ifdef USE_PAC_STORE
   392 #endif // End: 	#ifdef USE_PAC_STORE
   389 
   393 
   390 	m_notifier_data_to_user = new(ELeave) CEapAuthNotifier::TEapDialogInfo;
   394 	m_notifier_data_to_user = new(ELeave) CEapAuthNotifier::TEapDialogInfo;
   391 	m_notifier_data_pckg_to_user = new(ELeave) TPckg<CEapAuthNotifier::TEapDialogInfo> (*m_notifier_data_to_user);
   395 	m_notifier_data_pckg_to_user = new(ELeave) TPckg<CEapAuthNotifier::TEapDialogInfo> (*m_notifier_data_to_user);
   392 
       
   393 		EAP_TRACE_DATA_DEBUG(
       
   394 			m_am_tools,
       
   395 			TRACE_FLAGS_DEFAULT,
       
   396 			(EAPL("eap_am_type_tls_peap_symbian_c::ConstructL m_notifier_data_pckg_to_user"),
       
   397 			m_notifier_data_pckg_to_user->Ptr(),
       
   398 			m_notifier_data_pckg_to_user->Size()));	
       
   399 
       
   400 
       
   401 #ifdef USE_FAST_EAP_TYPE
       
   402 
       
   403 #endif	// End: #ifdef USE_FAST_EAP_TYPE	
       
   404 	
       
   405 
   396 
   406 }
   397 }
   407 
   398 
   408 //--------------------------------------------------
   399 //--------------------------------------------------
   409 
   400 
   541 	m_database.Close();
   532 	m_database.Close();
   542 	m_session.Close();
   533 	m_session.Close();
   543 
   534 
   544 	delete m_notifier_data_to_user;
   535 	delete m_notifier_data_to_user;
   545 	delete m_notifier_data_pckg_to_user;
   536 	delete m_notifier_data_pckg_to_user;
   546 
       
   547 
       
   548 #ifdef USE_FAST_EAP_TYPE
       
   549 	
       
   550 #endif	// End: #ifdef USE_FAST_EAP_TYPE	
       
   551 		
   537 		
   552 	delete m_cert_if;
   538 	delete m_cert_if;
   553 
   539 
   554 	delete m_ca_certificate;
   540 	delete m_ca_certificate;
   555 	delete m_own_certificate;
   541 	delete m_own_certificate;
   565 
   551 
   566 #ifdef USE_PAC_STORE
   552 #ifdef USE_PAC_STORE
   567 	
   553 	
   568 	delete iPacStoreDb;
   554 	delete iPacStoreDb;
   569 	
   555 	
   570 #endif	// End: #ifdef USE_PAC_STORE	
   556 #endif // #ifdef USE_PAC_STORE	
       
   557 
   571 	delete iEapAuthNotifier;
   558 	delete iEapAuthNotifier;
   572 	iEapAuthNotifier = 0;
   559 	iEapAuthNotifier = 0;
   573 
   560 
   574 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   561 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
   575 }
   562 }
   576 //--------------------------------------------------
   563 //--------------------------------------------------
   577 
   564 
   578 EAP_FUNC_EXPORT void eap_am_type_tls_peap_symbian_c::DlgComplete( TInt aStatus )
   565 EAP_FUNC_EXPORT void eap_am_type_tls_peap_symbian_c::DlgComplete( TInt aStatus )
   579 	{
   566 {
       
   567 	EAP_TRACE_DEBUG(
       
   568 		m_am_tools,
       
   569 		TRACE_FLAGS_DEFAULT,
       
   570 		(EAPL("TLS: function: eap_am_type_tls_peap_symbian_c::DlgComplete(): m_notifier_complete=%d, m_state=%d\n"),
       
   571 		m_notifier_complete,
       
   572 		m_state));
       
   573 
       
   574 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_type_tls_peap_symbian_c::DlgComplete()");
       
   575 
   580 #ifdef USE_FAST_EAP_TYPE
   576 #ifdef USE_FAST_EAP_TYPE
   581 	m_userAction = EEapFastNotifierUserActionOk;
   577 	m_userAction = EEapFastNotifierUserActionOk;
   582 #endif
   578 #endif
       
   579 
   583 	eap_status_e status = m_am_tools->convert_am_error_to_eapol_error(aStatus);
   580 	eap_status_e status = m_am_tools->convert_am_error_to_eapol_error(aStatus);
   584 	
   581 
   585 	
       
   586 	if(m_notifier_complete)
   582 	if(m_notifier_complete)
   587 		{
   583 	{
   588   	EAP_TRACE_DEBUG_SYMBIAN(
   584 		EAP_TRACE_DATA_DEBUG(
   589   			(_L("m_notifier_data_pckg_to_user"),
   585 			m_am_tools,
   590   			m_notifier_data_pckg_to_user->Ptr(),
   586 			TRACE_FLAGS_DEFAULT,
   591   			m_notifier_data_pckg_to_user->Size()));	    		
   587 			(EAPL( "m_notifier_data_pckg_to_user" ),
   592   	if ( aStatus == KErrCancel )
   588 			m_notifier_data_pckg_to_user->Ptr(),
   593   		{
   589 			m_notifier_data_pckg_to_user->Size() ) );
   594   		EAP_TRACE_DEBUG_SYMBIAN(
   590 
   595   				(_L("eap_am_type_tls_peap_symbian_c::DlgComplete - User cancelled the dialog")));
   591 		if ( aStatus == KErrCancel )
       
   592 		{
       
   593 			EAP_TRACE_DEBUG(
       
   594 				m_am_tools,
       
   595 				TRACE_FLAGS_DEFAULT,
       
   596 				(EAPL("TLS: function: eap_am_type_tls_peap_symbian_c::DlgComplete(): User cancelled the dialog\n")));
       
   597 
   596 #ifdef USE_FAST_EAP_TYPE
   598 #ifdef USE_FAST_EAP_TYPE
   597   		m_userAction = EEapFastNotifierUserActionCancel;	
   599 			m_userAction = EEapFastNotifierUserActionCancel;	
   598 #endif
   600 #endif
   599   		}		
   601 		}		
   600   	else if( aStatus != KErrNone )
   602 		else if( aStatus != KErrNone )
   601   		{
   603 		{
   602   		EAP_TRACE_DEBUG_SYMBIAN(
   604 			EAP_TRACE_DEBUG(
   603   			(_L("eap_am_type_tls_peap_symbian_c::DlgComplete - ERROR: dialog error=%d"),
   605 				m_am_tools,
   604   			aStatus));	
   606 				TRACE_FLAGS_DEFAULT,
   605 	  	TBuf8<KMaxNotifItemLength> userNameUtf8;
   607 				(EAPL("ERROR: TLS: function: eap_am_type_tls_peap_symbian_c::DlgComplete(): dialog error=%d\n"),
   606 	  	TBuf8<KMaxUiDataLength> challengeUtf8;
   608 				aStatus));
       
   609 
       
   610 			TBuf8<KMaxNotifItemLength> userNameUtf8;
       
   611 			TBuf8<KMaxUiDataLength> challengeUtf8;
   607 			userNameUtf8.Zero();
   612 			userNameUtf8.Zero();
   608 			challengeUtf8.Zero();
   613 			challengeUtf8.Zero();
   609 			
   614 
   610     	CompleteQueryTtlsPapUserNameAndPassword(
   615 			CompleteQueryTtlsPapUserNameAndPassword(
   611        	status, userNameUtf8, challengeUtf8 );  
   616 				status, userNameUtf8, challengeUtf8 );
   612   		return; // m_am_tools->convert_am_error_to_eapol_error(aStatus);		
   617 
   613   		}
   618 			return; // m_am_tools->convert_am_error_to_eapol_error(aStatus);		
   614 
   619 		}
   615   	if ( m_notifier_data_to_user->iPassword.Size() > 0 )
   620 
   616   		{
   621 		if ( m_notifier_data_to_user->iPassword.Size() > 0 )
   617   		HBufC8* notifier_data8 = NULL;
   622 		{
       
   623 			HBufC8* notifier_data8 = NULL;
   618 			TRAPD(err, notifier_data8 = HBufC8::NewL(m_notifier_data_to_user->iPassword.Size()));
   624 			TRAPD(err, notifier_data8 = HBufC8::NewL(m_notifier_data_to_user->iPassword.Size()));
   619 			if (err)
   625 			if (err)
   620 				{
   626 			{
   621 				return;	
   627 				return;	
   622 				}
   628 			}
   623 			TPtr8 notifier_dataPtr8 = notifier_data8->Des();
   629 			TPtr8 notifier_dataPtr8 = notifier_data8->Des();
   624 			
   630 
   625 			notifier_dataPtr8.Copy(m_notifier_data_to_user->iPassword); // Unicode -> ascii.
   631 			notifier_dataPtr8.Copy(m_notifier_data_to_user->iPassword); // Unicode -> ascii.
   626 			EAP_TRACE_DEBUG_SYMBIAN(
   632 
   627 				(_L("eap_am_type_tls_peap_symbian_c::DlgComplete Data copy done")));
   633 			EAP_TRACE_DATA_DEBUG(
   628 		    
   634 				m_am_tools,
   629 			EAP_TRACE_DATA_DEBUG_SYMBIAN(
   635 				TRACE_FLAGS_DEFAULT,
   630   			("eap_am_type_tls_peap_symbian_c::DlgComplete PW from UI (8bits)",
   636 				(EAPL( "eap_am_type_tls_peap_symbian_c::DlgComplete PW from UI (8bits)" ),
   631 				notifier_dataPtr8.Ptr(), 
   637 				notifier_dataPtr8.Ptr(), 
   632 				notifier_dataPtr8.Size()));	    
   638 				notifier_dataPtr8.Size() ) );
   633 		    
   639 
   634 #ifdef USE_FAST_EAP_TYPE
   640 #ifdef USE_FAST_EAP_TYPE
   635 			status = m_userResponse.set_copy_of_buffer(
   641 			status = m_userResponse.set_copy_of_buffer(
   636 				notifier_dataPtr8.Ptr(),
   642 				notifier_dataPtr8.Ptr(),
   637 				notifier_dataPtr8.Size());
   643 				notifier_dataPtr8.Size());
   638 #endif			
   644 #endif			
   639   		CleanupStack::PopAndDestroy( notifier_data8 );
   645 			CleanupStack::PopAndDestroy( notifier_data8 );
   640   		}
   646 		}
   641 		}
   647 	}
   642   m_notifier_complete = 0;
   648 
       
   649 	m_notifier_complete = 0;
   643 
   650 
   644 	if ( m_state == EPapChallenge)
   651 	if ( m_state == EPapChallenge)
   645 		{
   652 	{
   646   	TBuf8<KMaxNotifItemLength> userNameUtf8;
   653 		EAP_TRACE_DEBUG(
   647   	TBuf8<KMaxUiDataLength> challengeUtf8;
   654 			m_am_tools,
   648 		userNameUtf8.Zero();
   655 			TRACE_FLAGS_DEFAULT,
   649 		challengeUtf8.Zero();
   656 			(EAPL("TLS: function: eap_am_type_tls_peap_symbian_c::DlgComplete(): EPapChallenge\n")));
   650 
   657 
   651 		if (m_notifier_data_to_user->iUsername.Size()>0)
   658 		m_state = EPapUserNameAndPassword;
       
   659 		TEapExpandedType aEapType(*EapExpandedTypeTtlsPap.GetType());
       
   660 
       
   661 		if (iEapAuthNotifier == 0)
       
   662 		{
       
   663 			TRAPD(err, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
       
   664 			if (err)
   652 			{
   665 			{
   653 			const TPtrC16 unicode_uname(
   666 			eap_variable_data_c userNameUtf8( m_am_tools );
   654 				reinterpret_cast<unsigned short *>(&m_notifier_data_to_user->iUsername),
   667 			eap_variable_data_c passwordUtf8( m_am_tools );
   655 				m_notifier_data_to_user->iUsername.Size()); // Length in unicode characters
   668 		
   656 	
   669 			(void) m_tls_am_partner->
   657 	  	CnvUtfConverter::ConvertFromUnicodeToUtf8( userNameUtf8, unicode_uname );
   670 			    complete_query_ttls_pap_username_and_password(
       
   671 				    &userNameUtf8, &passwordUtf8, eap_status_process_general_error);	
       
   672 				return;
   658 			}
   673 			}
   659   	EAP_TRACE_DATA_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (
   674 		}
   660   		EAPL( "userNameUtf8" ),
   675 
   661   		userNameUtf8.Ptr(),
   676 
   662   		userNameUtf8.Size() ) );
   677 		TTtlsPapDbInfo aInDbInfo;
   663 
   678 		TRAPD(err2, ReadTtlsPapDbL(aInDbInfo));
   664 		if (m_notifier_data_to_user->iUidata.Size()>0)
   679 		if (err2)
       
   680 		{
       
   681 			eap_variable_data_c userNameUtf8( m_am_tools );
       
   682 			eap_variable_data_c passwordUtf8( m_am_tools );
       
   683 		
       
   684 			(void) m_tls_am_partner->
       
   685 			    complete_query_ttls_pap_username_and_password(
       
   686 				    &userNameUtf8, &passwordUtf8, eap_status_process_general_error);	
       
   687 			return;
       
   688 		}
       
   689 
       
   690 		m_notifier_data_to_user->iPasswordPromptEnabled = aInDbInfo.iUsrPwdInfo.iPasswordPromptEnabled;
       
   691 
       
   692 		if (m_notifier_data_to_user->iPasswordPromptEnabled ||
       
   693 		(aInDbInfo.iUsrPwdInfo.iUserName.Size() == 0 &&
       
   694 		aInDbInfo.iUsrPwdInfo.iPassword.Size() == 0))
       
   695 		{
       
   696 			m_notifier_data_to_user->iUsername.Zero();
       
   697 			m_notifier_data_to_user->iPassword.Zero();
       
   698 
       
   699 			TRAPD(err3,SetTtlsPapColumnToNullL( cf_str_EAP_TLS_PEAP_ttls_pap_password_literal ));
       
   700 			if (err3)
   665 			{
   701 			{
   666 			const TPtrC16 unicode_pw(
   702 			eap_variable_data_c userNameUtf8( m_am_tools );
   667 				reinterpret_cast<unsigned short *>(&m_notifier_data_to_user->iUidata),
   703 			eap_variable_data_c passwordUtf8( m_am_tools );
   668 				m_notifier_data_to_user->iUidata.Size()); // Length in unicode characters
   704 		
   669 	
   705 			(void) m_tls_am_partner->
   670 	  	CnvUtfConverter::ConvertFromUnicodeToUtf8( challengeUtf8, unicode_pw );  
   706 			    complete_query_ttls_pap_username_and_password(
   671   		} 	
   707 				    &userNameUtf8, &passwordUtf8, eap_status_process_general_error);	
   672   	EAP_TRACE_DATA_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (
   708 			return;
   673   		EAPL( "challengeUtf8" ),
   709 			}
   674   		challengeUtf8.Ptr(),
   710 
   675   		challengeUtf8.Size() ) );
   711 			if (iEapAuthNotifier == 0)
   676 
   712 			{
   677     	CompleteQueryTtlsPapUserNameAndPassword(
   713 				TRAPD(err4, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
   678        	status, userNameUtf8, challengeUtf8 );  
   714 				if (err4)
   679 		}
   715 				{
   680 	if ( m_state == EPapUserNameAndPassword )
   716 				eap_variable_data_c userNameUtf8( m_am_tools );
   681 		{
   717 				eap_variable_data_c passwordUtf8( m_am_tools );
   682   	TBuf8<KMaxNotifItemLength> userNameUtf8;
   718 			
   683   	TBuf8<KMaxNotifItemLength> passwordUtf8;
   719 				(void) m_tls_am_partner->
       
   720 				    complete_query_ttls_pap_username_and_password(
       
   721 					    &userNameUtf8, &passwordUtf8, eap_status_process_general_error);	
       
   722 				return;
       
   723 				}
       
   724 			}
       
   725 			else
       
   726 			{
       
   727 				TRAPD(err5,iEapAuthNotifier->Cancel());
       
   728 				if (err5)
       
   729 				{
       
   730 				eap_variable_data_c userNameUtf8( m_am_tools );
       
   731 				eap_variable_data_c passwordUtf8( m_am_tools );
       
   732 			
       
   733 				(void) m_tls_am_partner->
       
   734 				    complete_query_ttls_pap_username_and_password(
       
   735 					    &userNameUtf8, &passwordUtf8, eap_status_process_general_error);	
       
   736 				return;
       
   737 				}
       
   738 			}
       
   739 
       
   740 			TRAPD(err6, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypePapAuthQueryDialog, m_notifier_data_to_user, aEapType));
       
   741 			if (err6)
       
   742 			{
       
   743 			eap_variable_data_c userNameUtf8( m_am_tools );
       
   744 			eap_variable_data_c passwordUtf8( m_am_tools );
       
   745 		
       
   746 			(void) m_tls_am_partner->
       
   747 			    complete_query_ttls_pap_username_and_password(
       
   748 				    &userNameUtf8, &passwordUtf8, eap_status_process_general_error);	
       
   749 			return;
       
   750 			}
       
   751 		}
       
   752 		else
       
   753 		{
       
   754 			m_notifier_data_to_user->iUsername = aInDbInfo.iUsrPwdInfo.iUserName;
       
   755 
       
   756 			EAP_TRACE_DATA_DEBUG(
       
   757 				m_am_tools,
       
   758 				TRACE_FLAGS_DEFAULT,
       
   759 				(EAPL("eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password(): iUserName"),
       
   760 				m_notifier_data_to_user->iUsername.Ptr(),
       
   761 				m_notifier_data_to_user->iUsername.Size()));
       
   762 
       
   763 			m_notifier_data_to_user->iPassword = aInDbInfo.iUsrPwdInfo.iPassword;
       
   764 
       
   765 			EAP_TRACE_DATA_DEBUG(
       
   766 				m_am_tools,
       
   767 				TRACE_FLAGS_DEFAULT,
       
   768 				(EAPL("eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password(): iPassword"),
       
   769 				m_notifier_data_to_user->iPassword.Ptr(),
       
   770 				m_notifier_data_to_user->iPassword.Size()));
       
   771 
       
   772 			DlgComplete(KErrNone);
       
   773 		}
       
   774 		 
       
   775 	}
       
   776 	else if ( m_state == EPapUserNameAndPassword )
       
   777 	{
       
   778 		EAP_TRACE_DEBUG(
       
   779 			m_am_tools,
       
   780 			TRACE_FLAGS_DEFAULT,
       
   781 			(EAPL("TLS: function: eap_am_type_tls_peap_symbian_c::DlgComplete(): EPapUserNameAndPassword\n")));
       
   782 
       
   783 		TBuf8<KMaxNotifItemLength> userNameUtf8;
       
   784 		TBuf8<KMaxNotifItemLength> passwordUtf8;
   684 		userNameUtf8.Zero();
   785 		userNameUtf8.Zero();
   685 		passwordUtf8.Zero();
   786 		passwordUtf8.Zero();
   686 
   787 
   687 		if (m_notifier_data_to_user->iUsername.Size()>0)
   788 		if (m_notifier_data_to_user->iUsername.Size()>0)
   688 			{
   789 		{
   689 			const TPtrC16 unicode_uname(
   790 			CnvUtfConverter::ConvertFromUnicodeToUtf8( userNameUtf8, m_notifier_data_to_user->iUsername );
   690 				reinterpret_cast<unsigned short *>(&m_notifier_data_to_user->iUsername),
   791 
   691 				m_notifier_data_to_user->iUsername.Size()); // Length in unicode characters
   792 			EAP_TRACE_DATA_DEBUG(
   692 	
   793 				m_am_tools,
   693 	  	CnvUtfConverter::ConvertFromUnicodeToUtf8( userNameUtf8, unicode_uname );
   794 				TRACE_FLAGS_DEFAULT,
   694 	  	EAP_TRACE_DATA_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (
   795 				(EAPL( "userNameUtf8" ),
   695 	  		EAPL( "userNameUtf8" ),
   796 				userNameUtf8.Ptr(),
   696 	  		userNameUtf8.Ptr(),
   797 				userNameUtf8.Size() ) );
   697 	  		userNameUtf8.Size() ) );
   798 		}
   698 			}
   799 
   699 		if (m_notifier_data_to_user->iPassword.Size()>0)
   800 		if (m_notifier_data_to_user->iPassword.Size()>0)
   700 			{
   801 		{
   701 			const TPtrC16 unicode_pw(
   802 			CnvUtfConverter::ConvertFromUnicodeToUtf8( passwordUtf8, m_notifier_data_to_user->iPassword );   	
   702 				reinterpret_cast<unsigned short *>(&m_notifier_data_to_user->iPassword),
   803 		}
   703 				m_notifier_data_to_user->iPassword.Size()); // Length in unicode characters
   804 
   704 	
   805 		EAP_TRACE_DATA_DEBUG(
   705 	  	CnvUtfConverter::ConvertFromUnicodeToUtf8( passwordUtf8, unicode_pw );   	
   806 			m_am_tools,
   706   		}
   807 			TRACE_FLAGS_DEFAULT,
   707   	EAP_TRACE_DATA_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT, (
   808 			(EAPL( "passwordUtf8" ),
   708   		EAPL( "passwordUtf8" ),
   809 			passwordUtf8.Ptr(),
   709   		passwordUtf8.Ptr(),
   810 			passwordUtf8.Size() ) );
   710   		passwordUtf8.Size() ) );
   811 
   711 
   812 		CompleteQueryTtlsPapUserNameAndPassword(
   712     	CompleteQueryTtlsPapUserNameAndPassword(
   813 			status, userNameUtf8, passwordUtf8 );  
   713        	status, userNameUtf8, passwordUtf8 );  
   814 
   714 	  		
   815 		TTtlsPapDbInfo aInDbInfo;
   715 			TTtlsPapDbInfo aInDbInfo;
   816 		aInDbInfo.iUsrPwdInfo.iPasswordPromptEnabled = m_notifier_data_to_user->iPasswordPromptEnabled;
   716 			aInDbInfo.iUsrPwdInfo.iPasswordPromptEnabled = m_notifier_data_to_user->iPasswordPromptEnabled;
   817 		aInDbInfo.iUsrPwdInfo.iUserName.Copy(userNameUtf8);
   717 			aInDbInfo.iUsrPwdInfo.iUserName.Copy(userNameUtf8);
   818 		aInDbInfo.iUsrPwdInfo.iPassword.Copy(passwordUtf8);
   718 			aInDbInfo.iUsrPwdInfo.iPassword.Copy(passwordUtf8);
   819 
   719 		
   820 		TRAPD(err1, WriteTtlsPapDbL( aInDbInfo));
   720 			TRAPD(err1, WriteTtlsPapDbL( aInDbInfo));
   821 		if (err1)
   721 			if (err1)
   822 		{
   722 				{
   823 			// continue
   723 					// continue
   824 		}
   724 				}
   825 	}
   725  		}
       
   726 #ifdef USE_FAST_EAP_TYPE
   826 #ifdef USE_FAST_EAP_TYPE
   727 	else if ( m_state == EPasswordCancel ||
   827 	else if ( m_state == EPasswordCancel
   728 		 m_state == EMasterkeyQuery ||
   828 		|| m_state == EMasterkeyQuery
   729 		 m_state == EPasswordQuery ||
   829 		|| m_state == EPasswordQuery
   730 		 m_state == EWrongPassword ||
   830 		|| m_state == EWrongPassword
   731 		 m_state == EFilePasswordQuery )
   831 		|| m_state == EFilePasswordQuery )
   732 		{
   832 	{
       
   833 		EAP_TRACE_DEBUG(
       
   834 			m_am_tools,
       
   835 			TRACE_FLAGS_DEFAULT,
       
   836 			(EAPL("TLS: function: eap_am_type_tls_peap_symbian_c::DlgComplete(): else\n")));
       
   837 
   733 		m_eap_fast_completion_status = m_partner->set_timer(
   838 		m_eap_fast_completion_status = m_partner->set_timer(
   734 				this,
   839 			this,
   735 				KHandleReadPacstoreTimerID, 
   840 			KHandleReadPacstoreTimerID, 
   736 				&aStatus,
   841 			&aStatus,
   737 				0);
   842 			0);
   738 		return;
   843 		return;
   739 		}
   844 	}
   740 #endif		
   845 #endif //#ifdef USE_FAST_EAP_TYPE
   741 		
   846 
   742 	}
   847 }
   743 
   848 
   744 //--------------------------------------------------
   849 //--------------------------------------------------
   745 
   850 
   746 //
   851 //
   747 void eap_am_type_tls_peap_symbian_c::RunL()
   852 void eap_am_type_tls_peap_symbian_c::RunL()
   751 	EAP_TRACE_DEBUG_SYMBIAN(
   856 	EAP_TRACE_DEBUG_SYMBIAN(
   752 		(_L("eap_am_type_tls_peap_symbian_c::RunL - iStatus.Int()=%d, m_state=%d "),
   857 		(_L("eap_am_type_tls_peap_symbian_c::RunL - iStatus.Int()=%d, m_state=%d "),
   753 		iStatus.Int() , m_state));
   858 		iStatus.Int() , m_state));
   754 	
   859 	
   755 #ifdef USE_FAST_EAP_TYPE
   860 #ifdef USE_FAST_EAP_TYPE
   756 	eap_status_e status(eap_status_ok);
       
   757 
       
   758 
       
   759 	if (m_state == ENone)
   861 	if (m_state == ENone)
   760 		{
   862 		{
   761 		return;		
   863 		return;		
   762 		}
   864 		}
   763 
   865 
  1228 #endif //#if defined(USE_FAST_EAP_TYPE)
  1330 #endif //#if defined(USE_FAST_EAP_TYPE)
  1229 
  1331 
  1230 //--------------------------------------------------
  1332 //--------------------------------------------------
  1231 
  1333 
  1232 //
  1334 //
  1233 void eap_am_type_tls_peap_symbian_c::notify_configuration_error(
  1335 EAP_FUNC_EXPORT void eap_am_type_tls_peap_symbian_c::notify_configuration_error(
  1234 	const eap_status_e configuration_status)
  1336 	const eap_status_e configuration_status)
  1235 {
  1337 {
  1236 	if (m_is_client == true)
  1338 	if (m_is_client == true)
  1237 	{
  1339 	{
  1238 		EAP_UNREFERENCED_PARAMETER(configuration_status); // in release
  1340 		EAP_UNREFERENCED_PARAMETER(configuration_status); // in release
  1464 
  1566 
  1465 	if (m_is_client == true)
  1567 	if (m_is_client == true)
  1466 	{
  1568 	{
  1467 		eap_variable_data_c use_automatic_ca_certificate(m_am_tools);
  1569 		eap_variable_data_c use_automatic_ca_certificate(m_am_tools);
  1468 
  1570 
  1469 		eap_status_e status = m_partner->read_configure(
  1571 		eap_status_e status = type_configure_read(
  1470 			cf_str_EAP_TLS_PEAP_use_automatic_ca_certificate.get_field(),
  1572 			cf_str_EAP_TLS_PEAP_use_automatic_ca_certificate.get_field(),
  1471 			&use_automatic_ca_certificate);
  1573 			&use_automatic_ca_certificate);
  1472 		if (status == eap_status_ok
  1574 		if (status == eap_status_ok
  1473 			&& use_automatic_ca_certificate.get_is_valid_data() == true)
  1575 			&& use_automatic_ca_certificate.get_is_valid_data() == true)
  1474 		{
  1576 		{
  1578 
  1680 
  1579 #if defined(USE_EAP_TLS_SESSION_TICKET)
  1681 #if defined(USE_EAP_TLS_SESSION_TICKET)
  1580 	{
  1682 	{
  1581 		eap_variable_data_c use_session_ticket(m_am_tools);
  1683 		eap_variable_data_c use_session_ticket(m_am_tools);
  1582 
  1684 
  1583 		eap_status_e status = m_partner->read_configure(
  1685 		eap_status_e status = type_configure_read(
  1584 			cf_str_EAP_TLS_PEAP_use_session_ticket.get_field(),
  1686 			cf_str_EAP_TLS_PEAP_use_session_ticket.get_field(),
  1585 			&use_session_ticket);
  1687 			&use_session_ticket);
  1586 		if (status == eap_status_ok
  1688 		if (status == eap_status_ok
  1587 			&& use_session_ticket.get_is_valid_data() == true)
  1689 			&& use_session_ticket.get_is_valid_data() == true)
  1588 		{
  1690 		{
  1651 		
  1753 		
  1652 		eap_status_e status(eap_status_ok);
  1754 		eap_status_e status(eap_status_ok);
  1653 
  1755 
  1654 		if (m_current_eap_type == eap_type_tls)
  1756 		if (m_current_eap_type == eap_type_tls)
  1655 		{
  1757 		{
  1656 			status = m_partner->read_configure(
  1758 			status = type_configure_read(
  1657 				cf_str_EAP_TLS_max_session_validity_time.get_field(),
  1759 				cf_str_EAP_TLS_max_session_validity_time.get_field(),
  1658 				&sessionTimeFromFile);
  1760 				&sessionTimeFromFile);
  1659 		}
  1761 		}
  1660 		else if (m_current_eap_type == eap_type_peap)
  1762 		else if (m_current_eap_type == eap_type_peap)
  1661 		{
  1763 		{
  1662 			status = m_partner->read_configure(
  1764 			status = type_configure_read(
  1663 				cf_str_EAP_PEAP_max_session_validity_time.get_field(),
  1765 				cf_str_EAP_PEAP_max_session_validity_time.get_field(),
  1664 				&sessionTimeFromFile);
  1766 				&sessionTimeFromFile);
  1665 		}
  1767 		}
  1666 		else if (m_current_eap_type == eap_type_ttls)
  1768 		else if (m_current_eap_type == eap_type_ttls)
  1667 		{
  1769 		{
  1668 			status = m_partner->read_configure(
  1770 			status = type_configure_read(
  1669 				cf_str_EAP_TTLS_max_session_validity_time.get_field(),
  1771 				cf_str_EAP_TTLS_max_session_validity_time.get_field(),
  1670 				&sessionTimeFromFile);
  1772 				&sessionTimeFromFile);
  1671 		}
  1773 		}
  1672 		else if (m_current_eap_type == eap_type_ttls_plain_pap)
  1774 		else if (m_current_eap_type == eap_type_ttls_plain_pap)
  1673 		{
  1775 		{
  1674 			// read PAP session time
  1776 			// read PAP session time
  1675 			status = m_partner->read_configure(
  1777 			status = type_configure_read(
  1676 				cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time.get_field(),
  1778 				cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time.get_field(),
  1677 				&sessionTimeFromFile );
  1779 				&sessionTimeFromFile );
  1678 		}
  1780 		}
  1679 #if defined(USE_FAST_EAP_TYPE)
  1781 #if defined(USE_FAST_EAP_TYPE)
  1680 		else if (m_current_eap_type == eap_type_fast)
  1782 		else if (m_current_eap_type == eap_type_fast)
  1681 		{
  1783 		{
  1682 			status = m_partner->read_configure(
  1784 			status = type_configure_read(
  1683 				cf_str_EAP_FAST_max_session_validity_time.get_field(),
  1785 				cf_str_EAP_FAST_max_session_validity_time.get_field(),
  1684 				&sessionTimeFromFile);
  1786 				&sessionTimeFromFile);
  1685 		}
  1787 		}
  1686 #endif
  1788 #endif
  1687 		else
  1789 		else
  2035 
  2137 
  2036 #endif // #if defined(USE_FAST_EAP_TYPE)
  2138 #endif // #if defined(USE_FAST_EAP_TYPE)
  2037 
  2139 
  2038 //--------------------------------------------------
  2140 //--------------------------------------------------
  2039 
  2141 
  2040 eap_status_e eap_am_type_tls_peap_symbian_c::reset()
  2142 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::reset()
  2041 {
  2143 {
  2042 
  2144 
  2043 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
  2145 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
  2044 }
  2146 }
  2045 
  2147 
  3245 	
  3347 	
  3246 	EAP_TRACE_DEBUG(m_am_tools, 
  3348 	EAP_TRACE_DEBUG(m_am_tools, 
  3247 		TRACE_FLAGS_DEFAULT, 
  3349 		TRACE_FLAGS_DEFAULT, 
  3248 		(EAPL("eap_am_type_tls_peap_symbian_c::type_configure_read - Start\n")));
  3350 		(EAPL("eap_am_type_tls_peap_symbian_c::type_configure_read - Start\n")));
  3249 	
  3351 	
       
  3352 	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: eap_am_type_tls_peap_symbian_c::type_configure_read()");
       
  3353 
       
  3354 
  3250 	if (m_current_eap_type == eap_type_peap
  3355 	if (m_current_eap_type == eap_type_peap
  3251 #if defined(USE_TTLS_EAP_TYPE)
  3356 #if defined(USE_TTLS_EAP_TYPE)
  3252 		|| m_current_eap_type == eap_type_ttls
  3357 		|| m_current_eap_type == eap_type_ttls
  3253 #endif // #if defined(USE_TTLS_EAP_TYPE)
  3358 #endif // #if defined(USE_TTLS_EAP_TYPE)
  3254 #if defined(USE_FAST_EAP_TYPE)
  3359 #if defined(USE_FAST_EAP_TYPE)
  3391 				// This field is used only for Normal EAP types. This is illegal here.
  3496 				// This field is used only for Normal EAP types. This is illegal here.
  3392 				return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_type);
  3497 				return EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_configure_type);
  3393 			}
  3498 			}
  3394 		}
  3499 		}
  3395 	} // End of if (m_current_eap_type == eap_type_peap
  3500 	} // End of if (m_current_eap_type == eap_type_peap
  3396 	
  3501 
  3397 	TRAPD(err, type_configure_readL(
  3502 	TRAPD(err, type_configure_readL(
  3398 		field->get_field(),
  3503 		field->get_field(),
  3399 		field->get_field_length(),
  3504 		field->get_field_length(),
  3400 		data));
  3505 		data));
  3401 	if (err != KErrNone) 
  3506 	if (err != KErrNone) 
  3402 	{	
  3507 	{	
  3403 		status = m_am_tools->convert_am_error_to_eapol_error(err);
  3508 		status = m_partner->read_configure(field, data);
  3404 	}
  3509 	}
  3405 
  3510 
  3406 	m_am_tools->trace_configuration(
  3511 	m_am_tools->trace_configuration(
  3407 		status,
  3512 		status,
  3408 		field,
  3513 		field,
  3409 		data);
  3514 		data);
  3410         
       
  3411 	EAP_TRACE_DEBUG(m_am_tools, 
       
  3412 		TRACE_FLAGS_DEFAULT, 
       
  3413 		(EAPL("eap_am_type_tls_peap_symbian_c::type_configure_read - End\n")));
       
  3414 
  3515 
  3415 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3516 	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3416 	return EAP_STATUS_RETURN(m_am_tools, status);
  3517 	return EAP_STATUS_RETURN(m_am_tools, status);
  3417 }
  3518 }
  3418 
  3519 
  3853 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
  3954 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
  3854 }
  3955 }
  3855 
  3956 
  3856 //--------------------------------------------------
  3957 //--------------------------------------------------
  3857 
  3958 
       
  3959 eap_status_e eap_am_type_tls_peap_symbian_c::select_cipher_suite(
       
  3960 	const bool select_all_cipher_suites,
       
  3961 	const tls_cipher_suites_e test_cipher_suite,
       
  3962 	const TAlgorithmId testcertAlgorithm,
       
  3963 	const TAlgorithmId certAlgorithm,
       
  3964 	eap_array_c<u16_t> * cipher_suites)
       
  3965 {
       
  3966 	EAP_TRACE_DEBUG(
       
  3967 		m_am_tools,
       
  3968 		TRACE_FLAGS_DEFAULT,
       
  3969 		(EAPL("eap_am_type_tls_peap_symbian_c::select_cipher_suite(), select_all_cipher_suites=%d, test_cipher_suite=%d, testcertAlgorithm=%d, certAlgorithm=%d\n"),
       
  3970 		select_all_cipher_suites,
       
  3971 		test_cipher_suite,
       
  3972 		testcertAlgorithm,
       
  3973 		certAlgorithm));
       
  3974 
       
  3975 	eap_status_e status(eap_status_ok);
       
  3976 
       
  3977 	// Cipher suite must be allowed AND the algorithm must match the certificates algorithm.
       
  3978 	// Also select_all_cipher_suites can be used to add all cipher suites to the list.
       
  3979 
       
  3980 	TInt found = m_allowed_cipher_suites.Find(test_cipher_suite);
       
  3981 
       
  3982 	EAP_TRACE_DEBUG(
       
  3983 		m_am_tools,
       
  3984 		TRACE_FLAGS_DEFAULT,
       
  3985 		(EAPL("eap_am_type_tls_peap_symbian_c::select_cipher_suite(), found=%d, cipher suite=%d, KErrNotFound=%d\n"),
       
  3986 		found,
       
  3987 		test_cipher_suite,
       
  3988 		KErrNotFound));
       
  3989 
       
  3990 	if (found != KErrNotFound
       
  3991 		&& (select_all_cipher_suites == true
       
  3992 			|| testcertAlgorithm == certAlgorithm))
       
  3993 	{
       
  3994 		u16_t *tmp_object = new u16_t;
       
  3995 		if (tmp_object == 0)
       
  3996 		{
       
  3997 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  3998 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  3999 		}
       
  4000 		*tmp_object = eap_htons(test_cipher_suite);
       
  4001 		
       
  4002 		EAP_TRACE_DEBUG(
       
  4003 			m_am_tools,
       
  4004 			TRACE_FLAGS_DEFAULT,
       
  4005 			(EAPL("eap_am_type_tls_peap_symbian_c::select_cipher_suite(), adds cipher suite=%d\n"),
       
  4006 			test_cipher_suite));
       
  4007 
       
  4008 		status = cipher_suites->add_object(tmp_object, true);
       
  4009 	}
       
  4010 
       
  4011 	return EAP_STATUS_RETURN(m_am_tools, status);
       
  4012 }
       
  4013 
       
  4014 //--------------------------------------------------
       
  4015 
  3858 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::query_cipher_suites_and_previous_session()
  4016 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::query_cipher_suites_and_previous_session()
  3859 {
  4017 {
  3860 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  4018 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  3861 
  4019 
  3862 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("\n")));
  4020 	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("\n")));
  3864 		(m_is_client == true ? "client": "server")));
  4022 		(m_is_client == true ? "client": "server")));
  3865 
  4023 
  3866 	EAP_ASSERT_ALWAYS(m_is_client == true);
  4024 	EAP_ASSERT_ALWAYS(m_is_client == true);
  3867 
  4025 
  3868 	eap_status_e status(eap_status_process_general_error);
  4026 	eap_status_e status(eap_status_process_general_error);
  3869 	
  4027 
  3870 	TAlgorithmId certAlgorithm(ERSA);
  4028 	TAlgorithmId certAlgorithm(ERSA);
  3871 
  4029 
  3872 	bool select_all_cipher_suites = false;
  4030 	bool select_all_cipher_suites = false;
  3873 	
  4031 
  3874 	eap_variable_data_c session_id(m_am_tools);
  4032 	eap_variable_data_c session_id(m_am_tools);
  3875 	eap_variable_data_c master_secret(m_am_tools);
  4033 	eap_variable_data_c master_secret(m_am_tools);
  3876 	tls_cipher_suites_e used_cipher_suite(tls_cipher_suites_TLS_NULL_WITH_NULL_NULL);
  4034 	tls_cipher_suites_e used_cipher_suite(tls_cipher_suites_TLS_NULL_WITH_NULL_NULL);
  3877 	tls_session_type_e tls_session_type(tls_session_type_full_authentication);	
  4035 	tls_session_type_e tls_session_type(tls_session_type_full_authentication);	
  3878 
  4036 
  3879 	eap_array_c<u16_t> cipher_suites(m_am_tools);
  4037 	eap_array_c<u16_t> cipher_suites(m_am_tools);
  3880 		
  4038 
  3881 #if defined(USE_FAST_EAP_TYPE)
  4039 #if defined(USE_FAST_EAP_TYPE)
  3882 		
  4040 		
  3883 	if(m_current_eap_type == eap_type_fast &&
  4041 	if(m_current_eap_type == eap_type_fast &&
  3884 	   m_serv_unauth_prov_mode == true)
  4042 	   m_serv_unauth_prov_mode == true)
  3885 	{
  4043 	{
  3921 			// Since there is no user certificate and CA cert has not been read yet
  4079 			// Since there is no user certificate and CA cert has not been read yet
  3922 			// we need to read the CA cert.
  4080 			// we need to read the CA cert.
  3923 			EAP_TRACE_DEBUG(
  4081 			EAP_TRACE_DEBUG(
  3924 				m_am_tools, 
  4082 				m_am_tools, 
  3925 				TRACE_FLAGS_DEFAULT, 
  4083 				TRACE_FLAGS_DEFAULT, 
  3926 				(EAPL("query_cipher_suites_and_previous_session(): No user or CA certificate. Read CA certificate.\n")));
  4084 				(EAPL("query_cipher_suites_and_previous_session(): No user or CA certificate. Read CA certificate. m_allowed_ca_certs.Count()=%d\n"),
       
  4085 				m_allowed_ca_certs.Count()));
  3927 			
  4086 			
  3928 			if (m_allowed_ca_certs.Count() != 0)
  4087 			if (m_allowed_ca_certs.Count() != 0)
  3929 			{		
  4088 			{		
  3930 #if defined(USE_FAST_EAP_TYPE)
  4089 #if defined(USE_FAST_EAP_TYPE)
  3931 				
  4090 				
  3953 						EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4112 						EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3954 						return EAP_STATUS_RETURN(m_am_tools, eap_status_pending_request);
  4113 						return EAP_STATUS_RETURN(m_am_tools, eap_status_pending_request);
  3955 					}
  4114 					}
  3956 				}
  4115 				}
  3957 			} // End: if (m_allowed_ca_certs.Count() != 0)
  4116 			} // End: if (m_allowed_ca_certs.Count() != 0)
       
  4117 			else
       
  4118 			{
       
  4119 				EAP_TRACE_DEBUG(
       
  4120 					m_am_tools, 
       
  4121 					TRACE_FLAGS_DEFAULT, 
       
  4122 					(EAPL("query_cipher_suites_and_previous_session(): No allowed CA certificates. Sends all cipher suites and hopes best.\n"),
       
  4123 					m_allowed_ca_certs.Count()));
       
  4124 
       
  4125 				select_all_cipher_suites = true;
       
  4126 			}
  3958 		}
  4127 		}
  3959 		else if (m_own_certificate != 0)
  4128 		else if (m_own_certificate != 0)
  3960 		{
  4129 		{
  3961 			EAP_TRACE_DEBUG(
  4130 			EAP_TRACE_DEBUG(
  3962 				m_am_tools, 
  4131 				m_am_tools, 
  3980 			
  4149 			
  3981 			const CSubjectPublicKeyInfo& public_key = m_ca_certificate->PublicKey();
  4150 			const CSubjectPublicKeyInfo& public_key = m_ca_certificate->PublicKey();
  3982 
  4151 
  3983 			certAlgorithm = public_key.AlgorithmId();				
  4152 			certAlgorithm = public_key.AlgorithmId();				
  3984 		}
  4153 		}
  3985 		
  4154 
  3986 			// IF cipher suite is allowed
  4155 
  3987 		if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_RSA_WITH_3DES_EDE_CBC_SHA) != KErrNotFound
  4156 		status = select_cipher_suite(
  3988 			// AND the algorithm matches the certificates algorithm
  4157 			select_all_cipher_suites,
  3989 			&& (select_all_cipher_suites == true
  4158 			tls_cipher_suites_TLS_RSA_WITH_3DES_EDE_CBC_SHA,
  3990 				|| certAlgorithm == ERSA))
  4159 			certAlgorithm,
  3991 			// THEN add it to list.
  4160 			ERSA,
  3992 		{
  4161 			&cipher_suites);
  3993 			u16_t *tmp_object = new u16_t;
  4162 		if (status != eap_status_ok)
  3994 			if (tmp_object == 0)
  4163 		{
  3995 			{
  4164 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  3996 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4165 			return EAP_STATUS_RETURN(m_am_tools, status);
  3997 				return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
  4166 		}
  3998 			}
  4167 
  3999 			*tmp_object = eap_htons(tls_cipher_suites_TLS_RSA_WITH_3DES_EDE_CBC_SHA);
  4168 		status = select_cipher_suite(
  4000 			
  4169 			select_all_cipher_suites,
  4001 			status = cipher_suites.add_object(tmp_object, true);
  4170 			tls_cipher_suites_TLS_RSA_WITH_AES_128_CBC_SHA,
  4002 			if (status != eap_status_ok)
  4171 			certAlgorithm,
  4003 			{
  4172 			ERSA,
  4004 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4173 			&cipher_suites);
  4005 				return EAP_STATUS_RETURN(m_am_tools, status);
  4174 		if (status != eap_status_ok)
  4006 			}
  4175 		{
  4007 		}
  4176 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4008 
  4177 			return EAP_STATUS_RETURN(m_am_tools, status);
  4009 		if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_RSA_WITH_AES_128_CBC_SHA) != KErrNotFound
  4178 		}
  4010 			// AND the algorithm matches the certificates algorithm
  4179 
  4011 			&& (select_all_cipher_suites == true
  4180 		status = select_cipher_suite(
  4012 				|| certAlgorithm == ERSA))
  4181 			select_all_cipher_suites,
  4013 			// THEN add it to list.
  4182 			tls_cipher_suites_TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA,
  4014 		{
  4183 			certAlgorithm,
  4015 			u16_t *tmp_object = new u16_t;
  4184 			EDSA,
  4016 			if (tmp_object == 0)
  4185 			&cipher_suites);
  4017 			{
  4186 		if (status != eap_status_ok)
  4018 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4187 		{
  4019 				return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
  4188 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4020 			}
  4189 			return EAP_STATUS_RETURN(m_am_tools, status);
  4021 			*tmp_object = eap_htons(tls_cipher_suites_TLS_RSA_WITH_AES_128_CBC_SHA);
  4190 		}
  4022 			
  4191 
  4023 			status = cipher_suites.add_object(tmp_object, true);
  4192 		status = select_cipher_suite(
  4024 			if (status != eap_status_ok)
  4193 			select_all_cipher_suites,
  4025 			{
  4194 			tls_cipher_suites_TLS_DHE_DSS_WITH_AES_128_CBC_SHA,
  4026 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4195 			certAlgorithm,
  4027 				return EAP_STATUS_RETURN(m_am_tools, status);
  4196 			EDSA,
  4028 			}
  4197 			&cipher_suites);
  4029 		}
  4198 		if (status != eap_status_ok)
  4030 
  4199 		{
  4031 		if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA) != KErrNotFound
  4200 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4032 			// AND the algorithm matches the certificates algorithm
  4201 			return EAP_STATUS_RETURN(m_am_tools, status);
  4033 			&& (select_all_cipher_suites == true
  4202 		}
  4034 				|| certAlgorithm == EDSA))
  4203 
  4035 			// THEN add it to list.
  4204 		status = select_cipher_suite(
  4036 		{
  4205 			select_all_cipher_suites,
  4037 			u16_t *tmp_object = new u16_t;
  4206 			tls_cipher_suites_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA,
  4038 			if (tmp_object == 0)
  4207 			certAlgorithm,
  4039 			{
  4208 			ERSA,
  4040 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4209 			&cipher_suites);
  4041 				return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
  4210 		if (status != eap_status_ok)
  4042 			}
  4211 		{
  4043 			*tmp_object = eap_htons(tls_cipher_suites_TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA);
  4212 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4044 			
  4213 			return EAP_STATUS_RETURN(m_am_tools, status);
  4045 			status = cipher_suites.add_object(tmp_object, true);
  4214 		}
  4046 			if (status != eap_status_ok)
  4215 
  4047 			{
  4216 		status = select_cipher_suite(
  4048 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4217 			select_all_cipher_suites,
  4049 				return EAP_STATUS_RETURN(m_am_tools, status);
  4218 			tls_cipher_suites_TLS_DHE_RSA_WITH_AES_128_CBC_SHA,
  4050 			}
  4219 			certAlgorithm,
  4051 		}
  4220 			ERSA,
  4052 
  4221 			&cipher_suites);
  4053 		if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_DHE_DSS_WITH_AES_128_CBC_SHA) != KErrNotFound
  4222 		if (status != eap_status_ok)
  4054 			// AND the algorithm matches the certificates algorithm
  4223 		{
  4055 			&& (select_all_cipher_suites == true
  4224 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4056 				|| certAlgorithm == EDSA))
  4225 			return EAP_STATUS_RETURN(m_am_tools, status);
  4057 			// THEN add it to list.
  4226 		}
  4058 		{
  4227 
  4059 			u16_t *tmp_object = new u16_t;
  4228 		status = select_cipher_suite(
  4060 			if (tmp_object == 0)
  4229 			select_all_cipher_suites,
  4061 			{
  4230 			tls_cipher_suites_TLS_RSA_WITH_RC4_128_MD5,
  4062 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4231 			certAlgorithm,
  4063 				return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
  4232 			ERSA,
  4064 			}
  4233 			&cipher_suites);
  4065 			*tmp_object = eap_htons(tls_cipher_suites_TLS_DHE_DSS_WITH_AES_128_CBC_SHA);
  4234 		if (status != eap_status_ok)
  4066 			
  4235 		{
  4067 			status = cipher_suites.add_object(tmp_object, true);
  4236 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4068 			if (status != eap_status_ok)
  4237 			return EAP_STATUS_RETURN(m_am_tools, status);
  4069 			{
  4238 		}
  4070 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4239 
  4071 				return EAP_STATUS_RETURN(m_am_tools, status);
  4240 		status = select_cipher_suite(
  4072 			}
  4241 			select_all_cipher_suites,
  4073 		}
  4242 			tls_cipher_suites_TLS_RSA_WITH_RC4_128_SHA,
  4074 
  4243 			certAlgorithm,
  4075 		if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA) != KErrNotFound
  4244 			ERSA,
  4076 			// AND the algorithm matches the certificates algorithm
  4245 			&cipher_suites);
  4077 			&& (select_all_cipher_suites == true
  4246 		if (status != eap_status_ok)
  4078 				|| certAlgorithm == ERSA))
  4247 		{
  4079 			// THEN add it to list.
  4248 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4080 		{
  4249 			return EAP_STATUS_RETURN(m_am_tools, status);
  4081 			u16_t *tmp_object = new u16_t;
  4250 		}
  4082 			if (tmp_object == 0)
  4251 
  4083 			{
  4252 
  4084 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  4085 				return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  4086 			}
       
  4087 			*tmp_object = eap_htons(tls_cipher_suites_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA);
       
  4088 			
       
  4089 			status = cipher_suites.add_object(tmp_object, true);
       
  4090 			if (status != eap_status_ok)
       
  4091 			{
       
  4092 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  4093 				return EAP_STATUS_RETURN(m_am_tools, status);
       
  4094 			}
       
  4095 		}
       
  4096 
       
  4097 		if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_DHE_RSA_WITH_AES_128_CBC_SHA) != KErrNotFound
       
  4098 			// AND the algorithm matches the certificates algorithm
       
  4099 			&& (select_all_cipher_suites == true
       
  4100 				|| certAlgorithm == ERSA))
       
  4101 			// THEN add it to list.
       
  4102 		{
       
  4103 			u16_t *tmp_object = new u16_t;
       
  4104 			if (tmp_object == 0)
       
  4105 			{
       
  4106 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  4107 				return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  4108 			}
       
  4109 			*tmp_object = eap_htons(tls_cipher_suites_TLS_DHE_RSA_WITH_AES_128_CBC_SHA);
       
  4110 			
       
  4111 			status = cipher_suites.add_object(tmp_object, true);
       
  4112 			if (status != eap_status_ok)
       
  4113 			{
       
  4114 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  4115 				return EAP_STATUS_RETURN(m_am_tools, status);
       
  4116 			}
       
  4117 		}
       
  4118 
       
  4119 		if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_RSA_WITH_RC4_128_MD5) != KErrNotFound
       
  4120 			// AND the algorithm matches the certificates algorithm
       
  4121 			&& (select_all_cipher_suites == true
       
  4122 				|| certAlgorithm == ERSA))
       
  4123 			// THEN add it to list.
       
  4124 		{
       
  4125 			u16_t *tmp_object = new u16_t;
       
  4126 			if (tmp_object == 0)
       
  4127 			{
       
  4128 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  4129 				return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  4130 			}
       
  4131 			*tmp_object = eap_htons(tls_cipher_suites_TLS_RSA_WITH_RC4_128_MD5);
       
  4132 			
       
  4133 			status = cipher_suites.add_object(tmp_object, true);
       
  4134 			if (status != eap_status_ok)
       
  4135 			{
       
  4136 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  4137 				return EAP_STATUS_RETURN(m_am_tools, status);
       
  4138 			}
       
  4139 		}
       
  4140 
       
  4141 		if (m_allowed_cipher_suites.Find(tls_cipher_suites_TLS_RSA_WITH_RC4_128_SHA) != KErrNotFound
       
  4142 			// AND the algorithm matches the certificates algorithm
       
  4143 			&& (select_all_cipher_suites == true
       
  4144 				|| certAlgorithm == ERSA))
       
  4145 			// THEN add it to list.)
       
  4146 		{
       
  4147 			u16_t *tmp_object = new u16_t;
       
  4148 			if (tmp_object == 0)
       
  4149 			{
       
  4150 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  4151 				return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
       
  4152 			}
       
  4153 			*tmp_object = eap_htons(tls_cipher_suites_TLS_RSA_WITH_RC4_128_SHA);
       
  4154 			
       
  4155 			status = cipher_suites.add_object(tmp_object, true);
       
  4156 			if (status != eap_status_ok)
       
  4157 			{
       
  4158 				EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
       
  4159 				return EAP_STATUS_RETURN(m_am_tools, status);
       
  4160 			}
       
  4161 		}
       
  4162 		
  4253 		
  4163 		if (is_session_valid())
  4254 		if (is_session_valid())
  4164 		{
  4255 		{
  4165 			EAP_TRACE_DEBUG(
  4256 			EAP_TRACE_DEBUG(
  4166 				m_am_tools,
  4257 				m_am_tools,
  4254 	  //		m_serv_unauth_prov_mode == true)
  4345 	  //		m_serv_unauth_prov_mode == true)
  4255  
  4346  
  4256 
  4347 
  4257 	// Compression methods. TLS supports only null compression at the moment.
  4348 	// Compression methods. TLS supports only null compression at the moment.
  4258 	eap_array_c<u8_t> compression_methods(m_am_tools);
  4349 	eap_array_c<u8_t> compression_methods(m_am_tools);
       
  4350 
  4259 	{
  4351 	{
  4260 		u8_t *tmp_object = new u8_t;
  4352 		u8_t *tmp_object = new u8_t;
  4261 		if (tmp_object == 0)
  4353 		if (tmp_object == 0)
  4262 		{
  4354 		{
  4263 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4355 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4264 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
  4356 			return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
  4265 		}
  4357 		}
  4266 		*tmp_object = tls_compression_method_null;
  4358 		*tmp_object = tls_compression_method_null;
       
  4359 
  4267 		status = compression_methods.add_object(tmp_object, true);
  4360 		status = compression_methods.add_object(tmp_object, true);
  4268 		if (status != eap_status_ok)
  4361 		if (status != eap_status_ok)
  4269 		{
  4362 		{
  4270 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4363 			EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  4271 			return EAP_STATUS_RETURN(m_am_tools, status);
  4364 			return EAP_STATUS_RETURN(m_am_tools, status);
  4272 		}
  4365 		}
  4273 	}
  4366 	}
       
  4367 
  4274 
  4368 
  4275 	status = get_tls_am_partner()->complete_query_cipher_suites_and_previous_session(
  4369 	status = get_tls_am_partner()->complete_query_cipher_suites_and_previous_session(
  4276 		tls_session_type,
  4370 		tls_session_type,
  4277 		&cipher_suites,
  4371 		&cipher_suites,
  4278 		&compression_methods,
  4372 		&compression_methods,
  4966 #endif //#if defined(USE_EAP_DEBUG_TRACE)
  5060 #endif //#if defined(USE_EAP_DEBUG_TRACE)
  4967 
  5061 
  4968 //--------------------------------------------------
  5062 //--------------------------------------------------
  4969 
  5063 
  4970 void eap_am_type_tls_peap_symbian_c::complete_validate_chain(
  5064 void eap_am_type_tls_peap_symbian_c::complete_validate_chain(
  4971 	CPKIXValidationResult& aValidationResult,
  5065 	const CPKIXValidationResult * const aValidationResult,
  4972 	eap_status_e aStatus)
  5066 	const eap_status_e aStatus)
  4973 {
  5067 {
  4974 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  5068 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  4975 	
  5069 
       
  5070 	TValidationError validationError(EBadKeyUsage);
       
  5071 
       
  5072 	if (aValidationResult != 0)
       
  5073 	{
       
  5074 		validationError = aValidationResult->Error().iReason;
       
  5075 	}
       
  5076 
  4976 	EAP_TRACE_DEBUG(
  5077 	EAP_TRACE_DEBUG(
  4977 		m_am_tools,
  5078 		m_am_tools,
  4978 		TRACE_FLAGS_DEFAULT, 
  5079 		TRACE_FLAGS_DEFAULT,
  4979 		(EAPL("eap_am_type_tls_peap_symbian_c::complete_validate_chain(): Certificate chain validation reason=%d=%s, status=%d=%s\n"), 
  5080 		(EAPL("eap_am_type_tls_peap_symbian_c::complete_validate_chain(): Certificate chain validation reason=%d=%s, status=%d=%s\n"),
  4980 		aValidationResult.Error().iReason,
  5081 		validationError,
  4981 		get_certificate_error_string(aValidationResult.Error().iReason),
  5082 		get_certificate_error_string(validationError),
  4982 		aStatus,
  5083 		aStatus,
  4983 		eap_status_string_c::get_status_string(aStatus)));
  5084 		eap_status_string_c::get_status_string(aStatus)));
  4984 
  5085 
  4985 	if(aStatus != eap_status_ok)
  5086 	if(aStatus != eap_status_ok)
  4986 	{
  5087 	{
  4987 		get_tls_am_partner()->complete_verify_certificate_chain(aStatus);
  5088 		get_tls_am_partner()->complete_verify_certificate_chain(aStatus);
  4988 		return;
  5089 		return;
  4989 	}
  5090 	}
  4990 	
  5091 
  4991 	eap_status_e result(eap_status_ok);
  5092 	eap_status_e result(eap_status_ok);
  4992 
  5093 
  4993 	if (aValidationResult.Error().iReason == EValidatedOK) 
  5094 	if (validationError == EValidatedOK)
  4994 	{
  5095 	{
  4995 		EAP_TRACE_DEBUG(
  5096 		EAP_TRACE_DEBUG(
  4996 			m_am_tools,
  5097 			m_am_tools,
  4997 			TRACE_FLAGS_DEFAULT, 
  5098 			TRACE_FLAGS_DEFAULT,
  4998 			(EAPL("Certificate chain validation OK. Reason: %d=%s\n"), 
  5099 			(EAPL("Certificate chain validation OK. Reason: %d=%s\n"),
  4999 			aValidationResult.Error().iReason,
  5100 			validationError,
  5000 			get_certificate_error_string(aValidationResult.Error().iReason)));
  5101 			get_certificate_error_string(validationError)));
  5001 
  5102 
  5002 		result = eap_status_ok;
  5103 		result = eap_status_ok;
  5003 	}
  5104 	}
  5004 	else
  5105 	else
  5005 	{
  5106 	{
  5006 		if (aValidationResult.Error().iReason == EDateOutOfRange)
  5107 		if (validationError == EDateOutOfRange)
  5007 		{
  5108 		{
  5008 			send_error_notification(eap_status_certificate_expired);
  5109 			send_error_notification(eap_status_certificate_expired);
  5009 			// Ignore error on purpose
  5110 			// Ignore error on purpose
  5010 		}
  5111 		}
  5011 		else
  5112 		else
  5016 
  5117 
  5017 		EAP_TRACE_DEBUG(
  5118 		EAP_TRACE_DEBUG(
  5018 			m_am_tools,
  5119 			m_am_tools,
  5019 			TRACE_FLAGS_DEFAULT, 
  5120 			TRACE_FLAGS_DEFAULT, 
  5020 			(EAPL("ERROR: Certificate chain validation FAILED. Reason: %d=%s\n"), 
  5121 			(EAPL("ERROR: Certificate chain validation FAILED. Reason: %d=%s\n"), 
  5021 			aValidationResult.Error().iReason,
  5122 			validationError,
  5022 			get_certificate_error_string(aValidationResult.Error().iReason)));
  5123 			get_certificate_error_string(validationError)));
  5023 			
  5124 			
  5024 		result = eap_status_illegal_certificate;
  5125 		result = eap_status_illegal_certificate;
  5025 	}
  5126 	}
  5026 
  5127 
  5027 	// Copy the public key
  5128 	// Copy the public key
  5450 
  5551 
  5451 	eap_status_e status;
  5552 	eap_status_e status;
  5452 	eap_array_c<eap_variable_data_c> certificate_authorities(m_am_tools);
  5553 	eap_array_c<eap_variable_data_c> certificate_authorities(m_am_tools);
  5453 	eap_variable_data_c ca_dn(m_am_tools);
  5554 	eap_variable_data_c ca_dn(m_am_tools);
  5454 	
  5555 	
  5455 	// TEST CODE: This is not a proper CA DN.
  5556 	// TEST CODE: Implementation do not support yet a proper CA DN.
  5456 	_LIT8(KTestCA, "ca.eapsim.foo");
  5557 	_LIT8(KTestCA, "ca.eapsim.foo");
  5457 	status = ca_dn.add_data(KTestCA().Ptr(), KTestCA().Size());
  5558 	status = ca_dn.add_data(KTestCA().Ptr(), KTestCA().Size());
  5458 	if (status != eap_status_ok)
  5559 	if (status != eap_status_ok)
  5459 	{
  5560 	{
  5460 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5561 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5640 	TPtr8 ptr(
  5741 	TPtr8 ptr(
  5641 		subject_identity.get_data(subject_identity.get_data_length()), 
  5742 		subject_identity.get_data(subject_identity.get_data_length()), 
  5642 		subject_identity.get_data_length(),
  5743 		subject_identity.get_data_length(),
  5643 		subject_identity.get_data_length());		
  5744 		subject_identity.get_data_length());		
  5644 
  5745 
  5645 	status = subject_realm->set_copy_of_buffer((ptr.Mid(offset + 1)).Ptr(), ptr.Length() - offset - 1);
  5746 	status = subject_realm->set_copy_of_buffer((ptr.Mid(offset + KOffsetCorrection)).Ptr(), ptr.Length() - offset - KOffsetCorrection);
  5646 	if (status != eap_status_ok)
  5747 	if (status != eap_status_ok)
  5647 	{
  5748 	{
  5648 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5749 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5649 		return EAP_STATUS_RETURN(m_am_tools, status);
  5750 		return EAP_STATUS_RETURN(m_am_tools, status);
  5650 	}	
  5751 	}	
  5651 	
  5752 
  5652 	// ISSUER
  5753 	// ISSUER
  5653 	// Check DN
  5754 	// Check DN
  5654 	TRAP(err, get_identities_from_distinguished_namesL(certificate, &subject_identity, &issuer_identity));	
  5755 	TRAP(err, get_identities_from_distinguished_namesL(certificate, &subject_identity, &issuer_identity));	
  5655 	if (err != KErrNone)
  5756 	if (err != KErrNone)
  5656 	{
  5757 	{
  5661 	// Parse realm from identity
  5762 	// Parse realm from identity
  5662 	TPtr8 ptr2(
  5763 	TPtr8 ptr2(
  5663 		issuer_identity.get_data(issuer_identity.get_data_length()), 
  5764 		issuer_identity.get_data(issuer_identity.get_data_length()), 
  5664 		issuer_identity.get_data_length(),
  5765 		issuer_identity.get_data_length(),
  5665 		issuer_identity.get_data_length());		
  5766 		issuer_identity.get_data_length());		
  5666 		
  5767 
  5667 	offset = ptr2.Find(KAt);
  5768 	offset = ptr2.Find(KAt);
  5668 
  5769 
  5669 	status = issuer_realm->set_copy_of_buffer((ptr2.Mid(offset + 1)).Ptr(), ptr2.Length() - offset - 1);
  5770 	status = issuer_realm->set_copy_of_buffer((ptr2.Mid(offset + KOffsetCorrection)).Ptr(), ptr2.Length() - offset - KOffsetCorrection);
  5670 	if (status != eap_status_ok)
  5771 	if (status != eap_status_ok)
  5671 	{
  5772 	{
  5672 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5773 		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  5673 		return EAP_STATUS_RETURN(m_am_tools, status);
  5774 		return EAP_STATUS_RETURN(m_am_tools, status);
  5674 	}
  5775 	}
  6430 		false);
  6531 		false);
  6431 
  6532 
  6432 	notification.set_authentication_error(error);
  6533 	notification.set_authentication_error(error);
  6433 
  6534 
  6434 	m_partner->state_notification(&notification);
  6535 	m_partner->state_notification(&notification);
  6435 }
       
  6436 
       
  6437 //--------------------------------------------------
       
  6438 
       
  6439 eap_status_e eap_am_type_tls_peap_symbian_c::show_certificate_selection_dialog()
       
  6440 {
       
  6441 	return eap_status_ok;
       
  6442 }
       
  6443 
       
  6444 //--------------------------------------------------
       
  6445 
       
  6446 eap_status_e eap_am_type_tls_peap_symbian_c::show_manual_identity_dialog()
       
  6447 {
       
  6448 	return eap_status_ok;
       
  6449 }
  6536 }
  6450 
  6537 
  6451 //--------------------------------------------------
  6538 //--------------------------------------------------
  6452 // CANCELLATION FUNCTIONS
  6539 // CANCELLATION FUNCTIONS
  6453 //--------------------------------------------------
  6540 //--------------------------------------------------
  6944 	// Evaluate view
  7031 	// Evaluate view
  6945 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  7032 	User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited));
  6946 	CleanupClosePushL(view);
  7033 	CleanupClosePushL(view);
  6947 	User::LeaveIfError(view.EvaluateAll());
  7034 	User::LeaveIfError(view.EvaluateAll());
  6948 	
  7035 	
  6949 	// Get the first (and only) row for updation.
  7036 	// Get the first (and only) row for update.
  6950 	view.FirstL();
  7037 	view.FirstL();
  6951 	view.UpdateL();
  7038 	view.UpdateL();
  6952 	
  7039 	
  6953 	// Get column set so we get the correct column numbers
  7040 	// Get column set so we get the correct column numbers
  6954 	CDbColSet* colSet = view.ColSetL();
  7041 	CDbColSet* colSet = view.ColSetL();
  7153   		status = m_am_tools->convert_am_error_to_eapol_error(KErrArgument);
  7240   		status = m_am_tools->convert_am_error_to_eapol_error(KErrArgument);
  7154 
  7241 
  7155  		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  7242  		EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  7156  		return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7243  		return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  7157 	}
  7244 	}
  7158 
       
  7159  	TBool startedOk = ETrue;
       
  7160  
  7245  
  7161     TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  7246     TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  7162     
  7247     
  7163     m_notifier_data_to_user->iPassword.Copy(A_ID_infoPtr);
  7248     m_notifier_data_to_user->iPassword.Copy(A_ID_infoPtr);
  7164     
  7249     
  8401 						isNewEntry = EFalse;
  8486 						isNewEntry = EFalse;
  8402 						
  8487 						
  8403 						break;		
  8488 						break;		
  8404 					}		
  8489 					}		
  8405 					case eap_pac_store_data_type_PAC_store_password:
  8490 					case eap_pac_store_data_type_PAC_store_password:
  8406 					{
       
  8407 						//This is not saved anywhere.
       
  8408 						break;		
       
  8409 					}		
       
  8410 					case eap_pac_store_data_type_PAC_store_device_seed:
  8491 					case eap_pac_store_data_type_PAC_store_device_seed:
  8411 					{
       
  8412 						//This is not saved anywhere.
       
  8413 						break;		
       
  8414 					}		
       
  8415 					case eap_pac_store_data_type_PAC_store_IAP_reference:
  8492 					case eap_pac_store_data_type_PAC_store_IAP_reference:
  8416 					{
  8493 					{
  8417 						//This is not saved anywhere.
  8494 						//These are not saved anywhere.
  8418 						break;		
  8495 						break;		
  8419 					}		
  8496 					}		
  8420 					case eap_pac_store_data_type_PAC_store_group_reference:
  8497 					case eap_pac_store_data_type_PAC_store_group_reference:
  8421 					{
  8498 					{
  8422 						// This should be saved in FAST special settings table in EAP DB, not in PAC store.
  8499 						// This should be saved in FAST special settings table in EAP DB, not in PAC store.
  8913 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
  8990 	return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
  8914 }
  8991 }
  8915 
  8992 
  8916 //--------------------------------------------------
  8993 //--------------------------------------------------
  8917 
  8994 
  8918 EAP_FUNC_EXPORT eap_status_e
  8995 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::initialize_PAC_store(
  8919 eap_am_type_tls_peap_symbian_c::initialize_PAC_store(
       
  8920 	const eap_fast_completion_operation_e aCompletionOperation,
  8996 	const eap_fast_completion_operation_e aCompletionOperation,
  8921 	const eap_fast_initialize_pac_store_completion_e aCompletion )
  8997 	const eap_fast_initialize_pac_store_completion_e aCompletion )
  8922 {
  8998 {
  8923     EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  8999     EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
  8924     EAP_TRACE_DEBUG(m_am_tools, 
  9000     EAP_TRACE_DEBUG(m_am_tools, 
  8981 
  9057 
  8982 // ---------------------------------------------------------------------------
  9058 // ---------------------------------------------------------------------------
  8983 // eap_am_type_tls_peap_symbian_c::indicates_eap_fast_provisioning_starts
  9059 // eap_am_type_tls_peap_symbian_c::indicates_eap_fast_provisioning_starts
  8984 // ---------------------------------------------------------------------------
  9060 // ---------------------------------------------------------------------------
  8985 //  
  9061 //  
  8986 EAP_FUNC_EXPORT
  9062 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::indicates_eap_fast_provisioning_starts(
  8987 eap_status_e eap_am_type_tls_peap_symbian_c::indicates_eap_fast_provisioning_starts(
       
  8988 	const eap_fast_completion_operation_e provisioning_mode,
  9063 	const eap_fast_completion_operation_e provisioning_mode,
  8989 	const eap_fast_pac_type_e pac_type )
  9064 	const eap_fast_pac_type_e pac_type )
  8990 	{
  9065 {
  8991 	eap_status_e status( eap_status_ok );
  9066 	eap_status_e status( eap_status_ok );
  8992 	m_provisioning_mode = provisioning_mode; // save provis. mode
  9067 	m_provisioning_mode = provisioning_mode; // save provis. mode
  8993 	
  9068 
  8994 	TInt err = KErrNone;	
  9069 	TInt error(KErrNone);
  8995 	
  9070 
  8996 
  9071 	TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  8997     TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  9072 
  8998     
  9073 	m_notifier_data_to_user->iPassword.Zero();
  8999     m_notifier_data_to_user->iPassword.Zero();
  9074 
  9000     
  9075 	if (iEapAuthNotifier == 0)
  9001     if (iEapAuthNotifier == 0)
  9076 	{
  9002     	{
  9077 		TRAP(error, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
  9003     	TRAPD(err, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
  9078 		if (error)
  9004     	if (err)
  9079 		{
  9005     		{
  9080 			return m_am_tools->convert_am_error_to_eapol_error(error);
  9006     			return eap_status_process_general_error;
  9081 		}
  9007     		}
  9082 	}
  9008     	}
  9083 	else
  9009     else
  9084 	{
  9010 	   	{
  9085 		TRAP(error, iEapAuthNotifier->Cancel());
  9011 		 	TRAPD(err1, iEapAuthNotifier->Cancel());
  9086 		if (error)
  9012     	if (err1)
  9087 		{
  9013     		{
  9088 			return m_am_tools->convert_am_error_to_eapol_error(error);
  9014     			return eap_status_process_general_error;
  9089 		}
  9015     		}
  9090 	}
  9016      	}
       
  9017 
  9091 
  9018 	if ( pac_type == eap_fast_pac_type_tunnel_pac
  9092 	if ( pac_type == eap_fast_pac_type_tunnel_pac
  9019 		 && provisioning_mode == eap_fast_completion_operation_server_authenticated_provisioning_mode
  9093 		 && provisioning_mode == eap_fast_completion_operation_server_authenticated_provisioning_mode
  9020 		 && status == eap_status_ok )
  9094 		 && status == eap_status_ok )
  9021 				{
  9095 	{
  9022     		TRAPD(err2, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastStartAuthProvWaitNote, m_notifier_data_to_user, aEapType));
  9096 		TRAP(error, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastStartAuthProvWaitNote, m_notifier_data_to_user, aEapType));
  9023 	    	if (err2)
  9097 		if (error)
  9024 	    		{
  9098 		{
  9025 	    			return eap_status_process_general_error;
  9099 			return m_am_tools->convert_am_error_to_eapol_error(error);
  9026 	    		}
  9100 		}
  9027 				}
  9101 	}
  9028 	else if (
  9102 	else if (
  9029 		pac_type == eap_fast_pac_type_tunnel_pac
  9103 		pac_type == eap_fast_pac_type_tunnel_pac
  9030 		&& provisioning_mode == eap_fast_completion_operation_server_unauthenticated_provisioning_mode_ADHP
  9104 		&& provisioning_mode == eap_fast_completion_operation_server_unauthenticated_provisioning_mode_ADHP
  9031 	  && status == eap_status_ok )
  9105 	  && status == eap_status_ok )
  9032 				{
  9106 	{
  9033     		TRAPD(err3, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastStartUnauthProvWaitNote, m_notifier_data_to_user, aEapType));
  9107 		TRAP(error, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastStartUnauthProvWaitNote, m_notifier_data_to_user, aEapType));
  9034 	    	if (err3)
  9108 		if (error)
  9035 	    		{
  9109 		{
  9036 	    			return eap_status_process_general_error;
  9110 			return m_am_tools->convert_am_error_to_eapol_error(error);
  9037 	    		}
  9111 		}
  9038 				}
  9112 	}
  9039 
  9113 
  9040 
  9114 
  9041 
  9115 
  9042 	return status;
  9116 	return status;
  9043 	}
  9117 }
  9044 
  9118 
  9045 // ---------------------------------------------------------------------------
  9119 // ---------------------------------------------------------------------------
  9046 // eap_am_type_tls_peap_symbian_c::indicates_eap_fast_provisioning_ends
  9120 // eap_am_type_tls_peap_symbian_c::indicates_eap_fast_provisioning_ends
  9047 // ---------------------------------------------------------------------------
  9121 // ---------------------------------------------------------------------------
  9048 //  
  9122 //  
  9049 EAP_FUNC_EXPORT
  9123 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::indicates_eap_fast_provisioning_ends(
  9050 eap_status_e eap_am_type_tls_peap_symbian_c::indicates_eap_fast_provisioning_ends(
       
  9051     const bool provisioning_successfull,
  9124     const bool provisioning_successfull,
  9052     const eap_fast_completion_operation_e provisioning_mode,
  9125     const eap_fast_completion_operation_e provisioning_mode,
  9053     const eap_fast_pac_type_e pac_type )
  9126     const eap_fast_pac_type_e pac_type )
  9054 	{	
  9127 {	
  9055 	EAP_TRACE_DEBUG_SYMBIAN( (_L("eap_am_type_tls_peap_symbian_c:: \
  9128 	EAP_TRACE_DEBUG_SYMBIAN( (_L("eap_am_type_tls_peap_symbian_c::indicates_eap_fast_provisioning_ends()")));
  9056 	    indicates_eap_fast_provisioning_ends()")));
       
  9057 
  9129 
  9058 	EAP_UNREFERENCED_PARAMETER(provisioning_mode);
  9130 	EAP_UNREFERENCED_PARAMETER(provisioning_mode);
  9059 
  9131 
       
  9132 	TInt error(KErrNone);
       
  9133 
  9060 	eap_status_e status( eap_status_ok );
  9134 	eap_status_e status( eap_status_ok );
  9061 	
  9135 
  9062 	if ( pac_type == eap_fast_pac_type_tunnel_pac )
  9136 	if ( pac_type == eap_fast_pac_type_tunnel_pac )
  9063 		{
  9137 	{
  9064 	    // stop wait note;
  9138 		// stop wait note;
  9065     TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  9139 		TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  9066     
  9140 
  9067     m_notifier_data_to_user->iPassword.Zero();
  9141 		m_notifier_data_to_user->iPassword.Zero();
  9068     
  9142 
  9069     if (iEapAuthNotifier == 0)
  9143 		if (iEapAuthNotifier == 0)
  9070     	{
  9144 		{
  9071     	TRAPD(err, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
  9145 			TRAP(error, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
  9072     	if (err)
  9146 			if (error)
  9073     		{
       
  9074     			return eap_status_process_general_error;
       
  9075     		}
       
  9076     	}
       
  9077     else
       
  9078     	{
       
  9079     	TRAPD(err1, iEapAuthNotifier->Cancel());
       
  9080     	if (err1)
       
  9081     		{
       
  9082     			return eap_status_process_general_error;
       
  9083     		}
       
  9084     	}
       
  9085 
       
  9086     if( provisioning_successfull )
       
  9087 			{
  9147 			{
  9088 			TRAPD(err2, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastShowProvSuccessNote, m_notifier_data_to_user, aEapType));
  9148 				return m_am_tools->convert_am_error_to_eapol_error(error);
  9089     	if (err2)
       
  9090     		{
       
  9091     			return eap_status_process_general_error;
       
  9092     		}
       
  9093 			}
  9149 			}
       
  9150 		}
  9094 		else
  9151 		else
       
  9152 		{
       
  9153 			TRAP(error, iEapAuthNotifier->Cancel());
       
  9154 			if (error)
  9095 			{
  9155 			{
  9096 			TRAPD(err3, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastShowProvNotSuccessNote, m_notifier_data_to_user, aEapType));
  9156 				return m_am_tools->convert_am_error_to_eapol_error(error);
  9097     	if (err3)
       
  9098     		{
       
  9099     			return eap_status_process_general_error;
       
  9100     		}
       
  9101 			}
  9157 			}
  9102 def 
  9158 		}
  9103 		} // if ( pac_type == eap_fast_pac_type_tunnel_pac )
  9159 
       
  9160 		if( !provisioning_successfull )
       
  9161 		{
       
  9162 			TRAP(error, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastShowProvNotSuccessNote, m_notifier_data_to_user, aEapType));
       
  9163 			if (error)
       
  9164 			{
       
  9165 				return m_am_tools->convert_am_error_to_eapol_error(error);
       
  9166 			}
       
  9167 		}
       
  9168 	} // if ( pac_type == eap_fast_pac_type_tunnel_pac )
  9104 
  9169 
  9105 	return status;
  9170 	return status;
  9106 	}
  9171 }
  9107 
  9172 
  9108 #endif //#if defined(USE_FAST_EAP_TYPE)
  9173 #endif //#if defined(USE_FAST_EAP_TYPE)
  9109 
  9174 
  9110 //--------------------------------------------------
  9175 //--------------------------------------------------
  9111 
  9176 
  9596 			EAP_TRACE_DEBUG_SYMBIAN(
  9661 			EAP_TRACE_DEBUG_SYMBIAN(
  9597 					(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: Get directory contents")));					
  9662 					(_L("eap_am_type_tls_peap_symbian_c::ImportFilesL: Get directory contents")));					
  9598 
  9663 
  9599 			directoryEmpty = false;
  9664 			directoryEmpty = false;
  9600 
  9665 
  9601 			while( fileCounter < files->Count() || (!FileFound))
  9666 			while( fileCounter < files->Count())
  9602 				{
  9667 				{
  9603 				if (!((*files)[fileCounter].IsDir()))
  9668 				if (!((*files)[fileCounter].IsDir()))
  9604 					{
  9669 					{
  9605 					filesize = (*files)[fileCounter].iSize;
  9670 					filesize = (*files)[fileCounter].iSize;
  9606 					EAP_TRACE_DEBUG_SYMBIAN(
  9671 					EAP_TRACE_DEBUG_SYMBIAN(
  9639 				           m_eap_fast_completion_status = m_partner->set_timer(
  9704 				           m_eap_fast_completion_status = m_partner->set_timer(
  9640 				                    this,
  9705 				                    this,
  9641 				                    KHandleCompletePacstoreOkTimerID, 
  9706 				                    KHandleCompletePacstoreOkTimerID, 
  9642 				                    &m_eap_fast_completion_status,
  9707 				                    &m_eap_fast_completion_status,
  9643 				                    1);
  9708 				                    1);
  9644 					   	if (readData != NULL)
       
  9645 					   		CleanupStack::PopAndDestroy(readData);
       
  9646 					   	CleanupStack::PopAndDestroy(5); // Path, Path8, filename, buf2, group_reference8
  9709 					   	CleanupStack::PopAndDestroy(5); // Path, Path8, filename, buf2, group_reference8
  9647 						EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  9710 						EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
  9648 						return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  9711 						return EAP_STATUS_RETURN(m_am_tools, m_eap_fast_completion_status);
  9649 				   		}
  9712 				   		}
  9650 					}
  9713 					}
  9875 
  9938 
  9876 		  if(m_verificationStatus == EFalse)
  9939 		  if(m_verificationStatus == EFalse)
  9877 	    	{
  9940 	    	{
  9878 	    	CleanupStack::PopAndDestroy(m_pacStorePWBuf8);
  9941 	    	CleanupStack::PopAndDestroy(m_pacStorePWBuf8);
  9879 	    	
  9942 	    	
  9880     TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  9943 		    TEapExpandedType aEapType(*EapExpandedTypeFast.GetType());
  9881     
  9944 		    
  9882     m_notifier_data_to_user->iPassword.Zero();
  9945 		    m_notifier_data_to_user->iPassword.Zero();
  9883     
  9946 	
  9884     if (iEapAuthNotifier == 0)
       
  9885     	{
       
  9886     	TRAPD(err, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
       
  9887     	if (err)
       
  9888     		{
       
  9889     			return eap_status_process_general_error;
       
  9890     		}
       
  9891     	}
       
  9892     else
       
  9893     	{
       
  9894     	TRAPD(err1, iEapAuthNotifier->Cancel());
       
  9895     	if (err1)
       
  9896     		{
       
  9897     			return eap_status_process_general_error;
       
  9898     		}
       
  9899     	}
       
  9900 
       
  9901 		TRAPD(err2, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastWrongPacStorePwNote, m_notifier_data_to_user, aEapType));
       
  9902     	if (err2)
       
  9903     		{
       
  9904     			return eap_status_process_general_error;
       
  9905     		}
       
  9906 		
       
  9907 	
       
  9908 
       
  9909 
       
  9910 			return m_eap_fast_completion_status;
  9947 			return m_eap_fast_completion_status;
  9911 			 	    
  9948 			 	    
  9912 	    	}
  9949 	    	}
  9913 		  else
  9950 		  else
  9914 	    	{
  9951 	    	{
  9945     			return eap_status_process_general_error;
  9982     			return eap_status_process_general_error;
  9946     		}
  9983     		}
  9947     	}
  9984     	}
  9948     else
  9985     else
  9949     	{
  9986     	{
  9950     	TRAPD(err4, iEapAuthNotifier->Cancel();
  9987     	TRAPD(err4, iEapAuthNotifier->Cancel());
  9951     	if (err4)
  9988     	if (err4)
  9952     		{
  9989     		{
  9953     			return eap_status_process_general_error;
  9990     			return eap_status_process_general_error;
  9954     		}
  9991     		}
  9955     	}
  9992     	}
  9956 
  9993 
  9957 		TRAPD(err5, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastPacStorePwQueryDialog, m_notifier_data_to_user, aEapType);
  9994 		TRAPD(err5, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypeFastPacStorePwQueryDialog, m_notifier_data_to_user, aEapType));
  9958   	if (err5)
  9995   	if (err5)
  9959   		{
  9996   		{
  9960   			return eap_status_process_general_error;
  9997   			return eap_status_process_general_error;
  9961   		}
  9998   		}
  9962  
  9999  
 10481 	m_both_completed++;
 10518 	m_both_completed++;
 10482 	return m_eap_fast_completion_status;
 10519 	return m_eap_fast_completion_status;
 10483 
 10520 
 10484 }
 10521 }
 10485 
 10522 
 10486 // ---------------------------------------------------------
       
 10487 // eap_am_type_tls_peap_symbian_c::CompleteNotifier
       
 10488 // ---------------------------------------------------------
       
 10489 //    
       
 10490 eap_status_e eap_am_type_tls_peap_symbian_c::CompleteNotifierL()
       
 10491 {
       
 10492 	eap_status_e status( eap_status_ok );
       
 10493 	switch ( m_state )
       
 10494 	    {
       
 10495 	    case EPasswordCancel:
       
 10496 	    case EPasswordQuery:
       
 10497 	    case EWrongPassword:
       
 10498 	    case EFilePasswordQuery:
       
 10499 	    case EMasterkeyQuery:
       
 10500 	    	{
       
 10501 
       
 10502 	    	break;
       
 10503 
       
 10504 	    	}
       
 10505 	    default:
       
 10506 	    	{
       
 10507 	    	EAP_TRACE_DEBUG_SYMBIAN(
       
 10508 	    	    ( _L( "eap_am_type_tls_peap_symbian_c::CompleteNotifierL() m_state = %d not supported." ),
       
 10509 	    	    m_state ) );
       
 10510 	    	}
       
 10511 	    }
       
 10512 	return status;
       
 10513 }
       
 10514 
       
 10515 //--------------------------------------------------
 10523 //--------------------------------------------------
 10516 
 10524 
 10517 void eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL(const TDesC16& aFromUnicode, TDes8& aToAscii)
 10525 void eap_am_type_tls_peap_symbian_c::ConvertUnicodeToAsciiL(const TDesC16& aFromUnicode, TDes8& aToAscii)
 10518 {
 10526 {
 10519 	EAP_TRACE_DATA_DEBUG_SYMBIAN(
 10527 	EAP_TRACE_DATA_DEBUG_SYMBIAN(
 11024 	EAP_TRACE_DEBUG(m_am_tools, 
 11032 	EAP_TRACE_DEBUG(m_am_tools, 
 11025 			TRACE_FLAGS_DEFAULT, (
 11033 			TRACE_FLAGS_DEFAULT, (
 11026 			EAPL("UpdatePasswordTimeL - evaluate view\n")));
 11034 			EAPL("UpdatePasswordTimeL - evaluate view\n")));
 11027 	User::LeaveIfError(view.EvaluateAll());
 11035 	User::LeaveIfError(view.EvaluateAll());
 11028 	
 11036 	
 11029 	// Get the first (and only) row for updation.
 11037 	// Get the first (and only) row.
 11030 	view.FirstL();
 11038 	view.FirstL();
 11031 	view.UpdateL();
 11039 	view.UpdateL();
 11032 	
 11040 	
 11033 	// Get column set so we get the correct column numbers
 11041 	// Get column set so we get the correct column numbers
 11034 	CDbColSet* colSet = view.ColSetL();
 11042 	CDbColSet* colSet = view.ColSetL();
 11112 // ------------------------------------------------------------------------
 11120 // ------------------------------------------------------------------------
 11113 //    
 11121 //    
 11114 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password(
 11122 EAP_FUNC_EXPORT eap_status_e eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password(
 11115 	const eap_variable_data_c * const aInSrvChallengeUtf8 )
 11123 	const eap_variable_data_c * const aInSrvChallengeUtf8 )
 11116 {
 11124 {
 11117     EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password()" )));    
 11125 	EAP_TRACE_DEBUG_SYMBIAN((_L( "eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password()" )));    
 11118 	
 11126 
 11119     eap_status_e status( eap_status_pending_request );
 11127 	eap_status_e status( eap_status_pending_request );
 11120     TEapExpandedType aEapType(*EapExpandedTypeTtlsPap.GetType());
 11128 	TEapExpandedType aEapType(*EapExpandedTypeTtlsPap.GetType());
 11121     
 11129 
 11122     m_notifier_data_to_user->iUsername.Zero();
 11130 	m_notifier_data_to_user->iUsername.Zero();
 11123     m_notifier_data_to_user->iPassword.Zero();
 11131 	m_notifier_data_to_user->iPassword.Zero();
 11124     m_notifier_data_to_user->iUidata.Zero();
 11132 	m_notifier_data_to_user->iUidata.Zero();
 11125     
 11133 
 11126     if (aInSrvChallengeUtf8 != NULL)
 11134 	if ((aInSrvChallengeUtf8 != NULL) && (aInSrvChallengeUtf8->get_data_length() != 0))
 11127     	{
 11135 	{
 11128 			const TPtrC8 utf8(
 11136 		const TPtrC8 utf8(
 11129 				aInSrvChallengeUtf8->get_data(), aInSrvChallengeUtf8->get_data_length()*2); // Length in bytes
 11137 			aInSrvChallengeUtf8->get_data(),
 11130 		
 11138 			aInSrvChallengeUtf8->get_data_length()*2); // Length in bytes
 11131 			TPtr16 unicode(reinterpret_cast<unsigned short *>(&m_notifier_data_to_user->iUidata), m_notifier_data_to_user->iUidata.Size());
 11139 
 11132 			CnvUtfConverter::ConvertToUnicodeFromUtf8(unicode, utf8);
 11140 		CnvUtfConverter::ConvertToUnicodeFromUtf8(m_notifier_data_to_user->iUidata, utf8);
 11133 
 11141 
 11134 			m_state = EPapChallenge;
 11142 		EAP_TRACE_DATA_DEBUG(
 11135 	    TEapExpandedType aEapType(*EapExpandedTypeTtlsPap.GetType());
 11143 			m_am_tools,
 11136 	    
 11144 			TRACE_FLAGS_DEFAULT,
 11137 	    if (iEapAuthNotifier == 0)
 11145 			(EAPL("eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password(): iUidata"),
 11138 	    	{
 11146 			m_notifier_data_to_user->iUidata.Ptr(),
 11139 	    	TRAPD(err, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
 11147 			m_notifier_data_to_user->iUidata.Size()));
 11140 		  	if (err)
 11148 
 11141 		  		{
 11149 		m_state = EPapChallenge;
 11142 		  			return eap_status_process_general_error;
 11150 		TEapExpandedType aEapType(*EapExpandedTypeTtlsPap.GetType());
 11143 		  		}
 11151 
 11144 	    	}
 11152 		if (iEapAuthNotifier == 0)
 11145 	    TRAPD(err1, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypePapChallengeReplyQueryDialog, m_notifier_data_to_user, aEapType));
 11153 		{
 11146 	  	if (err1)
 11154 			TRAPD(err, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
 11147 	  		{
 11155 			if (err)
 11148 	  			return eap_status_process_general_error;
       
 11149 	  		}
       
 11150 	   	}
       
 11151 		else
       
 11152 			{
 11156 			{
 11153 			m_state = EPapUserNameAndPassword;
 11157 				return eap_status_process_general_error;
 11154 		
 11158 			}
 11155 			TTtlsPapDbInfo aInDbInfo;
 11159 		}
 11156 			TRAPD(err2, ReadTtlsPapDbL(aInDbInfo));
 11160 
 11157 	  	if (err2)
 11161 		TRAPD(err1, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypePapChallengeDialog, m_notifier_data_to_user, aEapType));
 11158 	  		{
 11162 		if (err1)
 11159 	  			return eap_status_process_general_error;
 11163 		{
 11160 	  		}
 11164 			return eap_status_process_general_error;
 11161 
 11165 		}
 11162 	    m_notifier_data_to_user->iPasswordPromptEnabled = aInDbInfo.iUsrPwdInfo.iPasswordPromptEnabled;
 11166 	}
 11163 			if (m_notifier_data_to_user->iPasswordPromptEnabled ||
 11167 	else
 11164 				 (aInDbInfo.iUsrPwdInfo.iUserName.Size() == 0 &&
 11168 	{
 11165 				  aInDbInfo.iUsrPwdInfo.iPassword.Size() == 0))
 11169 		m_state = EPapUserNameAndPassword;
       
 11170 
       
 11171 		TTtlsPapDbInfo aInDbInfo;
       
 11172 		TRAPD(err2, ReadTtlsPapDbL(aInDbInfo));
       
 11173 		if (err2)
       
 11174 		{
       
 11175 			return eap_status_process_general_error;
       
 11176 		}
       
 11177 
       
 11178 		m_notifier_data_to_user->iPasswordPromptEnabled = aInDbInfo.iUsrPwdInfo.iPasswordPromptEnabled;
       
 11179 
       
 11180 		if (m_notifier_data_to_user->iPasswordPromptEnabled
       
 11181 			|| aInDbInfo.iUsrPwdInfo.iUserName.Size() == 0
       
 11182 			|| aInDbInfo.iUsrPwdInfo.iPassword.Size() == 0)
       
 11183 		{
       
 11184 			if (aInDbInfo.iUsrPwdInfo.iUserName.Size() == 0)
       
 11185 			{
       
 11186 				m_notifier_data_to_user->iUsername.Zero();
       
 11187 			}
       
 11188 			else
       
 11189 			{
       
 11190 				m_notifier_data_to_user->iUsername = aInDbInfo.iUsrPwdInfo.iUserName;
       
 11191 			}
       
 11192 
       
 11193 			m_notifier_data_to_user->iPassword.Zero();
       
 11194 
       
 11195 			TRAPD(err3,SetTtlsPapColumnToNullL( cf_str_EAP_TLS_PEAP_ttls_pap_password_literal ));
       
 11196 			if (err3)
       
 11197 			{
       
 11198 				return eap_status_process_general_error;
       
 11199 			}
       
 11200 
       
 11201 			if (iEapAuthNotifier == 0)
       
 11202 			{
       
 11203 				TRAPD(err4, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
       
 11204 				if (err4)
 11166 				{
 11205 				{
 11167 	  	  m_notifier_data_to_user->iUsername.Zero();
 11206 					return eap_status_process_general_error;
 11168 	   		m_notifier_data_to_user->iPassword.Zero();
       
 11169 	   		TRAPD(err3,SetTtlsPapColumnToNullL( cf_str_EAP_TLS_PEAP_ttls_pap_password_literal ));
       
 11170 		  	if (err3)
       
 11171 		  		{
       
 11172 		  			return eap_status_process_general_error;
       
 11173 		  		}
       
 11174 	   		
       
 11175 		    if (iEapAuthNotifier == 0)
       
 11176 		    	{
       
 11177 		    	TRAPD(err4, iEapAuthNotifier = CEapAuthNotifier::NewL( *this ));
       
 11178 			  	if (err4)
       
 11179 			  		{
       
 11180 			  			return eap_status_process_general_error;
       
 11181 			  		}
       
 11182 		    	}
       
 11183 		    else
       
 11184 		    	{
       
 11185 		    	TRAPD(err5,iEapAuthNotifier->Cancel());
       
 11186 			  	if (err5)
       
 11187 			  		{
       
 11188 			  			return eap_status_process_general_error;
       
 11189 			  		}
       
 11190 		    	}
       
 11191 				TRAPD(err6, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypePapAuthQueryDialog, m_notifier_data_to_user, aEapType));
       
 11192 		  	if (err6)
       
 11193 		  		{
       
 11194 		  			return eap_status_process_general_error;
       
 11195 		  		}
       
 11196 				}
       
 11197 			else
       
 11198 				{
       
 11199 		    m_notifier_data_to_user->iUsername = aInDbInfo.iUsrPwdInfo.iUserName;
       
 11200 	  	  m_notifier_data_to_user->iPassword = aInDbInfo.iUsrPwdInfo.iPassword;
       
 11201 				DlgComplete(KErrNone);
       
 11202 				}
 11207 				}
 11203 			}
 11208 			}
       
 11209 			else
       
 11210 			{
       
 11211 				TRAPD(err5,iEapAuthNotifier->Cancel());
       
 11212 				if (err5)
       
 11213 				{
       
 11214 					return eap_status_process_general_error;
       
 11215 				}
       
 11216 			}
       
 11217 
       
 11218 			TRAPD(err6, iEapAuthNotifier->StartL(CEapAuthNotifier::EEapNotifierTypePapUsernamePasswordDialog, m_notifier_data_to_user, aEapType));
       
 11219 			if (err6)
       
 11220 			{
       
 11221 				return eap_status_process_general_error;
       
 11222 			}
       
 11223 		}
       
 11224 		else
       
 11225 		{
       
 11226 			m_notifier_data_to_user->iUsername = aInDbInfo.iUsrPwdInfo.iUserName;
       
 11227 
       
 11228 			EAP_TRACE_DATA_DEBUG(
       
 11229 				m_am_tools,
       
 11230 				TRACE_FLAGS_DEFAULT,
       
 11231 				(EAPL("eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password(): iUserName"),
       
 11232 				m_notifier_data_to_user->iUsername.Ptr(),
       
 11233 				m_notifier_data_to_user->iUsername.Size()));
       
 11234 
       
 11235 			m_notifier_data_to_user->iPassword = aInDbInfo.iUsrPwdInfo.iPassword;
       
 11236 
       
 11237 			EAP_TRACE_DATA_DEBUG(
       
 11238 				m_am_tools,
       
 11239 				TRACE_FLAGS_DEFAULT,
       
 11240 				(EAPL("eap_am_type_tls_peap_symbian_c::query_ttls_pap_username_and_password(): iPassword"),
       
 11241 				m_notifier_data_to_user->iPassword.Ptr(),
       
 11242 				m_notifier_data_to_user->iPassword.Size()));
       
 11243 
       
 11244 			DlgComplete(KErrNone);
       
 11245 		}
       
 11246 	}
 11204 
 11247 
 11205 	return status;
 11248 	return status;
 11206 }
 11249 }
 11207 
 11250 
 11208 // ================= TTLS-PAP public not exported =======================
 11251 // ================= TTLS-PAP public not exported =======================
 11325 			CleanupStack::PushL( colSet );
 11368 			CleanupStack::PushL( colSet );
 11326 			
 11369 			
 11327 			// columns reading	
 11370 			// columns reading	
 11328 			aOutDbInfo.iUsrPwdInfo.iPasswordPromptEnabled = view.ColUint(
 11371 			aOutDbInfo.iUsrPwdInfo.iPasswordPromptEnabled = view.ColUint(
 11329 				colSet->ColNo( cf_str_EAP_TLS_PEAP_ttls_pap_password_prompt_literal ) );
 11372 				colSet->ColNo( cf_str_EAP_TLS_PEAP_ttls_pap_password_prompt_literal ) );
       
 11373 
       
 11374 			{
       
 11375 				TPtrC username = view.ColDes(
       
 11376 					colSet->ColNo( cf_str_EAP_TLS_PEAP_ttls_pap_username_literal ) );
       
 11377 
       
 11378 				aOutDbInfo.iUsrPwdInfo.iUserName.Copy(username); 
       
 11379 
       
 11380 				EAP_TRACE_DATA_DEBUG(
       
 11381 					m_am_tools,
       
 11382 					TRACE_FLAGS_DEFAULT,
       
 11383 					(EAPL("eap_am_type_tls_peap_symbian_c::ReadTtlsPapDbL(): iUserName"),
       
 11384 					aOutDbInfo.iUsrPwdInfo.iUserName.Ptr(),
       
 11385 					aOutDbInfo.iUsrPwdInfo.iUserName.Size()));
       
 11386 			}
 11330 			
 11387 			
 11331 			aOutDbInfo.iUsrPwdInfo.iUserName = view.ColDes(
 11388 			{
 11332 				colSet->ColNo( cf_str_EAP_TLS_PEAP_ttls_pap_username_literal ) );
 11389 				TPtrC password = view.ColDes(
 11333 			
 11390 					colSet->ColNo( cf_str_EAP_TLS_PEAP_ttls_pap_password_literal ) );
 11334 			aOutDbInfo.iUsrPwdInfo.iPassword = view.ColDes(
 11391 
 11335 				colSet->ColNo( cf_str_EAP_TLS_PEAP_ttls_pap_password_literal ) );
 11392 				 aOutDbInfo.iUsrPwdInfo.iPassword.Copy(password);
       
 11393 
       
 11394 
       
 11395 				EAP_TRACE_DATA_DEBUG(
       
 11396 					m_am_tools,
       
 11397 					TRACE_FLAGS_DEFAULT,
       
 11398 					(EAPL("eap_am_type_tls_peap_symbian_c::ReadTtlsPapDbL(): iPassword"),
       
 11399 					aOutDbInfo.iUsrPwdInfo.iPassword.Ptr(),
       
 11400 					aOutDbInfo.iUsrPwdInfo.iPassword.Size()));
       
 11401 			}
 11336 			
 11402 			
 11337 			aOutDbInfo.iMaxSessionTime = view.ColInt64(
 11403 			aOutDbInfo.iMaxSessionTime = view.ColInt64(
 11338 				colSet->ColNo( cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time_literal ) );
 11404 				colSet->ColNo( cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time_literal ) );
 11339 			
 11405 			
 11340 			aOutDbInfo.iLastFullAuthTime = view.ColInt64(
 11406 			aOutDbInfo.iLastFullAuthTime = view.ColInt64(
 11405 		// columns updating
 11471 		// columns updating
 11406 		view.SetColL( colSet->ColNo(
 11472 		view.SetColL( colSet->ColNo(
 11407 			cf_str_EAP_TLS_PEAP_ttls_pap_password_prompt_literal ),
 11473 			cf_str_EAP_TLS_PEAP_ttls_pap_password_prompt_literal ),
 11408 			aInDbInfo.iUsrPwdInfo.iPasswordPromptEnabled );
 11474 			aInDbInfo.iUsrPwdInfo.iPasswordPromptEnabled );
 11409 
 11475 
       
 11476 		EAP_TRACE_DATA_DEBUG(
       
 11477 			m_am_tools,
       
 11478 			TRACE_FLAGS_DEFAULT,
       
 11479 			(EAPL( "eap_am_type_tls_peap_symbian_c::WriteTtlsPapDbL(): iUserName" ),
       
 11480 			aInDbInfo.iUsrPwdInfo.iUserName.Ptr(),
       
 11481 			aInDbInfo.iUsrPwdInfo.iUserName.Size() ) );
       
 11482 
 11410 		view.SetColL( colSet->ColNo(
 11483 		view.SetColL( colSet->ColNo(
 11411 			cf_str_EAP_TLS_PEAP_ttls_pap_username_literal ),
 11484 			cf_str_EAP_TLS_PEAP_ttls_pap_username_literal ),
 11412 			aInDbInfo.iUsrPwdInfo.iUserName );
 11485 			aInDbInfo.iUsrPwdInfo.iUserName );
       
 11486 
       
 11487 		EAP_TRACE_DATA_DEBUG(
       
 11488 			m_am_tools,
       
 11489 			TRACE_FLAGS_DEFAULT,
       
 11490 			(EAPL( "eap_am_type_tls_peap_symbian_c::WriteTtlsPapDbL(): iPassword" ),
       
 11491 			aInDbInfo.iUsrPwdInfo.iPassword.Ptr(),
       
 11492 			aInDbInfo.iUsrPwdInfo.iPassword.Size() ) );
 11413 
 11493 
 11414 		view.SetColL( colSet->ColNo(
 11494 		view.SetColL( colSet->ColNo(
 11415 			cf_str_EAP_TLS_PEAP_ttls_pap_password_literal ),
 11495 			cf_str_EAP_TLS_PEAP_ttls_pap_password_literal ),
 11416 			aInDbInfo.iUsrPwdInfo.iPassword );
 11496 			aInDbInfo.iUsrPwdInfo.iPassword );
 11417 
 11497