46
|
1 |
/*
|
|
2 |
* Copyright (c) 2001-2006 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: EAP and WLAN authentication protocols.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
/*
|
|
19 |
* %version: 12.1.2.1.2 %
|
|
20 |
*/
|
|
21 |
|
|
22 |
// This is enumeration of EAPOL source code.
|
|
23 |
#if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
|
|
24 |
#undef EAP_FILE_NUMBER_ENUM
|
|
25 |
#define EAP_FILE_NUMBER_ENUM 300
|
|
26 |
#undef EAP_FILE_NUMBER_DATE
|
|
27 |
#define EAP_FILE_NUMBER_DATE 1127594498
|
|
28 |
#endif //#if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
|
|
29 |
|
|
30 |
#include <e32base.h>
|
|
31 |
#include "EapMsChapV2DbUtils.h"
|
|
32 |
#include "EapMsChapV2DbParameterNames.h"
|
|
33 |
#include "EapMsChapV2DbDefaults.h"
|
|
34 |
#include <EapMsChapV2UiConnection.h>
|
|
35 |
#include <EapMsChapV2UiDataConnection.h>
|
|
36 |
#include <EapMsChapV2UiMsChapV2Data.h>
|
|
37 |
#include "eap_am_trace_symbian.h"
|
|
38 |
|
|
39 |
const TUint KMaxSqlQueryLength = 256;
|
|
40 |
|
|
41 |
|
|
42 |
CEapMsChapV2UiDataConnection::CEapMsChapV2UiDataConnection(CEapMsChapV2UiConnection * aUiConn)
|
|
43 |
: iIsOpened(EFalse)
|
|
44 |
, iUiConn(aUiConn)
|
|
45 |
, iColSet(NULL)
|
|
46 |
, iDataPtr(NULL)
|
|
47 |
{
|
|
48 |
}
|
|
49 |
|
|
50 |
|
|
51 |
CEapMsChapV2UiDataConnection::~CEapMsChapV2UiDataConnection()
|
|
52 |
{
|
|
53 |
if (iUiConn)
|
|
54 |
{
|
|
55 |
Close();
|
|
56 |
iUiConn = NULL;
|
|
57 |
}
|
|
58 |
}
|
|
59 |
|
|
60 |
|
|
61 |
TInt CEapMsChapV2UiDataConnection::Open()
|
|
62 |
{
|
|
63 |
if (iIsOpened)
|
|
64 |
{
|
|
65 |
return KErrAlreadyExists;
|
|
66 |
}
|
|
67 |
|
|
68 |
TInt err = iUiConn->GetDatabase(iDatabase);
|
|
69 |
if (err != KErrNone)
|
|
70 |
{
|
|
71 |
return err;
|
|
72 |
}
|
|
73 |
|
|
74 |
iIsOpened = ETrue;
|
|
75 |
return KErrNone;
|
|
76 |
}
|
|
77 |
|
|
78 |
|
|
79 |
TInt CEapMsChapV2UiDataConnection::GetData(CEapMsChapV2UiMsChapV2Data ** aDataPtr)
|
|
80 |
{
|
|
81 |
if (aDataPtr == NULL)
|
|
82 |
{
|
|
83 |
return KErrArgument;
|
|
84 |
}
|
|
85 |
if (iIsOpened == EFalse)
|
|
86 |
{
|
|
87 |
return KErrSessionClosed;
|
|
88 |
}
|
|
89 |
iDataPtr = new CEapMsChapV2UiMsChapV2Data();
|
|
90 |
if (!iDataPtr)
|
|
91 |
{
|
|
92 |
return KErrNoMemory;
|
|
93 |
}
|
|
94 |
|
|
95 |
TRAPD(err, FetchDataL());
|
|
96 |
if (err != KErrNone)
|
|
97 |
{
|
|
98 |
delete iDataPtr;
|
|
99 |
iDataPtr = NULL;
|
|
100 |
|
|
101 |
delete iColSet;
|
|
102 |
iColSet = NULL;
|
|
103 |
|
|
104 |
iView.Close();
|
|
105 |
|
|
106 |
return err;
|
|
107 |
}
|
|
108 |
|
|
109 |
*aDataPtr = iDataPtr;
|
|
110 |
|
|
111 |
return KErrNone;
|
|
112 |
}
|
|
113 |
|
|
114 |
|
|
115 |
TInt CEapMsChapV2UiDataConnection::Update()
|
|
116 |
{
|
|
117 |
TRAPD(err, iView.UpdateL());
|
|
118 |
if (err != KErrNone)
|
|
119 |
{
|
|
120 |
return err;
|
|
121 |
}
|
|
122 |
|
|
123 |
// Validate the length of username and password.
|
|
124 |
if(iDataPtr->GetUsername().Length() > KMaxUsernameLengthInDB
|
|
125 |
|| iDataPtr->GetPassword().Length() > KMaxPasswordLengthInDB)
|
|
126 |
{
|
|
127 |
// Username or password too long. Can not be stored in DB.
|
|
128 |
EAP_TRACE_DEBUG_SYMBIAN((_L("CEapMsChapV2UiDataConnection::Update: Too long username or password. Length: UN=%d, PW=%d\n"),
|
|
129 |
iDataPtr->GetUsername().Length(),
|
|
130 |
iDataPtr->GetPassword().Length()));
|
|
131 |
|
|
132 |
return KErrArgument;
|
|
133 |
}
|
|
134 |
|
|
135 |
TRAP(err, iView.SetColL(iColSet->ColNo(cf_str_EAP_MSCHAPV2_username_literal), iDataPtr->GetUsername()));
|
|
136 |
if (err != KErrNone)
|
|
137 |
{
|
|
138 |
return err;
|
|
139 |
}
|
|
140 |
|
|
141 |
TRAP(err, iView.SetColL(iColSet->ColNo(cf_str_EAP_MSCHAPV2_password_literal), iDataPtr->GetPassword()));
|
|
142 |
if (err != KErrNone)
|
|
143 |
{
|
|
144 |
return err;
|
|
145 |
}
|
|
146 |
|
|
147 |
if (*(iDataPtr->GetPasswordPrompt()))
|
|
148 |
{
|
|
149 |
TRAP(err, iView.SetColL(iColSet->ColNo(cf_str_EAP_MSCHAPV2_password_prompt_literal), EMSCHAPV2PasswordPromptOn));
|
|
150 |
if (err != KErrNone)
|
|
151 |
{
|
|
152 |
return err;
|
|
153 |
}
|
|
154 |
}
|
|
155 |
else
|
|
156 |
{
|
|
157 |
TRAP(err, iView.SetColL(iColSet->ColNo(cf_str_EAP_MSCHAPV2_password_prompt_literal), EMSCHAPV2PasswordPromptOff));
|
|
158 |
if (err != KErrNone)
|
|
159 |
{
|
|
160 |
return err;
|
|
161 |
}
|
|
162 |
}
|
|
163 |
|
|
164 |
// Last full authentication time should be made zero when EAP configurations are modified.
|
|
165 |
// This makes sure that the next authentication with this EAP would be full authentication
|
|
166 |
// instead of reauthentication even if the session is still valid.
|
|
167 |
|
|
168 |
TRAP(err, iView.SetColL(iColSet->ColNo(KMSCHAPv2LastFullAuthTime), default_FullAuthTime));
|
|
169 |
if (err != KErrNone)
|
|
170 |
{
|
|
171 |
return err;
|
|
172 |
}
|
|
173 |
|
|
174 |
EAP_TRACE_DEBUG_SYMBIAN((_L("Session Validity: EAP-Type=MSCHAPv2 (or plain), Resetting Full Auth Time since settings are modified\n")));
|
|
175 |
|
|
176 |
TRAP(err, iView.PutL());
|
|
177 |
|
|
178 |
return err;
|
|
179 |
}
|
|
180 |
|
|
181 |
|
|
182 |
TInt CEapMsChapV2UiDataConnection::Close()
|
|
183 |
{
|
|
184 |
if (iIsOpened == EFalse)
|
|
185 |
{
|
|
186 |
return KErrNone;
|
|
187 |
}
|
|
188 |
|
|
189 |
delete iDataPtr;
|
|
190 |
iDataPtr = NULL;
|
|
191 |
|
|
192 |
delete iColSet;
|
|
193 |
iColSet = NULL;
|
|
194 |
|
|
195 |
iView.Close();
|
|
196 |
|
|
197 |
iUiConn = NULL;
|
|
198 |
|
|
199 |
return KErrNone;
|
|
200 |
}
|
|
201 |
|
|
202 |
|
|
203 |
void CEapMsChapV2UiDataConnection::FetchDataL()
|
|
204 |
{
|
|
205 |
HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength);
|
|
206 |
TPtr sqlStatement = buf->Des();
|
|
207 |
|
|
208 |
// Form the query. Query everything.
|
|
209 |
_LIT(KSQLQuery, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d");
|
|
210 |
sqlStatement.Format(KSQLQuery,
|
|
211 |
&KMsChapV2TableName,
|
|
212 |
&KServiceType,
|
|
213 |
iUiConn->GetIndexType(),
|
|
214 |
&KServiceIndex,
|
|
215 |
iUiConn->GetIndex(),
|
|
216 |
&KTunnelingType,
|
|
217 |
iUiConn->GetTunnelingType());
|
|
218 |
// Evaluate view
|
|
219 |
User::LeaveIfError(iView.Prepare(iDatabase, TDbQuery(sqlStatement)));
|
|
220 |
User::LeaveIfError(iView.EvaluateAll());
|
|
221 |
|
|
222 |
// Get the first (and only) row
|
|
223 |
iView.FirstL();
|
|
224 |
iView.GetL();
|
|
225 |
|
|
226 |
// Get column set so we get the correct column numbers
|
|
227 |
delete iColSet;
|
|
228 |
iColSet = NULL;
|
|
229 |
iColSet = iView.ColSetL();
|
|
230 |
|
|
231 |
// Start fetching the values
|
|
232 |
|
|
233 |
// Prompt password
|
|
234 |
TUint intValue = iView.ColUint(iColSet->ColNo(cf_str_EAP_MSCHAPV2_password_prompt_literal));
|
|
235 |
if (intValue == 0)
|
|
236 |
{
|
|
237 |
*(iDataPtr->GetPasswordPrompt()) = EFalse;
|
|
238 |
}
|
|
239 |
else
|
|
240 |
{
|
|
241 |
*(iDataPtr->GetPasswordPrompt()) = ETrue;
|
|
242 |
}
|
|
243 |
|
|
244 |
// username
|
|
245 |
iDataPtr->GetUsername().Copy(iView.ColDes16(iColSet->ColNo(cf_str_EAP_MSCHAPV2_username_literal)));
|
|
246 |
|
|
247 |
// password
|
|
248 |
iDataPtr->GetPassword().Copy(iView.ColDes16(iColSet->ColNo(cf_str_EAP_MSCHAPV2_password_literal)));
|
|
249 |
|
|
250 |
CleanupStack::PopAndDestroy(buf);
|
|
251 |
}
|
|
252 |
|
|
253 |
// End of file
|