32 #include "EapAkaDbUtils.h" |
32 #include "EapAkaDbUtils.h" |
33 #include "EapAkaDbDefaults.h" |
33 #include "EapAkaDbDefaults.h" |
34 #include "EapAkaDbParameterNames.h" |
34 #include "EapAkaDbParameterNames.h" |
35 #include "eap_type_aka_types.h" |
35 #include "eap_type_aka_types.h" |
36 |
36 |
37 #include "eap_am_trace_symbian.h" |
37 #include <EapTraceSymbian.h> |
|
38 #include <EapPluginTools.h> |
38 |
39 |
39 const TInt KMaxSqlQueryLength = 2048; |
40 const TInt KMaxSqlQueryLength = 2048; |
40 const TInt KMicroSecsInAMinute = 60000000; // 60000000 micro seconds is 1 minute. |
41 const TInt KMicroSecsInAMinute = 60000000; // 60000000 micro seconds is 1 minute. |
41 |
42 |
42 // ================= MEMBER FUNCTIONS ======================= |
43 // ================= MEMBER FUNCTIONS ======================= |
43 |
44 |
44 void EapAkaDbUtils::OpenDatabaseL(RDbNamedDatabase& aDatabase, RDbs& aSession, const TIndexType aIndexType, |
45 // ---------------------------------------------------------- |
45 const TInt aIndex, const eap_type_value_e aTunnelingType) |
46 |
|
47 void EapAkaDbUtils::OpenDatabaseL( |
|
48 RDbNamedDatabase& aDatabase, |
|
49 RFs& aFileServerSession, |
|
50 const TIndexType aIndexType, |
|
51 const TInt aIndex, |
|
52 const eap_type_value_e aTunnelingType) |
46 { |
53 { |
47 #ifdef USE_EAP_EXPANDED_TYPES |
54 EAP_TRACE_DEBUG_SYMBIAN((_L("EapAkaDbUtils::OpenDatabaseL(): -Start- aIndexType=%d, aIndex=%d, aTunnelingVendorType=0xfe%06x%08x\n"), |
48 |
55 aIndexType, |
49 TUint aTunnelingVendorType = aTunnelingType.get_vendor_type(); |
56 aIndex, |
50 |
57 aTunnelingType.get_vendor_id(), |
51 #else |
58 aTunnelingType.get_vendor_type()) ); |
52 |
|
53 TUint aTunnelingVendorType = static_cast<TUint>(aTunnelingType); |
|
54 |
|
55 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
|
56 |
|
57 EAP_TRACE_DEBUG_SYMBIAN((_L("EapAkaDbUtils::OpenDatabaseL -Start- aIndexType=%d, aIndex=%d, aTunnelingVendorType=%d \n"), |
|
58 aIndexType,aIndex,aTunnelingVendorType) ); |
|
59 |
59 |
60 // 1. Open/create a database |
60 // 1. Open/create a database |
61 |
61 |
62 // Connect to the DBMS server. |
62 TInt error(KErrNone); |
63 User::LeaveIfError(aSession.Connect()); |
63 TFileName aPrivateDatabasePathName; |
64 CleanupClosePushL(aSession); |
64 |
65 // aSession and aDatabase are pushed to the cleanup stack even though they may be member |
65 EapPluginTools::CreateDatabaseLC( |
66 // variables of the calling class and would be closed in the destructor anyway. This ensures |
66 aDatabase, |
67 // that if they are not member variables they will be closed. Closing the handle twice |
67 aFileServerSession, |
68 // does no harm. |
68 error, |
69 |
69 KEapAkaDatabaseName, |
70 #ifdef SYMBIAN_SECURE_DBMS |
70 aPrivateDatabasePathName); |
71 |
71 |
72 // Create the secure shared database with the specified secure policy. |
72 if(error == KErrNone) |
73 // Database will be created in the data caging path for DBMS (C:\private\100012a5). |
|
74 |
|
75 TInt err = aDatabase.Create(aSession, KDatabaseName, KSecureUIDFormat); |
|
76 |
|
77 EAP_TRACE_DEBUG_SYMBIAN((_L("EapAkaDbUtils::OpenDatabaseL - Created Secure DB for eapaka.dat. err=%d\n"), err)); |
|
78 |
|
79 |
|
80 if(err == KErrNone) |
|
81 { |
73 { |
82 aDatabase.Close(); |
74 aDatabase.Close(); |
83 |
75 } |
84 } else if (err != KErrAlreadyExists) |
76 else if (error != KErrAlreadyExists) |
85 { |
77 { |
86 User::LeaveIfError(err); |
78 User::LeaveIfError(error); |
87 } |
79 } |
88 |
80 |
89 User::LeaveIfError(aDatabase.Open(aSession, KDatabaseName, KSecureUIDFormat)); |
81 EAP_TRACE_DEBUG_SYMBIAN((_L("EapAkaDbUtils::OpenDatabaseL(): - calls aDatabase.Open()\n"))); |
90 CleanupClosePushL(aDatabase); |
82 |
91 |
83 error = aDatabase.Open(aFileServerSession, aPrivateDatabasePathName); |
92 #else |
84 |
93 // For non-secured database. The database will be created in the old location (c:\system\data). |
85 EAP_TRACE_DEBUG_SYMBIAN((_L("EapAkaDbUtils::OpenDatabaseL(): - Opened private DB for EAP-AKA. error=%d\n"), error)); |
94 |
86 |
95 RFs fsSession; |
87 User::LeaveIfError(error); |
96 User::LeaveIfError(fsSession.Connect()); |
|
97 CleanupClosePushL(fsSession); |
|
98 TInt err = aDatabase.Create(fsSession, KDatabaseName); |
|
99 |
|
100 EAP_TRACE_DEBUG_SYMBIAN((_L("EapAkaDbUtils::OpenDatabaseL - Created Non-Secure DB for eapaka.dat. err=%d\n"), err)); |
|
101 |
|
102 |
|
103 if(err == KErrNone) |
|
104 { |
|
105 aDatabase.Close(); |
|
106 |
|
107 } else if (err != KErrAlreadyExists) |
|
108 { |
|
109 User::LeaveIfError(err); |
|
110 } |
|
111 CleanupStack::PopAndDestroy( &fsSession ); // close fsSession |
|
112 |
|
113 User::LeaveIfError(aDatabase.Open(aSession, KDatabaseName)); |
|
114 CleanupClosePushL(aDatabase); |
|
115 |
|
116 #endif // #ifdef SYMBIAN_SECURE_DBMS |
|
117 |
88 |
118 // 2. Create the eapaka table to database (ignore error if exists) |
89 // 2. Create the eapaka table to database (ignore error if exists) |
119 |
90 |
120 // Table columns: |
91 // Table columns: |
121 //// NAME ///////////////////////////////////////////////// TYPE ////////////// Constant ///////// |
92 //// NAME ///////////////////////////////////////////////// TYPE ////////////// Constant ///////// |
122 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
93 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
123 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
94 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
124 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
95 //| TunnelingTypeVendorId | UNSIGNED INTEGER | KTunnelingTypeVendorId |// |
125 //| EAP_AKA_use_manual_realm | UNSIGNED INTEGER | cf_str_EAP_AKA_use_manual_realm_literal |// |
96 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
126 //| EAP_AKA_manual_realm | VARCHAR(255) | cf_str_EAP_AKA_manual_realm_literal |// |
97 //| EAP_AKA_use_manual_realm | UNSIGNED INTEGER | cf_str_EAP_AKA_use_manual_realm_literal |// |
127 //| EAP_AKA_use_manual_username | UNSIGNED INTEGER | cf_str_EAP_AKA_use_manual_username_literal|// |
98 //| EAP_AKA_manual_realm | VARCHAR(255) | cf_str_EAP_AKA_manual_realm_literal |// |
128 //| EAP_AKA_manual_username | VARCHAR(255) | cf_str_EAP_AKA_manual_username_literal|// |
99 //| EAP_AKA_use_manual_username | UNSIGNED INTEGER | cf_str_EAP_AKA_use_manual_username_literal|// |
129 //| PseudonymId | LONG VARBINARY | KPseudonymId |// |
100 //| EAP_AKA_manual_username | VARCHAR(255) | cf_str_EAP_AKA_manual_username_literal|// |
130 //| XKEY | BINARY(20) | KXKey |// |
101 //| PseudonymId | LONG VARBINARY | KPseudonymId |// |
131 //| K_aut | BINARY(16) | KK_aut |// |
102 //| XKEY | BINARY(20) | KXKey |// |
132 //| K_encr | BINARY(16) | KK_encr |// |
103 //| K_aut | BINARY(16) | KK_aut |// |
133 //| ReauthCounter | UNSIGNED INTEGER | KReauthCounter |// |
104 //| K_encr | BINARY(16) | KK_encr |// |
134 //| ReauthId | LONG VARBINARY | KReauthId |// |
105 //| ReauthCounter | UNSIGNED INTEGER | KReauthCounter |// |
135 //| PreviousIMSI | VARBINARY(15) | KPreviousIMSI |// |
106 //| ReauthId | LONG VARBINARY | KReauthId |// |
136 //| EAP_AKA_use_pseudonym_identity | UNSIGNED INTEGER | cf_str_EAP_AKA_use_pseudonym_identity_literal |// |
107 //| PreviousIMSI | VARBINARY(15) | KPreviousIMSI |// |
137 //| EAP_AKA_max_session_validity_time | BIGINT | cf_str_EAP_AKA_max_session_validity_time_literal |// |
108 //| EAP_AKA_use_pseudonym_identity | UNSIGNED INTEGER | cf_str_EAP_AKA_use_pseudonym_identity_literal |// |
138 //| EAP_AKA_last_full_authentication_time | BIGINT | KAKALastFullAuthTime |// |
109 //| EAP_AKA_max_session_validity_time | BIGINT | cf_str_EAP_AKA_max_session_validity_time_literal |// |
139 ////////////////////////////////////////////////////////////////////////////////////////////////// |
110 //| EAP_AKA_last_full_authentication_time | BIGINT | KAKALastFullAuthTime |// |
|
111 ////////////////////////////////////////////////////////////////////////////////////////////////// |
140 |
112 |
141 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
113 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
142 TPtr sqlStatement = buf->Des(); |
114 TPtr sqlStatement = buf->Des(); |
143 |
115 |
144 _LIT(KSQLCreateTable, "CREATE TABLE %S (%S UNSIGNED INTEGER, \ |
116 _LIT(KSQLCreateTable, "CREATE TABLE %S \ |
145 %S UNSIGNED INTEGER, \ |
117 (%S UNSIGNED INTEGER, \ |
146 %S UNSIGNED INTEGER, \ |
118 %S UNSIGNED INTEGER, \ |
147 %S UNSIGNED INTEGER, \ |
119 %S UNSIGNED INTEGER, \ |
148 %S VARCHAR(%d), \ |
120 %S UNSIGNED INTEGER, \ |
149 %S UNSIGNED INTEGER, \ |
121 %S UNSIGNED INTEGER, \ |
150 %S VARCHAR(%d), \ |
122 %S VARCHAR(%d), \ |
151 %S LONG VARBINARY, \ |
123 %S UNSIGNED INTEGER, \ |
152 %S BINARY(%d), \ |
124 %S VARCHAR(%d), \ |
153 %S BINARY(%d), \ |
125 %S LONG VARBINARY, \ |
154 %S BINARY(%d), \ |
126 %S BINARY(%d), \ |
155 %S UNSIGNED INTEGER, \ |
127 %S BINARY(%d), \ |
156 %S LONG VARBINARY, \ |
128 %S BINARY(%d), \ |
157 %S VARBINARY(%d), \ |
129 %S UNSIGNED INTEGER, \ |
158 %S UNSIGNED INTEGER, \ |
130 %S LONG VARBINARY, \ |
159 %S BIGINT, \ |
131 %S VARBINARY(%d), \ |
160 %S BIGINT)"); |
132 %S UNSIGNED INTEGER, \ |
161 |
133 %S BIGINT, \ |
162 sqlStatement.Format(KSQLCreateTable, &KAkaTableName, &KServiceType, |
134 %S BIGINT)"); |
163 &KServiceIndex, |
135 |
164 &KTunnelingType, |
136 sqlStatement.Format(KSQLCreateTable, |
165 &cf_str_EAP_AKA_use_manual_realm_literal, |
137 &KAkaTableName, |
166 &cf_str_EAP_AKA_manual_realm_literal,KMaxManualRealmLengthInDB, |
138 &KServiceType, |
167 &cf_str_EAP_AKA_use_manual_username_literal, |
139 &KServiceIndex, |
168 &cf_str_EAP_AKA_manual_username_literal, KMaxManualUsernameLengthInDB, |
140 &KTunnelingTypeVendorId, |
169 &KPseudonymId, |
141 &KTunnelingType, |
170 &KXKey, KMaxXKeyLengthInDB, |
142 &cf_str_EAP_AKA_use_manual_realm_literal, |
171 &KK_aut, KMaxK_autLengthInDB, |
143 &cf_str_EAP_AKA_manual_realm_literal, KMaxRealmLengthInDB, |
172 &KK_encr, KMaxK_encrLengthInDB, |
144 &cf_str_EAP_AKA_use_manual_username_literal, |
173 &KReauthCounter, |
145 &cf_str_EAP_AKA_manual_username_literal, KMaxUsernameLengthInDB, |
174 &KReauthId, |
146 &KPseudonymId, |
175 &KPreviousIMSI, KMaxIMSILengthInDB, |
147 &KXKey, KMaxXKeyLengthInDB, |
176 &cf_str_EAP_AKA_use_pseudonym_identity_literal, |
148 &KK_aut, KMaxK_autLengthInDB, |
177 &cf_str_EAP_AKA_max_session_validity_time_literal, |
149 &KK_encr, KMaxK_encrLengthInDB, |
178 &KAKALastFullAuthTime); |
150 &KReauthCounter, |
|
151 &KReauthId, |
|
152 &KPreviousIMSI, KMaxIMSILengthInDB, |
|
153 &cf_str_EAP_AKA_use_pseudonym_identity_literal, |
|
154 &cf_str_EAP_AKA_max_session_validity_time_literal, |
|
155 &KAKALastFullAuthTime); |
179 |
156 |
180 err = aDatabase.Execute(sqlStatement); |
157 error = aDatabase.Execute(sqlStatement); |
181 if (err != KErrNone && err != KErrAlreadyExists) |
158 if (error != KErrNone && error != KErrAlreadyExists) |
182 { |
159 { |
183 User::Leave(err); |
160 User::Leave(error); |
184 } |
161 } |
185 |
162 |
186 // 4. Check if database table contains a row for this service type and id |
163 // 4. Check if database table contains a row for this service type and id |
187 |
164 |
188 _LIT(KSQLQueryRow, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
165 _LIT(KSQLQueryRow, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d"); |
189 sqlStatement.Format(KSQLQueryRow, &cf_str_EAP_AKA_manual_realm_literal, &KAkaTableName, |
166 sqlStatement.Format(KSQLQueryRow, |
190 &KServiceType, aIndexType, &KServiceIndex, aIndex, &KTunnelingType, aTunnelingVendorType); |
167 &cf_str_EAP_AKA_manual_realm_literal, |
|
168 &KAkaTableName, |
|
169 &KServiceType, |
|
170 aIndexType, |
|
171 &KServiceIndex, |
|
172 aIndex, |
|
173 &KTunnelingTypeVendorId, |
|
174 aTunnelingType.get_vendor_id(), |
|
175 &KTunnelingType, |
|
176 aTunnelingType.get_vendor_type()); |
191 |
177 |
192 RDbView view; |
178 RDbView view; |
193 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
179 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
194 // View must be closed when no longer needed |
180 // View must be closed when no longer needed |
195 CleanupClosePushL(view); |
181 CleanupClosePushL(view); |
214 CleanupStack::PushL(colSet); |
200 CleanupStack::PushL(colSet); |
215 |
201 |
216 view.InsertL(); |
202 view.InsertL(); |
217 view.SetColL(colSet->ColNo(KServiceType), static_cast<TInt>(aIndexType)); |
203 view.SetColL(colSet->ColNo(KServiceType), static_cast<TInt>(aIndexType)); |
218 view.SetColL(colSet->ColNo(KServiceIndex), aIndex); |
204 view.SetColL(colSet->ColNo(KServiceIndex), aIndex); |
219 view.SetColL(colSet->ColNo(KTunnelingType), aTunnelingVendorType); |
205 view.SetColL(colSet->ColNo(KTunnelingTypeVendorId), aTunnelingType.get_vendor_id()); |
|
206 view.SetColL(colSet->ColNo(KTunnelingType), aTunnelingType.get_vendor_type()); |
220 |
207 |
221 view.SetColL(colSet->ColNo(cf_str_EAP_AKA_use_manual_realm_literal), default_EAP_AKA_use_manual_realm); |
208 view.SetColL(colSet->ColNo(cf_str_EAP_AKA_use_manual_realm_literal), default_EAP_AKA_use_manual_realm); |
222 view.SetColL(colSet->ColNo(cf_str_EAP_AKA_manual_realm_literal), default_EAP_AKA_manual_realm); |
209 view.SetColL(colSet->ColNo(cf_str_EAP_AKA_manual_realm_literal), default_EAP_realm); |
223 |
210 |
224 view.SetColL(colSet->ColNo(cf_str_EAP_AKA_use_manual_username_literal), default_EAP_AKA_use_manual_username); |
211 view.SetColL(colSet->ColNo(cf_str_EAP_AKA_use_manual_username_literal), default_EAP_AKA_use_manual_username); |
225 view.SetColL(colSet->ColNo(cf_str_EAP_AKA_manual_username_literal), default_EAP_AKA_manual_username); |
212 view.SetColL(colSet->ColNo(cf_str_EAP_AKA_manual_username_literal), default_EAP_username); |
226 |
213 |
227 view.SetColL(colSet->ColNo(cf_str_EAP_AKA_use_pseudonym_identity_literal), default_EAP_AKA_use_pseudonym_identity); |
214 view.SetColL(colSet->ColNo(cf_str_EAP_AKA_use_pseudonym_identity_literal), default_EAP_AKA_use_pseudonym_identity); |
228 |
215 |
229 view.SetColL(colSet->ColNo(cf_str_EAP_AKA_max_session_validity_time_literal), default_MaxSessionTime); |
216 view.SetColL(colSet->ColNo(cf_str_EAP_AKA_max_session_validity_time_literal), default_MaxSessionTime); |
230 |
217 |
231 view.SetColL(colSet->ColNo(KAKALastFullAuthTime), default_FullAuthTime); |
218 view.SetColL(colSet->ColNo(KAKALastFullAuthTime), default_FullAuthTime); |
232 |
219 |
233 view.PutL(); |
220 view.PutL(); |
234 |
221 |
235 CleanupStack::PopAndDestroy( colSet ); // Delete colSet. |
222 CleanupStack::PopAndDestroy( colSet ); |
236 |
223 |
237 CleanupStack::PopAndDestroy( &view ); // Close view. |
224 CleanupStack::PopAndDestroy( &view ); |
238 } |
225 } |
239 |
226 |
240 CleanupStack::PopAndDestroy( buf ); // Delete buf |
227 aDatabase.Compact(); |
241 |
228 |
|
229 CleanupStack::PopAndDestroy( buf ); |
242 CleanupStack::Pop( &aDatabase ); |
230 CleanupStack::Pop( &aDatabase ); |
243 CleanupStack::Pop( &aSession ); |
231 CleanupStack::Pop( &aFileServerSession ); |
244 |
|
245 aDatabase.Compact(); |
|
246 } |
232 } |
|
233 |
|
234 // ---------------------------------------------------------- |
247 |
235 |
248 void EapAkaDbUtils::SetIndexL( |
236 void EapAkaDbUtils::SetIndexL( |
249 RDbNamedDatabase& aDatabase, |
237 RDbNamedDatabase& aDatabase, |
250 const TIndexType aIndexType, |
238 const TIndexType aIndexType, |
251 const TInt aIndex, |
239 const TInt aIndex, |
252 const eap_type_value_e aTunnelingType, |
240 const eap_type_value_e aTunnelingType, |
253 const TIndexType aNewIndexType, |
241 const TIndexType aNewIndexType, |
254 const TInt aNewIndex, |
242 const TInt aNewIndex, |
255 const eap_type_value_e aNewTunnelingType) |
243 const eap_type_value_e aNewTunnelingType) |
256 { |
244 { |
257 #ifdef USE_EAP_EXPANDED_TYPES |
245 EAP_TRACE_DEBUG_SYMBIAN( |
258 |
246 (_L("EapAkaDbUtils::SetIndexL(): -Start- aIndexType=%d, aIndex=%d, aTunnelingType=0xfe%06x%08x\n"), |
259 TUint aTunnelingVendorType = aTunnelingType.get_vendor_type(); |
247 aIndexType, |
260 TUint aNewTunnelingVendorType = aNewTunnelingType.get_vendor_type(); |
248 aIndex, |
261 |
249 aTunnelingType.get_vendor_id(), |
262 #else |
250 aTunnelingType.get_vendor_type())); |
263 |
251 |
264 TUint aTunnelingVendorType = static_cast<TUint>(aTunnelingType); |
252 EAP_TRACE_DEBUG_SYMBIAN( |
265 TUint aNewTunnelingVendorType = static_cast<TUint>(aNewTunnelingType); |
253 (_L("EapAkaDbUtils::SetIndexL(): -Start- aNewIndexType=%d, aNewIndex=%d, aNewTunnelingType=0xfe%06x%08x\n"), |
266 |
254 aNewIndexType, |
267 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
255 aNewIndex, |
|
256 aNewTunnelingType.get_vendor_id(), |
|
257 aNewTunnelingType.get_vendor_type())); |
|
258 |
|
259 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: EapAkaDbUtils::SetIndexL()\n")); |
268 |
260 |
269 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
261 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
270 TPtr sqlStatement = buf->Des(); |
262 TPtr sqlStatement = buf->Des(); |
271 |
263 |
272 _LIT(KSQL, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
264 _LIT(KSQL, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d"); |
273 |
265 |
274 sqlStatement.Format(KSQL, &KAkaTableName, |
266 sqlStatement.Format(KSQL, |
275 &KServiceType, aIndexType, &KServiceIndex, aIndex, &KTunnelingType, aTunnelingVendorType); |
267 &KAkaTableName, |
|
268 &KServiceType, |
|
269 aIndexType, |
|
270 &KServiceIndex, |
|
271 aIndex, |
|
272 &KTunnelingTypeVendorId, |
|
273 aTunnelingType.get_vendor_id(), |
|
274 &KTunnelingType, |
|
275 aTunnelingType.get_vendor_type()); |
276 |
276 |
277 RDbView view; |
277 RDbView view; |
278 |
278 |
279 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
279 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
280 |
280 |
299 CleanupStack::PushL(colSet); |
299 CleanupStack::PushL(colSet); |
300 |
300 |
301 view.UpdateL(); |
301 view.UpdateL(); |
302 |
302 |
303 view.SetColL(colSet->ColNo(KServiceType), aNewIndexType); |
303 view.SetColL(colSet->ColNo(KServiceType), aNewIndexType); |
304 |
|
305 view.SetColL(colSet->ColNo(KServiceIndex), aNewIndex); |
304 view.SetColL(colSet->ColNo(KServiceIndex), aNewIndex); |
306 |
305 view.SetColL(colSet->ColNo(KTunnelingTypeVendorId), aNewTunnelingType.get_vendor_id()); |
307 view.SetColL(colSet->ColNo(KTunnelingType), aNewTunnelingVendorType); |
306 view.SetColL(colSet->ColNo(KTunnelingType), aNewTunnelingType.get_vendor_type()); |
308 |
307 |
309 view.PutL(); |
308 view.PutL(); |
310 |
309 |
311 CleanupStack::PopAndDestroy(3); // view, colset, buf |
310 CleanupStack::PopAndDestroy(colSet); |
|
311 CleanupStack::PopAndDestroy(&view); |
|
312 CleanupStack::PopAndDestroy(buf); |
312 } |
313 } |
|
314 |
|
315 // ---------------------------------------------------------- |
313 |
316 |
314 void EapAkaDbUtils::SetConfigurationL( |
317 void EapAkaDbUtils::SetConfigurationL( |
315 RDbNamedDatabase& aDatabase, |
318 RDbNamedDatabase& aDatabase, |
316 const EAPSettings& aSettings, |
319 const EAPSettings& aSettings, |
317 const TIndexType aIndexType, |
320 const TIndexType aIndexType, |
318 const TInt aIndex, |
321 const TInt aIndex, |
319 const eap_type_value_e aTunnelingType) |
322 const eap_type_value_e aTunnelingType) |
320 { |
323 { |
321 #ifdef USE_EAP_EXPANDED_TYPES |
324 EAP_TRACE_DEBUG_SYMBIAN((_L("EapAkaDbUtils::SetConfigurationL -Start- aIndexType=%d, aIndex=%d, aTunnelingVendorType=0xfe%06x%08x\n"), |
322 |
325 aIndexType, |
323 TUint aTunnelingVendorType = aTunnelingType.get_vendor_type(); |
326 aIndex, |
324 |
327 aTunnelingType.get_vendor_id(), |
325 #else |
328 aTunnelingType.get_vendor_type())); |
326 |
329 |
327 TUint aTunnelingVendorType = static_cast<TUint>(aTunnelingType); |
330 EAP_TRACE_DEBUG_SYMBIAN((_L("*************************** SetConfigurationL(): Set the below values: ***************************\n")) ); |
328 |
331 |
329 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
332 EAP_TRACE_SETTINGS(&aSettings); |
330 |
333 |
331 EAP_TRACE_DEBUG_SYMBIAN((_L("EapAkaDbUtils::SetConfigurationL -Start- aIndexType=%d, aIndex=%d, aTunnelingVendorType=%d\n"), |
334 EAP_TRACE_DEBUG_SYMBIAN((_L("*************************** SetConfigurationL(): Set the above values: ***************************\n")) ); |
332 aIndexType,aIndex, aTunnelingVendorType)); |
|
333 |
|
334 EAP_TRACE_DEBUG_SYMBIAN((_L("*************************** SetConfigurationL - Set the below values: ***************************\n")) ); |
|
335 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - Set these values for EAPType=%d"),aSettings.iEAPType) ); |
|
336 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, Username=%S"),aSettings.iUsernamePresent, &(aSettings.iUsername)) ); |
|
337 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, Password=%S"),aSettings.iPasswordPresent, &(aSettings.iPassword)) ); |
|
338 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, Realm=%S"),aSettings.iRealmPresent, &(aSettings.iRealm)) ); |
|
339 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, UsePseudonyms=%d"),aSettings.iUsePseudonymsPresent, aSettings.iUsePseudonyms) ); |
|
340 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, VerifyServerRealm=%d"), |
|
341 aSettings.iVerifyServerRealmPresent, aSettings.iVerifyServerRealm) ); |
|
342 |
|
343 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, RequireClientAuthentication=%d"), |
|
344 aSettings.iRequireClientAuthenticationPresent, aSettings.iRequireClientAuthentication) ); |
|
345 |
|
346 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, SessionValidityTime=%d minutes"), |
|
347 aSettings.iSessionValidityTimePresent, aSettings.iSessionValidityTime) ); |
|
348 |
|
349 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, CipherSuites Count=%d"), |
|
350 aSettings.iCipherSuitesPresent, aSettings.iCipherSuites.Count()) ); |
|
351 |
|
352 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, PEAPv0Allowed=%d, PEAPv1Allowed=%d, PEAPv2Allowed=%d"), |
|
353 aSettings.iPEAPVersionsPresent, aSettings.iPEAPv0Allowed,aSettings.iPEAPv1Allowed, aSettings.iPEAPv2Allowed ) ); |
|
354 |
|
355 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, Certificates Count=%d"), |
|
356 aSettings.iCertificatesPresent, aSettings.iCertificates.Count()) ); |
|
357 |
|
358 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - Certificate details below: \n")) ); |
|
359 |
|
360 for( TInt n=0; n < aSettings.iCertificates.Count(); n++ ) |
|
361 { |
|
362 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - Certificate type:%d \n"), aSettings.iCertificates[n].iCertType) ); |
|
363 |
|
364 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - certificates - present=%d, SubjectName=%S"), |
|
365 aSettings.iCertificates[n].iSubjectNamePresent, &(aSettings.iCertificates[n].iSubjectName) ) ); |
|
366 |
|
367 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - certificates - present=%d, IssuerName=%S"), |
|
368 aSettings.iCertificates[n].iIssuerNamePresent, &(aSettings.iCertificates[n].iIssuerName) ) ); |
|
369 |
|
370 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - certificates - present=%d, SerialNumber=%S"), |
|
371 aSettings.iCertificates[n].iSerialNumberPresent, &(aSettings.iCertificates[n].iSerialNumber) ) ); |
|
372 |
|
373 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - certificates - SubjectKeyID present=%d"), |
|
374 aSettings.iCertificates[n].iSubjectKeyIDPresent ) ); |
|
375 |
|
376 EAP_TRACE_DATA_DEBUG_SYMBIAN( ( "SubjectKeyID:", aSettings.iCertificates[n].iSubjectKeyID.Ptr(), |
|
377 aSettings.iCertificates[n].iSubjectKeyID.Size() ) ); |
|
378 |
|
379 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - certificates - present=%d, Thumbprint=%S"), |
|
380 aSettings.iCertificates[n].iThumbprintPresent, &(aSettings.iCertificates[n].iThumbprint) ) ); |
|
381 } |
|
382 |
|
383 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, EncapsulatedEAPTypes Count=%d"), |
|
384 aSettings.iEncapsulatedEAPTypesPresent, aSettings.iEncapsulatedEAPTypes.Count()) ); |
|
385 for( TInt m=0; m < aSettings.iEncapsulatedEAPTypes.Count(); m++ ) |
|
386 { |
|
387 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - EncapsulatedEAPTypes=%d"), |
|
388 aSettings.iEncapsulatedEAPTypes[m]) ); |
|
389 } |
|
390 |
|
391 EAP_TRACE_DEBUG_SYMBIAN((_L("*************************** SetConfigurationL - Set the above values: ***************************\n")) ); |
|
392 |
335 |
393 // Check if the settings are for the correct type |
336 // Check if the settings are for the correct type |
394 if (aSettings.iEAPType != EAPSettings::EEapAka) |
337 if (aSettings.iEAPExpandedType != (*EapExpandedTypeAka.GetType())) |
395 { |
338 { |
396 User::Leave(KErrNotSupported); |
339 User::Leave(KErrNotSupported); |
397 } |
340 } |
398 |
341 |
399 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
342 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
400 TPtr sqlStatement = buf->Des(); |
343 TPtr sqlStatement = buf->Des(); |
401 |
344 |
402 RDbView view; |
345 RDbView view; |
403 |
346 |
404 _LIT(KSQLQuery, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
347 _LIT(KSQLQuery, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d"); |
405 sqlStatement.Format(KSQLQuery, &KAkaTableName, |
348 sqlStatement.Format(KSQLQuery, |
406 &KServiceType, aIndexType, &KServiceIndex, aIndex, &KTunnelingType, aTunnelingVendorType); |
349 &KAkaTableName, |
|
350 &KServiceType, |
|
351 aIndexType, |
|
352 &KServiceIndex, |
|
353 aIndex, |
|
354 &KTunnelingTypeVendorId, |
|
355 aTunnelingType.get_vendor_id(), |
|
356 &KTunnelingType, |
|
357 aTunnelingType.get_vendor_type()); |
407 |
358 |
408 // Evaluate view |
359 // Evaluate view |
409 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement))); |
360 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement))); |
410 |
361 |
411 CleanupClosePushL(view); |
362 CleanupClosePushL(view); |
418 |
369 |
419 // Get column set so we get the correct column numbers |
370 // Get column set so we get the correct column numbers |
420 CDbColSet* colSet = view.ColSetL(); |
371 CDbColSet* colSet = view.ColSetL(); |
421 CleanupStack::PushL(colSet); |
372 CleanupStack::PushL(colSet); |
422 |
373 |
|
374 |
|
375 if (aSettings.iUseAutomaticUsernamePresent) |
|
376 { |
|
377 // This is to set the automatic or manual status. |
|
378 TUint useManualUsernameStatus; |
|
379 |
|
380 if (aSettings.iUseAutomaticUsername) |
|
381 { |
|
382 useManualUsernameStatus = EEapDbFalse; |
|
383 } |
|
384 else |
|
385 { |
|
386 useManualUsernameStatus = EEapDbTrue; |
|
387 } |
|
388 |
|
389 // Set the value. |
|
390 view.SetColL(colSet->ColNo(cf_str_EAP_AKA_use_manual_username_literal), useManualUsernameStatus); |
|
391 } |
|
392 |
|
393 |
|
394 if (aSettings.iUseAutomaticRealmPresent) |
|
395 { |
|
396 // This is to set the automatic or manual status. |
|
397 TUint useManualRealmStatus; |
|
398 |
|
399 if (aSettings.iUseAutomaticRealm) |
|
400 { |
|
401 useManualRealmStatus = EEapDbFalse; |
|
402 } |
|
403 else |
|
404 { |
|
405 useManualRealmStatus = EEapDbTrue; |
|
406 } |
|
407 |
|
408 // Set the value. |
|
409 view.SetColL(colSet->ColNo(cf_str_EAP_AKA_use_manual_realm_literal), useManualRealmStatus); |
|
410 } |
|
411 |
|
412 |
423 // Manual username |
413 // Manual username |
424 //if (aSettings.iUsernamePresent) // no need to check as there may be empty usernames with the present status is EFlase. |
414 if (aSettings.iUsernamePresent) // no need to check as there may be empty usernames with the present status is EFlase. |
425 { |
415 { |
426 // Check if length of username is less than the max length. |
416 // Check if length of username is less than the max length. |
427 if(aSettings.iUsername.Length() > KMaxManualUsernameLengthInDB) |
417 if(aSettings.iUsername.Length() > KMaxUsernameLengthInDB) |
428 { |
418 { |
429 // Username too long. Can not be stored in DB. |
419 // Username too long. Can not be stored in DB. |
430 |
420 |
431 EAP_TRACE_DEBUG_SYMBIAN((_L("EapAkaDbUtils::SetConfigurationL: Too long Username. Length=%d \n"), |
421 EAP_TRACE_DEBUG_SYMBIAN((_L("ERROR: EapAkaDbUtils::SetConfigurationL(): Too long Username. Length=%d \n"), |
432 aSettings.iUsername.Length())); |
422 aSettings.iUsername.Length())); |
433 |
423 |
434 User::Leave(KErrArgument); |
424 User::Leave(KErrArgument); |
435 } |
425 } |
436 |
426 |
437 // Length is ok. Set the value in DB. |
427 // Length is ok. Set the value in DB. |
438 view.SetColL(colSet->ColNo(cf_str_EAP_AKA_manual_username_literal), aSettings.iUsername); |
428 view.SetColL(colSet->ColNo(cf_str_EAP_AKA_manual_username_literal), aSettings.iUsername); |
439 |
|
440 // This is to set the automatic or manual status. |
|
441 TUint useManualUsernameStatus; |
|
442 |
|
443 if (aSettings.iUsernamePresent) |
|
444 { |
|
445 useManualUsernameStatus = EAKAUseManualUsernameYes; |
|
446 } |
|
447 else |
|
448 { |
|
449 useManualUsernameStatus = EAKAUseManualUsernameNo; |
|
450 } |
|
451 |
|
452 // Set the value. |
|
453 view.SetColL(colSet->ColNo(cf_str_EAP_AKA_use_manual_username_literal), useManualUsernameStatus); |
|
454 } |
429 } |
455 |
430 |
456 // Manual realm |
431 // Manual realm |
457 //if (aSettings.iRealmPresent) // no need to check as there may be empty realms with the present status is EFlase. |
432 if (aSettings.iRealmPresent) // no need to check as there may be empty realms with the present status is EFlase. |
458 { |
433 { |
459 // Check if length of realm is less than the max length. |
434 // Check if length of realm is less than the max length. |
460 if(aSettings.iRealm.Length() > KMaxManualRealmLengthInDB) |
435 if(aSettings.iRealm.Length() > KMaxRealmLengthInDB) |
461 { |
436 { |
462 // Realm too long. Can not be stored in DB. |
437 // Realm too long. Can not be stored in DB. |
463 |
438 |
464 EAP_TRACE_DEBUG_SYMBIAN((_L("EapAkaDbUtils::SetConfigurationL: Too long Realm. Length=%d \n"), |
439 EAP_TRACE_DEBUG_SYMBIAN((_L("ERROR: EapAkaDbUtils::SetConfigurationL: Too long Realm. Length=%d \n"), |
465 aSettings.iRealm.Length())); |
440 aSettings.iRealm.Length())); |
466 |
441 |
467 User::Leave(KErrArgument); |
442 User::Leave(KErrArgument); |
468 } |
443 } |
469 |
444 |
470 // Length is ok. Set the value in DB. Value could be empty. It doesn't matter. |
445 // Length is ok. Set the value in DB. Value could be empty. It doesn't matter. |
471 view.SetColL(colSet->ColNo(cf_str_EAP_AKA_manual_realm_literal), aSettings.iRealm); |
446 view.SetColL(colSet->ColNo(cf_str_EAP_AKA_manual_realm_literal), aSettings.iRealm); |
472 |
447 } |
473 // This is to set the automatic or manual status. |
448 |
474 TUint useManualRealmStatus; |
|
475 |
|
476 if (aSettings.iRealmPresent) |
|
477 { |
|
478 useManualRealmStatus = EAKAUseManualRealmYes; |
|
479 } |
|
480 else |
|
481 { |
|
482 useManualRealmStatus = EAKAUseManualRealmNo; |
|
483 } |
|
484 |
|
485 // Set the value. |
|
486 view.SetColL(colSet->ColNo(cf_str_EAP_AKA_use_manual_realm_literal), useManualRealmStatus); |
|
487 } |
|
488 |
|
489 // UsePseudonym |
|
490 if (aSettings.iUsePseudonymsPresent) |
449 if (aSettings.iUsePseudonymsPresent) |
491 { |
450 { |
492 if (aSettings.iUsePseudonyms) |
451 if (aSettings.iUsePseudonyms) |
493 { |
452 { |
494 // Use pseudonym. |
453 // Use pseudonym. |
495 view.SetColL(colSet->ColNo(cf_str_EAP_AKA_use_pseudonym_identity_literal), EAKAUsePseudonymIdYes); |
454 view.SetColL(colSet->ColNo(cf_str_EAP_AKA_use_pseudonym_identity_literal), EEapDbTrue); |
496 } |
455 } |
497 else |
456 else |
498 { |
457 { |
499 // Don't use pseudonym. |
458 // Don't use pseudonym. |
500 view.SetColL(colSet->ColNo(cf_str_EAP_AKA_use_pseudonym_identity_literal), EAKAUsePseudonymIdNo); |
459 view.SetColL(colSet->ColNo(cf_str_EAP_AKA_use_pseudonym_identity_literal), EEapDbFalse); |
501 } |
460 } |
502 } |
461 } |
503 else |
462 else |
504 { |
463 { |
505 // Value is not configured. Value is read from config file if needed. |
464 // Value is not configured. Value is read from config file if needed. |
506 view.SetColL(colSet->ColNo(cf_str_EAP_AKA_use_pseudonym_identity_literal), EAKAUsePseudonymIdNotValid); |
465 view.SetColL(colSet->ColNo(cf_str_EAP_AKA_use_pseudonym_identity_literal), EEapDbNotValid); |
507 } |
466 } |
508 |
467 |
509 // Session validity time |
468 // Session validity time |
510 if (aSettings.iSessionValidityTimePresent) |
469 if (aSettings.iSessionValidityTimePresent) |
511 { |
470 { |
523 // This makes sure that the next authentication with this EAP would be full authentication |
482 // This makes sure that the next authentication with this EAP would be full authentication |
524 // instead of reauthentication even if the session is still valid. |
483 // instead of reauthentication even if the session is still valid. |
525 |
484 |
526 view.SetColL(colSet->ColNo(KAKALastFullAuthTime), default_FullAuthTime); |
485 view.SetColL(colSet->ColNo(KAKALastFullAuthTime), default_FullAuthTime); |
527 |
486 |
528 EAP_TRACE_DEBUG_SYMBIAN((_L("Session Validity: EAP-Type=%d, Resetting Full Auth Time since settings are modified\n"), |
487 EAP_TRACE_DEBUG_SYMBIAN((_L("EapAkaDbUtils::SetConfigurationL(): Session Validity: Resetting Full Auth Time since settings are modified\n"))); |
529 aSettings.iEAPType )); |
|
530 } |
488 } |
531 |
489 |
532 view.PutL(); |
490 view.PutL(); |
533 CleanupStack::PopAndDestroy(3); // view, colset, buf |
491 |
|
492 CleanupStack::PopAndDestroy(colSet); |
|
493 CleanupStack::PopAndDestroy(&view); |
|
494 CleanupStack::PopAndDestroy(buf); |
534 } |
495 } |
|
496 |
|
497 // ---------------------------------------------------------- |
535 |
498 |
536 void EapAkaDbUtils::GetConfigurationL( |
499 void EapAkaDbUtils::GetConfigurationL( |
537 RDbNamedDatabase& aDatabase, |
500 RDbNamedDatabase& aDatabase, |
538 EAPSettings& aSettings, |
501 EAPSettings& aSettings, |
539 const TIndexType aIndexType, |
502 const TIndexType aIndexType, |
540 const TInt aIndex, |
503 const TInt aIndex, |
541 const eap_type_value_e aTunnelingType) |
504 const eap_type_value_e aTunnelingType) |
542 { |
505 { |
543 #ifdef USE_EAP_EXPANDED_TYPES |
506 EAP_TRACE_DEBUG_SYMBIAN( |
544 |
507 (_L("EapAkaDbUtils::GetConfigurationL(): -Start- aIndexType=%d, aIndex=%d, aTunnelingType=0xfe%06x%08x\n"), |
545 TUint aTunnelingVendorType = aTunnelingType.get_vendor_type(); |
508 aIndexType, |
546 |
509 aIndex, |
547 #else |
510 aTunnelingType.get_vendor_id(), |
548 |
511 aTunnelingType.get_vendor_type())); |
549 TUint aTunnelingVendorType = static_cast<TUint>(aTunnelingType); |
512 |
550 |
513 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: EapAkaDbUtils::GetConfigurationL()\n")); |
551 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
|
552 |
514 |
553 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
515 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
554 TPtr sqlStatement = buf->Des(); |
516 TPtr sqlStatement = buf->Des(); |
555 |
517 |
556 RDbView view; |
518 RDbView view; |
557 |
519 |
558 // Form the query |
520 // Form the query |
559 _LIT(KSQLQuery, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
521 _LIT(KSQLQuery, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d"); |
560 sqlStatement.Format(KSQLQuery, &KAkaTableName, |
522 sqlStatement.Format(KSQLQuery, |
561 &KServiceType, aIndexType, &KServiceIndex, aIndex, &KTunnelingType, aTunnelingVendorType); |
523 &KAkaTableName, |
|
524 &KServiceType, |
|
525 aIndexType, |
|
526 &KServiceIndex, |
|
527 aIndex, |
|
528 &KTunnelingTypeVendorId, |
|
529 aTunnelingType.get_vendor_id(), |
|
530 &KTunnelingType, |
|
531 aTunnelingType.get_vendor_type()); |
562 |
532 |
563 // Evaluate view |
533 // Evaluate view |
564 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement))); |
534 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement))); |
565 |
535 |
566 CleanupClosePushL(view); |
536 CleanupClosePushL(view); |
573 |
543 |
574 // Get column set so we get the correct column numbers |
544 // Get column set so we get the correct column numbers |
575 CDbColSet* colSet = view.ColSetL(); |
545 CDbColSet* colSet = view.ColSetL(); |
576 CleanupStack::PushL(colSet); |
546 CleanupStack::PushL(colSet); |
577 |
547 |
578 aSettings.iEAPType = EAPSettings::EEapAka; |
548 aSettings.iEAPExpandedType = *EapExpandedTypeAka.GetType(); |
579 |
549 |
580 // Username |
550 { |
581 TPtrC username = view.ColDes(colSet->ColNo(cf_str_EAP_AKA_manual_username_literal)); |
551 // For manual or automatic username. |
582 aSettings.iUsername.Copy(username); |
552 TUint useUsername = view.ColUint(colSet->ColNo(cf_str_EAP_AKA_use_manual_username_literal)); |
583 |
553 |
584 // For manual or automatic status. |
554 aSettings.iUseAutomaticUsernamePresent = ETrue; |
585 TUint useUsername = view.ColUint(colSet->ColNo(cf_str_EAP_AKA_use_manual_username_literal)); |
555 |
586 if(useUsername == EAKAUseManualUsernameNo) |
556 if(useUsername == EEapDbTrue) |
587 { |
557 { |
588 aSettings.iUsernamePresent = EFalse; |
558 aSettings.iUseAutomaticUsername = EFalse; |
589 } |
559 } |
590 else |
560 else |
591 { |
561 { |
592 aSettings.iUsernamePresent = ETrue; |
562 aSettings.iUseAutomaticUsername = ETrue; |
593 } |
563 } |
594 |
564 } |
595 // Realm |
565 |
596 TPtrC realm = view.ColDes(colSet->ColNo(cf_str_EAP_AKA_manual_realm_literal)); |
566 { |
597 aSettings.iRealm.Copy(realm); |
567 // For manual or automatic realm. |
598 |
568 TUint useRealm = view.ColUint(colSet->ColNo(cf_str_EAP_AKA_use_manual_realm_literal)); |
599 // For manual or automatic status. |
569 |
600 TUint useRealm = view.ColUint(colSet->ColNo(cf_str_EAP_AKA_use_manual_realm_literal)); |
570 aSettings.iUseAutomaticRealmPresent = ETrue; |
601 if(useRealm == EAKAUseManualRealmNo) |
571 |
602 { |
572 if(useRealm == EEapDbTrue) |
603 aSettings.iRealmPresent = EFalse; |
573 { |
604 } |
574 aSettings.iUseAutomaticRealm = EFalse; |
605 else |
575 } |
606 { |
576 else |
|
577 { |
|
578 aSettings.iUseAutomaticRealm = ETrue; |
|
579 } |
|
580 } |
|
581 |
|
582 { |
|
583 // Username |
|
584 TPtrC username = view.ColDes(colSet->ColNo(cf_str_EAP_AKA_manual_username_literal)); |
|
585 |
|
586 aSettings.iUsernamePresent = ETrue; |
|
587 |
|
588 aSettings.iUsername.Copy(username); |
|
589 } |
|
590 |
|
591 { |
|
592 // Realm |
|
593 TPtrC realm = view.ColDes(colSet->ColNo(cf_str_EAP_AKA_manual_realm_literal)); |
|
594 |
607 aSettings.iRealmPresent = ETrue; |
595 aSettings.iRealmPresent = ETrue; |
608 } |
596 |
609 |
597 aSettings.iRealm.Copy(realm); |
610 TInt usePseudonym = view.ColUint(colSet->ColNo(cf_str_EAP_AKA_use_pseudonym_identity_literal)); |
598 } |
611 |
599 |
612 if (usePseudonym == EAKAUsePseudonymIdNotValid) |
600 { |
613 { |
601 TInt usePseudonym = view.ColUint(colSet->ColNo(cf_str_EAP_AKA_use_pseudonym_identity_literal)); |
614 aSettings.iUsePseudonymsPresent = EFalse; |
602 |
615 } |
603 if (usePseudonym == EEapDbNotValid) |
616 else |
604 { |
617 { |
605 aSettings.iUsePseudonymsPresent = EFalse; |
618 if (usePseudonym == EAKAUsePseudonymIdNo) |
|
619 { |
|
620 aSettings.iUsePseudonyms = EFalse; |
|
621 } |
606 } |
622 else |
607 else |
623 { |
608 { |
624 aSettings.iUsePseudonyms = ETrue; |
609 if (usePseudonym == EEapDbFalse) |
625 } |
610 { |
626 |
611 aSettings.iUsePseudonyms = EFalse; |
627 aSettings.iUsePseudonymsPresent = ETrue; |
612 } |
628 } |
613 else |
629 |
614 { |
630 // Session validity time |
615 aSettings.iUsePseudonyms = ETrue; |
631 TInt64 maxSessionTimeMicro = view.ColInt64(colSet->ColNo(cf_str_EAP_AKA_max_session_validity_time_literal)); |
616 } |
632 |
617 |
633 // Convert the time to minutes. |
618 aSettings.iUsePseudonymsPresent = ETrue; |
634 TInt64 maxSessionTimeMin = maxSessionTimeMicro / KMicroSecsInAMinute; |
619 } |
635 |
620 } |
636 aSettings.iSessionValidityTime = static_cast<TUint>(maxSessionTimeMin); |
621 |
637 aSettings.iSessionValidityTimePresent = ETrue; |
622 { |
638 |
623 // Session validity time |
639 CleanupStack::PopAndDestroy(3); // view, colset, buf |
624 TInt64 maxSessionTimeMicro = view.ColInt64(colSet->ColNo(cf_str_EAP_AKA_max_session_validity_time_literal)); |
|
625 |
|
626 // Convert the time to minutes. |
|
627 TInt64 maxSessionTimeMin = maxSessionTimeMicro / KMicroSecsInAMinute; |
|
628 |
|
629 aSettings.iSessionValidityTime = static_cast<TUint>(maxSessionTimeMin); |
|
630 aSettings.iSessionValidityTimePresent = ETrue; |
|
631 } |
|
632 |
|
633 CleanupStack::PopAndDestroy(colSet); |
|
634 CleanupStack::PopAndDestroy(&view); |
|
635 CleanupStack::PopAndDestroy(buf); |
|
636 |
|
637 EAP_TRACE_SETTINGS(&aSettings); |
640 } |
638 } |
|
639 |
|
640 // ---------------------------------------------------------- |
641 |
641 |
642 void EapAkaDbUtils::CopySettingsL( |
642 void EapAkaDbUtils::CopySettingsL( |
643 RDbNamedDatabase& aDatabase, |
643 RDbNamedDatabase& aDatabase, |
644 const TIndexType aSrcIndexType, |
644 const TIndexType aSrcIndexType, |
645 const TInt aSrcIndex, |
645 const TInt aSrcIndex, |
646 const eap_type_value_e aSrcTunnelingType, |
646 const eap_type_value_e aSrcTunnelingType, |
647 const TIndexType aDestIndexType, |
647 const TIndexType aDestIndexType, |
648 const TInt aDestIndex, |
648 const TInt aDestIndex, |
649 const eap_type_value_e aDestTunnelingType) |
649 const eap_type_value_e aDestTunnelingType) |
650 { |
650 { |
651 #ifdef USE_EAP_EXPANDED_TYPES |
651 EAP_TRACE_DEBUG_SYMBIAN( |
652 |
652 (_L("EapAkaDbUtils::CopySettingsL(): -Start- aSrcIndexType=%d, aSrcIndex=%d, aSrcTunnelingType=0xfe%06x%08x\n"), |
653 TUint aSrcTunnelingVendorType = aSrcTunnelingType.get_vendor_type(); |
653 aSrcIndexType, |
654 TUint aDestTunnelingVendorType = aDestTunnelingType.get_vendor_type(); |
654 aSrcIndex, |
655 |
655 aSrcTunnelingType.get_vendor_id(), |
656 #else |
656 aSrcTunnelingType.get_vendor_type())); |
657 |
657 |
658 TUint aSrcTunnelingVendorType = static_cast<TUint>(aSrcTunnelingType); |
658 EAP_TRACE_DEBUG_SYMBIAN( |
659 TUint aDestTunnelingVendorType = static_cast<TUint>(aDestTunnelingType); |
659 (_L("EapAkaDbUtils::CopySettingsL(): -Start- aDestIndexType=%d, aDestTunnelingType=0xfe%06x%08x\n"), |
660 |
660 aDestIndexType, |
661 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
661 aDestIndex, |
|
662 aDestTunnelingType.get_vendor_id(), |
|
663 aDestTunnelingType.get_vendor_type())); |
|
664 |
|
665 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: EapAkaDbUtils::CopySettingsL()\n")); |
662 |
666 |
663 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
667 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
664 TPtr sqlStatement = buf->Des(); |
668 TPtr sqlStatement = buf->Des(); |
665 |
669 |
666 _LIT(KSQL, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
670 _LIT(KSQL, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d"); |
667 |
671 |
668 sqlStatement.Format(KSQL, &KAkaTableName, |
672 sqlStatement.Format(KSQL, |
669 &KServiceType, aSrcIndexType, &KServiceIndex, aSrcIndex, &KTunnelingType, aSrcTunnelingVendorType); |
673 &KAkaTableName, |
|
674 &KServiceType, |
|
675 aSrcIndexType, |
|
676 &KServiceIndex, |
|
677 aSrcIndex, |
|
678 &KTunnelingTypeVendorId, |
|
679 aSrcTunnelingType.get_vendor_id(), |
|
680 &KTunnelingType, |
|
681 aSrcTunnelingType.get_vendor_type()); |
670 |
682 |
671 RDbView view; |
683 RDbView view; |
672 |
684 |
673 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
685 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
674 |
686 |
695 CDbColSet* colSet = view.ColSetL(); |
707 CDbColSet* colSet = view.ColSetL(); |
696 |
708 |
697 CleanupStack::PushL(colSet); |
709 CleanupStack::PushL(colSet); |
698 |
710 |
699 view.SetColL(colSet->ColNo(KServiceType), static_cast<TUint>(aDestIndexType)); |
711 view.SetColL(colSet->ColNo(KServiceType), static_cast<TUint>(aDestIndexType)); |
700 |
|
701 view.SetColL(colSet->ColNo(KServiceIndex), aDestIndex); |
712 view.SetColL(colSet->ColNo(KServiceIndex), aDestIndex); |
702 |
713 view.SetColL(colSet->ColNo(KTunnelingTypeVendorId), aDestTunnelingType.get_vendor_id()); |
703 view.SetColL(colSet->ColNo(KTunnelingType), static_cast<TUint>(aDestTunnelingVendorType)); |
714 view.SetColL(colSet->ColNo(KTunnelingType), aDestTunnelingType.get_vendor_type()); |
704 |
715 |
705 view.PutL(); |
716 view.PutL(); |
706 |
717 |
707 CleanupStack::PopAndDestroy(3); // view, colset, buf |
718 CleanupStack::PopAndDestroy(colSet); |
|
719 CleanupStack::PopAndDestroy(&view); |
|
720 CleanupStack::PopAndDestroy(buf); |
708 } |
721 } |
|
722 |
|
723 // ---------------------------------------------------------- |
709 |
724 |
710 void EapAkaDbUtils::DeleteConfigurationL( |
725 void EapAkaDbUtils::DeleteConfigurationL( |
711 const TIndexType aIndexType, |
726 const TIndexType aIndexType, |
712 const TInt aIndex, |
727 const TInt aIndex, |
713 const eap_type_value_e aTunnelingType) |
728 const eap_type_value_e aTunnelingType) |
714 { |
729 { |
715 #ifdef USE_EAP_EXPANDED_TYPES |
730 EAP_TRACE_DEBUG_SYMBIAN( |
716 |
731 (_L("EapAkaDbUtils::DeleteConfigurationL(): -Start- aIndexType=%d, aIndex=%d, aTunnelingType=0xfe%06x%08x\n"), |
717 TUint aTunnelingVendorType = aTunnelingType.get_vendor_type(); |
732 aIndexType, |
718 |
733 aIndex, |
719 #else |
734 aTunnelingType.get_vendor_id(), |
720 |
735 aTunnelingType.get_vendor_type())); |
721 TUint aTunnelingVendorType = static_cast<TUint>(aTunnelingType); |
736 |
722 |
737 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: EapAkaDbUtils::DeleteConfigurationL()\n")); |
723 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
738 |
724 |
739 RDbNamedDatabase aDatabase; |
725 RDbs session; |
740 RFs aFileServerSession; |
726 RDbNamedDatabase database; |
741 |
727 // Connect to the DBMS server. |
742 TInt error(KErrNone); |
728 User::LeaveIfError(session.Connect()); |
743 TFileName aPrivateDatabasePathName; |
729 CleanupClosePushL(session); |
744 |
730 |
745 EapPluginTools::CreateDatabaseLC( |
731 #ifdef SYMBIAN_SECURE_DBMS |
746 aDatabase, |
732 |
747 aFileServerSession, |
733 // Create the secure shared database with the specified secure policy. |
748 error, |
734 // Database will be created in the data caging path for DBMS (C:\private\100012a5). |
749 KEapAkaDatabaseName, |
735 |
750 aPrivateDatabasePathName); |
736 TInt err = database.Create(session, KDatabaseName, KSecureUIDFormat); |
751 |
737 |
752 if(error == KErrNone) |
738 if(err == KErrNone) |
|
739 { |
753 { |
740 // Database was created so it was empty. No need for further actions. |
754 // Database was created so it was empty. No need for further actions. |
741 database.Destroy(); |
755 aDatabase.Destroy(); |
742 CleanupStack::PopAndDestroy(); |
756 CleanupStack::PopAndDestroy(&aDatabase); |
|
757 CleanupStack::PopAndDestroy(&aFileServerSession); |
743 return; |
758 return; |
744 |
759 } |
745 } |
760 else if (error != KErrAlreadyExists) |
746 else if (err != KErrAlreadyExists) |
761 { |
747 { |
762 User::LeaveIfError(error); |
748 User::LeaveIfError(err); |
763 } |
749 } |
764 |
750 |
765 EAP_TRACE_DEBUG_SYMBIAN((_L("EapAkaDbUtils::DeleteConfigurationL(): - calls aDatabase.Open()\n"))); |
751 // Database existed, open it. |
766 |
752 User::LeaveIfError(database.Open(session, KDatabaseName, KSecureUIDFormat)); |
767 error = aDatabase.Open(aFileServerSession, aPrivateDatabasePathName); |
753 CleanupClosePushL(database); |
768 |
754 |
769 EAP_TRACE_DEBUG_SYMBIAN((_L("EapAkaDbUtils::DeleteConfigurationL(): - Opened private DB for EAP-AKA. error=%d\n"), error)); |
755 #else |
770 |
756 // For non-secured database. The database will be created in the old location (c:\system\data). |
771 User::LeaveIfError(error); |
757 |
|
758 RFs fsSession; |
|
759 User::LeaveIfError(fsSession.Connect()); |
|
760 CleanupClosePushL(fsSession); |
|
761 TInt err = database.Create(fsSession, KDatabaseName); |
|
762 |
|
763 if(err == KErrNone) |
|
764 { |
|
765 // Database was created so it was empty. No need for further actions. |
|
766 database.Destroy(); |
|
767 CleanupStack::PopAndDestroy(2); // fsSession, database session |
|
768 return; |
|
769 |
|
770 } |
|
771 else if (err != KErrAlreadyExists) |
|
772 { |
|
773 User::LeaveIfError(err); |
|
774 } |
|
775 |
|
776 CleanupStack::PopAndDestroy(); // close fsSession |
|
777 |
|
778 User::LeaveIfError(database.Open(session, KDatabaseName)); |
|
779 CleanupClosePushL(database); |
|
780 |
|
781 #endif // #ifdef SYMBIAN_SECURE_DBMS |
|
782 |
772 |
783 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
773 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
784 TPtr sqlStatement = buf->Des(); |
774 TPtr sqlStatement = buf->Des(); |
785 |
775 |
786 // Main settings table |
776 // Main settings table |
787 _LIT(KSQL, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
777 _LIT(KSQL, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d"); |
788 sqlStatement.Format(KSQL, &KAkaTableName, |
778 sqlStatement.Format(KSQL, |
789 &KServiceType, aIndexType, &KServiceIndex, aIndex, &KTunnelingType, aTunnelingVendorType); |
779 &KAkaTableName, |
|
780 &KServiceType, |
|
781 aIndexType, |
|
782 &KServiceIndex, |
|
783 aIndex, |
|
784 &KTunnelingTypeVendorId, |
|
785 aTunnelingType.get_vendor_id(), |
|
786 &KTunnelingType, |
|
787 aTunnelingType.get_vendor_type()); |
|
788 |
790 // Evaluate view |
789 // Evaluate view |
791 RDbView view; |
790 RDbView view; |
792 User::LeaveIfError(view.Prepare(database,TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
791 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
793 CleanupClosePushL(view); |
792 CleanupClosePushL(view); |
794 User::LeaveIfError(view.EvaluateAll()); |
793 User::LeaveIfError(view.EvaluateAll()); |
795 |
794 |
796 // Delete rows |
795 // Delete rows |
797 if (view.FirstL()) |
796 if (view.FirstL()) |