15 * EAP-FAST PAC store password correctness validator |
15 * EAP-FAST PAC store password correctness validator |
16 * |
16 * |
17 */ |
17 */ |
18 |
18 |
19 /* |
19 /* |
20 * %version: 5 % |
20 * %version: 7 % |
21 */ |
21 */ |
22 |
22 |
23 // System includes |
23 // System includes |
24 #include <HbEditorInterface> |
24 #include <HbEditorInterface> |
25 #include <HbLineEdit> |
25 #include <HbLineEdit> |
|
26 #include <QDebug> |
26 |
27 |
27 // User includes |
28 // User includes |
28 #include "eapqtvalidatorpacstorepasswordconfirm.h" |
29 #include "eapqtvalidatorpacstorepasswordconfirm.h" |
29 #include "eapqtconfiginterface_p.h" |
30 #include "eapqtconfiginterface_p.h" |
|
31 #include "EapFastPacStore.h" |
30 |
32 |
31 /*! |
33 /*! |
32 * \class EapQtValidatorPacStorePasswordConfirm |
34 * \class EapQtValidatorPacStorePasswordConfirm |
33 * \brief EAP-FAST PAC store password correctness validator, checks if the |
35 * \brief EAP-FAST PAC store password correctness validator, checks if the |
34 * supplied password can be used for opening the existing PAC store |
36 * supplied password can be used for opening the existing PAC store |
40 |
42 |
41 // ======== LOCAL FUNCTIONS ======== |
43 // ======== LOCAL FUNCTIONS ======== |
42 |
44 |
43 // ======== MEMBER FUNCTIONS ======== |
45 // ======== MEMBER FUNCTIONS ======== |
44 |
46 |
45 EapQtValidatorPacStorePasswordConfirm::EapQtValidatorPacStorePasswordConfirm() |
47 EapQtValidatorPacStorePasswordConfirm::EapQtValidatorPacStorePasswordConfirm() : |
|
48 mPacStoreIf(NULL) |
46 { |
49 { |
47 // nothing to do |
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"); |
48 } |
63 } |
49 |
64 |
50 EapQtValidatorPacStorePasswordConfirm::~EapQtValidatorPacStorePasswordConfirm() |
65 EapQtValidatorPacStorePasswordConfirm::~EapQtValidatorPacStorePasswordConfirm() |
51 { |
66 { |
52 // nothing to do |
67 qDebug("~EapQtValidatorPacStorePasswordConfirm()"); |
|
68 // mPacStoreIf deleted automatically |
53 } |
69 } |
54 |
70 |
55 EapQtValidator::Status EapQtValidatorPacStorePasswordConfirm::validate(const QVariant& /* value */) |
71 EapQtValidator::Status EapQtValidatorPacStorePasswordConfirm::validate(const QVariant& value) |
56 { |
72 { |
57 qDebug("EapQtValidatorPacStorePasswordConfirm::validate()"); |
73 qDebug("EapQtValidatorPacStorePasswordConfirm::validate()"); |
58 // not supported |
74 |
59 return EapQtValidator::StatusInvalid; |
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; |
60 } |
115 } |
61 |
116 |
62 void EapQtValidatorPacStorePasswordConfirm::updateEditor(HbLineEdit* const edit) |
117 void EapQtValidatorPacStorePasswordConfirm::updateEditor(HbLineEdit* const edit) |
63 { |
118 { |
64 qDebug("EapQtValidatorPacStorePasswordConfirm::updateEditor()"); |
119 qDebug("EapQtValidatorPacStorePasswordConfirm::updateEditor()"); |
65 |
120 |
66 Q_ASSERT(edit); |
121 Q_ASSERT(edit); |
67 |
122 |
68 edit->setMaxLength(EapQtConfigInterfacePrivate::StringMaxLength); |
123 edit->setMaxLength(EapQtConfigInterfacePrivate::PacPasswordMaxLength); |
69 edit->setInputMethodHints(Qt::ImhNoAutoUppercase | Qt::ImhPreferLowercase |
124 edit->setInputMethodHints(Qt::ImhNoAutoUppercase | Qt::ImhPreferLowercase |
70 | Qt::ImhNoPredictiveText); |
125 | Qt::ImhNoPredictiveText); |
71 |
126 |
72 // do not set editor class or auto completing since they might leak the pwd |
127 // do not set editor class or auto completing since they might leak the pwd |
73 HbEditorInterface editInterface(edit); |
128 HbEditorInterface editInterface(edit); |