|
1 /* |
|
2 * Copyright (c) 2010 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: |
|
15 * EAP method configuration QT interface |
|
16 * |
|
17 */ |
|
18 |
|
19 /* |
|
20 * %version: 39 % |
|
21 */ |
|
22 |
|
23 #include <QDir> |
|
24 #include <QList> |
|
25 #include <QVariant> |
|
26 #include <QPluginLoader> |
|
27 #include <HbTranslator> |
|
28 #include <QLocale> |
|
29 #include <QCoreApplication> |
|
30 #include <QDebug> |
|
31 |
|
32 #include <cmmanager.h> |
|
33 #include <cmpluginwlandef.h> |
|
34 #include <EapGeneralSettings.h> |
|
35 |
|
36 #include <eapqtplugininfo.h> |
|
37 #include <eapqtcertificateinfo.h> |
|
38 |
|
39 #include "cpeapplugininterface.h" |
|
40 #include "eapqtconfiginterface_p.h" |
|
41 |
|
42 // validators |
|
43 #include "eapqtvalidatorpassword.h" |
|
44 #include "eapqtvalidatorusername.h" |
|
45 #include "eapqtvalidatorrealm.h" |
|
46 |
|
47 static const QString eapPluginDir("\\resource\\qt\\plugins\\controlpanel\\eapsecurity"); |
|
48 static const QString eapTranslationFile("cpeapuiplugins"); |
|
49 |
|
50 EapQtConfigInterfacePrivate::EapQtConfigInterfacePrivate() : |
|
51 mValidatorInstance(true), |
|
52 mLastOuterHandle(EapQtPluginHandle::PluginUndefined), |
|
53 mTranslator(NULL), |
|
54 mEapGsIf(NULL), |
|
55 mEapTypeIf(NULL), |
|
56 mIapId(0), |
|
57 mEapBearer(ELan), |
|
58 mEapDbIndex(EapQtConfigInterface::IapIdUndefined), |
|
59 mEapDbIndexValid(false) |
|
60 { |
|
61 qDebug("EapQtConfigInterfacePrivate() - created validator instance, this = 0x%08x", this); |
|
62 |
|
63 } |
|
64 |
|
65 EapQtConfigInterfacePrivate::EapQtConfigInterfacePrivate(/* EapQtConfigInterface *configIf, */ |
|
66 const EapQtConfigInterface::EapBearerType bearerType, const int iapId) : |
|
67 mValidatorInstance(false), |
|
68 mLastOuterHandle(EapQtPluginHandle::PluginUndefined), |
|
69 mTranslator(NULL), |
|
70 mEapGsIf(NULL), |
|
71 mEapTypeIf(NULL), |
|
72 mIapId(iapId), |
|
73 mEapBearer(ELan), |
|
74 mEapDbIndex(EapQtConfigInterface::IapIdUndefined), |
|
75 mEapDbIndexValid(false) |
|
76 { |
|
77 qDebug("EapQtConfigInterfacePrivate() - creating non-validator instance, this = 0x%08x", this); |
|
78 |
|
79 |
|
80 switch (bearerType) { |
|
81 case EapQtConfigInterface::EapBearerTypeVpn: |
|
82 mEapBearer = EVpn; |
|
83 break; |
|
84 default: |
|
85 // All others default to EapQtConfigInterface::EapBearerTypeWlan i.e. ELan |
|
86 mEapBearer = ELan; |
|
87 } |
|
88 |
|
89 if (!setEapDbIndex(iapId)) { |
|
90 qDebug("ERROR: EapQtConfigInterfacePrivate() - setIapId failed, bearer = %d, index = %d", |
|
91 mEapBearer, iapId); |
|
92 shutdown(); |
|
93 // throw an exception |
|
94 qt_symbian_throwIfError(KErrNotFound); |
|
95 } |
|
96 |
|
97 // load plugins after everything else is ok |
|
98 qDebug("EapQtConfigInterfacePrivate() - load plugins"); |
|
99 loadPlugins(); |
|
100 |
|
101 qDebug("EapQtConfigInterfacePrivate() - ends"); |
|
102 } |
|
103 |
|
104 EapQtConfigInterfacePrivate::~EapQtConfigInterfacePrivate() |
|
105 { |
|
106 qDebug("EapQtConfigInterfacePrivate::~EapQtConfigInterfacePrivate(), this = 0x%08x", this); |
|
107 |
|
108 shutdown(); |
|
109 } |
|
110 |
|
111 void EapQtConfigInterfacePrivate::shutdown() |
|
112 { |
|
113 qDebug("EapQtConfigInterfacePrivate::shutdown(), this = 0x%08x", this); |
|
114 |
|
115 |
|
116 mOuterEapsOn.Close(); |
|
117 mOuterEapsOff.Close(); |
|
118 |
|
119 // cleanup Ecom |
|
120 REComSession::FinalClose(); |
|
121 |
|
122 // mTranslator gets deleted automatically (QScopedPointer) |
|
123 // mEapTypeIf gets deleted automatically (QScopedPointer) |
|
124 // mEapGsIf gets deleted automatically (QScopedPointer) |
|
125 } |
|
126 |
|
127 bool EapQtConfigInterfacePrivate::setConfigurationReference(const int iapId) |
|
128 { |
|
129 qDebug("EapQtConfigInterfacePrivate::setConfigurationReference - requested id: %d, this = 0x%08x", iapId, this); |
|
130 |
|
131 checkInstanceThrowing(); |
|
132 return setEapDbIndex(iapId); |
|
133 } |
|
134 |
|
135 bool EapQtConfigInterfacePrivate::setEapDbIndex(const int iapId) |
|
136 { |
|
137 |
|
138 qDebug("EapQtConfigInterfacePrivate::setIapId - requested id: %d, this = 0x%08x", iapId, this); |
|
139 |
|
140 |
|
141 // optimization: do not re-create the interface if the reference does |
|
142 // not change and mEapGsIf exists already |
|
143 |
|
144 // WLAN reference is checked after setEapWlanDbIndex below since iapId may be |
|
145 // different than WLAN service ID |
|
146 |
|
147 // case for EapQtConfigInterface::IapIdUndefined i.e. setIapId was called |
|
148 // with a negative id last time and now again |
|
149 if (!mEapDbIndexValid && !mEapGsIf.isNull() && iapId < 0) { |
|
150 qDebug( |
|
151 "EapQtConfigInterfacePrivate::setIapId - interface created for IapIdUndefined already"); |
|
152 return true; |
|
153 } |
|
154 |
|
155 // case for VPN (or any other bearer) in which iap id equals EAP db index |
|
156 if (mEapBearer != ELan && mEapDbIndexValid && !mEapGsIf.isNull() && iapId == mEapDbIndex) { |
|
157 qDebug( |
|
158 "EapQtConfigInterfacePrivate::setIapId - interface created for requested IAP ID for VPN already"); |
|
159 return true; |
|
160 } |
|
161 |
|
162 // save the current id for checking if WLAN reference changes or not |
|
163 TInt previousEapDbIndex = mEapDbIndex; |
|
164 bool wlanIndexOk = true; |
|
165 |
|
166 // allow accessing certain methods with negative iapId |
|
167 if (iapId < 0) { |
|
168 // set to zero to be able to create EAP server instances |
|
169 mEapDbIndex = 0; |
|
170 mEapDbIndexValid = false; |
|
171 } |
|
172 // for real usage iapId must not be negative |
|
173 else { |
|
174 // for VPN |
|
175 mIapId = iapId; |
|
176 mEapDbIndex = iapId; |
|
177 mEapDbIndexValid = true; |
|
178 |
|
179 // for WLAN |
|
180 if (mEapBearer == ELan) { |
|
181 // get WLAN service ID as the reference |
|
182 mEapDbIndexValid = setEapWlanDbIndex(iapId); |
|
183 wlanIndexOk = mEapDbIndexValid; |
|
184 // do not re-create if the interface is ok for the new (i.e. same) index already |
|
185 if (!mEapGsIf.isNull() && mEapDbIndex == previousEapDbIndex) { |
|
186 qDebug() << "EapQtConfigInterfacePrivate::setIapId - interface" |
|
187 << "created for requested IAP ID for WLAN already"; |
|
188 return true; |
|
189 } |
|
190 |
|
191 } |
|
192 } |
|
193 |
|
194 // delete possibly existing instances |
|
195 mEapGsIf.reset(NULL); |
|
196 mEapTypeIf.reset(NULL); |
|
197 |
|
198 mCurrentServerEapType = *EapExpandedTypeNone.GetType(); |
|
199 mLastOuterHandle = EapQtPluginHandle::PluginUndefined; |
|
200 |
|
201 if (!wlanIndexOk && mEapBearer == ELan) { |
|
202 // setEapWlanDbIndex was called and failed |
|
203 qDebug("ERROR: EapQtConfigInterfacePrivate::setIapId() - setEapWlanDbIndex failed"); |
|
204 return false; |
|
205 } |
|
206 |
|
207 qDebug( |
|
208 "EapQtConfigInterfacePrivate::setIapId() - calls CEapGeneralSettings::NewL(), bearer = %d, index = %d", |
|
209 mEapBearer, mEapDbIndex); |
|
210 |
|
211 // load EAP general settings interface |
|
212 CEapGeneralSettings* tmp = NULL; |
|
213 TRAPD(err, tmp = CEapGeneralSettings::NewL(mEapBearer, mEapDbIndex)); |
|
214 if (err != KErrNone) { |
|
215 qDebug("ERROR: EapQtConfigInterfacePrivate::setIapId - CEapGeneralSettings::NewL() failed"); |
|
216 mEapDbIndexValid = false; |
|
217 return false; |
|
218 } |
|
219 |
|
220 // set to the created instance |
|
221 mEapGsIf.reset(tmp); |
|
222 |
|
223 return true; |
|
224 } |
|
225 |
|
226 bool EapQtConfigInterfacePrivate::setEapWlanDbIndex(const int iapId) |
|
227 { |
|
228 qDebug("EapQtConfigInterfacePrivate::setEapWlanDbIndex - requested id: %d, this = 0x%08x", iapId, this); |
|
229 |
|
230 |
|
231 RCmManager cmm; |
|
232 TRAPD(err, cmm.OpenL()); |
|
233 if (err != KErrNone) { |
|
234 qDebug("ERROR: EapQtConfigInterfacePrivate::setEapWlanDbIndex - cmm.OpenL() failed", |
|
235 mEapBearer, iapId); |
|
236 mEapDbIndex = EapQtConfigInterface::IapIdUndefined; |
|
237 mIapId = 0; |
|
238 return false; |
|
239 } |
|
240 |
|
241 TRAP(err, mEapDbIndex = cmm.GetConnectionMethodInfoIntL(iapId, CMManager::EWlanServiceId)); |
|
242 if (err != KErrNone) { |
|
243 qDebug( |
|
244 "ERROR: EapQtConfigInterfacePrivate::setEapWlanDbIndex - cmm.GetConnectionMethodInfoIntL() failed", |
|
245 mEapBearer, iapId); |
|
246 cmm.Close(); |
|
247 mEapDbIndex = EapQtConfigInterface::IapIdUndefined; |
|
248 mIapId = 0; |
|
249 return false; |
|
250 } |
|
251 |
|
252 cmm.Close(); |
|
253 |
|
254 qDebug("EapQtConfigInterfacePrivate::setEapWlanDbIndex - obtained WLAN service id: %d", |
|
255 mEapDbIndex); |
|
256 |
|
257 return true; |
|
258 } |
|
259 |
|
260 void EapQtConfigInterfacePrivate::checkInstanceThrowing() const |
|
261 { |
|
262 qDebug() << "EapQtConfigInterfacePrivate::checkInstanceThrowing() - mValidatorInstance:" |
|
263 << mValidatorInstance; |
|
264 |
|
265 if (mValidatorInstance) { |
|
266 qDebug( |
|
267 "ERROR: EapQtConfigInterfacePrivate::checkInstanceThrowing - method not supported by this instance"); |
|
268 qt_symbian_throwIfError(KErrNotSupported); |
|
269 } |
|
270 } |
|
271 |
|
272 void EapQtConfigInterfacePrivate::appendEapTypes(const RArray<TEapExpandedType>* const eapTypes, |
|
273 QList<QByteArray>* const eapList) |
|
274 { |
|
275 qDebug("EapQtConfigInterfacePrivate::appendEapTypes(), this = 0x%08x", this); |
|
276 |
|
277 |
|
278 Q_ASSERT(eapTypes); |
|
279 Q_ASSERT(eapList); |
|
280 |
|
281 qDebug("EapQtConfigInterfacePrivate - appendEapTypes, EAP count = %d", eapTypes->Count()); |
|
282 |
|
283 QByteArray tmpEap; |
|
284 for (int ind = 0; ind < eapTypes->Count(); ind++) { |
|
285 tmpEap.append(reinterpret_cast<const char*> ((*eapTypes)[ind].GetValue().Ptr()), |
|
286 (*eapTypes)[ind].GetValue().Length()); |
|
287 eapList->append(tmpEap); |
|
288 qDebug() << "EapQtConfigInterfacePrivate - appendEapTypes added EAP: " << tmpEap.toHex(); |
|
289 tmpEap.clear(); |
|
290 } |
|
291 } |
|
292 |
|
293 QList<EapQtPluginInfo> EapQtConfigInterfacePrivate::supportedOuterTypes() |
|
294 { |
|
295 qDebug("EapQtConfigInterfacePrivate::supportedOuterTypes(), this = 0x%08x", this); |
|
296 |
|
297 |
|
298 checkInstanceThrowing(); |
|
299 |
|
300 if (mEapGsIf.isNull()) { |
|
301 qDebug("ERROR: EapQtConfigInterfacePrivate::supportedOuterTypes() - mEapGsIf is NULL"); |
|
302 mOuterEapsOn.Reset(); |
|
303 mOuterEapsOff.Reset(); |
|
304 // return empty list |
|
305 mSupportedOuterTypes.clear(); |
|
306 return mSupportedOuterTypes; |
|
307 } |
|
308 |
|
309 // get outer EAPs from EAP server, |
|
310 // returned in two lists: enabled and disabled outer EAPs |
|
311 // do this always as the list might have changed and mOuterEapsOn/Off are needed in |
|
312 // other methods |
|
313 |
|
314 mOuterEapsOn.Reset(); |
|
315 mOuterEapsOff.Reset(); |
|
316 |
|
317 qDebug("EapQtConfigInterfacePrivate::supportedOuterTypes() - calls GetEapMethods()"); |
|
318 |
|
319 TUint err = mEapGsIf->GetEapMethods(mOuterEapsOn, mOuterEapsOff); |
|
320 if (err != KErrNone) { |
|
321 qDebug("ERROR: EapQtConfigInterfacePrivate::supportedOuterTypes() - GetEapMethods failed"); |
|
322 mOuterEapsOn.Reset(); |
|
323 mOuterEapsOff.Reset(); |
|
324 // return empty list |
|
325 mSupportedOuterTypes.clear(); |
|
326 return mSupportedOuterTypes; |
|
327 } |
|
328 |
|
329 // optimization: collect the list only once per instance life time |
|
330 // since no new EAPs will appear to the combination of mOuterEapsOn and mOuterEapsOff |
|
331 if (mSupportedOuterTypes.count() > 0) { |
|
332 qDebug( |
|
333 "EapQtConfigInterfacePrivate - supportedOuterTypes: supported EAPs already listed, return stored list"); |
|
334 return mSupportedOuterTypes; |
|
335 } |
|
336 |
|
337 qDebug("EapQtConfigInterfacePrivate - supportedOuterTypes: copy response to QList"); |
|
338 |
|
339 // copy response to qlist for easier comparison |
|
340 QList<QByteArray> outerEaps; |
|
341 |
|
342 appendEapTypes(&mOuterEapsOn, &outerEaps); |
|
343 appendEapTypes(&mOuterEapsOff, &outerEaps); |
|
344 |
|
345 qDebug("EapQtConfigInterfacePrivate - supportedOuterTypes: EAP server outer type count: %d", |
|
346 outerEaps.count()); |
|
347 |
|
348 qDebug("EapQtConfigInterfacePrivate - supportedOuterTypes: collected UI plugin count: %d", |
|
349 mPluginInfos.count()); |
|
350 |
|
351 // set mSupportedOuterTypes to contain only EAPs that both UI and EAP server support |
|
352 QByteArray tmpEap; |
|
353 for (int ind = 0; ind < mPluginInfos.count(); ind++) { |
|
354 tmpEap = mPluginInfos[ind].pluginHandle().type().eapExpandedData(); |
|
355 if (outerEaps.contains(tmpEap)) { |
|
356 mSupportedOuterTypes.append(mPluginInfos[ind]); |
|
357 qDebug() << "EapQtConfigInterfacePrivate - supportedOuterTypes: appended EAP: " |
|
358 << tmpEap.toHex(); |
|
359 } |
|
360 } |
|
361 |
|
362 qDebug("EapQtConfigInterfacePrivate - supportedOuterTypes: supported EAP count: %d", |
|
363 mSupportedOuterTypes.count()); |
|
364 |
|
365 return mSupportedOuterTypes; |
|
366 } |
|
367 |
|
368 // checks if UI plugins support supplied eapType and returns the |
|
369 // index (in mPluginInfos) of the supporting plugin |
|
370 bool EapQtConfigInterfacePrivate::isUiSupported(const QByteArray &eapType, int &pluginIndex) const |
|
371 { |
|
372 qDebug("EapQtConfigInterfacePrivate::isUiSupported(), this = 0x%08x", this); |
|
373 |
|
374 bool ret = false; |
|
375 for (int ind = 0; ind < mPluginInfos.count(); ind++) { |
|
376 qDebug("EapQtConfigInterfacePrivate::isUiSupported() - checking index: %d", ind); |
|
377 pluginIndex = ind; |
|
378 if (eapType == mPluginInfos[ind].pluginHandle().type().eapExpandedData()) { |
|
379 qDebug("EapQtConfigInterfacePrivate::isUiSupported() - ui supported!"); |
|
380 ret = true; |
|
381 break; |
|
382 } |
|
383 } |
|
384 return ret; |
|
385 } |
|
386 |
|
387 QList<EapQtPluginInfo> EapQtConfigInterfacePrivate::supportedInnerTypes( |
|
388 const EapQtPluginHandle& outer) |
|
389 { |
|
390 qDebug("EapQtConfigInterfacePrivate::supportedInnerTypes(), this = 0x%08x", this); |
|
391 |
|
392 |
|
393 checkInstanceThrowing(); |
|
394 |
|
395 // check if we already have up-to-date data |
|
396 if (mLastOuterHandle == outer) { |
|
397 return mSupportedInnerTypes; |
|
398 } |
|
399 |
|
400 // clear previous query result |
|
401 mSupportedInnerTypes.clear(); |
|
402 mLastOuterHandle = EapQtPluginHandle::PluginUndefined; |
|
403 |
|
404 qDebug() |
|
405 << "EapQtConfigInterfacePrivate::supportedInnerTypes() - calls isSupportedOuterType for: " |
|
406 << outer.type().eapExpandedData().toHex(); |
|
407 |
|
408 // check if the queried outer EAP is supported |
|
409 if (!isSupportedOuterType(outer)) { |
|
410 qDebug() |
|
411 << "ERROR: EapQtConfigInterfacePrivate::supportedInnerTypes() - queried outer type not supported: " |
|
412 << outer.type().eapExpandedData().toHex(); |
|
413 // return empty list |
|
414 return mSupportedInnerTypes; |
|
415 } |
|
416 |
|
417 qDebug("EapQtConfigInterfacePrivate::supportedInnerTypes() - calls getEapTypeIf"); |
|
418 |
|
419 // get outer EAP settings interface |
|
420 getEapTypeIf(outer); |
|
421 if (mEapTypeIf.isNull()) { |
|
422 qDebug("ERROR: EapQtConfigInterfacePrivate::supportedInnerTypes() - getEapTypeIf failed"); |
|
423 // return empty list |
|
424 return mSupportedInnerTypes; |
|
425 } |
|
426 |
|
427 // get outer EAP settings |
|
428 EAPSettings eapSettings; |
|
429 TRAPD(err, mEapTypeIf->GetConfigurationL(eapSettings)); |
|
430 // getEapTypeIf has set mCurrentServerEapType correctly for comparison |
|
431 if (err != KErrNone || eapSettings.iEAPExpandedType != mCurrentServerEapType) { |
|
432 qDebug("ERROR: EapQtConfigInterfacePrivate::supportedInnerTypes - GetConfigurationL failed"); |
|
433 // clear the instance so that the next attempt starts from scratch |
|
434 mEapTypeIf.reset(NULL); |
|
435 // return empty list |
|
436 return mSupportedInnerTypes; |
|
437 } |
|
438 |
|
439 // store inner EAPs supported by EAP server |
|
440 QList<QByteArray> innerEaps; |
|
441 appendEapTypes(&(eapSettings.iEnabledEncapsulatedEAPExpandedTypes), &innerEaps); |
|
442 appendEapTypes(&(eapSettings.iDisabledEncapsulatedEAPExpandedTypes), &innerEaps); |
|
443 |
|
444 int pluginIndex = 0; |
|
445 for (int ind = 0; ind < innerEaps.count(); ind++) { |
|
446 // report only EAPs which do have an UI plugin |
|
447 if (isUiSupported(innerEaps[ind], pluginIndex)) { |
|
448 mSupportedInnerTypes.append(mPluginInfos[pluginIndex]); |
|
449 qDebug() << "EapQtConfigInterfacePrivate::supportedInnerTypes - added inner EAP: " |
|
450 << innerEaps[ind].toHex(); |
|
451 } |
|
452 } |
|
453 |
|
454 mLastOuterHandle = outer; |
|
455 |
|
456 return mSupportedInnerTypes; |
|
457 } |
|
458 |
|
459 void EapQtConfigInterfacePrivate::copyCertificateInfo( |
|
460 const RPointerArray<EapCertificateEntry>* const certEntries, |
|
461 QList<EapQtCertificateInfo>* const certInfos) |
|
462 { |
|
463 qDebug("EapQtConfigInterfacePrivate::copyCertificateInfo(), this = 0x%08x", this); |
|
464 |
|
465 |
|
466 Q_ASSERT(certEntries); |
|
467 Q_ASSERT(certInfos); |
|
468 |
|
469 certInfos->clear(); |
|
470 |
|
471 EapQtCertificateInfo cert; |
|
472 TKeyIdentifier subjectKeyId; |
|
473 const TDes* text = 0; |
|
474 int ind = 0; |
|
475 |
|
476 for (ind = 0; ind < certEntries->Count(); ind++) { |
|
477 |
|
478 qDebug() << "EapQtConfigInterfacePrivate - copyCertificateInfo *** certificate starts *** "; |
|
479 |
|
480 if ((*certEntries)[ind]->GetSubjectNamePresent() != EFalse) { |
|
481 |
|
482 text = (*certEntries)[ind]->GetSubjectName(); |
|
483 cert.setValue(EapQtCertificateInfo::SubjectName, QString::fromUtf16(text->Ptr(), |
|
484 text->Length())); |
|
485 |
|
486 qDebug() << "EapQtConfigInterfacePrivate - copyCertificateInfo SubjectName: " |
|
487 << QString::fromUtf16(text->Ptr(), text->Length()); |
|
488 } |
|
489 if ((*certEntries)[ind]->GetIssuerNamePresent() != EFalse) { |
|
490 |
|
491 text = (*certEntries)[ind]->GetIssuerName(); |
|
492 cert.setValue(EapQtCertificateInfo::IssuerName, QString::fromUtf16(text->Ptr(), |
|
493 text->Length())); |
|
494 |
|
495 qDebug() << "EapQtConfigInterfacePrivate - copyCertificateInfo IssuerName: " |
|
496 << QString::fromUtf16(text->Ptr(), text->Length()); |
|
497 } |
|
498 if ((*certEntries)[ind]->GetSerialNumberPresent() != EFalse) { |
|
499 |
|
500 text = (*certEntries)[ind]->GetSerialNumber(); |
|
501 cert.setValue(EapQtCertificateInfo::SerialNumber, QString::fromUtf16(text->Ptr(), |
|
502 text->Length())); |
|
503 |
|
504 qDebug() << "EapQtConfigInterfacePrivate - copyCertificateInfo SerialNumber: " |
|
505 << QString::fromUtf16(text->Ptr(), text->Length()); |
|
506 } |
|
507 if ((*certEntries)[ind]->GetSubjectKeyIdPresent() != EFalse) { |
|
508 |
|
509 subjectKeyId = (*certEntries)[ind]->GetSubjectKeyId(); |
|
510 cert.setValue(EapQtCertificateInfo::SubjectKeyId, QByteArray( |
|
511 reinterpret_cast<const char*> (subjectKeyId.Ptr()), subjectKeyId.Length())); |
|
512 |
|
513 qDebug() << "EapQtConfigInterfacePrivate - copyCertificateInfo SubjectKeyId: " |
|
514 << (QByteArray(reinterpret_cast<const char*> (subjectKeyId.Ptr()), |
|
515 subjectKeyId.Length())).toHex(); |
|
516 } |
|
517 if ((*certEntries)[ind]->GetThumbprintPresent() != EFalse) { |
|
518 |
|
519 text = (*certEntries)[ind]->GetThumbprint(); |
|
520 cert.setValue(EapQtCertificateInfo::ThumbPrint, QString::fromUtf16(text->Ptr(), |
|
521 text->Length())); |
|
522 |
|
523 qDebug() << "EapQtConfigInterfacePrivate - copyCertificateInfo ThumbPrint: " |
|
524 << QString::fromUtf16(text->Ptr(), text->Length()); |
|
525 } |
|
526 if ((*certEntries)[ind]->GetLabelPresent() != EFalse) { |
|
527 |
|
528 text = (*certEntries)[ind]->GetLabel(); |
|
529 cert.setValue(EapQtCertificateInfo::CertificateLabel, QString::fromUtf16(text->Ptr(), |
|
530 text->Length())); |
|
531 |
|
532 qDebug() << "EapQtConfigInterfacePrivate - copyCertificateInfo CertificateLabel: " |
|
533 << QString::fromUtf16(text->Ptr(), text->Length()); |
|
534 } |
|
535 |
|
536 qDebug() << "EapQtConfigInterfacePrivate - copyCertificateInfo *** certificate ends *** "; |
|
537 |
|
538 certInfos->append(cert); |
|
539 |
|
540 } |
|
541 } |
|
542 |
|
543 bool EapQtConfigInterfacePrivate::fetchCertificates(QList<EapQtCertificateInfo>* const caInfos, |
|
544 QList<EapQtCertificateInfo>* const clientInfos) |
|
545 { |
|
546 qDebug("EapQtConfigInterfacePrivate::fetchCertificates(), this = 0x%08x", this); |
|
547 |
|
548 |
|
549 Q_ASSERT(caInfos != NULL || clientInfos != NULL || !mEapGsIf.isNull()); |
|
550 |
|
551 TInt err(KErrNone); |
|
552 RPointerArray<EapCertificateEntry> clientCerts; |
|
553 RPointerArray<EapCertificateEntry> caCerts; |
|
554 |
|
555 // lists are always queried again as the user might have installed new certificates |
|
556 // during the life time of the object |
|
557 err = mEapGsIf->GetCertificateLists(clientCerts, caCerts); |
|
558 if (err != KErrNone) { |
|
559 qDebug("EapQtConfigInterfacePrivate - fetchCertificates failed: %d", err); |
|
560 caCerts.ResetAndDestroy(); |
|
561 clientCerts.ResetAndDestroy(); |
|
562 return false; |
|
563 } |
|
564 |
|
565 qDebug("user cert count: %d, CA cert count: %d", clientCerts.Count(), caCerts.Count()); |
|
566 |
|
567 if (caInfos != NULL) { |
|
568 copyCertificateInfo(&caCerts, caInfos); |
|
569 } |
|
570 if (clientInfos != NULL) { |
|
571 copyCertificateInfo(&clientCerts, clientInfos); |
|
572 } |
|
573 |
|
574 caCerts.ResetAndDestroy(); |
|
575 clientCerts.ResetAndDestroy(); |
|
576 return true; |
|
577 } |
|
578 |
|
579 QList<EapQtCertificateInfo> EapQtConfigInterfacePrivate::certificateAuthorityCertificates() |
|
580 { |
|
581 qDebug("EapQtConfigInterfacePrivate::certificateAuthorityCertificates(), this = 0x%08x", this); |
|
582 |
|
583 |
|
584 checkInstanceThrowing(); |
|
585 |
|
586 QList<EapQtCertificateInfo> list; |
|
587 if (!fetchCertificates(&list, 0)) { |
|
588 // query failed |
|
589 list.clear(); |
|
590 } |
|
591 return list; |
|
592 } |
|
593 |
|
594 QList<EapQtCertificateInfo> EapQtConfigInterfacePrivate::userCertificates() |
|
595 { |
|
596 qDebug("EapQtConfigInterfacePrivate::userCertificates(), this = 0x%08x", this); |
|
597 |
|
598 |
|
599 checkInstanceThrowing(); |
|
600 |
|
601 QList<EapQtCertificateInfo> list; |
|
602 if (!fetchCertificates(0, &list)) { |
|
603 // query failed |
|
604 list.clear(); |
|
605 } |
|
606 return list; |
|
607 } |
|
608 |
|
609 void EapQtConfigInterfacePrivate::getEapTypeIf(const EapQtPluginHandle& pluginHandle) |
|
610 { |
|
611 qDebug("EapQtConfigInterfacePrivate::getEapTypeIf(), this = 0x%08x", this); |
|
612 |
|
613 |
|
614 // dig up the EAP type in TEapExpandedType format |
|
615 TEapExpandedType eapServerType; |
|
616 QByteArray eapType = pluginHandle.type().eapExpandedData(); |
|
617 TInt err(KErrNone); |
|
618 |
|
619 qDebug() << "EapQtConfigInterfacePrivate - getEapTypeIf: wanted EAP type: " << eapType.toHex(); |
|
620 |
|
621 // no need to check if this is successful, |
|
622 // CEapType::NewL call will handle errors |
|
623 (void) eapServerType.SetValue(eapType.data(), eapType.length()); |
|
624 |
|
625 // slight optimization, load interface only if it does not exist or the EAP type changes |
|
626 if (mEapTypeIf.isNull() || mCurrentServerEapType != eapServerType) { |
|
627 |
|
628 qDebug("EapQtConfigInterfacePrivate - getEapTypeIf deletes previous instance"); |
|
629 |
|
630 // delete previous instance |
|
631 mEapTypeIf.reset(NULL); |
|
632 mCurrentServerEapType = eapServerType; |
|
633 |
|
634 qDebug("EapQtConfigInterfacePrivate - getEapTypeIf calls CEapType::NewL()"); |
|
635 |
|
636 // trap all leaves |
|
637 CEapType* tmp = NULL; |
|
638 TRAP(err, tmp = CEapType::NewL(mEapBearer, mEapDbIndex, mCurrentServerEapType)); |
|
639 if (err != KErrNone) { |
|
640 qDebug( |
|
641 "ERROR: EapQtConfigInterfacePrivate - getEapTypeIf CEapType::NewL failed with error: %d", |
|
642 err); |
|
643 mCurrentServerEapType = *EapExpandedTypeNone.GetType(); |
|
644 } |
|
645 mEapTypeIf.reset(tmp); |
|
646 } |
|
647 |
|
648 // always clear the tunnelling type state just in case some earlier call has set it |
|
649 if (!mEapTypeIf.isNull()) { |
|
650 mEapTypeIf->SetTunnelingType(*EapExpandedTypeNone.GetType()); |
|
651 } |
|
652 |
|
653 } |
|
654 |
|
655 // in config: |
|
656 // if OuterType is defined, the configuration for pluginHandle is set inside this OuterType |
|
657 // if OuterType is not defined, pluginHandle is for an outer type |
|
658 // if InnerType is defined, the defined inner types in config are activated for pluginHandle |
|
659 // if InnerType is not defined, the pluginHandle does not activate any inner type (or they do not exist) |
|
660 bool EapQtConfigInterfacePrivate::saveConfiguration(const EapQtPluginHandle& pluginHandle, |
|
661 EapQtConfig& config) |
|
662 { |
|
663 qDebug("EapQtConfigInterfacePrivate::saveConfiguration(), this = 0x%08x", this); |
|
664 |
|
665 |
|
666 checkInstanceThrowing(); |
|
667 |
|
668 if (!mEapDbIndexValid) { |
|
669 qDebug() << "ERROR: Database reference not valid, call setConfigurationReference first!"; |
|
670 return false; |
|
671 } |
|
672 |
|
673 // only check if EAP ui is supported here, |
|
674 // getEapTypeIf checks the EAP server support |
|
675 int dummy = 0; |
|
676 if (!isUiSupported(pluginHandle.type().eapExpandedData(), dummy)) { |
|
677 qDebug( |
|
678 "ERROR: EapQtConfigInterfacePrivate::saveConfiguration() - UI not supported for the requested EAP"); |
|
679 return false; |
|
680 } |
|
681 |
|
682 getEapTypeIf(pluginHandle); |
|
683 if (mEapTypeIf.isNull()) { |
|
684 qDebug("ERROR: EapQtConfigInterfacePrivate::saveConfiguration() - getEapTypeIf failed"); |
|
685 return false; |
|
686 } |
|
687 |
|
688 // set tunneling type |
|
689 // if we are configuring outer type, OuterType == Invalid or EapQtPluginHandle::PluginUndefined |
|
690 |
|
691 EapQtPluginHandle tmpOuterHandle; |
|
692 QVariant varValue = config.value(EapQtConfig::OuterType); |
|
693 if (varValue != QVariant::Invalid) { |
|
694 tmpOuterHandle = varValue.value<EapQtPluginHandle> (); |
|
695 } |
|
696 else { |
|
697 tmpOuterHandle = EapQtPluginHandle::PluginUndefined; |
|
698 } |
|
699 |
|
700 TEapExpandedType tmpOuterEap; |
|
701 tmpOuterEap.SetValue(tmpOuterHandle.type().eapExpandedData().data(), |
|
702 tmpOuterHandle.type().eapExpandedData().length()); |
|
703 |
|
704 qDebug() << "EapQtConfigInterfacePrivate::saveConfiguration() - sets tunnelling type to: " |
|
705 << tmpOuterHandle.type().eapExpandedData().toHex(); |
|
706 |
|
707 mEapTypeIf->SetTunnelingType(tmpOuterEap); |
|
708 |
|
709 // set EAP type here |
|
710 QByteArray eapType = pluginHandle.type().eapExpandedData(); |
|
711 |
|
712 // copy config to EAP settings, |
|
713 // no need to check if this is successful, |
|
714 // SetConfigurationL call will handle errors |
|
715 EAPSettings eapSettings; |
|
716 (void) eapSettings.iEAPExpandedType.SetValue(eapType.data(), eapType.length()); |
|
717 |
|
718 // copy the rest of the settings in the function |
|
719 copyToEapSettings(config, eapSettings); |
|
720 // store settings |
|
721 TRAPD(err, mEapTypeIf->SetConfigurationL(eapSettings)); |
|
722 if (err != KErrNone) { |
|
723 qDebug("ERROR: EapQtConfigInterfacePrivate - saveConfiguration: SetConfigurationL failed"); |
|
724 // clear the instance so that the next attempt starts from scratch |
|
725 mEapTypeIf.reset(NULL); |
|
726 mCurrentServerEapType = *EapExpandedTypeNone.GetType(); |
|
727 return false; |
|
728 } |
|
729 |
|
730 return true; |
|
731 } |
|
732 |
|
733 // config must be empty when calling |
|
734 bool EapQtConfigInterfacePrivate::readConfiguration(const EapQtPluginHandle& outerHandle, |
|
735 const EapQtPluginHandle& pluginHandle, EapQtConfig& config) |
|
736 { |
|
737 qDebug("EapQtConfigInterfacePrivate::readConfiguration(), this = 0x%08x", this); |
|
738 |
|
739 |
|
740 // clear input |
|
741 config.clear(); |
|
742 |
|
743 checkInstanceThrowing(); |
|
744 |
|
745 if (!mEapDbIndexValid) { |
|
746 qDebug() << "ERROR: Database reference not valid, call setConfigurationReference first!"; |
|
747 return false; |
|
748 } |
|
749 |
|
750 // only check if UI is supported for pluginHandle here, |
|
751 // getEapTypeIf checks the EAP server support |
|
752 int dummy = 0; |
|
753 if (!isUiSupported(pluginHandle.type().eapExpandedData(), dummy)) { |
|
754 qDebug( |
|
755 "ERROR: EapQtConfigInterfacePrivate::readConfiguration - UI not supported for the requested EAP"); |
|
756 return false; |
|
757 } |
|
758 |
|
759 getEapTypeIf(pluginHandle); |
|
760 if (mEapTypeIf.isNull()) { |
|
761 qDebug("ERROR: EapQtConfigInterfacePrivate::readConfiguration - getEapTypeIf failed"); |
|
762 return false; |
|
763 } |
|
764 |
|
765 // set tunneling type |
|
766 // if we are configuring outer type, outerHandle == EapQtPluginHandle::PluginUndefined |
|
767 // and calling SetTunnelingType is also ok |
|
768 TEapExpandedType tmpEap; |
|
769 tmpEap.SetValue(outerHandle.type().eapExpandedData().data(), |
|
770 outerHandle.type().eapExpandedData().length()); |
|
771 |
|
772 qDebug() << "EapQtConfigInterfacePrivate::readConfiguration - sets tunnelling type to: " |
|
773 << outerHandle.type().eapExpandedData().toHex(); |
|
774 |
|
775 mEapTypeIf->SetTunnelingType(tmpEap); |
|
776 |
|
777 // always set OuterType, |
|
778 // set to EapQtPluginHandle::PluginUndefined if no outer type specified |
|
779 config.setValue(EapQtConfig::OuterType, qVariantFromValue(outerHandle)); |
|
780 |
|
781 qDebug("EapQtConfigInterfacePrivate::readConfiguration - calls GetConfigurationL()"); |
|
782 |
|
783 // trap all leaves |
|
784 EAPSettings eapSettings; |
|
785 TRAPD(err, mEapTypeIf->GetConfigurationL(eapSettings)); |
|
786 |
|
787 // check if failed or something strange happened (incorrect EAP type settings received) |
|
788 if (err != KErrNone || eapSettings.iEAPExpandedType != mCurrentServerEapType) { |
|
789 qDebug("ERROR: EapQtConfigInterfacePrivate - readConfiguration: GetConfigurationL failed"); |
|
790 // clear the instance so that the next attempt starts from scratch |
|
791 mEapTypeIf.reset(NULL); |
|
792 mCurrentServerEapType = *EapExpandedTypeNone.GetType(); |
|
793 // nothing to be set to config |
|
794 return false; |
|
795 } |
|
796 copyFromEapSettings(eapSettings, config); |
|
797 return true; |
|
798 } |
|
799 |
|
800 bool EapQtConfigInterfacePrivate::convertToBool(TBool value) |
|
801 { |
|
802 return (value != EFalse ? true : false); |
|
803 } |
|
804 |
|
805 TBool EapQtConfigInterfacePrivate::convertToTbool(bool value) |
|
806 { |
|
807 return (value ? ETrue : EFalse); |
|
808 } |
|
809 |
|
810 void EapQtConfigInterfacePrivate::copyToEapSettings(EapQtConfig& config, EAPSettings& eapSettings) |
|
811 { |
|
812 // TODO: |
|
813 // - fix & add validation |
|
814 // - check if there are something missing still defined in EapSettings.h |
|
815 // - pac store parameters from eapqtconfig.h |
|
816 |
|
817 qDebug("EapQtConfigInterfacePrivate::copyToEapSettings(), this = 0x%08x", this); |
|
818 |
|
819 |
|
820 int ind = 0; |
|
821 |
|
822 QVariant varValue = config.value(EapQtConfig::UsernameAutomatic); |
|
823 if (varValue.type() == QVariant::Bool) { |
|
824 eapSettings.iUseAutomaticUsernamePresent = ETrue; |
|
825 eapSettings.iUseAutomaticUsername = convertToTbool(varValue.toBool()); |
|
826 qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings UsernameAutomatic: " |
|
827 << varValue.toBool(); |
|
828 } |
|
829 |
|
830 varValue = config.value(EapQtConfig::AuthorityCertificateAutomatic); |
|
831 if (varValue.type() == QVariant::Bool) { |
|
832 eapSettings.iUseAutomaticCACertificatePresent = ETrue; |
|
833 eapSettings.iUseAutomaticCACertificate = convertToTbool(varValue.toBool()); |
|
834 qDebug() |
|
835 << "EapQtConfigInterfacePrivate - copyToEapSettings AuthorityCertificateAutomatic: " |
|
836 << varValue.toBool(); |
|
837 } |
|
838 |
|
839 varValue = config.value(EapQtConfig::Username); |
|
840 // do not copy if too large string |
|
841 if (varValue.type() == QVariant::String && varValue.toString().count() <= StringMaxLength) { |
|
842 // QString::utf16 returns a null terminated string |
|
843 eapSettings.iUsername.Copy(varValue.toString().utf16()); |
|
844 eapSettings.iUsernamePresent = ETrue; |
|
845 qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings Username: " |
|
846 << varValue.toString(); |
|
847 } |
|
848 |
|
849 varValue = config.value(EapQtConfig::PasswordPrompt); |
|
850 if (varValue.type() == QVariant::Bool) { |
|
851 eapSettings.iShowPassWordPromptPresent = ETrue; |
|
852 eapSettings.iShowPassWordPrompt = convertToTbool(varValue.toBool()); |
|
853 qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings PasswordPrompt: " |
|
854 << varValue.toBool(); |
|
855 } |
|
856 |
|
857 varValue = config.value(EapQtConfig::Password); |
|
858 // do not copy if too large string |
|
859 if (varValue.type() == QVariant::String && varValue.toString().count() <= StringMaxLength) { |
|
860 //QString::utf16 returns a null terminated string |
|
861 eapSettings.iPassword.Copy(varValue.toString().utf16()); |
|
862 eapSettings.iPasswordPresent = ETrue; |
|
863 qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings Password: " |
|
864 << varValue.toString(); |
|
865 } |
|
866 |
|
867 varValue = config.value(EapQtConfig::PasswordClear); |
|
868 if (varValue.type() == QVariant::Bool) { |
|
869 eapSettings.iPasswordExistPresent = ETrue; |
|
870 eapSettings.iPasswordExist = convertToTbool(varValue.toBool()); |
|
871 qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings PasswordClear: " |
|
872 << varValue.toBool(); |
|
873 } |
|
874 |
|
875 varValue = config.value(EapQtConfig::RealmAutomatic); |
|
876 if (varValue.type() == QVariant::Bool) { |
|
877 eapSettings.iUseAutomaticRealmPresent = ETrue; |
|
878 eapSettings.iUseAutomaticRealm = convertToTbool(varValue.toBool()); |
|
879 qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings RealmAutomatic: " |
|
880 << varValue.toBool(); |
|
881 } |
|
882 |
|
883 varValue = config.value(EapQtConfig::Realm); |
|
884 // do not copy if too large string |
|
885 if (varValue.type() == QVariant::String && varValue.toString().count() <= StringMaxLength) { |
|
886 // QString::utf16 returns a null terminated string |
|
887 eapSettings.iRealm.Copy(varValue.toString().utf16()); |
|
888 eapSettings.iRealmPresent = ETrue; |
|
889 qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings Realm: " |
|
890 << varValue.toString(); |
|
891 } |
|
892 |
|
893 varValue = config.value(EapQtConfig::UsePseudonyms); |
|
894 if (varValue.type() == QVariant::Bool) { |
|
895 eapSettings.iUsePseudonymsPresent = ETrue; |
|
896 eapSettings.iUsePseudonyms = convertToTbool(varValue.toBool()); |
|
897 qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings UsePseudonyms: " |
|
898 << varValue.toBool(); |
|
899 } |
|
900 |
|
901 varValue = config.value(EapQtConfig::VerifyServerRealm); |
|
902 if (varValue.type() == QVariant::Bool) { |
|
903 eapSettings.iVerifyServerRealmPresent = ETrue; |
|
904 eapSettings.iVerifyServerRealm = convertToTbool(varValue.toBool()); |
|
905 qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings VerifyServerRealm: " |
|
906 << varValue.toBool(); |
|
907 } |
|
908 |
|
909 varValue = config.value(EapQtConfig::ClientAuthenticationRequired); |
|
910 if (varValue.type() == QVariant::Bool) { |
|
911 eapSettings.iRequireClientAuthenticationPresent = ETrue; |
|
912 eapSettings.iRequireClientAuthentication = convertToTbool(varValue.toBool()); |
|
913 qDebug() |
|
914 << "EapQtConfigInterfacePrivate - copyToEapSettings ClientAuthenticationRequired: " |
|
915 << varValue.toBool(); |
|
916 } |
|
917 |
|
918 varValue = config.value(EapQtConfig::SessionValidityTime); |
|
919 if (varValue.type() == QVariant::UInt) { |
|
920 eapSettings.iSessionValidityTimePresent = ETrue; |
|
921 eapSettings.iSessionValidityTime = varValue.toUInt(); |
|
922 qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings SessionValidityTime: " |
|
923 << varValue.toUInt(); |
|
924 } |
|
925 |
|
926 varValue = config.value(EapQtConfig::PeapVersion0Allowed); |
|
927 if (varValue.type() == QVariant::Bool) { |
|
928 eapSettings.iPEAPVersionsPresent = ETrue; |
|
929 eapSettings.iPEAPv0Allowed = convertToTbool(varValue.toBool()); |
|
930 qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings PeapVersion0Allowed: " |
|
931 << varValue.toBool(); |
|
932 } |
|
933 |
|
934 varValue = config.value(EapQtConfig::PeapVersion1Allowed); |
|
935 if (varValue.type() == QVariant::Bool) { |
|
936 eapSettings.iPEAPVersionsPresent = ETrue; |
|
937 eapSettings.iPEAPv1Allowed = convertToTbool(varValue.toBool()); |
|
938 qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings PeapVersion1Allowed: " |
|
939 << varValue.toBool(); |
|
940 } |
|
941 |
|
942 varValue = config.value(EapQtConfig::PeapVersion2Allowed); |
|
943 if (varValue.type() == QVariant::Bool) { |
|
944 eapSettings.iPEAPVersionsPresent = ETrue; |
|
945 eapSettings.iPEAPv2Allowed = convertToTbool(varValue.toBool()); |
|
946 qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings PeapVersion2Allowed: " |
|
947 << varValue.toBool(); |
|
948 } |
|
949 |
|
950 varValue = config.value(EapQtConfig::ProvisioningModeAuthenticated); |
|
951 if (varValue.type() == QVariant::Bool) { |
|
952 eapSettings.iAuthProvModeAllowedPresent = ETrue; |
|
953 eapSettings.iAuthProvModeAllowed = convertToTbool(varValue.toBool()); |
|
954 qDebug() |
|
955 << "EapQtConfigInterfacePrivate - copyToEapSettings ProvisioningModeAuthenticated: " |
|
956 << varValue.toBool(); |
|
957 } |
|
958 |
|
959 varValue = config.value(EapQtConfig::ProvisioningModeUnauthenticated); |
|
960 if (varValue.type() == QVariant::Bool) { |
|
961 eapSettings.iUnauthProvModeAllowedPresent = ETrue; |
|
962 eapSettings.iUnauthProvModeAllowed = convertToTbool(varValue.toBool()); |
|
963 qDebug() |
|
964 << "EapQtConfigInterfacePrivate - copyToEapSettings ProvisioningModeUnauthenticated: " |
|
965 << varValue.toBool(); |
|
966 } |
|
967 |
|
968 varValue = config.value(EapQtConfig::PACGroupReference); |
|
969 // do not copy if too large string |
|
970 if (varValue.type() == QVariant::String && varValue.toString().count() <= StringMaxLength) { |
|
971 // TODO: what is the format (ascii/unicode?) of iPACGroupReference? |
|
972 qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings PACGroupReference: " |
|
973 << varValue.toString(); |
|
974 } |
|
975 |
|
976 varValue = config.value(EapQtConfig::WarnADHPNoPAC); |
|
977 if (varValue.type() == QVariant::Bool) { |
|
978 eapSettings.iWarnADHPNoPACPresent = ETrue; |
|
979 eapSettings.iWarnADHPNoPAC = convertToTbool(varValue.toBool()); |
|
980 qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings WarnADHPNoPAC: " |
|
981 << varValue.toBool(); |
|
982 } |
|
983 |
|
984 varValue = config.value(EapQtConfig::WarnADHPNoMatchingPAC); |
|
985 if (varValue.type() == QVariant::Bool) { |
|
986 eapSettings.iWarnADHPNoMatchingPACPresent = ETrue; |
|
987 eapSettings.iWarnADHPNoMatchingPAC = convertToTbool(varValue.toBool()); |
|
988 qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings WarnADHPNoMatchingPAC: " |
|
989 << varValue.toBool(); |
|
990 } |
|
991 |
|
992 varValue = config.value(EapQtConfig::WarnNotDefaultServer); |
|
993 if (varValue.type() == QVariant::Bool) { |
|
994 eapSettings.iWarnNotDefaultServerPresent = ETrue; |
|
995 eapSettings.iWarnNotDefaultServer = convertToTbool(varValue.toBool()); |
|
996 qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings WarnNotDefaultServer: " |
|
997 << varValue.toBool(); |
|
998 } |
|
999 |
|
1000 varValue = config.value(EapQtConfig::UseIdentityPrivacy); |
|
1001 if (varValue.type() == QVariant::Bool) { |
|
1002 eapSettings.iUseIdentityPrivacyPresent = ETrue; |
|
1003 eapSettings.iUseIdentityPrivacy = convertToTbool(varValue.toBool()); |
|
1004 qDebug() << "EapQtConfigInterfacePrivate - copyToEapSettings UseIdentityPrivacy: " |
|
1005 << varValue.toBool(); |
|
1006 } |
|
1007 |
|
1008 varValue = config.value(EapQtConfig::InnerType); |
|
1009 if (varValue.type() == QVariant::List) { |
|
1010 |
|
1011 // not need to set disable inner types |
|
1012 // EAP server takes care of them internally |
|
1013 |
|
1014 qDebug() << "EapQtConfigInterfacePrivate::copyToEapSettings() - InnerType present"; |
|
1015 |
|
1016 QList<QVariant> varList = varValue.toList(); |
|
1017 TEapExpandedType tmpEap; |
|
1018 EapQtPluginHandle tmpHandle; |
|
1019 |
|
1020 for (ind = 0; ind < varList.count(); ind++) { |
|
1021 if (varList[ind].canConvert<EapQtPluginHandle> ()) { |
|
1022 // set to true only if at least one item is ok |
|
1023 eapSettings.iEnabledEncapsulatedEAPExpandedTypesPresent = ETrue; |
|
1024 |
|
1025 tmpHandle = varList[ind].value<EapQtPluginHandle> (); |
|
1026 tmpEap.SetValue(tmpHandle.type().eapExpandedData().data(), |
|
1027 tmpHandle.type().eapExpandedData().length()); |
|
1028 eapSettings.iEnabledEncapsulatedEAPExpandedTypes.Append(tmpEap); |
|
1029 |
|
1030 qDebug() |
|
1031 << "EapQtConfigInterfacePrivate::copyToEapSettings() - Added to InnerType: " |
|
1032 << tmpHandle.type().eapExpandedData().toHex(); |
|
1033 } |
|
1034 } |
|
1035 } |
|
1036 |
|
1037 varValue = config.value(EapQtConfig::CipherSuites); |
|
1038 if (varValue.type() == QVariant::List) { |
|
1039 |
|
1040 qDebug() << "EapQtConfigInterfacePrivate::copyToEapSettings() - CipherSuites present"; |
|
1041 QList<QVariant> varCiphers = varValue.toList(); |
|
1042 |
|
1043 for (ind = 0; ind < varCiphers.count(); ind++) { |
|
1044 // check that the item is of correct type (int also accepted to not be too strict) |
|
1045 if (varCiphers[ind].type() == QVariant::UInt || varCiphers[ind].type() == QVariant::Int) { |
|
1046 // set to true only if at least item cipher is ok |
|
1047 eapSettings.iCipherSuitesPresent = ETrue; |
|
1048 eapSettings.iCipherSuites.Append(varCiphers[ind].toUInt()); |
|
1049 qDebug( |
|
1050 "EapQtConfigInterfacePrivate::copyToEapSettings() - CipherSuites at %d: 0x%08x", |
|
1051 ind, varCiphers[ind].toUInt()); |
|
1052 } |
|
1053 } |
|
1054 } |
|
1055 |
|
1056 varValue = config.value(EapQtConfig::AuthorityCertificate); |
|
1057 if (varValue.type() == QVariant::List) { |
|
1058 |
|
1059 qDebug() |
|
1060 << "EapQtConfigInterfacePrivate::copyToEapSettings() - AuthorityCertificate present"; |
|
1061 |
|
1062 QList<QVariant> varCerts = varValue.toList(); |
|
1063 for (ind = 0; ind < varCerts.count(); ind++) { |
|
1064 // check that the item is of correct type |
|
1065 if (varCerts[ind].canConvert<EapQtCertificateInfo> ()) { |
|
1066 // set to true only if at least one item is ok |
|
1067 eapSettings.iCertificatesPresent = ETrue; |
|
1068 appendCertificateInfo(true, varCerts[ind].value<EapQtCertificateInfo> (), |
|
1069 &(eapSettings.iCertificates)); |
|
1070 qDebug() |
|
1071 << "EapQtConfigInterfacePrivate::copyToEapSettings() - AuthorityCertificate appended"; |
|
1072 } |
|
1073 } |
|
1074 } |
|
1075 |
|
1076 varValue = config.value(EapQtConfig::UserCertificate); |
|
1077 if (varValue.type() == QVariant::List) { |
|
1078 |
|
1079 qDebug() << "EapQtConfigInterfacePrivate::copyToEapSettings() - UserCertificate present"; |
|
1080 |
|
1081 QList<QVariant> varCerts = varValue.toList(); |
|
1082 for (ind = 0; ind < varCerts.count(); ind++) { |
|
1083 // check that the item is of correct type |
|
1084 if (varCerts[ind].canConvert<EapQtCertificateInfo> ()) { |
|
1085 // set to true only if at least one item is ok |
|
1086 eapSettings.iCertificatesPresent = ETrue; |
|
1087 appendCertificateInfo(false, varCerts[ind].value<EapQtCertificateInfo> (), |
|
1088 &(eapSettings.iCertificates)); |
|
1089 qDebug() |
|
1090 << "EapQtConfigInterfacePrivate::copyToEapSettings() - AuthorityCertificate appended"; |
|
1091 } |
|
1092 } |
|
1093 } |
|
1094 |
|
1095 } |
|
1096 |
|
1097 // caller takes care of deallocating resulting data in certList |
|
1098 void EapQtConfigInterfacePrivate::appendCertificateInfo(bool isCaCertificate, |
|
1099 const EapQtCertificateInfo& certInfo, RPointerArray<EapCertificateEntry>* const certList) |
|
1100 { |
|
1101 qDebug("EapQtConfigInterfacePrivate::appendCertificateInfo(), this = 0x%08x", this); |
|
1102 |
|
1103 |
|
1104 Q_ASSERT(certList); |
|
1105 |
|
1106 // use scoped pointer to make sure memory is not leaked in failures |
|
1107 QScopedPointer<EapCertificateEntry> certEntry(new EapCertificateEntry); |
|
1108 |
|
1109 // set certificate enabled in EAP settings |
|
1110 certEntry->SetIsEnabledPresent(); |
|
1111 certEntry->SetIsEnabled(ETrue); |
|
1112 |
|
1113 if (isCaCertificate) { |
|
1114 qDebug("EapQtConfigInterfacePrivate::appendCertificateInfo() - CA certificate"); |
|
1115 certEntry->SetCertType(EapCertificateEntry::ECA); |
|
1116 } |
|
1117 else { |
|
1118 qDebug("EapQtConfigInterfacePrivate::appendCertificateInfo() - Client certificate"); |
|
1119 certEntry->SetCertType(EapCertificateEntry::EUser); |
|
1120 } |
|
1121 |
|
1122 qDebug("EapQtConfigInterfacePrivate::appendCertificateInfo() - *** Adding cert data"); |
|
1123 |
|
1124 TBuf<KGeneralStringMaxLength> certText; |
|
1125 |
|
1126 QVariant varValue = certInfo.value(EapQtCertificateInfo::SubjectName); |
|
1127 if (varValue.type() == QVariant::String && varValue.toString().count() <= StringMaxLength) { |
|
1128 certEntry->SetSubjectNamePresent(); |
|
1129 certText.Copy(varValue.toString().utf16()); |
|
1130 certEntry->SetSubjectName(certText); |
|
1131 |
|
1132 qDebug() << "EapQtConfigInterfacePrivate::appendCertificateInfo() - SubjectName: " |
|
1133 << varValue.toString(); |
|
1134 } |
|
1135 |
|
1136 varValue = certInfo.value(EapQtCertificateInfo::IssuerName); |
|
1137 if (varValue.type() == QVariant::String && varValue.toString().count() <= StringMaxLength) { |
|
1138 certEntry->SetIssuerNamePresent(); |
|
1139 certText.Copy(varValue.toString().utf16()); |
|
1140 certEntry->SetIssuerName(certText); |
|
1141 |
|
1142 qDebug() << "EapQtConfigInterfacePrivate::appendCertificateInfo() - IssuerName: " |
|
1143 << varValue.toString(); |
|
1144 } |
|
1145 |
|
1146 varValue = certInfo.value(EapQtCertificateInfo::SerialNumber); |
|
1147 if (varValue.type() == QVariant::String && varValue.toString().count() <= StringMaxLength) { |
|
1148 certEntry->SetSerialNumberPresent(); |
|
1149 certText.Copy(varValue.toString().utf16()); |
|
1150 certEntry->SetSerialNumber(certText); |
|
1151 |
|
1152 qDebug() << "EapQtConfigInterfacePrivate::appendCertificateInfo() - SerialNumber: " |
|
1153 << varValue.toString(); |
|
1154 } |
|
1155 |
|
1156 TCertLabel certLabel; |
|
1157 |
|
1158 varValue = certInfo.value(EapQtCertificateInfo::CertificateLabel); |
|
1159 if (varValue.type() == QVariant::String && varValue.toString().count() <= CertLabelMaxLength) { |
|
1160 certEntry->SetLabelPresent(); |
|
1161 certLabel.Copy(varValue.toString().utf16()); |
|
1162 certEntry->SetLabel(certLabel); |
|
1163 |
|
1164 qDebug() << "EapQtConfigInterfacePrivate::appendCertificateInfo() - CertificateLabel: " |
|
1165 << varValue.toString(); |
|
1166 } |
|
1167 |
|
1168 TBuf<KThumbprintMaxLength> thumbPrint; |
|
1169 |
|
1170 varValue = certInfo.value(EapQtCertificateInfo::ThumbPrint); |
|
1171 if (varValue.type() == QVariant::String && varValue.toString().count() |
|
1172 <= CertThumbprintMaxLength) { |
|
1173 certEntry->SetThumbprintPresent(); |
|
1174 thumbPrint.Copy(varValue.toString().utf16()); |
|
1175 certEntry->SetThumbprint(thumbPrint); |
|
1176 |
|
1177 qDebug() << "EapQtConfigInterfacePrivate::appendCertificateInfo() - ThumbPrint: " |
|
1178 << varValue.toString(); |
|
1179 } |
|
1180 |
|
1181 TKeyIdentifier keyId; |
|
1182 |
|
1183 varValue = certInfo.value(EapQtCertificateInfo::SubjectKeyId); |
|
1184 if (varValue.type() == QVariant::ByteArray && varValue.toByteArray().count() |
|
1185 <= CertSubjectKeyIdLength) { |
|
1186 certEntry->SetSubjectKeyIdPresent(); |
|
1187 keyId.Copy(reinterpret_cast<unsigned char*> (varValue.toByteArray().data()), |
|
1188 varValue.toByteArray().size()); |
|
1189 certEntry->SetSubjectKeyId(keyId); |
|
1190 |
|
1191 qDebug() << "EapQtConfigInterfacePrivate::appendCertificateInfo() - SubjectKeyId: " |
|
1192 << varValue.toByteArray().toHex(); |
|
1193 } |
|
1194 |
|
1195 // EapSettings destructor takes care of deallocating the entry |
|
1196 certList->Append(certEntry.data()); |
|
1197 |
|
1198 qDebug() |
|
1199 << "EapQtConfigInterfacePrivate::appendCertificateInfo()" |
|
1200 << "- *** certificate appended to list"; |
|
1201 |
|
1202 // all ok, remove the ownerhsip from scoped pointer |
|
1203 (void) certEntry.take(); |
|
1204 } |
|
1205 |
|
1206 void EapQtConfigInterfacePrivate::copyFromEapSettings(EAPSettings& eapSettings, EapQtConfig& config) |
|
1207 { |
|
1208 // TODO: |
|
1209 // - add validation? |
|
1210 // - check if there are something missing still defined in EaPSettings.h |
|
1211 // - pac store parameters from eapqtconfig.h |
|
1212 qDebug("EapQtConfigInterfacePrivate::copyFromEapSettings(), this = 0x%08x", this); |
|
1213 |
|
1214 |
|
1215 int ind = 0; |
|
1216 |
|
1217 // automatic username |
|
1218 if (eapSettings.iUseAutomaticUsernamePresent) { |
|
1219 config.setValue(EapQtConfig::UsernameAutomatic, convertToBool( |
|
1220 eapSettings.iUseAutomaticUsername)); |
|
1221 qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings UsernameAutomatic: " |
|
1222 << config.value(EapQtConfig::UsernameAutomatic).toBool(); |
|
1223 } |
|
1224 |
|
1225 // automatic CA certificate |
|
1226 if (eapSettings.iUseAutomaticCACertificatePresent) { |
|
1227 config.setValue(EapQtConfig::AuthorityCertificateAutomatic, convertToBool( |
|
1228 eapSettings.iUseAutomaticCACertificate)); |
|
1229 qDebug() |
|
1230 << "EapQtConfigInterfacePrivate - copyFromEapSettings AuthorityCertificateAutomatic: " |
|
1231 << config.value(EapQtConfig::AuthorityCertificateAutomatic).toBool(); |
|
1232 } |
|
1233 |
|
1234 // username |
|
1235 if (eapSettings.iUsernamePresent) { |
|
1236 config.setValue(EapQtConfig::Username, QString::fromUtf16(eapSettings.iUsername.Ptr(), |
|
1237 eapSettings.iUsername.Length())); |
|
1238 qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings Username: " << config.value( |
|
1239 EapQtConfig::Username).toString(); |
|
1240 } |
|
1241 |
|
1242 // password existence check, password itself is write-only, cannot be read |
|
1243 if (eapSettings.iPasswordExistPresent) { |
|
1244 // report to caller if password exists in the database |
|
1245 config.setValue(EapQtConfig::PasswordStored, convertToBool(eapSettings.iPasswordExist)); |
|
1246 |
|
1247 qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings PasswordStored: " |
|
1248 << config.value(EapQtConfig::PasswordStored).toBool(); |
|
1249 } |
|
1250 |
|
1251 // password prompt |
|
1252 if (eapSettings.iShowPassWordPromptPresent) { |
|
1253 config.setValue(EapQtConfig::PasswordPrompt, convertToBool(eapSettings.iShowPassWordPrompt)); |
|
1254 |
|
1255 qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings PasswordPrompt: " |
|
1256 << config.value(EapQtConfig::PasswordPrompt).toBool(); |
|
1257 } |
|
1258 |
|
1259 // automatic realm |
|
1260 if (eapSettings.iUseAutomaticRealmPresent) { |
|
1261 config.setValue(EapQtConfig::RealmAutomatic, convertToBool(eapSettings.iUseAutomaticRealm)); |
|
1262 qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings RealmAutomatic: " |
|
1263 << config.value(EapQtConfig::RealmAutomatic).toBool(); |
|
1264 } |
|
1265 |
|
1266 // realm |
|
1267 if (eapSettings.iRealmPresent) { |
|
1268 config.setValue(EapQtConfig::Realm, QString::fromUtf16(eapSettings.iRealm.Ptr(), |
|
1269 eapSettings.iRealm.Length())); |
|
1270 qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings Realm: " << config.value( |
|
1271 EapQtConfig::Realm).toString(); |
|
1272 } |
|
1273 |
|
1274 // server name |
|
1275 if (eapSettings.iVerifyServerRealmPresent) { |
|
1276 config.setValue(EapQtConfig::VerifyServerRealm, convertToBool( |
|
1277 eapSettings.iVerifyServerRealm)); |
|
1278 qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings VerifyServerRealm: " |
|
1279 << config.value(EapQtConfig::VerifyServerRealm).toBool(); |
|
1280 } |
|
1281 |
|
1282 // pseudonym |
|
1283 if (eapSettings.iUsePseudonymsPresent) { |
|
1284 config.setValue(EapQtConfig::UsePseudonyms, convertToBool(eapSettings.iUsePseudonyms)); |
|
1285 |
|
1286 qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings UsePseudonyms: " |
|
1287 << config.value(EapQtConfig::UsePseudonyms).toBool(); |
|
1288 } |
|
1289 |
|
1290 // policy: server must require client authentication |
|
1291 if (eapSettings.iRequireClientAuthenticationPresent) { |
|
1292 config.setValue(EapQtConfig::ClientAuthenticationRequired, convertToBool( |
|
1293 eapSettings.iRequireClientAuthentication)); |
|
1294 |
|
1295 qDebug() |
|
1296 << "EapQtConfigInterfacePrivate - copyFromEapSettings ClientAuthenticationRequired: " |
|
1297 << config.value(EapQtConfig::ClientAuthenticationRequired).toBool(); |
|
1298 } |
|
1299 |
|
1300 // session validity time |
|
1301 if (eapSettings.iSessionValidityTimePresent) { |
|
1302 config.setValue(EapQtConfig::SessionValidityTime, eapSettings.iSessionValidityTime); |
|
1303 |
|
1304 qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings SessionValidityTime: " |
|
1305 << config.value(EapQtConfig::SessionValidityTime).toUInt(); |
|
1306 } |
|
1307 |
|
1308 // TLS ciphersuites |
|
1309 if (eapSettings.iCipherSuitesPresent) { |
|
1310 QList<QVariant> ciphers; // QVariant has a constructor for uint |
|
1311 for (ind = 0; ind < eapSettings.iCipherSuites.Count(); ind++) { |
|
1312 ciphers.append(eapSettings.iCipherSuites[ind]); |
|
1313 qDebug("EapQtConfigInterfacePrivate - copyFromEapSettings CipherSuites at %d: 0x%08x", |
|
1314 ind, ciphers[ind].toUInt()); |
|
1315 } |
|
1316 config.setValue(EapQtConfig::CipherSuites, ciphers); |
|
1317 } |
|
1318 |
|
1319 // certificates |
|
1320 if (eapSettings.iCertificatesPresent) { |
|
1321 |
|
1322 QList<EapQtCertificateInfo> caCerts; |
|
1323 QList<EapQtCertificateInfo> clientCerts; |
|
1324 RPointerArray<EapCertificateEntry> serverCaCerts; |
|
1325 RPointerArray<EapCertificateEntry> serverClientCerts; |
|
1326 |
|
1327 // separate CA and client certs to their own lists |
|
1328 for (ind = 0; ind < eapSettings.iCertificates.Count(); ind++) { |
|
1329 |
|
1330 qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings certificates, " |
|
1331 << "cert type: " << eapSettings.iCertificates[ind]->GetCertType() << ", enabled: " |
|
1332 << convertToBool(eapSettings.iCertificates[ind]->GetIsEnabled()); |
|
1333 |
|
1334 // only enabled certificates are reported |
|
1335 if (eapSettings.iCertificates[ind]->GetCertType() == EapCertificateEntry::EUser |
|
1336 && eapSettings.iCertificates[ind]->GetIsEnabled() != EFalse) { |
|
1337 serverClientCerts.Append(eapSettings.iCertificates[ind]); |
|
1338 } |
|
1339 // only enabled certificates are reported |
|
1340 else if (eapSettings.iCertificates[ind]->GetCertType() == EapCertificateEntry::ECA |
|
1341 && eapSettings.iCertificates[ind]->GetIsEnabled() != EFalse) { |
|
1342 serverCaCerts.Append(eapSettings.iCertificates[ind]); |
|
1343 } |
|
1344 else { |
|
1345 qDebug() |
|
1346 << "WARNING: EapQtConfigInterfacePrivate - copyFromEapSettings certificates, " |
|
1347 << "unknown certificate type in the list or certificate not enabled"; |
|
1348 } |
|
1349 } |
|
1350 |
|
1351 // copy to lists of our type |
|
1352 qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings AuthorityCertificates"; |
|
1353 copyCertificateInfo(&serverCaCerts, &caCerts); |
|
1354 qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings UserCertificates"; |
|
1355 copyCertificateInfo(&serverClientCerts, &clientCerts); |
|
1356 |
|
1357 // reset the arrays, data is owned by EapSettings.h, |
|
1358 // must not be destroyed here |
|
1359 serverCaCerts.Reset(); |
|
1360 serverClientCerts.Reset(); |
|
1361 |
|
1362 // we still need to convert QList<EapQtCertificateInfo> to QList<QVariant> |
|
1363 // to be able to store to config |
|
1364 QVariant tmp; |
|
1365 QList<QVariant> varCaCerts; |
|
1366 QList<QVariant> varClientCerts; |
|
1367 |
|
1368 for (ind = 0; ind < caCerts.count(); ind++) { |
|
1369 tmp.setValue(caCerts[ind]); |
|
1370 varCaCerts.append(tmp); |
|
1371 } |
|
1372 for (ind = 0; ind < clientCerts.count(); ind++) { |
|
1373 tmp.setValue(clientCerts[ind]); |
|
1374 varClientCerts.append(tmp); |
|
1375 } |
|
1376 |
|
1377 // finally copy to config |
|
1378 config.setValue(EapQtConfig::AuthorityCertificate, varCaCerts); |
|
1379 config.setValue(EapQtConfig::UserCertificate, varClientCerts); |
|
1380 } |
|
1381 |
|
1382 // PEAP specific |
|
1383 if (eapSettings.iPEAPVersionsPresent) { |
|
1384 config.setValue(EapQtConfig::PeapVersion0Allowed, convertToBool(eapSettings.iPEAPv0Allowed)); |
|
1385 config.setValue(EapQtConfig::PeapVersion1Allowed, convertToBool(eapSettings.iPEAPv1Allowed)); |
|
1386 config.setValue(EapQtConfig::PeapVersion2Allowed, convertToBool(eapSettings.iPEAPv2Allowed)); |
|
1387 |
|
1388 qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings PeapVersion0Allowed: " |
|
1389 << config.value(EapQtConfig::PeapVersion0Allowed).toBool(); |
|
1390 qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings PeapVersion1Allowed: " |
|
1391 << config.value(EapQtConfig::PeapVersion1Allowed).toBool(); |
|
1392 qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings PeapVersion2Allowed: " |
|
1393 << config.value(EapQtConfig::PeapVersion2Allowed).toBool(); |
|
1394 } |
|
1395 |
|
1396 // TLS privacy |
|
1397 if (eapSettings.iUseIdentityPrivacyPresent) { |
|
1398 config.setValue(EapQtConfig::UseIdentityPrivacy, convertToBool( |
|
1399 eapSettings.iUseIdentityPrivacy)); |
|
1400 |
|
1401 qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings UseIdentityPrivacy: " |
|
1402 << config.value(EapQtConfig::UseIdentityPrivacy).toBool(); |
|
1403 } |
|
1404 |
|
1405 // EAP-FAST specific |
|
1406 if (eapSettings.iAuthProvModeAllowedPresent) { |
|
1407 config.setValue(EapQtConfig::ProvisioningModeAuthenticated, convertToBool( |
|
1408 eapSettings.iAuthProvModeAllowed)); |
|
1409 |
|
1410 qDebug() |
|
1411 << "EapQtConfigInterfacePrivate - copyFromEapSettings ProvisioningModeAuthenticated: " |
|
1412 << config.value(EapQtConfig::ProvisioningModeAuthenticated).toBool(); |
|
1413 } |
|
1414 if (eapSettings.iUnauthProvModeAllowedPresent) { |
|
1415 config.setValue(EapQtConfig::ProvisioningModeUnauthenticated, convertToBool( |
|
1416 eapSettings.iUnauthProvModeAllowed)); |
|
1417 |
|
1418 qDebug() |
|
1419 << "EapQtConfigInterfacePrivate - copyFromEapSettings ProvisioningModeUnauthenticated: " |
|
1420 << config.value(EapQtConfig::ProvisioningModeUnauthenticated).toBool(); |
|
1421 } |
|
1422 if (eapSettings.iWarnADHPNoPACPresent) { |
|
1423 config.setValue(EapQtConfig::WarnADHPNoPAC, convertToBool(eapSettings.iWarnADHPNoPAC)); |
|
1424 |
|
1425 qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings WarnADHPNoPAC: " |
|
1426 << config.value(EapQtConfig::WarnADHPNoPAC).toBool(); |
|
1427 } |
|
1428 if (eapSettings.iWarnADHPNoMatchingPACPresent) { |
|
1429 config.setValue(EapQtConfig::WarnADHPNoMatchingPAC, convertToBool( |
|
1430 eapSettings.iWarnADHPNoMatchingPAC)); |
|
1431 |
|
1432 qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings WarnADHPNoMatchingPAC: " |
|
1433 << config.value(EapQtConfig::WarnADHPNoMatchingPAC).toBool(); |
|
1434 } |
|
1435 if (eapSettings.iWarnNotDefaultServerPresent) { |
|
1436 config.setValue(EapQtConfig::WarnNotDefaultServer, convertToBool( |
|
1437 eapSettings.iWarnNotDefaultServer)); |
|
1438 |
|
1439 qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings WarnNotDefaultServer: " |
|
1440 << config.value(EapQtConfig::WarnNotDefaultServer).toBool(); |
|
1441 } |
|
1442 if (eapSettings.iPACGroupReferencePresent) { |
|
1443 config.setValue(EapQtConfig::PACGroupReference, QString::fromUtf16( |
|
1444 eapSettings.iPACGroupReference.Ptr(), eapSettings.iPACGroupReference.Length())); |
|
1445 qDebug() << "EapQtConfigInterfacePrivate - copyFromEapSettings PACGroupReference: " |
|
1446 << config.value(EapQtConfig::PACGroupReference).toString(); |
|
1447 } |
|
1448 |
|
1449 // enabled inner EAPs |
|
1450 if (eapSettings.iEnabledEncapsulatedEAPExpandedTypesPresent) { |
|
1451 |
|
1452 qDebug("EapQtConfigInterfacePrivate - copyFromEapSettings InnerType, enabled count %d", |
|
1453 eapSettings.iEnabledEncapsulatedEAPExpandedTypes.Count()); |
|
1454 |
|
1455 QList<QByteArray> innerEapsOn; |
|
1456 appendEapTypes(&(eapSettings.iEnabledEncapsulatedEAPExpandedTypes), &innerEapsOn); |
|
1457 |
|
1458 // convert to QList<QVariant> to be able to store to config |
|
1459 QVariant varTmp; |
|
1460 QList<QVariant> varInnerEapsOn; |
|
1461 int dummy = 0; |
|
1462 |
|
1463 for (ind = 0; ind < innerEapsOn.count(); ind++) { |
|
1464 // report only EAPs which do have an UI plugin |
|
1465 if (isUiSupported(innerEapsOn[ind], dummy)) { |
|
1466 // create plugin handle from EAP type with constructors |
|
1467 // calls: EapQtExpandedEapType(const QByteArray data) -> EapQtPluginHandle(EapQtExpandedEapType type) |
|
1468 varTmp.setValue(EapQtPluginHandle(EapQtExpandedEapType(innerEapsOn[ind]))); |
|
1469 varInnerEapsOn.append(varTmp); |
|
1470 qDebug() |
|
1471 << "EapQtConfigInterfacePrivate - copyFromEapSettings InnerType: added EAP: " |
|
1472 << innerEapsOn[ind].toHex(); |
|
1473 } |
|
1474 } |
|
1475 |
|
1476 // copy to config |
|
1477 config.setValue(EapQtConfig::InnerType, varInnerEapsOn); |
|
1478 } |
|
1479 |
|
1480 // disabled inner EAPs |
|
1481 if (eapSettings.iDisabledEncapsulatedEAPExpandedTypesPresent) { |
|
1482 // setting is not needed, enabled are enough |
|
1483 qDebug( |
|
1484 "EapQtConfigInterfacePrivate - copyFromEapSettings InnerType: disabled count %d (not needed for anything here)", |
|
1485 eapSettings.iDisabledEncapsulatedEAPExpandedTypes.Count()); |
|
1486 } |
|
1487 |
|
1488 } |
|
1489 |
|
1490 QList<EapQtPluginHandle> EapQtConfigInterfacePrivate::selectedOuterTypes() |
|
1491 { |
|
1492 qDebug("EapQtConfigInterfacePrivate::selectedOuterTypes(), this = 0x%08x", this); |
|
1493 |
|
1494 |
|
1495 checkInstanceThrowing(); |
|
1496 |
|
1497 if (!mEapDbIndexValid) { |
|
1498 qDebug() << "ERROR: Database reference not valid, call setConfigurationReference first!"; |
|
1499 return QList<EapQtPluginHandle> (); |
|
1500 } |
|
1501 |
|
1502 // call to make sure the members (mOuterEapsOn and mSupportedOuterTypes) are up-to-date |
|
1503 (void) supportedOuterTypes(); |
|
1504 |
|
1505 QList<EapQtPluginHandle> selectedOuterTypes; |
|
1506 |
|
1507 QList<QByteArray> tmpEaps; |
|
1508 appendEapTypes(&mOuterEapsOn, &tmpEaps); |
|
1509 |
|
1510 // report only the ones that also have an UI, i.e. listed in mSupportedOuterTypes |
|
1511 for (int ind = 0; ind < mSupportedOuterTypes.count(); ind++) { |
|
1512 if (tmpEaps.contains(mSupportedOuterTypes[ind].pluginHandle().type().eapExpandedData())) { |
|
1513 selectedOuterTypes.append(mSupportedOuterTypes[ind].pluginHandle()); |
|
1514 } |
|
1515 } |
|
1516 |
|
1517 qDebug("EapQtConfigInterfacePrivate - selected outer type count: %d", |
|
1518 selectedOuterTypes.count()); |
|
1519 |
|
1520 return selectedOuterTypes; |
|
1521 } |
|
1522 |
|
1523 bool EapQtConfigInterfacePrivate::isSupportedOuterType(const EapQtPluginHandle& handle) |
|
1524 { |
|
1525 qDebug("EapQtConfigInterfacePrivate::isSupportedOuterType(), this = 0x%08x", this); |
|
1526 |
|
1527 |
|
1528 checkInstanceThrowing(); |
|
1529 |
|
1530 // check if mSupportedOuterTypes is up-to-date |
|
1531 if (mSupportedOuterTypes.count() <= 0) { |
|
1532 // update mSupportedOuterTypes |
|
1533 (void) supportedOuterTypes(); |
|
1534 } |
|
1535 |
|
1536 bool ret = false; |
|
1537 for (int ind = 0; ind < mSupportedOuterTypes.count(); ind++) { |
|
1538 if (mSupportedOuterTypes[ind].pluginHandle() == handle) { |
|
1539 ret = true; |
|
1540 } |
|
1541 } |
|
1542 return ret; |
|
1543 } |
|
1544 |
|
1545 bool EapQtConfigInterfacePrivate::setSelectedOuterTypes( |
|
1546 const QList<EapQtPluginHandle>& outerHandles) |
|
1547 { |
|
1548 qDebug("EapQtConfigInterfacePrivate::setSelectedOuterTypes()"); |
|
1549 |
|
1550 |
|
1551 checkInstanceThrowing(); |
|
1552 |
|
1553 if (!mEapDbIndexValid || mEapGsIf.isNull()) { |
|
1554 qDebug() |
|
1555 << "ERROR: Database reference not valid (or mEapGsIf is NULL), call setConfigurationReference first!"; |
|
1556 return false; |
|
1557 } |
|
1558 |
|
1559 // check if mSupportedOuterTypes is up-to-date |
|
1560 if (mSupportedOuterTypes.count() <= 0) { |
|
1561 // update mSupportedOuterTypes |
|
1562 (void) supportedOuterTypes(); |
|
1563 } |
|
1564 |
|
1565 // clear arrays |
|
1566 mOuterEapsOn.Reset(); |
|
1567 mOuterEapsOff.Reset(); |
|
1568 |
|
1569 // pick only the supported ones from outerHandles |
|
1570 TEapExpandedType tmpEap; |
|
1571 for (int ind = 0; ind < mSupportedOuterTypes.count(); ind++) { |
|
1572 if (outerHandles.contains(mSupportedOuterTypes[ind].pluginHandle())) { |
|
1573 |
|
1574 // convert to TEapExpandedType |
|
1575 tmpEap.SetValue( |
|
1576 mSupportedOuterTypes[ind].pluginHandle().type().eapExpandedData().data(), |
|
1577 mSupportedOuterTypes[ind].pluginHandle().type().eapExpandedData().length()); |
|
1578 |
|
1579 // add to mOuterEapsOn |
|
1580 mOuterEapsOn.Append(tmpEap); |
|
1581 |
|
1582 qDebug() |
|
1583 << "EapQtConfigInterfacePrivate - setSelectedOuterTypes adding to enabledOuterHandles: " |
|
1584 << mSupportedOuterTypes[ind].pluginHandle().type().eapExpandedData().toHex(); |
|
1585 } |
|
1586 } |
|
1587 |
|
1588 bool ret = true; |
|
1589 |
|
1590 // set selection to EAP server, no need to have correct content in mOuterEapsOff, |
|
1591 // EAP server handles it, mOuterEapsOn is only important |
|
1592 TUint err = mEapGsIf->SetEapMethods(mOuterEapsOn, mOuterEapsOff); |
|
1593 if (err != KErrNone) { |
|
1594 qDebug("EapQtConfigInterfacePrivate::setSelectedOuterTypes() - SetEapMethods failed: %d", |
|
1595 err); |
|
1596 // nothing we can do to recover, just exit |
|
1597 ret = false; |
|
1598 } |
|
1599 return ret; |
|
1600 } |
|
1601 |
|
1602 bool EapQtConfigInterfacePrivate::isSupportedInnerType(const EapQtPluginHandle& outerHandle, |
|
1603 const EapQtPluginHandle& innerHandle) |
|
1604 { |
|
1605 qDebug("EapQtConfigInterfacePrivate::isSupportedInnerType(), this = 0x%08x", this); |
|
1606 |
|
1607 |
|
1608 checkInstanceThrowing(); |
|
1609 |
|
1610 // update mSupportedInnerTypes |
|
1611 (void) supportedInnerTypes(outerHandle); |
|
1612 |
|
1613 for (int ind = 0; ind < mSupportedInnerTypes.count(); ind++) { |
|
1614 if (mSupportedInnerTypes[ind].pluginHandle() == innerHandle) { |
|
1615 return true; |
|
1616 } |
|
1617 } |
|
1618 return false; |
|
1619 } |
|
1620 |
|
1621 bool EapQtConfigInterfacePrivate::deleteConfiguration() |
|
1622 { |
|
1623 qDebug("EapQtConfigInterfacePrivate::deleteConfiguration(), this = 0x%08x", this); |
|
1624 |
|
1625 |
|
1626 checkInstanceThrowing(); |
|
1627 |
|
1628 if (!mEapDbIndexValid || mEapGsIf.isNull()) { |
|
1629 qDebug() |
|
1630 << "ERROR: Database reference not valid (or mEapGsIf is NULL), call setConfigurationReference first!"; |
|
1631 return false; |
|
1632 } |
|
1633 |
|
1634 bool ret = true; |
|
1635 TInt err = mEapGsIf->DeleteAllEapSettings(); |
|
1636 if (err != KErrNone) { |
|
1637 ret = false; |
|
1638 } |
|
1639 return ret; |
|
1640 } |
|
1641 |
|
1642 void EapQtConfigInterfacePrivate::loadPlugins() |
|
1643 { |
|
1644 qDebug("EapQtConfigInterfacePrivate::loadPlugins(), this = 0x%08x", this); |
|
1645 |
|
1646 checkInstanceThrowing(); |
|
1647 |
|
1648 QDir pluginsDir(eapPluginDir); |
|
1649 foreach( QString fileName, pluginsDir.entryList(QDir::Files) ) |
|
1650 { |
|
1651 QPluginLoader loader(pluginsDir.absoluteFilePath(fileName)); |
|
1652 QObject *tmp = loader.instance(); |
|
1653 if (tmp) { |
|
1654 CpEapPluginInterface *plugin = qobject_cast<CpEapPluginInterface*> (tmp); |
|
1655 if (plugin) { |
|
1656 mPlugins.append(plugin); |
|
1657 } |
|
1658 } |
|
1659 } |
|
1660 |
|
1661 // collect UI plugin infos |
|
1662 QList<CpEapPluginInterface*>::iterator iter; |
|
1663 for (iter = mPlugins.begin(); iter != mPlugins.end(); ++iter) { |
|
1664 mPluginInfos.append((*iter)->pluginInfo()); |
|
1665 } |
|
1666 } |
|
1667 |
|
1668 CpBaseSettingView *EapQtConfigInterfacePrivate::uiInstance(const EapQtPluginHandle& outerHandle, |
|
1669 const EapQtPluginHandle& pluginHandle) |
|
1670 { |
|
1671 qDebug("EapQtConfigInterfacePrivate::uiInstance(), this = 0x%08x", this); |
|
1672 |
|
1673 |
|
1674 checkInstanceThrowing(); |
|
1675 |
|
1676 // if outer type UI is requested, outerHandle must be undefined and pluginHandle |
|
1677 // must be supported as outer type |
|
1678 if (outerHandle == EapQtPluginHandle::PluginUndefined) { |
|
1679 if (!isSupportedOuterType(pluginHandle)) { |
|
1680 qDebug() << "ERROR: EapQtConfigInterfacePrivate::uiInstance() -" |
|
1681 << "plugin not supported as outer type"; |
|
1682 return NULL; |
|
1683 } |
|
1684 } |
|
1685 else { |
|
1686 // outerHandle defined, pluginHandle must be supported inside outerHandle |
|
1687 if (!isSupportedInnerType(outerHandle, pluginHandle)) { |
|
1688 qDebug() << "ERROR: EapQtConfigInterfacePrivate::uiInstance() -" |
|
1689 << "plugin not supported as the inner type of the specified outer type"; |
|
1690 return NULL; |
|
1691 } |
|
1692 } |
|
1693 |
|
1694 if (mTranslator.isNull()) { |
|
1695 // install translations for EAP UI plugins |
|
1696 mTranslator.reset(new HbTranslator(eapTranslationFile)); |
|
1697 } |
|
1698 |
|
1699 // go through all interfaces (dlls) |
|
1700 QList<CpEapPluginInterface*>::iterator iter; |
|
1701 for (iter = mPlugins.begin(); iter != mPlugins.end(); ++iter) { |
|
1702 QList<EapQtPluginInfo> plugins; |
|
1703 plugins.append((*iter)->pluginInfo()); |
|
1704 |
|
1705 // go through all plugings inside the interface implementation |
|
1706 QList<EapQtPluginInfo>::iterator j; |
|
1707 for (j = plugins.begin(); j != plugins.end(); ++j) { |
|
1708 if ((*j).pluginHandle() == pluginHandle) { |
|
1709 qDebug("EapQtConfigInterfacePrivate::uiInstance() - found plugin"); |
|
1710 // indicate configured IAP to plugin |
|
1711 (*iter)->setSettingsReference(getEapBearer(), mIapId); |
|
1712 return (*iter)->uiInstance(outerHandle, *j); |
|
1713 } |
|
1714 } |
|
1715 |
|
1716 } |
|
1717 qDebug("ERROR: EapQtConfigInterfacePrivate::uiInstance() - plugin not found"); |
|
1718 return NULL; |
|
1719 } |
|
1720 |
|
1721 EapQtConfigInterface::EapBearerType EapQtConfigInterfacePrivate::getEapBearer() |
|
1722 { |
|
1723 EapQtConfigInterface::EapBearerType ret(EapQtConfigInterface::EapBearerTypeWlan); |
|
1724 |
|
1725 switch (mEapBearer) { |
|
1726 case EVpn: |
|
1727 ret = EapQtConfigInterface::EapBearerTypeVpn; |
|
1728 break; |
|
1729 default: |
|
1730 ret = EapQtConfigInterface::EapBearerTypeWlan; |
|
1731 break; |
|
1732 } |
|
1733 return ret; |
|
1734 } |
|
1735 |
|
1736 EapQtValidator *EapQtConfigInterfacePrivate::validatorEap(EapQtExpandedEapType type, |
|
1737 EapQtConfig::SettingsId id) |
|
1738 { |
|
1739 qDebug("EapQtConfigInterfacePrivate::validatorEap(), this = 0x%08x", this); |
|
1740 |
|
1741 |
|
1742 EapQtValidator *ret = NULL; |
|
1743 |
|
1744 switch (id) { |
|
1745 |
|
1746 case EapQtConfig::Username: |
|
1747 switch (type.type()) { |
|
1748 case EapQtExpandedEapType::TypeEapAka: |
|
1749 case EapQtExpandedEapType::TypeEapFast: |
|
1750 case EapQtExpandedEapType::TypeEapGtc: |
|
1751 case EapQtExpandedEapType::TypeLeap: |
|
1752 case EapQtExpandedEapType::TypeEapMschapv2: |
|
1753 case EapQtExpandedEapType::TypePeap: |
|
1754 case EapQtExpandedEapType::TypeEapSim: |
|
1755 case EapQtExpandedEapType::TypeEapTls: |
|
1756 case EapQtExpandedEapType::TypeEapTtls: |
|
1757 case EapQtExpandedEapType::TypePap: |
|
1758 case EapQtExpandedEapType::TypePlainMschapv2: |
|
1759 ret = new EapQtValidatorUsername(type); |
|
1760 break; |
|
1761 default: |
|
1762 ret = NULL; |
|
1763 } |
|
1764 break; |
|
1765 |
|
1766 case EapQtConfig::Password: |
|
1767 switch (type.type()) { |
|
1768 case EapQtExpandedEapType::TypeEapGtc: |
|
1769 case EapQtExpandedEapType::TypeLeap: |
|
1770 case EapQtExpandedEapType::TypeEapMschapv2: |
|
1771 case EapQtExpandedEapType::TypePap: |
|
1772 case EapQtExpandedEapType::TypePlainMschapv2: |
|
1773 ret = new EapQtValidatorPassword(type); |
|
1774 break; |
|
1775 default: |
|
1776 ret = NULL; |
|
1777 } |
|
1778 break; |
|
1779 |
|
1780 case EapQtConfig::Realm: |
|
1781 switch (type.type()) { |
|
1782 case EapQtExpandedEapType::TypeEapAka: |
|
1783 case EapQtExpandedEapType::TypeEapFast: |
|
1784 case EapQtExpandedEapType::TypePeap: |
|
1785 case EapQtExpandedEapType::TypeEapSim: |
|
1786 case EapQtExpandedEapType::TypeEapTls: |
|
1787 case EapQtExpandedEapType::TypeEapTtls: |
|
1788 ret = new EapQtValidatorRealm(type); |
|
1789 break; |
|
1790 default: |
|
1791 ret = NULL; |
|
1792 } |
|
1793 break; |
|
1794 |
|
1795 default: |
|
1796 ret = NULL; |
|
1797 |
|
1798 } |
|
1799 |
|
1800 return ret; |
|
1801 } |