128 |
144 |
129 iDataPtr = new CEapTlsPeapUiTlsPeapData(); |
145 iDataPtr = new CEapTlsPeapUiTlsPeapData(); |
130 if (!iDataPtr) |
146 if (!iDataPtr) |
131 { |
147 { |
132 EAP_TRACE_DEBUG_SYMBIAN( |
148 EAP_TRACE_DEBUG_SYMBIAN( |
133 (_L("CEapTlsPeapUiDataConnection::GetData: ERROR: NO MEMORY!\n"))); |
149 (_L("ERROR: CEapTlsPeapUiDataConnection::GetData(): NO MEMORY!\n"))); |
134 |
150 |
135 return KErrNoMemory; |
151 return KErrNoMemory; |
136 } |
152 } |
137 |
153 |
138 TRAPD(err, FetchDataL()); |
154 EAPSettings aSettings; |
139 if (err != KErrNone) |
155 |
140 { |
156 TRAPD(error,iEapTypeConnection->GetConfigurationL(aSettings)); |
141 delete iDataPtr; |
157 if (error) |
142 iDataPtr = NULL; |
158 { |
143 |
159 EAP_TRACE_DEBUG_SYMBIAN((_L("ERROR: CEapTlsPeapUiDataConnection::GetData() GetConfigurationL(): failed %d\n"), error)); |
144 delete iColSet; |
160 return error; |
145 iColSet = NULL; |
161 } |
146 |
162 |
147 delete iFastSpecificColSet; |
163 /**************** only for TTLS PAP ****************/ |
148 iFastSpecificColSet = NULL; |
164 |
149 |
165 if ( iUiConn->GetEapType() == *EapExpandedTypeTtlsPap.GetType() ) |
150 iView.Close(); |
166 { |
151 iFastSpecificView.Close(); |
167 if (aSettings.iShowPassWordPromptPresent) |
152 |
168 { |
153 return err; |
169 if (aSettings.iShowPassWordPrompt) |
154 } |
170 { |
|
171 *( iDataPtr->GetPapPasswordPrompt() ) = ETrue; |
|
172 } |
|
173 else |
|
174 { |
|
175 *( iDataPtr->GetPapPasswordPrompt() ) = EFalse; |
|
176 } |
|
177 } |
|
178 |
|
179 if (aSettings.iUsernamePresent) |
|
180 { |
|
181 iDataPtr->GetPapUserName().Copy(aSettings.iUsername); |
|
182 } |
|
183 |
|
184 if (aSettings.iPasswordPresent) |
|
185 { |
|
186 iDataPtr->GetPapPassword().Copy(aSettings.iPassword); |
|
187 } |
|
188 |
|
189 return KErrNone; |
|
190 } |
|
191 |
|
192 // Get use manual username |
|
193 if (aSettings.iUsernamePresent) |
|
194 { |
|
195 *(iDataPtr->GetUseManualUsername()) = ETrue; |
|
196 iDataPtr->GetManualUsername().Copy(aSettings.iUsername); |
|
197 } |
|
198 else |
|
199 { |
|
200 *(iDataPtr->GetUseManualUsername()) = EFalse; |
|
201 } |
|
202 |
|
203 // Get use manual realm |
|
204 if (aSettings.iRealmPresent) |
|
205 { |
|
206 *(iDataPtr->GetUseManualRealm()) = ETrue; |
|
207 iDataPtr->GetManualRealm().Copy(aSettings.iRealm); |
|
208 } |
|
209 else |
|
210 { |
|
211 *(iDataPtr->GetUseManualRealm()) = EFalse; |
|
212 } |
|
213 |
|
214 // Get PEAP/TTLS versions |
|
215 if (iUiConn->GetEapType() == *EapExpandedTypePeap.GetType() |
|
216 || iUiConn->GetEapType() == *EapExpandedTypeTtls.GetType() |
|
217 #ifdef USE_FAST_EAP_TYPE |
|
218 || iUiConn->GetEapType() == *EapExpandedTypeFast.GetType() |
|
219 #endif |
|
220 ) |
|
221 { |
|
222 if (aSettings.iPEAPVersionsPresent) |
|
223 { |
|
224 if (aSettings.iPEAPv0Allowed) |
|
225 { |
|
226 *(iDataPtr->GetAllowVersion0()) = ETrue; |
|
227 } |
|
228 |
|
229 if (aSettings.iPEAPv1Allowed) |
|
230 { |
|
231 *(iDataPtr->GetAllowVersion1()) = ETrue; |
|
232 } |
|
233 |
|
234 if (aSettings.iPEAPv2Allowed) |
|
235 { |
|
236 *(iDataPtr->GetAllowVersion2()) = ETrue; |
|
237 } |
|
238 } |
|
239 } |
|
240 |
|
241 if (aSettings.iUseIdentityPrivacyPresent) |
|
242 { |
|
243 if (aSettings.iUseIdentityPrivacy) |
|
244 { |
|
245 *(iDataPtr->GetTlsPrivacy()) = ETrue; |
|
246 } |
|
247 else |
|
248 { |
|
249 *(iDataPtr->GetTlsPrivacy()) = EFalse; |
|
250 } |
|
251 } |
|
252 |
|
253 #ifdef USE_FAST_EAP_TYPE |
|
254 |
|
255 EAP_TRACE_DEBUG_SYMBIAN((_L("Fetching EAP-FAST specific Special settings!\n"))); |
|
256 |
|
257 if(iUiConn->GetEapType() == *EapExpandedTypeFast.GetType()) |
|
258 { |
|
259 // Get provisioning modes |
|
260 if (aSettings.iAuthProvModeAllowedPresent) |
|
261 { |
|
262 if (aSettings.iAuthProvModeAllowed) |
|
263 { |
|
264 *(iDataPtr->GetAuthProvModeAllowed()) = ETrue; |
|
265 } |
|
266 else |
|
267 { |
|
268 *(iDataPtr->GetAuthProvModeAllowed()) = EFalse; |
|
269 } |
|
270 } |
|
271 |
|
272 if (aSettings.iUnauthProvModeAllowedPresent) |
|
273 { |
|
274 if (aSettings.iUnauthProvModeAllowed) |
|
275 { |
|
276 *(iDataPtr->GetUnauthProvModeAllowed()) = ETrue; |
|
277 } |
|
278 else |
|
279 { |
|
280 *(iDataPtr->GetUnauthProvModeAllowed()) = EFalse; |
|
281 } |
|
282 } |
|
283 |
|
284 if (aSettings.iShowPassWordPromptPresent) |
|
285 { |
|
286 if (aSettings.iShowPassWordPrompt) |
|
287 { |
|
288 *( iDataPtr->GetUsePacStorePasswordPrompt() ) = ETrue; |
|
289 } |
|
290 else |
|
291 { |
|
292 *( iDataPtr->GetUsePacStorePasswordPrompt() ) = EFalse; |
|
293 } |
|
294 } |
|
295 |
|
296 #ifdef USE_PAC_STORE |
|
297 |
|
298 { |
|
299 // Get PAC store Password |
|
300 // PAC store password is in a different database, pac store db. |
|
301 // We can use the PacStoreDbUtils to get the PAC store password. |
|
302 |
|
303 TBuf8<KMaxPasswordLengthInDB> tmpPacStorePw8; |
|
304 |
|
305 TRAPD(err, iUiConn->GetPacStorePasswordL(tmpPacStorePw8)); |
|
306 if (err) |
|
307 { |
|
308 EAP_TRACE_DEBUG_SYMBIAN((_L("couldn't get GetPacStorePasswordL!\n"))); |
|
309 } |
|
310 |
|
311 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
312 ("CEapTlsPeapUiDataConnection::FetchDataL: PW from PAC store DB(8 bits)", |
|
313 tmpPacStorePw8.Ptr(), |
|
314 tmpPacStorePw8.Size())); |
|
315 |
|
316 /***** Convert the 8 bit password to 16 bits for the UI ***************/ |
|
317 |
|
318 iDataPtr->GetPacStorePassword().Copy(tmpPacStorePw8); // This takes care of the conversion automatically. |
|
319 |
|
320 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
321 ("CEapTlsPeapUiDataConnection::FetchDataL: PW to UI (16 bits)", |
|
322 iDataPtr->GetPacStorePassword().Ptr(), |
|
323 iDataPtr->GetPacStorePassword().Size())); |
|
324 } |
|
325 |
|
326 #endif // End: #ifdef USE_PAC_STORE |
|
327 |
|
328 } // End: if(iUiConn->GetEapType() == *EapExpandedTypeFast.GetType()) |
|
329 |
|
330 #endif // End: #ifdef USE_FAST_EAP_TYPE |
155 |
331 |
156 *aDataPtr = iDataPtr; |
332 *aDataPtr = iDataPtr; |
157 |
333 |
158 EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiDataConnection::GetData: End\n"))); |
|
159 |
|
160 return KErrNone; |
334 return KErrNone; |
161 } // CEapTlsPeapUiDataConnection::GetData() |
335 } // CEapTlsPeapUiDataConnection::GetData() |
162 |
336 |
163 |
337 |
164 // --------------------------------------------------------- |
338 // --------------------------------------------------------- |
165 // CEapTlsPeapUiDataConnection::Update() |
339 // CEapTlsPeapUiDataConnection::Update() |
166 // --------------------------------------------------------- |
340 // --------------------------------------------------------- |
167 // |
341 // |
168 TInt CEapTlsPeapUiDataConnection::Update() |
342 TInt CEapTlsPeapUiDataConnection::Update() |
169 { |
343 { |
170 EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiDataConnection::Update: Start EAP-Type=%d\n"), |
344 EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiDataConnection::Update(): Start EAP-Type=0xfe%06x%08x\n"), |
171 iUiConn->GetEapType())); |
345 iUiConn->GetEapType().GetVendorId(), |
|
346 iUiConn->GetEapType().GetVendorType())); |
|
347 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: CEapTlsPeapUiDataConnection::Update()\n")); |
172 |
348 |
173 // Do the length checks first. |
349 // Do the length checks first. |
174 // Check if length of username and realm are less than the max length possible in DB. |
350 // Check if length of username and realm are less than the max length possible in DB. |
175 if(iDataPtr->GetManualUsername().Length() > KMaxManualUsernameLengthInDB |
351 if(iDataPtr->GetManualUsername().Length() > KMaxUsernameLengthInDB |
176 || iDataPtr->GetManualRealm().Length() > KMaxManualRealmLengthInDB) |
352 || iDataPtr->GetManualRealm().Length() > KMaxRealmLengthInDB) |
177 { |
353 { |
178 // Username or realm too long. Can not be stored in DB. |
354 // Username or realm too long. Can not be stored in DB. |
179 EAP_TRACE_DEBUG_SYMBIAN( |
355 EAP_TRACE_DEBUG_SYMBIAN( |
180 (_L("CEapTlsPeapUiDataConnection::Update: Too long username or realm. Length: UN=%d, Realm=%d\n"), |
356 (_L("ERROR: CEapTlsPeapUiDataConnection::Update(): Too long username or realm. Length: UN=%d, Realm=%d\n"), |
181 iDataPtr->GetManualUsername().Length(), |
357 iDataPtr->GetManualUsername().Length(), |
182 iDataPtr->GetManualRealm().Length())); |
358 iDataPtr->GetManualRealm().Length())); |
183 |
359 |
184 return KErrOverflow; |
360 return KErrOverflow; |
185 } |
361 } |
186 |
362 |
187 #ifdef USE_FAST_EAP_TYPE |
363 #ifdef USE_FAST_EAP_TYPE |
|
364 |
188 // Check the length of PAC store password. |
365 // Check the length of PAC store password. |
189 |
|
190 if(iDataPtr->GetPacStorePassword().Size() > KMaxPasswordLengthInDB) |
366 if(iDataPtr->GetPacStorePassword().Size() > KMaxPasswordLengthInDB) |
191 { |
367 { |
192 // PAC store password too long. Can not be stored in DB. |
368 // PAC store password too long. Can not be stored in DB. |
193 EAP_TRACE_DEBUG_SYMBIAN( |
369 EAP_TRACE_DEBUG_SYMBIAN( |
194 (_L("CEapTlsPeapUiDataConnection::Update: Too long PAC store PW. Size:%d\n"), |
370 (_L("ERROR: CEapTlsPeapUiDataConnection::Update(): Too long PAC store PW. Size:%d\n"), |
195 iDataPtr->GetPacStorePassword().Size())); |
371 iDataPtr->GetPacStorePassword().Size())); |
196 |
372 |
197 return KErrOverflow; |
373 return KErrOverflow; |
198 } |
374 } |
199 |
375 |
200 #endif |
376 #endif |
201 |
377 |
202 TRAPD(err, UpdateDataL()); |
378 EAPSettings aSettings; |
203 |
379 |
204 EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiDataConnection::Update: End, err=%d\n"), |
380 if( iUiConn->GetEapType() == *EapExpandedTypeTtlsPap.GetType() ) |
205 err)); |
381 { |
206 |
382 /************** only for TTLS PAP **************/ |
207 return err; |
383 |
208 } // CEapTlsPeapUiDataConnection::Update() |
384 aSettings.iShowPassWordPromptPresent = ETrue; |
209 |
385 |
210 |
386 if (*(iDataPtr->GetPapPasswordPrompt())) |
211 // --------------------------------------------------------- |
387 { |
212 // CEapTlsPeapUiDataConnection::Close() |
388 aSettings.iShowPassWordPrompt = ETrue; |
213 // --------------------------------------------------------- |
389 } |
214 // |
390 else |
215 TInt CEapTlsPeapUiDataConnection::Close() |
391 { |
216 { |
392 aSettings.iShowPassWordPrompt = EFalse; |
217 if (iIsOpened == EFalse) |
393 } |
218 { |
394 |
219 return KErrNone; |
395 aSettings.iUsernamePresent = ETrue; |
220 } |
396 aSettings.iUsername.Copy(iDataPtr->GetPapUserName()); |
221 |
397 |
222 delete iDataPtr; |
398 aSettings.iPasswordPresent = ETrue; |
223 iDataPtr = NULL; |
399 aSettings.iPassword.Copy(iDataPtr->GetPapPassword()); |
224 |
400 |
225 delete iColSet; |
401 } // if( iUiConn->GetEapType() == *EapExpandedTypeTtlsPap.GetType() ) |
226 iColSet = NULL; |
|
227 |
|
228 delete iFastSpecificColSet; |
|
229 iFastSpecificColSet = NULL; |
|
230 |
|
231 iView.Close(); |
|
232 |
|
233 iFastSpecificView.Close(); |
|
234 |
|
235 iUiConn = NULL; |
|
236 |
|
237 return KErrNone; |
|
238 } // CEapTlsPeapUiDataConnection::Close() |
|
239 |
|
240 |
|
241 // --------------------------------------------------------- |
|
242 // CEapTlsPeapUiDataConnection::FetchDataL() |
|
243 // --------------------------------------------------------- |
|
244 // |
|
245 void CEapTlsPeapUiDataConnection::FetchDataL() |
|
246 { |
|
247 EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiDataConnection::FetchDataL: Start EAP-Type=%d\n"), |
|
248 iUiConn->GetEapType())); |
|
249 |
|
250 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
|
251 TPtr sqlStatement = buf->Des(); |
|
252 |
|
253 // Form the general query for TLS, PEAP, TTLS and FAST. Query everything. |
|
254 _LIT(KSQLQuery, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
|
255 |
|
256 if (iUiConn->GetEapType() == eap_type_tls) |
|
257 { |
|
258 sqlStatement.Format(KSQLQuery, |
|
259 &KTlsDatabaseTableName, |
|
260 &KServiceType, |
|
261 iUiConn->GetIndexType(), |
|
262 &KServiceIndex, |
|
263 iUiConn->GetIndex(), |
|
264 &KTunnelingType, |
|
265 iUiConn->GetTunnelingType()); |
|
266 } |
|
267 else if (iUiConn->GetEapType() == eap_type_peap) |
|
268 { |
|
269 sqlStatement.Format(KSQLQuery, |
|
270 &KPeapDatabaseTableName, |
|
271 &KServiceType, |
|
272 iUiConn->GetIndexType(), |
|
273 &KServiceIndex, |
|
274 iUiConn->GetIndex(), |
|
275 &KTunnelingType, |
|
276 iUiConn->GetTunnelingType()); |
|
277 } |
|
278 else if (iUiConn->GetEapType() == eap_type_ttls || iUiConn->GetEapType() == eap_type_ttls_plain_pap) |
|
279 { |
|
280 sqlStatement.Format(KSQLQuery, |
|
281 &KTtlsDatabaseTableName, |
|
282 &KServiceType, |
|
283 iUiConn->GetIndexType(), |
|
284 &KServiceIndex, |
|
285 iUiConn->GetIndex(), |
|
286 &KTunnelingType, |
|
287 iUiConn->GetTunnelingType()); |
|
288 } |
|
289 |
|
290 #ifdef USE_FAST_EAP_TYPE |
|
291 else if (iUiConn->GetEapType() == eap_type_fast) |
|
292 { |
|
293 // Unlike other EAP types, EAP-FAST has two settings tables. |
|
294 // General settings and special settings |
|
295 |
|
296 // This is for the General settings. The special settings are read below. |
|
297 |
|
298 sqlStatement.Format(KSQLQuery, |
|
299 &KFastGeneralSettingsDBTableName, |
|
300 &KServiceType, |
|
301 iUiConn->GetIndexType(), |
|
302 &KServiceIndex, |
|
303 iUiConn->GetIndex(), |
|
304 &KTunnelingType, |
|
305 iUiConn->GetTunnelingType()); |
|
306 } |
|
307 #endif |
|
308 else |
402 else |
309 { |
403 { |
310 // Unknown EAP type |
404 if (*(iDataPtr->GetUseManualUsername())) |
311 EAP_TRACE_DEBUG_SYMBIAN((_L("EAP-Type=%d - ERROR: Unknown EAP type!\n"), |
405 { |
312 iUiConn->GetEapType())); |
406 aSettings.iUsernamePresent = ETrue; |
313 |
407 aSettings.iUsername = iDataPtr->GetManualUsername(); |
314 User::Leave(KErrNotSupported); |
408 } |
315 } |
409 else |
316 |
410 { |
317 // Evaluate view |
411 aSettings.iUsernamePresent = EFalse; |
318 User::LeaveIfError(iView.Prepare(iDatabase, TDbQuery(sqlStatement))); |
412 } |
319 User::LeaveIfError(iView.EvaluateAll()); |
413 } |
320 |
414 |
321 // Get the first (and only) row |
415 if (*(iDataPtr->GetUseManualRealm())) |
322 iView.FirstL(); |
416 { |
323 iView.GetL(); |
417 aSettings.iRealmPresent = ETrue; |
324 |
418 aSettings.iRealm = iDataPtr->GetManualRealm(); |
325 // Get column set so we get the correct column numbers |
|
326 delete iColSet; |
|
327 iColSet = NULL; |
|
328 iColSet = iView.ColSetL(); |
|
329 |
|
330 // Start fetching the values |
|
331 |
|
332 |
|
333 /**************** only for TTLS PAP ****************/ |
|
334 |
|
335 if ( iUiConn->GetEapType() == eap_type_ttls_plain_pap ) |
|
336 { |
|
337 // Prompt password |
|
338 TUint intValue = iView.ColUint( iColSet->ColNo( |
|
339 cf_str_EAP_TLS_PEAP_ttls_pap_password_prompt_literal ) ); |
|
340 if ( intValue == 0 ) |
|
341 { |
|
342 *( iDataPtr->GetPapPasswordPrompt() ) = EFalse; |
|
343 } |
|
344 else |
|
345 { |
|
346 *( iDataPtr->GetPapPasswordPrompt() ) = ETrue; |
|
347 } |
|
348 |
|
349 // username |
|
350 iDataPtr->GetPapUserName().Copy( iView.ColDes16( iColSet->ColNo( |
|
351 cf_str_EAP_TLS_PEAP_ttls_pap_username_literal ) ) ); |
|
352 |
|
353 // password |
|
354 iDataPtr->GetPapPassword().Copy( iView.ColDes16( iColSet->ColNo( |
|
355 cf_str_EAP_TLS_PEAP_ttls_pap_password_literal ) ) ); |
|
356 |
|
357 CleanupStack::PopAndDestroy(buf); |
|
358 |
|
359 EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiDataConnection::FetchDataL: Return\n"))); |
|
360 return; |
|
361 } |
|
362 |
|
363 // Get use manual username |
|
364 TUint intValue = iView.ColUint(iColSet->ColNo(cf_str_EAP_TLS_PEAP_use_manual_username_literal)); |
|
365 if (intValue == 0) |
|
366 { |
|
367 *(iDataPtr->GetUseManualUsername()) = EFalse; |
|
368 } |
419 } |
369 else |
420 else |
370 { |
421 { |
371 *(iDataPtr->GetUseManualUsername()) = ETrue; |
422 aSettings.iRealmPresent = EFalse; |
372 } |
|
373 |
|
374 // Get use manual realm |
|
375 intValue = iView.ColUint(iColSet->ColNo(cf_str_EAP_TLS_PEAP_use_manual_realm_literal)); |
|
376 if (intValue == 0) |
|
377 { |
|
378 *(iDataPtr->GetUseManualRealm()) = EFalse; |
|
379 } |
|
380 else |
|
381 { |
|
382 *(iDataPtr->GetUseManualRealm()) = ETrue; |
|
383 } |
|
384 |
|
385 // Get Username |
|
386 iDataPtr->GetManualUsername().Copy(iView.ColDes16(iColSet->ColNo(cf_str_EAP_TLS_PEAP_manual_username_literal))); |
|
387 |
|
388 // Get Realm |
|
389 iDataPtr->GetManualRealm().Copy(iView.ColDes16(iColSet->ColNo(cf_str_EAP_TLS_PEAP_manual_realm_literal))); |
|
390 |
|
391 // Get PEAP/TTLS versions |
|
392 if (iUiConn->GetEapType() == eap_type_peap |
|
393 || iUiConn->GetEapType() == eap_type_ttls |
|
394 #ifdef USE_FAST_EAP_TYPE |
|
395 || iUiConn->GetEapType() == eap_type_fast |
|
396 #endif |
|
397 ) |
|
398 { |
|
399 TPtrC8 binaryValue = iView.ColDes8(iColSet->ColNo(cf_str_EAP_TLS_PEAP_accepted_PEAP_versions_literal)); |
|
400 |
|
401 const TInt* allowedVersions = reinterpret_cast<const TInt *>(binaryValue.Ptr()); |
|
402 |
|
403 TInt i; |
|
404 for (i = 0; i < static_cast<TInt>(binaryValue.Length() / sizeof(TInt)); i++) |
|
405 { |
|
406 switch(allowedVersions[i]) |
|
407 { |
|
408 case 0: |
|
409 *(iDataPtr->GetAllowVersion0()) = ETrue; |
|
410 break; |
|
411 case 1: |
|
412 *(iDataPtr->GetAllowVersion1()) = ETrue; |
|
413 break; |
|
414 case 2: |
|
415 *(iDataPtr->GetAllowVersion2()) = ETrue; |
|
416 break; |
|
417 } |
|
418 } |
|
419 } |
|
420 |
|
421 |
|
422 intValue = iView.ColUint(iColSet->ColNo(cf_str_EAP_TLS_PEAP_use_identity_privacy_literal)); |
|
423 |
|
424 if (intValue == 0) |
|
425 { |
|
426 *(iDataPtr->GetTlsPrivacy()) = EFalse; |
|
427 } |
|
428 else |
|
429 { |
|
430 *(iDataPtr->GetTlsPrivacy()) = ETrue; |
|
431 } |
|
432 |
|
433 |
|
434 #ifdef USE_FAST_EAP_TYPE |
|
435 |
|
436 EAP_TRACE_DEBUG_SYMBIAN((_L("Fetching EAP-FAST specific Special settings!\n"))); |
|
437 |
|
438 if(iUiConn->GetEapType() == eap_type_fast) |
|
439 { |
|
440 // This is for the EAP-FAST specific Special settings. |
|
441 |
|
442 sqlStatement.Format(KSQLQuery, |
|
443 &KFastSpecialSettingsDBTableName, |
|
444 &KServiceType, |
|
445 iUiConn->GetIndexType(), |
|
446 &KServiceIndex, |
|
447 iUiConn->GetIndex(), |
|
448 &KTunnelingType, |
|
449 iUiConn->GetTunnelingType()); |
|
450 |
|
451 // Evaluate view |
|
452 User::LeaveIfError(iFastSpecificView.Prepare(iDatabase, TDbQuery(sqlStatement))); |
|
453 User::LeaveIfError(iFastSpecificView.EvaluateAll()); |
|
454 |
|
455 // Get the first (and only) row |
|
456 iFastSpecificView.FirstL(); |
|
457 iFastSpecificView.GetL(); |
|
458 |
|
459 // Get column set so we get the correct column numbers |
|
460 delete iFastSpecificColSet; |
|
461 iFastSpecificColSet = NULL; |
|
462 iFastSpecificColSet = iFastSpecificView.ColSetL(); |
|
463 |
|
464 // Start fetching the values |
|
465 // The below uses EAP-FAST Specific settings table. So use the specific view and colset. |
|
466 |
|
467 // Get provisioning modes |
|
468 intValue = iFastSpecificView.ColUint(iFastSpecificColSet->ColNo(cf_str_EAP_FAST_allow_server_authenticated_provisioning_mode_literal)); |
|
469 if (intValue == 0) |
|
470 { |
|
471 *(iDataPtr->GetAuthProvModeAllowed()) = EFalse; |
|
472 } |
|
473 else |
|
474 { |
|
475 *(iDataPtr->GetAuthProvModeAllowed()) = ETrue; |
|
476 } |
|
477 |
|
478 intValue = iFastSpecificView.ColUint(iFastSpecificColSet->ColNo(cf_str_EAP_FAST_allow_server_unauthenticated_provisioning_mode_ADHP_literal)); |
|
479 if (intValue == 0) |
|
480 { |
|
481 *(iDataPtr->GetUnauthProvModeAllowed()) = EFalse; |
|
482 } |
|
483 else |
|
484 { |
|
485 *(iDataPtr->GetUnauthProvModeAllowed()) = ETrue; |
|
486 } |
|
487 |
|
488 #ifdef USE_PAC_STORE |
|
489 // Get PAC store Password |
|
490 // PAC store password is in a different database, pac store db. |
|
491 // We can use the PacStoreDbUtils to get the PAC store password. |
|
492 |
|
493 TBuf8<KMaxPasswordLengthInDB> tmpPacStorePw8; |
|
494 |
|
495 iUiConn->GetPacStoreDb()->GetPacStoreDataL( |
|
496 cf_str_EAP_FAST_PAC_store_password_literal(), |
|
497 tmpPacStorePw8); |
|
498 |
|
499 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
500 ("CEapTlsPeapUiDataConnection::FetchDataL: PW from PAC store DB(8 bits)", |
|
501 tmpPacStorePw8.Ptr(), |
|
502 tmpPacStorePw8.Size())); |
|
503 |
|
504 /***** Convert the 8 bit password to 16 bits for the UI ***************/ |
|
505 |
|
506 iDataPtr->GetPacStorePassword().Copy(tmpPacStorePw8); // This takes care of the conversion automatically. |
|
507 |
|
508 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
509 ("CEapTlsPeapUiDataConnection::FetchDataL: PW to UI (16 bits)", |
|
510 iDataPtr->GetPacStorePassword().Ptr(), |
|
511 iDataPtr->GetPacStorePassword().Size())); |
|
512 |
|
513 /*****************TEST*************/ |
|
514 |
|
515 #endif // End: #ifdef USE_PAC_STORE |
|
516 |
|
517 } // End: if(iUiConn->GetEapType() == eap_type_fast) |
|
518 |
|
519 #endif // End: #ifdef USE_FAST_EAP_TYPE |
|
520 |
|
521 CleanupStack::PopAndDestroy(buf); |
|
522 |
|
523 EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiDataConnection::FetchDataL: End\n"))); |
|
524 |
|
525 } // CEapTlsPeapUiDataConnection::FetchDataL() |
|
526 |
|
527 |
|
528 // --------------------------------------------------------- |
|
529 // CEapTlsPeapUiDataConnection::UpdateDataL() |
|
530 // --------------------------------------------------------- |
|
531 // |
|
532 void CEapTlsPeapUiDataConnection::UpdateDataL() |
|
533 { |
|
534 EAP_TRACE_DEBUG_SYMBIAN( |
|
535 (_L("CEapTlsPeapUiDataConnection::UpdateDataL: Start\n"))); |
|
536 |
|
537 iView.UpdateL(); |
|
538 |
|
539 iView.SetColL( |
|
540 iColSet->ColNo(cf_str_EAP_TLS_PEAP_manual_username_literal), |
|
541 iDataPtr->GetManualUsername()); |
|
542 |
|
543 iView.SetColL( |
|
544 iColSet->ColNo(cf_str_EAP_TLS_PEAP_manual_realm_literal), |
|
545 iDataPtr->GetManualRealm()); |
|
546 |
|
547 if (*(iDataPtr->GetUseManualUsername())) |
|
548 { |
|
549 iView.SetColL( |
|
550 iColSet->ColNo(cf_str_EAP_TLS_PEAP_use_manual_username_literal), |
|
551 ETLSPEAPUseManualUsernameYes); |
|
552 } |
|
553 else |
|
554 { |
|
555 iView.SetColL( |
|
556 iColSet->ColNo(cf_str_EAP_TLS_PEAP_use_manual_username_literal), |
|
557 ETLSPEAPUseManualUsernameNo); |
|
558 } |
|
559 |
|
560 if (*(iDataPtr->GetUseManualRealm())) |
|
561 { |
|
562 iView.SetColL( |
|
563 iColSet->ColNo(cf_str_EAP_TLS_PEAP_use_manual_realm_literal), |
|
564 ETLSPEAPUseManualRealmYes); |
|
565 } |
|
566 else |
|
567 { |
|
568 iView.SetColL( |
|
569 iColSet->ColNo(cf_str_EAP_TLS_PEAP_use_manual_realm_literal), |
|
570 ETLSPEAPUseManualRealmNo); |
|
571 } |
423 } |
572 |
424 |
573 // PEAP/TTLS versions |
425 // PEAP/TTLS versions |
574 if (iUiConn->GetEapType() == eap_type_peap |
426 if (iUiConn->GetEapType() == *EapExpandedTypePeap.GetType() |
575 || iUiConn->GetEapType() == eap_type_ttls |
427 || iUiConn->GetEapType() == *EapExpandedTypeTtls.GetType() |
576 #ifdef USE_FAST_EAP_TYPE |
428 #ifdef USE_FAST_EAP_TYPE |
577 || iUiConn->GetEapType() == eap_type_fast |
429 || iUiConn->GetEapType() == *EapExpandedTypeFast.GetType() |
578 #endif |
430 #endif |
579 ) |
431 ) |
580 { |
432 { |
581 TBuf8<KMaxPEAPVersionsStringLengthInDB> acceptedVersions; |
|
582 |
|
583 if (*(iDataPtr->GetAllowVersion0())) |
433 if (*(iDataPtr->GetAllowVersion0())) |
584 { |
434 { |
585 TInt tmp(0); |
435 aSettings.iPEAPv0Allowed = ETrue; |
586 acceptedVersions.Append(reinterpret_cast<const TUint8*>(&tmp), sizeof(TInt)); |
436 } |
587 } |
437 |
588 if (*(iDataPtr->GetAllowVersion1())) |
438 if (*(iDataPtr->GetAllowVersion1())) |
589 { |
439 { |
590 TInt tmp(1); |
440 aSettings.iPEAPv1Allowed = ETrue; |
591 acceptedVersions.Append(reinterpret_cast<const TUint8*>(&tmp), sizeof(TInt)); |
441 } |
592 } |
442 |
593 if (*(iDataPtr->GetAllowVersion2())) |
443 if (*(iDataPtr->GetAllowVersion2())) |
594 { |
444 { |
595 TInt tmp(2); |
445 aSettings.iPEAPv2Allowed = ETrue; |
596 acceptedVersions.Append(reinterpret_cast<const TUint8*>(&tmp), sizeof(TInt)); |
446 } |
597 } |
|
598 |
|
599 iView.SetColL( |
|
600 iColSet->ColNo(cf_str_EAP_TLS_PEAP_accepted_PEAP_versions_literal), |
|
601 acceptedVersions); |
|
602 } |
447 } |
603 |
448 |
604 // Last full authentication time should be made zero when EAP configurations are modified. |
|
605 // This makes sure that the next authentication with this EAP would be full authentication |
|
606 // instead of reauthentication even if the session is still valid. |
|
607 |
|
608 TPtrC lastFullAuthTimeString; |
|
609 |
|
610 switch (iUiConn->GetEapType()) |
|
611 { |
|
612 case eap_type_tls: |
|
613 { |
|
614 lastFullAuthTimeString.Set(KTLSLastFullAuthTime); |
|
615 } |
|
616 break; |
|
617 |
|
618 case eap_type_peap: |
|
619 { |
|
620 lastFullAuthTimeString.Set(KPEAPLastFullAuthTime); |
|
621 } |
|
622 break; |
|
623 |
|
624 case eap_type_ttls: |
|
625 { |
|
626 lastFullAuthTimeString.Set(KTTLSLastFullAuthTime); |
|
627 } |
|
628 break; |
|
629 |
|
630 #ifdef USE_FAST_EAP_TYPE |
|
631 case eap_type_fast: |
|
632 { |
|
633 lastFullAuthTimeString.Set(KFASTLastFullAuthTime); |
|
634 } |
|
635 break; |
|
636 #endif |
|
637 |
|
638 case eap_type_ttls_plain_pap: |
|
639 { |
|
640 lastFullAuthTimeString.Set( KTTLSPAPLastFullAuthTime ); |
|
641 } |
|
642 break; |
|
643 |
|
644 default: |
|
645 { |
|
646 // Should never happen. Don't return error here as this is just to reset the auth time only. |
|
647 EAP_TRACE_DEBUG_SYMBIAN( |
|
648 (_L("Session Validity: EAP-Type=%d - ERROR: Unknown EAP type!\n"), |
|
649 iUiConn->GetEapType() )); |
|
650 } |
|
651 } |
|
652 |
|
653 iView.SetColL( |
|
654 iColSet->ColNo(lastFullAuthTimeString), |
|
655 default_FullAuthTime); |
|
656 |
|
657 EAP_TRACE_DEBUG_SYMBIAN( |
|
658 (_L("Session Validity: EAP-Type=%d, Resetting Full Auth Time since settings are modified\n"), |
|
659 iUiConn->GetEapType() )); |
|
660 |
|
661 |
449 |
662 // Update TLS Privacy |
450 // Update TLS Privacy |
663 if (*(iDataPtr->GetTlsPrivacy())) |
451 aSettings.iUseIdentityPrivacyPresent = ETrue; |
664 { |
452 |
665 iView.SetColL( |
453 if (*(iDataPtr->GetTlsPrivacy())) |
666 iColSet->ColNo(cf_str_EAP_TLS_PEAP_use_identity_privacy_literal), |
454 { |
667 ETLSPEAPTLSPrivacyYes); |
455 aSettings.iUseIdentityPrivacy = ETrue; |
668 } |
456 } |
669 else |
457 else |
670 { |
458 { |
671 iView.SetColL( |
459 aSettings.iUseIdentityPrivacy = EFalse; |
672 iColSet->ColNo(cf_str_EAP_TLS_PEAP_use_identity_privacy_literal), |
460 } |
673 ETLSPEAPTLSPrivacyNo); |
461 |
674 } |
|
675 |
|
676 |
|
677 |
|
678 |
|
679 /************** only for TTLS PAP **************/ |
|
680 |
|
681 if( iUiConn->GetEapType() == eap_type_ttls_plain_pap ) |
|
682 { |
|
683 // PAP user name |
|
684 iView.SetColL( iColSet->ColNo( cf_str_EAP_TLS_PEAP_ttls_pap_username_literal ), |
|
685 iDataPtr->GetPapUserName() ); |
|
686 // PAP password |
|
687 iView.SetColL( iColSet->ColNo( cf_str_EAP_TLS_PEAP_ttls_pap_password_literal ), |
|
688 iDataPtr->GetPapPassword() ); |
|
689 // PAP password prompt |
|
690 if ( *( iDataPtr->GetPapPasswordPrompt() ) ) |
|
691 { |
|
692 iView.SetColL( iColSet->ColNo( cf_str_EAP_TLS_PEAP_ttls_pap_password_prompt_literal ), |
|
693 EPapPasswordPromptOn ); |
|
694 } |
|
695 else |
|
696 { |
|
697 iView.SetColL( iColSet->ColNo( cf_str_EAP_TLS_PEAP_ttls_pap_password_prompt_literal ), |
|
698 EPapPasswordPromptOff ); |
|
699 } |
|
700 |
|
701 } // if( iUiConn->GetEapType() == eap_type_ttls_plain_pap ) |
|
702 |
|
703 |
|
704 |
|
705 // Now put all the updated values in DB table. |
|
706 iView.PutL(); |
|
707 |
462 |
708 #ifdef USE_FAST_EAP_TYPE |
463 #ifdef USE_FAST_EAP_TYPE |
709 |
464 |
710 if(iUiConn->GetEapType() == eap_type_fast) |
465 if(iUiConn->GetEapType() == *EapExpandedTypeFast.GetType()) |
711 { |
466 { |
712 // Make the view ready for updation. This is important! |
|
713 iFastSpecificView.UpdateL(); |
|
714 |
|
715 // Update Authentication modes |
467 // Update Authentication modes |
716 if (*(iDataPtr->GetAuthProvModeAllowed())) |
468 aSettings.iAuthProvModeAllowedPresent = ETrue; |
717 { |
469 |
718 iFastSpecificView.SetColL( |
470 if (*(iDataPtr->GetAuthProvModeAllowed())) |
719 iFastSpecificColSet->ColNo(cf_str_EAP_FAST_allow_server_authenticated_provisioning_mode_literal), |
471 { |
720 EFASTAuthProvModeAllowedYes); |
472 aSettings.iAuthProvModeAllowed = ETrue; |
721 } |
473 } |
722 else |
474 else |
723 { |
475 { |
724 iFastSpecificView.SetColL( |
476 aSettings.iAuthProvModeAllowed = EFalse; |
725 iFastSpecificColSet->ColNo(cf_str_EAP_FAST_allow_server_authenticated_provisioning_mode_literal), |
477 } |
726 EFASTAuthProvModeAllowedNo); |
478 |
727 } |
479 aSettings.iUnauthProvModeAllowedPresent = ETrue; |
728 |
480 |
729 if (*(iDataPtr->GetUnauthProvModeAllowed())) |
481 if (*(iDataPtr->GetUnauthProvModeAllowed())) |
730 { |
482 { |
731 iFastSpecificView.SetColL( |
483 aSettings.iUnauthProvModeAllowed = ETrue; |
732 iFastSpecificColSet->ColNo(cf_str_EAP_FAST_allow_server_unauthenticated_provisioning_mode_ADHP_literal), |
484 } |
733 EFASTUnauthProvModeAllowedYes); |
485 else |
734 } |
486 { |
735 else |
487 aSettings.iUnauthProvModeAllowed = EFalse; |
736 { |
488 } |
737 iFastSpecificView.SetColL( |
489 |
738 iFastSpecificColSet->ColNo(cf_str_EAP_FAST_allow_server_unauthenticated_provisioning_mode_ADHP_literal), |
490 if (*(iDataPtr->GetUsePacStorePasswordPrompt())) |
739 EFASTUnauthProvModeAllowedNo); |
491 { |
740 } |
492 aSettings.iShowPassWordPrompt = ETrue; |
741 |
493 } |
742 // Now put all the updated values in DB table. |
494 else |
743 iFastSpecificView.PutL(); |
495 { |
744 |
496 aSettings.iShowPassWordPrompt = EFalse; |
745 |
497 } |
|
498 |
746 #ifdef USE_PAC_STORE |
499 #ifdef USE_PAC_STORE |
747 |
500 |
748 // Update PAC store password. |
501 // Update PAC store password. |
749 // PAC store password should be stored in a different database, pac store db. |
502 // PAC store password should be stored in a different database, pac store db. |
750 // We can use the UI connection to save the PAC store password. |
503 // We can use the UI connection to save the PAC store password. |
751 |
504 |
752 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
505 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
753 ("CEapTlsPeapUiDataConnection::UpdateDataL: PW from UI(16 bits)", |
506 ("CEapTlsPeapUiDataConnection::UpdateDataL: PW from UI(16 bits)", |
754 iDataPtr->GetPacStorePassword().Ptr(), |
507 iDataPtr->GetPacStorePassword().Ptr(), |
755 iDataPtr->GetPacStorePassword().Size())); |
508 iDataPtr->GetPacStorePassword().Size())); |
756 |
509 |
757 TBuf8<KMaxPasswordLengthInDB> tmpSetPacStorePw8; |
510 TBuf8<KMaxPasswordLengthInDB> tmpSetPacStorePw8; |
758 tmpSetPacStorePw8.Copy(iDataPtr->GetPacStorePassword()); |
511 tmpSetPacStorePw8.Copy(iDataPtr->GetPacStorePassword()); |
759 |
512 |
760 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
513 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
761 ("CEapTlsPeapUiDataConnection::UpdateDataL: PW to PAC store DB(8 bits)", |
514 ("CEapTlsPeapUiDataConnection::UpdateDataL: PW to PAC store DB(8 bits)", |
762 tmpSetPacStorePw8.Ptr(), |
515 tmpSetPacStorePw8.Ptr(), |
763 tmpSetPacStorePw8.Size())); |
516 tmpSetPacStorePw8.Size())); |
764 |
517 |
765 iUiConn->GetPacStoreDb()->SetPacStoreDataL( |
518 TRAPD(err, iUiConn->SetPacStorePasswordL(tmpSetPacStorePw8)); |
766 cf_str_EAP_FAST_PAC_store_password_literal(), |
519 |
767 tmpSetPacStorePw8); |
520 if (err) |
|
521 return err; |
|
522 |
|
523 EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiDataConnection::Update(): SetPacStorePassword error = %d\n"),err)); |
768 |
524 |
769 /*****************TEST*************/ |
|
770 |
|
771 #ifdef PAC_STORE_DATA_HACK |
|
772 |
|
773 TBuf<4> tmpSetPacStoreData1; |
|
774 TBuf<4> tmpSetPacStoreData2; |
|
775 TBuf<4> tmpSetPacStoreData3; |
|
776 TBuf<4> tmpSetPacStoreData4; |
|
777 TBuf<4> tmpSetPacStoreData5; |
|
778 TBuf<4> tmpSetPacStoreData6; |
|
779 RArray<SInfoEntry> infoarray1; |
|
780 RArray<SInfoEntry> infoarray2; |
|
781 |
|
782 tmpSetPacStoreData1.Copy(iDataPtr->GetUsePAC_Store_Group_Reference()); |
|
783 tmpSetPacStoreData2.Copy(iDataPtr->GetUsePAC_Store_Group_Value()); |
|
784 tmpSetPacStoreData3.Copy(iDataPtr->GetUsePAC_Store_AID_Reference()); |
|
785 tmpSetPacStoreData4.Copy(iDataPtr->GetUsePAC_Store_AID_Value()); |
|
786 tmpSetPacStoreData6.Copy(iDataPtr->GetUsePAC_Store_PAC_Reference()); |
|
787 tmpSetPacStoreData6.Copy(iDataPtr->GetUsePAC_Store_PAC_Value()); |
|
788 |
|
789 EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiDataConnection::UpdateDataL: tmpSetPacStoreData=%S\n"), |
|
790 &tmpSetPacStorePw)); |
|
791 |
|
792 iUiConn->GetPacStoreDb()->SetPacStoreDataL( |
|
793 KPacStoreGroupReference, |
|
794 tmpSetPacStoreData1, |
|
795 KPacStoreGroupReference); |
|
796 iUiConn->GetPacStoreDb()->SetPacStoreDataL( |
|
797 KPacStoreGroupValue, |
|
798 tmpSetPacStoreData2, |
|
799 KPacStoreGroupReference); |
|
800 iUiConn->GetPacStoreDb()->SetPacStoreDataL( |
|
801 KPacStoreAIDReference, |
|
802 tmpSetPacStoreData3, |
|
803 KPacStoreAIDReference); |
|
804 iUiConn->GetPacStoreDb()->SetPacStoreDataL( |
|
805 KPacStoreAIDValue, |
|
806 tmpSetPacStoreData4, |
|
807 KPacStoreAIDReference); |
|
808 iUiConn->GetPacStoreDb()->SetPacStoreDataL( |
|
809 KPacStorePACReference, |
|
810 tmpSetPacStoreData5, |
|
811 KPacStorePACValue); |
|
812 iUiConn->GetPacStoreDb()->SetPacStoreDataL( |
|
813 KPacStorePACValue, |
|
814 tmpSetPacStoreData6, |
|
815 KPacStorePACReference); |
|
816 |
|
817 #endif |
|
818 |
|
819 /*****************TEST*************/ |
|
820 |
|
821 #endif // End: #ifdef USE_PAC_STORE |
525 #endif // End: #ifdef USE_PAC_STORE |
822 |
526 |
823 } // End: if(iUiConn->GetEapType() == eap_type_fast) |
527 } // End: if(iUiConn->GetEapType() == *EapExpandedTypeFast.GetType()) |
824 |
528 |
825 #endif // End: #ifdef USE_FAST_EAP_TYPE |
529 #endif // End: #ifdef USE_FAST_EAP_TYPE |
826 |
530 |
827 EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiDataConnection::UpdateDataL: End\n"))); |
531 TRAPD(error,iEapTypeConnection->SetConfigurationL(aSettings)); |
828 |
532 |
829 } // CEapTlsPeapUiDataConnection::UpdateDataL() |
533 EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiDataConnection::Update(): SetConfiguration error = %d\n"),error)); |
830 |
534 |
|
535 return error; |
|
536 |
|
537 } // CEapTlsPeapUiDataConnection::Update() |
|
538 |
|
539 |
|
540 // --------------------------------------------------------- |
|
541 // CEapTlsPeapUiDataConnection::Close() |
|
542 // --------------------------------------------------------- |
|
543 // |
|
544 TInt CEapTlsPeapUiDataConnection::Close() |
|
545 { |
|
546 EAP_TRACE_DEBUG_SYMBIAN((_L("CEapTlsPeapUiDataConnection::Close()\n"))); |
|
547 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: CEapTlsPeapUiDataConnection::Close()\n")); |
|
548 |
|
549 if (iIsOpened == EFalse) |
|
550 { |
|
551 return KErrNone; |
|
552 } |
|
553 |
|
554 delete iDataPtr; |
|
555 iDataPtr = NULL; |
|
556 |
|
557 delete iFastSpecificColSet; |
|
558 iFastSpecificColSet = NULL; |
|
559 |
|
560 iUiConn = NULL; |
|
561 |
|
562 return KErrNone; |
|
563 } // CEapTlsPeapUiDataConnection::Close() |
|
564 |
|
565 // --------------------------------------------------------- |
831 // End of file |
566 // End of file |