34
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
* EAP-FAST PAC store password correctness validator
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
/*
|
49
|
20 |
* %version: 7 %
|
34
|
21 |
*/
|
|
22 |
|
|
23 |
// System includes
|
|
24 |
#include <HbEditorInterface>
|
|
25 |
#include <HbLineEdit>
|
49
|
26 |
#include <QDebug>
|
34
|
27 |
|
|
28 |
// User includes
|
|
29 |
#include "eapqtvalidatorpacstorepasswordconfirm.h"
|
|
30 |
#include "eapqtconfiginterface_p.h"
|
49
|
31 |
#include "EapFastPacStore.h"
|
34
|
32 |
|
|
33 |
/*!
|
|
34 |
* \class EapQtValidatorPacStorePasswordConfirm
|
|
35 |
* \brief EAP-FAST PAC store password correctness validator, checks if the
|
|
36 |
* supplied password can be used for opening the existing PAC store
|
|
37 |
*/
|
|
38 |
|
|
39 |
// External function prototypes
|
|
40 |
|
|
41 |
// Local constants
|
|
42 |
|
|
43 |
// ======== LOCAL FUNCTIONS ========
|
|
44 |
|
|
45 |
// ======== MEMBER FUNCTIONS ========
|
|
46 |
|
49
|
47 |
EapQtValidatorPacStorePasswordConfirm::EapQtValidatorPacStorePasswordConfirm() :
|
|
48 |
mPacStoreIf(NULL)
|
34
|
49 |
{
|
49
|
50 |
qDebug("EapQtValidatorPacStorePasswordConfirm() - starts");
|
|
51 |
|
|
52 |
// try to create PAC store instance,
|
|
53 |
// this will throw if EAP-FAST is not supported
|
|
54 |
CEapFastPacStore* tmpPacStoreIf = NULL;
|
|
55 |
QT_TRAP_THROWING(tmpPacStoreIf = CEapFastPacStore::NewL());
|
|
56 |
|
|
57 |
Q_ASSERT(tmpPacStoreIf);
|
|
58 |
|
|
59 |
// move the result to scoped member pointer
|
|
60 |
mPacStoreIf.reset(tmpPacStoreIf);
|
|
61 |
|
|
62 |
qDebug("EapQtValidatorPacStorePasswordConfirm() - ends");
|
34
|
63 |
}
|
|
64 |
|
|
65 |
EapQtValidatorPacStorePasswordConfirm::~EapQtValidatorPacStorePasswordConfirm()
|
|
66 |
{
|
49
|
67 |
qDebug("~EapQtValidatorPacStorePasswordConfirm()");
|
|
68 |
// mPacStoreIf deleted automatically
|
34
|
69 |
}
|
|
70 |
|
49
|
71 |
EapQtValidator::Status EapQtValidatorPacStorePasswordConfirm::validate(const QVariant& value)
|
34
|
72 |
{
|
|
73 |
qDebug("EapQtValidatorPacStorePasswordConfirm::validate()");
|
49
|
74 |
|
|
75 |
Status status(StatusOk);
|
|
76 |
const QString str = value.toString();
|
|
77 |
|
|
78 |
// input must be of correct type
|
|
79 |
if (value.type() != QVariant::String) {
|
|
80 |
status = StatusInvalid;
|
|
81 |
}
|
|
82 |
else if (str.length() > EapQtConfigInterfacePrivate::PacPasswordMaxLength) {
|
|
83 |
status = StatusTooLong;
|
|
84 |
}
|
|
85 |
else {
|
|
86 |
TBool match(EFalse);
|
|
87 |
// TBufC8 must be twice as long as QString
|
|
88 |
TBufC8<EapQtConfigInterfacePrivate::StringMaxLength> tmpPassword;
|
|
89 |
QByteArray tmp = str.toUtf8();
|
|
90 |
|
|
91 |
// Convert to suitable format
|
|
92 |
tmpPassword.Des().Copy(reinterpret_cast<const TUint8*> (tmp.data()), tmp.count());
|
|
93 |
|
|
94 |
// check if given password can be used to open the PAC store,
|
|
95 |
// this will fail in all other cases except if PAC store exists
|
|
96 |
// and the password can open it
|
|
97 |
TRAPD(err, match = mPacStoreIf->IsMasterKeyAndPasswordMatchingL(tmpPassword));
|
|
98 |
|
|
99 |
qDebug() << "EapQtValidatorPacStorePasswordConfirm::validate() -"
|
|
100 |
<< "IsMasterKeyAndPasswordMatchingL trap returned:" << err;
|
|
101 |
|
|
102 |
if (err == KErrNone && match != EFalse) {
|
|
103 |
qDebug() << "EapQtValidatorPacStorePasswordConfirm::validate() - password matches";
|
|
104 |
status = StatusOk;
|
|
105 |
}
|
|
106 |
else {
|
|
107 |
qDebug()
|
|
108 |
<< "EapQtValidatorPacStorePasswordConfirm::validate() - password does not match";
|
|
109 |
status = StatusInvalid;
|
|
110 |
}
|
|
111 |
}
|
|
112 |
|
|
113 |
qDebug("EapQtValidatorPacStorePasswordConfirm::validate - return status: %d", status);
|
|
114 |
return status;
|
34
|
115 |
}
|
|
116 |
|
|
117 |
void EapQtValidatorPacStorePasswordConfirm::updateEditor(HbLineEdit* const edit)
|
|
118 |
{
|
|
119 |
qDebug("EapQtValidatorPacStorePasswordConfirm::updateEditor()");
|
|
120 |
|
|
121 |
Q_ASSERT(edit);
|
|
122 |
|
49
|
123 |
edit->setMaxLength(EapQtConfigInterfacePrivate::PacPasswordMaxLength);
|
34
|
124 |
edit->setInputMethodHints(Qt::ImhNoAutoUppercase | Qt::ImhPreferLowercase
|
|
125 |
| Qt::ImhNoPredictiveText);
|
|
126 |
|
|
127 |
// do not set editor class or auto completing since they might leak the pwd
|
|
128 |
HbEditorInterface editInterface(edit);
|
|
129 |
editInterface.setSmileyTheme(HbSmileyTheme());
|
|
130 |
}
|