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