|
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 311 |
|
23 #undef EAP_FILE_NUMBER_DATE |
|
24 #define EAP_FILE_NUMBER_DATE 1127594498 |
|
25 #endif //#if defined(USE_EAP_MINIMUM_RELEASE_TRACES) |
|
26 |
|
27 |
|
28 // INCLUDE FILES |
|
29 |
|
30 #include <coemain.h> |
|
31 #include <bautils.h> |
|
32 #include <barsc.h> |
|
33 |
|
34 #include "eap_am_memory.h" |
|
35 #include "eap_tools.h" |
|
36 #include "eap_am_type_securid_symbian.h" |
|
37 #include "EapSecurIDDbParameterNames.h" |
|
38 #include "EapSecurIDDbUtils.h" |
|
39 #include "EapSecurIDNotifierStructs.h" |
|
40 #include "EapGtcDbParameterNames.h" |
|
41 #include "EapGtcDbUtils.h" |
|
42 #include "EapSecurIDNotifierUids.h" |
|
43 #include "eap_configuration_field.h" |
|
44 #include "eap_state_notification.h" |
|
45 |
|
46 #include "eap_am_trace_symbian.h" |
|
47 |
|
48 const TUint KMaxSqlQueryLength = 256; |
|
49 const TUint KMaxDBFieldNameLength = 255; |
|
50 const char EAP_GTC_USERNAME_HANDLE_KEY[] = "eap_type_securid_c GTC username"; |
|
51 const TInt KDefaultColumnInView_One = 1; // For DB view. |
|
52 const TInt KMicroSecsInASecond = 1000000; // 1000000 micro seconds is 1 second. |
|
53 |
|
54 // ================= MEMBER FUNCTIONS ======================= |
|
55 |
|
56 EAP_FUNC_EXPORT eap_am_type_securid_symbian_c::~eap_am_type_securid_symbian_c() |
|
57 { |
|
58 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
59 |
|
60 EAP_TRACE_DEBUG( |
|
61 m_am_tools, |
|
62 TRACE_FLAGS_DEFAULT, |
|
63 (EAPL("eap_am_type_securid_symbian_c::~eap_am_type_securid_symbian_c(): this = 0x%08x\n"), |
|
64 this)); |
|
65 |
|
66 EAP_ASSERT(m_shutdown_was_called == true); |
|
67 |
|
68 m_database.Close(); |
|
69 m_session.Close(); |
|
70 |
|
71 delete m_dialog_data_ptr; |
|
72 delete m_dialog_data_pckg_ptr; |
|
73 delete m_message_buf; |
|
74 |
|
75 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
76 } |
|
77 |
|
78 //-------------------------------------------------- |
|
79 |
|
80 EAP_FUNC_EXPORT eap_status_e eap_am_type_securid_symbian_c::shutdown() |
|
81 { |
|
82 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
83 |
|
84 EAP_TRACE_DEBUG( |
|
85 m_am_tools, |
|
86 TRACE_FLAGS_DEFAULT, |
|
87 (EAPL("eap_am_type_securid_symbian_c::shutdown(): this = 0x%08x\n"), |
|
88 this)); |
|
89 |
|
90 if( IsActive() ) |
|
91 { |
|
92 Cancel(); // Cancel only if active. |
|
93 } |
|
94 else |
|
95 { |
|
96 if( m_is_notifier_connected ) |
|
97 { |
|
98 EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::shutdown - calling m_notifier.CancelNotifier(..)\n"))); |
|
99 |
|
100 TInt error = m_notifier.CancelNotifier(KEapSecurIDIdentityQueryUid); |
|
101 |
|
102 EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::shutdown - CancelNotifier(KEapSecurIDIdentityQueryUid) error=%d\n"), error)); |
|
103 |
|
104 |
|
105 error = m_notifier.CancelNotifier(KEapSecurIDPasscodeQueryUid); |
|
106 |
|
107 EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::shutdown - CancelNotifier(KEapSecurIDPasscodeQueryUid) error=%d\n"), error)); |
|
108 |
|
109 |
|
110 error = m_notifier.CancelNotifier(KEapSecurIDPincodeQueryUid); |
|
111 |
|
112 EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::shutdown - CancelNotifier(KEapSecurIDPincodeQueryUid) error=%d\n"), error)); |
|
113 |
|
114 |
|
115 error = m_notifier.CancelNotifier(KEapGtcIdentityQueryUid); |
|
116 |
|
117 EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::shutdown - CancelNotifier(KEapGtcIdentityQueryUid) error=%d\n"), error)); |
|
118 |
|
119 |
|
120 error = m_notifier.CancelNotifier(KEapGtcUserInputQueryUid); |
|
121 |
|
122 EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::shutdown - CancelNotifier(KEapGtcUserInputQueryUid) error=%d\n"), error)); |
|
123 |
|
124 |
|
125 |
|
126 EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::shutdown - calling m_notifier.Close(), prev error=%d\n"), error)); |
|
127 |
|
128 m_notifier.Close(); // Call close only if it is connected. |
|
129 |
|
130 m_is_notifier_connected = false; |
|
131 } |
|
132 } |
|
133 |
|
134 m_shutdown_was_called = true; |
|
135 |
|
136 EAP_TRACE_DEBUG( |
|
137 m_am_tools, |
|
138 TRACE_FLAGS_DEFAULT, |
|
139 (EAPL("eap_am_type_securid_symbian_c::shutdown(): this = 0x%08x returns\n"), |
|
140 this)); |
|
141 |
|
142 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
143 return eap_status_ok; |
|
144 } |
|
145 |
|
146 //-------------------------------------------------- |
|
147 |
|
148 eap_am_type_securid_symbian_c::eap_am_type_securid_symbian_c( |
|
149 abs_eap_am_tools_c * const tools, |
|
150 abs_eap_base_type_c * const partner, |
|
151 const TIndexType aIndexType, |
|
152 const TInt aIndex, |
|
153 const eap_type_value_e aTunnelingType, |
|
154 const eap_type_value_e aEapType, |
|
155 const bool aIsClient, |
|
156 const eap_am_network_id_c * const receive_network_id) |
|
157 : CActive(CActive::EPriorityStandard) |
|
158 , eap_am_type_securid_c(tools /*, partner */) |
|
159 , m_state(EHandlingIdentityQuery) |
|
160 , m_am_tools(tools) |
|
161 , m_partner(partner) |
|
162 , m_receive_network_id(tools) |
|
163 , m_index_type(aIndexType) |
|
164 , m_index(aIndex) |
|
165 , m_tunneling_type(aTunnelingType) |
|
166 , m_is_client(aIsClient) |
|
167 , m_is_valid(false) |
|
168 , m_shutdown_was_called(false) |
|
169 , m_eap_type(aEapType) |
|
170 , m_is_notifier_connected(false) |
|
171 , m_max_session_time(0) |
|
172 { |
|
173 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
174 |
|
175 #ifdef USE_EAP_EXPANDED_TYPES |
|
176 |
|
177 m_tunneling_vendor_type = m_tunneling_type.get_vendor_type(); |
|
178 m_eap_vendor_type = m_eap_type.get_vendor_type(); |
|
179 |
|
180 #else |
|
181 |
|
182 m_tunneling_vendor_type = static_cast<TUint>(m_tunneling_type); |
|
183 m_eap_vendor_type = static_cast<TUint>(m_eap_type); |
|
184 |
|
185 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
|
186 |
|
187 if (receive_network_id != 0 |
|
188 && receive_network_id->get_is_valid_data() == true) |
|
189 { |
|
190 eap_status_e status = m_receive_network_id.set_copy_of_network_id( |
|
191 receive_network_id); |
|
192 if (status != eap_status_ok) |
|
193 { |
|
194 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
195 (void)EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error); |
|
196 return; |
|
197 } |
|
198 } |
|
199 |
|
200 set_is_valid(); |
|
201 |
|
202 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
203 } |
|
204 |
|
205 //-------------------------------------------------- |
|
206 |
|
207 eap_am_type_securid_symbian_c* eap_am_type_securid_symbian_c::NewL( |
|
208 abs_eap_am_tools_c * const aTools, |
|
209 abs_eap_base_type_c * const aPartner, |
|
210 const TIndexType aIndexType, |
|
211 const TInt aIndex, |
|
212 const eap_type_value_e aTunnelingType, |
|
213 const eap_type_value_e aEapType, |
|
214 const bool aIsClient, |
|
215 const eap_am_network_id_c * const receive_network_id) |
|
216 { |
|
217 eap_am_type_securid_symbian_c * self = new(ELeave) eap_am_type_securid_symbian_c( |
|
218 aTools, |
|
219 aPartner, |
|
220 aIndexType, |
|
221 aIndex, |
|
222 aTunnelingType, |
|
223 aEapType, |
|
224 aIsClient, |
|
225 receive_network_id); |
|
226 |
|
227 CleanupStack::PushL(self); |
|
228 |
|
229 if (self->get_is_valid() != true) |
|
230 { |
|
231 User::Leave(KErrGeneral); |
|
232 } |
|
233 |
|
234 self->ConstructL(); |
|
235 |
|
236 CleanupStack::Pop(); |
|
237 |
|
238 return self; |
|
239 } |
|
240 |
|
241 //-------------------------------------------------- |
|
242 |
|
243 void eap_am_type_securid_symbian_c::ConstructL() |
|
244 { |
|
245 // Open/create database |
|
246 if (m_eap_type == eap_type_generic_token_card) |
|
247 { |
|
248 EapGtcDbUtils::OpenDatabaseL(m_database, m_session, m_index_type, m_index, m_tunneling_type); |
|
249 } |
|
250 else |
|
251 { |
|
252 EapSecurIDDbUtils::OpenDatabaseL(m_database, m_session, m_index_type, m_index, m_tunneling_type); |
|
253 } |
|
254 |
|
255 m_dialog_data_ptr = new(ELeave) TEapSecurIDStruct; |
|
256 m_dialog_data_pckg_ptr = new(ELeave) TPckg<TEapSecurIDStruct> (*m_dialog_data_ptr); |
|
257 |
|
258 CActiveScheduler::Add(this); |
|
259 } |
|
260 |
|
261 //-------------------------------------------------- |
|
262 |
|
263 EAP_FUNC_EXPORT void eap_am_type_securid_symbian_c::set_is_valid() |
|
264 { |
|
265 m_is_valid = true; |
|
266 } |
|
267 |
|
268 //-------------------------------------------------- |
|
269 |
|
270 EAP_FUNC_EXPORT bool eap_am_type_securid_symbian_c::get_is_valid() |
|
271 { |
|
272 return m_is_valid; |
|
273 } |
|
274 |
|
275 //-------------------------------------------------- |
|
276 |
|
277 void eap_am_type_securid_symbian_c::send_error_notification(const eap_status_e error) |
|
278 { |
|
279 eap_general_state_variable_e general_state_variable(eap_general_state_authentication_error); |
|
280 |
|
281 if (error == eap_status_user_cancel_authentication) |
|
282 { |
|
283 general_state_variable = eap_general_state_authentication_cancelled; |
|
284 } |
|
285 // Here we swap the addresses. |
|
286 eap_am_network_id_c send_network_id(m_am_tools, |
|
287 m_receive_network_id.get_destination_id(), |
|
288 m_receive_network_id.get_source_id(), |
|
289 m_receive_network_id.get_type()); |
|
290 |
|
291 // Notifies the lower level of an authentication error. |
|
292 eap_state_notification_c notification( |
|
293 m_am_tools, |
|
294 &send_network_id, |
|
295 m_is_client, |
|
296 eap_state_notification_eap, |
|
297 eap_protocol_layer_general, |
|
298 m_eap_type, |
|
299 eap_state_none, |
|
300 general_state_variable, |
|
301 0, |
|
302 false); |
|
303 |
|
304 notification.set_authentication_error(error); |
|
305 |
|
306 m_partner->state_notification(¬ification); |
|
307 } |
|
308 |
|
309 //-------------------------------------------------- |
|
310 |
|
311 void eap_am_type_securid_symbian_c::RunL() |
|
312 { |
|
313 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
314 |
|
315 EAP_TRACE_DEBUG( |
|
316 m_am_tools, |
|
317 TRACE_FLAGS_DEFAULT, |
|
318 (EAPL("eap_am_type_securid_symbian_c::RunL - start") |
|
319 EAPL("m_state, iStatus.Int()=%d\n"), |
|
320 m_state, iStatus.Int())); |
|
321 |
|
322 if (iStatus.Int() == KErrCancel) |
|
323 { |
|
324 delete m_message_buf; |
|
325 m_message_buf = NULL; |
|
326 get_am_partner()->finish_unsuccessful_authentication(true); |
|
327 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
328 return; |
|
329 } |
|
330 |
|
331 if (iStatus.Int() != KErrNone) |
|
332 { |
|
333 delete m_message_buf; |
|
334 m_message_buf = NULL; |
|
335 // Something is very wrong... |
|
336 |
|
337 EAP_TRACE_ERROR( |
|
338 m_am_tools, |
|
339 TRACE_FLAGS_DEFAULT, |
|
340 (EAPL("ERROR: EAP - SecurID notifier or dialog\n"))); |
|
341 |
|
342 send_error_notification(eap_status_authentication_failure); |
|
343 |
|
344 get_am_partner()->finish_unsuccessful_authentication(false); |
|
345 |
|
346 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
347 return; |
|
348 } |
|
349 |
|
350 switch (m_state) |
|
351 { |
|
352 case EHandlingIdentityQuery: |
|
353 { |
|
354 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::RunL(): EHandlingIdentityQuery\n"))); |
|
355 |
|
356 eap_variable_data_c identity(m_am_tools); |
|
357 |
|
358 eap_status_e status = identity.set_copy_of_buffer( |
|
359 m_dialog_data_ptr->iIdentity.Ptr(), |
|
360 m_dialog_data_ptr->iIdentity.Size()); |
|
361 if (status != eap_status_ok) |
|
362 { |
|
363 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
364 (void)EAP_STATUS_RETURN(m_am_tools, status); |
|
365 return; |
|
366 } |
|
367 |
|
368 eap_variable_data_c identity_utf8(m_am_tools); |
|
369 status = m_am_tools->convert_unicode_to_utf8(identity_utf8, identity); |
|
370 if (status != eap_status_ok) |
|
371 { |
|
372 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
373 (void)EAP_STATUS_RETURN(m_am_tools, status); |
|
374 return; |
|
375 } |
|
376 |
|
377 status = get_am_partner()->complete_eap_identity_query(&identity_utf8); |
|
378 } |
|
379 break; |
|
380 |
|
381 case EHandlingPasscodeQuery: |
|
382 { |
|
383 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::RunL(): EHandlingPasscodeQuery\n"))); |
|
384 |
|
385 eap_variable_data_c passcode(m_am_tools); |
|
386 |
|
387 eap_status_e status = passcode.set_copy_of_buffer( |
|
388 m_dialog_data_ptr->iPasscode.Ptr(), |
|
389 m_dialog_data_ptr->iPasscode.Size()); |
|
390 if (status != eap_status_ok) |
|
391 { |
|
392 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
393 (void)EAP_STATUS_RETURN(m_am_tools, status); |
|
394 return; |
|
395 } |
|
396 |
|
397 eap_variable_data_c passcode_utf8(m_am_tools); |
|
398 status = m_am_tools->convert_unicode_to_utf8(passcode_utf8, passcode); |
|
399 if (status != eap_status_ok) |
|
400 { |
|
401 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
402 (void)EAP_STATUS_RETURN(m_am_tools, status); |
|
403 return; |
|
404 } |
|
405 |
|
406 status = get_am_partner()->client_securid_complete_passcode_query(&passcode_utf8); |
|
407 } |
|
408 break; |
|
409 |
|
410 case EHandlingPincodeQuery: |
|
411 { |
|
412 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::RunL(): EHandlingPincodeQuery\n"))); |
|
413 |
|
414 eap_variable_data_c pincode(m_am_tools); |
|
415 |
|
416 eap_status_e status = pincode.set_copy_of_buffer( |
|
417 m_dialog_data_ptr->iPincode.Ptr(), |
|
418 m_dialog_data_ptr->iPincode.Size()); |
|
419 if (status != eap_status_ok) |
|
420 { |
|
421 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
422 (void)EAP_STATUS_RETURN(m_am_tools, status); |
|
423 return; |
|
424 } |
|
425 |
|
426 eap_variable_data_c passcode(m_am_tools); |
|
427 |
|
428 status = passcode.set_copy_of_buffer( |
|
429 m_dialog_data_ptr->iPasscode.Ptr(), |
|
430 m_dialog_data_ptr->iPasscode.Size()); |
|
431 if (status != eap_status_ok) |
|
432 { |
|
433 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
434 (void)EAP_STATUS_RETURN(m_am_tools, status); |
|
435 return; |
|
436 } |
|
437 |
|
438 |
|
439 eap_variable_data_c pincode_utf8(m_am_tools); |
|
440 status = m_am_tools->convert_unicode_to_utf8(pincode_utf8, pincode); |
|
441 if (status != eap_status_ok) |
|
442 { |
|
443 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
444 (void)EAP_STATUS_RETURN(m_am_tools, status); |
|
445 return; |
|
446 } |
|
447 |
|
448 eap_variable_data_c passcode_utf8(m_am_tools); |
|
449 status = m_am_tools->convert_unicode_to_utf8(passcode_utf8, passcode); |
|
450 if (status != eap_status_ok) |
|
451 { |
|
452 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
453 (void)EAP_STATUS_RETURN(m_am_tools, status); |
|
454 return; |
|
455 } |
|
456 |
|
457 status = get_am_partner()->client_securid_complete_pincode_query(&passcode_utf8, &passcode_utf8); |
|
458 } |
|
459 break; |
|
460 |
|
461 case EHandlingGTCQuery: |
|
462 { |
|
463 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::RunL(): EHandlingGTCQuery\n"))); |
|
464 |
|
465 delete m_message_buf; |
|
466 m_message_buf = NULL; |
|
467 |
|
468 eap_variable_data_c passcode(m_am_tools); |
|
469 |
|
470 eap_status_e status = passcode.set_copy_of_buffer( |
|
471 m_dialog_data_ptr->iPasscode.Ptr(), |
|
472 m_dialog_data_ptr->iPasscode.Size()); |
|
473 if (status != eap_status_ok) |
|
474 { |
|
475 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
476 (void)EAP_STATUS_RETURN(m_am_tools, status); |
|
477 return; |
|
478 } |
|
479 |
|
480 eap_variable_data_c passcode_utf8(m_am_tools); |
|
481 status = m_am_tools->convert_unicode_to_utf8(passcode_utf8, passcode); |
|
482 if (status != eap_status_ok) |
|
483 { |
|
484 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
485 (void)EAP_STATUS_RETURN(m_am_tools, status); |
|
486 return; |
|
487 } |
|
488 |
|
489 // User must have entered some password and pressed OK. |
|
490 // Treat this as a full authentication and update the Last Auth Time. |
|
491 status = store_authentication_time(); |
|
492 if (status != eap_status_ok) |
|
493 { |
|
494 // Storing failed. Don't care. |
|
495 EAP_TRACE_ERROR(m_am_tools, |
|
496 TRACE_FLAGS_DEFAULT, ( |
|
497 EAPL("eap_am_type_securid_symbian_c:Storing Last Full Authentication time failed, status=%d, but continuing\n"), |
|
498 status)); |
|
499 |
|
500 status = eap_status_ok; |
|
501 } |
|
502 |
|
503 status = get_am_partner()->client_gtc_complete_user_input_query(&passcode_utf8); |
|
504 } |
|
505 break; |
|
506 |
|
507 default: |
|
508 EAP_TRACE_ERROR( |
|
509 m_am_tools, |
|
510 TRACE_FLAGS_DEFAULT, |
|
511 (EAPL("ERROR: EAP - SecurID illegal state in RunL.\n"))); |
|
512 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
513 return; |
|
514 } |
|
515 |
|
516 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
517 } |
|
518 |
|
519 //-------------------------------------------------- |
|
520 |
|
521 void eap_am_type_securid_symbian_c::DoCancel() |
|
522 { |
|
523 if( m_is_notifier_connected ) |
|
524 { |
|
525 EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::DoCancel - calling m_notifier.CancelNotifier(..)\n"))); |
|
526 |
|
527 TInt error = m_notifier.CancelNotifier(KEapSecurIDIdentityQueryUid); |
|
528 |
|
529 EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::DoCancel - CancelNotifier(KEapSecurIDIdentityQueryUid) error=%d\n"), error)); |
|
530 |
|
531 error = m_notifier.CancelNotifier(KEapSecurIDPasscodeQueryUid); |
|
532 |
|
533 EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::DoCancel - CancelNotifier(KEapSecurIDPasscodeQueryUid) error=%d\n"), error)); |
|
534 |
|
535 error = m_notifier.CancelNotifier(KEapSecurIDPincodeQueryUid); |
|
536 |
|
537 EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::DoCancel - CancelNotifier(KEapSecurIDPincodeQueryUid) error=%d\n"), error)); |
|
538 |
|
539 error = m_notifier.CancelNotifier(KEapGtcIdentityQueryUid); |
|
540 |
|
541 EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::DoCancel - CancelNotifier(KEapGtcIdentityQueryUid) error=%d\n"), error)); |
|
542 |
|
543 error = m_notifier.CancelNotifier(KEapGtcUserInputQueryUid); |
|
544 |
|
545 EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::DoCancel - CancelNotifier(KEapGtcUserInputQueryUid) error=%d\n"), error)); |
|
546 |
|
547 m_notifier.Close(); // Call close only if it is connected. |
|
548 |
|
549 m_is_notifier_connected = false; |
|
550 } |
|
551 } |
|
552 |
|
553 //-------------------------------------------------- |
|
554 |
|
555 |
|
556 EAP_FUNC_EXPORT eap_status_e eap_am_type_securid_symbian_c::type_configure_read( |
|
557 const eap_configuration_field_c * const field, |
|
558 eap_variable_data_c * const data) |
|
559 { |
|
560 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
561 EAP_ASSERT(data != 0); |
|
562 // Trap must be set here because the OS independent portion of EAP SecurID |
|
563 // that calls this function does not know anything about Symbian. |
|
564 eap_status_e status(eap_status_ok); |
|
565 TRAPD(err, type_configure_readL( |
|
566 field->get_field(), |
|
567 field->get_field_length(), |
|
568 data)); |
|
569 if (err != KErrNone) |
|
570 { |
|
571 // Read is routed to partner object, for reading from configuration file. |
|
572 status = m_partner->read_configure( |
|
573 field, |
|
574 data); |
|
575 } |
|
576 |
|
577 m_am_tools->trace_configuration( |
|
578 status, |
|
579 field, |
|
580 data); |
|
581 |
|
582 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
583 return EAP_STATUS_RETURN(m_am_tools, status); |
|
584 } |
|
585 |
|
586 //-------------------------------------------------- |
|
587 |
|
588 void eap_am_type_securid_symbian_c::type_configure_readL( |
|
589 eap_config_string field, |
|
590 const u32_t field_length, |
|
591 eap_variable_data_c * const data) |
|
592 { |
|
593 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
594 EAP_UNREFERENCED_PARAMETER(field_length); |
|
595 |
|
596 // Create a buffer for the ascii strings - initialised with the argument |
|
597 HBufC16* unicodeBuf = HBufC16::NewLC(KMaxDBFieldNameLength); |
|
598 TPtr16 unicodeString = unicodeBuf->Des(); |
|
599 |
|
600 TPtrC8 fieldPtr(reinterpret_cast<const TUint8 *> (field), field_length); |
|
601 |
|
602 unicodeString.Copy(fieldPtr); |
|
603 |
|
604 // Now do the database query |
|
605 |
|
606 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
|
607 TPtr sqlStatement = buf->Des(); |
|
608 |
|
609 _LIT(KSQLQueryRow, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
|
610 if (m_eap_type == eap_type_securid) |
|
611 { |
|
612 sqlStatement.Format(KSQLQueryRow, &unicodeString, &KSecurIDTableName, |
|
613 &KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type); |
|
614 } |
|
615 else |
|
616 { |
|
617 sqlStatement.Format(KSQLQueryRow, &unicodeString, &KGtcTableName, |
|
618 &KServiceType, m_index_type, &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type); |
|
619 } |
|
620 RDbView view; |
|
621 User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
|
622 CleanupClosePushL(view); |
|
623 |
|
624 User::LeaveIfError(view.EvaluateAll()); |
|
625 |
|
626 if (view.FirstL()) |
|
627 { |
|
628 eap_status_e status = eap_status_ok; |
|
629 view.GetL(); |
|
630 |
|
631 switch (view.ColType(KDefaultColumnInView_One)) |
|
632 { |
|
633 case EDbColText: |
|
634 { |
|
635 if (view.ColLength(KDefaultColumnInView_One) > 0) |
|
636 { |
|
637 TPtrC16 value = view.ColDes16(KDefaultColumnInView_One); |
|
638 |
|
639 eap_variable_data_c string_unicode(m_am_tools); |
|
640 |
|
641 status = string_unicode.set_copy_of_buffer(value.Ptr(), value.Size()); |
|
642 if (status != eap_status_ok) |
|
643 { |
|
644 User::Leave( |
|
645 m_am_tools->convert_eapol_error_to_am_error( |
|
646 EAP_STATUS_RETURN(m_am_tools, status))); |
|
647 } |
|
648 |
|
649 status = m_am_tools->convert_unicode_to_utf8( |
|
650 *data, |
|
651 string_unicode); |
|
652 if (status != eap_status_ok) |
|
653 { |
|
654 User::Leave( |
|
655 m_am_tools->convert_eapol_error_to_am_error( |
|
656 EAP_STATUS_RETURN(m_am_tools, status))); |
|
657 } |
|
658 } |
|
659 else |
|
660 { |
|
661 data->reset(); |
|
662 status = data->set_copy_of_buffer("", 0); |
|
663 if (status != eap_status_ok) |
|
664 { |
|
665 User::Leave( |
|
666 m_am_tools->convert_eapol_error_to_am_error( |
|
667 EAP_STATUS_RETURN(m_am_tools, status))); |
|
668 } |
|
669 } |
|
670 } |
|
671 break; |
|
672 |
|
673 case EDbColUint32: |
|
674 { |
|
675 TUint value = view.ColUint32(KDefaultColumnInView_One); |
|
676 status = data->set_copy_of_buffer(reinterpret_cast<unsigned char *> (&value), sizeof(value)); |
|
677 if (status != eap_status_ok) |
|
678 { |
|
679 User::Leave( |
|
680 m_am_tools->convert_eapol_error_to_am_error( |
|
681 EAP_STATUS_RETURN(m_am_tools, status))); |
|
682 } |
|
683 } |
|
684 break; |
|
685 |
|
686 default: |
|
687 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("type_configure_readL: Unexpected column type.\n"))); |
|
688 User::Leave(KErrGeneral); |
|
689 break; |
|
690 } |
|
691 } |
|
692 else |
|
693 { |
|
694 // Could not find parameter |
|
695 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("type_configure_readL: Could not find configuration parameter.\n"))); |
|
696 User::Leave(KErrArgument); |
|
697 } |
|
698 |
|
699 CleanupStack::PopAndDestroy(3); // Close view, 2 x buf |
|
700 |
|
701 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
702 } |
|
703 |
|
704 //-------------------------------------------------- |
|
705 |
|
706 EAP_FUNC_EXPORT eap_status_e eap_am_type_securid_symbian_c::type_configure_write( |
|
707 const eap_configuration_field_c * const field, |
|
708 eap_variable_data_c * const data) |
|
709 { |
|
710 // NOTE: At the moment this is not called anywhere. |
|
711 // NOTE: This is really just for simulation. |
|
712 // Write is routed to partner object. |
|
713 eap_status_e status = m_partner->write_configure( |
|
714 field, |
|
715 data); |
|
716 return EAP_STATUS_RETURN(m_am_tools, status); |
|
717 } |
|
718 |
|
719 //-------------------------------------------------- |
|
720 |
|
721 EAP_FUNC_EXPORT eap_status_e eap_am_type_securid_symbian_c::configure() |
|
722 { |
|
723 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
724 |
|
725 { |
|
726 // Read Maximum Session Validity Time from the config file |
|
727 eap_variable_data_c sessionTimeFromFile(m_am_tools); |
|
728 |
|
729 eap_status_e status = m_partner->read_configure( |
|
730 cf_str_EAP_GTC_max_session_validity_time.get_field(), |
|
731 &sessionTimeFromFile); |
|
732 |
|
733 if (status == eap_status_ok |
|
734 && sessionTimeFromFile.get_is_valid_data() == true |
|
735 && sessionTimeFromFile.get_data_length() == sizeof(u32_t)) |
|
736 { |
|
737 u32_t *session = reinterpret_cast<u32_t *>(sessionTimeFromFile.get_data()); |
|
738 if (session != 0) |
|
739 { |
|
740 // Update the max session time (in micro seconds). |
|
741 // configuration file saves the time in seconds. We have to convert it to micro seconds. |
|
742 m_max_session_time = static_cast<TInt64>(*session) * static_cast<TInt64>(KMicroSecsInASecond); |
|
743 } |
|
744 } |
|
745 } |
|
746 |
|
747 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
748 |
|
749 return eap_status_ok; |
|
750 } |
|
751 |
|
752 //-------------------------------------------------- |
|
753 |
|
754 EAP_FUNC_EXPORT eap_status_e eap_am_type_securid_symbian_c::reset() |
|
755 { |
|
756 return eap_status_ok; |
|
757 } |
|
758 |
|
759 //-------------------------------------------------- |
|
760 |
|
761 eap_status_e eap_am_type_securid_symbian_c::show_identity_query_dialog( |
|
762 eap_type_value_e eap_type, |
|
763 eap_variable_data_c * const identity) |
|
764 { |
|
765 EAP_TRACE_DEBUG(m_am_tools, |
|
766 TRACE_FLAGS_DEFAULT, ( |
|
767 EAPL("eap_am_type_securid_symbian_c::show_identity_query_dialog()\n"))); |
|
768 |
|
769 EAP_UNREFERENCED_PARAMETER(eap_type); |
|
770 EAP_UNREFERENCED_PARAMETER(identity); |
|
771 |
|
772 // This function gets called only if the identity (username) is missing from the |
|
773 // user configuration. Probably user/device management hasn't configured it. |
|
774 |
|
775 EAP_TRACE_ERROR( |
|
776 m_am_tools, |
|
777 TRACE_FLAGS_DEFAULT, |
|
778 (EAPL("ERROR: EAP - SecurID - No Identity (username) \n"))); |
|
779 |
|
780 send_error_notification(eap_status_identity_query_failed); |
|
781 |
|
782 return eap_status_identity_query_failed; |
|
783 } |
|
784 |
|
785 //-------------------------------------------------- |
|
786 |
|
787 eap_status_e eap_am_type_securid_symbian_c::show_passcode_query_dialog( |
|
788 eap_variable_data_c * const /*passcode*/, |
|
789 bool is_first_query) |
|
790 { |
|
791 if (!IsActive()) |
|
792 { |
|
793 m_state = EHandlingPasscodeQuery; |
|
794 |
|
795 if (is_first_query == true) |
|
796 { |
|
797 m_dialog_data_ptr->iIsFirstQuery = ETrue; |
|
798 } |
|
799 else |
|
800 { |
|
801 m_dialog_data_ptr->iIsFirstQuery = EFalse; |
|
802 } |
|
803 |
|
804 if( !m_is_notifier_connected ) |
|
805 { |
|
806 TInt error = m_notifier.Connect(); |
|
807 |
|
808 EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::show_passcode_query_dialog - m_notifier.Connect() returned error=%d\n"), error)); |
|
809 |
|
810 if( error != KErrNone) |
|
811 { |
|
812 // Can not connect to notifier. |
|
813 return EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(error)); |
|
814 } |
|
815 |
|
816 m_is_notifier_connected = true; // Got connectted to notifier. |
|
817 } |
|
818 |
|
819 EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::show_passcode_query_dialog - StartNotifierAndGetResponse - KEapSecurIDPasscodeQueryUid \n"))); |
|
820 |
|
821 m_notifier.StartNotifierAndGetResponse( |
|
822 iStatus, |
|
823 KEapSecurIDPasscodeQueryUid, |
|
824 *m_dialog_data_pckg_ptr, |
|
825 *m_dialog_data_pckg_ptr); |
|
826 |
|
827 SetActive(); |
|
828 } |
|
829 else |
|
830 { |
|
831 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c: Already active when tried to show passcode query dialog.\n"))); |
|
832 return eap_status_process_general_error; |
|
833 } |
|
834 |
|
835 return eap_status_pending_request; |
|
836 } |
|
837 |
|
838 //-------------------------------------------------- |
|
839 |
|
840 eap_status_e eap_am_type_securid_symbian_c::show_gtc_query_dialog( |
|
841 eap_variable_data_c * const /*passcode*/, |
|
842 const u8_t * const message, |
|
843 u32_t message_length, |
|
844 bool is_first_query) |
|
845 { |
|
846 EAP_TRACE_DATA_DEBUG( |
|
847 m_am_tools, |
|
848 TRACE_FLAGS_DEFAULT, |
|
849 (EAPL("eap_am_type_securid_symbian_c::show_gtc_query_dialog: message"), |
|
850 message, |
|
851 message_length)); |
|
852 |
|
853 if (!IsActive()) |
|
854 { |
|
855 m_state = EHandlingGTCQuery; |
|
856 |
|
857 eap_variable_data_c message_utf8(m_am_tools); |
|
858 eap_status_e status = message_utf8.set_buffer(message, message_length, false, false); |
|
859 if (status != eap_status_ok) |
|
860 { |
|
861 return EAP_STATUS_RETURN(m_am_tools, status); |
|
862 } |
|
863 |
|
864 eap_variable_data_c message_unicode(m_am_tools); |
|
865 status = m_am_tools->convert_utf8_to_unicode(message_unicode, message_utf8); |
|
866 if (status != eap_status_ok) |
|
867 { |
|
868 return EAP_STATUS_RETURN(m_am_tools, status); |
|
869 } |
|
870 |
|
871 TRAPD(err, m_message_buf = HBufC8::NewL(message_unicode.get_data_length())); |
|
872 if (err != KErrNone) |
|
873 { |
|
874 return eap_status_allocation_error; |
|
875 } |
|
876 TPtr8 messageBufPtr = m_message_buf->Des(); |
|
877 messageBufPtr.Copy(message_unicode.get_data(), message_unicode.get_data_length()); |
|
878 |
|
879 if (is_first_query == true) |
|
880 { |
|
881 m_dialog_data_ptr->iIsFirstQuery = ETrue; |
|
882 } |
|
883 else |
|
884 { |
|
885 m_dialog_data_ptr->iIsFirstQuery = EFalse; |
|
886 } |
|
887 |
|
888 EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::show_gtc_query_dialog - before m_notifier.Connect(), m_is_notifier_connected=%d\n"), m_is_notifier_connected)); |
|
889 |
|
890 if( !m_is_notifier_connected ) |
|
891 { |
|
892 TInt error = m_notifier.Connect(); |
|
893 |
|
894 EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::show_gtc_query_dialog - m_notifier.Connect() returned error=%d\n"), error)); |
|
895 |
|
896 if( error != KErrNone) |
|
897 { |
|
898 // Can not connect to notifier. |
|
899 return EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(error)); |
|
900 } |
|
901 |
|
902 m_is_notifier_connected = true; // Got connectted to notifier. |
|
903 } |
|
904 |
|
905 EAP_TRACE_DATA_DEBUG( |
|
906 m_am_tools, |
|
907 TRACE_FLAGS_DEFAULT, |
|
908 (EAPL("eap_am_type_securid_symbian_c::show_gtc_query_dialog: m_message_buf"), |
|
909 m_message_buf->Ptr(), |
|
910 m_message_buf->Size())); |
|
911 |
|
912 m_notifier.StartNotifierAndGetResponse( |
|
913 iStatus, |
|
914 KEapGtcUserInputQueryUid, |
|
915 *m_message_buf, |
|
916 *m_dialog_data_pckg_ptr); |
|
917 |
|
918 SetActive(); |
|
919 } |
|
920 else |
|
921 { |
|
922 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c: Already active when tried to show GTC query dialog.\n"))); |
|
923 return eap_status_process_general_error; |
|
924 } |
|
925 |
|
926 return eap_status_pending_request; |
|
927 } |
|
928 |
|
929 //-------------------------------------------------- |
|
930 |
|
931 eap_status_e eap_am_type_securid_symbian_c::show_pincode_query_dialog( |
|
932 eap_variable_data_c * const /*passcode*/, |
|
933 eap_variable_data_c * const /*pincode*/, |
|
934 bool is_first_query) |
|
935 { |
|
936 EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::_pincode_query_dialog - start - is_first_query=%d\n"), is_first_query)); |
|
937 |
|
938 if (!IsActive()) |
|
939 { |
|
940 m_state = EHandlingPincodeQuery; |
|
941 |
|
942 if (is_first_query == true) |
|
943 { |
|
944 m_dialog_data_ptr->iIsFirstQuery = ETrue; |
|
945 } |
|
946 else |
|
947 { |
|
948 m_dialog_data_ptr->iIsFirstQuery = EFalse; |
|
949 } |
|
950 |
|
951 if( !m_is_notifier_connected ) |
|
952 { |
|
953 TInt error = m_notifier.Connect(); |
|
954 |
|
955 EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::show_pincode_query_dialog - m_notifier.Connect() returned error=%d\n"), error)); |
|
956 |
|
957 if( error != KErrNone) |
|
958 { |
|
959 // Can not connect to notifier. |
|
960 return EAP_STATUS_RETURN(m_am_tools, m_am_tools->convert_am_error_to_eapol_error(error)); |
|
961 } |
|
962 |
|
963 m_is_notifier_connected = true; // Got connectted to notifier. |
|
964 } |
|
965 |
|
966 EAP_TRACE_DEBUG_SYMBIAN((_L(" eap_am_type_securid_symbian_c::show_pincode_query_dialog - StartNotifierAndGetResponse - KEapSecurIDPincodeQueryUid \n"))); |
|
967 |
|
968 m_notifier.StartNotifierAndGetResponse( |
|
969 iStatus, |
|
970 KEapSecurIDPincodeQueryUid, |
|
971 *m_dialog_data_pckg_ptr, |
|
972 *m_dialog_data_pckg_ptr); |
|
973 |
|
974 SetActive(); |
|
975 } |
|
976 else |
|
977 { |
|
978 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c: Already active when tried to show identity query dialog.\n"))); |
|
979 return eap_status_process_general_error; |
|
980 } |
|
981 |
|
982 return eap_status_pending_request; |
|
983 } |
|
984 |
|
985 //-------------------------------------------------- |
|
986 |
|
987 EAP_FUNC_EXPORT eap_status_e eap_am_type_securid_symbian_c::read_auth_failure_string( |
|
988 eap_variable_data_c * const string) |
|
989 { |
|
990 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
991 |
|
992 EAP_UNREFERENCED_PARAMETER(string); |
|
993 |
|
994 eap_status_e status=eap_status_ok; |
|
995 |
|
996 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
997 return EAP_STATUS_RETURN(m_am_tools, status); |
|
998 } |
|
999 |
|
1000 //-------------------------------------------------- |
|
1001 |
|
1002 EAP_FUNC_EXPORT eap_status_e eap_am_type_securid_symbian_c::get_memory_store_key( |
|
1003 eap_variable_data_c * const memory_store_key) |
|
1004 { |
|
1005 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1006 |
|
1007 eap_status_e status = memory_store_key->set_copy_of_buffer( |
|
1008 EAP_GTC_USERNAME_HANDLE_KEY, |
|
1009 sizeof(EAP_GTC_USERNAME_HANDLE_KEY)); |
|
1010 if (status != eap_status_ok) |
|
1011 { |
|
1012 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1013 return EAP_STATUS_RETURN(m_am_tools, status); |
|
1014 } |
|
1015 |
|
1016 u8_t fill = ':'; |
|
1017 |
|
1018 status = memory_store_key->add_data( |
|
1019 &m_index_type, |
|
1020 sizeof(m_index_type)); |
|
1021 if (status != eap_status_ok) |
|
1022 { |
|
1023 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1024 return EAP_STATUS_RETURN(m_am_tools, status); |
|
1025 } |
|
1026 |
|
1027 status = memory_store_key->add_data( |
|
1028 &fill, |
|
1029 sizeof(fill)); |
|
1030 if (status != eap_status_ok) |
|
1031 { |
|
1032 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1033 return EAP_STATUS_RETURN(m_am_tools, status); |
|
1034 } |
|
1035 |
|
1036 status = memory_store_key->add_data( |
|
1037 &m_index, |
|
1038 sizeof(m_index)); |
|
1039 if (status != eap_status_ok) |
|
1040 { |
|
1041 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1042 return EAP_STATUS_RETURN(m_am_tools, status); |
|
1043 } |
|
1044 |
|
1045 |
|
1046 status = memory_store_key->add_data( |
|
1047 &fill, |
|
1048 sizeof(fill)); |
|
1049 if (status != eap_status_ok) |
|
1050 { |
|
1051 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1052 return EAP_STATUS_RETURN(m_am_tools, status); |
|
1053 } |
|
1054 |
|
1055 status = memory_store_key->add_data( |
|
1056 &m_tunneling_vendor_type, |
|
1057 sizeof(m_tunneling_vendor_type)); |
|
1058 if (status != eap_status_ok) |
|
1059 { |
|
1060 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1061 return EAP_STATUS_RETURN(m_am_tools, status); |
|
1062 } |
|
1063 |
|
1064 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1065 return EAP_STATUS_RETURN(m_am_tools, status); |
|
1066 } |
|
1067 |
|
1068 //-------------------------------------------------- |
|
1069 |
|
1070 bool eap_am_type_securid_symbian_c::is_session_valid() |
|
1071 { |
|
1072 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1073 |
|
1074 bool sessionValidity(false); |
|
1075 |
|
1076 TRAPD(err, sessionValidity = is_session_validL()); |
|
1077 if (err != KErrNone) |
|
1078 { |
|
1079 EAP_TRACE_ERROR(m_am_tools, |
|
1080 TRACE_FLAGS_DEFAULT, ( |
|
1081 EAPL("eap_am_type_securid_symbian_c::is_session_valid - LEAVE - error=%d, Assuming session is invalid \n"), |
|
1082 err)); |
|
1083 |
|
1084 sessionValidity = false; |
|
1085 } |
|
1086 |
|
1087 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1088 |
|
1089 return sessionValidity; |
|
1090 } |
|
1091 |
|
1092 //-------------------------------------------------- |
|
1093 |
|
1094 bool eap_am_type_securid_symbian_c::is_session_validL() |
|
1095 { |
|
1096 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1097 |
|
1098 EAP_TRACE_DEBUG(m_am_tools, |
|
1099 TRACE_FLAGS_DEFAULT, ( |
|
1100 EAPL("eap_am_type_securid_symbian_c::is_session_valid: EAP vendor type=%d\n"), |
|
1101 m_eap_vendor_type)); |
|
1102 |
|
1103 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
|
1104 TPtr sqlStatement = buf->Des(); |
|
1105 |
|
1106 // Query all the relevant parameters |
|
1107 _LIT(KSQLQuery, "SELECT %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
|
1108 |
|
1109 if (m_eap_type == eap_type_generic_token_card) |
|
1110 { |
|
1111 sqlStatement.Format(KSQLQuery, &cf_str_EAP_GTC_max_session_validity_time_literal, |
|
1112 &KGTCLastFullAuthTime, &KGtcTableName, |
|
1113 &KServiceType, m_index_type, |
|
1114 &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type); |
|
1115 } |
|
1116 else |
|
1117 { |
|
1118 // Secure ID is not supported at the moment. |
|
1119 // Treat this as session invalid. |
|
1120 |
|
1121 CleanupStack::PopAndDestroy(buf); // Delete buf. |
|
1122 return false; |
|
1123 } |
|
1124 |
|
1125 |
|
1126 RDbView view; |
|
1127 // Evaluate view |
|
1128 User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement))); |
|
1129 CleanupClosePushL(view); |
|
1130 |
|
1131 User::LeaveIfError(view.EvaluateAll()); |
|
1132 |
|
1133 // Get the first (and only) row |
|
1134 view.FirstL(); |
|
1135 view.GetL(); |
|
1136 |
|
1137 // Get column set so we get the correct column numbers |
|
1138 CDbColSet* colSet = view.ColSetL(); |
|
1139 CleanupStack::PushL(colSet); |
|
1140 |
|
1141 TInt64 maxSessionTime = view.ColInt64(colSet->ColNo(cf_str_EAP_GTC_max_session_validity_time_literal)); |
|
1142 TInt64 fullAuthTime = view.ColInt64(colSet->ColNo(KGTCLastFullAuthTime)); |
|
1143 |
|
1144 CleanupStack::PopAndDestroy(colSet); // Delete colSet. |
|
1145 CleanupStack::PopAndDestroy(&view); // Close view. |
|
1146 CleanupStack::PopAndDestroy(buf); // Delete buf. |
|
1147 |
|
1148 // If the max session time from DB is zero then we use the |
|
1149 // one read from configuration file. |
|
1150 |
|
1151 if( maxSessionTime == 0) |
|
1152 { |
|
1153 EAP_TRACE_DEBUG(m_am_tools, |
|
1154 TRACE_FLAGS_DEFAULT, ( |
|
1155 EAPL("Session Validity - Using max session validity time from config file\n"))); |
|
1156 |
|
1157 maxSessionTime = m_max_session_time; // value from configuration file. |
|
1158 } |
|
1159 |
|
1160 // Get the current time. |
|
1161 TTime currentTime; |
|
1162 currentTime.UniversalTime(); |
|
1163 |
|
1164 TTime lastFullAuthTime(fullAuthTime); |
|
1165 |
|
1166 #if defined(_DEBUG) || defined(DEBUG) |
|
1167 |
|
1168 TDateTime currentDateTime = currentTime.DateTime(); |
|
1169 |
|
1170 TDateTime fullAuthDateTime = lastFullAuthTime.DateTime(); |
|
1171 |
|
1172 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, |
|
1173 (EAPL("Session Validity - Current Time, %2d-%2d-%4d : %2d-%2d-%2d-%d\n"), |
|
1174 currentDateTime.Day()+1, currentDateTime.Month()+1, currentDateTime.Year(), currentDateTime.Hour(), |
|
1175 currentDateTime.Minute(), currentDateTime.Second(), currentDateTime.MicroSecond())); |
|
1176 |
|
1177 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, |
|
1178 (EAPL("Session Validity - Last Full Auth Time, %2d-%2d-%4d : %2d-%2d-%2d-%d\n"), |
|
1179 fullAuthDateTime.Day()+1, fullAuthDateTime.Month()+1, fullAuthDateTime.Year(), fullAuthDateTime.Hour(), |
|
1180 fullAuthDateTime.Minute(), fullAuthDateTime.Second(), fullAuthDateTime.MicroSecond())); |
|
1181 |
|
1182 #endif |
|
1183 |
|
1184 TTimeIntervalMicroSeconds interval = currentTime.MicroSecondsFrom(lastFullAuthTime); |
|
1185 |
|
1186 EAP_TRACE_DATA_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT,(EAPL("eap_am_type_securid_symbian_c::is_session_valid:interval in microseconds:"), |
|
1187 &(interval.Int64()), |
|
1188 sizeof(interval.Int64()) ) ); |
|
1189 |
|
1190 EAP_TRACE_DATA_DEBUG( m_am_tools, TRACE_FLAGS_DEFAULT,(EAPL("eap_am_type_securid_symbian_c::is_session_valid:max session time in microseconds:"), |
|
1191 &(maxSessionTime), |
|
1192 sizeof(maxSessionTime) ) ); |
|
1193 |
|
1194 |
|
1195 #if defined(_DEBUG) || defined(DEBUG) |
|
1196 |
|
1197 TTimeIntervalMinutes intervalMins; |
|
1198 TInt error = currentTime.MinutesFrom(lastFullAuthTime, intervalMins); |
|
1199 |
|
1200 if(error == KErrNone) |
|
1201 { |
|
1202 EAP_TRACE_DEBUG( |
|
1203 m_am_tools, |
|
1204 TRACE_FLAGS_DEFAULT, |
|
1205 (EAPL("eap_am_type_securid_symbian_c::is_session_validL()") |
|
1206 EAPL("interval in Minutes =%d\n"), |
|
1207 intervalMins.Int())); |
|
1208 } |
|
1209 |
|
1210 #endif |
|
1211 |
|
1212 |
|
1213 if( maxSessionTime >= interval.Int64() ) |
|
1214 { |
|
1215 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::is_session_valid - Session Valid \n"))); |
|
1216 |
|
1217 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1218 |
|
1219 return true; |
|
1220 } |
|
1221 else |
|
1222 { |
|
1223 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("eap_am_type_securid_symbian_c::is_session_valid - Session NOT Valid \n"))); |
|
1224 |
|
1225 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1226 |
|
1227 return false; |
|
1228 } |
|
1229 } |
|
1230 |
|
1231 //-------------------------------------------------- |
|
1232 |
|
1233 eap_status_e eap_am_type_securid_symbian_c::store_authentication_time() |
|
1234 { |
|
1235 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1236 |
|
1237 eap_status_e status(eap_status_ok); |
|
1238 |
|
1239 TRAPD(err, store_authentication_timeL()); |
|
1240 if (err != KErrNone) |
|
1241 { |
|
1242 status = m_am_tools->convert_am_error_to_eapol_error(err); |
|
1243 } |
|
1244 |
|
1245 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1246 |
|
1247 return EAP_STATUS_RETURN(m_am_tools, status); |
|
1248 } |
|
1249 |
|
1250 //-------------------------------------------------- |
|
1251 |
|
1252 void eap_am_type_securid_symbian_c::store_authentication_timeL() |
|
1253 { |
|
1254 EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1255 |
|
1256 EAP_TRACE_DEBUG(m_am_tools, |
|
1257 TRACE_FLAGS_DEFAULT, ( |
|
1258 EAPL("eap_am_type_securid_symbian_c::store_authentication_timeL: EAP Vendor Type=%d\n"), |
|
1259 m_eap_vendor_type)); |
|
1260 |
|
1261 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
|
1262 TPtr sqlStatement = buf->Des(); |
|
1263 |
|
1264 // Query all the relevant parameters |
|
1265 _LIT(KSQLQuery, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
|
1266 |
|
1267 if (m_eap_type == eap_type_generic_token_card) |
|
1268 { |
|
1269 sqlStatement.Format(KSQLQuery, &KGTCLastFullAuthTime, &KGtcTableName, |
|
1270 &KServiceType, m_index_type, |
|
1271 &KServiceIndex, m_index, &KTunnelingType, m_tunneling_vendor_type); |
|
1272 } |
|
1273 else |
|
1274 { |
|
1275 // Secure ID is not supported at the moment. |
|
1276 // Leave with error. |
|
1277 |
|
1278 CleanupStack::PopAndDestroy(buf); // Delete buf. |
|
1279 User::Leave(KErrNotSupported); |
|
1280 } |
|
1281 |
|
1282 RDbView view; |
|
1283 // Evaluate view |
|
1284 User::LeaveIfError(view.Prepare(m_database, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
|
1285 CleanupClosePushL(view); |
|
1286 |
|
1287 User::LeaveIfError(view.EvaluateAll()); |
|
1288 |
|
1289 // Get the first (and only) row for updation. |
|
1290 view.FirstL(); |
|
1291 view.UpdateL(); |
|
1292 |
|
1293 // Get column set so we get the correct column numbers |
|
1294 CDbColSet* colSet = view.ColSetL(); |
|
1295 CleanupStack::PushL(colSet); |
|
1296 |
|
1297 // Get the current universal time. |
|
1298 TTime currentTime; |
|
1299 currentTime.UniversalTime(); |
|
1300 |
|
1301 #if defined(_DEBUG) || defined(DEBUG) |
|
1302 |
|
1303 TDateTime currentDateTime = currentTime.DateTime(); |
|
1304 |
|
1305 EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, |
|
1306 (EAPL("eap_am_type_securid_symbian_c::store_authentication_time, %2d-%2d-%4d : %2d-%2d-%2d-%d\n"), |
|
1307 currentDateTime.Day()+1, currentDateTime.Month()+1,currentDateTime.Year(), currentDateTime.Hour(), |
|
1308 currentDateTime.Minute(), currentDateTime.Second(), currentDateTime.MicroSecond())); |
|
1309 |
|
1310 #endif |
|
1311 |
|
1312 TInt64 fullAuthTime = currentTime.Int64(); |
|
1313 |
|
1314 view.SetColL(colSet->ColNo(KGTCLastFullAuthTime), fullAuthTime); |
|
1315 |
|
1316 view.PutL(); |
|
1317 |
|
1318 CleanupStack::PopAndDestroy(colSet); // Delete colSet. |
|
1319 CleanupStack::PopAndDestroy(&view); // Close view. |
|
1320 CleanupStack::PopAndDestroy(buf); // Delete buf. |
|
1321 |
|
1322 EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT); |
|
1323 } |
|
1324 |
|
1325 //-------------------------------------------------- |
|
1326 // End of File |