|
1 /* |
|
2 * Copyright (c) 2005 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 "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: Implementation of the class CProcessorWlan |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 |
|
23 #include "cdcprocessorwlan.h" |
|
24 #include "cdclogger.h" |
|
25 #include "cdcerrors.h" |
|
26 |
|
27 #include <cmpluginwlandef.h> |
|
28 #include <cmpluginbaseeng.h> |
|
29 #include <cmconnectionmethoddef.h> |
|
30 #include <cmmanagerext.h> |
|
31 #include <datamobilitycommsdattypes.h> |
|
32 #include <commsdattypesv1_1.h> |
|
33 #include <WlanCdbCols.h> |
|
34 #include <commsdattypesv1_1.h> |
|
35 #include <wlancontainer.h> |
|
36 #include <EapType.h> |
|
37 |
|
38 using namespace CMManager; |
|
39 |
|
40 // CONSTANTS |
|
41 |
|
42 // network modes. |
|
43 _LIT16( KStrAd_hoc, "Ad-hoc" ); |
|
44 _LIT16( KStrInfrastructure, "Infrastructure" ); // Default value. |
|
45 |
|
46 // security modes. |
|
47 _LIT16( KStrWEP, "WEP" ); |
|
48 _LIT16( KStr802_1x, "802.1x" ); |
|
49 _LIT16( KStrWPA, "WPA" ); // WPA/WPA2 mixed mode |
|
50 _LIT16( KStrWPA2, "WPA2" ); // WPA2-only mode |
|
51 _LIT16( KStrOpen, "Open" ); // Default value. |
|
52 |
|
53 // default WLAN channel Id value |
|
54 const TInt KDefaultChannelId = 0; |
|
55 const TInt KMaximumChannelId = 11; |
|
56 |
|
57 // default port number |
|
58 const TUint32 KDefaultPortNum = 0; |
|
59 |
|
60 // ratio between sizes of ascii and unicode characters |
|
61 const TUint KAsciiUnicodeRatio = 2; |
|
62 |
|
63 // Length of expanded EAP type identifier |
|
64 const TUint KExpandedEAPIdLength = 8; |
|
65 |
|
66 // Plain MSCHAPv2 EAP identifier. Needed because of special handling |
|
67 const TUint8 KMschapv2TypeId[] = {0xfe, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x63}; |
|
68 |
|
69 // ================= MEMBER FUNCTIONS ======================= |
|
70 |
|
71 CEapTypeElement::~CEapTypeElement() |
|
72 { |
|
73 delete iEapSettings; |
|
74 delete iName; |
|
75 } |
|
76 |
|
77 |
|
78 // --------------------------------------------------------- |
|
79 // CProcessorWlan::NewL |
|
80 // --------------------------------------------------------- |
|
81 // |
|
82 CProcessorWlan* CProcessorWlan::NewL( CReaderBase* aFileReader, |
|
83 RCmManagerExt& aCmManager, |
|
84 RPointerArray< RCmConnectionMethodExt >& aPluginArray, |
|
85 RPointerArray< HBufC >& aPluginNames, |
|
86 RPointerArray< HBufC >& aSecurityInfo, |
|
87 RPointerArray< CEapTypeElement >& aEapSettings ) |
|
88 { |
|
89 CProcessorWlan* self = new ( ELeave ) CProcessorWlan( aFileReader, |
|
90 aCmManager, |
|
91 aPluginArray, |
|
92 aPluginNames, |
|
93 aSecurityInfo, |
|
94 aEapSettings ); |
|
95 CleanupStack::PushL( self ); |
|
96 |
|
97 // From base class |
|
98 self->ConstructL(); |
|
99 CleanupStack::Pop( self ); |
|
100 return self; |
|
101 } |
|
102 |
|
103 |
|
104 // --------------------------------------------------------- |
|
105 // CProcessorWlan::ConstructL |
|
106 // --------------------------------------------------------- |
|
107 // |
|
108 void CProcessorWlan::ConstructL() |
|
109 { |
|
110 iEmptyTag = KStrEmpty.operator const TDesC16&().Alloc(); |
|
111 |
|
112 Reset(); // iWepData, iWpaData |
|
113 } |
|
114 |
|
115 |
|
116 // --------------------------------------------------------- |
|
117 // CProcessorWlan::CProcessorWlan |
|
118 // --------------------------------------------------------- |
|
119 // |
|
120 CProcessorWlan::CProcessorWlan( CReaderBase* aFileReader, |
|
121 RCmManagerExt& aCmManager, |
|
122 RPointerArray< RCmConnectionMethodExt >& aPluginArray, |
|
123 RPointerArray< HBufC >& aPluginNames, |
|
124 RPointerArray< HBufC >& aSecurityInfo, |
|
125 RPointerArray< CEapTypeElement >& aEapSettings ) : |
|
126 CProcessorBase( aFileReader, |
|
127 aCmManager, |
|
128 aPluginArray, |
|
129 aPluginNames ), |
|
130 iSecurityMode( ESecurityModeOpen ), |
|
131 iEapSettings( aEapSettings ), |
|
132 iIsEasyWlan( ETrue ) |
|
133 { |
|
134 iBearerType = KUidWlanBearerType; |
|
135 iSecurityInfo = &aSecurityInfo; |
|
136 iDataStart = 0; |
|
137 } |
|
138 |
|
139 |
|
140 // --------------------------------------------------------- |
|
141 // CProcessorWlan::~CProcessorWlan |
|
142 // --------------------------------------------------------- |
|
143 // |
|
144 CProcessorWlan::~CProcessorWlan() |
|
145 { |
|
146 delete iEmptyTag; |
|
147 } |
|
148 |
|
149 // --------------------------------------------------------- |
|
150 // CProcessorWlan::ProcessSpecialFieldsL |
|
151 // --------------------------------------------------------- |
|
152 // |
|
153 void CProcessorWlan::ProcessSpecialFieldsL( TInt aField, HBufC* aPtrTag, TInt /*aDx*/ ) |
|
154 { |
|
155 switch( aField ) |
|
156 { |
|
157 // TDesC16 |
|
158 case EWlanSSID: |
|
159 { |
|
160 if ( aPtrTag->CompareF( KStrEmpty ) != 0 ) |
|
161 { |
|
162 iPlugin.SetStringAttributeL( aField, *aPtrTag ); |
|
163 iIsEasyWlan = EFalse; |
|
164 } |
|
165 else |
|
166 { |
|
167 // Access point is Easy WLAN |
|
168 iIsEasyWlan = ETrue; |
|
169 } |
|
170 break; |
|
171 } |
|
172 case EWlanIpAddr: |
|
173 { |
|
174 if ( aPtrTag->CompareF( KStrEmpty ) != 0 ) |
|
175 { |
|
176 iPlugin.SetStringAttributeL( aField, *aPtrTag ); |
|
177 } |
|
178 break; |
|
179 } |
|
180 // TDesC16 |
|
181 case EWlanIpGateway: //fall through |
|
182 case EWlanIpNetMask: //fall through |
|
183 { |
|
184 iPlugin.SetStringAttributeL( aField, *aPtrTag ); |
|
185 break; |
|
186 } |
|
187 case EWlanIpNameServer1: //fall through |
|
188 case EWlanIpNameServer2: //fall through |
|
189 case EWlanIp6NameServer1: //fall through |
|
190 case EWlanIp6NameServer2: //fall through |
|
191 { |
|
192 iPlugin.SetStringAttributeL( aField, *aPtrTag ); |
|
193 SetAddressFromServerL( EWlanIpNameServer1, |
|
194 EWlanIpNameServer2, |
|
195 EWlanIpDNSAddrFromServer, |
|
196 EWlanIp6NameServer1, |
|
197 EWlanIp6NameServer2, |
|
198 EWlanIp6DNSAddrFromServer ); |
|
199 break; |
|
200 } |
|
201 // TUint32 |
|
202 case EWlanSecurityMode: |
|
203 { |
|
204 |
|
205 if ( aPtrTag->CompareF( KStrWEP ) == 0 ) |
|
206 { |
|
207 // WEP |
|
208 iPlugin.SetIntAttributeL( aField, EWlanSecModeWep ); |
|
209 iSecurityMode = ESecurityModeWEP; |
|
210 } |
|
211 else if ( aPtrTag->CompareF( KStr802_1x ) == 0 ) |
|
212 { |
|
213 // 802.1x |
|
214 iPlugin.SetIntAttributeL( aField, EWlanSecMode802_1x ); |
|
215 iSecurityMode = ESecurityMode802; |
|
216 } |
|
217 else if ( aPtrTag->CompareF( KStrWPA ) == 0 ) |
|
218 { |
|
219 // WPA/WPA2 mixed mode |
|
220 iPlugin.SetIntAttributeL( aField, EWlanSecModeWpa ); |
|
221 iSecurityMode = ESecurityModeWPA; |
|
222 } |
|
223 else if ( aPtrTag->CompareF( KStrWPA2 ) == 0 ) |
|
224 { |
|
225 // WPA2 |
|
226 iPlugin.SetIntAttributeL( aField, EWlanSecModeWpa2 ); |
|
227 iSecurityMode = ESecurityModeWPA2; |
|
228 } |
|
229 else if ( aPtrTag->CompareF( KStrOpen ) == 0 ) |
|
230 { |
|
231 // Open network (default) |
|
232 iPlugin.SetIntAttributeL( aField, EWlanSecModeOpen ); |
|
233 iSecurityMode = ESecurityModeOpen; |
|
234 } |
|
235 else |
|
236 { |
|
237 iPlugin.SetIntAttributeL( aField, EWlanSecModeOpen ); |
|
238 iSecurityMode = ESecurityModeOpen; |
|
239 CLOG_WRITE( "! Error : Invalid Security Mode. Default:Open" ) |
|
240 } |
|
241 break; |
|
242 } |
|
243 |
|
244 // TUint32 |
|
245 case EWlanConnectionMode: |
|
246 { |
|
247 |
|
248 if ( !aPtrTag->CompareF( KStrAd_hoc ) ) |
|
249 { |
|
250 // Ad-hoc |
|
251 iPlugin.SetIntAttributeL( aField, EAdhoc ); |
|
252 } |
|
253 else if ( !aPtrTag->CompareF( KStrInfrastructure ) ) |
|
254 { |
|
255 // Infrastructure |
|
256 iPlugin.SetIntAttributeL( aField, EInfra ); |
|
257 } |
|
258 else |
|
259 { |
|
260 iPlugin.SetIntAttributeL( aField, EInfra ); |
|
261 CLOG_WRITE( "! Error : Invalid Network Mode. Default:Infrastructure" ) |
|
262 } |
|
263 break; |
|
264 } |
|
265 |
|
266 // TUint32 |
|
267 case ECmProxyPortNumber: |
|
268 { |
|
269 // First set proxy usage to enabled |
|
270 if( !iProxyEnabled ) |
|
271 { |
|
272 iPlugin.SetBoolAttributeL( ECmProxyUsageEnabled, ETrue ); |
|
273 iProxyEnabled = ETrue; |
|
274 } |
|
275 TLex16 lex( *aPtrTag ); |
|
276 TUint32 tmp( 0 ); |
|
277 if ( lex.Val( tmp, EDecimal ) == KErrNone ) |
|
278 { |
|
279 iPlugin.SetIntAttributeL( aField, tmp ); |
|
280 } |
|
281 else |
|
282 { |
|
283 //no valid data is given |
|
284 iPlugin.SetIntAttributeL( aField, KDefaultPortNum ); |
|
285 CLOG_WRITE( "! Error : Invalid port number. Default:0" ); |
|
286 } |
|
287 break; |
|
288 } |
|
289 // Long text. |
|
290 case ECmStartPage: |
|
291 { |
|
292 |
|
293 if ( aPtrTag->CompareF( KStrEmpty ) != 0 ) |
|
294 { |
|
295 iPlugin.SetStringAttributeL( aField, *aPtrTag ); |
|
296 } |
|
297 break; |
|
298 } |
|
299 |
|
300 case ECmProxyProtocolName: |
|
301 { |
|
302 // Do not enable proxy in this case yet |
|
303 iPlugin.SetStringAttributeL( aField, *aPtrTag ); |
|
304 break; |
|
305 } |
|
306 |
|
307 // Long text. |
|
308 case ECmProxyServerName: |
|
309 { |
|
310 // First set proxy usage to enabled |
|
311 if( !iProxyEnabled ) |
|
312 { |
|
313 iPlugin.SetBoolAttributeL( ECmProxyUsageEnabled, ETrue ); |
|
314 iProxyEnabled = ETrue; |
|
315 } |
|
316 iPlugin.SetStringAttributeL( aField, *aPtrTag ); |
|
317 break; |
|
318 } |
|
319 // Bool |
|
320 case EWlanScanSSID: |
|
321 { |
|
322 if ( !aPtrTag->CompareF( KStrYes ) ) |
|
323 { |
|
324 iPlugin.SetBoolAttributeL( aField, ETrue ); |
|
325 } |
|
326 else if ( !aPtrTag->CompareF( KStrNo ) ) |
|
327 { |
|
328 iPlugin.SetBoolAttributeL( aField, EFalse ); |
|
329 } |
|
330 else |
|
331 { |
|
332 iPlugin.SetBoolAttributeL( aField, EFalse ); |
|
333 CLOG_WRITE( "! Error : Invalid Scan SSID. Default:No" ) |
|
334 } |
|
335 break; |
|
336 } |
|
337 |
|
338 // TUint32 |
|
339 case EWlanChannelID: |
|
340 { |
|
341 TLex16 lex( *aPtrTag ); |
|
342 TUint32 tmp( 0 ); |
|
343 lex.Val( tmp, EDecimal ); |
|
344 |
|
345 if( tmp <= KMaximumChannelId ) |
|
346 { |
|
347 iPlugin.SetIntAttributeL( aField, tmp ); |
|
348 } |
|
349 else |
|
350 { |
|
351 // Default value |
|
352 iPlugin.SetIntAttributeL( aField, KDefaultChannelId ); |
|
353 CLOG_WRITE( "! Error : Invalid Chanel Id. Default:0" ) |
|
354 } |
|
355 break; |
|
356 } |
|
357 //WEP |
|
358 case EWEPKeyInUse: |
|
359 case EWEPAuthType: |
|
360 case EWEPKey1Length: |
|
361 case EWEPKey1Format: |
|
362 case EWEPKey1Data: |
|
363 case EWEPKey2Length: |
|
364 case EWEPKey2Format: |
|
365 case EWEPKey2Data: |
|
366 case EWEPKey3Length: |
|
367 case EWEPKey3Format: |
|
368 case EWEPKey3Data: |
|
369 case EWEPKey4Length: |
|
370 case EWEPKey4Format: |
|
371 case EWEPKey4Data: |
|
372 { |
|
373 if( iSecurityMode == ESecurityModeWEP ) |
|
374 { |
|
375 AddSecurityDataL( aField, aPtrTag, ETrue ); |
|
376 } |
|
377 } |
|
378 break; |
|
379 //WPA |
|
380 case EWPAPresharedKey: |
|
381 case EWPAKeyLength: |
|
382 case EWPAListOfEAPs: |
|
383 case EWPAUseOfPresharedKey: |
|
384 { |
|
385 if( iSecurityMode != ESecurityModeWEP && iSecurityMode != ESecurityModeOpen ) |
|
386 { |
|
387 AddSecurityDataL( aField, aPtrTag, EFalse ); |
|
388 } |
|
389 } |
|
390 break; |
|
391 |
|
392 default: |
|
393 // Check if this is EAP setting |
|
394 if ( EAPSetting( aField ) ) |
|
395 { |
|
396 AddEAPSettingL( aField, aPtrTag ); |
|
397 } |
|
398 else |
|
399 { |
|
400 CLOG_WRITE_FORMAT( "! Warning: Unhandled setting for WLAN: %d", aField ); |
|
401 } |
|
402 break; |
|
403 }//switch |
|
404 } |
|
405 |
|
406 |
|
407 // --------------------------------------------------------- |
|
408 // CProcessorWlan::ProcessAPL |
|
409 // --------------------------------------------------------- |
|
410 // |
|
411 void CProcessorWlan::ProcessAPL() |
|
412 { |
|
413 |
|
414 RCmConnectionMethodExt& iPlugin = GetLastPluginL(); |
|
415 |
|
416 if( iIsProtected ) |
|
417 { |
|
418 iPlugin.SetBoolAttributeL( ECmProtected, ETrue ); |
|
419 } |
|
420 |
|
421 // Ensure that Easy WLAN is always an open network |
|
422 if( iIsEasyWlan ) |
|
423 { |
|
424 iSecurityMode = ESecurityModeOpen; |
|
425 } |
|
426 |
|
427 FillSecurityInfoL(); |
|
428 |
|
429 // Writes into the log file. |
|
430 DoLogL(); |
|
431 |
|
432 Reset(); // iWepData, iWpaData |
|
433 } |
|
434 |
|
435 // --------------------------------------------------------- |
|
436 // CProcessorWlan::ProcessAPL |
|
437 // --------------------------------------------------------- |
|
438 // |
|
439 void CProcessorWlan::FillSecurityInfoL() |
|
440 { |
|
441 //Set Security mode settings |
|
442 switch ( iSecurityMode ) |
|
443 { |
|
444 case ESecurityModeWEP: |
|
445 if ( WEPFieldValidate() ) |
|
446 { |
|
447 FillSecurityInfoL( ETrue ); //WEP |
|
448 } |
|
449 else |
|
450 { |
|
451 CLOG_WRITE( "! Error : WEP settings are not valid." ) |
|
452 } |
|
453 break; |
|
454 case ESecurityMode802: |
|
455 case ESecurityModeWPA: |
|
456 case ESecurityModeWPA2: |
|
457 { |
|
458 FillSecurityInfoL( EFalse ); //WPA |
|
459 break; |
|
460 } |
|
461 default: |
|
462 { |
|
463 } |
|
464 break; |
|
465 } |
|
466 } |
|
467 |
|
468 // --------------------------------------------------------- |
|
469 // CProcessorWlan::ProcessAPL |
|
470 // --------------------------------------------------------- |
|
471 // |
|
472 void CProcessorWlan::FillSecurityInfoL( TBool aIsWep ) |
|
473 { |
|
474 // iName has been deleted by Base. Name is retrieved from name array. |
|
475 TInt lastPos = iPluginArray->Count() - 1; |
|
476 HBufC* name = (*iPluginName)[ lastPos ]; |
|
477 |
|
478 // Name appended to the array |
|
479 iSecurityInfo->Append( name->AllocL() ); |
|
480 CLOG_WRITE_FORMAT( "FillSecurityInfoL %S", name ); |
|
481 CLOG_WRITE_FORMAT( "FillSecurityInfoL start %d", iSecurityInfo->Count() ); |
|
482 |
|
483 if( aIsWep ) |
|
484 { |
|
485 // Security type appended to the array |
|
486 iSecurityInfo->Append( KStrWEP.operator const TDesC16&().Alloc() ); |
|
487 for( TInt i( 0 ); i < KWEPKeyNumOfFields; i++ ) |
|
488 { |
|
489 |
|
490 if( iWepData[i] != NULL ) |
|
491 { |
|
492 CLOG_WRITE_FORMAT( "wep info %S", iWepData[i] ); |
|
493 } |
|
494 else |
|
495 { |
|
496 CLOG_WRITE( "wep info NULL" ); |
|
497 } |
|
498 iSecurityInfo->Append( iWepData[i] ); |
|
499 } |
|
500 } |
|
501 else |
|
502 { |
|
503 // Security type appended to the array |
|
504 switch ( iSecurityMode ) |
|
505 { |
|
506 case ESecurityMode802: |
|
507 iSecurityInfo->Append( KStr802_1x.operator const TDesC16&().Alloc() ); |
|
508 break; |
|
509 case ESecurityModeWPA2: |
|
510 iSecurityInfo->Append( KStrWPA2.operator const TDesC16&().Alloc() ); |
|
511 break; |
|
512 default: |
|
513 iSecurityInfo->Append( KStrWPA.operator const TDesC16&().Alloc() ); |
|
514 break; |
|
515 } |
|
516 |
|
517 for( TInt i( 0 ); i < KWPAKeyNumOfFields; i++ ) |
|
518 { |
|
519 |
|
520 if( iWpaData[i] != NULL ) |
|
521 { |
|
522 CLOG_WRITE_FORMAT( "wpa info %S", iWpaData[i] ); |
|
523 } |
|
524 else |
|
525 { |
|
526 CLOG_WRITE( "wep info NULL" ); |
|
527 } |
|
528 iSecurityInfo->Append( iWpaData[ i ] ); |
|
529 } |
|
530 } |
|
531 |
|
532 CLOG_WRITE_FORMAT( "FillSecurityInfoL end %d", iSecurityInfo->Count() ); |
|
533 } |
|
534 |
|
535 // --------------------------------------------------------- |
|
536 // CProcessorWlan::SaveSecurityInfoL |
|
537 // --------------------------------------------------------- |
|
538 // |
|
539 void CProcessorWlan::SaveSecurityInfoL() |
|
540 { |
|
541 TInt i(0); |
|
542 |
|
543 while( i < iSecurityInfo->Count() ) |
|
544 { |
|
545 if( (*iSecurityInfo)[i] != NULL ) |
|
546 { |
|
547 CLOG_WRITE_FORMAT( "Sec Info: %S", (*iSecurityInfo)[i] ); |
|
548 } |
|
549 else |
|
550 { |
|
551 CLOG_WRITE( "Sec Info: NULL" ); |
|
552 } |
|
553 |
|
554 i++; |
|
555 } |
|
556 |
|
557 |
|
558 i = 0; |
|
559 |
|
560 while( i < iSecurityInfo->Count() ) |
|
561 { |
|
562 CLOG_WRITE_FORMAT( "SaveSecurityInfoL %S", (*iSecurityInfo)[i] ); |
|
563 |
|
564 TInt id = GetPluginIdL( (*iSecurityInfo)[i] ); |
|
565 if( id != KErrNotFound ) |
|
566 { |
|
567 i++; |
|
568 SaveSecurityInfoL( i, id ); |
|
569 } |
|
570 else |
|
571 { |
|
572 CLOG_WRITE_FORMAT( "WLan IAp cannot find %S", (*iSecurityInfo)[i] ); |
|
573 CLOG_WRITE( "Security save likely collapsed" ); |
|
574 // Tries to look for an existing IAP. |
|
575 i++; |
|
576 } |
|
577 } |
|
578 |
|
579 // EAP settings |
|
580 CLOG_WRITE( "Starting EAP settings saving" ); |
|
581 CMDBSession* session = CMDBSession::NewL( CMDBSession::LatestVersion() ); |
|
582 CleanupStack::PushL( session ); |
|
583 |
|
584 // Load IAP record in order to get the service id |
|
585 for ( i = 0; i < iEapSettings.Count() ; i++ ) |
|
586 { |
|
587 CEapTypeElement* eap = iEapSettings[i]; |
|
588 // |
|
589 TInt id = GetPluginIdL( eap->iName ); |
|
590 |
|
591 CCDIAPRecord* iapRecord = static_cast< CCDIAPRecord * > |
|
592 ( CCDRecordBase::RecordFactoryL( KCDTIdIAPRecord ) ); |
|
593 |
|
594 CleanupStack::PushL( iapRecord ); |
|
595 |
|
596 iapRecord->SetRecordId( id ); |
|
597 |
|
598 iapRecord->LoadL( *session ); |
|
599 |
|
600 TInt serviceId = iapRecord->iService; |
|
601 |
|
602 CleanupStack::PopAndDestroy( iapRecord ); |
|
603 |
|
604 TInt err = KErrNone; |
|
605 TUint8 expandedEapId[] = {0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
|
606 |
|
607 TBuf8<KExpandedEAPIdLength> cue; |
|
608 |
|
609 // Set-up 64-bit expanded EAP id |
|
610 if ( eap->iEapSettings->iEAPType == KMschapv2TypeId[7] ) |
|
611 { |
|
612 // This is plain MSCHAPv2. Set vendor ID correctly |
|
613 expandedEapId[1] = KMschapv2TypeId[1]; |
|
614 expandedEapId[2] = KMschapv2TypeId[2]; |
|
615 expandedEapId[3] = KMschapv2TypeId[3]; |
|
616 } |
|
617 |
|
618 expandedEapId[KExpandedEAPIdLength - 1] = static_cast<TUint8> ( eap->iEapSettings->iEAPType ); |
|
619 cue.Copy( expandedEapId, KExpandedEAPIdLength ); |
|
620 |
|
621 // Try loading EAP ECOM module |
|
622 CLOG_WRITE_FORMAT( "Try to load EAP module: %d", expandedEapId[7]); |
|
623 CEapType* eapType = 0; |
|
624 TRAP( err, eapType = CEapType::NewL( cue, ELan, serviceId ) ); |
|
625 // The error is caused by probably missing EAP method from the device. Ignore the error |
|
626 // because same scripts can be used for devices with and without certain methods. |
|
627 if( err == KErrNone ) |
|
628 { |
|
629 CleanupStack::PushL( eapType ); |
|
630 |
|
631 // Check if this type is tunneled |
|
632 if ( eap->iEncapsulatingEapId != EAPSettings::EEapNone ) |
|
633 { |
|
634 // It is tunneled. Take the last byte of the expanded id. |
|
635 eapType->SetTunnelingType( eap->iEncapsulatingEapId ); |
|
636 } |
|
637 CLOG_WRITE( "Calling eapType->SetConfiguration" ); |
|
638 eapType->SetConfigurationL( *eap->iEapSettings ); |
|
639 CLOG_WRITE( "eapType->SetConfiguration success!" ); |
|
640 CleanupStack::PopAndDestroy( eapType ); |
|
641 } |
|
642 } |
|
643 |
|
644 session->Close(); |
|
645 CleanupStack::PopAndDestroy( session ); |
|
646 CLOG_WRITE( "Finished EAP settings saving" ); |
|
647 //iEapSettings.ResetAndDestroy(); |
|
648 |
|
649 CLOG_WRITE_FORMAT( "SaveSecurityInfoL end %d", iSecurityInfo->Count() ); |
|
650 } |
|
651 |
|
652 // --------------------------------------------------------- |
|
653 // CProcessorWlan::SaveSecurityInfoL |
|
654 // --------------------------------------------------------- |
|
655 // |
|
656 void CProcessorWlan::SaveSecurityInfoL( TInt& aCounter, TInt aId ) |
|
657 { |
|
658 if( (*iSecurityInfo)[ aCounter ]->Compare( KStrWEP ) == 0 ) |
|
659 { |
|
660 aCounter++; |
|
661 TInt end( aCounter + KWEPKeyNumOfFields ); |
|
662 |
|
663 for( TInt index(0); aCounter < end; aCounter++, index++ ) |
|
664 { |
|
665 if( (*iSecurityInfo)[ aCounter ] != NULL ) |
|
666 { |
|
667 CLOG_WRITE_FORMAT( "wep info %S", (*iSecurityInfo)[ aCounter ] ); |
|
668 } |
|
669 else |
|
670 { |
|
671 CLOG_WRITE( "wep info NULL" ); |
|
672 } |
|
673 iWepData[ index] = (*iSecurityInfo)[ aCounter ] ; |
|
674 } |
|
675 SaveWEPL( aId ); |
|
676 } |
|
677 else |
|
678 { |
|
679 |
|
680 // Set security mode. |
|
681 if ( (*iSecurityInfo)[ aCounter ]->CompareF( KStr802_1x ) == 0 ) |
|
682 { |
|
683 // 802.1x |
|
684 iSecurityMode = ESecurityMode802; |
|
685 } |
|
686 else if ( (*iSecurityInfo)[ aCounter ]->CompareF( KStrWPA2 ) == 0 ) |
|
687 { |
|
688 // WPA2 mode |
|
689 iSecurityMode = ESecurityModeWPA2; |
|
690 } |
|
691 else |
|
692 { |
|
693 // WPA |
|
694 iSecurityMode = ESecurityModeWPA; |
|
695 } |
|
696 |
|
697 aCounter++; |
|
698 TInt end( aCounter + KWPAKeyNumOfFields ); |
|
699 |
|
700 for( TInt index(0); aCounter < end; aCounter++, index++ ) |
|
701 { |
|
702 if( (*iSecurityInfo)[ aCounter ] != NULL ) |
|
703 { |
|
704 CLOG_WRITE_FORMAT( "wpa info %S", (*iSecurityInfo)[ aCounter ] ); |
|
705 } |
|
706 else |
|
707 { |
|
708 CLOG_WRITE( "wpa info NULL" ); |
|
709 } |
|
710 iWpaData[ index ] = (*iSecurityInfo)[ aCounter ] ; |
|
711 } |
|
712 SaveWPAL( aId ); |
|
713 } |
|
714 } |
|
715 |
|
716 |
|
717 |
|
718 // --------------------------------------------------------- |
|
719 // WEP Security settings |
|
720 // --------------------------------------------------------- |
|
721 |
|
722 // --------------------------------------------------------- |
|
723 // CProcessorWlan::SaveWEPL |
|
724 // --------------------------------------------------------- |
|
725 // |
|
726 void CProcessorWlan::SaveWEPL( TUint32 aIapId ) |
|
727 { |
|
728 CMDBSession* session = CMDBSession::NewL( CMDBSession::LatestVersion() ); |
|
729 CleanupStack::PushL( session ); |
|
730 // Load IAP record |
|
731 CCDIAPRecord* iapRecord = static_cast< CCDIAPRecord * > |
|
732 ( CCDRecordBase::RecordFactoryL( KCDTIdIAPRecord ) ); |
|
733 CleanupStack::PushL( iapRecord ); |
|
734 iapRecord->SetRecordId( aIapId ); |
|
735 iapRecord->LoadL( *session ); |
|
736 |
|
737 // Load WLAN service table |
|
738 // first get WLAN table id |
|
739 CMDBGenericRecord* generic = static_cast<CMDBGenericRecord*> |
|
740 ( CCDRecordBase::RecordFactoryL( 0 ) ); |
|
741 CleanupStack::PushL( generic ); |
|
742 generic->InitializeL( TPtrC( WLAN_SERVICE ), NULL ); |
|
743 generic->LoadL( *session ); |
|
744 TMDBElementId wlanTableId = generic->TableId(); |
|
745 |
|
746 CMDBField<TUint32>* sidField = static_cast<CMDBField<TUint32>*> |
|
747 ( generic->GetFieldByIdL( KCDTIdWlanServiceId ) ); |
|
748 |
|
749 TInt service = iapRecord->iService; |
|
750 // prime with service id |
|
751 *sidField = (TUint32)service; |
|
752 |
|
753 User::LeaveIfError( generic->FindL( *session ) ); |
|
754 |
|
755 // Save index of key in use |
|
756 TUint32 keyInUse( WEPKeyInUse() ); |
|
757 CMDBField<TUint>* keyInUseField = static_cast<CMDBField<TUint>*> |
|
758 ( generic->GetFieldByIdL( KCDTIdWlanWepIndex ) ); |
|
759 keyInUseField->SetL( keyInUse ); |
|
760 |
|
761 // Save authentication mode |
|
762 TUint32 auth( WEPAuthentication() ); |
|
763 CMDBField<TUint>* authenticationField = static_cast<CMDBField<TUint>*> |
|
764 ( generic->GetFieldByIdL( KCDTIdWlanAuthMode ) ); |
|
765 authenticationField->SetL( auth ); |
|
766 |
|
767 // Save WEP keys and key formats |
|
768 if ( WEPFieldData( EWEPKey1Data )->Length() ) |
|
769 { |
|
770 CMDBField<TDesC8>* wepKey1Field = static_cast<CMDBField<TDesC8>*> |
|
771 ( generic->GetFieldByIdL( KCDTIdWlanWepKey1 ) ); |
|
772 WriteKeyL( wepKey1Field, |
|
773 WEPFieldData( EWEPKey1Data ), |
|
774 WEPKeyFormat( EWEPKey1Format ) ); |
|
775 CMDBField<TUint>* formatKey1Field = static_cast<CMDBField<TUint>*> |
|
776 ( generic->GetFieldByIdL( KCDTIdWlanFormatKey1 ) ); |
|
777 formatKey1Field->SetL( WEPKeyFormat( EWEPKey1Format ) ); |
|
778 } |
|
779 if ( WEPFieldData( EWEPKey2Data )->Length() ) |
|
780 { |
|
781 CMDBField<TDesC8>* wepKey2Field = static_cast<CMDBField<TDesC8>*> |
|
782 ( generic->GetFieldByIdL( KCDTIdWlanWepKey2 ) ); |
|
783 WriteKeyL( wepKey2Field, |
|
784 WEPFieldData( EWEPKey2Data ), |
|
785 WEPKeyFormat( EWEPKey2Format ) ); |
|
786 CMDBField<TUint>* formatKey2Field = static_cast<CMDBField<TUint>*> |
|
787 ( generic->GetFieldByIdL( KCDTIdWlanFormatKey2 ) ); |
|
788 formatKey2Field->SetL( WEPKeyFormat( EWEPKey2Format ) ); |
|
789 } |
|
790 if ( WEPFieldData( EWEPKey3Data )->Length() ) |
|
791 { |
|
792 CMDBField<TDesC8>* wepKey3Field = static_cast<CMDBField<TDesC8>*> |
|
793 ( generic->GetFieldByIdL( KCDTIdWlanWepKey3 ) ); |
|
794 WriteKeyL( wepKey3Field, |
|
795 WEPFieldData( EWEPKey3Data ), |
|
796 WEPKeyFormat( EWEPKey3Format ) ); |
|
797 CMDBField<TUint>* formatKey3Field = static_cast<CMDBField<TUint>*> |
|
798 ( generic->GetFieldByIdL( KCDTIdWlanFormatKey3 ) ); |
|
799 formatKey3Field->SetL( WEPKeyFormat( EWEPKey3Format ) ); |
|
800 } |
|
801 if ( WEPFieldData( EWEPKey4Data )->Length() ) |
|
802 { |
|
803 CMDBField<TDesC8>* wepKey4Field = static_cast<CMDBField<TDesC8>*> |
|
804 ( generic->GetFieldByIdL( KCDTIdWlanWepKey4 ) ); |
|
805 WriteKeyL( wepKey4Field, |
|
806 WEPFieldData( EWEPKey4Data ), |
|
807 WEPKeyFormat( EWEPKey4Format ) ); |
|
808 CMDBField<TUint>* formatKey4Field = static_cast<CMDBField<TUint>*> |
|
809 ( generic->GetFieldByIdL( KCDTIdWlanFormatKey4 ) ); |
|
810 formatKey4Field->SetL( WEPKeyFormat( EWEPKey4Format ) ); |
|
811 } |
|
812 |
|
813 generic->ModifyL( *session ); |
|
814 |
|
815 CleanupStack::PopAndDestroy( generic ); // generic |
|
816 CleanupStack::PopAndDestroy( iapRecord ); // iapRecord |
|
817 CleanupStack::PopAndDestroy( session ); // session |
|
818 } |
|
819 |
|
820 |
|
821 // --------------------------------------------------------- |
|
822 // CProcessorWlan::WriteKeyL |
|
823 // --------------------------------------------------------- |
|
824 // |
|
825 void CProcessorWlan::WriteKeyL( CMDBField<TDesC8>* aKeyField, |
|
826 HBufC16* aKey, |
|
827 const TInt aKeyFormat ) |
|
828 { |
|
829 TBuf8<KMaxLengthOfKeyData> key; |
|
830 |
|
831 //convert to 8 bit |
|
832 key.Copy( aKey->Des() ); |
|
833 |
|
834 if ( aKeyFormat == EAscii ) |
|
835 { |
|
836 // Must be converted to hexa and stored as a hexa |
|
837 // Ascii key is half the length of Hex |
|
838 HBufC8* buf8Conv = HBufC8::NewLC( key.Length() * KAsciiUnicodeRatio ); |
|
839 ConvertAsciiToHex( key, buf8Conv ); |
|
840 aKeyField->SetL( buf8Conv->Des() ); |
|
841 CleanupStack::PopAndDestroy( buf8Conv ); |
|
842 } |
|
843 else if ( VerifyHex( key ) ) |
|
844 { |
|
845 //already in hexa format |
|
846 aKeyField->SetL( key ); |
|
847 } |
|
848 else |
|
849 { |
|
850 CLOG_WRITE( "! Error : Invalid hexadecimal format" ) |
|
851 } |
|
852 } |
|
853 |
|
854 // --------------------------------------------------------- |
|
855 // CProcessorWlan::WEPFieldData |
|
856 // --------------------------------------------------------- |
|
857 // |
|
858 HBufC16* CProcessorWlan::WEPFieldData( TDbCreatorWEPFields aFieldId ) |
|
859 { |
|
860 TInt index = WEPIndex( aFieldId ); |
|
861 if( iWepData[ index ] == NULL ) |
|
862 { |
|
863 return iEmptyTag; |
|
864 } |
|
865 else |
|
866 { |
|
867 return iWepData[ index ]; |
|
868 } |
|
869 } |
|
870 |
|
871 // --------------------------------------------------------- |
|
872 // CProcessorWlan::WEPAuthentication |
|
873 // --------------------------------------------------------- |
|
874 // |
|
875 TInt CProcessorWlan::WEPAuthentication() |
|
876 { |
|
877 HBufC16* authTypeStr = WEPFieldData( EWEPAuthType ); |
|
878 TInt authType ( EAuthOpen ) ; |
|
879 |
|
880 _LIT16( KStrOpen, "Open" ); |
|
881 _LIT16( KStrShared, "Shared" ); |
|
882 |
|
883 if ( authTypeStr->CompareF( KStrOpen ) == 0 ) |
|
884 { |
|
885 //CLOG_WRITE( "Authentication type : Open" ) |
|
886 } |
|
887 else if ( authTypeStr->CompareF( KStrShared ) == 0 ) |
|
888 { |
|
889 //CLOG_WRITE( "Authentication type : Shared" ) |
|
890 authType = EAuthShared; |
|
891 } |
|
892 else |
|
893 { |
|
894 //aField is either empty or invalid |
|
895 authType = KErrNotFound; |
|
896 } |
|
897 |
|
898 return authType; |
|
899 } |
|
900 |
|
901 // --------------------------------------------------------- |
|
902 // CProcessorWlan::WEPKeyInUse |
|
903 // --------------------------------------------------------- |
|
904 // |
|
905 TInt CProcessorWlan::WEPKeyInUse() |
|
906 { |
|
907 HBufC16* keyStr = WEPFieldData( EWEPKeyInUse ); |
|
908 TInt key ( EKeyNumber1 ) ; |
|
909 |
|
910 _LIT16( KStrKey1, "key1" ); |
|
911 _LIT16( KStrKey2, "key2" ); |
|
912 _LIT16( KStrKey3, "key3" ); |
|
913 _LIT16( KStrKey4, "key4" ); |
|
914 |
|
915 if ( keyStr->CompareF( KStrKey1 ) == 0 ) |
|
916 { |
|
917 //CLOG_WRITE( "WEP key in use : key 1" ) |
|
918 } |
|
919 else if ( keyStr->CompareF( KStrKey2 ) == 0 ) |
|
920 { |
|
921 //CLOG_WRITE( "WEP key in use : key 2" ) |
|
922 key = EKeyNumber2; |
|
923 } |
|
924 else if ( keyStr->CompareF( KStrKey3 ) == 0 ) |
|
925 { |
|
926 //CLOG_WRITE( "WEP key in use : key 3" ) |
|
927 key = EKeyNumber3; |
|
928 } |
|
929 else if ( keyStr->CompareF( KStrKey4 ) == 0 ) |
|
930 { |
|
931 //CLOG_WRITE( "WEP key in use : key 4" ) |
|
932 key = EKeyNumber4; |
|
933 } |
|
934 else |
|
935 { |
|
936 //aField is either empty or invalid |
|
937 key = KErrNotFound; |
|
938 } |
|
939 |
|
940 return key; |
|
941 } |
|
942 |
|
943 |
|
944 |
|
945 // --------------------------------------------------------- |
|
946 // CProcessorWlan::WEPKeyFormat |
|
947 // --------------------------------------------------------- |
|
948 // |
|
949 TInt CProcessorWlan::WEPKeyFormat( TDbCreatorWEPFields aFieldId ) |
|
950 { |
|
951 __ASSERT_ALWAYS( ( aFieldId == EWEPKey1Format || |
|
952 aFieldId == EWEPKey2Format || |
|
953 aFieldId == EWEPKey3Format || |
|
954 aFieldId == EWEPKey4Format ), |
|
955 User::Panic ( KPanicOutOfRange, KErrOutOfRange ) ); |
|
956 |
|
957 HBufC16* keyFormatStr = WEPFieldData( aFieldId ); |
|
958 TWEPKeyFormat keyFormat ( EAscii ) ; |
|
959 |
|
960 _LIT16( KStrAscii, "Ascii" ); |
|
961 _LIT16( KStrHexadecimal, "Hexadecimal" ); |
|
962 |
|
963 if ( keyFormatStr->CompareF( KStrAscii ) == 0 ) |
|
964 { |
|
965 //CLOG_WRITE( "Key format : Ascii" ) |
|
966 } |
|
967 else if ( keyFormatStr->CompareF( KStrHexadecimal ) == 0 ) |
|
968 { |
|
969 //CLOG_WRITE( "Key format : Hexadecimal" ) |
|
970 keyFormat = EHexadecimal; |
|
971 } |
|
972 else |
|
973 { |
|
974 CLOG_WRITE( "! Error : Invalid key format. Default:Ascii" ) |
|
975 } |
|
976 |
|
977 return keyFormat; |
|
978 } |
|
979 |
|
980 // --------------------------------------------------------- |
|
981 // CProcessorWlan::WEPKeyLength |
|
982 // --------------------------------------------------------- |
|
983 // |
|
984 TWEPKeyLength CProcessorWlan::WEPKeyLength( TDbCreatorWEPFields aFieldId ) |
|
985 { |
|
986 __ASSERT_ALWAYS( ( aFieldId == EWEPKey1Length || |
|
987 aFieldId == EWEPKey2Length || |
|
988 aFieldId == EWEPKey3Length || |
|
989 aFieldId == EWEPKey4Length ), |
|
990 User::Panic ( KPanicOutOfRange, KErrOutOfRange ) ); |
|
991 |
|
992 HBufC16* keyLengthStr = WEPFieldData( aFieldId ); |
|
993 TWEPKeyLength keyLen ( E40Bits ) ; |
|
994 |
|
995 _LIT16( KStr64, "64" ); |
|
996 _LIT16( KStr128, "128" ); |
|
997 _LIT16( KStr256, "256" ); |
|
998 |
|
999 if ( keyLengthStr->CompareF( KStr64 ) == 0 ) |
|
1000 { |
|
1001 //CLOG_WRITE( "Key length : 64" ) |
|
1002 } |
|
1003 else if ( keyLengthStr->CompareF( KStr128 ) == 0 ) |
|
1004 { |
|
1005 //CLOG_WRITE( "Key length : 128" ) |
|
1006 keyLen = E104Bits; |
|
1007 } |
|
1008 else if ( keyLengthStr->CompareF( KStr256 ) == 0 ) |
|
1009 { |
|
1010 //CLOG_WRITE( "Key length : 256" ) |
|
1011 keyLen = E232Bits; |
|
1012 } |
|
1013 else |
|
1014 { |
|
1015 CLOG_WRITE( "! Error : Invalid key length. Default:64" ) |
|
1016 } |
|
1017 |
|
1018 return keyLen; |
|
1019 } |
|
1020 |
|
1021 // --------------------------------------------------------- |
|
1022 // CProcessorWlan::WEPKeyValidLen |
|
1023 // --------------------------------------------------------- |
|
1024 // |
|
1025 TInt CProcessorWlan::WEPKeyValidLen(TInt aFormat , TWEPKeyLength aLen ) |
|
1026 { |
|
1027 __ASSERT_ALWAYS( aFormat == EAscii || aFormat == EHexadecimal, |
|
1028 User::Panic ( KPanicOutOfRange, KErrOutOfRange ) ); |
|
1029 |
|
1030 __ASSERT_ALWAYS( aLen == E40Bits || aLen == E104Bits || aLen == E232Bits, |
|
1031 User::Panic ( KPanicOutOfRange, KErrOutOfRange ) ); |
|
1032 |
|
1033 TInt len( 0 ); |
|
1034 |
|
1035 switch ( aFormat ) |
|
1036 { |
|
1037 case EAscii: |
|
1038 switch ( aLen ) |
|
1039 { |
|
1040 case E40Bits : len = KKeyDataLength40Bits / |
|
1041 KAsciiUnicodeRatio; |
|
1042 break; |
|
1043 case E104Bits : len = KKeyDataLength104Bits / |
|
1044 KAsciiUnicodeRatio; |
|
1045 break; |
|
1046 case E232Bits : len = KKeyDataLength232Bits / |
|
1047 KAsciiUnicodeRatio; |
|
1048 } |
|
1049 break; |
|
1050 case EHexadecimal: |
|
1051 switch ( aLen ) |
|
1052 { |
|
1053 case E40Bits : len = KKeyDataLength40Bits; |
|
1054 break; |
|
1055 case E104Bits : len = KKeyDataLength104Bits; |
|
1056 break; |
|
1057 case E232Bits : len = KKeyDataLength232Bits; |
|
1058 } |
|
1059 } |
|
1060 |
|
1061 return len; |
|
1062 } |
|
1063 |
|
1064 // --------------------------------------------------------- |
|
1065 // CProcessorWlan::WEPIndex |
|
1066 // --------------------------------------------------------- |
|
1067 // |
|
1068 TInt CProcessorWlan::WEPIndex( TDbCreatorWEPFields aFieldId ) |
|
1069 { |
|
1070 __ASSERT_ALWAYS( aFieldId >= EWEPKeyInUse && aFieldId <= EWEPKey4Data, |
|
1071 User::Panic ( KPanicOutOfRange, KErrOutOfRange ) ); |
|
1072 |
|
1073 return aFieldId - 0x1000 + iDataStart; |
|
1074 |
|
1075 ////return iWEPIndex[ aFieldId - 0x1000 ]; |
|
1076 } |
|
1077 |
|
1078 // --------------------------------------------------------- |
|
1079 // CProcessorWlan::WEPFieldValidate |
|
1080 // --------------------------------------------------------- |
|
1081 // |
|
1082 TBool CProcessorWlan::WEPFieldValidate() |
|
1083 { |
|
1084 TBool valid (ETrue); |
|
1085 |
|
1086 if ( ( WEPAuthentication() == KErrNotFound ) || |
|
1087 ( WEPKeyInUse() == KErrNotFound ) ) |
|
1088 { |
|
1089 valid = EFalse; |
|
1090 } |
|
1091 else |
|
1092 { |
|
1093 //gets the actual keylength |
|
1094 TInt keyLen[ KMaxNumberofKeys ] = { 0,0,0,0 }; |
|
1095 |
|
1096 keyLen[EKeyNumber1] = WEPFieldData( EWEPKey1Data )->Length(); |
|
1097 keyLen[EKeyNumber2] = WEPFieldData( EWEPKey2Data )->Length(); |
|
1098 keyLen[EKeyNumber3] = WEPFieldData( EWEPKey3Data )->Length(); |
|
1099 keyLen[EKeyNumber4] = WEPFieldData( EWEPKey4Data )->Length(); |
|
1100 |
|
1101 |
|
1102 //check validity of key1 length |
|
1103 TInt validLen = WEPKeyValidLen( WEPKeyFormat( EWEPKey1Format ), |
|
1104 WEPKeyLength( EWEPKey1Length ) ); |
|
1105 if ( keyLen[EKeyNumber1] && keyLen[EKeyNumber1] != validLen) |
|
1106 { |
|
1107 valid = EFalse; |
|
1108 CLOG_WRITE_FORMAT( "! Error : Key1 length is invalid %d", |
|
1109 keyLen[EKeyNumber1] ); |
|
1110 CLOG_WRITE_FORMAT( "ValidLen1: %d \n", validLen ); |
|
1111 } |
|
1112 else if ( keyLen[EKeyNumber2] ) |
|
1113 { |
|
1114 //check validity of key2 length |
|
1115 validLen = WEPKeyValidLen( WEPKeyFormat( EWEPKey2Format ), |
|
1116 WEPKeyLength( EWEPKey2Length ) ); |
|
1117 if ( keyLen[EKeyNumber2] != validLen ) |
|
1118 { |
|
1119 valid = EFalse; |
|
1120 CLOG_WRITE_FORMAT( "! Error : Key2 length is invalid %d", |
|
1121 keyLen[EKeyNumber2] ) |
|
1122 CLOG_WRITE_FORMAT( "ValidLen2: %d \n", validLen ); |
|
1123 } |
|
1124 else if ( keyLen[EKeyNumber3] ) |
|
1125 { |
|
1126 //check validity of key3 length |
|
1127 validLen = WEPKeyValidLen( WEPKeyFormat( EWEPKey3Format ), |
|
1128 WEPKeyLength( EWEPKey3Length ) ); |
|
1129 if ( keyLen[EKeyNumber3] != validLen ) |
|
1130 { |
|
1131 valid = EFalse; |
|
1132 CLOG_WRITE_FORMAT( "! Error : Key3 length is invalid %d", |
|
1133 keyLen[EKeyNumber3] ); |
|
1134 CLOG_WRITE_FORMAT( "ValidLen3: %d \n", validLen ); |
|
1135 } |
|
1136 else if ( keyLen[EKeyNumber4] ) |
|
1137 { |
|
1138 //check validity of key4 length |
|
1139 validLen = WEPKeyValidLen( WEPKeyFormat( EWEPKey4Format ), |
|
1140 WEPKeyLength( EWEPKey4Length ) ); |
|
1141 if ( keyLen[EKeyNumber4] != validLen ) |
|
1142 { |
|
1143 valid = EFalse; |
|
1144 CLOG_WRITE_FORMAT( "! Error : Key4 length is invalid %d", |
|
1145 keyLen[EKeyNumber4] ); |
|
1146 CLOG_WRITE_FORMAT( "ValidLen4: %d \n", validLen ); |
|
1147 }//if |
|
1148 }//else |
|
1149 }//else |
|
1150 }//else |
|
1151 }//else |
|
1152 |
|
1153 return valid; |
|
1154 } |
|
1155 |
|
1156 //---------------------------------------------------------- |
|
1157 // CProcessorWlan::ConvertAsciiToHex |
|
1158 //---------------------------------------------------------- |
|
1159 // |
|
1160 void CProcessorWlan::ConvertAsciiToHex( const TDesC8& aSource, |
|
1161 HBufC8*& aDest ) |
|
1162 { |
|
1163 _LIT( hex, "0123456789ABCDEF" ); |
|
1164 TInt size = aSource.Size(); |
|
1165 TPtr8 ptr = aDest->Des(); |
|
1166 for ( TInt ii = 0; ii < size; ii++ ) |
|
1167 { |
|
1168 TText8 ch = aSource[ii]; |
|
1169 ptr.Append( hex()[(ch/16)&0x0f] ); |
|
1170 ptr.Append( hex()[ch&0x0f] ); |
|
1171 } |
|
1172 } |
|
1173 |
|
1174 //---------------------------------------------------------- |
|
1175 // CWEPSecuritySettingsDlg::VerifyHex |
|
1176 //---------------------------------------------------------- |
|
1177 // |
|
1178 TBool CProcessorWlan::VerifyHex( const TDesC8& aHex ) |
|
1179 { |
|
1180 TBool err( ETrue ); |
|
1181 |
|
1182 for ( TInt i = 0; i < aHex.Length(); i++ ) |
|
1183 { |
|
1184 TChar c( aHex[i] ); |
|
1185 |
|
1186 if ( !c.IsHexDigit() ) |
|
1187 { |
|
1188 err = EFalse; |
|
1189 break; |
|
1190 } |
|
1191 } |
|
1192 |
|
1193 return err; |
|
1194 } |
|
1195 |
|
1196 |
|
1197 // --------------------------------------------------------- |
|
1198 // WPA Security settings |
|
1199 // --------------------------------------------------------- |
|
1200 |
|
1201 |
|
1202 // --------------------------------------------------------- |
|
1203 // CProcessorWlan::SaveWPAL |
|
1204 // --------------------------------------------------------- |
|
1205 // |
|
1206 void CProcessorWlan::SaveWPAL( TUint32 aIapId ) |
|
1207 { |
|
1208 CLOG_WRITE( "CProcessorWlan::SaveWPAL enter" ); |
|
1209 CMDBSession* session = CMDBSession::NewL( CMDBSession::LatestVersion() ); |
|
1210 CleanupStack::PushL( session ); |
|
1211 |
|
1212 // Load IAP record |
|
1213 CCDIAPRecord* iapRecord = static_cast<CCDIAPRecord *> |
|
1214 ( CCDRecordBase::RecordFactoryL( KCDTIdIAPRecord ) ); |
|
1215 CleanupStack::PushL( iapRecord ); |
|
1216 iapRecord->SetRecordId( aIapId ); |
|
1217 iapRecord->LoadL( *session ); |
|
1218 |
|
1219 // Load WLAN service table |
|
1220 // first get WLAN table id |
|
1221 CMDBGenericRecord* generic = static_cast<CMDBGenericRecord*> |
|
1222 ( CCDRecordBase::RecordFactoryL( 0 ) ); |
|
1223 CleanupStack::PushL( generic ); |
|
1224 |
|
1225 generic->InitializeL( TPtrC( WLAN_SERVICE ), NULL ); |
|
1226 generic->LoadL( *session ); |
|
1227 TMDBElementId wlanTableId = generic->TableId(); |
|
1228 CMDBField<TUint32>* sidField = static_cast<CMDBField<TUint32>*> |
|
1229 ( generic->GetFieldByIdL( KCDTIdWlanServiceId ) ); |
|
1230 |
|
1231 TInt service = iapRecord->iService; |
|
1232 // prime with service id |
|
1233 *sidField = (TUint32)service; |
|
1234 |
|
1235 User::LeaveIfError( generic->FindL( *session ) ); |
|
1236 |
|
1237 // Set WPA mode |
|
1238 CMDBField<TUint>* enableWpaPskField = static_cast<CMDBField<TUint>*> |
|
1239 ( generic->GetFieldByIdL( KCDTIdWlanEnableWpaPsk ) ); |
|
1240 |
|
1241 enableWpaPskField->SetL( WPAPresharedKeyInUse() ); |
|
1242 |
|
1243 CLOG_WRITE( "Wrote enableWpaPskField" ); |
|
1244 |
|
1245 // Set security mode |
|
1246 CMDBField<TUint>* secModeField = static_cast<CMDBField<TUint>*> |
|
1247 ( generic->GetFieldByIdL( KCDTIdWlanSecMode ) ); |
|
1248 secModeField->SetL( iSecurityMode ); |
|
1249 |
|
1250 CLOG_WRITE( "Wrote securityMode" ); |
|
1251 // Save EAP list |
|
1252 CMDBField<TDesC>* wlanEapsField = static_cast<CMDBField<TDesC>*> |
|
1253 ( generic->GetFieldByIdL( KCDTIdWlanEaps ) ); |
|
1254 wlanEapsField->SetL( WPAFieldData( EWPAListOfEAPs )->Des() ); |
|
1255 |
|
1256 CLOG_WRITE( "Wrote EAPList" ); |
|
1257 |
|
1258 SetExpandedEapListL( generic ); |
|
1259 |
|
1260 CLOG_WRITE( "Wrote expandedEapList" ); |
|
1261 |
|
1262 // Save PreShared Key |
|
1263 TBuf8<KMaxLengthOfKeyData> keyWPA; |
|
1264 //convert to 8 bit |
|
1265 keyWPA.Copy( WPAFieldData( EWPAPresharedKey )->Des() ); |
|
1266 CMDBField<TDesC8>* wpaPskField = static_cast<CMDBField<TDesC8>*> |
|
1267 ( generic->GetFieldByIdL( KCDTIdWlanWpaPreSharedKey ) ); |
|
1268 wpaPskField->SetL( keyWPA ); |
|
1269 |
|
1270 CLOG_WRITE( "Wrote pre-shared key" ); |
|
1271 if ( keyWPA.Length() < 8 ) |
|
1272 { |
|
1273 CLOG_WRITE( "Error: WPA pre-shared key is less then 8 chars." ); |
|
1274 } |
|
1275 |
|
1276 // Check and save PreShared Key Length |
|
1277 TInt len( WPAKeyLength() ); |
|
1278 if ( len != keyWPA.Length() ) |
|
1279 { |
|
1280 CLOG_WRITE( "! Error : WPA key lengths do not match" ); |
|
1281 } |
|
1282 |
|
1283 CMDBField<TUint>* keyLengthField = static_cast<CMDBField<TUint>*> |
|
1284 ( generic->GetFieldByIdL( KCDTIdWlanWpaKeyLength ) ); |
|
1285 keyLengthField->SetL( len ); |
|
1286 |
|
1287 generic->ModifyL( *session ); |
|
1288 |
|
1289 CleanupStack::PopAndDestroy( generic ); |
|
1290 CleanupStack::PopAndDestroy( iapRecord ); |
|
1291 CleanupStack::PopAndDestroy( session ); |
|
1292 CLOG_WRITE( "CProcessorWlan::SaveWPAL exit" ); |
|
1293 } |
|
1294 |
|
1295 // --------------------------------------------------------- |
|
1296 // CProcessorWlan::SetExpandedEapListL |
|
1297 // --------------------------------------------------------- |
|
1298 // |
|
1299 void CProcessorWlan::SetExpandedEapListL( CMDBGenericRecord* generic ) |
|
1300 { |
|
1301 // Gets the text format eap list |
|
1302 HBufC16* eapList = WPAFieldData( EWPAListOfEAPs ); |
|
1303 |
|
1304 if ( eapList != NULL && 0 < eapList->Length() ) |
|
1305 { |
|
1306 |
|
1307 // Creates the expanded eap lists |
|
1308 HBufC8* enabledEapList = ExpandedEapListLC( eapList, ETrue ); |
|
1309 HBufC8* disabledEapList = ExpandedEapListLC( eapList, EFalse ); |
|
1310 |
|
1311 // Save enabled EAP list |
|
1312 CMDBField<TDesC8>* wlanEnabledEapsField = static_cast<CMDBField<TDesC8>*> |
|
1313 ( generic->GetFieldByIdL( KCDTIdWlanEnabledEaps ) ); |
|
1314 wlanEnabledEapsField->SetL( enabledEapList->Des() ); |
|
1315 |
|
1316 // Save disabled EAP list |
|
1317 CMDBField<TDesC8>* wlanDisabledEapsField = static_cast<CMDBField<TDesC8>*> |
|
1318 ( generic->GetFieldByIdL( KCDTIdWlanDisabledEaps ) ); |
|
1319 wlanDisabledEapsField->SetL( disabledEapList->Des() ); |
|
1320 |
|
1321 CleanupStack::PopAndDestroy( disabledEapList ); |
|
1322 CleanupStack::PopAndDestroy( enabledEapList ); |
|
1323 |
|
1324 } |
|
1325 } |
|
1326 |
|
1327 // --------------------------------------------------------- |
|
1328 // CProcessorWlan::ExpandedEapListLC |
|
1329 // --------------------------------------------------------- |
|
1330 // |
|
1331 HBufC8* CProcessorWlan::ExpandedEapListLC( HBufC16* aEapList, TBool aEnabledNeed ) |
|
1332 { |
|
1333 // The eap list has a well defined form |
|
1334 // so this parser supposes this concrete form like this: |
|
1335 // "+018,-023,+026,-021,-006" |
|
1336 |
|
1337 // Lenght of a 3 digit long signed number |
|
1338 const TInt sliceLength = 4; |
|
1339 |
|
1340 // Max lenght of the resulted list. |
|
1341 // Adding one "," then divide the lenght of a slice+1 |
|
1342 TInt maxLenght = ( ( aEapList->Length()+1 ) / 5 ) * 8; |
|
1343 |
|
1344 HBufC8* expandedEapList = HBufC8::NewLC( maxLenght ); |
|
1345 |
|
1346 TInt pos = 0; |
|
1347 while ( pos + sliceLength <= aEapList->Length() ) |
|
1348 { |
|
1349 // Getting a slice |
|
1350 TPtrC16 slice = aEapList->Mid( pos, sliceLength ); |
|
1351 |
|
1352 // Checks the sign |
|
1353 if( slice[0] == '+' ) |
|
1354 { |
|
1355 if( aEnabledNeed ) |
|
1356 { |
|
1357 AddToList( expandedEapList, slice ); |
|
1358 } |
|
1359 } |
|
1360 else if( slice[0] == '-' ) |
|
1361 { |
|
1362 if( !aEnabledNeed ) |
|
1363 { |
|
1364 AddToList( expandedEapList, slice ); |
|
1365 } |
|
1366 } |
|
1367 else |
|
1368 { |
|
1369 CLOG_WRITE_FORMAT( "! Error : Wrong Eap list format %S", aEapList ); |
|
1370 } |
|
1371 |
|
1372 // Step over one slice and "," e.g. "+023," |
|
1373 pos+=5; |
|
1374 |
|
1375 } |
|
1376 if( pos != aEapList->Length() + 1) |
|
1377 { |
|
1378 CLOG_WRITE_FORMAT( "! Warning : possible wrong Eap list format %S", aEapList ); |
|
1379 } |
|
1380 |
|
1381 return expandedEapList; |
|
1382 } |
|
1383 |
|
1384 // --------------------------------------------------------- |
|
1385 // CProcessorWlan::AddToList |
|
1386 // --------------------------------------------------------- |
|
1387 // |
|
1388 void CProcessorWlan::AddToList( HBufC8* aExpandedEapList, TPtrC16 aSlice ) |
|
1389 { |
|
1390 // Fills the 8 byte form with "0xFE000000000000" |
|
1391 TBuf8<8> expandedForm; |
|
1392 expandedForm.AppendFill( 0xFE, 1 ); |
|
1393 expandedForm.AppendFill( 0x00, 6 ); |
|
1394 |
|
1395 // Leave the "sign" |
|
1396 TPtrC16 number = aSlice.Mid( 1 ); |
|
1397 TUint8 resultByte; |
|
1398 TLex16 lex( number ); |
|
1399 |
|
1400 if( KErrNone == lex.Val( resultByte, EDecimal ) ) |
|
1401 { |
|
1402 expandedForm.AppendFill( resultByte, 1 ); |
|
1403 } |
|
1404 else |
|
1405 { |
|
1406 expandedForm.AppendFill( 0x00, 1 ); |
|
1407 CLOG_WRITE( "! Error : Unlexed Eap number. 0 is addded" ); |
|
1408 } |
|
1409 |
|
1410 aExpandedEapList->Des().Append( expandedForm ); |
|
1411 } |
|
1412 |
|
1413 |
|
1414 // --------------------------------------------------------- |
|
1415 // CProcessorWlan::WPAIndex |
|
1416 // --------------------------------------------------------- |
|
1417 // |
|
1418 TInt CProcessorWlan::WPAIndex( TDbCreatorWPAFields aFieldId ) |
|
1419 { |
|
1420 __ASSERT_ALWAYS( aFieldId >= EWPAPresharedKey && aFieldId <= EWPAUseOfPresharedKey, |
|
1421 User::Panic ( KPanicOutOfRange, KErrOutOfRange ) ); |
|
1422 |
|
1423 return aFieldId - 0x2000 + iDataStart; |
|
1424 } |
|
1425 |
|
1426 |
|
1427 // --------------------------------------------------------- |
|
1428 // CProcessorWlan::WPAFieldData |
|
1429 // --------------------------------------------------------- |
|
1430 // |
|
1431 HBufC16* CProcessorWlan::WPAFieldData( TDbCreatorWPAFields aFieldId ) |
|
1432 { |
|
1433 TInt index = WPAIndex( aFieldId ); |
|
1434 if( iWpaData[ index ] == NULL ) |
|
1435 { |
|
1436 return iEmptyTag; |
|
1437 } |
|
1438 else |
|
1439 { |
|
1440 return iWpaData[ index ]; |
|
1441 } |
|
1442 } |
|
1443 |
|
1444 // --------------------------------------------------------- |
|
1445 // CProcessorWlan::WPAPresharedKeyInUse |
|
1446 // --------------------------------------------------------- |
|
1447 // |
|
1448 TBool CProcessorWlan::WPAPresharedKeyInUse() |
|
1449 { |
|
1450 HBufC16* useStr = WPAFieldData( EWPAUseOfPresharedKey ); |
|
1451 |
|
1452 TBool usePSK ( EFalse ) ; |
|
1453 |
|
1454 if ( useStr->CompareF( KStrYes ) == 0 ) |
|
1455 { |
|
1456 CLOG_WRITE( "Preshared key in use" ) |
|
1457 usePSK = ETrue; |
|
1458 } |
|
1459 else if ( useStr->CompareF( KStrNo ) == 0 ) |
|
1460 { |
|
1461 CLOG_WRITE( "Preshared key not in use" ); |
|
1462 } |
|
1463 else |
|
1464 { |
|
1465 //aField is either empty or invalid |
|
1466 CLOG_WRITE( "! Error : Invalid Use WPA preshared key. Default:No" ); |
|
1467 } |
|
1468 |
|
1469 return usePSK; |
|
1470 } |
|
1471 |
|
1472 // --------------------------------------------------------- |
|
1473 // CProcessorWlan::WPAKeyLength |
|
1474 // --------------------------------------------------------- |
|
1475 // |
|
1476 TInt CProcessorWlan::WPAKeyLength() |
|
1477 { |
|
1478 HBufC16* tag = WPAFieldData( EWPAKeyLength ); |
|
1479 |
|
1480 TInt num( 0 ); |
|
1481 TLex parser( tag->Des() ); |
|
1482 |
|
1483 if ( parser.Val( num ) != KErrNone ) |
|
1484 { |
|
1485 CLOG_WRITE( "! Error : Invalid input : WPA key length" ); |
|
1486 } |
|
1487 |
|
1488 return num; |
|
1489 } |
|
1490 |
|
1491 // --------------------------------------------------------- |
|
1492 // CProcessorWlan::AddSecurityDataL |
|
1493 // --------------------------------------------------------- |
|
1494 // |
|
1495 void CProcessorWlan::AddSecurityDataL( TInt aField, HBufC* aPtrTag, TBool aIsWep ) |
|
1496 { |
|
1497 if( aIsWep ) |
|
1498 { |
|
1499 iWepData[ WEPIndex( (TDbCreatorWEPFields)aField ) ] = aPtrTag->AllocL(); |
|
1500 ////iWepData.Insert( aPtrTag->AllocL(), WEPIndex( (TDbCreatorWEPFields)aField ) ); |
|
1501 } |
|
1502 else |
|
1503 { |
|
1504 iWpaData[ WPAIndex( (TDbCreatorWPAFields)aField ) ] = aPtrTag->AllocL(); |
|
1505 ////iWpaData.Insert( aPtrTag->AllocL(), WPAIndex( (TDbCreatorWPAFields)aField ) ); |
|
1506 } |
|
1507 } |
|
1508 |
|
1509 // --------------------------------------------------------- |
|
1510 // CProcessorWlan::DoLogL |
|
1511 // --------------------------------------------------------- |
|
1512 // |
|
1513 void CProcessorWlan::DoLogL() |
|
1514 { |
|
1515 // Writes some data of the actual WLAN access point into the log file. |
|
1516 HBufC16* tmp; |
|
1517 RCmConnectionMethodExt& plugin = GetLastPluginL(); |
|
1518 |
|
1519 // Writes some data of the Internet acces point into the log file. |
|
1520 if ( iIsEasyWlan ) |
|
1521 { |
|
1522 CLOG_WRITE( "Easy WLAN Access Point created:" ) |
|
1523 } |
|
1524 else |
|
1525 { |
|
1526 CLOG_WRITE( "WLAN Access Point created:" ) |
|
1527 } |
|
1528 |
|
1529 CLOG_WRITE_FORMAT( "\t Connection name in array: %S ", |
|
1530 (*iPluginName)[ PluginCount() - 1] ); |
|
1531 |
|
1532 tmp = plugin.GetStringAttributeL( ECmName ); |
|
1533 if( tmp ) |
|
1534 { |
|
1535 CleanupStack::PushL( tmp ); |
|
1536 CLOG_WRITE_FORMAT( "\t Connection name: %S ", tmp ) |
|
1537 CleanupStack::PopAndDestroy( tmp ); |
|
1538 } |
|
1539 |
|
1540 // For the WLAN network name |
|
1541 tmp = plugin.GetStringAttributeL( EWlanSSID ); |
|
1542 if( tmp ) |
|
1543 { |
|
1544 CleanupStack::PushL( tmp ); |
|
1545 CLOG_WRITE_FORMAT( "\t Network name: %S", tmp ) |
|
1546 CleanupStack::PopAndDestroy( tmp ); |
|
1547 } |
|
1548 CLOG_WRITE( "\t \r\n" ) |
|
1549 } |
|
1550 |
|
1551 |
|
1552 // --------------------------------------------------------- |
|
1553 // CProcessorWlan::Reset |
|
1554 // --------------------------------------------------------- |
|
1555 // |
|
1556 void CProcessorWlan::Reset() |
|
1557 { |
|
1558 for( TInt i = 0; i < KWEPKeyNumOfFields; i++ ) |
|
1559 { |
|
1560 iWepData[i] = NULL; |
|
1561 } |
|
1562 for( TInt i = 0; i < KWPAKeyNumOfFields; i++ ) |
|
1563 { |
|
1564 iWpaData[i] = NULL; |
|
1565 } |
|
1566 } |
|
1567 |
|
1568 // --------------------------------------------------------- |
|
1569 // CProcessorWlan::EAPSetting |
|
1570 // --------------------------------------------------------- |
|
1571 // |
|
1572 TBool CProcessorWlan::EAPSetting( const TInt aField ) |
|
1573 { |
|
1574 // Checks if the supplied field is EAP settings and returns ETrue if it is |
|
1575 if ( aField > EEapParameterFirst |
|
1576 && aField < EEapParameterLast ) |
|
1577 { |
|
1578 return ETrue; |
|
1579 } |
|
1580 else |
|
1581 { |
|
1582 return EFalse; |
|
1583 } |
|
1584 } |
|
1585 // --------------------------------------------------------- |
|
1586 // CProcessorWlan::GetEapTypeIdFromSettingId |
|
1587 // --------------------------------------------------------- |
|
1588 // |
|
1589 EAPSettings::TEapType CProcessorWlan::GetEapTypeIdFromSettingId( const TInt aField ) |
|
1590 { |
|
1591 switch ( aField ) |
|
1592 { |
|
1593 case EEapGtcUsername: |
|
1594 case EEapGtcSessionValidityTime: |
|
1595 case EEapGtcEncapsulation: |
|
1596 { |
|
1597 return EAPSettings::EEapGtc; |
|
1598 } |
|
1599 case EEapTlsUsername: |
|
1600 case EEapTlsRealm: |
|
1601 case EEapTlsVerifyServerRealm: |
|
1602 case EEapTlsRequireClientAuth: |
|
1603 case EEapTlsSessionValidityTime: |
|
1604 case EEapTlsCipherSuites: |
|
1605 case EEapTlsUserCertSubjectKeyId: |
|
1606 case EEapTlsUserCertIssuerName: |
|
1607 case EEapTlsUserCertSerialNumber: |
|
1608 case EEapTlsCaCertSubjectKeyId: |
|
1609 case EEapTlsCaCertIssuerName: |
|
1610 case EEapTlsCaCertSerialNumber: |
|
1611 case EEapTlsEncapsulation: |
|
1612 { |
|
1613 return EAPSettings::EEapTls; |
|
1614 } |
|
1615 case EEapLeapUsername: |
|
1616 case EEapLeapPassword: |
|
1617 case EEapLeapSessionValidityTime: |
|
1618 { |
|
1619 return EAPSettings::EEapLeap; |
|
1620 } |
|
1621 case EEapSimUsername: |
|
1622 case EEapSimRealm: |
|
1623 case EEapSimUsePseudonyms: |
|
1624 case EEapSimSessionValidityTime: |
|
1625 case EEapSimEncapsulation: |
|
1626 { |
|
1627 return EAPSettings::EEapSim; |
|
1628 } |
|
1629 case EEapTtlsUsername: |
|
1630 case EEapTtlsRealm: |
|
1631 case EEapTtlsVerifyServerRealm: |
|
1632 case EEapTtlsRequireClientAuth: |
|
1633 case EEapTtlsSessionValidityTime: |
|
1634 case EEapTtlsCipherSuites: |
|
1635 case EEapTtlsEncapsulatedTypes: |
|
1636 case EEapTtlsUserCertSubjectKeyId: |
|
1637 case EEapTtlsUserCertIssuerName: |
|
1638 case EEapTtlsUserCertSerialNumber: |
|
1639 case EEapTtlsCaCertSubjectKeyId: |
|
1640 case EEapTtlsCaCertIssuerName: |
|
1641 case EEapTtlsCaCertSerialNumber: |
|
1642 { |
|
1643 return EAPSettings::EEapTtls; |
|
1644 } |
|
1645 case EEapAkaUsername: |
|
1646 case EEapAkaRealm: |
|
1647 case EEapAkaUsePseudonyms: |
|
1648 case EEapAkaSessionValidityTime: |
|
1649 case EEapAkaEncapsulation: |
|
1650 { |
|
1651 return EAPSettings::EEapAka; |
|
1652 } |
|
1653 case EEapPeapUsername: |
|
1654 case EEapPeapRealm: |
|
1655 case EEapPeapVerifyServerRealm: |
|
1656 case EEapPeapRequireClientAuth: |
|
1657 case EEapPeapSessionValidityTime: |
|
1658 case EEapPeapCipherSuites: |
|
1659 case EEapPeapV0Allowed: |
|
1660 case EEapPeapV1Allowed: |
|
1661 case EEapPeapV2Allowed: |
|
1662 case EEapPeapEncapsulatedTypes: |
|
1663 case EEapPeapUserCertSubjectKeyId: |
|
1664 case EEapPeapUserCertIssuerName: |
|
1665 case EEapPeapUserCertSerialNumber: |
|
1666 case EEapPeapCaCertSubjectKeyId: |
|
1667 case EEapPeapCaCertIssuerName: |
|
1668 case EEapPeapCaCertSerialNumber: |
|
1669 { |
|
1670 return EAPSettings::EEapPeap; |
|
1671 } |
|
1672 case EEapMschapv2Username: |
|
1673 case EEapMschapv2Password: |
|
1674 case EEapMschapv2SessionValidityTime: |
|
1675 case EEapMschapv2Encapsulation: |
|
1676 { |
|
1677 return EAPSettings::EEapMschapv2; |
|
1678 } |
|
1679 case EEapFastUsername: |
|
1680 case EEapFastRealm: |
|
1681 case EEapFastVerifyServerRealm: |
|
1682 case EEapFastRequireClientAuth: |
|
1683 case EEapFastSessionValidityTime: |
|
1684 case EEapFastCipherSuites: |
|
1685 case EEapFastEncapsulatedTypes: |
|
1686 case EEapFastAuthProvModeAllowed: |
|
1687 case EEapFastUnauthProvModeAllowed: |
|
1688 case EEapFastWarnADHPNoPAC: |
|
1689 case EEapFastWarnADHPNoMatchingPAC: |
|
1690 case EEapFastWarnNotDefaultServer: |
|
1691 case EEapFastUserCertSubjectKeyId: |
|
1692 case EEapFastUserCertIssuerName: |
|
1693 case EEapFastUserCertSerialNumber: |
|
1694 case EEapFastCaCertSubjectKeyId: |
|
1695 case EEapFastCaCertIssuerName: |
|
1696 case EEapFastCaCertSerialNumber: |
|
1697 { |
|
1698 return EAPSettings::EEapFast; |
|
1699 } |
|
1700 |
|
1701 case EMschapv2Username: |
|
1702 case EMschapv2Password: |
|
1703 case EMschapv2SessionValidityTime: |
|
1704 case EMschapv2Encapsulation: |
|
1705 { |
|
1706 return EAPSettings::EPlainMschapv2; |
|
1707 } |
|
1708 default: |
|
1709 { |
|
1710 return EAPSettings::EEapNone; |
|
1711 } |
|
1712 |
|
1713 } |
|
1714 } |
|
1715 // --------------------------------------------------------- |
|
1716 // CProcessorWlan::AddEAPSetting |
|
1717 // --------------------------------------------------------- |
|
1718 // |
|
1719 void CProcessorWlan::AddEAPSettingL( const TInt aField, const HBufC16* const aValue ) |
|
1720 { |
|
1721 EAPSettings::TEapType eapId = GetEapTypeIdFromSettingId( aField ); |
|
1722 if ( eapId == EAPSettings::EEapNone ) |
|
1723 { |
|
1724 CLOG_WRITE( "! Error : Unknown EAP method" ); |
|
1725 User::Leave( KErrArgument ); |
|
1726 } |
|
1727 |
|
1728 TInt eapIndex(0); |
|
1729 // Search if the EAP instance already exists in the array for this |
|
1730 for ( eapIndex = 0 ; eapIndex < iEapSettings.Count() ; eapIndex++ ) |
|
1731 { |
|
1732 if ( ( iEapSettings[eapIndex]->iEapSettings->iEAPType == eapId ) |
|
1733 && ( iEapSettings[eapIndex]->iName != NULL ) |
|
1734 && ( iEapSettings[eapIndex]->iName->Compare( *iName ) == 0 )) |
|
1735 { |
|
1736 // Found it |
|
1737 break; |
|
1738 } |
|
1739 } |
|
1740 |
|
1741 if ( eapIndex == iEapSettings.Count() ) |
|
1742 { |
|
1743 // Not found. Create new |
|
1744 CEapTypeElement* newEap = new (ELeave) CEapTypeElement; |
|
1745 CleanupStack::PushL( newEap ); |
|
1746 |
|
1747 newEap->iEapSettings = new (ELeave) EAPSettings; |
|
1748 |
|
1749 newEap->iEapSettings->iEAPType = eapId; |
|
1750 |
|
1751 newEap->iName = iName->AllocL(); |
|
1752 |
|
1753 iEapSettings.AppendL(newEap); |
|
1754 |
|
1755 CleanupStack::Pop( newEap ); |
|
1756 |
|
1757 // Set the index to the newly created EAP settings instance |
|
1758 eapIndex = iEapSettings.Count() - 1; |
|
1759 |
|
1760 } |
|
1761 switch ( aField ) |
|
1762 { |
|
1763 case EEapGtcUsername: |
|
1764 case EEapTlsUsername: |
|
1765 case EEapLeapUsername: |
|
1766 case EEapSimUsername: |
|
1767 case EEapTtlsUsername: |
|
1768 case EEapAkaUsername: |
|
1769 case EEapPeapUsername: |
|
1770 case EEapMschapv2Username: |
|
1771 case EEapFastUsername: |
|
1772 case EMschapv2Username: |
|
1773 { |
|
1774 iEapSettings[eapIndex]->iEapSettings->iUsernamePresent = ETrue; |
|
1775 iEapSettings[eapIndex]->iEapSettings->iUsername.Copy( *aValue ); |
|
1776 break; |
|
1777 } |
|
1778 |
|
1779 case EEapLeapPassword: |
|
1780 case EEapMschapv2Password: |
|
1781 case EMschapv2Password: |
|
1782 { |
|
1783 iEapSettings[eapIndex]->iEapSettings->iPasswordPresent = ETrue; |
|
1784 iEapSettings[eapIndex]->iEapSettings->iPassword.Copy( *aValue ); |
|
1785 break; |
|
1786 } |
|
1787 |
|
1788 case EEapTlsRealm: |
|
1789 case EEapSimRealm: |
|
1790 case EEapTtlsRealm: |
|
1791 case EEapAkaRealm: |
|
1792 case EEapPeapRealm: |
|
1793 case EEapFastRealm: |
|
1794 { |
|
1795 iEapSettings[eapIndex]->iEapSettings->iRealmPresent = ETrue; |
|
1796 iEapSettings[eapIndex]->iEapSettings->iRealm.Copy( *aValue ); |
|
1797 break; |
|
1798 } |
|
1799 |
|
1800 case EEapGtcSessionValidityTime: |
|
1801 case EEapTtlsSessionValidityTime: |
|
1802 case EEapTlsSessionValidityTime: |
|
1803 case EEapSimSessionValidityTime: |
|
1804 case EEapLeapSessionValidityTime: |
|
1805 case EMschapv2SessionValidityTime: |
|
1806 case EEapAkaSessionValidityTime: |
|
1807 case EEapPeapSessionValidityTime: |
|
1808 case EEapMschapv2SessionValidityTime: |
|
1809 case EEapFastSessionValidityTime: |
|
1810 { |
|
1811 // Convert the input parameter to integer |
|
1812 TLex lex( *aValue ); |
|
1813 TUint value( 0 ); |
|
1814 if( lex.Val( value, EDecimal) != KErrNone ) |
|
1815 { |
|
1816 CLOG_WRITE_FORMAT( "! Error : Invalid session validity time value. EapId: %d", eapId ); |
|
1817 User::Leave( KErrArgument ); |
|
1818 } |
|
1819 |
|
1820 iEapSettings[eapIndex]->iEapSettings->iSessionValidityTimePresent = ETrue; |
|
1821 iEapSettings[eapIndex]->iEapSettings->iSessionValidityTime = value; |
|
1822 break; |
|
1823 } |
|
1824 |
|
1825 case EEapGtcEncapsulation: |
|
1826 case EEapTlsEncapsulation: |
|
1827 case EEapSimEncapsulation: |
|
1828 case EEapAkaEncapsulation: |
|
1829 case EEapMschapv2Encapsulation: |
|
1830 case EMschapv2Encapsulation: |
|
1831 { |
|
1832 TLex lex( *aValue ); |
|
1833 TUint eapTypeId( 0 ); |
|
1834 if( lex.Val( eapTypeId, EDecimal) != KErrNone ) |
|
1835 { |
|
1836 CLOG_WRITE_FORMAT( "! Error : Invalid encapsulation value. EapId: %d", eapId ); |
|
1837 User::Leave( KErrArgument ); |
|
1838 } |
|
1839 |
|
1840 iEapSettings[eapIndex]->iEncapsulatingEapId = static_cast< EAPSettings::TEapType >( eapTypeId ); |
|
1841 break; |
|
1842 } |
|
1843 |
|
1844 case EEapTlsVerifyServerRealm: |
|
1845 case EEapTtlsVerifyServerRealm: |
|
1846 case EEapPeapVerifyServerRealm: |
|
1847 case EEapFastVerifyServerRealm: |
|
1848 { |
|
1849 if ( !aValue->CompareF( KStrYes ) ) |
|
1850 { |
|
1851 iEapSettings[eapIndex]->iEapSettings->iVerifyServerRealmPresent = ETrue; |
|
1852 iEapSettings[eapIndex]->iEapSettings->iVerifyServerRealm = ETrue; |
|
1853 } |
|
1854 else if ( !aValue->CompareF( KStrNo ) ) |
|
1855 { |
|
1856 iEapSettings[eapIndex]->iEapSettings->iVerifyServerRealmPresent = ETrue; |
|
1857 iEapSettings[eapIndex]->iEapSettings->iVerifyServerRealm = EFalse; |
|
1858 } |
|
1859 else |
|
1860 { |
|
1861 CLOG_WRITE_FORMAT( "! Error : Invalid VerifyServerRealm. EapId: %d", eapId ); |
|
1862 User::Leave( KErrArgument ); |
|
1863 } |
|
1864 |
|
1865 break; |
|
1866 } |
|
1867 |
|
1868 case EEapTlsRequireClientAuth: |
|
1869 case EEapTtlsRequireClientAuth: |
|
1870 case EEapPeapRequireClientAuth: |
|
1871 case EEapFastRequireClientAuth: |
|
1872 { |
|
1873 if ( !aValue->CompareF( KStrYes ) ) |
|
1874 { |
|
1875 iEapSettings[eapIndex]->iEapSettings->iRequireClientAuthenticationPresent = ETrue; |
|
1876 iEapSettings[eapIndex]->iEapSettings->iRequireClientAuthentication = ETrue; |
|
1877 } |
|
1878 else if ( !aValue->CompareF( KStrNo ) ) |
|
1879 { |
|
1880 iEapSettings[eapIndex]->iEapSettings->iRequireClientAuthenticationPresent = ETrue; |
|
1881 iEapSettings[eapIndex]->iEapSettings->iRequireClientAuthentication = EFalse; |
|
1882 } |
|
1883 else |
|
1884 { |
|
1885 CLOG_WRITE_FORMAT( "! Error : Invalid RequireClientAuth. EapId: %d", eapId ); |
|
1886 User::Leave( KErrArgument ); |
|
1887 } |
|
1888 |
|
1889 break; |
|
1890 } |
|
1891 |
|
1892 case EEapTlsCipherSuites: |
|
1893 case EEapTtlsCipherSuites: |
|
1894 case EEapPeapCipherSuites: |
|
1895 case EEapFastCipherSuites: |
|
1896 { |
|
1897 TRAPD( err, FillCipherSuitesL( aValue, eapIndex ) ); |
|
1898 if( err != KErrNone ) |
|
1899 { |
|
1900 CLOG_WRITE_FORMAT( "! Error : Invalid CipherSuites. EapId: %d", eapId ); |
|
1901 User::Leave( KErrArgument ); |
|
1902 } |
|
1903 break; |
|
1904 } |
|
1905 |
|
1906 case EEapTlsUserCertSubjectKeyId: |
|
1907 case EEapTtlsUserCertSubjectKeyId: |
|
1908 case EEapPeapUserCertSubjectKeyId: |
|
1909 case EEapFastUserCertSubjectKeyId: |
|
1910 { |
|
1911 TInt certIndex = FindCertificateEntryL( CertificateEntry::EUser, eapIndex ); |
|
1912 |
|
1913 TBuf<KKeyIdentifierLength> key; |
|
1914 |
|
1915 TRAPD( err, ConvertSubjectKeyIdToBinaryL( aValue, key) ); |
|
1916 if( err != KErrNone ) |
|
1917 { |
|
1918 CLOG_WRITE_FORMAT( "! Error : Invalid UserCertSubjectKeyId. EapId: %d", eapId ); |
|
1919 User::Leave( KErrArgument ); |
|
1920 } |
|
1921 |
|
1922 iEapSettings[eapIndex]->iEapSettings->iCertificatesPresent = ETrue; |
|
1923 iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex].iSubjectKeyID.Copy(key); |
|
1924 iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex].iSubjectKeyIDPresent = ETrue; |
|
1925 break; |
|
1926 } |
|
1927 |
|
1928 case EEapTlsUserCertIssuerName: |
|
1929 case EEapTtlsUserCertIssuerName: |
|
1930 case EEapPeapUserCertIssuerName: |
|
1931 case EEapFastUserCertIssuerName: |
|
1932 { |
|
1933 TUint certIndex = FindCertificateEntryL( CertificateEntry::EUser, eapIndex ); |
|
1934 |
|
1935 iEapSettings[eapIndex]->iEapSettings->iCertificatesPresent = ETrue; |
|
1936 iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex].iIssuerNamePresent= ETrue; |
|
1937 iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex].iIssuerName.Copy( *aValue ); |
|
1938 break; |
|
1939 } |
|
1940 |
|
1941 case EEapTlsUserCertSerialNumber: |
|
1942 case EEapTtlsUserCertSerialNumber: |
|
1943 case EEapPeapUserCertSerialNumber: |
|
1944 case EEapFastUserCertSerialNumber: |
|
1945 { |
|
1946 TUint certIndex = FindCertificateEntryL( CertificateEntry::EUser, eapIndex ); |
|
1947 |
|
1948 iEapSettings[eapIndex]->iEapSettings->iCertificatesPresent = ETrue; |
|
1949 iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex].iSerialNumberPresent= ETrue; |
|
1950 iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex].iSerialNumber.Copy( *aValue ); |
|
1951 break; |
|
1952 } |
|
1953 |
|
1954 case EEapTlsCaCertSubjectKeyId: |
|
1955 case EEapTtlsCaCertSubjectKeyId: |
|
1956 case EEapPeapCaCertSubjectKeyId: |
|
1957 case EEapFastCaCertSubjectKeyId: |
|
1958 { |
|
1959 TInt certIndex = FindCertificateEntryL( CertificateEntry::ECA, eapIndex ); |
|
1960 |
|
1961 TBuf<KKeyIdentifierLength> key; |
|
1962 |
|
1963 TRAPD( err, ConvertSubjectKeyIdToBinaryL( aValue, key) ); |
|
1964 if( err != KErrNone ) |
|
1965 { |
|
1966 CLOG_WRITE_FORMAT( "! Error : Invalid UserCertSubjectKeyId. EapId: %d", eapId ); |
|
1967 User::Leave( KErrArgument ); |
|
1968 } |
|
1969 |
|
1970 iEapSettings[eapIndex]->iEapSettings->iCertificatesPresent = ETrue; |
|
1971 iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex].iSubjectKeyID.Copy(key); |
|
1972 iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex].iSubjectKeyIDPresent = ETrue; |
|
1973 break; |
|
1974 } |
|
1975 |
|
1976 case EEapTlsCaCertIssuerName: |
|
1977 case EEapTtlsCaCertIssuerName: |
|
1978 case EEapPeapCaCertIssuerName: |
|
1979 case EEapFastCaCertIssuerName: |
|
1980 { |
|
1981 TUint certIndex = FindCertificateEntryL( CertificateEntry::ECA, eapIndex ); |
|
1982 iEapSettings[eapIndex]->iEapSettings->iCertificatesPresent = ETrue; |
|
1983 iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex].iIssuerNamePresent= ETrue; |
|
1984 iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex].iIssuerName.Copy( *aValue ); |
|
1985 |
|
1986 break; |
|
1987 } |
|
1988 |
|
1989 case EEapTlsCaCertSerialNumber: |
|
1990 case EEapTtlsCaCertSerialNumber: |
|
1991 case EEapPeapCaCertSerialNumber: |
|
1992 case EEapFastCaCertSerialNumber: |
|
1993 { |
|
1994 TUint certIndex = FindCertificateEntryL( CertificateEntry::ECA, eapIndex ); |
|
1995 iEapSettings[eapIndex]->iEapSettings->iCertificatesPresent = ETrue; |
|
1996 iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex].iSerialNumberPresent= ETrue; |
|
1997 iEapSettings[eapIndex]->iEapSettings->iCertificates[certIndex].iSerialNumber.Copy( *aValue ); |
|
1998 break; |
|
1999 } |
|
2000 |
|
2001 case EEapSimUsePseudonyms: |
|
2002 case EEapAkaUsePseudonyms: |
|
2003 { |
|
2004 if ( !aValue->CompareF( KStrYes ) ) |
|
2005 { |
|
2006 iEapSettings[eapIndex]->iEapSettings->iUsePseudonymsPresent = ETrue; |
|
2007 iEapSettings[eapIndex]->iEapSettings->iUsePseudonyms = ETrue; |
|
2008 } |
|
2009 else if ( !aValue->CompareF( KStrNo ) ) |
|
2010 { |
|
2011 iEapSettings[eapIndex]->iEapSettings->iUsePseudonymsPresent = ETrue; |
|
2012 iEapSettings[eapIndex]->iEapSettings->iUsePseudonyms = EFalse; |
|
2013 } |
|
2014 else |
|
2015 { |
|
2016 CLOG_WRITE_FORMAT( "! Error : Invalid UsePseudonyms. EapId: %d", eapId ); |
|
2017 User::Leave( KErrArgument ); |
|
2018 } |
|
2019 break; |
|
2020 } |
|
2021 |
|
2022 case EEapTtlsEncapsulatedTypes: |
|
2023 case EEapPeapEncapsulatedTypes: |
|
2024 case EEapFastEncapsulatedTypes: |
|
2025 { |
|
2026 // Lenght of a 3 digit long signed number |
|
2027 const TInt sliceLength = 4; |
|
2028 |
|
2029 TInt pos = 0; |
|
2030 while ( pos + sliceLength <= aValue->Length() ) |
|
2031 { |
|
2032 // Getting a slice |
|
2033 TPtrC16 slice = aValue->Mid( pos, sliceLength ); |
|
2034 |
|
2035 // Checks the sign |
|
2036 if( slice[0] == '+' ) |
|
2037 { |
|
2038 TLex lex( slice.Ptr() + 1 ); |
|
2039 TUint encapsEapId( 0 ); |
|
2040 |
|
2041 if( lex.Val( encapsEapId, EDecimal) != KErrNone ) |
|
2042 { |
|
2043 CLOG_WRITE_FORMAT( "! Error : Invalid EncapsulatedTypes. EapId: %d", eapId ); |
|
2044 User::Leave( KErrArgument ); |
|
2045 } |
|
2046 |
|
2047 iEapSettings[eapIndex]->iEapSettings->iEncapsulatedEAPTypes.Append( encapsEapId ); |
|
2048 iEapSettings[eapIndex]->iEapSettings->iEncapsulatedEAPTypesPresent = ETrue; |
|
2049 } |
|
2050 |
|
2051 // Step over one slice and "," e.g. "+023," |
|
2052 pos+=5; |
|
2053 } |
|
2054 |
|
2055 break; |
|
2056 } |
|
2057 |
|
2058 case EEapPeapV0Allowed: |
|
2059 { |
|
2060 if ( !aValue->CompareF( KStrYes ) ) |
|
2061 { |
|
2062 iEapSettings[eapIndex]->iEapSettings->iPEAPVersionsPresent = ETrue; |
|
2063 iEapSettings[eapIndex]->iEapSettings->iPEAPv0Allowed = ETrue; |
|
2064 } |
|
2065 else if ( !aValue->CompareF( KStrNo ) ) |
|
2066 { |
|
2067 iEapSettings[eapIndex]->iEapSettings->iPEAPVersionsPresent = ETrue; |
|
2068 iEapSettings[eapIndex]->iEapSettings->iPEAPv0Allowed = EFalse; |
|
2069 } |
|
2070 else |
|
2071 { |
|
2072 CLOG_WRITE_FORMAT( "! Error : Invalid EapPeapV0Allowed. EapId: %d", eapId ); |
|
2073 User::Leave( KErrArgument ); |
|
2074 } |
|
2075 |
|
2076 break; |
|
2077 } |
|
2078 |
|
2079 case EEapPeapV1Allowed: |
|
2080 { |
|
2081 if ( !aValue->CompareF( KStrYes ) ) |
|
2082 { |
|
2083 iEapSettings[eapIndex]->iEapSettings->iPEAPVersionsPresent = ETrue; |
|
2084 iEapSettings[eapIndex]->iEapSettings->iPEAPv1Allowed = ETrue; |
|
2085 } |
|
2086 else if ( !aValue->CompareF( KStrNo ) ) |
|
2087 { |
|
2088 iEapSettings[eapIndex]->iEapSettings->iPEAPVersionsPresent = ETrue; |
|
2089 iEapSettings[eapIndex]->iEapSettings->iPEAPv1Allowed = EFalse; |
|
2090 } |
|
2091 else |
|
2092 { |
|
2093 CLOG_WRITE_FORMAT( "! Error : Invalid EapPeapV1Allowed. EapId: %d", eapId ); |
|
2094 User::Leave( KErrArgument ); |
|
2095 } |
|
2096 |
|
2097 break; |
|
2098 } |
|
2099 |
|
2100 case EEapPeapV2Allowed: |
|
2101 { |
|
2102 if ( !aValue->CompareF( KStrYes ) ) |
|
2103 { |
|
2104 iEapSettings[eapIndex]->iEapSettings->iPEAPVersionsPresent = ETrue; |
|
2105 iEapSettings[eapIndex]->iEapSettings->iPEAPv2Allowed = ETrue; |
|
2106 } |
|
2107 else if ( !aValue->CompareF( KStrNo ) ) |
|
2108 { |
|
2109 iEapSettings[eapIndex]->iEapSettings->iPEAPVersionsPresent = ETrue; |
|
2110 iEapSettings[eapIndex]->iEapSettings->iPEAPv2Allowed = EFalse; |
|
2111 } |
|
2112 else |
|
2113 { |
|
2114 CLOG_WRITE_FORMAT( "! Error : Invalid EapPeapV2Allowed. EapId: %d", eapId ); |
|
2115 User::Leave( KErrArgument ); |
|
2116 } |
|
2117 |
|
2118 break; |
|
2119 } |
|
2120 |
|
2121 case EEapFastAuthProvModeAllowed: |
|
2122 { |
|
2123 if ( !aValue->CompareF( KStrYes ) ) |
|
2124 { |
|
2125 iEapSettings[eapIndex]->iEapSettings->iAuthProvModeAllowedPresent = ETrue; |
|
2126 iEapSettings[eapIndex]->iEapSettings->iAuthProvModeAllowed = ETrue; |
|
2127 } |
|
2128 else if ( !aValue->CompareF( KStrNo ) ) |
|
2129 { |
|
2130 iEapSettings[eapIndex]->iEapSettings->iAuthProvModeAllowedPresent = ETrue; |
|
2131 iEapSettings[eapIndex]->iEapSettings->iAuthProvModeAllowed = EFalse; |
|
2132 } |
|
2133 else |
|
2134 { |
|
2135 CLOG_WRITE_FORMAT( "! Error : Invalid EEapFastAuthProvModeAllowed. EapId: %d", eapId ); |
|
2136 User::Leave( KErrArgument ); |
|
2137 } |
|
2138 |
|
2139 break; |
|
2140 } |
|
2141 |
|
2142 case EEapFastUnauthProvModeAllowed: |
|
2143 { |
|
2144 if ( !aValue->CompareF( KStrYes ) ) |
|
2145 { |
|
2146 iEapSettings[eapIndex]->iEapSettings->iUnauthProvModeAllowedPresent = ETrue; |
|
2147 iEapSettings[eapIndex]->iEapSettings->iUnauthProvModeAllowed = ETrue; |
|
2148 } |
|
2149 else if ( !aValue->CompareF( KStrNo ) ) |
|
2150 { |
|
2151 iEapSettings[eapIndex]->iEapSettings->iUnauthProvModeAllowedPresent = ETrue; |
|
2152 iEapSettings[eapIndex]->iEapSettings->iUnauthProvModeAllowed = EFalse; |
|
2153 } |
|
2154 else |
|
2155 { |
|
2156 |
|
2157 CLOG_WRITE_FORMAT( "! Error : Invalid EapFastUnauthProvModeAllowed. EapId: %d", eapId ); |
|
2158 User::Leave( KErrArgument ); |
|
2159 } |
|
2160 |
|
2161 break; |
|
2162 } |
|
2163 |
|
2164 case EEapFastWarnADHPNoPAC: |
|
2165 { |
|
2166 if ( !aValue->CompareF( KStrYes ) ) |
|
2167 { |
|
2168 iEapSettings[eapIndex]->iEapSettings->iWarnADHPNoPACPresent = ETrue; |
|
2169 iEapSettings[eapIndex]->iEapSettings->iWarnADHPNoPAC = ETrue; |
|
2170 } |
|
2171 else if ( !aValue->CompareF( KStrNo ) ) |
|
2172 { |
|
2173 iEapSettings[eapIndex]->iEapSettings->iWarnADHPNoPACPresent = ETrue; |
|
2174 iEapSettings[eapIndex]->iEapSettings->iWarnADHPNoPAC = EFalse; |
|
2175 } |
|
2176 else |
|
2177 { |
|
2178 CLOG_WRITE_FORMAT( "! Error : Invalid EapFastWarnADHPNoPAC. EapId: %d", eapId ); |
|
2179 User::Leave( KErrArgument ); |
|
2180 } |
|
2181 |
|
2182 break; |
|
2183 } |
|
2184 |
|
2185 case EEapFastWarnADHPNoMatchingPAC: |
|
2186 { |
|
2187 if ( !aValue->CompareF( KStrYes ) ) |
|
2188 { |
|
2189 iEapSettings[eapIndex]->iEapSettings->iWarnADHPNoMatchingPACPresent = ETrue; |
|
2190 iEapSettings[eapIndex]->iEapSettings->iWarnADHPNoMatchingPAC = ETrue; |
|
2191 } |
|
2192 else if ( !aValue->CompareF( KStrNo ) ) |
|
2193 { |
|
2194 iEapSettings[eapIndex]->iEapSettings->iWarnADHPNoMatchingPACPresent = ETrue; |
|
2195 iEapSettings[eapIndex]->iEapSettings->iWarnADHPNoMatchingPAC = EFalse; |
|
2196 } |
|
2197 else |
|
2198 { |
|
2199 CLOG_WRITE_FORMAT( "! Error : Invalid EapFastWarnADHPNoMatchingPAC. EapId: %d", eapId ); |
|
2200 User::Leave( KErrArgument ); |
|
2201 } |
|
2202 |
|
2203 break; |
|
2204 } |
|
2205 |
|
2206 case EEapFastWarnNotDefaultServer: |
|
2207 { |
|
2208 if ( !aValue->CompareF( KStrYes ) ) |
|
2209 { |
|
2210 iEapSettings[eapIndex]->iEapSettings->iWarnNotDefaultServerPresent = ETrue; |
|
2211 iEapSettings[eapIndex]->iEapSettings->iWarnNotDefaultServer = ETrue; |
|
2212 } |
|
2213 else if ( !aValue->CompareF( KStrNo ) ) |
|
2214 { |
|
2215 iEapSettings[eapIndex]->iEapSettings->iWarnNotDefaultServerPresent = ETrue; |
|
2216 iEapSettings[eapIndex]->iEapSettings->iWarnNotDefaultServer = EFalse; |
|
2217 } |
|
2218 else |
|
2219 { |
|
2220 CLOG_WRITE_FORMAT( "! Error : Invalid EapFastWarnNotDefaultServer. EapId: %d", eapId ); |
|
2221 User::Leave( KErrArgument ); |
|
2222 } |
|
2223 |
|
2224 break; |
|
2225 } |
|
2226 |
|
2227 default: |
|
2228 { |
|
2229 |
|
2230 } |
|
2231 } |
|
2232 } |
|
2233 // --------------------------------------------------------- |
|
2234 // CProcessorWlan::FillCipherSuitesL |
|
2235 // --------------------------------------------------------- |
|
2236 // |
|
2237 void CProcessorWlan::FillCipherSuitesL( const HBufC16* const aPtrTag, const TInt aEapIndex ) |
|
2238 { |
|
2239 if ( iEapSettings[aEapIndex] == NULL ) |
|
2240 { |
|
2241 User::Leave( KErrArgument ); |
|
2242 } |
|
2243 |
|
2244 iEapSettings[aEapIndex]->iEapSettings->iCipherSuites.Reset(); |
|
2245 iEapSettings[aEapIndex]->iEapSettings->iCipherSuitesPresent = EFalse; // init to EFalse |
|
2246 |
|
2247 TChar plus( '+' ); |
|
2248 |
|
2249 TBuf8<256> tmpBuf; |
|
2250 tmpBuf.Copy( *aPtrTag); |
|
2251 |
|
2252 TInt length = tmpBuf.Length(); |
|
2253 |
|
2254 for ( TInt i = 0 ; i + 3 < length ; i += 5) |
|
2255 { |
|
2256 if ( tmpBuf[i] == plus ) |
|
2257 { |
|
2258 TLex8 lex( tmpBuf.Mid( i + 1, 3) ); |
|
2259 TUint suite; |
|
2260 User::LeaveIfError( lex.Val( suite ) ); |
|
2261 iEapSettings[aEapIndex]->iEapSettings->iCipherSuites.Append(suite); |
|
2262 iEapSettings[aEapIndex]->iEapSettings->iCipherSuitesPresent = ETrue; |
|
2263 } |
|
2264 } |
|
2265 } |
|
2266 |
|
2267 // --------------------------------------------------------- |
|
2268 // CProcessorWlan::FindCertificateEntry |
|
2269 // --------------------------------------------------------- |
|
2270 // |
|
2271 TUint CProcessorWlan::FindCertificateEntryL( const CertificateEntry::TCertType aCertType, const TInt aEapIndex ) |
|
2272 { |
|
2273 TUint certIndex( 0 ); |
|
2274 for( certIndex = 0; certIndex < iEapSettings[aEapIndex]->iEapSettings->iCertificates.Count() ; certIndex++ ) |
|
2275 { |
|
2276 if( iEapSettings[aEapIndex]->iEapSettings->iCertificates[certIndex].iCertType == aCertType ) |
|
2277 { |
|
2278 // Found |
|
2279 break; |
|
2280 } |
|
2281 } |
|
2282 if( certIndex == iEapSettings[aEapIndex]->iEapSettings->iCertificates.Count() ) |
|
2283 { |
|
2284 // Not found. Create |
|
2285 CertificateEntry entry; |
|
2286 |
|
2287 entry.iCertType = aCertType; |
|
2288 |
|
2289 iEapSettings[aEapIndex]->iEapSettings->iCertificates.AppendL( entry ); |
|
2290 |
|
2291 certIndex = iEapSettings[aEapIndex]->iEapSettings->iCertificates.Count() - 1; |
|
2292 } |
|
2293 return certIndex; |
|
2294 } |
|
2295 |
|
2296 // --------------------------------------------------------- |
|
2297 // CProcessorWlan::ConvertSubjectKeyIdToBinary |
|
2298 // --------------------------------------------------------- |
|
2299 // |
|
2300 void CProcessorWlan::ConvertSubjectKeyIdToBinaryL( const HBufC16* const aSubjectKeyIdString, TDes& aBinaryKey) |
|
2301 { |
|
2302 TInt err( KErrNone ); |
|
2303 |
|
2304 // Define literals to search the subject key for possible 0X/0x beginning |
|
2305 _LIT(KHexIdLC, "0x"); |
|
2306 _LIT(KHexIdUC, "0X"); |
|
2307 TBuf<2> hexIdBuf; |
|
2308 |
|
2309 // The lenght of the key given as input |
|
2310 TInt keyLen = aSubjectKeyIdString->Length(); |
|
2311 |
|
2312 // setting the given key to the key buffer |
|
2313 TBuf8<256> origKey; |
|
2314 |
|
2315 origKey.Copy( *aSubjectKeyIdString ); |
|
2316 origKey.SetLength(keyLen); |
|
2317 |
|
2318 TLex8 tmpByte; |
|
2319 TUint16 byte; |
|
2320 |
|
2321 // Remove possible spaces from the beginning |
|
2322 origKey.TrimLeft(); |
|
2323 |
|
2324 // the key should be atleast two chars long |
|
2325 if (origKey.Length() >= 2) |
|
2326 { |
|
2327 // Copy the two left most characters in to the buffer |
|
2328 hexIdBuf.Copy(origKey.Left(2)); |
|
2329 |
|
2330 // If the first characters are 0x or 0X, then thet should be ignored |
|
2331 if (hexIdBuf.Compare(KHexIdLC) == 0 |
|
2332 || hexIdBuf.Compare(KHexIdUC) == 0) |
|
2333 { |
|
2334 // delete two characters |
|
2335 origKey.Delete(0, 2); |
|
2336 } |
|
2337 } |
|
2338 |
|
2339 |
|
2340 // looping the subject key through, removing whitespaces |
|
2341 for (TInt i = 0; i < KKeyIdentifierLength; i++) |
|
2342 { |
|
2343 // removing white spaces from the left side of the key |
|
2344 origKey.TrimLeft(); |
|
2345 // check that there are characters left |
|
2346 if (origKey.Length() >= 2) |
|
2347 { |
|
2348 // pick the two left most bytes from the key |
|
2349 tmpByte = origKey.Left(2); |
|
2350 // convert byte into binary format |
|
2351 err = tmpByte.Val(byte, EHex); |
|
2352 |
|
2353 // check whether conversion to decimal went ok |
|
2354 if (err != KErrNone) |
|
2355 { |
|
2356 // if there are problems, then leave the loop |
|
2357 break; |
|
2358 } |
|
2359 |
|
2360 // store the appended byte into the key variable |
|
2361 aBinaryKey.Append(byte); |
|
2362 // delete two characters from the left side of the character array in the buffer |
|
2363 origKey.Delete(0, 2); |
|
2364 } |
|
2365 else { |
|
2366 // leave the loop, no characters are left |
|
2367 break; |
|
2368 } |
|
2369 } |
|
2370 User::LeaveIfError( err ); |
|
2371 } |
|
2372 |
|
2373 |
|
2374 // End of File. |