|
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 433 |
|
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 #include <e32base.h> |
|
30 #include "EapTlsPeapUtils.h" |
|
31 #include <EapTlsPeapUiConnection.h> |
|
32 #include <EapTlsPeapUiEapTypes.h> |
|
33 #include <EapTlsPeapUiEapType.h> |
|
34 #include "eap_am_trace_symbian.h" |
|
35 |
|
36 const TUint KNumberOfSupportedEAPTypes = 10; //Now 10, including EAP-FAST & TTLS-PAP |
|
37 |
|
38 CEapTlsPeapUiEapTypes::CEapTlsPeapUiEapTypes(CEapTlsPeapUiConnection * const aUiConn) |
|
39 : iIsOpened(EFalse) |
|
40 , iUiConn(aUiConn) |
|
41 , iDataPtr(NULL) |
|
42 { |
|
43 } |
|
44 |
|
45 |
|
46 CEapTlsPeapUiEapTypes::~CEapTlsPeapUiEapTypes() |
|
47 { |
|
48 if (iUiConn) |
|
49 { |
|
50 Close(); |
|
51 iUiConn = NULL; |
|
52 } |
|
53 } |
|
54 |
|
55 |
|
56 TInt CEapTlsPeapUiEapTypes::Open() |
|
57 { |
|
58 if (iIsOpened) |
|
59 { |
|
60 return KErrAlreadyExists; |
|
61 } |
|
62 |
|
63 TInt err = iUiConn->GetDatabase(iDatabase); |
|
64 if (err != KErrNone) |
|
65 { |
|
66 return err; |
|
67 } |
|
68 |
|
69 iIsOpened = ETrue; |
|
70 |
|
71 return KErrNone; |
|
72 } |
|
73 |
|
74 |
|
75 TInt CEapTlsPeapUiEapTypes::GetEapTypes(CArrayFixFlat<TEapTlsPeapUiEapType> ** aDataPtr) |
|
76 { |
|
77 if (aDataPtr == NULL) |
|
78 { |
|
79 return KErrArgument; |
|
80 } |
|
81 if (iIsOpened == EFalse) |
|
82 { |
|
83 return KErrSessionClosed; |
|
84 } |
|
85 if (iDataPtr != 0) |
|
86 { |
|
87 *aDataPtr = iDataPtr; |
|
88 return KErrNone; |
|
89 } |
|
90 iDataPtr = new CArrayFixFlat<TEapTlsPeapUiEapType>(KNumberOfSupportedEAPTypes); |
|
91 if (!iDataPtr) |
|
92 { |
|
93 return KErrNoMemory; |
|
94 } |
|
95 |
|
96 #ifdef USE_EAP_EXPANDED_TYPES |
|
97 |
|
98 TRAPD(err, FetchExpandedDataL()); |
|
99 |
|
100 #else |
|
101 |
|
102 TRAPD(err, FetchDataL()); |
|
103 |
|
104 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
|
105 |
|
106 if (err != KErrNone) |
|
107 { |
|
108 delete iDataPtr; |
|
109 return err; |
|
110 } |
|
111 |
|
112 *aDataPtr = iDataPtr; |
|
113 |
|
114 return KErrNone; |
|
115 } |
|
116 |
|
117 |
|
118 TInt CEapTlsPeapUiEapTypes::Update() |
|
119 { |
|
120 |
|
121 #ifdef USE_EAP_EXPANDED_TYPES |
|
122 |
|
123 TRAPD(err, UpdateExpandedDataL()); |
|
124 |
|
125 #else |
|
126 |
|
127 TRAPD(err, UpdateL()); |
|
128 |
|
129 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
|
130 |
|
131 return err; |
|
132 } |
|
133 |
|
134 #ifndef USE_EAP_EXPANDED_TYPES |
|
135 |
|
136 void CEapTlsPeapUiEapTypes::UpdateL() |
|
137 { |
|
138 TEapArray eapTypes; |
|
139 TEap* eapTmp; |
|
140 |
|
141 TInt i(0); |
|
142 |
|
143 for(i = 0; i < iDataPtr->Count(); i++) |
|
144 { |
|
145 eapTmp = new (ELeave) TEap; |
|
146 CleanupStack::PushL(eapTmp); |
|
147 eapTmp->Enabled = iDataPtr->At(i).iIsEnabled; |
|
148 eapTmp->UID.Copy(iDataPtr->At(i).iEapType); |
|
149 User::LeaveIfError(eapTypes.Append(eapTmp)); |
|
150 CleanupStack::Pop(eapTmp); |
|
151 } |
|
152 |
|
153 TRAPD(err, EapTlsPeapUtils::SetEapDataL( |
|
154 iDatabase, |
|
155 0, |
|
156 eapTypes, |
|
157 iUiConn->GetIndexType(), |
|
158 iUiConn->GetIndex(), |
|
159 static_cast<eap_type_value_e>(iUiConn->GetTunnelingType()), |
|
160 static_cast<eap_type_value_e>(iUiConn->GetEapType()))); |
|
161 |
|
162 eapTypes.ResetAndDestroy(); |
|
163 if (err != KErrNone) |
|
164 { |
|
165 User::Leave(err); |
|
166 } |
|
167 } |
|
168 #endif // #ifndef USE_EAP_EXPANDED_TYPES |
|
169 |
|
170 |
|
171 TInt CEapTlsPeapUiEapTypes::Close() |
|
172 { |
|
173 if (iIsOpened == EFalse) |
|
174 { |
|
175 return KErrNone; |
|
176 } |
|
177 |
|
178 delete iDataPtr; |
|
179 iDataPtr = 0; |
|
180 |
|
181 iUiConn = NULL; |
|
182 return KErrNone; |
|
183 } |
|
184 |
|
185 #ifndef USE_EAP_EXPANDED_TYPES |
|
186 |
|
187 void CEapTlsPeapUiEapTypes::FetchDataL() |
|
188 { |
|
189 TEapArray eapTypes; |
|
190 |
|
191 TRAPD(err, EapTlsPeapUtils::GetEapDataL( |
|
192 iDatabase, |
|
193 0, |
|
194 eapTypes, |
|
195 iUiConn->GetIndexType(), |
|
196 iUiConn->GetIndex(), |
|
197 static_cast<eap_type_value_e>(iUiConn->GetTunnelingType()), |
|
198 static_cast<eap_type_value_e>(iUiConn->GetEapType()))); |
|
199 |
|
200 if (err != KErrNone) |
|
201 { |
|
202 eapTypes.ResetAndDestroy(); |
|
203 User::Leave(err); |
|
204 } |
|
205 |
|
206 TInt i(0); |
|
207 for (i = 0; i < eapTypes.Count(); i++) |
|
208 { |
|
209 TEapTlsPeapUiEapType tmp; |
|
210 |
|
211 tmp.iIsEnabled = eapTypes[i]->Enabled; |
|
212 |
|
213 tmp.iEapType.Copy(eapTypes[i]->UID); |
|
214 |
|
215 TRAPD(err, iDataPtr->AppendL(tmp)); |
|
216 if (err != KErrNone) |
|
217 { |
|
218 eapTypes.ResetAndDestroy(); |
|
219 User::Leave(err); |
|
220 } |
|
221 } |
|
222 eapTypes.ResetAndDestroy(); |
|
223 } |
|
224 #endif // #ifndef USE_EAP_EXPANDED_TYPES |
|
225 |
|
226 #ifdef USE_EAP_EXPANDED_TYPES |
|
227 |
|
228 void CEapTlsPeapUiEapTypes::FetchExpandedDataL() |
|
229 { |
|
230 EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiEapTypes::FetchExpandedDataL: Start\n"))); |
|
231 |
|
232 RExpandedEapTypePtrArray enabledEAPTypes; |
|
233 RExpandedEapTypePtrArray disabledEAPTypes; |
|
234 |
|
235 eap_type_value_e tunnelingType(static_cast<eap_type_ietf_values_e>(iUiConn->GetTunnelingType())); |
|
236 eap_type_value_e eapType(static_cast<eap_type_ietf_values_e>(iUiConn->GetEapType())); |
|
237 |
|
238 TRAPD(err, EapTlsPeapUtils::GetTunnelingExpandedEapDataL( |
|
239 iDatabase, |
|
240 0, |
|
241 enabledEAPTypes, |
|
242 disabledEAPTypes, |
|
243 iUiConn->GetIndexType(), |
|
244 iUiConn->GetIndex(), |
|
245 tunnelingType, |
|
246 eapType)); |
|
247 |
|
248 if (err != KErrNone) |
|
249 { |
|
250 enabledEAPTypes.ResetAndDestroy(); |
|
251 disabledEAPTypes.ResetAndDestroy(); |
|
252 |
|
253 EAP_TRACE_DEBUG_SYMBIAN( |
|
254 (_L("CEapTlsPeapUiEapTypes::FetchExpandedDataL: Error from GetTunnelingExpandedEapDataL:%d\n"), |
|
255 err)); |
|
256 |
|
257 User::Leave(err); |
|
258 } |
|
259 |
|
260 EAP_TRACE_DEBUG_SYMBIAN( |
|
261 (_L("CEapTlsPeapUiEapTypes::FetchExpandedDataL: Got tunneling EAPs from DB: enabled=%d,disabled=%d\n"), |
|
262 enabledEAPTypes.Count(), disabledEAPTypes.Count())); |
|
263 |
|
264 TInt i(0); |
|
265 |
|
266 // First fill the enabled EAP types. |
|
267 for (i = 0; i < enabledEAPTypes.Count(); i++) |
|
268 { |
|
269 TEapTlsPeapUiEapType tmpEAP; |
|
270 |
|
271 tmpEAP.iIsEnabled = ETrue; // All EAP types here are enabled. |
|
272 |
|
273 tmpEAP.iEapType.Copy(enabledEAPTypes[i]->iExpandedEAPType); |
|
274 |
|
275 TRAPD(err, iDataPtr->AppendL(tmpEAP)); |
|
276 if (err != KErrNone) |
|
277 { |
|
278 enabledEAPTypes.ResetAndDestroy(); |
|
279 User::Leave(err); |
|
280 } |
|
281 |
|
282 EAP_TRACE_DATA_DEBUG_SYMBIAN(("CEapTlsPeapUiEapTypes::FetchExpandedDataL:Appended ENABLED EAP type:", |
|
283 tmpEAP.iEapType.Ptr(), |
|
284 tmpEAP.iEapType.Size() ) ); |
|
285 } |
|
286 |
|
287 // Now fill the disabled EAP types. |
|
288 for (i = 0; i < disabledEAPTypes.Count(); i++) |
|
289 { |
|
290 TEapTlsPeapUiEapType tmpEAP; |
|
291 |
|
292 tmpEAP.iIsEnabled = EFalse; // All EAP types here are disabled. |
|
293 |
|
294 tmpEAP.iEapType.Copy(disabledEAPTypes[i]->iExpandedEAPType); |
|
295 |
|
296 TRAPD(err, iDataPtr->AppendL(tmpEAP)); |
|
297 if (err != KErrNone) |
|
298 { |
|
299 disabledEAPTypes.ResetAndDestroy(); |
|
300 User::Leave(err); |
|
301 } |
|
302 |
|
303 EAP_TRACE_DATA_DEBUG_SYMBIAN(("CEapTlsPeapUiEapTypes::FetchExpandedDataL:Appended DISABLED EAP type:", |
|
304 tmpEAP.iEapType.Ptr(), |
|
305 tmpEAP.iEapType.Size() ) ); |
|
306 } |
|
307 |
|
308 enabledEAPTypes.ResetAndDestroy(); |
|
309 disabledEAPTypes.ResetAndDestroy(); |
|
310 |
|
311 EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiEapTypes::FetchExpandedDataL: End\n"))); |
|
312 } |
|
313 |
|
314 void CEapTlsPeapUiEapTypes::UpdateExpandedDataL() |
|
315 { |
|
316 EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiEapTypes::UpdateExpandedDataL: Start\n"))); |
|
317 |
|
318 RExpandedEapTypePtrArray enabledEAPTypes; |
|
319 RExpandedEapTypePtrArray disabledEAPTypes; |
|
320 SExpandedEAPType* expandedEAPTmp; |
|
321 |
|
322 for(TInt i=0 ; i < iDataPtr->Count(); i++) |
|
323 { |
|
324 expandedEAPTmp = new (ELeave) SExpandedEAPType; |
|
325 CleanupStack::PushL(expandedEAPTmp); |
|
326 |
|
327 expandedEAPTmp->iExpandedEAPType.Copy(iDataPtr->At(i).iEapType); |
|
328 |
|
329 if(iDataPtr->At(i).iIsEnabled) |
|
330 { |
|
331 // Enabled |
|
332 TInt error = enabledEAPTypes.Append(expandedEAPTmp); |
|
333 |
|
334 if (error != KErrNone) |
|
335 { |
|
336 enabledEAPTypes.ResetAndDestroy(); |
|
337 disabledEAPTypes.ResetAndDestroy(); |
|
338 User::LeaveIfError(error); |
|
339 } |
|
340 |
|
341 EAP_TRACE_DATA_DEBUG_SYMBIAN(("CEapTlsPeapUiEapTypes::UpdateExpandedDataL:Appended ENABLED EAP type:", |
|
342 expandedEAPTmp->iExpandedEAPType.Ptr(), |
|
343 expandedEAPTmp->iExpandedEAPType.Size() ) ); |
|
344 } |
|
345 else |
|
346 { |
|
347 // Disabled |
|
348 TInt error = disabledEAPTypes.Append(expandedEAPTmp); |
|
349 |
|
350 if (error != KErrNone) |
|
351 { |
|
352 enabledEAPTypes.ResetAndDestroy(); |
|
353 disabledEAPTypes.ResetAndDestroy(); |
|
354 User::LeaveIfError(error); |
|
355 } |
|
356 |
|
357 EAP_TRACE_DATA_DEBUG_SYMBIAN(("CEapTlsPeapUiEapTypes::UpdateExpandedDataL:Appended DISABLED EAP type:", |
|
358 expandedEAPTmp->iExpandedEAPType.Ptr(), |
|
359 expandedEAPTmp->iExpandedEAPType.Size() ) ); |
|
360 } |
|
361 |
|
362 CleanupStack::Pop(expandedEAPTmp); |
|
363 } |
|
364 |
|
365 eap_type_value_e tunnelingType(static_cast<eap_type_ietf_values_e>(iUiConn->GetTunnelingType())); |
|
366 eap_type_value_e eapType(static_cast<eap_type_ietf_values_e>(iUiConn->GetEapType())); |
|
367 |
|
368 TRAPD(err, EapTlsPeapUtils::SetTunnelingExpandedEapDataL( |
|
369 iDatabase, |
|
370 0, |
|
371 enabledEAPTypes, |
|
372 disabledEAPTypes, |
|
373 iUiConn->GetIndexType(), |
|
374 iUiConn->GetIndex(), |
|
375 tunnelingType, |
|
376 eapType)); |
|
377 |
|
378 enabledEAPTypes.ResetAndDestroy(); |
|
379 disabledEAPTypes.ResetAndDestroy(); |
|
380 |
|
381 if (err != KErrNone) |
|
382 { |
|
383 EAP_TRACE_DEBUG_SYMBIAN( |
|
384 (_L("CEapTlsPeapUiEapTypes::UpdateExpandedDataL: Error from SetTunnelingExpandedEapDataL:%d\n"), |
|
385 err)); |
|
386 |
|
387 User::Leave(err); |
|
388 } |
|
389 |
|
390 EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiEapTypes::UpdateExpandedDataL: End\n"))); |
|
391 } |
|
392 |
|
393 #endif // #ifdef USE_EAP_EXPANDED_TYPES |
|
394 |
|
395 // End of file |