|
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: 14.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 341 |
|
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 "EapGtcDbUtils.h" |
|
32 #include "EapSecurIDDbParameterNames.h" |
|
33 #include "EapGtcDbParameterNames.h" |
|
34 #include "EapGtcDbDefaults.h" |
|
35 #include <EapGtcUiConnection.h> |
|
36 #include <EapGtcUiDataConnection.h> |
|
37 #include <EapGtcUiGtcData.h> |
|
38 #include "eap_am_trace_symbian.h" |
|
39 |
|
40 const TUint KMaxSqlQueryLength = 256; |
|
41 |
|
42 |
|
43 CEapGtcUiDataConnection::CEapGtcUiDataConnection(CEapGtcUiConnection * aUiConn) |
|
44 : iIsOpened(EFalse) |
|
45 , iUiConn(aUiConn) |
|
46 , iColSet(NULL) |
|
47 , iDataPtr(NULL) |
|
48 { |
|
49 } |
|
50 |
|
51 |
|
52 CEapGtcUiDataConnection::~CEapGtcUiDataConnection() |
|
53 { |
|
54 if (iUiConn) |
|
55 { |
|
56 Close(); |
|
57 iUiConn = NULL; |
|
58 } |
|
59 } |
|
60 |
|
61 |
|
62 TInt CEapGtcUiDataConnection::Open() |
|
63 { |
|
64 if (iIsOpened) |
|
65 { |
|
66 return KErrAlreadyExists; |
|
67 } |
|
68 |
|
69 TInt err = iUiConn->GetDatabase(iDatabase); |
|
70 if (err != KErrNone) |
|
71 { |
|
72 return err; |
|
73 } |
|
74 |
|
75 iIsOpened = ETrue; |
|
76 return KErrNone; |
|
77 } |
|
78 |
|
79 |
|
80 TInt CEapGtcUiDataConnection::GetData(CEapGtcUiGtcData ** aDataPtr) |
|
81 { |
|
82 if (aDataPtr == NULL) |
|
83 { |
|
84 return KErrArgument; |
|
85 } |
|
86 if (iIsOpened == EFalse) |
|
87 { |
|
88 return KErrSessionClosed; |
|
89 } |
|
90 iDataPtr = new CEapGtcUiGtcData(); |
|
91 if (!iDataPtr) |
|
92 { |
|
93 return KErrNoMemory; |
|
94 } |
|
95 |
|
96 TRAPD(err, FetchDataL()); |
|
97 if (err != KErrNone) |
|
98 { |
|
99 delete iDataPtr; |
|
100 iDataPtr = NULL; |
|
101 |
|
102 delete iColSet; |
|
103 iColSet = NULL; |
|
104 |
|
105 iView.Close(); |
|
106 |
|
107 return err; |
|
108 } |
|
109 |
|
110 *aDataPtr = iDataPtr; |
|
111 |
|
112 return KErrNone; |
|
113 } |
|
114 |
|
115 |
|
116 TInt CEapGtcUiDataConnection::Update() |
|
117 { |
|
118 TRAPD(err, iView.UpdateL()); |
|
119 if (err != KErrNone) |
|
120 { |
|
121 return err; |
|
122 } |
|
123 |
|
124 // Validate the length of username/identity. |
|
125 if(iDataPtr->GetIdentity().Length() > KMaxIdentityLengthInDB) |
|
126 { |
|
127 // Username or identity too long. Can not be stored in DB. |
|
128 EAP_TRACE_DEBUG_SYMBIAN((_L("CEapGtcUiDataConnection::Update: Too long username/identity. length =%d\n"), |
|
129 iDataPtr->GetIdentity().Length())); |
|
130 |
|
131 return KErrArgument; |
|
132 } |
|
133 |
|
134 TRAP(err, iView.SetColL(iColSet->ColNo(cf_str_EAP_GTC_identity_literal), iDataPtr->GetIdentity())); |
|
135 if (err != KErrNone) |
|
136 { |
|
137 return err; |
|
138 } |
|
139 |
|
140 // Last full authentication time should be made zero when EAP configurations are modified. |
|
141 // This makes sure that the next authentication with this EAP would be full authentication |
|
142 // instead of reauthentication even if the session is still valid. |
|
143 |
|
144 TRAP(err, iView.SetColL(iColSet->ColNo(KGTCLastFullAuthTime), default_FullAuthTime)); |
|
145 if (err != KErrNone) |
|
146 { |
|
147 return err; |
|
148 } |
|
149 |
|
150 EAP_TRACE_DEBUG_SYMBIAN((_L("Session Validity: Resetting Full Auth Time since EAP-GTC settings are modified\n"))); |
|
151 |
|
152 TRAP(err, iView.PutL()); |
|
153 |
|
154 return err; |
|
155 } |
|
156 |
|
157 |
|
158 TInt CEapGtcUiDataConnection::Close() |
|
159 { |
|
160 if (iIsOpened == EFalse) |
|
161 { |
|
162 return KErrNone; |
|
163 } |
|
164 |
|
165 delete iDataPtr; |
|
166 iDataPtr = NULL; |
|
167 |
|
168 delete iColSet; |
|
169 iColSet = NULL; |
|
170 |
|
171 iView.Close(); |
|
172 |
|
173 iUiConn = NULL; |
|
174 |
|
175 return KErrNone; |
|
176 } |
|
177 |
|
178 |
|
179 void CEapGtcUiDataConnection::FetchDataL() |
|
180 { |
|
181 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
|
182 TPtr sqlStatement = buf->Des(); |
|
183 |
|
184 // Form the query. Query everything. |
|
185 _LIT(KSQLQuery, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
|
186 sqlStatement.Format(KSQLQuery, |
|
187 &KGtcTableName, |
|
188 &KServiceType, |
|
189 iUiConn->GetIndexType(), |
|
190 &KServiceIndex, |
|
191 iUiConn->GetIndex(), |
|
192 &KTunnelingType, |
|
193 iUiConn->GetTunnelingType()); |
|
194 |
|
195 // Evaluate view |
|
196 User::LeaveIfError(iView.Prepare(iDatabase, TDbQuery(sqlStatement))); |
|
197 |
|
198 User::LeaveIfError(iView.EvaluateAll()); |
|
199 |
|
200 // Get the first (and only) row |
|
201 iView.FirstL(); |
|
202 iView.GetL(); |
|
203 |
|
204 // Get column set so we get the correct column numbers |
|
205 delete iColSet; |
|
206 iColSet = NULL; |
|
207 iColSet = iView.ColSetL(); |
|
208 |
|
209 // Start fetching the values |
|
210 |
|
211 // identity |
|
212 iDataPtr->GetIdentity().Copy(iView.ColDes16(iColSet->ColNo(cf_str_EAP_GTC_identity_literal))); |
|
213 |
|
214 CleanupStack::PopAndDestroy(buf); |
|
215 } |
|
216 |
|
217 // End of File |