eapol/eapol_framework/eapol_common/type/securid/core/eap_type_securid_state.cpp
changeset 0 c8830336c852
child 2 1c7bc153c08e
equal deleted inserted replaced
-1:000000000000 0:c8830336c852
       
     1 /*
       
     2 * Copyright (c) 2001-2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  EAP and WLAN authentication protocols.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // This is enumeration of EAPOL source code.
       
    20 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
       
    21 	#undef EAP_FILE_NUMBER_ENUM
       
    22 	#define EAP_FILE_NUMBER_ENUM 117 
       
    23 	#undef EAP_FILE_NUMBER_DATE 
       
    24 	#define EAP_FILE_NUMBER_DATE 1127594498 
       
    25 #endif //#if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
       
    26 
       
    27 #include "eap_type_securid_state.h"
       
    28 
       
    29 eap_type_securid_state_c::eap_type_securid_state_c(const bool client)
       
    30 {
       
    31 	m_is_client = client;
       
    32 
       
    33 	if (m_is_client)
       
    34 	{
       
    35 		m_state = eap_type_securid_state_none;
       
    36 		m_prev_state = eap_type_securid_state_none;
       
    37 		m_next_state = eap_type_securid_state_identity_query;
       
    38 	}
       
    39 	else
       
    40 	{
       
    41 		m_state = eap_type_securid_state_none;
       
    42 		m_prev_state = eap_type_securid_state_none;
       
    43 		m_next_state = eap_type_securid_state_identity_response;
       
    44 	}
       
    45 }
       
    46 
       
    47 eap_type_securid_state_c::~eap_type_securid_state_c()
       
    48 {
       
    49 }
       
    50 
       
    51 eap_type_securid_state_variable_e eap_type_securid_state_c::get_state() const
       
    52 {
       
    53 	return m_state;
       
    54 }
       
    55 
       
    56 void eap_type_securid_state_c::set_state(const eap_type_securid_state_variable_e new_state)
       
    57 {
       
    58 	set_state(new_state, eap_type_securid_state_none);
       
    59 }
       
    60 
       
    61 void eap_type_securid_state_c::set_state(
       
    62 	const eap_type_securid_state_variable_e new_state,
       
    63 	const eap_type_securid_state_variable_e new_next_state)
       
    64 
       
    65 {
       
    66 	m_prev_state = m_state;
       
    67 	m_state = new_state;
       
    68 	m_next_state = new_next_state;
       
    69 }
       
    70 
       
    71 bool eap_type_securid_state_c::is_valid_state(const eap_type_securid_state_variable_e new_state) const
       
    72 {
       
    73 	if (m_is_client) // Client
       
    74 	{
       
    75 		if (new_state == eap_type_securid_state_identity_query)
       
    76 		{
       
    77 			return true;
       
    78 		}
       
    79 
       
    80 		// Check validity against (current) state.
       
    81 		// If it fails then against previous state (in case of resending)
       
    82 
       
    83 		switch (m_state)
       
    84 		{
       
    85 		case eap_type_securid_state_none:
       
    86 			if (new_state == eap_type_securid_state_identity_query
       
    87 				|| new_state == eap_type_securid_state_gtc_user_input_query)
       
    88 			{
       
    89 				return true;
       
    90 			}
       
    91 			break;
       
    92 
       
    93 		case eap_type_securid_state_identity_query:
       
    94 			if (new_state == eap_type_securid_state_passcode_query)
       
    95 			{
       
    96 				return true;
       
    97 			}
       
    98 			break;
       
    99 
       
   100 		case eap_type_securid_state_passcode_query:
       
   101 			if (new_state == eap_type_securid_state_success
       
   102 				|| new_state == eap_type_securid_state_failure)
       
   103 			{
       
   104 				return true;
       
   105 			}
       
   106 			break;
       
   107 
       
   108 		case eap_type_securid_state_gtc_user_input_query:
       
   109 			if (new_state == eap_type_securid_state_gtc_user_input_query
       
   110 				|| new_state == eap_type_securid_state_success
       
   111 				|| new_state == eap_type_securid_state_failure)
       
   112 			{
       
   113 				return true;
       
   114 			}
       
   115 			break;
       
   116 
       
   117 		case eap_type_securid_state_success:
       
   118 		case eap_type_securid_state_failure:
       
   119 			// Session is ended
       
   120 			return false;
       
   121 
       
   122 		default:
       
   123 			;
       
   124 		}
       
   125 
       
   126 	}
       
   127 
       
   128 	else // Server
       
   129 	{
       
   130 		if (new_state == eap_type_securid_state_identity_response)
       
   131 		{
       
   132 			return true;
       
   133 		}
       
   134 
       
   135 		switch (m_state)
       
   136 		{
       
   137 		case eap_type_securid_state_none:
       
   138 			//if (new_state == eap_type_securid_state_identity_response) See 8 lines up.
       
   139 			//{
       
   140 			//	return true;
       
   141 			//}
       
   142 			break;
       
   143 
       
   144 		case eap_type_securid_state_identity_response:
       
   145 			if (new_state == eap_type_securid_state_passcode_response
       
   146 				|| new_state == eap_type_securid_state_gtc_response)
       
   147 			{
       
   148 				return true;
       
   149 			}
       
   150 			break;
       
   151 
       
   152 		case eap_type_securid_state_passcode_response:
       
   153 			if (m_next_state == new_state)
       
   154 			{
       
   155 				return true;
       
   156 			}
       
   157 			if (m_next_state == eap_type_securid_state_passcode_response)
       
   158 			{
       
   159 				return true;
       
   160 			}
       
   161 			break;
       
   162 
       
   163 		case eap_type_securid_state_gtc_response:
       
   164 			if (new_state == eap_type_securid_state_gtc_response)
       
   165 			{
       
   166 				return true;
       
   167 			}
       
   168 			break;
       
   169 
       
   170 		default:
       
   171 			;
       
   172 		}
       
   173 	}
       
   174 	return false;
       
   175 }
       
   176 
       
   177 void eap_type_securid_state_c::set_failure_message_received()
       
   178 {
       
   179 }
       
   180 
       
   181 void eap_type_securid_state_c::unset_failure_message_received()
       
   182 {
       
   183 }
       
   184 
       
   185 void eap_type_securid_state_c::cancel_eap_failure_timer()
       
   186 {
       
   187 }
       
   188 
       
   189 //--------------------------------------------------
       
   190 
       
   191 
       
   192 // End.