|
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 |
|
20 |
|
21 #if !defined(_EAPOL_AM_WLAN_AUTHENTICATION_SYMBIAN_H_) |
|
22 #define _EAPOL_AM_WLAN_AUTHENTICATION_SYMBIAN_H_ |
|
23 |
|
24 #include "eap_am_export.h" |
|
25 #include "eapol_am_wlan_authentication.h" |
|
26 #include "eapol_wlan_database_reference.h" |
|
27 #include "eap_am_network_id.h" |
|
28 #include "eap_array_algorithms.h" |
|
29 |
|
30 #if defined(USE_EAP_SIMPLE_CONFIG) |
|
31 #include "abs_eap_configuration_if.h" |
|
32 #include "simple_config_credential.h" |
|
33 #include "abs_eap_configuration_if.h" |
|
34 #endif // #if defined(USE_EAP_SIMPLE_CONFIG) |
|
35 |
|
36 #include <e32base.h> |
|
37 #include <e32std.h> |
|
38 #include <d32dbms.h> |
|
39 |
|
40 #include <wdbifwlansettings.h> |
|
41 |
|
42 #include <EapType.h> // For TIndexType |
|
43 |
|
44 |
|
45 #ifdef SYMBIAN_SECURE_DBMS |
|
46 // For EAP TLS, PEAP, TTLS, FAST secure databases. |
|
47 // Full path is not needed. The database eaptls.dat will be saved in the |
|
48 // data cage path for DBMS. So it will be in "\private\100012a5\eaptls.dat" in C: drive. |
|
49 // The maximum length of database name is 0x40 (KDbMaxName) , which is defined in d32dbms.h. |
|
50 |
|
51 _LIT(KFastDatabaseName, "c:eapfast.dat"); |
|
52 |
|
53 |
|
54 #else |
|
55 |
|
56 #ifdef USE_EAP_FAST_TYPE |
|
57 _LIT(KFastDatabaseName, "c:\\system\\data\\eapfast.dat"); |
|
58 #endif |
|
59 |
|
60 #endif // #ifdef SYMBIAN_SECURE_DBMS |
|
61 |
|
62 |
|
63 class CEapType; |
|
64 class abs_eapol_am_wlan_authentication_c; |
|
65 class abs_eap_am_tools_c; |
|
66 class eap_file_config_c; |
|
67 |
|
68 const TInt KMaxWPAPSKPasswordLength = 64; |
|
69 const TInt KWPAPSKLength = 32; |
|
70 // Just to make this different of already existing constant. |
|
71 const TUint K_Max_SSID_Length = 32; |
|
72 |
|
73 |
|
74 /// This class declares the simulator adaptation module of eapol_am_wlan_authentication_c. |
|
75 /// See comments of the functions from eapol_am_wlan_authentication_c. |
|
76 class EAP_EXPORT eapol_am_wlan_authentication_symbian_c |
|
77 : public CActive |
|
78 , public eapol_am_wlan_authentication_c |
|
79 #if defined(USE_EAP_SIMPLE_CONFIG) |
|
80 , public abs_eap_configuration_if_c |
|
81 #endif // #if defined(USE_EAP_SIMPLE_CONFIG) |
|
82 { |
|
83 private: |
|
84 //-------------------------------------------------- |
|
85 |
|
86 abs_eapol_am_wlan_authentication_c * m_am_partner; |
|
87 |
|
88 #if defined(USE_EAP_SIMPLE_CONFIG) |
|
89 abs_eap_configuration_if_c * m_configuration_if; |
|
90 #endif // #if defined(USE_EAP_SIMPLE_CONFIG) |
|
91 |
|
92 abs_eap_am_tools_c * m_am_tools; |
|
93 |
|
94 /// This is object to handle file configuration. |
|
95 eap_file_config_c * m_fileconfig; |
|
96 |
|
97 /// SSID of current network. |
|
98 eap_variable_data_c m_SSID; |
|
99 |
|
100 /// WPA(2)-PSK |
|
101 eap_variable_data_c m_wpa_preshared_key; |
|
102 |
|
103 /// HAHS of WPA(2)-PSK |
|
104 eap_variable_data_c m_wpa_preshared_key_hash; |
|
105 |
|
106 /// This pointer is abstract interface to reference of WLAN database of the current connection. |
|
107 const abs_eapol_wlan_database_reference_if_c * m_wlan_database_reference; |
|
108 |
|
109 /// Handle of database session. |
|
110 RDbs m_session; |
|
111 |
|
112 /// Handle of database file. |
|
113 RFs m_fs; |
|
114 |
|
115 /// Array for storing the loaded EAP types. |
|
116 RPointerArray<CEapType> m_plugin_if_array; |
|
117 |
|
118 #ifdef USE_EAP_EXPANDED_TYPES |
|
119 |
|
120 /// Enabled expanded EAP configuration data from CommsDat |
|
121 // This is for the outer most EAP (not tunneled) |
|
122 RExpandedEapTypeArray m_enabled_expanded_eap_array; |
|
123 |
|
124 /// Disabled expanded EAP configuration data from CommsDat |
|
125 // This is for the outer most EAP (not tunneled) |
|
126 RExpandedEapTypeArray m_disabled_expanded_eap_array; |
|
127 |
|
128 /// Array which corresponds with m_plugin_if_array and indicates the types of the loaded EAP types. |
|
129 eap_array_c<eap_type_value_e> m_eap_type_array; |
|
130 |
|
131 #else |
|
132 |
|
133 /// EAP configuration data from CommDb |
|
134 TEapArray m_iap_eap_array; |
|
135 |
|
136 /// Array which corresponds with m_plugin_if_array and indicates the types of the loaded EAP types. |
|
137 RArray<eap_type_value_e> m_eap_type_array; |
|
138 |
|
139 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
|
140 |
|
141 /// Network identity of current connection. |
|
142 eap_am_network_id_c m_receive_network_id; |
|
143 |
|
144 /// WLAN security mode as defined in Symbian platform. |
|
145 EWlanSecurityMode m_security_mode; |
|
146 |
|
147 /// WLAN authentication type. |
|
148 eapol_key_authentication_type_e m_selected_eapol_key_authentication_type; |
|
149 |
|
150 /// WPA(2)-PSK override. |
|
151 bool m_WPA_override_enabled; |
|
152 |
|
153 /// This object is client (true). |
|
154 bool m_is_client; |
|
155 |
|
156 /// This object is valid (true). |
|
157 bool m_is_valid; |
|
158 |
|
159 //-------------------------------------------------- |
|
160 |
|
161 /// This struct is used in WPA(2)-PSK setting handling. |
|
162 struct TPSKEntry |
|
163 { |
|
164 TIndexType indexType; |
|
165 TUint index; |
|
166 TBuf8<K_Max_SSID_Length> ssid; |
|
167 TBuf8<KMaxWPAPSKPasswordLength> password; |
|
168 TBuf8<KWPAPSKLength> psk; |
|
169 }; |
|
170 |
|
171 /// This function tries to initialize database. |
|
172 void TryInitDatabaseL(); |
|
173 |
|
174 /// This function tries to initialize database or if it fails |
|
175 /// tries to create new database. |
|
176 void InitDatabaseL(); |
|
177 |
|
178 /// Function reads one configuration value from database. |
|
179 void read_configureL( |
|
180 const TDesC& aDbName, |
|
181 const TDesC& aTableName, |
|
182 eap_config_string field, |
|
183 const u32_t /*field_length*/, |
|
184 eap_variable_data_c * const data); |
|
185 |
|
186 /// Control function of this active-object. |
|
187 void RunL(); |
|
188 |
|
189 /// Cancel function for active-object. |
|
190 void DoCancel(); |
|
191 |
|
192 /// This function reads WPA(2)-PSK from database. |
|
193 void RetrievePSKL(TPSKEntry& entry); |
|
194 |
|
195 /// This function saves WPA(2)-PSK to database. |
|
196 void SavePSKL(TPSKEntry& entry); |
|
197 |
|
198 /// This function reads EAP-settings from database. |
|
199 void ReadEAPSettingsL(); |
|
200 |
|
201 #ifdef USE_EAP_EXPANDED_TYPES |
|
202 |
|
203 /// This function set the EAP-type to highest in priority. |
|
204 void SetToTopPriorityL(const eap_type_value_e aEapType); |
|
205 |
|
206 #else // For normal EAP types. |
|
207 |
|
208 /// This function set the EAP-type to highest in priority. |
|
209 void SetToTopPriorityL(const TEap* const aEapType); |
|
210 |
|
211 #endif // #ifdef USE_EAP_EXPANDED_TYPES |
|
212 |
|
213 /// THis function reads the references to active Internet Access Point (IAP). |
|
214 eap_status_e read_database_reference_values( |
|
215 TIndexType * const type, |
|
216 TUint * const index); |
|
217 |
|
218 /// This function resets all EAP-plugings. |
|
219 eap_status_e reset_eap_plugins(); |
|
220 |
|
221 /// This function sends error notification to partner object. |
|
222 void send_error_notification(const eap_status_e error); |
|
223 |
|
224 //-------------------------------------------------- |
|
225 public: |
|
226 //-------------------------------------------------- |
|
227 |
|
228 // |
|
229 EAP_FUNC_IMPORT virtual ~eapol_am_wlan_authentication_symbian_c(); |
|
230 |
|
231 // |
|
232 EAP_FUNC_IMPORT eapol_am_wlan_authentication_symbian_c( |
|
233 abs_eap_am_tools_c * const tools, |
|
234 const bool is_client_when_true, |
|
235 const abs_eapol_wlan_database_reference_if_c * const wlan_database_reference); |
|
236 |
|
237 |
|
238 /// See comments of the functions from eapol_am_wlan_authentication_c. |
|
239 |
|
240 EAP_FUNC_IMPORT bool get_is_valid(); |
|
241 |
|
242 EAP_FUNC_IMPORT eap_status_e configure(); |
|
243 |
|
244 EAP_FUNC_IMPORT eap_status_e shutdown(); |
|
245 |
|
246 EAP_FUNC_IMPORT eap_status_e set_am_partner( |
|
247 abs_eapol_am_wlan_authentication_c * am_partner |
|
248 #if defined(USE_EAP_SIMPLE_CONFIG) |
|
249 , abs_eap_configuration_if_c * const configuration_if |
|
250 #endif // #if defined(USE_EAP_SIMPLE_CONFIG) |
|
251 ); |
|
252 |
|
253 EAP_FUNC_IMPORT eap_status_e reset_eap_configuration(); |
|
254 |
|
255 EAP_FUNC_IMPORT eap_status_e set_wlan_parameters( |
|
256 const eap_variable_data_c * const SSID, |
|
257 const bool WPA_override_enabled, |
|
258 const eap_variable_data_c * const wpa_preshared_key, |
|
259 const eapol_key_authentication_type_e selected_eapol_key_authentication_type); |
|
260 |
|
261 EAP_FUNC_IMPORT eap_status_e association( |
|
262 const eap_am_network_id_c * const receive_network_id); |
|
263 |
|
264 EAP_FUNC_IMPORT eap_status_e disassociation( |
|
265 const eap_am_network_id_c * const receive_network_id ///< source includes remote address, destination includes local address. |
|
266 ); |
|
267 |
|
268 EAP_FUNC_IMPORT eap_status_e get_selected_eap_types( |
|
269 eap_array_c<eap_type_selection_c> * const selected_eap_types); |
|
270 |
|
271 EAP_FUNC_IMPORT eap_status_e get_wlan_configuration( |
|
272 eap_variable_data_c * const wpa_preshared_key_hash); |
|
273 |
|
274 EAP_FUNC_IMPORT eap_status_e authentication_finished( |
|
275 const bool when_true_successfull, |
|
276 const eap_type_value_e eap_type, |
|
277 const eapol_key_authentication_type_e authentication_type); |
|
278 |
|
279 EAP_FUNC_IMPORT eap_status_e load_module( |
|
280 const eap_type_value_e type, |
|
281 const eap_type_value_e tunneling_type, |
|
282 abs_eap_base_type_c * const partner, |
|
283 eap_base_type_c ** const eap_type_if, |
|
284 const bool is_client_when_true, |
|
285 const eap_am_network_id_c * const receive_network_id ///< source includes remote address, destination includes local address. |
|
286 ); |
|
287 |
|
288 EAP_FUNC_IMPORT eap_status_e unload_module( |
|
289 const eap_type_value_e type); |
|
290 |
|
291 EAP_FUNC_IMPORT eap_status_e read_configure( |
|
292 const eap_configuration_field_c * const field, |
|
293 eap_variable_data_c * const data); |
|
294 |
|
295 EAP_FUNC_IMPORT eap_status_e write_configure( |
|
296 const eap_configuration_field_c * const field, |
|
297 eap_variable_data_c * const data); |
|
298 |
|
299 EAP_FUNC_IMPORT eap_status_e set_timer( |
|
300 abs_eap_base_timer_c * const initializer, |
|
301 const u32_t id, |
|
302 void * const data, |
|
303 const u32_t p_time_ms); |
|
304 |
|
305 EAP_FUNC_IMPORT eap_status_e cancel_timer( |
|
306 abs_eap_base_timer_c * const initializer, |
|
307 const u32_t id); |
|
308 |
|
309 EAP_FUNC_IMPORT eap_status_e cancel_all_timers(); |
|
310 |
|
311 EAP_FUNC_IMPORT eap_status_e check_is_valid_eap_type(const eap_type_value_e eap_type); |
|
312 |
|
313 EAP_FUNC_IMPORT eap_status_e get_eap_type_list( |
|
314 eap_array_c<eap_type_value_e> * const eap_type_list); |
|
315 |
|
316 EAP_FUNC_IMPORT void state_notification( |
|
317 const abs_eap_state_notification_c * const state); |
|
318 |
|
319 #if defined(USE_EAP_SIMPLE_CONFIG) |
|
320 |
|
321 EAP_FUNC_EXPORT eap_status_e save_simple_config_session( |
|
322 const simple_config_state_e state, |
|
323 EAP_TEMPLATE_CONST eap_array_c<simple_config_credential_c> * const credential_array, |
|
324 const eap_variable_data_c * const new_password, |
|
325 const simple_config_Device_Password_ID_e Device_Password_ID, |
|
326 const simple_config_payloads_c * const other_configuration); |
|
327 |
|
328 #endif // #if defined(USE_EAP_SIMPLE_CONFIG) |
|
329 |
|
330 //-------------------------------------------------- |
|
331 }; // class eapol_am_wlan_authentication_symbian_c |
|
332 |
|
333 #endif //#if !defined(_EAPOL_AM_WLAN_AUTHENTICATION_SYMBIAN_H_) |
|
334 |
|
335 //-------------------------------------------------- |
|
336 |
|
337 |
|
338 |
|
339 // End. |