34 #include "EapTlsPeapDbParameterNames.h" |
34 #include "EapTlsPeapDbParameterNames.h" |
35 #include <x500dn.h> |
35 #include <x500dn.h> |
36 #include <x509cert.h> |
36 #include <x509cert.h> |
37 #include <x509certext.h> |
37 #include <x509certext.h> |
38 |
38 |
|
39 #include "EapPluginTools.h" |
|
40 #include "EapConversion.h" |
|
41 #include "EapAutomatic.h" |
|
42 |
39 #ifdef USE_FAST_EAP_TYPE |
43 #ifdef USE_FAST_EAP_TYPE |
40 #include "pac_store_db_parameters.h" |
44 #include "pac_store_db_parameters.h" |
41 #endif //#ifdef USE_FAST_EAP_TYPE |
45 #endif //#ifdef USE_FAST_EAP_TYPE |
42 |
46 |
43 #include "eap_am_trace_symbian.h" |
47 #include <EapTraceSymbian.h> |
|
48 |
44 #include "EapTlsPeapCertFetcher.h" |
49 #include "EapTlsPeapCertFetcher.h" |
45 |
50 |
46 const TUint KMaxSqlQueryLength = 2048; |
51 const TUint KMaxSqlQueryLength = 2048; |
47 const TInt KMicroSecsInAMinute = 60000000; // 60000000 micro seconds is 1 minute. |
52 const TInt KMicroSecsInAMinute = 60000000; // 60000000 micro seconds is 1 minute. |
48 const TInt KDefaultColumnInView_One = 1; // For DB view. |
53 const TInt KDefaultColumnInView_One = 1; // For DB view. |
49 const TInt KMaxEapDbTableNameLength = 64; |
54 const TInt KMaxEapDbTableNameLength = 64; |
|
55 |
50 // ================= MEMBER FUNCTIONS ======================= |
56 // ================= MEMBER FUNCTIONS ======================= |
51 |
57 |
52 void EapTlsPeapUtils::OpenDatabaseL( |
58 void EapTlsPeapUtils::OpenDatabaseL( |
53 RDbNamedDatabase& aDatabase, |
59 RDbNamedDatabase& aDatabase, |
54 RDbs& aSession, |
60 RFs& aFileServerSession, |
55 const TIndexType aIndexType, |
61 const TIndexType aIndexType, |
56 const TInt aIndex, |
62 const TInt aIndex, |
57 const eap_type_value_e aTunnelingType, |
63 const eap_type_value_e aTunnelingType, |
58 eap_type_value_e aEapType) |
64 eap_type_value_e aEapType) |
59 { |
65 { |
60 #ifdef USE_EAP_EXPANDED_TYPES |
|
61 |
|
62 EAP_TRACE_DEBUG_SYMBIAN( |
66 EAP_TRACE_DEBUG_SYMBIAN( |
63 (_L("EapTlsPeapUtils::OpenDatabaseL -Start- aIndexType=%d, aIndex=%d, Tunneling vendor type=%d, Eap vendor type=%d \n"), |
67 (_L("EapTlsPeapUtils::OpenDatabaseL(): - Start - aIndexType=%d, aIndex=%d, aTunnelingType=0xfe%06x%08x, aEapType=0xfe%06x%08x\n"), |
64 aIndexType,aIndex, aTunnelingType.get_vendor_type(), aEapType.get_vendor_type())); |
68 aIndexType, |
65 #else |
69 aIndex, |
66 |
70 aTunnelingType.get_vendor_id(), |
67 EAP_TRACE_DEBUG_SYMBIAN( |
71 aTunnelingType.get_vendor_type(), |
68 (_L("EapTlsPeapUtils::OpenDatabaseL -Start- aIndexType=%d, aIndex=%d, aTunnelingType=%d, aEapType=%d \n"), |
72 aEapType.get_vendor_id(), |
69 aIndexType,aIndex, aTunnelingType, aEapType)); |
73 aEapType.get_vendor_type())); |
70 |
74 |
71 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
75 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: EapTlsPeapUtils::OpenDatabaseL()\n")); |
72 |
76 |
73 if (aEapType == eap_type_tls) |
77 if (aEapType == eap_type_tls) |
74 { |
78 { |
75 OpenTlsDatabaseL(aDatabase, aSession, aIndexType, aIndex, aTunnelingType); |
79 OpenTlsDatabaseL(aDatabase, aFileServerSession, aIndexType, aIndex, aTunnelingType); |
76 } |
80 } |
77 else if (aEapType == eap_type_peap) |
81 else if (aEapType == eap_type_peap) |
78 { |
82 { |
79 OpenPeapDatabaseL(aDatabase, aSession, aIndexType, aIndex, aTunnelingType); |
83 OpenPeapDatabaseL(aDatabase, aFileServerSession, aIndexType, aIndex, aTunnelingType); |
80 } |
84 } |
81 #if defined(USE_TTLS_EAP_TYPE) |
85 #if defined(USE_TTLS_EAP_TYPE) |
82 else if (aEapType == eap_type_ttls) |
86 else if (aEapType == eap_type_ttls) |
83 { |
87 { |
84 OpenTtlsDatabaseL(aDatabase, aSession, aIndexType, aIndex, aTunnelingType); |
88 OpenTtlsDatabaseL(aDatabase, aFileServerSession, aIndexType, aIndex, aTunnelingType); |
85 } |
89 } |
86 #endif // #if defined(USE_TTLS_EAP_TYPE) |
90 #endif // #if defined(USE_TTLS_EAP_TYPE) |
87 #if defined(USE_FAST_EAP_TYPE) |
91 #if defined(USE_FAST_EAP_TYPE) |
88 else if (aEapType == eap_type_fast) |
92 else if (aEapType == eap_type_fast) |
89 { |
93 { |
90 OpenFastDatabaseL(aDatabase, aSession, aIndexType, aIndex, aTunnelingType); |
94 OpenFastDatabaseL(aDatabase, aFileServerSession, aIndexType, aIndex, aTunnelingType); |
91 } |
95 } |
92 #endif // #if defined(USE_FAST_EAP_TYPE) |
96 #endif // #if defined(USE_FAST_EAP_TYPE) |
93 |
97 else if ( aEapType == eap_expanded_type_ttls_plain_pap.get_type() ) |
94 else if ( aEapType == eap_type_ttls_plain_pap ) |
98 { |
95 { |
99 OpenTtlsDatabaseL( aDatabase, aFileServerSession, aIndexType, aIndex, aTunnelingType); |
96 OpenTtlsDatabaseL( aDatabase, aSession, aIndexType, aIndex, aTunnelingType); |
100 } |
97 } |
|
98 |
|
99 else |
101 else |
100 { |
102 { |
101 // Unsupported EAP type |
103 // Unsupported EAP type |
102 User::Leave(KErrNotSupported); |
104 User::Leave(KErrNotSupported); |
103 } |
105 } |
104 } // EapTlsPeapUtils::OpenDatabaseL() |
106 } // EapTlsPeapUtils::OpenDatabaseL() |
105 |
107 |
|
108 // --------------------------------------------------------- |
|
109 |
106 void EapTlsPeapUtils::OpenTlsDatabaseL( |
110 void EapTlsPeapUtils::OpenTlsDatabaseL( |
107 RDbNamedDatabase& aDatabase, |
111 RDbNamedDatabase& aDatabase, |
108 RDbs& aSession, |
112 RFs& aFileServerSession, |
109 const TIndexType aIndexType, |
113 const TIndexType aIndexType, |
110 const TInt aIndex, |
114 const TInt aIndex, |
111 const eap_type_value_e aTunnelingType) |
115 const eap_type_value_e aTunnelingType) |
112 { |
116 { |
113 #ifdef USE_EAP_EXPANDED_TYPES |
|
114 |
|
115 TUint aTunnelingVendorType = aTunnelingType.get_vendor_type(); |
|
116 |
|
117 #else |
|
118 |
|
119 TUint aTunnelingVendorType = static_cast<TUint>(aTunnelingType); |
|
120 |
|
121 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
|
122 |
|
123 EAP_TRACE_DEBUG_SYMBIAN( |
117 EAP_TRACE_DEBUG_SYMBIAN( |
124 (_L("EapTlsPeapUtils::OpenTlsDatabaseL -Start- aIndexType=%d, aIndex=%d, Tunneling vendor type=%d \n"), |
118 (_L("EapTlsPeapUtils::OpenTlsDatabaseL(): - Start - aIndexType=%d, aIndex=%d, aTunnelingType=0xfe%06x%08x\n"), |
125 aIndexType,aIndex, aTunnelingVendorType)); |
119 aIndexType, |
|
120 aIndex, |
|
121 aTunnelingType.get_vendor_id(), |
|
122 aTunnelingType.get_vendor_type())); |
|
123 |
|
124 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: EapTlsPeapUtils::OpenTlsDatabaseL()\n")); |
126 |
125 |
127 // 1. Open/create a database |
126 // 1. Open/create a database |
128 |
127 |
129 // Connect to the DBMS server. |
128 TInt error(KErrNone); |
130 User::LeaveIfError(aSession.Connect()); |
129 TFileName aPrivateDatabasePathName; |
131 CleanupClosePushL(aSession); |
130 |
132 // aSession and aDatabase are pushed to the cleanup stack even though they may be member |
131 EapPluginTools::CreateDatabaseLC( |
133 // variables of the calling class and would be closed in the destructor anyway. This ensures |
132 aDatabase, |
134 // that if they are not member variables they will be closed. Closing the handle twice |
133 aFileServerSession, |
135 // does no harm. |
134 error, |
136 |
135 KTlsDatabaseName, |
137 #ifdef SYMBIAN_SECURE_DBMS |
136 aPrivateDatabasePathName); |
138 |
137 |
139 // Create the secure shared database with the specified secure policy. |
138 if(error == KErrNone) |
140 // Database will be created in the data caging path for DBMS (C:\private\100012a5). |
|
141 |
|
142 TInt err = aDatabase.Create(aSession, KTlsDatabaseName, KSecureUIDFormat); |
|
143 |
|
144 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenTlsDatabaseL - Created Secure DB for eaptls.dat. err=%d\n"), err) ); |
|
145 |
|
146 if(err == KErrNone) |
|
147 { |
139 { |
148 aDatabase.Close(); |
140 aDatabase.Close(); |
149 |
141 } |
150 } else if (err != KErrAlreadyExists) |
142 else if (error != KErrAlreadyExists) |
151 { |
143 { |
152 User::LeaveIfError(err); |
144 User::LeaveIfError(error); |
153 } |
145 } |
154 |
146 |
155 User::LeaveIfError(aDatabase.Open(aSession, KTlsDatabaseName, KSecureUIDFormat)); |
147 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenTlsDatabaseL(): - calls aDatabase.Open()\n"))); |
156 CleanupClosePushL(aDatabase); |
148 |
157 |
149 error = aDatabase.Open(aFileServerSession, aPrivateDatabasePathName); |
158 #else |
150 |
159 // For non-secured database. The database will be created in the old location (c:\system\data). |
151 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenTlsDatabaseL(): - Opened private DB for EAP-TLS. error=%d\n"), error)); |
160 |
152 |
161 RFs fsSession; |
153 User::LeaveIfError(error); |
162 User::LeaveIfError(fsSession.Connect()); |
|
163 CleanupClosePushL(fsSession); |
|
164 TInt err = aDatabase.Create(fsSession, KTlsDatabaseName); |
|
165 |
|
166 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenTlsDatabaseL - Created Non-Secure DB for eaptls.dat. err=%d\n"), err) ); |
|
167 |
|
168 if(err == KErrNone) |
|
169 { |
|
170 aDatabase.Close(); |
|
171 |
|
172 } else if (err != KErrAlreadyExists) |
|
173 { |
|
174 User::LeaveIfError(err); |
|
175 } |
|
176 |
|
177 User::LeaveIfError(aDatabase.Open(fsSession, KTlsDatabaseName)); |
|
178 |
|
179 CleanupStack::PopAndDestroy(); // close fsSession |
|
180 |
|
181 CleanupClosePushL(aDatabase); |
|
182 |
|
183 #endif // #ifdef SYMBIAN_SECURE_DBMS |
|
184 |
154 |
185 // 2. Create the eaptls table to database (ignore error if exists) |
155 // 2. Create the eaptls table to database (ignore error if exists) |
186 |
156 |
187 // Table columns: |
157 // Table columns: |
188 //// NAME ////////////////////////////////////////// TYPE //////////// Constant //////////////////// |
158 //// NAME ////////////////////////////////////////// TYPE //////////// Constant //////////////////// |
189 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
159 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
190 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
160 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
191 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
161 //| TunnelingTypeVendorId | UNSIGNED INTEGER | KTunnelingTypeVendorId |// |
192 //| EAP_TLS_PEAP_use_manual_realm | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_use_manual_realm_literal |// |
162 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
193 //| EAP_TLS_PEAP_manual_realm | VARCHAR(255) | cf_str_EAP_TLS_PEAP_manual_realm_literal |// |
163 //| EAP_TLS_PEAP_use_manual_realm | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_use_manual_realm_literal |// |
194 //| EAP_TLS_PEAP_use_manual_username | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_use_manual_username_literal |// |
164 //| EAP_TLS_PEAP_manual_realm | VARCHAR(255) | cf_str_EAP_TLS_PEAP_manual_realm_literal |// |
195 //| EAP_TLS_PEAP_manual_username | VARCHAR(255) | cf_str_EAP_TLS_PEAP_manual_username_literal |// |
165 //| EAP_TLS_PEAP_use_manual_username | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_use_manual_username_literal |// |
196 //| EAP_TLS_PEAP_cipher_suite | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_cipher_suite_literal |// |
166 //| EAP_TLS_PEAP_manual_username | VARCHAR(255) | cf_str_EAP_TLS_PEAP_manual_username_literal |// |
197 //| EAP_TLS_server_authenticates_client | UNSIGNED INTEGER | cf_str_TLS_server_authenticates_client_policy_in_client_literal |// |
167 //| EAP_TLS_PEAP_cipher_suite | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_cipher_suite_literal |// |
198 //| CA_cert_label | VARCHAR(255) | KCACertLabelOld |// |
168 //| EAP_TLS_server_authenticates_client | UNSIGNED INTEGER | cf_str_TLS_server_authenticates_client_policy_in_client_literal |// |
199 //| client_cert_label | VARCHAR(255) | KClientCertLabel |// |
169 //| CA_cert_label | VARCHAR(255) | KCACertLabel |// |
200 //| EAP_TLS_PEAP_saved_session_id | BINARY(32) | cf_str_EAP_TLS_PEAP_saved_session_id_literal |// |
170 //| client_cert_label | VARCHAR(255) | KClientCertLabel |// |
201 //| EAP_TLS_PEAP_saved_master_secret | BINARY(48) | cf_str_EAP_TLS_PEAP_saved_master_secret_literal |// |
171 //| EAP_TLS_PEAP_saved_session_id | BINARY(32) | cf_str_EAP_TLS_PEAP_saved_session_id_literal |// |
202 //| EAP_TLS_PEAP_saved_cipher_suite | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_saved_cipher_suite_literal |// |
172 //| EAP_TLS_PEAP_saved_master_secret | BINARY(48) | cf_str_EAP_TLS_PEAP_saved_master_secret_literal |// |
203 //| EAP_TLS_PEAP_verify_certificate_realm | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_verify_certificate_realm_literal |// |
173 //| EAP_TLS_PEAP_saved_cipher_suite | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_saved_cipher_suite_literal |// |
204 //| EAP_TLS_max_session_validity_time | BIGINT | cf_str_EAP_TLS_max_session_validity_time_literal |// |
174 //| EAP_TLS_PEAP_verify_certificate_realm | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_verify_certificate_realm_literal |// |
205 //| EAP_TLS_last_full_authentication_time | BIGINT | KTLSLastFullAuthTime |// |
175 //| EAP_TLS_max_session_validity_time | BIGINT | cf_str_EAP_TLS_max_session_validity_time_literal |// |
206 //| EAP_TLS_PEAP_use_identity_privacy | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_use_identity_privacy_literal|// |
176 //| EAP_TLS_last_full_authentication_time | BIGINT | KTLSLastFullAuthTime |// |
207 /////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
177 //| EAP_TLS_PEAP_use_identity_privacy | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_use_identity_privacy_literal|// |
|
178 //| EAP_TLS_PEAP_use_automatic_ca_certificate | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_use_automatic_ca_certificate_literal|// |
|
179 /////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
208 |
180 |
209 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
181 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
210 TPtr sqlStatement = buf->Des(); |
182 TPtr sqlStatement = buf->Des(); |
211 |
183 |
212 // Table creation is divided into two parts because otherwise the SQL string would get too long |
184 // Table creation is divided into two parts because otherwise the SQL string would get too long |
213 _LIT(KSQLCreateTable1, "CREATE TABLE %S (%S UNSIGNED INTEGER, \ |
185 _LIT(KSQLCreateTable1, "CREATE TABLE %S \ |
214 %S UNSIGNED INTEGER, \ |
186 (%S UNSIGNED INTEGER, \ |
215 %S UNSIGNED INTEGER, \ |
187 %S UNSIGNED INTEGER, \ |
216 %S UNSIGNED INTEGER, \ |
188 %S UNSIGNED INTEGER, \ |
217 %S VARCHAR(%d), \ |
189 %S UNSIGNED INTEGER, \ |
218 %S UNSIGNED INTEGER, \ |
190 %S UNSIGNED INTEGER, \ |
219 %S VARCHAR(%d), \ |
191 %S VARCHAR(%d), \ |
220 %S UNSIGNED INTEGER, \ |
192 %S UNSIGNED INTEGER, \ |
221 %S UNSIGNED INTEGER, \ |
193 %S VARCHAR(%d), \ |
222 %S VARCHAR(%d), \ |
194 %S UNSIGNED INTEGER, \ |
223 %S VARCHAR(%d), \ |
195 %S UNSIGNED INTEGER, \ |
224 %S BINARY(%d), \ |
196 %S VARCHAR(%d), \ |
225 %S BINARY(%d), \ |
197 %S VARCHAR(%d), \ |
226 %S UNSIGNED INTEGER, \ |
198 %S BINARY(%d), \ |
227 %S UNSIGNED INTEGER, \ |
199 %S BINARY(%d), \ |
228 %S BIGINT, \ |
200 %S UNSIGNED INTEGER, \ |
229 %S BIGINT, \ |
201 %S UNSIGNED INTEGER, \ |
230 %S UNSIGNED INTEGER)"); |
202 %S BIGINT, \ |
|
203 %S BIGINT, \ |
|
204 %S UNSIGNED INTEGER, \ |
|
205 %S UNSIGNED INTEGER)"); |
231 |
206 |
232 sqlStatement.Format(KSQLCreateTable1, |
207 sqlStatement.Format(KSQLCreateTable1, |
233 &KTlsDatabaseTableName, |
208 &KTlsDatabaseTableName, |
234 &KServiceType, |
209 &KServiceType, |
235 &KServiceIndex, |
210 &KServiceIndex, |
|
211 &KTunnelingTypeVendorId, |
236 &KTunnelingType, |
212 &KTunnelingType, |
237 &cf_str_EAP_TLS_PEAP_use_manual_realm_literal, |
213 &cf_str_EAP_TLS_PEAP_use_manual_realm_literal, |
238 &cf_str_EAP_TLS_PEAP_manual_realm_literal, KMaxManualRealmLengthInDB, |
214 &cf_str_EAP_TLS_PEAP_manual_realm_literal, KMaxRealmLengthInDB, |
239 &cf_str_EAP_TLS_PEAP_use_manual_username_literal, |
215 &cf_str_EAP_TLS_PEAP_use_manual_username_literal, |
240 &cf_str_EAP_TLS_PEAP_manual_username_literal, KMaxManualUsernameLengthInDB, |
216 &cf_str_EAP_TLS_PEAP_manual_username_literal, KMaxUsernameLengthInDB, |
241 &cf_str_EAP_TLS_PEAP_cipher_suite_literal, |
217 &cf_str_EAP_TLS_PEAP_cipher_suite_literal, |
242 &cf_str_TLS_server_authenticates_client_policy_in_client_literal, |
218 &cf_str_TLS_server_authenticates_client_policy_in_client_literal, |
243 &KCACertLabelOld, KMaxCertLabelLengthInDB, |
219 &KCACertLabel, KMaxCertLabelLengthInDB, |
244 &KClientCertLabel, KMaxCertLabelLengthInDB, |
220 &KClientCertLabel, KMaxCertLabelLengthInDB, |
245 &cf_str_EAP_TLS_PEAP_saved_session_id_literal, KMaxSessionIdLengthInDB, |
221 &cf_str_EAP_TLS_PEAP_saved_session_id_literal, KMaxSessionIdLengthInDB, |
246 &cf_str_EAP_TLS_PEAP_saved_master_secret_literal, KMaxMasterSecretLengthInDB, |
222 &cf_str_EAP_TLS_PEAP_saved_master_secret_literal, KMaxMasterSecretLengthInDB, |
247 &cf_str_EAP_TLS_PEAP_saved_cipher_suite_literal, |
223 &cf_str_EAP_TLS_PEAP_saved_cipher_suite_literal, |
248 &cf_str_EAP_TLS_PEAP_verify_certificate_realm_literal, |
224 &cf_str_EAP_TLS_PEAP_verify_certificate_realm_literal, |
249 &cf_str_EAP_TLS_max_session_validity_time_literal, |
225 &cf_str_EAP_TLS_max_session_validity_time_literal, |
250 &KTLSLastFullAuthTime, |
226 &KTLSLastFullAuthTime, |
251 &cf_str_EAP_TLS_PEAP_use_identity_privacy_literal); |
227 &cf_str_EAP_TLS_PEAP_use_identity_privacy_literal, |
252 |
228 &cf_str_EAP_TLS_PEAP_use_automatic_ca_certificate_literal); |
253 err = aDatabase.Execute(sqlStatement); |
229 |
254 if (err == KErrAlreadyExists) |
230 error = aDatabase.Execute(sqlStatement); |
255 { |
231 if (error == KErrAlreadyExists) |
256 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenTlsDatabaseL - Alter Table err=%d\n"), err) ); |
232 { |
257 _LIT( KColumnDef, "UNSIGNED INTEGER" ); |
233 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenTlsDatabaseL - Alter Table error=%d\n"), error) ); |
258 AlterTableL( aDatabase, EAddColumn , KTlsDatabaseTableName, |
234 _LIT( KColumnDef, "UNSIGNED INTEGER" ); |
|
235 AlterTableL( aDatabase, EAddColumn , KTlsDatabaseTableName, |
259 cf_str_EAP_TLS_PEAP_use_identity_privacy_literal, KColumnDef); |
236 cf_str_EAP_TLS_PEAP_use_identity_privacy_literal, KColumnDef); |
260 } |
237 } |
261 else if (err != KErrNone) |
238 else if (error != KErrNone) |
262 { |
239 { |
263 User::Leave(err); |
240 User::Leave(error); |
264 } |
241 } |
265 |
242 |
266 // Create table for _allowed_ user certificates |
243 // Create table for _allowed_ user certificates |
267 |
244 |
268 //// NAME ////////////////// TYPE ////////////// Constant /////////// |
245 //// NAME ////////////////// TYPE ////////////// Constant /////////// |
269 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
246 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
270 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
247 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
271 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
248 //| TunnelingTypeVendorId | UNSIGNED INTEGER | KTunnelingTypeVendorId |// |
272 //| CertLabel | VARCHAR(255) | KCertLabel |// |
249 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
273 //| SubjectKeyId | BINARY(20) | KSubjectKeyIdentifier |// This is Symbian subjectkey id |
250 //| CertLabel | VARCHAR(255) | KCertLabel |// |
274 //| ActualSubjectKeyId | BINARY(20) | KActualSubjectKeyIdentifier |// This is the actual subjectkeyid present in the certificate. |
251 //| SubjectKeyId | BINARY(20) | KSubjectKeyIdentifier |// This is Symbian subjectkey id |
275 //| SubjectName | VARCHAR(255) | KSubjectName |// |
252 //| ActualSubjectKeyId | BINARY(20) | KActualSubjectKeyIdentifier |// This is the actual subjectkeyid present in the certificate. |
276 //| IssuerName | VARCHAR(255) | KIssuerName |// |
253 //| SubjectName | VARCHAR(255) | KSubjectName |// |
277 //| SerialNumber | VARCHAR(255) | KSerialNumber |// |
254 //| IssuerName | VARCHAR(255) | KIssuerName |// |
278 //| Thumbprint | BINARY(64) | KThumbprint |// |
255 //| SerialNumber | VARCHAR(255) | KSerialNumber |// |
279 ////////////////////////////////////////////////////////////////////////////////////////////////////// |
256 //| Thumbprint | BINARY(64) | KThumbprint |// |
280 |
257 ////////////////////////////////////////////////////////////////////////////////////////////////////// |
281 _LIT(KSQLCreateTable2, "CREATE TABLE %S (%S UNSIGNED INTEGER, \ |
258 |
282 %S UNSIGNED INTEGER, \ |
259 _LIT(KSQLCreateTable2, "CREATE TABLE %S \ |
283 %S UNSIGNED INTEGER, \ |
260 (%S UNSIGNED INTEGER, \ |
284 %S VARCHAR(%d), \ |
261 %S UNSIGNED INTEGER, \ |
285 %S BINARY(%d), \ |
262 %S UNSIGNED INTEGER, \ |
286 %S BINARY(%d), \ |
263 %S UNSIGNED INTEGER, \ |
287 %S VARCHAR(%d), \ |
264 %S VARCHAR(%d), \ |
288 %S VARCHAR(%d), \ |
265 %S BINARY(%d), \ |
289 %S VARCHAR(%d), \ |
266 %S BINARY(%d), \ |
290 %S BINARY(%d))"); |
267 %S VARCHAR(%d), \ |
291 |
268 %S VARCHAR(%d), \ |
292 sqlStatement.Format(KSQLCreateTable2, &KTlsAllowedUserCertsDatabaseTableName, |
269 %S VARCHAR(%d), \ |
|
270 %S BINARY(%d))"); |
|
271 |
|
272 sqlStatement.Format(KSQLCreateTable2, |
|
273 &KTlsAllowedUserCertsDatabaseTableName, |
293 &KServiceType, |
274 &KServiceType, |
294 &KServiceIndex, |
275 &KServiceIndex, |
|
276 &KTunnelingTypeVendorId, |
295 &KTunnelingType, |
277 &KTunnelingType, |
296 &KCertLabel, KMaxCertLabelLengthInDB, |
278 &KCertLabel, KMaxCertLabelLengthInDB, |
297 &KSubjectKeyIdentifier, KMaxSubjectKeyIdLengthInDB, |
279 &KSubjectKeyIdentifier, KMaxSubjectKeyIdLengthInDB, |
298 &KActualSubjectKeyIdentifier, KKeyIdentifierLength, |
280 &KActualSubjectKeyIdentifier, KKeyIdentifierLength, |
299 &KSubjectName, KGeneralStringMaxLength, |
281 &KSubjectName, KGeneralStringMaxLength, |
300 &KIssuerName, KGeneralStringMaxLength, |
282 &KIssuerName, KGeneralStringMaxLength, |
301 &KSerialNumber, KGeneralStringMaxLength, |
283 &KSerialNumber, KGeneralStringMaxLength, |
302 &KThumbprint, KThumbprintMaxLength); |
284 &KThumbprint, KThumbprintMaxLength); |
303 |
285 |
304 err = aDatabase.Execute(sqlStatement); |
286 error = aDatabase.Execute(sqlStatement); |
305 if (err != KErrNone && err != KErrAlreadyExists) |
287 if (error != KErrNone && error != KErrAlreadyExists) |
306 { |
288 { |
307 User::Leave(err); |
289 User::Leave(error); |
308 } |
290 } |
309 |
291 |
310 // Create table for _allowed_ CA certs |
292 // Create table for _allowed_ CA certs |
311 |
293 |
312 //// NAME ////////////////// TYPE ////////////// Constant /////////// |
294 //// NAME ////////////////// TYPE ////////////// Constant /////////// |
313 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
295 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
314 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
296 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
315 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
297 //| TunnelingTypeVendorId | UNSIGNED INTEGER | KTunnelingTypeVendorId |// |
316 //| CertLabel | VARCHAR(255) | KCACertLabel |// |
298 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
317 //| SubjectKeyId | BINARY(255) | KSubjectKeyIdentifier |// This is Symbian subjectkey id |
299 //| CertLabel | VARCHAR(255) | KCACertLabel |// |
318 //| ActualSubjectKeyId | BINARY(20) | KActualSubjectKeyIdentifier |// This is the actual subjectkeyid present in the certificate. |
300 //| SubjectKeyId | BINARY(255) | KSubjectKeyIdentifier |// This is Symbian subjectkey id |
319 //| SubjectName | VARCHAR(255) | KSubjectName |// |
301 //| ActualSubjectKeyId | BINARY(20) | KActualSubjectKeyIdentifier |// This is the actual subjectkeyid present in the certificate. |
320 //| IssuerName | VARCHAR(255) | KIssuerName |// |
302 //| SubjectName | VARCHAR(255) | KSubjectName |// |
321 //| SerialNumber | VARCHAR(255) | KSerialNumber |// |
303 //| IssuerName | VARCHAR(255) | KIssuerName |// |
322 //| Thumbprint | BINARY(64) | KThumbprint |// |
304 //| SerialNumber | VARCHAR(255) | KSerialNumber |// |
323 ////////////////////////////////////////////////////////////////////////////////////////////////////// |
305 //| Thumbprint | BINARY(64) | KThumbprint |// |
324 |
306 ////////////////////////////////////////////////////////////////////////////////////////////////////// |
325 _LIT(KSQLCreateTable3, "CREATE TABLE %S (%S UNSIGNED INTEGER, \ |
307 |
326 %S UNSIGNED INTEGER, \ |
308 _LIT(KSQLCreateTable3, "CREATE TABLE %S \ |
327 %S UNSIGNED INTEGER, \ |
309 (%S UNSIGNED INTEGER, \ |
328 %S VARCHAR(%d), \ |
310 %S UNSIGNED INTEGER, \ |
329 %S BINARY(%d), \ |
311 %S UNSIGNED INTEGER, \ |
330 %S BINARY(%d), \ |
312 %S UNSIGNED INTEGER, \ |
331 %S VARCHAR(%d), \ |
313 %S VARCHAR(%d), \ |
332 %S VARCHAR(%d), \ |
314 %S BINARY(%d), \ |
333 %S VARCHAR(%d), \ |
315 %S BINARY(%d), \ |
334 %S BINARY(%d))"); |
316 %S VARCHAR(%d), \ |
335 |
317 %S VARCHAR(%d), \ |
336 sqlStatement.Format(KSQLCreateTable3, &KTlsAllowedCACertsDatabaseTableName, |
318 %S VARCHAR(%d), \ |
|
319 %S BINARY(%d))"); |
|
320 |
|
321 sqlStatement.Format(KSQLCreateTable3, |
|
322 &KTlsAllowedCACertsDatabaseTableName, |
337 &KServiceType, |
323 &KServiceType, |
338 &KServiceIndex, |
324 &KServiceIndex, |
|
325 &KTunnelingTypeVendorId, |
339 &KTunnelingType, |
326 &KTunnelingType, |
340 &KCertLabel, KMaxCertLabelLengthInDB, |
327 &KCertLabel, KMaxCertLabelLengthInDB, |
341 &KSubjectKeyIdentifier, KMaxSubjectKeyIdLengthInDB, |
328 &KSubjectKeyIdentifier, KMaxSubjectKeyIdLengthInDB, |
342 &KActualSubjectKeyIdentifier, KKeyIdentifierLength, |
329 &KActualSubjectKeyIdentifier, KKeyIdentifierLength, |
343 &KSubjectName, KGeneralStringMaxLength, |
330 &KSubjectName, KGeneralStringMaxLength, |
344 &KIssuerName, KGeneralStringMaxLength, |
331 &KIssuerName, KGeneralStringMaxLength, |
345 &KSerialNumber, KGeneralStringMaxLength, |
332 &KSerialNumber, KGeneralStringMaxLength, |
346 &KThumbprint, KThumbprintMaxLength); |
333 &KThumbprint, KThumbprintMaxLength); |
347 |
334 |
348 err = aDatabase.Execute(sqlStatement); |
335 error = aDatabase.Execute(sqlStatement); |
349 if (err != KErrNone && err != KErrAlreadyExists) |
336 if (error != KErrNone && error != KErrAlreadyExists) |
350 { |
337 { |
351 User::Leave(err); |
338 User::Leave(error); |
352 } |
339 } |
353 |
340 |
354 // Create table for allowed cipher suites |
341 // Create table for allowed cipher suites |
355 |
342 |
356 //// NAME ///////////////// TYPE ////////////// Constant /////////// |
343 //// NAME ///////////////// TYPE ////////////// Constant /////////// |
357 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
344 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
358 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
345 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
359 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
346 //| TunnelingTypeVendorId | UNSIGNED INTEGER | KTunnelingTypeVendorId |// |
360 //| CipherSuite | UNSIGNED INTEGER | KCipherSuite |// |
347 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
361 ////////////////////////////////////////////////////////////////////////////////////////////////////// |
348 //| CipherSuite | UNSIGNED INTEGER | KCipherSuite |// |
362 |
349 ////////////////////////////////////////////////////////////////////////////////////////////////////// |
363 _LIT(KSQLCreateTable4, "CREATE TABLE %S (%S UNSIGNED INTEGER, \ |
350 |
364 %S UNSIGNED INTEGER, \ |
351 _LIT(KSQLCreateTable4, "CREATE TABLE %S \ |
365 %S UNSIGNED INTEGER, \ |
352 (%S UNSIGNED INTEGER, \ |
366 %S UNSIGNED INTEGER)"); |
353 %S UNSIGNED INTEGER, \ |
367 |
354 %S UNSIGNED INTEGER, \ |
368 sqlStatement.Format(KSQLCreateTable4, &KTlsAllowedCipherSuitesDatabaseTableName, |
355 %S UNSIGNED INTEGER, \ |
|
356 %S UNSIGNED INTEGER)"); |
|
357 |
|
358 sqlStatement.Format(KSQLCreateTable4, |
|
359 &KTlsAllowedCipherSuitesDatabaseTableName, |
369 &KServiceType, |
360 &KServiceType, |
370 &KServiceIndex, |
361 &KServiceIndex, |
|
362 &KTunnelingTypeVendorId, |
371 &KTunnelingType, |
363 &KTunnelingType, |
372 &KCipherSuite); |
364 &KCipherSuite); |
373 |
365 |
374 err = aDatabase.Execute(sqlStatement); |
366 error = aDatabase.Execute(sqlStatement); |
375 if (err != KErrNone && err != KErrAlreadyExists) |
367 if (error != KErrNone && error != KErrAlreadyExists) |
376 { |
368 { |
377 User::Leave(err); |
369 User::Leave(error); |
378 } |
370 } |
379 |
371 |
380 // 4. Check if database table contains a row for this service type and id |
372 // 4. Check if database table contains a row for this service type and id |
381 |
373 |
382 _LIT(KSQLQueryRow, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
374 _LIT(KSQLQueryRow, "SELECT %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d"); |
383 |
375 |
384 sqlStatement.Format(KSQLQueryRow, &cf_str_EAP_TLS_PEAP_cipher_suite_literal, &KTlsDatabaseTableName, |
376 sqlStatement.Format(KSQLQueryRow, |
385 &KServiceType, aIndexType, &KServiceIndex, aIndex, &KTunnelingType, aTunnelingVendorType); |
377 &cf_str_EAP_TLS_PEAP_cipher_suite_literal, |
|
378 &KTlsDatabaseTableName, |
|
379 &KServiceType, |
|
380 aIndexType, |
|
381 &KServiceIndex, |
|
382 aIndex, |
|
383 &KTunnelingTypeVendorId, |
|
384 aTunnelingType.get_vendor_id(), |
|
385 &KTunnelingType, |
|
386 aTunnelingType.get_vendor_type()); |
386 |
387 |
387 RDbView view; |
388 RDbView view; |
388 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
389 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
389 // View must be closed when no longer needed |
390 // View must be closed when no longer needed |
390 CleanupClosePushL(view); |
391 CleanupClosePushL(view); |
474 |
480 |
475 // For the table _allowed_ CA certificates |
481 // For the table _allowed_ CA certificates |
476 tableName = KTlsAllowedCACertsDatabaseTableName; |
482 tableName = KTlsAllowedCACertsDatabaseTableName; |
477 AddExtraCertColumnsL(aDatabase,tableName); |
483 AddExtraCertColumnsL(aDatabase,tableName); |
478 |
484 |
479 CleanupStack::PopAndDestroy( buf ); // Delete buf or sqlStatement |
485 |
480 CleanupStack::Pop( &aDatabase ); |
|
481 CleanupStack::Pop( &aSession ); |
|
482 |
|
483 aDatabase.Compact(); |
486 aDatabase.Compact(); |
|
487 |
|
488 CleanupStack::PopAndDestroy( buf ); |
|
489 CleanupStack::Pop( &aDatabase ); |
|
490 CleanupStack::Pop( &aFileServerSession ); |
484 } |
491 } |
485 |
492 |
|
493 // --------------------------------------------------------- |
|
494 |
486 void EapTlsPeapUtils::OpenPeapDatabaseL( |
495 void EapTlsPeapUtils::OpenPeapDatabaseL( |
487 RDbNamedDatabase& aDatabase, |
496 RDbNamedDatabase& aDatabase, |
488 RDbs& aSession, |
497 RFs& aFileServerSession, |
489 const TIndexType aIndexType, |
498 const TIndexType aIndexType, |
490 const TInt aIndex, |
499 const TInt aIndex, |
491 const eap_type_value_e aTunnelingType) |
500 const eap_type_value_e aTunnelingType) |
492 { |
501 { |
493 #ifdef USE_EAP_EXPANDED_TYPES |
|
494 |
|
495 TUint aTunnelingVendorType = aTunnelingType.get_vendor_type(); |
|
496 |
|
497 #else |
|
498 |
|
499 TUint aTunnelingVendorType = static_cast<TUint>(aTunnelingType); |
|
500 |
|
501 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
|
502 |
|
503 EAP_TRACE_DEBUG_SYMBIAN( |
502 EAP_TRACE_DEBUG_SYMBIAN( |
504 (_L("EapTlsPeapUtils::OpenPeapDatabaseL -Start- aIndexType=%d, aIndex=%d, Tunneling vendor type=%d \n"), |
503 (_L("EapTlsPeapUtils::OpenPeapDatabaseL(): - Start - aIndexType=%d, aIndex=%d, aTunnelingType=0xfe%06x%08x\n"), |
505 aIndexType,aIndex, aTunnelingVendorType)); |
504 aIndexType, |
|
505 aIndex, |
|
506 aTunnelingType.get_vendor_id(), |
|
507 aTunnelingType.get_vendor_type())); |
|
508 |
|
509 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: EapTlsPeapUtils::OpenPeapDatabaseL()\n")); |
506 |
510 |
507 // 1. Open/create a database |
511 // 1. Open/create a database |
508 |
512 |
509 // Connect to the DBMS server. |
513 TInt error(KErrNone); |
510 User::LeaveIfError(aSession.Connect()); |
514 TFileName aPrivateDatabasePathName; |
511 CleanupClosePushL(aSession); |
515 |
512 // aSession and aDatabase are pushed to the cleanup stack even though they may be member |
516 EapPluginTools::CreateDatabaseLC( |
513 // variables of the calling class and would be closed in the destructor anyway. This ensures |
517 aDatabase, |
514 // that if they are not member variables they will be closed. Closing the handle twice |
518 aFileServerSession, |
515 // does no harm. |
519 error, |
516 |
520 KPeapDatabaseName, |
517 #ifdef SYMBIAN_SECURE_DBMS |
521 aPrivateDatabasePathName); |
518 |
522 |
519 // Create the secure shared database with the specified secure policy. |
523 if(error == KErrNone) |
520 // Database will be created in the data caging path for DBMS (C:\private\100012a5). |
|
521 |
|
522 TInt err = aDatabase.Create(aSession, KPeapDatabaseName, KSecureUIDFormat); |
|
523 |
|
524 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenPeapDatabaseL - Created Secure DB for eappeap.dat. err=%d\n"), err) ); |
|
525 |
|
526 if(err == KErrNone) |
|
527 { |
524 { |
528 aDatabase.Close(); |
525 aDatabase.Close(); |
529 |
526 } |
530 } else if (err != KErrAlreadyExists) |
527 else if (error != KErrAlreadyExists) |
531 { |
528 { |
532 User::LeaveIfError(err); |
529 User::LeaveIfError(error); |
533 } |
530 } |
534 |
531 |
535 User::LeaveIfError(aDatabase.Open(aSession, KPeapDatabaseName, KSecureUIDFormat)); |
532 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenPeapDatabaseL(): - calls aDatabase.Open()\n"))); |
536 CleanupClosePushL(aDatabase); |
533 |
537 |
534 error = aDatabase.Open(aFileServerSession, aPrivateDatabasePathName); |
538 #else |
535 |
539 // For non-secured database. The database will be created in the old location (c:\system\data). |
536 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenPeapDatabaseL(): - Opened private DB for EAP-PEAP. error=%d\n"), error)); |
540 |
537 |
541 RFs fsSession; |
538 User::LeaveIfError(error); |
542 User::LeaveIfError(fsSession.Connect()); |
|
543 CleanupClosePushL(fsSession); |
|
544 TInt err = aDatabase.Create(fsSession, KPeapDatabaseName); |
|
545 |
|
546 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenPeapDatabaseL - Created Non-Secure DB for eappeap.dat. err=%d\n"), err) ); |
|
547 |
|
548 if(err == KErrNone) |
|
549 { |
|
550 aDatabase.Close(); |
|
551 |
|
552 } else if (err != KErrAlreadyExists) |
|
553 { |
|
554 User::LeaveIfError(err); |
|
555 } |
|
556 |
|
557 User::LeaveIfError(aDatabase.Open(fsSession, KPeapDatabaseName)); |
|
558 |
|
559 CleanupStack::PopAndDestroy(); // close fsSession |
|
560 |
|
561 CleanupClosePushL(aDatabase); |
|
562 |
|
563 #endif // #ifdef SYMBIAN_SECURE_DBMS |
|
564 |
539 |
565 // 2. Create the eappeap table to database (ignore error if exists) |
540 // 2. Create the eappeap table to database (ignore error if exists) |
566 |
541 |
567 // Table columns: |
542 // Table columns: |
568 //// NAME /////////////////////////////////////////////// TYPE ////////////// Constant /////////////////// |
543 //// NAME /////////////////////////////////////////////// TYPE ////////////// Constant /////////////////// |
569 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
544 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
570 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
545 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
571 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
546 //| TunnelingTypeVendorId | UNSIGNED INTEGER | KTunnelingTypeVendorId |// |
572 //| EAP_TLS_PEAP_use_manual_realm | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_use_manual_realm_literal |// |
547 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
573 //| EAP_TLS_PEAP_manual_realm | VARCHAR(255) | cf_str_EAP_TLS_PEAP_manual_realm_literal |// |
548 //| EAP_TLS_PEAP_use_manual_realm | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_use_manual_realm_literal |// |
574 //| EAP_TLS_PEAP_use_manual_username | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_use_manual_username_literal |// |
549 //| EAP_TLS_PEAP_manual_realm | VARCHAR(255) | cf_str_EAP_TLS_PEAP_manual_realm_literal |// |
575 //| EAP_TLS_PEAP_manual_username | VARCHAR(255) | cf_str_EAP_TLS_PEAP_manual_username_literal |// |
550 //| EAP_TLS_PEAP_use_manual_username | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_use_manual_username_literal |// |
576 //| EAP_TLS_PEAP_max_count_of_session_resumes | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_max_count_of_session_resumes_literal |// |
551 //| EAP_TLS_PEAP_manual_username | VARCHAR(255) | cf_str_EAP_TLS_PEAP_manual_username_literal |// |
577 //| EAP_TLS_PEAP_cipher_suite | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_cipher_suite_literal |// |
552 //| EAP_TLS_PEAP_max_count_of_session_resumes | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_max_count_of_session_resumes_literal |// |
578 //| EAP_TLS_PEAP_used_PEAP_version | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_used_PEAP_version_literal |// |
553 //| EAP_TLS_PEAP_cipher_suite | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_cipher_suite_literal |// |
579 //| EAP_TLS_PEAP_accepted_PEAP_versions | BINARY(12) | cf_str_EAP_TLS_PEAP_accepted_PEAP_versions_literal|// |
554 //| EAP_TLS_PEAP_used_PEAP_version | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_used_PEAP_version_literal |// |
580 //| PEAP_accepted_tunneled_client_types | VARBINARY(240) | cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal |// |
555 //| EAP_TLS_PEAP_accepted_PEAP_versions | BINARY(12) | cf_str_EAP_TLS_PEAP_accepted_PEAP_versions_literal|// |
581 //| PEAP_unaccepted_tunneled_client_types | VARBINARY(240) | cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal |// |
556 //| PEAP_accepted_tunneled_client_types | VARBINARY(240) | cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal |// |
582 //| EAP_TLS_server_authenticates_client | UNSIGNED INTEGER | cf_str_TLS_server_authenticates_client_policy_in_client_literal|// |
557 //| PEAP_unaccepted_tunneled_client_types | VARBINARY(240) | cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal |// |
583 //| CA_cert_label | VARCHAR(255) | KCACertLabelOld |// |
558 //| EAP_TLS_server_authenticates_client | UNSIGNED INTEGER | cf_str_TLS_server_authenticates_client_policy_in_client_literal|// |
584 //| client_cert_label | VARCHAR(255) | KClientCertLabel |// |
559 //| CA_cert_label | VARCHAR(255) | KCACertLabel |// |
585 //| EAP_TLS_PEAP_saved_session_id | BINARY(32) | cf_str_EAP_TLS_PEAP_saved_session_id_literal |// |
560 //| client_cert_label | VARCHAR(255) | KClientCertLabel |// |
586 //| EAP_TLS_PEAP_saved_master_secret | BINARY(48) | cf_str_EAP_TLS_PEAP_saved_master_secret_literal |// |
561 //| EAP_TLS_PEAP_saved_session_id | BINARY(32) | cf_str_EAP_TLS_PEAP_saved_session_id_literal |// |
587 //| EAP_TLS_PEAP_saved_cipher_suite | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_saved_cipher_suite_literal |// |
562 //| EAP_TLS_PEAP_saved_master_secret | BINARY(48) | cf_str_EAP_TLS_PEAP_saved_master_secret_literal |// |
588 //| EAP_TLS_PEAP_verify_certificate_realm | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_verify_certificate_realm_literal |// |
563 //| EAP_TLS_PEAP_saved_cipher_suite | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_saved_cipher_suite_literal |// |
589 //| EAP_PEAP_max_session_validity_time | BIGINT | cf_str_EAP_PEAP_max_session_validity_time_literal |// |
564 //| EAP_TLS_PEAP_verify_certificate_realm | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_verify_certificate_realm_literal |// |
590 //| EAP_PEAP_last_full_authentication_time | BIGINT | KPEAPLastFullAuthTime |// |
565 //| EAP_PEAP_max_session_validity_time | BIGINT | cf_str_EAP_PEAP_max_session_validity_time_literal |// |
591 //| EAP_TLS_PEAP_use_identity_privacy | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_use_identity_privacy_literal|// |
566 //| EAP_PEAP_last_full_authentication_time | BIGINT | KPEAPLastFullAuthTime |// |
592 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
567 //| EAP_TLS_PEAP_use_identity_privacy | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_use_identity_privacy_literal|// |
|
568 //| EAP_TLS_PEAP_use_automatic_ca_certificate | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_use_automatic_ca_certificate_literal|// |
|
569 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
593 |
570 |
594 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
571 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
595 TPtr sqlStatement = buf->Des(); |
572 TPtr sqlStatement = buf->Des(); |
596 |
573 |
597 // Table creation is divided into two parts because otherwise the SQL string would get too long |
574 // Table creation is divided into two parts because otherwise the SQL string would get too long |
598 _LIT(KSQLCreateTable1, "CREATE TABLE %S (%S UNSIGNED INTEGER, \ |
575 _LIT(KSQLCreateTable1, "CREATE TABLE %S \ |
599 %S UNSIGNED INTEGER, \ |
576 (%S UNSIGNED INTEGER, \ |
600 %S UNSIGNED INTEGER, \ |
577 %S UNSIGNED INTEGER, \ |
601 %S UNSIGNED INTEGER, \ |
578 %S UNSIGNED INTEGER, \ |
602 %S VARCHAR(%d), \ |
579 %S UNSIGNED INTEGER, \ |
603 %S UNSIGNED INTEGER, \ |
580 %S UNSIGNED INTEGER, \ |
604 %S VARCHAR(%d), \ |
581 %S VARCHAR(%d), \ |
605 %S UNSIGNED INTEGER, \ |
582 %S UNSIGNED INTEGER, \ |
606 %S UNSIGNED INTEGER, \ |
583 %S VARCHAR(%d), \ |
607 %S BINARY(%d), \ |
584 %S UNSIGNED INTEGER, \ |
608 %S VARBINARY(%d), \ |
585 %S UNSIGNED INTEGER, \ |
609 %S VARBINARY(%d), \ |
586 %S BINARY(%d), \ |
610 %S UNSIGNED INTEGER, \ |
587 %S VARBINARY(%d), \ |
611 %S VARCHAR(%d), \ |
588 %S VARBINARY(%d), \ |
612 %S VARCHAR(%d), \ |
589 %S UNSIGNED INTEGER, \ |
613 %S BINARY(%d), \ |
590 %S VARCHAR(%d), \ |
614 %S BINARY(%d), \ |
591 %S VARCHAR(%d), \ |
615 %S UNSIGNED INTEGER, \ |
592 %S BINARY(%d), \ |
616 %S UNSIGNED INTEGER, \ |
593 %S BINARY(%d), \ |
617 %S BIGINT, \ |
594 %S UNSIGNED INTEGER, \ |
618 %S BIGINT, \ |
595 %S UNSIGNED INTEGER, \ |
619 %S UNSIGNED INTEGER)"); |
596 %S BIGINT, \ |
|
597 %S BIGINT, \ |
|
598 %S UNSIGNED INTEGER, \ |
|
599 %S UNSIGNED INTEGER)"); |
|
600 |
620 sqlStatement.Format(KSQLCreateTable1, |
601 sqlStatement.Format(KSQLCreateTable1, |
621 &KPeapDatabaseTableName, |
602 &KPeapDatabaseTableName, |
622 &KServiceType, |
603 &KServiceType, |
623 &KServiceIndex, |
604 &KServiceIndex, |
|
605 &KTunnelingTypeVendorId, |
624 &KTunnelingType, |
606 &KTunnelingType, |
625 &cf_str_EAP_TLS_PEAP_use_manual_realm_literal, |
607 &cf_str_EAP_TLS_PEAP_use_manual_realm_literal, |
626 &cf_str_EAP_TLS_PEAP_manual_realm_literal, KMaxManualRealmLengthInDB, |
608 &cf_str_EAP_TLS_PEAP_manual_realm_literal, KMaxRealmLengthInDB, |
627 &cf_str_EAP_TLS_PEAP_use_manual_username_literal, |
609 &cf_str_EAP_TLS_PEAP_use_manual_username_literal, |
628 &cf_str_EAP_TLS_PEAP_manual_username_literal, KMaxManualUsernameLengthInDB, |
610 &cf_str_EAP_TLS_PEAP_manual_username_literal, KMaxUsernameLengthInDB, |
629 &cf_str_EAP_TLS_PEAP_cipher_suite_literal, |
611 &cf_str_EAP_TLS_PEAP_cipher_suite_literal, |
630 &cf_str_EAP_TLS_PEAP_used_PEAP_version_literal, |
612 &cf_str_EAP_TLS_PEAP_used_PEAP_version_literal, |
631 &cf_str_EAP_TLS_PEAP_accepted_PEAP_versions_literal, KMaxPEAPVersionsStringLengthInDB, |
613 &cf_str_EAP_TLS_PEAP_accepted_PEAP_versions_literal, KMaxPEAPVersionsStringLengthInDB, |
632 &cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal, KMaxTunneledTypeStringLengthInDB, |
614 &cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal, KMaxTunneledTypeStringLengthInDB, |
633 &cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal, KMaxTunneledTypeStringLengthInDB, |
615 &cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal, KMaxTunneledTypeStringLengthInDB, |
634 &cf_str_TLS_server_authenticates_client_policy_in_client_literal, |
616 &cf_str_TLS_server_authenticates_client_policy_in_client_literal, |
635 &KCACertLabelOld, KMaxCertLabelLengthInDB, |
617 &KCACertLabel, KMaxCertLabelLengthInDB, |
636 &KClientCertLabel, KMaxCertLabelLengthInDB, |
618 &KClientCertLabel, KMaxCertLabelLengthInDB, |
637 &cf_str_EAP_TLS_PEAP_saved_session_id_literal, KMaxSessionIdLengthInDB, |
619 &cf_str_EAP_TLS_PEAP_saved_session_id_literal, KMaxSessionIdLengthInDB, |
638 &cf_str_EAP_TLS_PEAP_saved_master_secret_literal, KMaxMasterSecretLengthInDB, |
620 &cf_str_EAP_TLS_PEAP_saved_master_secret_literal, KMaxMasterSecretLengthInDB, |
639 &cf_str_EAP_TLS_PEAP_saved_cipher_suite_literal, |
621 &cf_str_EAP_TLS_PEAP_saved_cipher_suite_literal, |
640 &cf_str_EAP_TLS_PEAP_verify_certificate_realm_literal, |
622 &cf_str_EAP_TLS_PEAP_verify_certificate_realm_literal, |
641 &cf_str_EAP_PEAP_max_session_validity_time_literal, |
623 &cf_str_EAP_PEAP_max_session_validity_time_literal, |
642 &KPEAPLastFullAuthTime, |
624 &KPEAPLastFullAuthTime, |
643 &cf_str_EAP_TLS_PEAP_use_identity_privacy_literal); |
625 &cf_str_EAP_TLS_PEAP_use_identity_privacy_literal, |
|
626 &cf_str_EAP_TLS_PEAP_use_automatic_ca_certificate_literal); |
644 |
627 |
645 err = aDatabase.Execute(sqlStatement); |
628 error = aDatabase.Execute(sqlStatement); |
646 if (err == KErrAlreadyExists) |
629 if (error == KErrAlreadyExists) |
647 { |
630 { |
648 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenPeapDatabaseL - Alter Table err=%d\n"), err) ); |
631 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenPeapDatabaseL - Alter Table error=%d\n"), error) ); |
649 _LIT( KColumnDef, "UNSIGNED INTEGER" ); |
632 _LIT( KColumnDef, "UNSIGNED INTEGER" ); |
650 AlterTableL( aDatabase, EAddColumn , KPeapDatabaseTableName, |
633 AlterTableL( aDatabase, EAddColumn , KPeapDatabaseTableName, |
651 cf_str_EAP_TLS_PEAP_use_identity_privacy_literal, KColumnDef); |
634 cf_str_EAP_TLS_PEAP_use_identity_privacy_literal, KColumnDef); |
652 } |
635 } |
653 else if (err != KErrNone) |
636 else if (error != KErrNone) |
654 { |
637 { |
655 User::Leave(err); |
638 User::Leave(error); |
656 } |
639 } |
657 |
640 |
658 // Create table for _allowed_ user certificates |
641 // Create table for _allowed_ user certificates |
659 |
642 |
660 //// NAME ////////////////// TYPE ////////////// Constant /////////// |
643 //// NAME ////////////////// TYPE ////////////// Constant /////////// |
661 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
644 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
662 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
645 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
663 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
646 //| TunnelingTypeVendorId | UNSIGNED INTEGER | KTunnelingTypeVendorId |// |
664 //| CertLabel | VARCHAR(255) | KCACertLabel |// |
647 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
665 //| SubjectKeyId | BINARY(20) | KSubjectKeyIdentifier |// This is Symbian subjectkey id |
648 //| CertLabel | VARCHAR(255) | KCACertLabel |// |
666 //| ActualSubjectKeyId | BINARY(20) | KActualSubjectKeyIdentifier |// This is the actual subjectkeyid present in the certificate. |
649 //| SubjectKeyId | BINARY(20) | KSubjectKeyIdentifier |// This is Symbian subjectkey id |
667 //| SubjectName | VARCHAR(255) | KSubjectName |// |
650 //| ActualSubjectKeyId | BINARY(20) | KActualSubjectKeyIdentifier |// This is the actual subjectkeyid present in the certificate. |
668 //| IssuerName | VARCHAR(255) | KIssuerName |// |
651 //| SubjectName | VARCHAR(255) | KSubjectName |// |
669 //| SerialNumber | VARCHAR(255) | KSerialNumber |// |
652 //| IssuerName | VARCHAR(255) | KIssuerName |// |
670 //| Thumbprint | BINARY(64) | KThumbprint |// |
653 //| SerialNumber | VARCHAR(255) | KSerialNumber |// |
671 ////////////////////////////////////////////////////////////////////////////////////////////////////// |
654 //| Thumbprint | BINARY(64) | KThumbprint |// |
672 |
655 ////////////////////////////////////////////////////////////////////////////////////////////////////// |
673 _LIT(KSQLCreateTable2, "CREATE TABLE %S (%S UNSIGNED INTEGER, \ |
656 |
674 %S UNSIGNED INTEGER, \ |
657 _LIT(KSQLCreateTable2, "CREATE TABLE %S \ |
675 %S UNSIGNED INTEGER, \ |
658 (%S UNSIGNED INTEGER, \ |
676 %S VARCHAR(%d), \ |
659 %S UNSIGNED INTEGER, \ |
677 %S BINARY(%d), \ |
660 %S UNSIGNED INTEGER, \ |
678 %S BINARY(%d), \ |
661 %S UNSIGNED INTEGER, \ |
679 %S VARCHAR(%d), \ |
662 %S VARCHAR(%d), \ |
680 %S VARCHAR(%d), \ |
663 %S BINARY(%d), \ |
681 %S VARCHAR(%d), \ |
664 %S BINARY(%d), \ |
682 %S BINARY(%d))"); |
665 %S VARCHAR(%d), \ |
683 |
666 %S VARCHAR(%d), \ |
684 sqlStatement.Format(KSQLCreateTable2, &KPeapAllowedUserCertsDatabaseTableName, |
667 %S VARCHAR(%d), \ |
|
668 %S BINARY(%d))"); |
|
669 |
|
670 sqlStatement.Format(KSQLCreateTable2, |
|
671 &KPeapAllowedUserCertsDatabaseTableName, |
685 &KServiceType, |
672 &KServiceType, |
686 &KServiceIndex, |
673 &KServiceIndex, |
|
674 &KTunnelingTypeVendorId, |
687 &KTunnelingType, |
675 &KTunnelingType, |
688 &KCertLabel, KMaxCertLabelLengthInDB, |
676 &KCertLabel, KMaxCertLabelLengthInDB, |
689 &KSubjectKeyIdentifier, KMaxSubjectKeyIdLengthInDB, |
677 &KSubjectKeyIdentifier, KMaxSubjectKeyIdLengthInDB, |
690 &KActualSubjectKeyIdentifier, KKeyIdentifierLength, |
678 &KActualSubjectKeyIdentifier, KKeyIdentifierLength, |
691 &KSubjectName, KGeneralStringMaxLength, |
679 &KSubjectName, KGeneralStringMaxLength, |
692 &KIssuerName, KGeneralStringMaxLength, |
680 &KIssuerName, KGeneralStringMaxLength, |
693 &KSerialNumber, KGeneralStringMaxLength, |
681 &KSerialNumber, KGeneralStringMaxLength, |
694 &KThumbprint, KThumbprintMaxLength); |
682 &KThumbprint, KThumbprintMaxLength); |
695 |
683 |
696 err = aDatabase.Execute(sqlStatement); |
684 error = aDatabase.Execute(sqlStatement); |
697 if (err != KErrNone && err != KErrAlreadyExists) |
685 if (error != KErrNone && error != KErrAlreadyExists) |
698 { |
686 { |
699 User::Leave(err); |
687 User::Leave(error); |
700 } |
688 } |
701 |
689 |
702 // Create table for _allowed_ CA certs |
690 // Create table for _allowed_ CA certs |
703 |
691 |
704 //// NAME ////////////////// TYPE ////////////// Constant /////////// |
692 //// NAME ////////////////// TYPE ////////////// Constant /////////// |
705 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
693 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
706 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
694 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
707 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
695 //| TunnelingTypeVendorId | UNSIGNED INTEGER | KTunnelingTypeVendorId |// |
708 //| CACertLabel | VARCHAR(255) | KCACertLabel |// |
696 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
709 //| SubjectKeyId | BINARY(20) | KSubjectKeyIdentifier |// This is Symbian subjectkey id |
697 //| CACertLabel | VARCHAR(255) | KCACertLabel |// |
710 //| ActualSubjectKeyId | BINARY(20) | KActualSubjectKeyIdentifier |// This is the actual subjectkeyid present in the certificate. |
698 //| SubjectKeyId | BINARY(20) | KSubjectKeyIdentifier |// This is Symbian subjectkey id |
711 //| SubjectName | VARCHAR(255) | KSubjectName |// |
699 //| ActualSubjectKeyId | BINARY(20) | KActualSubjectKeyIdentifier |// This is the actual subjectkeyid present in the certificate. |
712 //| IssuerName | VARCHAR(255) | KIssuerName |// |
700 //| SubjectName | VARCHAR(255) | KSubjectName |// |
713 //| SerialNumber | VARCHAR(255) | KSerialNumber |// |
701 //| IssuerName | VARCHAR(255) | KIssuerName |// |
714 //| Thumbprint | BINARY(64) | KThumbprint |// |
702 //| SerialNumber | VARCHAR(255) | KSerialNumber |// |
715 ////////////////////////////////////////////////////////////////////////////////////////////////////// |
703 //| Thumbprint | BINARY(64) | KThumbprint |// |
716 |
704 ////////////////////////////////////////////////////////////////////////////////////////////////////// |
717 _LIT(KSQLCreateTable3, "CREATE TABLE %S (%S UNSIGNED INTEGER, \ |
705 |
718 %S UNSIGNED INTEGER, \ |
706 _LIT(KSQLCreateTable3, "CREATE TABLE %S \ |
719 %S UNSIGNED INTEGER, \ |
707 (%S UNSIGNED INTEGER, \ |
720 %S VARCHAR(%d), \ |
708 %S UNSIGNED INTEGER, \ |
721 %S BINARY(%d), \ |
709 %S UNSIGNED INTEGER, \ |
722 %S BINARY(%d), \ |
710 %S UNSIGNED INTEGER, \ |
723 %S VARCHAR(%d), \ |
711 %S VARCHAR(%d), \ |
724 %S VARCHAR(%d), \ |
712 %S BINARY(%d), \ |
725 %S VARCHAR(%d), \ |
713 %S BINARY(%d), \ |
726 %S BINARY(%d))"); |
714 %S VARCHAR(%d), \ |
|
715 %S VARCHAR(%d), \ |
|
716 %S VARCHAR(%d), \ |
|
717 %S BINARY(%d))"); |
727 |
718 |
728 sqlStatement.Format(KSQLCreateTable3, &KPeapAllowedCACertsDatabaseTableName, |
719 sqlStatement.Format(KSQLCreateTable3, |
|
720 &KPeapAllowedCACertsDatabaseTableName, |
729 &KServiceType, |
721 &KServiceType, |
730 &KServiceIndex, |
722 &KServiceIndex, |
|
723 &KTunnelingTypeVendorId, |
731 &KTunnelingType, |
724 &KTunnelingType, |
732 &KCertLabel, KMaxCertLabelLengthInDB, |
725 &KCertLabel, KMaxCertLabelLengthInDB, |
733 &KSubjectKeyIdentifier, KMaxSubjectKeyIdLengthInDB, |
726 &KSubjectKeyIdentifier, KMaxSubjectKeyIdLengthInDB, |
734 &KActualSubjectKeyIdentifier, KKeyIdentifierLength, |
727 &KActualSubjectKeyIdentifier, KKeyIdentifierLength, |
735 &KSubjectName, KGeneralStringMaxLength, |
728 &KSubjectName, KGeneralStringMaxLength, |
736 &KIssuerName, KGeneralStringMaxLength, |
729 &KIssuerName, KGeneralStringMaxLength, |
737 &KSerialNumber, KGeneralStringMaxLength, |
730 &KSerialNumber, KGeneralStringMaxLength, |
738 &KThumbprint, KThumbprintMaxLength); |
731 &KThumbprint, KThumbprintMaxLength); |
739 |
732 |
740 err = aDatabase.Execute(sqlStatement); |
733 error = aDatabase.Execute(sqlStatement); |
741 if (err != KErrNone && err != KErrAlreadyExists) |
734 if (error != KErrNone && error != KErrAlreadyExists) |
742 { |
735 { |
743 User::Leave(err); |
736 User::Leave(error); |
744 } |
737 } |
745 |
738 |
746 // Create table for _allowed_ cipher suites |
739 // Create table for _allowed_ cipher suites |
747 |
740 |
748 //// NAME ///////////////// TYPE ////////////// Constant /////////// |
741 //// NAME ///////////////////// TYPE ////////////// Constant /////////// |
749 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
742 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
750 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
743 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
751 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
744 //| TunnelingTypeVendorId | UNSIGNED INTEGER | KTunnelingTypeVendorId |// |
752 //| CipherSuite | UNSIGNED INTEGER | KCipherSuite |// |
745 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
753 ////////////////////////////////////////////////////////////////////////////////////////////////////// |
746 //| CipherSuite | UNSIGNED INTEGER | KCipherSuite |// |
754 |
747 ////////////////////////////////////////////////////////////////////////////////////////////////////// |
755 _LIT(KSQLCreateTable4, "CREATE TABLE %S (%S UNSIGNED INTEGER, \ |
748 |
756 %S UNSIGNED INTEGER, \ |
749 _LIT(KSQLCreateTable4, "CREATE TABLE %S \ |
757 %S UNSIGNED INTEGER, \ |
750 (%S UNSIGNED INTEGER, \ |
758 %S UNSIGNED INTEGER)"); |
751 %S UNSIGNED INTEGER, \ |
759 |
752 %S UNSIGNED INTEGER, \ |
760 sqlStatement.Format(KSQLCreateTable4, &KPeapAllowedCipherSuitesDatabaseTableName, |
753 %S UNSIGNED INTEGER, \ |
761 &KServiceType, &KServiceIndex, &KTunnelingType, &KCipherSuite); |
754 %S UNSIGNED INTEGER)"); |
762 err = aDatabase.Execute(sqlStatement); |
755 |
763 if (err != KErrNone && err != KErrAlreadyExists) |
756 sqlStatement.Format(KSQLCreateTable4, |
764 { |
757 &KPeapAllowedCipherSuitesDatabaseTableName, |
765 User::Leave(err); |
758 &KServiceType, |
|
759 &KServiceIndex, |
|
760 &KTunnelingTypeVendorId, |
|
761 &KTunnelingType, |
|
762 &KCipherSuite); |
|
763 |
|
764 error = aDatabase.Execute(sqlStatement); |
|
765 if (error != KErrNone && error != KErrAlreadyExists) |
|
766 { |
|
767 User::Leave(error); |
766 } |
768 } |
767 |
769 |
768 // 4. Check if database table contains a row for this service type and id |
770 // 4. Check if database table contains a row for this service type and id |
769 |
771 |
770 _LIT(KSQLQueryRow, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
772 _LIT(KSQLQueryRow, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d"); |
771 |
773 |
772 sqlStatement.Format(KSQLQueryRow, &KPeapDatabaseTableName, |
774 sqlStatement.Format(KSQLQueryRow, |
773 &KServiceType, aIndexType, &KServiceIndex, aIndex, &KTunnelingType, aTunnelingVendorType); |
775 &KPeapDatabaseTableName, |
774 |
776 &KServiceType, |
|
777 aIndexType, |
|
778 &KServiceIndex, |
|
779 aIndex, |
|
780 &KTunnelingTypeVendorId, |
|
781 aTunnelingType.get_vendor_id(), |
|
782 &KTunnelingType, |
|
783 aTunnelingType.get_vendor_type()); |
|
784 |
775 RDbView view; |
785 RDbView view; |
776 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
786 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
777 // View must be closed when no longer needed |
787 // View must be closed when no longer needed |
778 CleanupClosePushL(view); |
788 CleanupClosePushL(view); |
779 User::LeaveIfError(view.EvaluateAll()); |
789 User::LeaveIfError(view.EvaluateAll()); |
780 |
790 |
781 // 5. If row is not found then add it |
791 // 5. If row is not found then add it |
782 |
792 |
783 TInt rows = view.CountL(); |
793 TInt rows = view.CountL(); |
784 CleanupStack::PopAndDestroy(); // view |
794 CleanupStack::PopAndDestroy(); // view |
785 if (rows == 0) |
795 if (rows == 0) |
786 { |
796 { |
787 _LIT(KSQLInsert, "SELECT * FROM %S"); |
797 _LIT(KSQLInsert, "SELECT * FROM %S"); |
880 |
894 |
881 // For the table _allowed_ CA certificates |
895 // For the table _allowed_ CA certificates |
882 tableName = KPeapAllowedCACertsDatabaseTableName; |
896 tableName = KPeapAllowedCACertsDatabaseTableName; |
883 AddExtraCertColumnsL(aDatabase,tableName); |
897 AddExtraCertColumnsL(aDatabase,tableName); |
884 |
898 |
885 CleanupStack::PopAndDestroy( buf ); // Delete buf or sqlStatement |
|
886 CleanupStack::Pop( &aDatabase ); |
|
887 CleanupStack::Pop( &aSession ); |
|
888 |
|
889 aDatabase.Compact(); |
899 aDatabase.Compact(); |
|
900 |
|
901 CleanupStack::PopAndDestroy( buf ); |
|
902 CleanupStack::Pop( &aDatabase ); |
|
903 CleanupStack::Pop( &aFileServerSession ); |
890 } |
904 } |
891 |
905 |
892 #if defined(USE_TTLS_EAP_TYPE) |
906 #if defined(USE_TTLS_EAP_TYPE) |
893 |
907 |
894 // --------------------------------------------------------- |
908 // --------------------------------------------------------- |
895 // EapTlsPeapUtils::OpenTtlsDatabaseL() |
909 // EapTlsPeapUtils::OpenTtlsDatabaseL() |
896 // --------------------------------------------------------- |
910 // --------------------------------------------------------- |
897 // |
911 // |
898 void EapTlsPeapUtils::OpenTtlsDatabaseL( |
912 void EapTlsPeapUtils::OpenTtlsDatabaseL( |
899 RDbNamedDatabase& aDatabase, |
913 RDbNamedDatabase& aDatabase, |
900 RDbs& aSession, |
914 RFs& aFileServerSession, |
901 const TIndexType aIndexType, |
915 const TIndexType aIndexType, |
902 const TInt aIndex, |
916 const TInt aIndex, |
903 const eap_type_value_e aTunnelingType) |
917 const eap_type_value_e aTunnelingType) |
904 { |
918 { |
905 #ifdef USE_EAP_EXPANDED_TYPES |
|
906 |
|
907 TUint aTunnelingVendorType = aTunnelingType.get_vendor_type(); |
|
908 |
|
909 #else |
|
910 |
|
911 TUint aTunnelingVendorType = static_cast<TUint>(aTunnelingType); |
|
912 |
|
913 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
|
914 |
|
915 EAP_TRACE_DEBUG_SYMBIAN( |
919 EAP_TRACE_DEBUG_SYMBIAN( |
916 (_L("EapTlsPeapUtils::OpenTtlsDatabaseL -Start- aIndexType=%d, aIndex=%d, Tunneling vendor type=%d \n"), |
920 (_L("EapTlsPeapUtils::OpenTtlsDatabaseL(): - Start - aIndexType=%d, aIndex=%d, aTunnelingType=0xfe%06x%08x\n"), |
917 aIndexType,aIndex, aTunnelingVendorType)); |
921 aIndexType, |
|
922 aIndex, |
|
923 aTunnelingType.get_vendor_id(), |
|
924 aTunnelingType.get_vendor_type())); |
|
925 |
|
926 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: EapTlsPeapUtils::OpenTtlsDatabaseL()\n")); |
918 |
927 |
919 // 1. Open/create a database |
928 // 1. Open/create a database |
920 |
929 |
921 // Connect to the DBMS server. |
930 TInt error(KErrNone); |
922 User::LeaveIfError(aSession.Connect()); |
931 TFileName aPrivateDatabasePathName; |
923 CleanupClosePushL(aSession); |
932 |
924 // aSession and aDatabase are pushed to the cleanup stack even though they may be member |
933 EapPluginTools::CreateDatabaseLC( |
925 // variables of the calling class and would be closed in the destructor anyway. This ensures |
934 aDatabase, |
926 // that if they are not member variables they will be closed. Closing the handle twice |
935 aFileServerSession, |
927 // does no harm. |
936 error, |
928 |
937 KTtlsDatabaseName, |
929 #ifdef SYMBIAN_SECURE_DBMS |
938 aPrivateDatabasePathName); |
930 |
939 |
931 // Create the secure shared database with the specified secure policy. |
940 if(error == KErrNone) |
932 // Database will be created in the data caging path for DBMS (C:\private\100012a5). |
|
933 |
|
934 TInt err = aDatabase.Create(aSession, KTtlsDatabaseName, KSecureUIDFormat); |
|
935 |
|
936 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenTtlsDatabaseL - Created Secure DB for eapttls.dat. err=%d\n"), err) ); |
|
937 |
|
938 if(err == KErrNone) |
|
939 { |
941 { |
940 aDatabase.Close(); |
942 aDatabase.Close(); |
941 |
943 } |
942 } else if (err != KErrAlreadyExists) |
944 else if (error != KErrAlreadyExists) |
943 { |
945 { |
944 User::LeaveIfError(err); |
946 User::LeaveIfError(error); |
945 } |
947 } |
946 |
948 |
947 User::LeaveIfError(aDatabase.Open(aSession, KTtlsDatabaseName, KSecureUIDFormat)); |
949 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenTtlsDatabaseL(): - calls aDatabase.Open()\n"))); |
948 CleanupClosePushL(aDatabase); |
950 |
949 |
951 error = aDatabase.Open(aFileServerSession, aPrivateDatabasePathName); |
950 #else |
952 |
951 // For non-secured database. The database will be created in the old location (c:\system\data). |
953 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenTtlsDatabaseL(): - Opened private DB for EAP-TTLS. error=%d\n"), error)); |
952 |
954 |
953 RFs fsSession; |
955 User::LeaveIfError(error); |
954 User::LeaveIfError(fsSession.Connect()); |
956 |
955 CleanupClosePushL(fsSession); |
|
956 TInt err = aDatabase.Create(fsSession, KTtlsDatabaseName); |
|
957 |
|
958 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenTtlsDatabaseL - Created Non-Secure DB for eapttls.dat. err=%d\n"), err) ); |
|
959 |
|
960 if(err == KErrNone) |
|
961 { |
|
962 aDatabase.Close(); |
|
963 |
|
964 } else if (err != KErrAlreadyExists) |
|
965 { |
|
966 User::LeaveIfError(err); |
|
967 } |
|
968 |
|
969 User::LeaveIfError(aDatabase.Open(fsSession, KTtlsDatabaseName)); |
|
970 |
|
971 CleanupStack::PopAndDestroy(); // close fsSession |
|
972 |
|
973 CleanupClosePushL(aDatabase); |
|
974 |
|
975 #endif // #ifdef SYMBIAN_SECURE_DBMS |
|
976 |
957 |
977 // 2. Create the eapttls table to database (ignore error if exists) |
958 // 2. Create the eapttls table to database (ignore error if exists) |
978 |
959 |
979 // Table columns: |
960 // Table columns: |
980 //// NAME //////////////////////////////////////////// TYPE ////////////// Constant /////////////////// |
961 //// NAME //////////////////////////////////////////// TYPE ////////////// Constant /////////////////// |
981 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
962 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
982 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
963 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
983 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
964 //| TunnelingTypeVendorId | UNSIGNED INTEGER | KTunnelingTypeVendorId |// |
984 //| EAP_TLS_PEAP_use_manual_realm | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_use_manual_realm_literal |// |
965 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
985 //| EAP_TLS_PEAP_manual_realm | VARCHAR(255) | cf_str_EAP_TLS_PEAP_manual_realm_literal |// |
966 //| EAP_TLS_PEAP_use_manual_realm | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_use_manual_realm_literal |// |
986 //| EAP_TLS_PEAP_use_manual_username | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_use_manual_username_literal |// |
967 //| EAP_TLS_PEAP_manual_realm | VARCHAR(255) | cf_str_EAP_TLS_PEAP_manual_realm_literal |// |
987 //| EAP_TLS_PEAP_manual_username | VARCHAR(255) | cf_str_EAP_TLS_PEAP_manual_username_literal |// |
968 //| EAP_TLS_PEAP_use_manual_username | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_use_manual_username_literal |// |
988 //| EAP_TLS_PEAP_cipher_suite | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_cipher_suite_literal |// |
969 //| EAP_TLS_PEAP_manual_username | VARCHAR(255) | cf_str_EAP_TLS_PEAP_manual_username_literal |// |
989 //| EAP_TLS_PEAP_used_PEAP_version | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_used_PEAP_version_literal |// |
970 //| EAP_TLS_PEAP_cipher_suite | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_cipher_suite_literal |// |
990 //| EAP_TLS_PEAP_accepted_PEAP_versions | BINARY(12) | cf_str_EAP_TLS_PEAP_accepted_PEAP_versions_literal|// |
971 //| EAP_TLS_PEAP_used_PEAP_version | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_used_PEAP_version_literal |// |
991 //| PEAP_accepted_tunneled_client_types | VARBINARY(240) | cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal |// |
972 //| EAP_TLS_PEAP_accepted_PEAP_versions | BINARY(12) | cf_str_EAP_TLS_PEAP_accepted_PEAP_versions_literal|// |
992 //| PEAP_unaccepted_tunneled_client_types | VARBINARY(240) | cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal |// |
973 //| PEAP_accepted_tunneled_client_types | VARBINARY(240) | cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal |// |
993 //| EAP_TLS_server_authenticates_client | UNSIGNED INTEGER | cf_str_TLS_server_authenticates_client_policy_in_client_literal|// |
974 //| PEAP_unaccepted_tunneled_client_types | VARBINARY(240) | cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal |// |
994 //| CA_cert_label | VARCHAR(255) | KCACertLabelOld |// |
975 //| EAP_TLS_server_authenticates_client | UNSIGNED INTEGER | cf_str_TLS_server_authenticates_client_policy_in_client_literal|// |
995 //| client_cert_label | VARCHAR(255) | KClientCertLabel |// |
976 //| CA_cert_label | VARCHAR(255) | KCACertLabel |// |
996 //| EAP_TLS_PEAP_saved_session_id | BINARY(32) | cf_str_EAP_TLS_PEAP_saved_session_id_literal |// |
977 //| client_cert_label | VARCHAR(255) | KClientCertLabel |// |
997 //| EAP_TLS_PEAP_saved_master_secret | BINARY(48) | cf_str_EAP_TLS_PEAP_saved_master_secret_literal |// |
978 //| EAP_TLS_PEAP_saved_session_id | BINARY(32) | cf_str_EAP_TLS_PEAP_saved_session_id_literal |// |
998 //| EAP_TLS_PEAP_saved_cipher_suite | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_saved_cipher_suite_literal |// |
979 //| EAP_TLS_PEAP_saved_master_secret | BINARY(48) | cf_str_EAP_TLS_PEAP_saved_master_secret_literal |// |
999 //| EAP_TLS_PEAP_verify_certificate_realm | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_verify_certificate_realm_literal |// |
980 //| EAP_TLS_PEAP_saved_cipher_suite | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_saved_cipher_suite_literal |// |
1000 //| EAP_TTLS_max_session_validity_time | BIGINT | cf_str_EAP_TTLS_max_session_validity_time_literal |// |
981 //| EAP_TLS_PEAP_verify_certificate_realm | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_verify_certificate_realm_literal |// |
1001 //| EAP_TTLS_last_full_authentication_time | BIGINT | KTTLSLastFullAuthTime |// |
982 //| EAP_TTLS_max_session_validity_time | BIGINT | cf_str_EAP_TTLS_max_session_validity_time_literal |// |
1002 //| EAP_TLS_PEAP_use_identity_privacy | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_use_identity_privacy_literal |// |
983 //| EAP_TTLS_last_full_authentication_time | BIGINT | KTTLSLastFullAuthTime |// |
1003 |
984 //| EAP_TLS_PEAP_use_identity_privacy | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_use_identity_privacy_literal |// |
1004 |
985 |
1005 //| EAP_TLS_PEAP_ttls_pap_password_prompt | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_ttls_pap_password_prompt_literal |// |
986 |
1006 //| EAP_TLS_PEAP_ttls_pap_username | VARCHAR(253) | cf_str_EAP_TLS_PEAP_ttls_pap_username_literal |// |
987 //| EAP_TLS_PEAP_ttls_pap_password_prompt | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_ttls_pap_password_prompt_literal |// |
1007 //| EAP_TLS_PEAP_ttls_pap_password | VARCHAR(128) | cf_str_EAP_TLS_PEAP_ttls_pap_password_literal |// |
988 //| EAP_TLS_PEAP_ttls_pap_username | VARCHAR(253) | cf_str_EAP_TLS_PEAP_ttls_pap_username_literal |// |
1008 //| EAP_TLS_PEAP_ttls_pap_max_session_validity_time | BIGINT | cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time_literal |// |
989 //| EAP_TLS_PEAP_ttls_pap_password | VARCHAR(128) | cf_str_EAP_TLS_PEAP_ttls_pap_password_literal |// |
1009 //| EAP_TLS_PEAP_ttls_pap_last_full_authentication_time | BIGINT | KTTLSPAPLastFullAuthTime |// |
990 //| EAP_TLS_PEAP_ttls_pap_max_session_validity_time | BIGINT | cf_str_EAP_TLS_PEAP_ttls_pap_max_session_validity_time_literal |// |
1010 |
991 //| EAP_TLS_PEAP_ttls_pap_last_full_authentication_time | BIGINT | KTTLSPAPLastFullAuthTime |// |
1011 |
992 |
1012 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
993 //| EAP_TLS_PEAP_use_automatic_ca_certificate | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_use_automatic_ca_certificate_literal|// |
|
994 |
|
995 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
1013 |
996 |
1014 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
997 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
1015 TPtr sqlStatement = buf->Des(); |
998 TPtr sqlStatement = buf->Des(); |
1016 |
999 |
1017 // Table creation is divided into two parts because otherwise the SQL string would get too long |
1000 // Table creation is divided into two parts because otherwise the SQL string would get too long |
1018 _LIT(KSQLCreateTable1, |
1001 _LIT(KSQLCreateTable1, "CREATE TABLE %S \ |
1019 "CREATE TABLE %S (%S UNSIGNED INTEGER, \ |
1002 (%S UNSIGNED INTEGER, \ |
1020 %S UNSIGNED INTEGER, \ |
1003 %S UNSIGNED INTEGER, \ |
1021 %S UNSIGNED INTEGER, \ |
1004 %S UNSIGNED INTEGER, \ |
1022 %S UNSIGNED INTEGER, \ |
1005 %S UNSIGNED INTEGER, \ |
1023 %S VARCHAR(%d), \ |
1006 %S UNSIGNED INTEGER, \ |
1024 %S UNSIGNED INTEGER, \ |
1007 %S VARCHAR(%d), \ |
1025 %S VARCHAR(%d), \ |
1008 %S UNSIGNED INTEGER, \ |
1026 %S UNSIGNED INTEGER, \ |
1009 %S VARCHAR(%d), \ |
1027 %S UNSIGNED INTEGER, \ |
1010 %S UNSIGNED INTEGER, \ |
1028 %S BINARY(%d), \ |
1011 %S UNSIGNED INTEGER, \ |
1029 %S VARBINARY(%d), \ |
1012 %S BINARY(%d), \ |
1030 %S VARBINARY(%d), \ |
1013 %S VARBINARY(%d), \ |
1031 %S UNSIGNED INTEGER, \ |
1014 %S VARBINARY(%d), \ |
1032 %S VARCHAR(%d), \ |
1015 %S UNSIGNED INTEGER, \ |
1033 %S VARCHAR(%d), \ |
1016 %S VARCHAR(%d), \ |
1034 %S BINARY(%d), \ |
1017 %S VARCHAR(%d), \ |
1035 %S BINARY(%d), \ |
1018 %S BINARY(%d), \ |
1036 %S UNSIGNED INTEGER, \ |
1019 %S BINARY(%d), \ |
1037 %S UNSIGNED INTEGER, \ |
1020 %S UNSIGNED INTEGER, \ |
1038 %S BIGINT, \ |
1021 %S UNSIGNED INTEGER, \ |
1039 %S BIGINT, \ |
1022 %S BIGINT, \ |
1040 %S UNSIGNED INTEGER, \ |
1023 %S BIGINT, \ |
1041 %S UNSIGNED INTEGER, \ |
1024 %S UNSIGNED INTEGER, \ |
1042 %S VARCHAR(%d), \ |
1025 %S UNSIGNED INTEGER, \ |
1043 %S VARCHAR(%d), \ |
1026 %S VARCHAR(%d), \ |
1044 %S BIGINT, \ |
1027 %S VARCHAR(%d), \ |
1045 %S BIGINT)"); |
1028 %S BIGINT, \ |
|
1029 %S BIGINT)"); |
|
1030 |
|
1031 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenTtlsDatabaseL(): sqlStatement.Format(KSQLCreateTable1)\n")) ); |
1046 |
1032 |
1047 sqlStatement.Format( KSQLCreateTable1, |
1033 sqlStatement.Format( KSQLCreateTable1, |
1048 &KTtlsDatabaseTableName, |
1034 &KTtlsDatabaseTableName, |
1049 &KServiceType, |
1035 &KServiceType, |
1050 &KServiceIndex, |
1036 &KServiceIndex, |
|
1037 &KTunnelingTypeVendorId, |
1051 &KTunnelingType, |
1038 &KTunnelingType, |
1052 &cf_str_EAP_TLS_PEAP_use_manual_realm_literal, |
1039 &cf_str_EAP_TLS_PEAP_use_manual_realm_literal, |
1053 &cf_str_EAP_TLS_PEAP_manual_realm_literal, KMaxManualRealmLengthInDB, |
1040 &cf_str_EAP_TLS_PEAP_manual_realm_literal, KMaxRealmLengthInDB, |
1054 &cf_str_EAP_TLS_PEAP_use_manual_username_literal, |
1041 &cf_str_EAP_TLS_PEAP_use_manual_username_literal, |
1055 &cf_str_EAP_TLS_PEAP_manual_username_literal, KMaxManualUsernameLengthInDB, |
1042 &cf_str_EAP_TLS_PEAP_manual_username_literal, KMaxUsernameLengthInDB, |
1056 &cf_str_EAP_TLS_PEAP_cipher_suite_literal, |
1043 &cf_str_EAP_TLS_PEAP_cipher_suite_literal, |
1057 &cf_str_EAP_TLS_PEAP_used_PEAP_version_literal, |
1044 &cf_str_EAP_TLS_PEAP_used_PEAP_version_literal, |
1058 &cf_str_EAP_TLS_PEAP_accepted_PEAP_versions_literal, KMaxPEAPVersionsStringLengthInDB, |
1045 &cf_str_EAP_TLS_PEAP_accepted_PEAP_versions_literal, KMaxPEAPVersionsStringLengthInDB, |
1059 &cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal, KMaxTunneledTypeStringLengthInDB, |
1046 &cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal, KMaxTunneledTypeStringLengthInDB, |
1060 &cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal, KMaxTunneledTypeStringLengthInDB, |
1047 &cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal, KMaxTunneledTypeStringLengthInDB, |
1061 &cf_str_TLS_server_authenticates_client_policy_in_client_literal, |
1048 &cf_str_TLS_server_authenticates_client_policy_in_client_literal, |
1062 &KCACertLabelOld, KMaxCertLabelLengthInDB, |
1049 &KCACertLabel, KMaxCertLabelLengthInDB, |
1063 &KClientCertLabel, KMaxCertLabelLengthInDB, |
1050 &KClientCertLabel, KMaxCertLabelLengthInDB, |
1064 &cf_str_EAP_TLS_PEAP_saved_session_id_literal, KMaxSessionIdLengthInDB, |
1051 &cf_str_EAP_TLS_PEAP_saved_session_id_literal, KMaxSessionIdLengthInDB, |
1065 &cf_str_EAP_TLS_PEAP_saved_master_secret_literal, KMaxMasterSecretLengthInDB, |
1052 &cf_str_EAP_TLS_PEAP_saved_master_secret_literal, KMaxMasterSecretLengthInDB, |
1066 &cf_str_EAP_TLS_PEAP_saved_cipher_suite_literal, |
1053 &cf_str_EAP_TLS_PEAP_saved_cipher_suite_literal, |
1067 &cf_str_EAP_TLS_PEAP_verify_certificate_realm_literal, |
1054 &cf_str_EAP_TLS_PEAP_verify_certificate_realm_literal, |
1112 |
1110 |
1113 _LIT( KColumnDef5, "BIGINT" ); |
1111 _LIT( KColumnDef5, "BIGINT" ); |
1114 AlterTableL( aDatabase, EAddColumn , KTtlsDatabaseTableName, |
1112 AlterTableL( aDatabase, EAddColumn , KTtlsDatabaseTableName, |
1115 KTTLSPAPLastFullAuthTime, KColumnDef5); |
1113 KTTLSPAPLastFullAuthTime, KColumnDef5); |
1116 |
1114 |
1117 } |
1115 _LIT( KColumnDef6, "UNSIGNED INTEGER" ); |
1118 else if (err != KErrNone) |
1116 AlterTableL( aDatabase, EAddColumn , KTtlsDatabaseTableName, |
1119 { |
1117 cf_str_EAP_TLS_PEAP_use_automatic_ca_certificate_literal, KColumnDef6); |
1120 User::Leave(err); |
1118 |
|
1119 } |
|
1120 else if (error != KErrNone) |
|
1121 { |
|
1122 EAP_TRACE_DEBUG_SYMBIAN((_L("ERROR: EapTlsPeapUtils::OpenTtlsDatabaseL(): aDatabase.Execute() failed error=%d\n"), error) ); |
|
1123 |
|
1124 User::Leave(error); |
1121 } |
1125 } |
1122 |
1126 |
1123 // Create table for _allowed_ user certificates |
1127 // Create table for _allowed_ user certificates |
1124 |
1128 |
1125 //// NAME ////////////////// TYPE ////////////// Constant /////////// |
1129 //// NAME ////////////////// TYPE ////////////// Constant /////////// |
1126 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
1130 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
1127 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
1131 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
1128 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
1132 //| TunnelingTypeVendorId | UNSIGNED INTEGER | KTunnelingTypeVendorId |// |
1129 //| CertLabel | VARCHAR(255) | KCACertLabel |// |
1133 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
1130 //| SubjectKeyId | BINARY(20) | KSubjectKeyIdentifier |// This is Symbian subjectkey id |
1134 //| CertLabel | VARCHAR(255) | KCACertLabel |// |
1131 //| ActualSubjectKeyId | BINARY(20) | KActualSubjectKeyIdentifier |// This is the actual subjectkeyid present in the certificate. |
1135 //| SubjectKeyId | BINARY(20) | KSubjectKeyIdentifier |// This is Symbian subjectkey id |
1132 //| SubjectName | VARCHAR(255) | KSubjectName |// |
1136 //| ActualSubjectKeyId | BINARY(20) | KActualSubjectKeyIdentifier |// This is the actual subjectkeyid present in the certificate. |
1133 //| IssuerName | VARCHAR(255) | KIssuerName |// |
1137 //| SubjectName | VARCHAR(255) | KSubjectName |// |
1134 //| SerialNumber | VARCHAR(255) | KSerialNumber |// |
1138 //| IssuerName | VARCHAR(255) | KIssuerName |// |
1135 //| Thumbprint | BINARY(64) | KThumbprint |// |
1139 //| SerialNumber | VARCHAR(255) | KSerialNumber |// |
1136 ////////////////////////////////////////////////////////////////////////////////////////////////////// |
1140 //| Thumbprint | BINARY(64) | KThumbprint |// |
1137 |
1141 ////////////////////////////////////////////////////////////////////////////////////////////////////// |
1138 _LIT(KSQLCreateTable2, "CREATE TABLE %S (%S UNSIGNED INTEGER, \ |
1142 |
1139 %S UNSIGNED INTEGER, \ |
1143 _LIT(KSQLCreateTable2, "CREATE TABLE %S \ |
1140 %S UNSIGNED INTEGER, \ |
1144 (%S UNSIGNED INTEGER, \ |
1141 %S VARCHAR(%d), \ |
1145 %S UNSIGNED INTEGER, \ |
1142 %S BINARY(%d), \ |
1146 %S UNSIGNED INTEGER, \ |
1143 %S BINARY(%d), \ |
1147 %S UNSIGNED INTEGER, \ |
1144 %S VARCHAR(%d), \ |
1148 %S VARCHAR(%d), \ |
1145 %S VARCHAR(%d), \ |
1149 %S BINARY(%d), \ |
1146 %S VARCHAR(%d), \ |
1150 %S BINARY(%d), \ |
1147 %S BINARY(%d))"); |
1151 %S VARCHAR(%d), \ |
1148 |
1152 %S VARCHAR(%d), \ |
1149 sqlStatement.Format(KSQLCreateTable2, &KTtlsAllowedUserCertsDatabaseTableName, |
1153 %S VARCHAR(%d), \ |
|
1154 %S BINARY(%d))"); |
|
1155 |
|
1156 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenTtlsDatabaseL(): sqlStatement.Format(KSQLCreateTable2)\n")) ); |
|
1157 |
|
1158 sqlStatement.Format(KSQLCreateTable2, |
|
1159 &KTtlsAllowedUserCertsDatabaseTableName, |
1150 &KServiceType, |
1160 &KServiceType, |
1151 &KServiceIndex, |
1161 &KServiceIndex, |
|
1162 &KTunnelingTypeVendorId, |
1152 &KTunnelingType, |
1163 &KTunnelingType, |
1153 &KCertLabel, KMaxCertLabelLengthInDB, |
1164 &KCertLabel, KMaxCertLabelLengthInDB, |
1154 &KSubjectKeyIdentifier, KMaxSubjectKeyIdLengthInDB, |
1165 &KSubjectKeyIdentifier, KMaxSubjectKeyIdLengthInDB, |
1155 &KActualSubjectKeyIdentifier, KKeyIdentifierLength, |
1166 &KActualSubjectKeyIdentifier, KKeyIdentifierLength, |
1156 &KSubjectName, KGeneralStringMaxLength, |
1167 &KSubjectName, KGeneralStringMaxLength, |
1157 &KIssuerName, KGeneralStringMaxLength, |
1168 &KIssuerName, KGeneralStringMaxLength, |
1158 &KSerialNumber, KGeneralStringMaxLength, |
1169 &KSerialNumber, KGeneralStringMaxLength, |
1159 &KThumbprint, KThumbprintMaxLength); |
1170 &KThumbprint, KThumbprintMaxLength); |
1160 |
1171 |
1161 err = aDatabase.Execute(sqlStatement); |
1172 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenTtlsDatabaseL(): aDatabase.Execute()\n")) ); |
1162 if (err != KErrNone && err != KErrAlreadyExists) |
1173 |
1163 { |
1174 error = aDatabase.Execute(sqlStatement); |
1164 User::Leave(err); |
1175 if (error != KErrNone && error != KErrAlreadyExists) |
|
1176 { |
|
1177 User::Leave(error); |
1165 } |
1178 } |
1166 |
1179 |
1167 // Create table for _allowed_ CA certs |
1180 // Create table for _allowed_ CA certs |
1168 |
1181 |
1169 //// NAME ////////////////// TYPE ////////////// Constant /////////// |
1182 //// NAME ////////////////// TYPE ////////////// Constant /////////// |
1170 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
1183 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
1171 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
1184 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
1172 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
1185 //| TunnelingTypeVendorId | UNSIGNED INTEGER | KTunnelingTypeVendorId |// |
1173 //| CACertLabel | VARCHAR(255) | KCACertLabel |// |
1186 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
1174 //| SubjectKeyId | BINARY(20) | KSubjectKeyIdentifier |// This is Symbian subjectkey id |
1187 //| CACertLabel | VARCHAR(255) | KCACertLabel |// |
1175 //| ActualSubjectKeyId | BINARY(20) | KActualSubjectKeyIdentifier |// This is the actual subjectkeyid present in the certificate. |
1188 //| SubjectKeyId | BINARY(20) | KSubjectKeyIdentifier |// This is Symbian subjectkey id |
1176 //| SubjectName | VARCHAR(255) | KSubjectName |// |
1189 //| ActualSubjectKeyId | BINARY(20) | KActualSubjectKeyIdentifier |// This is the actual subjectkeyid present in the certificate. |
1177 //| IssuerName | VARCHAR(255) | KIssuerName |// |
1190 //| SubjectName | VARCHAR(255) | KSubjectName |// |
1178 //| SerialNumber | VARCHAR(255) | KSerialNumber |// |
1191 //| IssuerName | VARCHAR(255) | KIssuerName |// |
1179 //| Thumbprint | BINARY(64) | KThumbprint |// |
1192 //| SerialNumber | VARCHAR(255) | KSerialNumber |// |
1180 ////////////////////////////////////////////////////////////////////////////////////////////////////// |
1193 //| Thumbprint | BINARY(64) | KThumbprint |// |
1181 |
1194 ////////////////////////////////////////////////////////////////////////////////////////////////////// |
1182 _LIT(KSQLCreateTable3, "CREATE TABLE %S (%S UNSIGNED INTEGER, \ |
1195 |
1183 %S UNSIGNED INTEGER, \ |
1196 _LIT(KSQLCreateTable3, "CREATE TABLE %S \ |
1184 %S UNSIGNED INTEGER, \ |
1197 (%S UNSIGNED INTEGER, \ |
1185 %S VARCHAR(%d), \ |
1198 %S UNSIGNED INTEGER, \ |
1186 %S BINARY(%d), \ |
1199 %S UNSIGNED INTEGER, \ |
1187 %S BINARY(%d), \ |
1200 %S UNSIGNED INTEGER, \ |
1188 %S VARCHAR(%d), \ |
1201 %S VARCHAR(%d), \ |
1189 %S VARCHAR(%d), \ |
1202 %S BINARY(%d), \ |
1190 %S VARCHAR(%d), \ |
1203 %S BINARY(%d), \ |
1191 %S BINARY(%d))"); |
1204 %S VARCHAR(%d), \ |
|
1205 %S VARCHAR(%d), \ |
|
1206 %S VARCHAR(%d), \ |
|
1207 %S BINARY(%d))"); |
1192 |
1208 |
1193 sqlStatement.Format(KSQLCreateTable3, &KTtlsAllowedCACertsDatabaseTableName, |
1209 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenTtlsDatabaseL(): sqlStatement.Format(KSQLCreateTable3)\n")) ); |
|
1210 |
|
1211 sqlStatement.Format(KSQLCreateTable3, |
|
1212 &KTtlsAllowedCACertsDatabaseTableName, |
1194 &KServiceType, |
1213 &KServiceType, |
1195 &KServiceIndex, |
1214 &KServiceIndex, |
|
1215 &KTunnelingTypeVendorId, |
1196 &KTunnelingType, |
1216 &KTunnelingType, |
1197 &KCertLabel, KMaxCertLabelLengthInDB, |
1217 &KCertLabel, KMaxCertLabelLengthInDB, |
1198 &KSubjectKeyIdentifier, KMaxSubjectKeyIdLengthInDB, |
1218 &KSubjectKeyIdentifier, KMaxSubjectKeyIdLengthInDB, |
1199 &KActualSubjectKeyIdentifier, KKeyIdentifierLength, |
1219 &KActualSubjectKeyIdentifier, KKeyIdentifierLength, |
1200 &KSubjectName, KGeneralStringMaxLength, |
1220 &KSubjectName, KGeneralStringMaxLength, |
1201 &KIssuerName, KGeneralStringMaxLength, |
1221 &KIssuerName, KGeneralStringMaxLength, |
1202 &KSerialNumber, KGeneralStringMaxLength, |
1222 &KSerialNumber, KGeneralStringMaxLength, |
1203 &KThumbprint, KThumbprintMaxLength); |
1223 &KThumbprint, KThumbprintMaxLength); |
1204 |
1224 |
1205 err = aDatabase.Execute(sqlStatement); |
1225 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenTtlsDatabaseL(): aDatabase.Execute()\n")) ); |
1206 if (err != KErrNone && err != KErrAlreadyExists) |
1226 |
1207 { |
1227 error = aDatabase.Execute(sqlStatement); |
1208 User::Leave(err); |
1228 if (error != KErrNone && error != KErrAlreadyExists) |
|
1229 { |
|
1230 User::Leave(error); |
1209 } |
1231 } |
1210 |
1232 |
1211 // Create table for _allowed_ cipher suites |
1233 // Create table for _allowed_ cipher suites |
1212 |
1234 |
1213 //// NAME ///////////////// TYPE ////////////// Constant /////////// |
1235 //// NAME ///////////////// TYPE ////////////// Constant /////////// |
1214 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
1236 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
1215 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
1237 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
1216 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
1238 //| TunnelingTypeVendorId | UNSIGNED INTEGER | KTunnelingTypeVendorId |// |
1217 //| CipherSuite | UNSIGNED INTEGER | KCipherSuite |// |
1239 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
1218 ////////////////////////////////////////////////////////////////////////////////////////////////////// |
1240 //| CipherSuite | UNSIGNED INTEGER | KCipherSuite |// |
1219 |
1241 ////////////////////////////////////////////////////////////////////////////////////////////////////// |
1220 _LIT(KSQLCreateTable4, "CREATE TABLE %S (%S UNSIGNED INTEGER, \ |
1242 |
1221 %S UNSIGNED INTEGER, \ |
1243 _LIT(KSQLCreateTable4, "CREATE TABLE %S \ |
1222 %S UNSIGNED INTEGER, \ |
1244 (%S UNSIGNED INTEGER, \ |
1223 %S UNSIGNED INTEGER)"); |
1245 %S UNSIGNED INTEGER, \ |
1224 |
1246 %S UNSIGNED INTEGER, \ |
1225 sqlStatement.Format(KSQLCreateTable4, &KTtlsAllowedCipherSuitesDatabaseTableName, |
1247 %S UNSIGNED INTEGER, \ |
1226 &KServiceType, &KServiceIndex, &KTunnelingType, &KCipherSuite); |
1248 %S UNSIGNED INTEGER)"); |
1227 err = aDatabase.Execute(sqlStatement); |
1249 |
1228 if (err != KErrNone && err != KErrAlreadyExists) |
1250 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenTtlsDatabaseL(): sqlStatement.Format(KSQLCreateTable4)\n")) ); |
1229 { |
1251 |
1230 User::Leave(err); |
1252 sqlStatement.Format(KSQLCreateTable4, |
|
1253 &KTtlsAllowedCipherSuitesDatabaseTableName, |
|
1254 &KServiceType, |
|
1255 &KServiceIndex, |
|
1256 &KTunnelingTypeVendorId, |
|
1257 &KTunnelingType, |
|
1258 &KCipherSuite); |
|
1259 |
|
1260 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenTtlsDatabaseL(): aDatabase.Execute()\n")) ); |
|
1261 |
|
1262 error = aDatabase.Execute(sqlStatement); |
|
1263 if (error != KErrNone && error != KErrAlreadyExists) |
|
1264 { |
|
1265 User::Leave(error); |
1231 } |
1266 } |
1232 |
1267 |
1233 // 4. Check if database table contains a row for this service type and id |
1268 // 4. Check if database table contains a row for this service type and id |
1234 |
1269 |
1235 _LIT(KSQLQueryRow, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
1270 _LIT(KSQLQueryRow, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d"); |
1236 |
1271 |
1237 sqlStatement.Format(KSQLQueryRow, &KTtlsDatabaseTableName, |
1272 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenTtlsDatabaseL(): sqlStatement.Format(KSQLQueryRow)\n")) ); |
1238 &KServiceType, aIndexType, &KServiceIndex, aIndex, &KTunnelingType, aTunnelingVendorType); |
1273 |
|
1274 sqlStatement.Format(KSQLQueryRow, |
|
1275 &KTtlsDatabaseTableName, |
|
1276 &KServiceType, |
|
1277 aIndexType, |
|
1278 &KServiceIndex, |
|
1279 aIndex, |
|
1280 &KTunnelingTypeVendorId, |
|
1281 aTunnelingType.get_vendor_id(), |
|
1282 &KTunnelingType, |
|
1283 aTunnelingType.get_vendor_type()); |
1239 |
1284 |
1240 RDbView view; |
1285 RDbView view; |
|
1286 |
|
1287 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenTtlsDatabaseL(): view.Prepare()\n")) ); |
|
1288 |
1241 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
1289 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
1242 // View must be closed when no longer needed |
1290 // View must be closed when no longer needed |
1243 CleanupClosePushL(view); |
1291 CleanupClosePushL(view); |
|
1292 |
|
1293 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenTtlsDatabaseL(): view.EvaluateAll()\n")) ); |
|
1294 |
1244 User::LeaveIfError(view.EvaluateAll()); |
1295 User::LeaveIfError(view.EvaluateAll()); |
1245 |
1296 |
1246 // 5. If row is not found then add it |
1297 // 5. If row is not found then add it |
1247 |
1298 |
1248 TInt rows = view.CountL(); |
1299 TInt rows = view.CountL(); |
|
1300 |
|
1301 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenTtlsDatabaseL(): view.CountL()=%d\n"), |
|
1302 rows)); |
|
1303 |
1249 CleanupStack::PopAndDestroy(); // view |
1304 CleanupStack::PopAndDestroy(); // view |
1250 if (rows == 0) |
1305 if (rows == 0) |
1251 { |
1306 { |
1252 _LIT(KSQLInsert, "SELECT * FROM %S"); |
1307 _LIT(KSQLInsert, "SELECT * FROM %S"); |
|
1308 |
|
1309 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenTtlsDatabaseL(): sqlStatement.Format(KSQLInsert)\n")) ); |
|
1310 |
1253 sqlStatement.Format(KSQLInsert, &KTtlsDatabaseTableName); |
1311 sqlStatement.Format(KSQLInsert, &KTtlsDatabaseTableName); |
|
1312 |
|
1313 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenTtlsDatabaseL(): view.Prepare()\n")) ); |
1254 |
1314 |
1255 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited, RDbView::EInsertOnly)); |
1315 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited, RDbView::EInsertOnly)); |
1256 CleanupClosePushL(view); |
1316 CleanupClosePushL(view); |
|
1317 |
|
1318 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenTtlsDatabaseL(): view.InsertL()\n")) ); |
|
1319 |
1257 view.InsertL(); |
1320 view.InsertL(); |
1258 |
1321 |
1259 // Get column set so we get the correct column numbers |
1322 // Get column set so we get the correct column numbers |
1260 CDbColSet* colSet = view.ColSetL(); |
1323 CDbColSet* colSet = view.ColSetL(); |
1261 CleanupStack::PushL(colSet); |
1324 CleanupStack::PushL(colSet); |
1262 |
1325 |
1263 // Set the default values. The other three tables (certs, ca certs & cipher suites) are empty by default. |
1326 // Set the default values. The other three tables (certs, ca certs & cipher suites) are empty by default. |
1264 view.SetColL(colSet->ColNo(KServiceType), static_cast<TInt>(aIndexType)); |
1327 view.SetColL(colSet->ColNo(KServiceType), static_cast<TInt>(aIndexType)); |
1265 view.SetColL(colSet->ColNo(KServiceIndex), aIndex); |
1328 view.SetColL(colSet->ColNo(KServiceIndex), aIndex); |
1266 view.SetColL(colSet->ColNo(KTunnelingType), aTunnelingVendorType); |
1329 view.SetColL(colSet->ColNo(KTunnelingTypeVendorId), aTunnelingType.get_vendor_id()); |
|
1330 view.SetColL(colSet->ColNo(KTunnelingType), aTunnelingType.get_vendor_type()); |
1267 |
1331 |
1268 view.SetColL(colSet->ColNo(cf_str_EAP_TLS_PEAP_use_manual_realm_literal), default_EAP_TLS_PEAP_use_manual_realm); |
1332 view.SetColL(colSet->ColNo(cf_str_EAP_TLS_PEAP_use_manual_realm_literal), default_EAP_TLS_PEAP_use_manual_realm); |
1269 view.SetColL(colSet->ColNo(cf_str_EAP_TLS_PEAP_manual_realm_literal), default_EAP_TLS_PEAP_manual_realm); |
1333 view.SetColL(colSet->ColNo(cf_str_EAP_TLS_PEAP_manual_realm_literal), default_EAP_realm); |
1270 |
1334 |
1271 view.SetColL(colSet->ColNo(cf_str_EAP_TLS_PEAP_use_manual_username_literal), default_EAP_TLS_PEAP_use_manual_username); |
1335 view.SetColL(colSet->ColNo(cf_str_EAP_TLS_PEAP_use_manual_username_literal), default_EAP_TLS_PEAP_use_manual_username); |
1272 view.SetColL(colSet->ColNo(cf_str_EAP_TLS_PEAP_manual_username_literal), default_EAP_TLS_PEAP_manual_username); |
1336 view.SetColL(colSet->ColNo(cf_str_EAP_TLS_PEAP_manual_username_literal), default_EAP_username); |
1273 |
1337 |
1274 view.SetColL(colSet->ColNo(cf_str_EAP_TLS_PEAP_cipher_suite_literal), default_EAP_TLS_PEAP_cipher_suite); |
1338 view.SetColL(colSet->ColNo(cf_str_EAP_TLS_PEAP_cipher_suite_literal), default_EAP_TLS_PEAP_cipher_suite); |
1275 |
1339 |
1276 view.SetColL(colSet->ColNo(cf_str_EAP_TLS_PEAP_used_PEAP_version_literal), default_EAP_TLS_PEAP_used_PEAP_version); |
1340 view.SetColL(colSet->ColNo(cf_str_EAP_TLS_PEAP_used_PEAP_version_literal), default_EAP_TLS_PEAP_used_PEAP_version); |
1277 |
1341 |
1385 // --------------------------------------------------------- |
1464 // --------------------------------------------------------- |
1386 // EapTlsPeapUtils::OpenFastDatabaseL() |
1465 // EapTlsPeapUtils::OpenFastDatabaseL() |
1387 // --------------------------------------------------------- |
1466 // --------------------------------------------------------- |
1388 // |
1467 // |
1389 void EapTlsPeapUtils::OpenFastDatabaseL( |
1468 void EapTlsPeapUtils::OpenFastDatabaseL( |
1390 RDbNamedDatabase& aDatabase, |
1469 RDbNamedDatabase& aDatabase, |
1391 RDbs& aSession, |
1470 RFs& aFileServerSession, |
1392 const TIndexType aIndexType, |
1471 const TIndexType aIndexType, |
1393 const TInt aIndex, |
1472 const TInt aIndex, |
1394 const eap_type_value_e aTunnelingType) |
1473 const eap_type_value_e aTunnelingType) |
1395 { |
1474 { |
1396 #ifdef USE_EAP_EXPANDED_TYPES |
|
1397 |
|
1398 TUint aTunnelingVendorType = aTunnelingType.get_vendor_type(); |
|
1399 |
|
1400 #else |
|
1401 |
|
1402 TUint aTunnelingVendorType = static_cast<TUint>(aTunnelingType); |
|
1403 |
|
1404 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
|
1405 |
|
1406 EAP_TRACE_DEBUG_SYMBIAN( |
1475 EAP_TRACE_DEBUG_SYMBIAN( |
1407 (_L("EapTlsPeapUtils::OpenFastDatabaseL -Start- aIndexType=%d, aIndex=%d, Tunneling vendor type=%d \n"), |
1476 (_L("EapTlsPeapUtils::OpenFastDatabaseL(): - Start - aIndexType=%d, aIndex=%d, aTunnelingType=0xfe%06x%08x\n"), |
1408 aIndexType,aIndex, aTunnelingVendorType)); |
1477 aIndexType, |
|
1478 aIndex, |
|
1479 aTunnelingType.get_vendor_id(), |
|
1480 aTunnelingType.get_vendor_type())); |
|
1481 |
|
1482 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: EapTlsPeapUtils::OpenFastDatabaseL()\n")); |
1409 |
1483 |
1410 // 1. Open/create a database |
1484 // 1. Open/create a database |
1411 |
1485 |
1412 // Connect to the DBMS server. |
1486 TInt error(KErrNone); |
1413 User::LeaveIfError(aSession.Connect()); |
1487 TFileName aPrivateDatabasePathName; |
1414 CleanupClosePushL(aSession); |
1488 |
1415 // aSession and aDatabase are pushed to the cleanup stack even though they may be member |
1489 EapPluginTools::CreateDatabaseLC( |
1416 // variables of the calling class and would be closed in the destructor anyway. This ensures |
1490 aDatabase, |
1417 // that if they are not member variables they will be closed. Closing the handle twice |
1491 aFileServerSession, |
1418 // does no harm. |
1492 error, |
1419 |
1493 KFastDatabaseName, |
1420 #ifdef SYMBIAN_SECURE_DBMS |
1494 aPrivateDatabasePathName); |
1421 |
1495 |
1422 // Create the secure shared database with the specified secure policy. |
1496 if(error == KErrNone) |
1423 // Database will be created in the data caging path for DBMS (C:\private\100012a5). |
|
1424 |
|
1425 TInt err = aDatabase.Create(aSession, KFastDatabaseName, KSecureUIDFormat); |
|
1426 |
|
1427 EAP_TRACE_DEBUG_SYMBIAN( |
|
1428 (_L("EapTlsPeapUtils::OpenFastDatabaseL - Created Secure DB for eapfast.dat. err=%d (-11=DB created before)\n"), |
|
1429 err) ); |
|
1430 |
|
1431 if(err == KErrNone) |
|
1432 { |
1497 { |
1433 aDatabase.Close(); |
1498 aDatabase.Close(); |
1434 |
1499 } |
1435 } else if (err != KErrAlreadyExists) |
1500 else if (error != KErrAlreadyExists) |
1436 { |
1501 { |
1437 User::LeaveIfError(err); |
1502 User::LeaveIfError(error); |
1438 } |
1503 } |
1439 |
1504 |
1440 User::LeaveIfError(aDatabase.Open(aSession, KFastDatabaseName, KSecureUIDFormat)); |
1505 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenFastDatabaseL(): - calls aDatabase.Open()\n"))); |
1441 CleanupClosePushL(aDatabase); |
1506 |
1442 |
1507 error = aDatabase.Open(aFileServerSession, aPrivateDatabasePathName); |
1443 #else |
1508 |
1444 // For non-secured database. The database will be created in the old location (c:\system\data). |
1509 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenFastDatabaseL(): - Opened private DB for EAP-FAST. error=%d\n"), error)); |
1445 |
1510 |
1446 RFs fsSession; |
1511 User::LeaveIfError(error); |
1447 User::LeaveIfError(fsSession.Connect()); |
|
1448 CleanupClosePushL(fsSession); |
|
1449 TInt err = aDatabase.Create(fsSession, KFastDatabaseName); |
|
1450 |
|
1451 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::OpenFastDatabaseL - Created Non-Secure DB for eapfast.dat. err=%d\n"), err) ); |
|
1452 |
|
1453 if(err == KErrNone) |
|
1454 { |
|
1455 aDatabase.Close(); |
|
1456 |
|
1457 } else if (err != KErrAlreadyExists) |
|
1458 { |
|
1459 User::LeaveIfError(err); |
|
1460 } |
|
1461 |
|
1462 User::LeaveIfError(aDatabase.Open(fsSession, KFastDatabaseName)); |
|
1463 |
|
1464 CleanupStack::PopAndDestroy(); // close fsSession |
|
1465 |
|
1466 CleanupClosePushL(aDatabase); |
|
1467 |
|
1468 #endif // #ifdef SYMBIAN_SECURE_DBMS |
|
1469 |
1512 |
1470 // 2. Create the eapfast tables to database (ignore error if exists) |
1513 // 2. Create the eapfast tables to database (ignore error if exists) |
1471 |
1514 |
1472 // Table 1: Create table for general settings of EAP-FAST. |
1515 // Table 1: Create table for general settings of EAP-FAST. |
1473 |
1516 |
1474 // Table columns: |
1517 // Table columns: |
1475 //// NAME //////////////////////////////////////////// TYPE ////////////// Constant /////////////////// |
1518 //// NAME //////////////////////////////////////////// TYPE ////////////// Constant /////////////////// |
1476 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
1519 //| ServiceType | UNSIGNED INTEGER | KServiceType |// |
1477 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
1520 //| ServiceIndex | UNSIGNED INTEGER | KServiceIndex |// |
1478 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
1521 //| TunnelingTypeVendorId | UNSIGNED INTEGER | KTunnelingTypeVendorId |// |
1479 //| EAP_TLS_PEAP_use_manual_realm | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_use_manual_realm_literal |// |
1522 //| TunnelingType | UNSIGNED INTEGER | KTunnelingType |// |
1480 //| EAP_TLS_PEAP_manual_realm | VARCHAR(255) | cf_str_EAP_TLS_PEAP_manual_realm_literal |// |
1523 //| EAP_TLS_PEAP_use_manual_realm | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_use_manual_realm_literal |// |
1481 //| EAP_TLS_PEAP_use_manual_username | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_use_manual_username_literal |// |
1524 //| EAP_TLS_PEAP_manual_realm | VARCHAR(255) | cf_str_EAP_TLS_PEAP_manual_realm_literal |// |
1482 //| EAP_TLS_PEAP_manual_username | VARCHAR(255) | cf_str_EAP_TLS_PEAP_manual_username_literal |// |
1525 //| EAP_TLS_PEAP_use_manual_username | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_use_manual_username_literal |// |
1483 //| EAP_TLS_PEAP_cipher_suite | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_cipher_suite_literal |// |
1526 //| EAP_TLS_PEAP_manual_username | VARCHAR(255) | cf_str_EAP_TLS_PEAP_manual_username_literal |// |
1484 //| EAP_TLS_PEAP_used_PEAP_version | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_used_PEAP_version_literal |// |
1527 //| EAP_TLS_PEAP_cipher_suite | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_cipher_suite_literal |// |
1485 //| EAP_TLS_PEAP_accepted_PEAP_versions | BINARY(12) | cf_str_EAP_TLS_PEAP_accepted_PEAP_versions_literal|// |
1528 //| EAP_TLS_PEAP_used_PEAP_version | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_used_PEAP_version_literal |// |
1486 //| PEAP_accepted_tunneled_client_types | VARBINARY(240) | cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal |// |
1529 //| EAP_TLS_PEAP_accepted_PEAP_versions | BINARY(12) | cf_str_EAP_TLS_PEAP_accepted_PEAP_versions_literal|// |
1487 //| PEAP_unaccepted_tunneled_client_types | VARBINARY(240) | cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal |// |
1530 //| PEAP_accepted_tunneled_client_types | VARBINARY(240) | cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal |// |
1488 //| EAP_TLS_server_authenticates_client | UNSIGNED INTEGER | cf_str_TLS_server_authenticates_client_policy_in_client_literal|// |
1531 //| PEAP_unaccepted_tunneled_client_types | VARBINARY(240) | cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal |// |
1489 //| EAP_TLS_PEAP_saved_session_id | BINARY(32) | cf_str_EAP_TLS_PEAP_saved_session_id_literal |// |
1532 //| EAP_TLS_server_authenticates_client | UNSIGNED INTEGER | cf_str_TLS_server_authenticates_client_policy_in_client_literal|// |
1490 //| EAP_TLS_PEAP_saved_master_secret | BINARY(48) | cf_str_EAP_TLS_PEAP_saved_master_secret_literal |// |
1533 //| EAP_TLS_PEAP_saved_session_id | BINARY(32) | cf_str_EAP_TLS_PEAP_saved_session_id_literal |// |
1491 //| EAP_TLS_PEAP_saved_cipher_suite | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_saved_cipher_suite_literal |// |
1534 //| EAP_TLS_PEAP_saved_master_secret | BINARY(48) | cf_str_EAP_TLS_PEAP_saved_master_secret_literal |// |
1492 //| EAP_TLS_PEAP_verify_certificate_realm | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_verify_certificate_realm_literal |// |
1535 //| EAP_TLS_PEAP_saved_cipher_suite | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_saved_cipher_suite_literal |// |
1493 //| EAP_FAST_max_session_validity_time | BIGINT | cf_str_EAP_FAST_max_session_validity_time_literal |// |
1536 //| EAP_TLS_PEAP_verify_certificate_realm | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_verify_certificate_realm_literal |// |
1494 //| EAP_FAST_last_full_authentication_time | BIGINT | KFASTLastFullAuthTime |// |
1537 //| EAP_FAST_max_session_validity_time | BIGINT | cf_str_EAP_FAST_max_session_validity_time_literal |// |
1495 //| EAP_TLS_PEAP_use_identity_privacy | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_use_identity_privacy_literal |// |
1538 //| EAP_FAST_last_full_authentication_time | BIGINT | KFASTLastFullAuthTime |// |
1496 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
1539 //| EAP_TLS_PEAP_use_identity_privacy | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_use_identity_privacy_literal |// |
1497 |
1540 //| EAP_TLS_PEAP_use_automatic_ca_certificate | UNSIGNED INTEGER | cf_str_EAP_TLS_PEAP_use_automatic_ca_certificate_literal|// |
1498 /** moved to PAC store db, because time is the same for all IAPs **/ |
1541 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
1499 //| EAP_FAST_last_password_identity_time | BIGINT | KFASTLastPasswordIdentityTime |// |
1542 |
1500 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
1543 /** moved to PAC store db, because time is the same for all IAPs **/ |
|
1544 //| EAP_FAST_last_password_identity_time | BIGINT | KFASTLastPasswordIdentityTime |// |
|
1545 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
1501 |
1546 |
1502 |
1547 |
1503 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
1548 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
1504 TPtr sqlStatement = buf->Des(); |
1549 TPtr sqlStatement = buf->Des(); |
1505 |
1550 |
1506 EAP_TRACE_DEBUG_SYMBIAN( |
1551 EAP_TRACE_DEBUG_SYMBIAN( |
1507 (_L("EapTlsPeapUtils::OpenFastDatabaseL - Creating the tables for EAP-FAST\n"))); |
1552 (_L("EapTlsPeapUtils::OpenFastDatabaseL - Creating the tables for EAP-FAST\n"))); |
1508 |
1553 |
1509 _LIT(KSQLCreateTable1, "CREATE TABLE %S (%S UNSIGNED INTEGER, \ |
1554 _LIT(KSQLCreateTable1, "CREATE TABLE %S \ |
1510 %S UNSIGNED INTEGER, \ |
1555 (%S UNSIGNED INTEGER, \ |
1511 %S UNSIGNED INTEGER, \ |
1556 %S UNSIGNED INTEGER, \ |
1512 %S UNSIGNED INTEGER, \ |
1557 %S UNSIGNED INTEGER, \ |
1513 %S VARCHAR(%d), \ |
1558 %S UNSIGNED INTEGER, \ |
1514 %S UNSIGNED INTEGER, \ |
1559 %S UNSIGNED INTEGER, \ |
1515 %S VARCHAR(%d), \ |
1560 %S VARCHAR(%d), \ |
1516 %S UNSIGNED INTEGER, \ |
1561 %S UNSIGNED INTEGER, \ |
1517 %S UNSIGNED INTEGER, \ |
1562 %S VARCHAR(%d), \ |
1518 %S BINARY(%d), \ |
1563 %S UNSIGNED INTEGER, \ |
1519 %S VARBINARY(%d), \ |
1564 %S UNSIGNED INTEGER, \ |
1520 %S VARBINARY(%d), \ |
1565 %S BINARY(%d), \ |
1521 %S UNSIGNED INTEGER, \ |
1566 %S VARBINARY(%d), \ |
1522 %S BINARY(%d), \ |
1567 %S VARBINARY(%d), \ |
1523 %S BINARY(%d), \ |
1568 %S UNSIGNED INTEGER, \ |
1524 %S UNSIGNED INTEGER, \ |
1569 %S BINARY(%d), \ |
1525 %S UNSIGNED INTEGER, \ |
1570 %S BINARY(%d), \ |
1526 %S BIGINT, \ |
1571 %S UNSIGNED INTEGER, \ |
1527 %S BIGINT, \ |
1572 %S UNSIGNED INTEGER, \ |
1528 %S UNSIGNED INTEGER)"); |
1573 %S BIGINT, \ |
1529 |
1574 %S BIGINT, \ |
1530 sqlStatement.Format(KSQLCreateTable1, &KFastGeneralSettingsDBTableName, |
1575 %S UNSIGNED INTEGER, \ |
|
1576 %S UNSIGNED INTEGER)"); |
|
1577 |
|
1578 sqlStatement.Format(KSQLCreateTable1, |
|
1579 &KFastGeneralSettingsDBTableName, |
1531 &KServiceType, |
1580 &KServiceType, |
1532 &KServiceIndex, |
1581 &KServiceIndex, |
|
1582 &KTunnelingTypeVendorId, |
1533 &KTunnelingType, |
1583 &KTunnelingType, |
1534 &cf_str_EAP_TLS_PEAP_use_manual_realm_literal, |
1584 &cf_str_EAP_TLS_PEAP_use_manual_realm_literal, |
1535 &cf_str_EAP_TLS_PEAP_manual_realm_literal, KMaxManualRealmLengthInDB, |
1585 &cf_str_EAP_TLS_PEAP_manual_realm_literal, KMaxRealmLengthInDB, |
1536 &cf_str_EAP_TLS_PEAP_use_manual_username_literal, |
1586 &cf_str_EAP_TLS_PEAP_use_manual_username_literal, |
1537 &cf_str_EAP_TLS_PEAP_manual_username_literal, KMaxManualUsernameLengthInDB, |
1587 &cf_str_EAP_TLS_PEAP_manual_username_literal, KMaxUsernameLengthInDB, |
1538 &cf_str_EAP_TLS_PEAP_cipher_suite_literal, |
1588 &cf_str_EAP_TLS_PEAP_cipher_suite_literal, |
1539 &cf_str_EAP_TLS_PEAP_used_PEAP_version_literal, |
1589 &cf_str_EAP_TLS_PEAP_used_PEAP_version_literal, |
1540 &cf_str_EAP_TLS_PEAP_accepted_PEAP_versions_literal, KMaxPEAPVersionsStringLengthInDB, |
1590 &cf_str_EAP_TLS_PEAP_accepted_PEAP_versions_literal, KMaxPEAPVersionsStringLengthInDB, |
1541 &cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal, KMaxTunneledTypeStringLengthInDB, |
1591 &cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal, KMaxTunneledTypeStringLengthInDB, |
1542 &cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal, KMaxTunneledTypeStringLengthInDB, |
1592 &cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal, KMaxTunneledTypeStringLengthInDB, |
2118 { |
2252 { |
2119 return EFalse; |
2253 return EFalse; |
2120 } |
2254 } |
2121 } |
2255 } |
2122 |
2256 |
2123 TBool EapTlsPeapUtils::CompareSCertEntries(const SCertEntry& item1, const SCertEntry& item2) |
2257 // --------------------------------------------------------- |
|
2258 |
|
2259 TBool EapTlsPeapUtils::CompareSCertEntries(const EapCertificateEntry& item1, const EapCertificateEntry& item2) |
2124 { |
2260 { |
2125 EAP_TRACE_DEBUG_SYMBIAN((_L("\nEapTlsPeapUtils::CompareSCertEntries, Label_1=%S, Label_2=%S"), |
2261 EAP_TRACE_DEBUG_SYMBIAN( |
2126 &(item1.iLabel), &(item2.iLabel))); |
2262 (_L("EapTlsPeapUtils::CompareSCertEntries(): item1.Label=\"%S\", item2.Label=\"%S\"\n"), |
2127 |
2263 item1.GetLabel(), |
2128 EAP_TRACE_DATA_DEBUG_SYMBIAN(("EapTlsPeapUtils::CompareSCertEntries, SubjectKeyID_1:", |
2264 item2.GetLabel())); |
2129 item1.iSubjectKeyId.Ptr(), item1.iSubjectKeyId.Size())); |
2265 |
2130 |
2266 EAP_TRACE_DEBUG_SYMBIAN( |
2131 EAP_TRACE_DATA_DEBUG_SYMBIAN(("EapTlsPeapUtils::CompareSCertEntries, SubjectKeyID_2:", |
2267 (_L("EapTlsPeapUtils::CompareSCertEntries(): item1.Label=\"%S\", item2.Label=\"%S\"\n"), |
2132 item2.iSubjectKeyId.Ptr(), item2.iSubjectKeyId.Size())); |
2268 item1.GetLabel(), |
2133 |
2269 item2.GetLabel())); |
2134 if (item1.iLabel == item2.iLabel || |
2270 |
2135 item1.iLabel.Length() == 0 || |
2271 EAP_TRACE_DATA_DEBUG_SYMBIAN(("EapTlsPeapUtils::CompareSCertEntries(): SubjectKeyID_1:", |
2136 item2.iLabel.Length() == 0 ) // Label is not saved when certs are saved using OMA DM. |
2272 item1.GetSubjectKeyId().Ptr(), |
2137 { |
2273 item1.GetSubjectKeyId().Length())); |
2138 if (item1.iSubjectKeyId == item2.iSubjectKeyId) |
2274 |
|
2275 EAP_TRACE_DATA_DEBUG_SYMBIAN(("EapTlsPeapUtils::CompareSCertEntries(): SubjectKeyID_2:", |
|
2276 item2.GetSubjectKeyId().Ptr(), |
|
2277 item2.GetSubjectKeyId().Length())); |
|
2278 |
|
2279 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: EapTlsPeapUtils::CompareSCertEntries()\n")); |
|
2280 |
|
2281 |
|
2282 if (*(item1.GetLabel()) == *(item2.GetLabel()) |
|
2283 || item1.GetLabel()->Length() == 0 |
|
2284 || item2.GetLabel()->Length() == 0 ) // Label is not saved when certs are saved using OMA DM. |
|
2285 { |
|
2286 if (item1.GetSubjectKeyId() == item2.GetSubjectKeyId()) |
2139 { |
2287 { |
2140 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::CompareSCertEntries, Certs matched\n"))); |
2288 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::CompareSCertEntries, Certs matched\n"))); |
2141 |
2289 |
2142 return ETrue; |
2290 return ETrue; |
2143 } |
2291 } |
2144 } |
2292 } |
2145 |
2293 |
2146 return EFalse; |
2294 return EFalse; |
2147 } |
2295 } |
2148 |
2296 |
2149 |
2297 //-------------------------------------------------- |
2150 #ifndef USE_EAP_EXPANDED_TYPES |
2298 |
2151 // There are separate functions (SetTunnelingExpandedEapDataL and GetTunnelingExpandedEapDataL) if USE_EAP_EXPANDED_TYPES is defined. |
2299 // Stores the tunneled EAP type (expanded) to the database. |
2152 |
2300 void EapTlsPeapUtils::SetTunnelingExpandedEapDataL( |
2153 /** |
|
2154 * Sets EAP data to a binary string record in commsdat. |
|
2155 * The old format (NOT USED NOW) is "+123,- 34", + means enabled, - disabled, then id, id is always 3 characters for easy parsing. |
|
2156 * In the new format each EAP type is saved as an unsigned integer of 32 bits ( TUint). |
|
2157 * There is separate binary strings for accepted (enabled) and unaccepted (disabled) tunneled EAP types. |
|
2158 */ |
|
2159 |
|
2160 void EapTlsPeapUtils::SetEapDataL( |
|
2161 RDbNamedDatabase& aDatabase, |
2301 RDbNamedDatabase& aDatabase, |
2162 eap_am_tools_symbian_c * const /*aTools*/, |
2302 eap_am_tools_symbian_c * const /*aTools*/, |
2163 TEapArray &aEaps, |
2303 RPointerArray<TEapExpandedType> &aEnabledEAPArrary, |
|
2304 RPointerArray<TEapExpandedType> &aDisabledEAPArrary, |
2164 const TIndexType aIndexType, |
2305 const TIndexType aIndexType, |
2165 const TInt aIndex, |
2306 const TInt aIndex, |
2166 const eap_type_value_e aTunnelingType, |
2307 const eap_type_value_e aTunnelingType, |
2167 const eap_type_value_e aEapType) |
2308 const eap_type_value_e aEapType) |
2168 { |
2309 { |
2169 #ifdef USE_EAP_EXPANDED_TYPES |
|
2170 |
|
2171 TUint aTunnelingVendorType = aTunnelingType.get_vendor_type(); |
|
2172 TUint aEapVendorType = aEapType.get_vendor_type(); |
|
2173 |
|
2174 #else |
|
2175 |
|
2176 TUint aTunnelingVendorType = static_cast<TUint>(aTunnelingType); |
|
2177 TUint aEapVendorType = static_cast<TUint>(aEapType); |
|
2178 |
|
2179 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
|
2180 |
|
2181 EAP_TRACE_DEBUG_SYMBIAN( |
2310 EAP_TRACE_DEBUG_SYMBIAN( |
2182 (_L("EapTlsPeapUtils::SetEapDataL aIndexType=%d, aIndex=%d, Tunneling vendor type=%d, Eap vendor type=%d, No: of tunneled EAP types=%d \n"), |
2311 (_L("EapTlsPeapUtils::SetTunnelingExpandedEapDataL(): - Start - aIndexType=%d, aIndex=%d, aTunnelingType=0xfe%06x%08x, aEapType=0xfe%06x%08x\n"), |
2183 aIndexType,aIndex, aTunnelingVendorType, aEapVendorType, aEaps.Count()) ); |
2312 aIndexType, |
|
2313 aIndex, |
|
2314 aTunnelingType.get_vendor_id(), |
|
2315 aTunnelingType.get_vendor_type(), |
|
2316 aEapType.get_vendor_id(), |
|
2317 aEapType.get_vendor_type())); |
|
2318 |
|
2319 EAP_TRACE_DEBUG_SYMBIAN( |
|
2320 (_L("Number of Tunneled EAP types: Enabled=%d, Disabled=%d\n"), |
|
2321 aEnabledEAPArrary.Count(), |
|
2322 aDisabledEAPArrary.Count())); |
|
2323 |
|
2324 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: EapTlsPeapUtils::SetTunnelingExpandedEapDataL()\n")); |
2184 |
2325 |
2185 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
2326 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
2186 TPtr sqlStatement = buf->Des(); |
2327 TPtr sqlStatement = buf->Des(); |
2187 |
2328 |
2188 _LIT(KSQLQueryRow, "SELECT %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
2329 _LIT(KSQLQueryRow, "SELECT %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d"); |
2189 |
2330 |
2190 if (aEapType == eap_type_peap) |
2331 if (aEapType == eap_type_peap) |
2191 { |
2332 { |
2192 sqlStatement.Format(KSQLQueryRow, &cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal, |
2333 sqlStatement.Format(KSQLQueryRow, |
|
2334 &cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal, |
2193 &cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal, |
2335 &cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal, |
2194 &KPeapDatabaseTableName, &KServiceType, aIndexType, &KServiceIndex, aIndex, |
2336 &KPeapDatabaseTableName, |
2195 &KTunnelingType, aTunnelingVendorType); |
2337 &KServiceType, |
|
2338 aIndexType, |
|
2339 &KServiceIndex, |
|
2340 aIndex, |
|
2341 &KTunnelingTypeVendorId, |
|
2342 aTunnelingType.get_vendor_id(), |
|
2343 &KTunnelingType, |
|
2344 aTunnelingType.get_vendor_type()); |
2196 } |
2345 } |
2197 #if defined(USE_TTLS_EAP_TYPE) |
2346 #if defined(USE_TTLS_EAP_TYPE) |
2198 else if (aEapType == eap_type_ttls) |
2347 else if (aEapType == eap_type_ttls) |
2199 { |
2348 { |
2200 sqlStatement.Format(KSQLQueryRow, &cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal, |
2349 sqlStatement.Format(KSQLQueryRow, |
|
2350 &cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal, |
2201 &cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal, |
2351 &cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal, |
2202 &KTtlsDatabaseTableName, &KServiceType, aIndexType, &KServiceIndex, aIndex, |
2352 &KTtlsDatabaseTableName, |
2203 &KTunnelingType, aTunnelingVendorType); |
2353 &KServiceType, |
|
2354 aIndexType, |
|
2355 &KServiceIndex, |
|
2356 aIndex, |
|
2357 &KTunnelingTypeVendorId, |
|
2358 aTunnelingType.get_vendor_id(), |
|
2359 &KTunnelingType, |
|
2360 aTunnelingType.get_vendor_type()); |
2204 } |
2361 } |
2205 #endif |
2362 #endif |
2206 |
|
2207 else if (aEapType == eap_type_ttls_plain_pap) |
|
2208 { |
|
2209 sqlStatement.Format(KSQLQueryRow, &cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal, |
|
2210 &cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal, |
|
2211 &KTtlsDatabaseTableName, &KServiceType, aIndexType, &KServiceIndex, aIndex, |
|
2212 &KTunnelingType, aTunnelingVendorType); |
|
2213 } |
|
2214 |
|
2215 #if defined(USE_FAST_EAP_TYPE) |
2363 #if defined(USE_FAST_EAP_TYPE) |
2216 else if (aEapType == eap_type_fast) |
2364 else if (aEapType == eap_type_fast) |
2217 { |
2365 { |
2218 sqlStatement.Format(KSQLQueryRow, &cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal, |
2366 sqlStatement.Format(KSQLQueryRow, |
|
2367 &cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal, |
2219 &cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal, |
2368 &cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal, |
2220 &KFastGeneralSettingsDBTableName, &KServiceType, aIndexType, &KServiceIndex, aIndex, |
2369 &KFastGeneralSettingsDBTableName, |
2221 &KTunnelingType, aTunnelingVendorType); |
2370 &KServiceType, |
|
2371 aIndexType, |
|
2372 &KServiceIndex, |
|
2373 aIndex, |
|
2374 &KTunnelingTypeVendorId, |
|
2375 aTunnelingType.get_vendor_id(), |
|
2376 &KTunnelingType, |
|
2377 aTunnelingType.get_vendor_type()); |
2222 } |
2378 } |
2223 #endif |
2379 #endif |
|
2380 |
|
2381 else if ( aEapType == eap_expanded_type_ttls_plain_pap.get_type() ) |
|
2382 { |
|
2383 sqlStatement.Format(KSQLQueryRow, |
|
2384 &cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal, |
|
2385 &cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal, |
|
2386 &KTtlsDatabaseTableName, |
|
2387 &KServiceType, |
|
2388 aIndexType, |
|
2389 &KServiceIndex, |
|
2390 aIndex, |
|
2391 &KTunnelingTypeVendorId, |
|
2392 aTunnelingType.get_vendor_id(), |
|
2393 &KTunnelingType, |
|
2394 aTunnelingType.get_vendor_type()); |
|
2395 } |
|
2396 |
2224 else |
2397 else |
2225 { |
2398 { |
2226 EAP_TRACE_DEBUG_SYMBIAN( |
2399 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::SetTunnelingExpandedEapDataL - Unsupported EAP-type=0xfe%06x%08x\n"), |
2227 (_L("EapTlsPeapUtils::SetEapDataL - Unsupported EAP type =%d \n"), |
2400 aEapType.get_vendor_id(), |
2228 aEapVendorType)); |
2401 aEapType.get_vendor_type())); |
2229 |
2402 |
2230 // Unsupported EAP type |
2403 // Unsupported EAP type |
2231 User::Leave(KErrNotSupported); |
2404 User::Leave(KErrNotSupported); |
2232 } |
2405 } |
2233 |
2406 |
2234 RDbView view; |
2407 RDbView view; |
2235 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
2408 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
2236 CleanupClosePushL(view); |
2409 CleanupClosePushL(view); |
2237 User::LeaveIfError(view.EvaluateAll()); |
2410 User::LeaveIfError(view.EvaluateAll()); |
2238 User::LeaveIfError(view.FirstL()); |
2411 User::LeaveIfError(view.FirstL()); |
2239 view.UpdateL(); |
2412 view.UpdateL(); |
2240 |
2413 |
2241 TInt eapCount = aEaps.Count(); |
2414 TInt enabledEAPCount = aEnabledEAPArrary.Count(); |
2242 |
2415 TInt disabledEAPCount = aDisabledEAPArrary.Count(); |
2243 HBufC8 *acceptedDbText = HBufC8::NewLC( (sizeof(TUint)) * eapCount ); // 4 bytes (32 bits) for an EAP type, Need to save as TUInt (4 bytes). |
2416 |
2244 HBufC8 *unacceptedDbText = HBufC8::NewLC( (sizeof(TUint)) * eapCount ); // 4 bytes (32 bits) for an EAP type, Need to save as TUInt (4 bytes). |
2417 HBufC8 *acceptedDbText = HBufC8::NewLC( KEapExpandedTypeLength * enabledEAPCount ); // 8 bytes (64 bits) for an EAP type. |
|
2418 HBufC8 *unacceptedDbText = HBufC8::NewLC( KEapExpandedTypeLength * disabledEAPCount ); // 8 bytes (64 bits) for an EAP type. |
2245 |
2419 |
2246 TPtr8 acceptedPtr(acceptedDbText->Des()); |
2420 TPtr8 acceptedPtr(acceptedDbText->Des()); |
2247 TPtr8 unacceptedPtr(unacceptedDbText->Des()); |
2421 TPtr8 unacceptedPtr(unacceptedDbText->Des()); |
2248 |
2422 |
2249 TBuf8<3> UidTmp; |
2423 // Fill in accepted tunneled type. |
2250 |
2424 for(TInt i = 0 ; i< enabledEAPCount; i++) |
2251 for(TInt i = 0 ; i< eapCount; i++) |
2425 { |
2252 { |
2426 EAP_TRACE_DEBUG_SYMBIAN( |
2253 UidTmp.Copy(aEaps[i]->UID); |
2427 (_L("EapTlsPeapUtils::SetTunnelingExpandedEapDataL(): enabled EAP-type=0xfe%06x%08x\n"), |
2254 |
2428 aEnabledEAPArrary[i]->GetVendorId(), |
2255 TLex8 eapUidLex( UidTmp.Right(2) ); // Only last two characters determines the EAP type. |
2429 aEnabledEAPArrary[i]->GetVendorType())); |
2256 TUint eapTypeUint = 0; |
2430 |
2257 |
2431 acceptedPtr.Append(aEnabledEAPArrary[i]->GetValue()); |
2258 User::LeaveIfError( eapUidLex.Val(eapTypeUint, EDecimal) ); |
2432 } |
2259 |
2433 |
2260 TPtrC8 tempEAPtype( reinterpret_cast<TUint8*>(&eapTypeUint), sizeof(TUint) ); |
2434 // Fill in unaccepted tunneled type. |
2261 |
2435 for(TInt i = 0 ; i< disabledEAPCount; i++) |
2262 if( aEaps[i]->Enabled ) |
2436 { |
2263 { |
2437 EAP_TRACE_DEBUG_SYMBIAN( |
2264 // Fill in accepted tunneled type. |
2438 (_L("EapTlsPeapUtils::SetTunnelingExpandedEapDataL(): disabled EAP-type=0xfe%06x%08x\n"), |
2265 acceptedPtr.Append( tempEAPtype ); |
2439 aDisabledEAPArrary[i]->GetVendorId(), |
2266 } |
2440 aDisabledEAPArrary[i]->GetVendorType())); |
2267 else |
2441 |
2268 { |
2442 unacceptedPtr.Append(aDisabledEAPArrary[i]->GetValue()); |
2269 // Fill in unaccepted tunneled type. |
|
2270 unacceptedPtr.Append( tempEAPtype); |
|
2271 } |
|
2272 } |
2443 } |
2273 |
2444 |
2274 // Save the strings in the DB. |
2445 // Save the strings in the DB. |
2275 |
2446 |
2276 // Get column set so we get the correct column numbers |
2447 // Get column set so we get the correct column numbers |
2291 |
2462 |
2292 CleanupStack::PopAndDestroy( colSet ); // Delete colSet. |
2463 CleanupStack::PopAndDestroy( colSet ); // Delete colSet. |
2293 |
2464 |
2294 view.PutL(); |
2465 view.PutL(); |
2295 |
2466 |
2296 EAP_TRACE_DATA_DEBUG_SYMBIAN(("EapTlsPeapUtils::SetEapDataL- Enabled extended EAP type data added to DB:", |
2467 EAP_TRACE_DATA_DEBUG_SYMBIAN(("EapTlsPeapUtils::SetTunnelingExpandedEapDataL- Enabled extended EAP type data added to DB:", |
2297 acceptedPtr.Ptr(), |
2468 acceptedPtr.Ptr(), |
2298 acceptedPtr.Size() ) ); |
2469 acceptedPtr.Size() ) ); |
2299 |
2470 |
2300 EAP_TRACE_DATA_DEBUG_SYMBIAN(("EapTlsPeapUtils::SetEapDataL- Disabled extended EAP type data added to DB:", |
2471 EAP_TRACE_DATA_DEBUG_SYMBIAN(("EapTlsPeapUtils::SetTunnelingExpandedEapDataL- Disabled extended EAP type data added to DB:", |
2301 unacceptedPtr.Ptr(), |
2472 unacceptedPtr.Ptr(), |
2302 unacceptedPtr.Size() ) ); |
2473 unacceptedPtr.Size() ) ); |
2303 |
2474 |
2304 CleanupStack::PopAndDestroy(unacceptedDbText); // Delete unacceptedDbText |
2475 CleanupStack::PopAndDestroy(unacceptedDbText); // Delete unacceptedDbText |
2305 CleanupStack::PopAndDestroy(acceptedDbText); // Delete acceptedDbText |
2476 CleanupStack::PopAndDestroy(acceptedDbText); // Delete acceptedDbText |
2306 CleanupStack::PopAndDestroy(&view); // Close view |
2477 CleanupStack::PopAndDestroy(&view); // Close view |
2307 CleanupStack::PopAndDestroy(buf); // Delete buf |
2478 CleanupStack::PopAndDestroy(buf); // Delete buf |
2308 } |
2479 } |
2309 |
2480 |
2310 /** |
2481 // --------------------------------------------------------- |
2311 * Gets Eapdata from corresponding table in commdb |
2482 |
2312 * see format in SetEapDAtaL |
2483 // Retrieves the tunneled EAP type (expanded) from the database . |
2313 */ |
2484 void EapTlsPeapUtils::GetTunnelingExpandedEapDataL( |
2314 void EapTlsPeapUtils::GetEapDataL( |
|
2315 RDbNamedDatabase& aDatabase, |
2485 RDbNamedDatabase& aDatabase, |
2316 eap_am_tools_symbian_c * const /*aTools*/, |
2486 eap_am_tools_symbian_c * const /*aTools*/, |
2317 TEapArray &aEaps, |
2487 RPointerArray<TEapExpandedType> &aEnabledEAPArrary, |
|
2488 RPointerArray<TEapExpandedType> &aDisabledEAPArrary, |
2318 const TIndexType aIndexType, |
2489 const TIndexType aIndexType, |
2319 const TInt aIndex, |
2490 const TInt aIndex, |
2320 const eap_type_value_e aTunnelingType, |
2491 const eap_type_value_e aTunnelingType, |
2321 const eap_type_value_e aEapType) |
2492 const eap_type_value_e aEapType) |
2322 { |
2493 { |
2323 #ifdef USE_EAP_EXPANDED_TYPES |
|
2324 |
|
2325 TUint aTunnelingVendorType = aTunnelingType.get_vendor_type(); |
|
2326 TUint aEapVendorType = aEapType.get_vendor_type(); |
|
2327 |
|
2328 #else |
|
2329 |
|
2330 TUint aTunnelingVendorType = static_cast<TUint>(aTunnelingType); |
|
2331 TUint aEapVendorType = static_cast<TUint>(aEapType); |
|
2332 |
|
2333 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
|
2334 |
|
2335 EAP_TRACE_DEBUG_SYMBIAN( |
2494 EAP_TRACE_DEBUG_SYMBIAN( |
2336 (_L("EapTlsPeapUtils::GetEapDataL aIndexType=%d, aIndex=%d, Tunneling vendor type=%d, Eap vendor type=%d \n"), |
2495 (_L("EapTlsPeapUtils::GetTunnelingExpandedEapDataL(): - Start - aIndexType=%d, aIndex=%d, aTunnelingType=0xfe%06x%08x, aEapType=0xfe%06x%08x\n"), |
2337 aIndexType,aIndex, aTunnelingVendorType, aEapVendorType)); |
2496 aIndexType, |
|
2497 aIndex, |
|
2498 aTunnelingType.get_vendor_id(), |
|
2499 aTunnelingType.get_vendor_type(), |
|
2500 aEapType.get_vendor_id(), |
|
2501 aEapType.get_vendor_type())); |
|
2502 |
|
2503 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: EapTlsPeapUtils::GetTunnelingExpandedEapDataL()\n")); |
2338 |
2504 |
2339 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
2505 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
2340 TPtr sqlStatement = buf->Des(); |
2506 TPtr sqlStatement = buf->Des(); |
2341 |
2507 |
2342 _LIT(KSQLQueryRow, "SELECT %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
2508 _LIT(KSQLQueryRow, "SELECT %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d"); |
2343 |
2509 |
2344 if (aEapType == eap_type_peap) |
2510 if (aEapType == eap_type_peap) |
2345 { |
2511 { |
2346 sqlStatement.Format(KSQLQueryRow, &cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal, |
2512 sqlStatement.Format(KSQLQueryRow, |
|
2513 &cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal, |
2347 &cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal, |
2514 &cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal, |
2348 &KPeapDatabaseTableName, &KServiceType, aIndexType, &KServiceIndex, aIndex, |
2515 &KPeapDatabaseTableName, |
2349 &KTunnelingType, aTunnelingVendorType); |
2516 &KServiceType, |
|
2517 aIndexType, |
|
2518 &KServiceIndex, |
|
2519 aIndex, |
|
2520 &KTunnelingTypeVendorId, |
|
2521 aTunnelingType.get_vendor_id(), |
|
2522 &KTunnelingType, |
|
2523 aTunnelingType.get_vendor_type()); |
2350 } |
2524 } |
2351 #if defined(USE_TTLS_EAP_TYPE) |
2525 #if defined(USE_TTLS_EAP_TYPE) |
2352 else if (aEapType == eap_type_ttls) |
2526 else if (aEapType == eap_type_ttls) |
2353 { |
2527 { |
2354 sqlStatement.Format(KSQLQueryRow, &cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal, |
2528 sqlStatement.Format(KSQLQueryRow, |
|
2529 &cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal, |
2355 &cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal, |
2530 &cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal, |
2356 &KTtlsDatabaseTableName, &KServiceType, aIndexType, &KServiceIndex, aIndex, |
2531 &KTtlsDatabaseTableName, |
2357 &KTunnelingType, aTunnelingVendorType); |
2532 &KServiceType, |
|
2533 aIndexType, |
|
2534 &KServiceIndex, |
|
2535 aIndex, |
|
2536 &KTunnelingTypeVendorId, |
|
2537 aTunnelingType.get_vendor_id(), |
|
2538 &KTunnelingType, |
|
2539 aTunnelingType.get_vendor_type()); |
2358 } |
2540 } |
2359 #endif |
2541 #endif |
2360 |
|
2361 else if (aEapType == eap_type_ttls_plain_pap) |
|
2362 { |
|
2363 sqlStatement.Format(KSQLQueryRow, &cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal, |
|
2364 &cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal, |
|
2365 &KTtlsDatabaseTableName, &KServiceType, aIndexType, &KServiceIndex, aIndex, |
|
2366 &KTunnelingType, aTunnelingVendorType); |
|
2367 } |
|
2368 |
|
2369 #if defined(USE_FAST_EAP_TYPE) |
2542 #if defined(USE_FAST_EAP_TYPE) |
2370 else if (aEapType == eap_type_fast) |
2543 else if (aEapType == eap_type_fast) |
2371 { |
2544 { |
2372 sqlStatement.Format(KSQLQueryRow, &cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal, |
2545 sqlStatement.Format(KSQLQueryRow, |
|
2546 &cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal, |
2373 &cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal, |
2547 &cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal, |
2374 &KFastGeneralSettingsDBTableName, &KServiceType, aIndexType, &KServiceIndex, aIndex, |
2548 &KFastGeneralSettingsDBTableName, |
2375 &KTunnelingType, aTunnelingVendorType); |
2549 &KServiceType, |
|
2550 aIndexType, |
|
2551 &KServiceIndex, |
|
2552 aIndex, |
|
2553 &KTunnelingTypeVendorId, |
|
2554 aTunnelingType.get_vendor_id(), |
|
2555 &KTunnelingType, |
|
2556 aTunnelingType.get_vendor_type()); |
2376 } |
2557 } |
2377 #endif |
2558 #endif |
|
2559 |
|
2560 else if (aEapType == eap_expanded_type_ttls_plain_pap.get_type() ) |
|
2561 { |
|
2562 sqlStatement.Format(KSQLQueryRow, |
|
2563 &cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal, |
|
2564 &cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal, |
|
2565 &KTtlsDatabaseTableName, |
|
2566 &KServiceType, |
|
2567 aIndexType, |
|
2568 &KServiceIndex, |
|
2569 aIndex, |
|
2570 &KTunnelingTypeVendorId, |
|
2571 aTunnelingType.get_vendor_id(), |
|
2572 &KTunnelingType, |
|
2573 aTunnelingType.get_vendor_type()); |
|
2574 } |
|
2575 |
2378 else |
2576 else |
2379 { |
2577 { |
2380 EAP_TRACE_DEBUG_SYMBIAN( |
2578 EAP_TRACE_DEBUG_SYMBIAN((_L("ERROR: EapTlsPeapUtils::GetTunnelingExpandedEapDataL(): - Unsupported EAP-type=0xfe%06x%08x\n"), |
2381 (_L("EapTlsPeapUtils::GetEapDataL - Unsupported EAP type=%d \n"), |
2579 aEapType.get_vendor_id(), |
2382 aEapVendorType)); |
2580 aEapType.get_vendor_type())); |
2383 |
2581 |
2384 // Unsupported EAP type |
2582 // Unsupported EAP type |
2385 User::Leave(KErrNotSupported); |
2583 User::Leave(KErrNotSupported); |
2386 } |
2584 } |
2387 |
2585 |
2401 TPtrC8 acceptedEAPData = view.ColDes8(colSet->ColNo(cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal)); |
2599 TPtrC8 acceptedEAPData = view.ColDes8(colSet->ColNo(cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal)); |
2402 TPtrC8 unacceptedEAPData = view.ColDes8(colSet->ColNo(cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal)); |
2600 TPtrC8 unacceptedEAPData = view.ColDes8(colSet->ColNo(cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal)); |
2403 |
2601 |
2404 CleanupStack::PopAndDestroy( colSet ); // Delete colSet. |
2602 CleanupStack::PopAndDestroy( colSet ); // Delete colSet. |
2405 |
2603 |
2406 EAP_TRACE_DATA_DEBUG_SYMBIAN(("EapTlsPeapUtils::GetEapDataL- Enabled extended EAP type data from DB:", |
2604 EAP_TRACE_DATA_DEBUG_SYMBIAN(("EapTlsPeapUtils::GetTunnelingExpandedEapDataL- Enabled extended EAP type data from DB:", |
2407 acceptedEAPData.Ptr(), |
2605 acceptedEAPData.Ptr(), |
2408 acceptedEAPData.Size() ) ); |
2606 acceptedEAPData.Size() ) ); |
2409 |
2607 |
2410 EAP_TRACE_DATA_DEBUG_SYMBIAN(("EapTlsPeapUtils::GetEapDataL- Disabled extended EAP type data from DB:", |
2608 EAP_TRACE_DATA_DEBUG_SYMBIAN(("EapTlsPeapUtils::GetTunnelingExpandedEapDataL- Disabled extended EAP type data from DB:", |
2411 unacceptedEAPData.Ptr(), |
2609 unacceptedEAPData.Ptr(), |
2412 unacceptedEAPData.Size() ) ); |
2610 unacceptedEAPData.Size() ) ); |
2413 |
2611 |
2414 aEaps.ResetAndDestroy(); |
2612 aEnabledEAPArrary.ResetAndDestroy(); |
|
2613 aDisabledEAPArrary.ResetAndDestroy(); |
2415 |
2614 |
2416 TUint acceptedLength = acceptedEAPData.Length(); |
2615 TUint acceptedLength = acceptedEAPData.Length(); |
2417 TUint unacceptedLength = unacceptedEAPData.Length(); |
2616 TUint unacceptedLength = unacceptedEAPData.Length(); |
2418 |
2617 |
2419 TEap *eapTmp; |
2618 TEapExpandedType *expandedEAPTmp = 0; |
2420 |
|
2421 TUint index = 0; |
2619 TUint index = 0; |
2422 |
|
2423 _LIT8(KUIDFormat,"%u"); |
|
2424 |
2620 |
2425 // For accepted or enabled tunneled EAP types. |
2621 // For accepted or enabled tunneled EAP types. |
2426 while(index < acceptedLength) |
2622 while(index < acceptedLength) |
2427 { |
2623 { |
2428 eapTmp = new (ELeave)TEap; |
2624 expandedEAPTmp = new TEapExpandedType; |
2429 |
|
2430 eapTmp->Enabled=ETrue; // All EAP types in here are enabled. |
|
2431 |
|
2432 eapTmp->UID.Zero(); |
|
2433 |
|
2434 // Get the UID from data from the DB. |
|
2435 TPtrC8 tempEAPtype( acceptedEAPData.Mid(index, sizeof(TUint)) ); |
|
2436 |
|
2437 EAP_TRACE_DATA_DEBUG_SYMBIAN(("EapTlsPeapUtils::GetEapDataL- extracted EAP type:", |
|
2438 tempEAPtype.Ptr(), |
|
2439 tempEAPtype.Size() ) ); |
|
2440 |
|
2441 TUint eapTypeUint = *(tempEAPtype.Ptr()); // All EAP types are saved as TUInt. |
|
2442 |
|
2443 eapTmp->UID.Format(KUIDFormat,eapTypeUint); |
|
2444 |
|
2445 aEaps.Append(eapTmp); |
|
2446 |
|
2447 index = index + sizeof(TUint); |
|
2448 |
|
2449 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::GetEapDataL - Appended enabled-EAP type=%s \n"),eapTmp->UID.Ptr()) ); |
|
2450 } |
|
2451 |
|
2452 index = 0; |
|
2453 |
|
2454 // For unaccepted or disabled tunneled EAP types. |
|
2455 while(index < unacceptedLength) |
|
2456 { |
|
2457 eapTmp = new (ELeave)TEap; |
|
2458 |
|
2459 eapTmp->Enabled=EFalse; // All EAP types in here are disabled. |
|
2460 |
|
2461 eapTmp->UID.Zero(); |
|
2462 |
|
2463 // Get the UID from data from the DB. |
|
2464 TPtrC8 tempEAPtype( unacceptedEAPData.Mid(index, sizeof(TUint)) ); |
|
2465 |
|
2466 EAP_TRACE_DATA_DEBUG_SYMBIAN(("EapTlsPeapUtils::GetEapDataL- extracted EAP type:", |
|
2467 tempEAPtype.Ptr(), |
|
2468 tempEAPtype.Size() ) ); |
|
2469 |
|
2470 TUint eapTypeUint = *(tempEAPtype.Ptr()); // All EAP types are saved as TUint. |
|
2471 |
|
2472 eapTmp->UID.Format(KUIDFormat,eapTypeUint); |
|
2473 |
|
2474 aEaps.Append(eapTmp); |
|
2475 |
|
2476 index = index + sizeof(TUint); |
|
2477 |
|
2478 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::GetEapDataL - Appended disabled-EAP type=%s \n"),eapTmp->UID.Ptr()) ); |
|
2479 } |
|
2480 |
|
2481 CleanupStack::PopAndDestroy(&view); // Close view |
|
2482 CleanupStack::PopAndDestroy(buf); // Delete buf |
|
2483 } |
|
2484 |
|
2485 #endif // #ifndef USE_EAP_EXPANDED_TYPES |
|
2486 |
|
2487 //-------------------------------------------------- |
|
2488 |
|
2489 #ifdef USE_EAP_EXPANDED_TYPES |
|
2490 |
|
2491 // Stores the tunneled EAP type (expanded) to the database. |
|
2492 void EapTlsPeapUtils::SetTunnelingExpandedEapDataL( |
|
2493 RDbNamedDatabase& aDatabase, |
|
2494 eap_am_tools_symbian_c * const /*aTools*/, |
|
2495 RExpandedEapTypePtrArray &aEnabledEAPArrary, |
|
2496 RExpandedEapTypePtrArray &aDisabledEAPArrary, |
|
2497 const TIndexType aIndexType, |
|
2498 const TInt aIndex, |
|
2499 const eap_type_value_e aTunnelingType, |
|
2500 const eap_type_value_e aEapType) |
|
2501 { |
|
2502 TUint aTunnelingVendorType = aTunnelingType.get_vendor_type(); |
|
2503 TUint aEapVendorType = aEapType.get_vendor_type(); |
|
2504 |
|
2505 EAP_TRACE_DEBUG_SYMBIAN( |
|
2506 (_L("EapTlsPeapUtils::SetTunnelingExpandedEapDataL:aIndexType=%d, aIndex=%d, Tunneling vendor type=%d, Eap vendor type=%d\n"), |
|
2507 aIndexType,aIndex, aTunnelingVendorType, aEapVendorType)); |
|
2508 |
|
2509 EAP_TRACE_DEBUG_SYMBIAN( |
|
2510 (_L("Number of Tunneled EAP types: Enabled=%d, Disabled=%d\n"), |
|
2511 aEnabledEAPArrary.Count(), aDisabledEAPArrary.Count())); |
|
2512 |
|
2513 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
|
2514 TPtr sqlStatement = buf->Des(); |
|
2515 |
|
2516 _LIT(KSQLQueryRow, "SELECT %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
|
2517 |
|
2518 if (aEapType == eap_type_peap) |
|
2519 { |
|
2520 sqlStatement.Format(KSQLQueryRow, &cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal, |
|
2521 &cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal, |
|
2522 &KPeapDatabaseTableName, &KServiceType, aIndexType, &KServiceIndex, aIndex, |
|
2523 &KTunnelingType, aTunnelingVendorType); |
|
2524 } |
|
2525 #if defined(USE_TTLS_EAP_TYPE) |
|
2526 else if (aEapType == eap_type_ttls) |
|
2527 { |
|
2528 sqlStatement.Format(KSQLQueryRow, &cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal, |
|
2529 &cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal, |
|
2530 &KTtlsDatabaseTableName, &KServiceType, aIndexType, &KServiceIndex, aIndex, |
|
2531 &KTunnelingType, aTunnelingVendorType); |
|
2532 } |
|
2533 #endif |
|
2534 #if defined(USE_FAST_EAP_TYPE) |
|
2535 else if (aEapType == eap_type_fast) |
|
2536 { |
|
2537 sqlStatement.Format(KSQLQueryRow, &cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal, |
|
2538 &cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal, |
|
2539 &KFastGeneralSettingsDBTableName, &KServiceType, aIndexType, &KServiceIndex, aIndex, |
|
2540 &KTunnelingType, aTunnelingVendorType); |
|
2541 } |
|
2542 #endif |
|
2543 |
|
2544 else if ( aEapType == eap_type_ttls_plain_pap ) |
|
2545 { |
|
2546 sqlStatement.Format(KSQLQueryRow, &cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal, |
|
2547 &cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal, |
|
2548 &KTtlsDatabaseTableName, &KServiceType, aIndexType, &KServiceIndex, aIndex, |
|
2549 &KTunnelingType, aTunnelingVendorType); |
|
2550 } |
|
2551 |
|
2552 else |
|
2553 { |
|
2554 EAP_TRACE_DEBUG_SYMBIAN( |
|
2555 (_L("EapTlsPeapUtils::SetTunnelingExpandedEapDataL - Unsupported EAP type =%d \n"), |
|
2556 aEapVendorType)); |
|
2557 |
|
2558 // Unsupported EAP type |
|
2559 User::Leave(KErrNotSupported); |
|
2560 } |
|
2561 |
|
2562 RDbView view; |
|
2563 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
|
2564 CleanupClosePushL(view); |
|
2565 User::LeaveIfError(view.EvaluateAll()); |
|
2566 User::LeaveIfError(view.FirstL()); |
|
2567 view.UpdateL(); |
|
2568 |
|
2569 TInt enabledEAPCount = aEnabledEAPArrary.Count(); |
|
2570 TInt disabledEAPCount = aDisabledEAPArrary.Count(); |
|
2571 |
|
2572 HBufC8 *acceptedDbText = HBufC8::NewLC( KExpandedEAPTypeSize * enabledEAPCount ); // 8 bytes (64 bits) for an EAP type. |
|
2573 HBufC8 *unacceptedDbText = HBufC8::NewLC( KExpandedEAPTypeSize * disabledEAPCount ); // 8 bytes (64 bits) for an EAP type. |
|
2574 |
|
2575 TPtr8 acceptedPtr(acceptedDbText->Des()); |
|
2576 TPtr8 unacceptedPtr(unacceptedDbText->Des()); |
|
2577 |
|
2578 // Fill in accepted tunneled type. |
|
2579 for(TInt i = 0 ; i< enabledEAPCount; i++) |
|
2580 { |
|
2581 acceptedPtr.Append(aEnabledEAPArrary[i]->iExpandedEAPType); |
|
2582 } |
|
2583 |
|
2584 // Fill in unaccepted tunneled type. |
|
2585 for(TInt i = 0 ; i< disabledEAPCount; i++) |
|
2586 { |
|
2587 unacceptedPtr.Append(aDisabledEAPArrary[i]->iExpandedEAPType); |
|
2588 } |
|
2589 |
|
2590 // Save the strings in the DB. |
|
2591 |
|
2592 // Get column set so we get the correct column numbers |
|
2593 CDbColSet* colSet = view.ColSetL(); |
|
2594 CleanupStack::PushL(colSet); |
|
2595 |
|
2596 // Validate length of strings |
|
2597 if(acceptedPtr.Length() > KMaxTunneledTypeStringLengthInDB |
|
2598 || unacceptedPtr.Length() > KMaxTunneledTypeStringLengthInDB) |
|
2599 { |
|
2600 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::SetTunnelingExpandedEapDataL - Too long Tunneled EAP type string \n") ) ); |
|
2601 |
|
2602 User::Leave(KErrArgument); |
|
2603 } |
|
2604 |
|
2605 view.SetColL(colSet->ColNo(cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal), acceptedPtr); |
|
2606 view.SetColL(colSet->ColNo(cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal), unacceptedPtr); |
|
2607 |
|
2608 CleanupStack::PopAndDestroy( colSet ); // Delete colSet. |
|
2609 |
|
2610 view.PutL(); |
|
2611 |
|
2612 EAP_TRACE_DATA_DEBUG_SYMBIAN(("EapTlsPeapUtils::SetTunnelingExpandedEapDataL- Enabled extended EAP type data added to DB:", |
|
2613 acceptedPtr.Ptr(), |
|
2614 acceptedPtr.Size() ) ); |
|
2615 |
|
2616 EAP_TRACE_DATA_DEBUG_SYMBIAN(("EapTlsPeapUtils::SetTunnelingExpandedEapDataL- Disabled extended EAP type data added to DB:", |
|
2617 unacceptedPtr.Ptr(), |
|
2618 unacceptedPtr.Size() ) ); |
|
2619 |
|
2620 CleanupStack::PopAndDestroy(unacceptedDbText); // Delete unacceptedDbText |
|
2621 CleanupStack::PopAndDestroy(acceptedDbText); // Delete acceptedDbText |
|
2622 CleanupStack::PopAndDestroy(&view); // Close view |
|
2623 CleanupStack::PopAndDestroy(buf); // Delete buf |
|
2624 } |
|
2625 |
|
2626 // Retrieves the tunneled EAP type (expanded) from the database . |
|
2627 void EapTlsPeapUtils::GetTunnelingExpandedEapDataL( |
|
2628 RDbNamedDatabase& aDatabase, |
|
2629 eap_am_tools_symbian_c * const /*aTools*/, |
|
2630 RExpandedEapTypePtrArray &aEnabledEAPArrary, |
|
2631 RExpandedEapTypePtrArray &aDisabledEAPArrary, |
|
2632 const TIndexType aIndexType, |
|
2633 const TInt aIndex, |
|
2634 const eap_type_value_e aTunnelingType, |
|
2635 const eap_type_value_e aEapType) |
|
2636 { |
|
2637 TUint aTunnelingVendorType = aTunnelingType.get_vendor_type(); |
|
2638 TUint aEapVendorType = aEapType.get_vendor_type(); |
|
2639 |
|
2640 EAP_TRACE_DEBUG_SYMBIAN( |
|
2641 (_L("EapTlsPeapUtils::GetTunnelingExpandedEapDataL aIndexType=%d, aIndex=%d, Tunneling vendor type=%d, Eap vendor type=%d \n"), |
|
2642 aIndexType,aIndex, aTunnelingVendorType, aEapVendorType)); |
|
2643 |
|
2644 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
|
2645 TPtr sqlStatement = buf->Des(); |
|
2646 |
|
2647 _LIT(KSQLQueryRow, "SELECT %S, %S FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
|
2648 |
|
2649 if (aEapType == eap_type_peap) |
|
2650 { |
|
2651 sqlStatement.Format(KSQLQueryRow, &cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal, |
|
2652 &cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal, |
|
2653 &KPeapDatabaseTableName, &KServiceType, aIndexType, &KServiceIndex, aIndex, |
|
2654 &KTunnelingType, aTunnelingVendorType); |
|
2655 } |
|
2656 #if defined(USE_TTLS_EAP_TYPE) |
|
2657 else if (aEapType == eap_type_ttls) |
|
2658 { |
|
2659 sqlStatement.Format(KSQLQueryRow, &cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal, |
|
2660 &cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal, |
|
2661 &KTtlsDatabaseTableName, &KServiceType, aIndexType, &KServiceIndex, aIndex, |
|
2662 &KTunnelingType, aTunnelingVendorType); |
|
2663 } |
|
2664 #endif |
|
2665 #if defined(USE_FAST_EAP_TYPE) |
|
2666 else if (aEapType == eap_type_fast) |
|
2667 { |
|
2668 sqlStatement.Format(KSQLQueryRow, &cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal, |
|
2669 &cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal, |
|
2670 &KFastGeneralSettingsDBTableName, &KServiceType, aIndexType, &KServiceIndex, aIndex, |
|
2671 &KTunnelingType, aTunnelingVendorType); |
|
2672 } |
|
2673 #endif |
|
2674 |
|
2675 else if (aEapType == eap_type_ttls_plain_pap ) |
|
2676 { |
|
2677 sqlStatement.Format(KSQLQueryRow, &cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal, |
|
2678 &cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal, |
|
2679 &KTtlsDatabaseTableName, &KServiceType, aIndexType, &KServiceIndex, aIndex, |
|
2680 &KTunnelingType, aTunnelingVendorType); |
|
2681 } |
|
2682 |
|
2683 else |
|
2684 { |
|
2685 EAP_TRACE_DEBUG_SYMBIAN( |
|
2686 (_L("EapTlsPeapUtils::GetTunnelingExpandedEapDataL - Unsupported EAP type=%d \n"), |
|
2687 aEapVendorType)); |
|
2688 |
|
2689 // Unsupported EAP type |
|
2690 User::Leave(KErrNotSupported); |
|
2691 } |
|
2692 |
|
2693 RDbView view; |
|
2694 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
|
2695 CleanupClosePushL(view); |
|
2696 User::LeaveIfError(view.EvaluateAll()); |
|
2697 |
|
2698 User::LeaveIfError(view.FirstL()); |
|
2699 |
|
2700 view.GetL(); |
|
2701 |
|
2702 // Get column set so we get the correct column numbers |
|
2703 CDbColSet* colSet = view.ColSetL(); |
|
2704 CleanupStack::PushL(colSet); |
|
2705 |
|
2706 TPtrC8 acceptedEAPData = view.ColDes8(colSet->ColNo(cf_str_PEAP_accepted_tunneled_client_types_hex_data_literal)); |
|
2707 TPtrC8 unacceptedEAPData = view.ColDes8(colSet->ColNo(cf_str_PEAP_unaccepted_tunneled_client_types_hex_data_literal)); |
|
2708 |
|
2709 CleanupStack::PopAndDestroy( colSet ); // Delete colSet. |
|
2710 |
|
2711 EAP_TRACE_DATA_DEBUG_SYMBIAN(("EapTlsPeapUtils::GetTunnelingExpandedEapDataL- Enabled extended EAP type data from DB:", |
|
2712 acceptedEAPData.Ptr(), |
|
2713 acceptedEAPData.Size() ) ); |
|
2714 |
|
2715 EAP_TRACE_DATA_DEBUG_SYMBIAN(("EapTlsPeapUtils::GetTunnelingExpandedEapDataL- Disabled extended EAP type data from DB:", |
|
2716 unacceptedEAPData.Ptr(), |
|
2717 unacceptedEAPData.Size() ) ); |
|
2718 |
|
2719 aEnabledEAPArrary.ResetAndDestroy(); |
|
2720 aDisabledEAPArrary.ResetAndDestroy(); |
|
2721 |
|
2722 TUint acceptedLength = acceptedEAPData.Length(); |
|
2723 TUint unacceptedLength = unacceptedEAPData.Length(); |
|
2724 |
|
2725 SExpandedEAPType *expandedEAPTmp = 0; |
|
2726 TUint index = 0; |
|
2727 |
|
2728 // For accepted or enabled tunneled EAP types. |
|
2729 while(index < acceptedLength) |
|
2730 { |
|
2731 expandedEAPTmp = new SExpandedEAPType; |
|
2732 |
2625 |
2733 if (expandedEAPTmp == 0) |
2626 if (expandedEAPTmp == 0) |
2734 { |
2627 { |
2735 aEnabledEAPArrary.ResetAndDestroy(); |
2628 aEnabledEAPArrary.ResetAndDestroy(); |
2736 aDisabledEAPArrary.ResetAndDestroy(); |
2629 aDisabledEAPArrary.ResetAndDestroy(); |
2737 User::LeaveIfError(KErrNoMemory); |
2630 User::LeaveIfError(KErrNoMemory); |
2738 } |
2631 } |
2739 |
2632 |
2740 expandedEAPTmp->iExpandedEAPType = acceptedEAPData.Mid(index, KExpandedEAPTypeSize); |
2633 *expandedEAPTmp = acceptedEAPData.Mid(index, KEapExpandedTypeLength); |
2741 |
2634 |
2742 EAP_TRACE_DATA_DEBUG_SYMBIAN(("Extracted EAP type:", |
2635 EAP_TRACE_DEBUG_SYMBIAN( |
2743 expandedEAPTmp->iExpandedEAPType.Ptr(), |
2636 (_L("EapTlsPeapUtils::GetTunnelingExpandedEapDataL(): enabled EAP-type=0xfe%06x%08x\n"), |
2744 expandedEAPTmp->iExpandedEAPType.Size() ) ); |
2637 expandedEAPTmp->GetVendorId(), |
2745 |
2638 expandedEAPTmp->GetVendorType())); |
2746 aEnabledEAPArrary.Append(expandedEAPTmp); |
2639 |
2747 |
2640 aEnabledEAPArrary.AppendL(expandedEAPTmp); |
2748 index = index + KExpandedEAPTypeSize; |
2641 |
|
2642 index = index + KEapExpandedTypeLength; |
2749 } |
2643 } |
2750 |
2644 |
2751 index = 0; |
2645 index = 0; |
2752 |
2646 |
2753 // For unaccepted or disabled tunneled EAP types. |
2647 // For unaccepted or disabled tunneled EAP types. |
2754 while(index < unacceptedLength) |
2648 while(index < unacceptedLength) |
2755 { |
2649 { |
2756 expandedEAPTmp = new SExpandedEAPType; |
2650 expandedEAPTmp = new TEapExpandedType; |
2757 |
2651 |
2758 if (expandedEAPTmp == 0) |
2652 if (expandedEAPTmp == 0) |
2759 { |
2653 { |
2760 aEnabledEAPArrary.ResetAndDestroy(); |
2654 aEnabledEAPArrary.ResetAndDestroy(); |
2761 aDisabledEAPArrary.ResetAndDestroy(); |
2655 aDisabledEAPArrary.ResetAndDestroy(); |
2762 User::LeaveIfError(KErrNoMemory); |
2656 User::LeaveIfError(KErrNoMemory); |
2763 } |
2657 } |
2764 |
2658 |
2765 expandedEAPTmp->iExpandedEAPType = unacceptedEAPData.Mid(index, KExpandedEAPTypeSize); |
2659 *expandedEAPTmp = unacceptedEAPData.Mid(index, KEapExpandedTypeLength); |
2766 |
2660 |
2767 EAP_TRACE_DATA_DEBUG_SYMBIAN(("Extracted EAP type:", |
2661 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::SetTunnelingExpandedEapDataL(): disabled EAP-type=0xfe%06x%08x\n"), |
2768 expandedEAPTmp->iExpandedEAPType.Ptr(), |
2662 expandedEAPTmp->GetVendorId(), |
2769 expandedEAPTmp->iExpandedEAPType.Size() ) ); |
2663 expandedEAPTmp->GetVendorType())); |
2770 |
2664 |
2771 aDisabledEAPArrary.Append(expandedEAPTmp); |
2665 aDisabledEAPArrary.AppendL(expandedEAPTmp); |
2772 |
2666 |
2773 index = index + KExpandedEAPTypeSize; |
2667 index = index + KEapExpandedTypeLength; |
2774 } |
2668 } |
2775 |
2669 |
2776 CleanupStack::PopAndDestroy(&view); // Close view |
2670 CleanupStack::PopAndDestroy(&view); // Close view |
2777 CleanupStack::PopAndDestroy(buf); // Delete buf |
2671 CleanupStack::PopAndDestroy(buf); // Delete buf |
2778 } |
2672 } |
2779 |
2673 |
2780 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
|
2781 |
|
2782 //-------------------------------------------------- |
2674 //-------------------------------------------------- |
2783 |
2675 |
2784 TBool EapTlsPeapUtils::CipherSuiteUseRSAKeys(tls_cipher_suites_e aCipherSuite) |
2676 TBool EapTlsPeapUtils::CipherSuiteUseRSAKeys(tls_cipher_suites_e aCipherSuite) |
2785 { |
2677 { |
|
2678 EAP_TRACE_DEBUG_SYMBIAN( |
|
2679 (_L("EapTlsPeapUtils::CipherSuiteUseRSAKeys(): aCipherSuite=%d\n"), |
|
2680 aCipherSuite)); |
|
2681 |
|
2682 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: EapTlsPeapUtils::CipherSuiteUseRSAKeys()\n")); |
|
2683 |
2786 if (aCipherSuite == tls_cipher_suites_TLS_RSA_WITH_3DES_EDE_CBC_SHA |
2684 if (aCipherSuite == tls_cipher_suites_TLS_RSA_WITH_3DES_EDE_CBC_SHA |
2787 || aCipherSuite == tls_cipher_suites_TLS_RSA_WITH_AES_128_CBC_SHA |
2685 || aCipherSuite == tls_cipher_suites_TLS_RSA_WITH_AES_128_CBC_SHA |
2788 || aCipherSuite == tls_cipher_suites_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA |
2686 || aCipherSuite == tls_cipher_suites_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA |
2789 || aCipherSuite == tls_cipher_suites_TLS_DHE_RSA_WITH_AES_128_CBC_SHA |
2687 || aCipherSuite == tls_cipher_suites_TLS_DHE_RSA_WITH_AES_128_CBC_SHA |
2790 || aCipherSuite == tls_cipher_suites_TLS_RSA_WITH_RC4_128_MD5 |
2688 || aCipherSuite == tls_cipher_suites_TLS_RSA_WITH_RC4_128_MD5 |
2836 const TIndexType aIndexType, |
2746 const TIndexType aIndexType, |
2837 const TInt aIndex, |
2747 const TInt aIndex, |
2838 const eap_type_value_e aTunnelingType, |
2748 const eap_type_value_e aTunnelingType, |
2839 const eap_type_value_e aEapType) |
2749 const eap_type_value_e aEapType) |
2840 { |
2750 { |
2841 #ifdef USE_EAP_EXPANDED_TYPES |
|
2842 |
|
2843 TUint aTunnelingVendorType = aTunnelingType.get_vendor_type(); |
|
2844 TUint aEapVendorType = aEapType.get_vendor_type(); |
|
2845 |
|
2846 #else |
|
2847 |
|
2848 TUint aTunnelingVendorType = static_cast<TUint>(aTunnelingType); |
|
2849 TUint aEapVendorType = static_cast<TUint>(aEapType); |
|
2850 |
|
2851 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
|
2852 |
|
2853 // The current values for TTLS-PAP: |
|
2854 // TTLS: aEapVendorType = TTLS, aTunnelingVendorType = None |
|
2855 // TTLS/plain-PAP: aEapVendorType = ttls_plain_pap, aTunnelingVendorType = TTLS |
|
2856 |
|
2857 EAP_TRACE_DEBUG_SYMBIAN( |
2751 EAP_TRACE_DEBUG_SYMBIAN( |
2858 (_L("EapTlsPeapUtils::SetConfigurationL -Start- aIndexType=%d, aIndex=%d, Tunneling vendor type=%d, Eap vendor type=%d \n"), |
2752 (_L("EapTlsPeapUtils::SetConfigurationL(): -Start- aIndexType=%d, aIndex=%d, aTunnelingType=0xfe%06x%08x, aEapType=0xfe%06x%08x\n"), |
2859 aIndexType,aIndex, aTunnelingVendorType, aEapVendorType)); |
2753 aIndexType, |
2860 |
2754 aIndex, |
2861 EAP_TRACE_DEBUG_SYMBIAN((_L("*************************** SetConfigurationL - Set the below values: ***************************\n")) ); |
2755 aTunnelingType.get_vendor_id(), |
2862 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - Set these values for EAPType=%d"),aSettings.iEAPType) ); |
2756 aTunnelingType.get_vendor_type(), |
2863 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, Username=%S"),aSettings.iUsernamePresent, &(aSettings.iUsername)) ); |
2757 aEapType.get_vendor_id(), |
2864 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, Password=%S"),aSettings.iPasswordPresent, &(aSettings.iPassword)) ); |
2758 aEapType.get_vendor_type())); |
2865 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, Realm=%S"),aSettings.iRealmPresent, &(aSettings.iRealm)) ); |
2759 |
2866 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, UsePseudonyms=%d"),aSettings.iUsePseudonymsPresent, aSettings.iUsePseudonyms) ); |
2760 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: EapTlsPeapUtils::SetConfigurationL()\n")); |
2867 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, VerifyServerRealm=%d"), |
2761 |
2868 aSettings.iVerifyServerRealmPresent, aSettings.iVerifyServerRealm) ); |
2762 EAP_TRACE_DEBUG_SYMBIAN((_L("*************************** EapTlsPeapUtils::SetConfigurationL(): Set the below values: ***************************\n")) ); |
2869 |
2763 |
2870 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, RequireClientAuthentication=%d"), |
2764 EAP_TRACE_SETTINGS(&aSettings); |
2871 aSettings.iRequireClientAuthenticationPresent, aSettings.iRequireClientAuthentication) ); |
2765 |
2872 |
2766 EAP_TRACE_DEBUG_SYMBIAN((_L("*************************** EapTlsPeapUtils::SetConfigurationL(): Set the above values: ***************************\n")) ); |
2873 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, SessionValidityTime=%d minutes"), |
2767 |
2874 aSettings.iSessionValidityTimePresent, aSettings.iSessionValidityTime) ); |
2768 |
2875 |
|
2876 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, CipherSuites Count=%d"), |
|
2877 aSettings.iCipherSuitesPresent, aSettings.iCipherSuites.Count()) ); |
|
2878 |
|
2879 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, PEAPv0Allowed=%d, PEAPv1Allowed=%d, PEAPv2Allowed=%d"), |
|
2880 aSettings.iPEAPVersionsPresent, aSettings.iPEAPv0Allowed,aSettings.iPEAPv1Allowed, aSettings.iPEAPv2Allowed ) ); |
|
2881 |
|
2882 // Validate length of inputs. |
2769 // Validate length of inputs. |
2883 if(aSettings.iUsername.Length() > KMaxManualUsernameLengthInDB |
2770 if(aSettings.iUsername.Length() > KMaxUsernameLengthInDB |
2884 || aSettings.iRealm.Length() > KMaxManualRealmLengthInDB ) |
2771 || aSettings.iRealm.Length() > KMaxRealmLengthInDB ) |
2885 { |
2772 { |
2886 // Some inputs are too long. Can not be stored in DB. |
2773 // Some inputs are too long. Can not be stored in DB. |
2887 |
2774 |
2888 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::SetConfigurationL: Too long arguments\n"))); |
2775 EAP_TRACE_DEBUG_SYMBIAN((_L("ERROR: EapTlsPeapUtils::SetConfigurationL(): Too long arguments\n"))); |
2889 |
2776 |
2890 User::Leave(KErrArgument); |
2777 User::Leave(KErrArgument); |
2891 } |
2778 } |
2892 |
2779 |
2893 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, Certificates Count=%d"), |
2780 #ifdef USE_FAST_EAP_TYPE |
2894 aSettings.iCertificatesPresent, aSettings.iCertificates.Count()) ); |
2781 |
2895 |
|
2896 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - Certificate details below: \n")) ); |
|
2897 |
|
2898 for( TInt n=0; n < aSettings.iCertificates.Count(); n++ ) |
|
2899 { |
|
2900 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - Certificate type:%d \n"), aSettings.iCertificates[n].iCertType) ); |
|
2901 |
|
2902 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - certificates - present=%d, SubjectName=%S"), |
|
2903 aSettings.iCertificates[n].iSubjectNamePresent, &(aSettings.iCertificates[n].iSubjectName) ) ); |
|
2904 |
|
2905 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - certificates - present=%d, IssuerName=%S"), |
|
2906 aSettings.iCertificates[n].iIssuerNamePresent, &(aSettings.iCertificates[n].iIssuerName) ) ); |
|
2907 |
|
2908 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - certificates - present=%d, SerialNumber=%S"), |
|
2909 aSettings.iCertificates[n].iSerialNumberPresent, &(aSettings.iCertificates[n].iSerialNumber) ) ); |
|
2910 |
|
2911 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - certificates - SubjectKeyID present=%d"), |
|
2912 aSettings.iCertificates[n].iSubjectKeyIDPresent ) ); |
|
2913 |
|
2914 EAP_TRACE_DATA_DEBUG_SYMBIAN( ( "SubjectKeyID:", aSettings.iCertificates[n].iSubjectKeyID.Ptr(), |
|
2915 aSettings.iCertificates[n].iSubjectKeyID.Size() ) ); |
|
2916 |
|
2917 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - certificates - Thumbprint present=%d"), |
|
2918 aSettings.iCertificates[n].iThumbprintPresent ) ); |
|
2919 |
|
2920 EAP_TRACE_DATA_DEBUG_SYMBIAN( ( "Thumbprint:", aSettings.iCertificates[n].iThumbprint.Ptr(), |
|
2921 aSettings.iCertificates[n].iThumbprint.Size() ) ); |
|
2922 } |
|
2923 |
|
2924 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, EncapsulatedEAPTypes Count=%d"), |
|
2925 aSettings.iEncapsulatedEAPTypesPresent, aSettings.iEncapsulatedEAPTypes.Count()) ); |
|
2926 |
|
2927 for( TInt m=0; m < aSettings.iEncapsulatedEAPTypes.Count(); m++ ) |
|
2928 { |
|
2929 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - EncapsulatedEAPTypes=%d"), |
|
2930 aSettings.iEncapsulatedEAPTypes[m]) ); |
|
2931 } |
|
2932 |
|
2933 #ifdef USE_FAST_EAP_TYPE |
|
2934 |
|
2935 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, AuthProvModeAllowed=%d"), |
|
2936 aSettings.iAuthProvModeAllowedPresent, aSettings.iAuthProvModeAllowed) ); |
|
2937 |
|
2938 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, UnauthProvModeAllowed=%d"), |
|
2939 aSettings.iUnauthProvModeAllowedPresent, aSettings.iUnauthProvModeAllowed) ); |
|
2940 |
|
2941 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, WarnADHPNoPAC=%d"), |
|
2942 aSettings.iWarnADHPNoPACPresent, aSettings.iWarnADHPNoPAC) ); |
|
2943 |
|
2944 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, WarnADHPNoMatchingPAC=%d"), |
|
2945 aSettings.iWarnADHPNoMatchingPACPresent, aSettings.iWarnADHPNoMatchingPAC) ); |
|
2946 |
|
2947 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, WarnNotDefaultServer=%d"), |
|
2948 aSettings.iWarnNotDefaultServerPresent, aSettings.iWarnNotDefaultServer) ); |
|
2949 |
|
2950 // Validate length of PAC Group Ref. |
2782 // Validate length of PAC Group Ref. |
2951 if(aSettings.iPACGroupReference.Length() > KMaxPACGroupRefCollectionLengthInDB) |
2783 if(aSettings.iPACGroupReference.Length() > KMaxPACGroupRefCollectionLengthInDB) |
2952 { |
2784 { |
2953 // Too long PAC Group Reference. Can not be stored in DB. |
2785 // Too long PAC Group Reference. Can not be stored in DB. |
2954 |
2786 |
2955 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::SetConfigurationL: Too long PAC Group Ref!\n"))); |
2787 EAP_TRACE_DEBUG_SYMBIAN((_L("ERROR: EapTlsPeapUtils::SetConfigurationL(): Too long PAC Group Ref!\n"))); |
2956 |
2788 |
2957 User::Leave(KErrArgument); |
2789 User::Leave(KErrArgument); |
2958 } |
2790 } |
2959 |
2791 |
2960 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - present=%d, PAC Group Ref=%S"), |
|
2961 aSettings.iPACGroupReferencePresent, &(aSettings.iPACGroupReference)) ); |
|
2962 |
|
2963 #endif //#ifdef USE_FAST_EAP_TYPE |
2792 #endif //#ifdef USE_FAST_EAP_TYPE |
2964 |
2793 |
2965 EAP_TRACE_DEBUG_SYMBIAN((_L("*************************** SetConfigurationL - Set the above values: ***************************\n")) ); |
|
2966 |
|
2967 |
|
2968 // Check if the settings are for the correct type |
2794 // Check if the settings are for the correct type |
2969 if ((aSettings.iEAPType != EAPSettings::EEapTls |
2795 if (aSettings.iEAPExpandedType != (*EapExpandedTypeTls.GetType()) |
2970 && aSettings.iEAPType != EAPSettings::EEapPeap |
2796 && aSettings.iEAPExpandedType != (*EapExpandedTypePeap.GetType()) |
2971 && aSettings.iEAPType != EAPSettings::EEapTtls |
2797 && aSettings.iEAPExpandedType != (*EapExpandedTypeTtls.GetType()) |
2972 #ifdef USE_FAST_EAP_TYPE |
2798 #ifdef USE_FAST_EAP_TYPE |
2973 && aSettings.iEAPType != EAPSettings::EEapFast |
2799 && aSettings.iEAPExpandedType != (*EapExpandedTypeFast.GetType()) |
2974 #endif |
2800 #endif //#ifdef USE_FAST_EAP_TYPE |
2975 && aSettings.iEAPType != EAPSettings::ETtlsPlainPap |
2801 && aSettings.iEAPExpandedType != (*EapExpandedTypeTtlsPap.GetType()) |
2976 ) |
2802 ) |
2977 || static_cast<TUint>(aSettings.iEAPType) != aEapVendorType) |
2803 { |
2978 { |
2804 EAP_TRACE_DEBUG_SYMBIAN((_L("ERROR: EapTlsPeapUtils::SetConfigurationL(): LEAVE - Unsupported EAP type\n")) ); |
2979 EAP_TRACE_DEBUG_SYMBIAN((_L("SetConfigurationL - LEAVE - Unsupported EAP type\n")) ); |
|
2980 |
2805 |
2981 User::Leave(KErrNotSupported); |
2806 User::Leave(KErrNotSupported); |
2982 } |
2807 } |
2983 |
2808 |
2984 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
2809 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
2985 TPtr sqlStatement = buf->Des(); |
2810 TPtr sqlStatement = buf->Des(); |
2986 |
2811 |
2987 TPtrC settings; |
2812 TPtrC settings; |
2988 TPtrC usercerts; |
2813 TPtrC usercerts; |
3095 |
2915 |
3096 |
2916 |
3097 ////////////////////////////////////////// |
2917 ////////////////////////////////////////// |
3098 // This is only for plain PAP settings. // |
2918 // This is only for plain PAP settings. // |
3099 ////////////////////////////////////////// |
2919 ////////////////////////////////////////// |
3100 if ( aEapVendorType == eap_type_ttls_plain_pap ) |
2920 if ( aEapType == eap_expanded_type_ttls_plain_pap.get_type() ) |
3101 { |
2921 { |
3102 // Username |
2922 // Username |
3103 if ( aSettings.iUsernamePresent ) |
2923 if ( aSettings.iUsernamePresent ) |
3104 { |
2924 { |
3105 // Validate length. |
2925 // Validate length. |
3106 if( aSettings.iUsername.Length() > KMaxPapUserNameLengthInDb ) |
2926 if( aSettings.iUsername.Length() > KMaxPapUserNameLengthInDb ) |
3107 { |
2927 { |
3108 // Username too long. Can not be stored in DB. |
2928 // Username too long. Can not be stored in DB. |
3109 EAP_TRACE_DEBUG_SYMBIAN( ( _L( |
2929 EAP_TRACE_DEBUG_SYMBIAN((_L("ERROR: EapTlsPeapUtils::SetConfigurationL: Too long Username. Length=%d, max length=%d \n" ), |
3110 "EapTlsPeapUtils::SetConfigurationL: Too long Username. Length=%d \n" ), |
2930 aSettings.iUsername.Length(), |
3111 aSettings.iUsername.Length() ) ); |
2931 KMaxPapUserNameLengthInDb) ); |
3112 CleanupStack::PopAndDestroy( 3 ); // colset, view, buf |
2932 |
|
2933 CleanupStack::PopAndDestroy(colSet); |
|
2934 CleanupStack::PopAndDestroy(&view); |
|
2935 CleanupStack::PopAndDestroy(buf); |
3113 User::Leave( KErrArgument ); |
2936 User::Leave( KErrArgument ); |
3114 } |
2937 } |
3115 |
2938 |
3116 // Length is ok. Set the value in DB. |
2939 // Length is ok. Set the value in DB. |
3117 view.SetColL( colSet->ColNo( cf_str_EAP_TLS_PEAP_ttls_pap_username_literal ), |
2940 view.SetColL( colSet->ColNo( cf_str_EAP_TLS_PEAP_ttls_pap_username_literal ), |
3118 aSettings.iUsername); |
2941 aSettings.iUsername); |
3119 } |
2942 } |
|
2943 |
|
2944 // Password existence. |
|
2945 if (aSettings.iPasswordExistPresent |
|
2946 && !aSettings.iPasswordExist) |
|
2947 { |
|
2948 // Clear password from database. |
|
2949 view.SetColL(colSet->ColNo(cf_str_EAP_TLS_PEAP_ttls_pap_password_literal), KNullPasswordData); |
|
2950 view.SetColNullL(colSet->ColNo(cf_str_EAP_TLS_PEAP_ttls_pap_password_literal)); |
|
2951 } |
|
2952 |
3120 // Password |
2953 // Password |
3121 if ( aSettings.iPasswordPresent ) |
2954 if ( aSettings.iPasswordPresent ) |
3122 { |
2955 { |
3123 // Validate length. |
2956 // Validate length. |
3124 if ( aSettings.iPassword.Length() > KMaxPapPasswordLengthInDb ) |
2957 if ( aSettings.iPassword.Length() > KMaxPapPasswordLengthInDb ) |
3125 { |
2958 { |
3126 // Password too long. Can not be stored in DB. |
2959 // Password too long. Can not be stored in DB. |
3127 EAP_TRACE_DEBUG_SYMBIAN( ( _L( |
2960 EAP_TRACE_DEBUG_SYMBIAN((_L("ERROR: EapTlsPeapUtils::SetConfigurationL: Too long Password. Length=%d, max length=%d\n" ), |
3128 "EapTlsPeapUtils::SetConfigurationL: Too long Password. Length=%d \n" ), |
2961 aSettings.iPassword.Length(), |
3129 aSettings.iPassword.Length() ) ); |
2962 KMaxPapPasswordLengthInDb) ); |
3130 CleanupStack::PopAndDestroy( 3 ); // colset, view, buf |
2963 |
|
2964 CleanupStack::PopAndDestroy(colSet); |
|
2965 CleanupStack::PopAndDestroy(&view); |
|
2966 CleanupStack::PopAndDestroy(buf); |
3131 User::Leave( KErrArgument ); |
2967 User::Leave( KErrArgument ); |
3132 } |
2968 } |
3133 |
2969 |
3134 // Length is ok. Set the value in DB. |
2970 // Length is ok. Set the value in DB. |
3135 view.SetColL( colSet->ColNo( |
2971 view.SetColL( colSet->ColNo( |
3136 cf_str_EAP_TLS_PEAP_ttls_pap_password_literal ), |
2972 cf_str_EAP_TLS_PEAP_ttls_pap_password_literal ), |
3137 aSettings.iPassword ); |
2973 aSettings.iPassword ); |
3138 |
2974 } |
3139 // If password was supplied set password prompting off |
2975 |
3140 view.SetColL( colSet->ColNo( |
2976 // Password prompt |
3141 cf_str_EAP_TLS_PEAP_ttls_pap_password_prompt_literal ), |
2977 if ( aSettings.iShowPassWordPromptPresent ) |
3142 EPapPasswordPromptOff ); |
2978 { |
3143 } |
2979 if ( aSettings.iShowPassWordPrompt ) |
|
2980 { |
|
2981 view.SetColL( colSet->ColNo( |
|
2982 cf_str_EAP_TLS_PEAP_ttls_pap_password_prompt_literal ), |
|
2983 EPapPasswordPromptOn ); |
|
2984 } |
|
2985 else |
|
2986 { |
|
2987 view.SetColL( colSet->ColNo( |
|
2988 cf_str_EAP_TLS_PEAP_ttls_pap_password_prompt_literal ), |
|
2989 EPapPasswordPromptOff ); |
|
2990 } |
|
2991 } |
3144 |
2992 |
3145 // Session validity time |
2993 // Session validity time |
3146 if ( aSettings.iSessionValidityTimePresent ) |
2994 if ( aSettings.iSessionValidityTimePresent ) |
3147 { |
2995 { |
3148 // User or device management wants to store the session validity time. |
2996 // User or device management wants to store the session validity time. |
3149 // Convert the time to micro seconds and save. |
2997 // Convert the time to micro seconds and save. |
3150 TInt64 validityInMicro = |
2998 TInt64 validityInMicro = (aSettings.iSessionValidityTime) * KMicroSecsInAMinute; |
3151 ( aSettings.iSessionValidityTime ) |
|
3152 * |
|
3153 KMicroSecsInAMinute; |
|
3154 view.SetColL( colSet->ColNo( maxSessionTime ), validityInMicro ); |
2999 view.SetColL( colSet->ColNo( maxSessionTime ), validityInMicro ); |
3155 |
3000 |
3156 // If max session validity time is supplied and non-zero, set password prompting ON. |
3001 // If max session validity time is supplied and non-zero, set password prompting ON. |
3157 // It doesn't matter even if the password is supplied. If max session validity is supplied, |
3002 // It doesn't matter even if the password is supplied. If max session validity is supplied, |
3158 // it means user needs to provide a password hence prompt should appear. |
3003 // it means user needs to provide a password hence prompt should appear. |
3159 if( validityInMicro != 0) |
3004 if( validityInMicro != 0) |
3160 { |
3005 { |
3161 view.SetColL( colSet->ColNo( |
3006 view.SetColL( colSet->ColNo( |
3162 cf_str_EAP_TLS_PEAP_ttls_pap_password_prompt_literal ), |
3007 cf_str_EAP_TLS_PEAP_ttls_pap_password_prompt_literal ), |
3163 EPapPasswordPromptOn ); |
3008 EPapPasswordPromptOn ); |
3164 } |
3009 } |
3165 } |
3010 } |
3166 |
3011 |
3167 // Last full authentication time should be made zero when EAP configurations are modified. |
3012 // Last full authentication time should be made zero when EAP configurations are modified. |
3168 // This makes sure that the next authentication with this EAP would be full authentication |
3013 // This makes sure that the next authentication with this EAP would be full authentication |
3169 // instead of reauthentication even if the session is still valid. |
3014 // instead of reauthentication even if the session is still valid. |
3170 view.SetColL( colSet->ColNo( lastFullAuthTime ), default_FullAuthTime ); |
3015 view.SetColL( colSet->ColNo( lastFullAuthTime ), default_FullAuthTime ); |
3171 EAP_TRACE_DEBUG_SYMBIAN( ( _L( |
3016 |
3172 "Session Validity: EAP-Type=%d, Resetting Full Auth Time since settings are modified\n" ), |
3017 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils: Session Validity: Resetting Full Auth Time since settings are modified\n"))); |
3173 aSettings.iEAPType )); |
|
3174 |
3018 |
3175 view.PutL(); |
3019 view.PutL(); |
3176 CleanupStack::PopAndDestroy( 3 ); // colset, view, buf |
3020 |
3177 |
3021 CleanupStack::PopAndDestroy(colSet); |
3178 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::SetConfigurationL - Return \n") ) ); |
3022 CleanupStack::PopAndDestroy(&view); |
|
3023 CleanupStack::PopAndDestroy(buf); |
|
3024 |
|
3025 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::SetConfigurationL(): Return PAP\n") ) ); |
3179 return; |
3026 return; |
3180 } // if ( aEapVendorType == eap_type_ttls_plain_pap ) |
3027 } // if ( aEapVendorType == eap_expanded_type_ttls_plain_pap.get_type() ) |
3181 |
3028 |
|
3029 |
|
3030 if (aSettings.iUseAutomaticCACertificatePresent) |
|
3031 { |
|
3032 // This is to set the automatic or manual status. |
|
3033 TUint useAutomaticCACertificateStatus; |
|
3034 |
|
3035 if (aSettings.iUseAutomaticCACertificate) |
|
3036 { |
|
3037 useAutomaticCACertificateStatus = EEapDbTrue; |
|
3038 } |
|
3039 else |
|
3040 { |
|
3041 useAutomaticCACertificateStatus = EEapDbFalse; |
|
3042 } |
|
3043 |
|
3044 // Set the value. |
|
3045 view.SetColL(colSet->ColNo(cf_str_EAP_TLS_PEAP_use_automatic_ca_certificate_literal), useAutomaticCACertificateStatus); |
|
3046 } |
|
3047 |
|
3048 |
|
3049 if (aSettings.iUseAutomaticUsernamePresent) |
|
3050 { |
|
3051 // This is to set the automatic or manual status. |
|
3052 TUint useManualUsernameStatus; |
|
3053 |
|
3054 if (aSettings.iUseAutomaticUsername) |
|
3055 { |
|
3056 useManualUsernameStatus = EEapDbFalse; |
|
3057 } |
|
3058 else |
|
3059 { |
|
3060 useManualUsernameStatus = EEapDbTrue; |
|
3061 } |
|
3062 |
|
3063 // Set the value. |
|
3064 view.SetColL(colSet->ColNo(cf_str_EAP_TLS_PEAP_use_manual_username_literal), useManualUsernameStatus); |
|
3065 } |
|
3066 |
|
3067 |
|
3068 if (aSettings.iUseAutomaticRealmPresent) |
|
3069 { |
|
3070 // This is to set the automatic or manual status. |
|
3071 TUint useManualRealmStatus; |
|
3072 |
|
3073 if (aSettings.iUseAutomaticRealm) |
|
3074 { |
|
3075 useManualRealmStatus = EEapDbFalse; |
|
3076 } |
|
3077 else |
|
3078 { |
|
3079 useManualRealmStatus = EEapDbTrue; |
|
3080 } |
|
3081 |
|
3082 // Set the value. |
|
3083 view.SetColL(colSet->ColNo(cf_str_EAP_TLS_PEAP_use_manual_realm_literal), useManualRealmStatus); |
|
3084 } |
|
3085 |
|
3086 |
3182 // Manual username |
3087 // Manual username |
3183 { |
3088 if (aSettings.iUsernamePresent) |
|
3089 { |
|
3090 // Check if length of username is less than the max length. |
|
3091 if(aSettings.iUsername.Length() > KMaxUsernameLengthInDB) |
|
3092 { |
|
3093 // Username too long. Can not be stored in DB. |
|
3094 |
|
3095 EAP_TRACE_DEBUG_SYMBIAN((_L("ERROR: EapTlsPeapUtils::SetConfigurationL(): Too long Username. Length=%d \n"), |
|
3096 aSettings.iUsername.Length())); |
|
3097 |
|
3098 User::Leave(KErrArgument); |
|
3099 } |
|
3100 |
3184 // Set the value in DB. Value could be empty. It doesn't matter. |
3101 // Set the value in DB. Value could be empty. It doesn't matter. |
3185 view.SetColL(colSet->ColNo(cf_str_EAP_TLS_PEAP_manual_username_literal), aSettings.iUsername); |
3102 view.SetColL(colSet->ColNo(cf_str_EAP_TLS_PEAP_manual_username_literal), aSettings.iUsername); |
3186 |
3103 |
3187 // This is to set the automatic or manual status. |
|
3188 TUint useManualUsernameStatus; |
|
3189 |
|
3190 if (aSettings.iUsernamePresent) |
|
3191 { |
|
3192 useManualUsernameStatus = ETLSPEAPUseManualUsernameYes; |
|
3193 } |
|
3194 else |
|
3195 { |
|
3196 useManualUsernameStatus = ETLSPEAPUseManualUsernameNo; |
|
3197 } |
|
3198 |
|
3199 // Set the value. |
|
3200 view.SetColL(colSet->ColNo(cf_str_EAP_TLS_PEAP_use_manual_username_literal), |
|
3201 useManualUsernameStatus); |
|
3202 |
|
3203 } |
3104 } |
3204 |
3105 |
3205 // Manual realm |
3106 // Manual realm |
3206 { |
3107 if (aSettings.iRealmPresent) |
|
3108 { |
|
3109 // Check if length of realm is less than the max length. |
|
3110 if(aSettings.iRealm.Length() > KMaxRealmLengthInDB) |
|
3111 { |
|
3112 // Realm too long. Can not be stored in DB. |
|
3113 |
|
3114 EAP_TRACE_DEBUG_SYMBIAN((_L("ERROR: EapTlsPeapUtils::SetConfigurationL(): Too long Realm. Length=%d \n"), |
|
3115 aSettings.iRealm.Length())); |
|
3116 |
|
3117 User::Leave(KErrArgument); |
|
3118 } |
|
3119 |
3207 // Set the value in DB. Value could be empty. It doesn't matter. |
3120 // Set the value in DB. Value could be empty. It doesn't matter. |
3208 view.SetColL(colSet->ColNo(cf_str_EAP_TLS_PEAP_manual_realm_literal), aSettings.iRealm); |
3121 view.SetColL(colSet->ColNo(cf_str_EAP_TLS_PEAP_manual_realm_literal), aSettings.iRealm); |
3209 |
|
3210 // This is to set the automatic or manual status. |
|
3211 TUint useManualRealmStatus; |
|
3212 |
|
3213 if (aSettings.iRealmPresent) |
|
3214 { |
|
3215 useManualRealmStatus = ETLSPEAPUseManualRealmYes; |
|
3216 } |
|
3217 else |
|
3218 { |
|
3219 useManualRealmStatus = ETLSPEAPUseManualRealmNo; |
|
3220 } |
|
3221 |
|
3222 // Set the value. |
|
3223 view.SetColL(colSet->ColNo(cf_str_EAP_TLS_PEAP_use_manual_realm_literal), |
|
3224 useManualRealmStatus); |
|
3225 } |
3122 } |
3226 |
3123 |
3227 // Verify server realm |
3124 // Verify server realm |
3228 if (aSettings.iVerifyServerRealmPresent) |
3125 if (aSettings.iVerifyServerRealmPresent) |
3229 { |
3126 { |
3230 if (aSettings.iVerifyServerRealm) |
3127 if (aSettings.iVerifyServerRealm) |
3231 { |
3128 { |
3232 view.SetColL(colSet->ColNo(cf_str_EAP_TLS_PEAP_verify_certificate_realm_literal), |
3129 view.SetColL(colSet->ColNo(cf_str_EAP_TLS_PEAP_verify_certificate_realm_literal), |
3233 ETLSPEAPVerifyCertRealmYes); |
3130 EEapDbTrue); |
3234 } |
3131 } |
3235 else |
3132 else |
3236 { |
3133 { |
3237 view.SetColL(colSet->ColNo(cf_str_EAP_TLS_PEAP_verify_certificate_realm_literal), |
3134 view.SetColL(colSet->ColNo(cf_str_EAP_TLS_PEAP_verify_certificate_realm_literal), |
3238 ETLSPEAPVerifyCertRealmNo); |
3135 EEapDbFalse); |
3239 } |
3136 } |
3240 } |
3137 } |
3241 |
3138 |
3242 // Require client authentication |
3139 // Require client authentication |
3243 if (aSettings.iRequireClientAuthenticationPresent) |
3140 if (aSettings.iRequireClientAuthenticationPresent) |
3244 { |
3141 { |
3245 if (aSettings.iRequireClientAuthentication) |
3142 if (aSettings.iRequireClientAuthentication) |
3246 { |
3143 { |
3247 view.SetColL(colSet->ColNo(cf_str_TLS_server_authenticates_client_policy_in_client_literal), |
3144 view.SetColL(colSet->ColNo(cf_str_TLS_server_authenticates_client_policy_in_client_literal), |
3248 ETLSPEAPServerAuthenticatesClientPolicyYes); |
3145 EEapDbTrue); |
3249 } |
3146 } |
3250 else |
3147 else |
3251 { |
3148 { |
3252 view.SetColL(colSet->ColNo(cf_str_TLS_server_authenticates_client_policy_in_client_literal), |
3149 view.SetColL(colSet->ColNo(cf_str_TLS_server_authenticates_client_policy_in_client_literal), |
3253 ETLSPEAPServerAuthenticatesClientPolicyNo); |
3150 EEapDbFalse); |
3254 } |
3151 } |
3255 } |
3152 } |
3256 |
3153 |
3257 // Session validity time |
3154 // Session validity time |
3258 if (aSettings.iSessionValidityTimePresent) |
3155 if (aSettings.iSessionValidityTimePresent) |
3597 // The cert label column is left empty |
3554 // The cert label column is left empty |
3598 |
3555 |
3599 view.InsertL(); |
3556 view.InsertL(); |
3600 view.SetColL(colSet->ColNo(KServiceType), static_cast<TUint>(aIndexType)); |
3557 view.SetColL(colSet->ColNo(KServiceType), static_cast<TUint>(aIndexType)); |
3601 view.SetColL(colSet->ColNo(KServiceIndex), static_cast<TUint>(aIndex)); |
3558 view.SetColL(colSet->ColNo(KServiceIndex), static_cast<TUint>(aIndex)); |
3602 view.SetColL(colSet->ColNo(KTunnelingType),aTunnelingVendorType); |
3559 view.SetColL(colSet->ColNo(KTunnelingTypeVendorId), aTunnelingType.get_vendor_id()); |
|
3560 view.SetColL(colSet->ColNo(KTunnelingType), aTunnelingType.get_vendor_type()); |
3603 |
3561 |
3604 view.SetColL(colSet->ColNo(KSubjectName), aSettings.iCertificates[i].iSubjectName); |
3562 view.SetColL(colSet->ColNo(KSubjectName), *(aSettings.iCertificates[i]->GetSubjectName())); |
3605 view.SetColL(colSet->ColNo(KIssuerName), aSettings.iCertificates[i].iIssuerName); |
3563 view.SetColL(colSet->ColNo(KIssuerName), *(aSettings.iCertificates[i]->GetIssuerName())); |
3606 view.SetColL(colSet->ColNo(KSerialNumber), aSettings.iCertificates[i].iSerialNumber); |
3564 view.SetColL(colSet->ColNo(KSerialNumber), *(aSettings.iCertificates[i]->GetSerialNumber())); |
3607 view.SetColL(colSet->ColNo(KActualSubjectKeyIdentifier), aSettings.iCertificates[i].iSubjectKeyID); |
3565 view.SetColL(colSet->ColNo(KActualSubjectKeyIdentifier), aSettings.iCertificates[i]->GetSubjectKeyId()); |
3608 |
3566 |
3609 // Special for thumb print (finger print). Need to convert it to 8 bits before storing in DB |
3567 // Special for thumb print (finger print). Need to convert it to 8 bits before storing in DB |
3610 TBuf8<KThumbprintMaxLength> thumbPrint8Bit; |
3568 TBuf8<KThumbprintMaxLength> thumbPrint8Bit; |
3611 thumbPrint8Bit.Copy(aSettings.iCertificates[i].iThumbprint); |
3569 thumbPrint8Bit.Copy(*(aSettings.iCertificates[i]->GetThumbprint())); |
3612 |
3570 |
3613 view.SetColL(colSet->ColNo(KThumbprint), thumbPrint8Bit); |
3571 view.SetColL(colSet->ColNo(KThumbprint), thumbPrint8Bit); |
3614 |
3572 |
3615 // Get the "symbian's subject key id" using symbian API. |
3573 // Get the "symbian's subject key id" using symbian API. |
3616 // We use this subject key id for authentication. |
3574 // We use this subject key id for authentication. |
3617 |
3575 |
3618 view.SetColL(colSet->ColNo(KSubjectKeyIdentifier), aSettings.iCertificates[i].iSubjectKeyID); |
3576 view.SetColL(colSet->ColNo(KSubjectKeyIdentifier), aSettings.iCertificates[i]->GetSubjectKeyId()); |
3619 |
3577 |
3620 EAP_TRACE_DATA_DEBUG_SYMBIAN( ( "EapTlsPeapUtils::SetConfigurationL - Adding CA cert to DB, Supplied (Actual) SubjectKeyID:", |
3578 EAP_TRACE_DATA_DEBUG_SYMBIAN( ( "EapTlsPeapUtils::SetConfigurationL(): Adding CA cert to DB, Supplied (Actual) SubjectKeyID:", |
3621 aSettings.iCertificates[i].iSubjectKeyID.Ptr(), aSettings.iCertificates[i].iSubjectKeyID.Size() ) ); |
3579 aSettings.iCertificates[i]->GetSubjectKeyId().Ptr(), |
|
3580 aSettings.iCertificates[i]->GetSubjectKeyId().Length() ) ); |
3622 |
3581 |
|
3582 EAP_TRACE_SETTINGS(aSettings.iCertificates[i]); |
|
3583 |
3623 view.PutL(); |
3584 view.PutL(); |
3624 } |
3585 } |
3625 } |
3586 } |
3626 |
3587 |
3627 CleanupStack::PopAndDestroy(2); // view, colset |
3588 CleanupStack::PopAndDestroy(colSet); |
3628 |
3589 CleanupStack::PopAndDestroy(&view); |
3629 CleanupStack::PopAndDestroy(certFetcher); |
3590 |
|
3591 //CleanupStack::PopAndDestroy(certFetcher); |
3630 |
3592 |
3631 } // End of if (aSettings.iCertificatesPresent) |
3593 } // End of if (aSettings.iCertificatesPresent) |
3632 |
3594 |
3633 CleanupStack::PopAndDestroy(); // buf |
3595 CleanupStack::PopAndDestroy(buf); |
3634 |
3596 |
3635 ///////////////////// |
3597 ///////////////////// |
3636 // Encapsulated types |
3598 // Encapsulated types |
3637 ///////////////////// |
3599 ///////////////////// |
3638 |
3600 |
3639 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::SetConfigurationL - aSettings.iEncapsulatedEAPTypesPresent=%d \n"), aSettings.iEncapsulatedEAPTypesPresent ) ); |
3601 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::SetConfigurationL(): aSettings.iEnabledEncapsulatedEAPExpandedTypesPresent=%d \n"), aSettings.iEnabledEncapsulatedEAPExpandedTypesPresent ) ); |
3640 |
3602 |
3641 // Encapsulated types are only for EAP-PEAP, EAP-TTLS and EAP-FAST. Not for EAP-TLS. |
3603 // Encapsulated types are only for EAP-PEAP, EAP-TTLS and EAP-FAST. Not for EAP-TLS. |
3642 // This is just to be on safe side. In case if iEncapsulatedEAPTypesPresent is set true for EAP-TLS by the caller. |
3604 // This is just to be on safe side. In case if iEnabledEncapsulatedEAPExpandedTypesPresent is set true for EAP-TLS by the caller. |
3643 if ( aEapType != eap_type_peap |
3605 if ( aEapType != eap_type_peap |
3644 && aEapType != eap_type_ttls |
3606 && aEapType != eap_type_ttls |
3645 #ifdef USE_FAST_EAP_TYPE |
3607 #ifdef USE_FAST_EAP_TYPE |
3646 && aEapType != eap_type_fast |
3608 && aEapType != eap_type_fast |
3647 #endif |
3609 #endif |
3648 ) |
3610 ) |
3649 { |
3611 { |
3650 EAP_TRACE_DEBUG_SYMBIAN( |
3612 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::SetConfigurationL(): End - Since no encapsulated type for the EAP-type=0xfe%06x%08x\n"), |
3651 (_L("EapTlsPeapUtils::SetConfigurationL - End - Since no encapsulated type for the EAPType =%d \n"), |
3613 aEapType.get_vendor_id(), |
3652 aEapVendorType ) ); |
3614 aEapType.get_vendor_type() ) ); |
3653 |
3615 |
3654 return; // No need to proceed. No encapsulated type for EAP-TLS.. |
3616 return; // No need to proceed. No encapsulated type for EAP-TLS.. |
3655 } |
3617 } |
3656 |
3618 |
3657 #ifdef USE_EAP_EXPANDED_TYPES |
3619 if (aSettings.iEnabledEncapsulatedEAPExpandedTypesPresent) |
3658 |
3620 { |
3659 if (aSettings.iEncapsulatedEAPTypesPresent) |
3621 RPointerArray<TEapExpandedType> enabledEAPTypes; |
3660 { |
|
3661 RExpandedEapTypePtrArray enabledEAPTypes; |
|
3662 // This is just for dummy. All EAP types available here are enabled as default. |
3622 // This is just for dummy. All EAP types available here are enabled as default. |
3663 RExpandedEapTypePtrArray disabledEAPTypes; |
3623 RPointerArray<TEapExpandedType> disabledEAPTypes; |
3664 SExpandedEAPType* expandedEAPTmp = 0; |
3624 TEapExpandedType* expandedEAPTmp = 0; |
3665 |
3625 |
3666 for (TInt i = 0; i < aSettings.iEncapsulatedEAPTypes.Count(); i++) |
3626 for (TInt i = 0; i < aSettings.iEnabledEncapsulatedEAPExpandedTypes.Count(); i++) |
3667 { |
3627 { |
3668 expandedEAPTmp = new SExpandedEAPType; |
3628 expandedEAPTmp = new TEapExpandedType; |
3669 |
3629 |
3670 if (expandedEAPTmp == 0) |
3630 if (expandedEAPTmp == 0) |
3671 { |
3631 { |
3672 enabledEAPTypes.ResetAndDestroy(); |
3632 enabledEAPTypes.ResetAndDestroy(); |
3673 disabledEAPTypes.ResetAndDestroy(); |
3633 disabledEAPTypes.ResetAndDestroy(); |
3674 enabledEAPTypes.Close(); |
3634 enabledEAPTypes.Close(); |
3675 disabledEAPTypes.Close(); |
3635 disabledEAPTypes.Close(); |
3676 User::Leave(KErrNoMemory); |
3636 User::Leave(KErrNoMemory); |
3677 } |
3637 } |
3678 |
3638 |
3679 // This fills the needed values for vendor id etc. |
3639 // Now copy the 8 byte string to expandedEAPTmp. |
3680 eap_expanded_type_c tmpExpEAP(static_cast <eap_type_ietf_values_e> (aSettings.iEncapsulatedEAPTypes[i])); |
3640 *expandedEAPTmp = aSettings.iEnabledEncapsulatedEAPExpandedTypes[i].GetValue(); |
3681 |
3641 |
3682 // This is only for plain-MSCHAPv2 as long as we are using the value 99 for it. |
3642 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
3683 if(aSettings.iEncapsulatedEAPTypes[i] == EAPSettings::EPlainMschapv2) |
3643 ("EapTlsPeapUtils::SetConfigurationL: Expanded EAP type string", |
|
3644 expandedEAPTmp->GetValue().Ptr(), |
|
3645 expandedEAPTmp->GetValue().Size() ) ); |
|
3646 |
|
3647 TInt error = enabledEAPTypes.Append(expandedEAPTmp); |
|
3648 if (error != KErrNone) |
3684 { |
3649 { |
3685 tmpExpEAP.set_eap_type_values( |
3650 delete expandedEAPTmp; |
3686 eap_type_vendor_id_hack, |
3651 expandedEAPTmp = 0; |
3687 eap_type_vendor_type_plain_MSCHAPv2_hack); |
|
3688 } |
3652 } |
3689 |
|
3690 // And this is for TTLS-PAP as long as we are using the value 98 for it. |
|
3691 if(aSettings.iEncapsulatedEAPTypes[i] == EAPSettings::ETtlsPlainPap) |
|
3692 { |
|
3693 tmpExpEAP.set_eap_type_values( |
|
3694 eap_type_vendor_id_hack, |
|
3695 eap_type_vendor_type_ttls_plain_pap_hack); |
|
3696 } |
|
3697 |
|
3698 // Some indirect way of forming the 8 byte string of an EAP type is needed here. |
|
3699 TUint8 tmpExpBuffer[KExpandedEAPTypeSize]; // This is for the eap_expanded_type_c::write_type |
|
3700 |
|
3701 // This copies the 8 byte string of EAP type to tmpExpBuffer. |
|
3702 eap_status_e status = eap_expanded_type_c::write_type(0, |
|
3703 0, // index should be zero here. |
|
3704 tmpExpBuffer, |
|
3705 KExpandedEAPTypeSize, |
|
3706 true, |
|
3707 tmpExpEAP); |
|
3708 |
|
3709 // Now copy the 8 byte string to expandedEAPTmp. |
|
3710 expandedEAPTmp->iExpandedEAPType.Copy(tmpExpBuffer, KExpandedEAPTypeSize); |
|
3711 |
|
3712 EAP_TRACE_DATA_DEBUG_SYMBIAN( |
|
3713 ("EapTlsPeapUtils::SetConfigurationL: Expanded EAp type string", |
|
3714 expandedEAPTmp->iExpandedEAPType.Ptr(), |
|
3715 expandedEAPTmp->iExpandedEAPType.Size() ) ); |
|
3716 |
|
3717 |
|
3718 enabledEAPTypes.Append(expandedEAPTmp); |
|
3719 } |
3653 } |
3720 |
3654 |
3721 TRAPD(error, SetTunnelingExpandedEapDataL( |
3655 TRAPD(error, SetTunnelingExpandedEapDataL( |
3722 aDatabase, |
3656 aDatabase, |
3723 0, |
3657 0, |
3724 enabledEAPTypes, |
3658 enabledEAPTypes, |
3725 disabledEAPTypes, |
3659 disabledEAPTypes, |
3726 aIndexType, |
3660 aIndexType, |
4296 { |
4370 { |
4297 do { |
4371 do { |
4298 view.GetL(); |
4372 view.GetL(); |
4299 { |
4373 { |
4300 // This is big object. |
4374 // This is big object. |
4301 CertificateEntry * certEntry = new (ELeave) CertificateEntry; |
4375 EapCertificateEntry * certEntry = new (ELeave) EapCertificateEntry; |
4302 CleanupStack::PushL(certEntry); |
4376 CleanupStack::PushL(certEntry); |
4303 |
4377 |
4304 certEntry->iCertType = CertificateEntry::ECA; |
4378 certEntry->SetCertType(EapCertificateEntry::ECA); |
4305 |
4379 |
4306 certEntry->iSubjectName.Copy(view.ColDes(colSet->ColNo(KSubjectName))); |
4380 certEntry->GetSubjectNameWritable()->Copy(view.ColDes(colSet->ColNo(KSubjectName))); |
4307 if(certEntry->iSubjectName.Length()) |
4381 if(certEntry->GetSubjectName()->Length()) |
4308 { |
4382 { |
4309 certEntry->iSubjectNamePresent = ETrue; |
4383 certEntry->SetSubjectNamePresent(); |
4310 } |
4384 } |
4311 |
4385 |
4312 certEntry->iIssuerName.Copy(view.ColDes(colSet->ColNo(KIssuerName))); |
4386 certEntry->GetIssuerNameWritable()->Copy(view.ColDes(colSet->ColNo(KIssuerName))); |
4313 if(certEntry->iIssuerName.Length()) |
4387 if(certEntry->GetIssuerName()->Length()) |
4314 { |
4388 { |
4315 certEntry->iIssuerNamePresent = ETrue; |
4389 certEntry->SetIssuerNamePresent(); |
4316 } |
4390 } |
4317 |
4391 |
4318 certEntry->iSerialNumber.Copy(view.ColDes(colSet->ColNo(KSerialNumber))); |
4392 certEntry->GetSerialNumberWritable()->Copy(view.ColDes(colSet->ColNo(KSerialNumber))); |
4319 if(certEntry->iSerialNumber.Length()) |
4393 if(certEntry->GetSerialNumber()->Length()) |
4320 { |
4394 { |
4321 certEntry->iSerialNumberPresent = ETrue; |
4395 certEntry->SetSerialNumberPresent(); |
4322 } |
4396 } |
4323 |
4397 |
4324 certEntry->iSubjectKeyID.Copy(view.ColDes8(colSet->ColNo(KActualSubjectKeyIdentifier))); // This is the subjectkey id we got in SetConfigurationL |
4398 certEntry->GetSubjectKeyIdWritable()->Copy(view.ColDes8(colSet->ColNo(KActualSubjectKeyIdentifier))); // This is the subjectkey id we got in SetConfigurationL |
4325 if(certEntry->iSubjectKeyID.Length()) |
4399 if(certEntry->GetSubjectKeyId().Length()) |
4326 { |
4400 { |
4327 certEntry->iSubjectKeyIDPresent = ETrue; |
4401 certEntry->SetSubjectKeyIdPresent(); |
4328 } |
4402 } |
4329 |
4403 |
4330 certEntry->iThumbprint.Copy(view.ColDes8(colSet->ColNo(KThumbprint))); |
4404 certEntry->GetThumbprintWritable()->Copy(view.ColDes8(colSet->ColNo(KThumbprint))); |
4331 if(certEntry->iThumbprint.Length()) |
4405 if(certEntry->GetThumbprint()->Length()) |
4332 { |
4406 { |
4333 certEntry->iThumbprintPresent = ETrue; |
4407 certEntry->SetThumbprintPresent(); |
4334 } |
4408 } |
4335 |
4409 |
4336 aSettings.iCertificates.AppendL(*certEntry); |
4410 certEntry->SetIsEnabledPresent(); |
4337 |
4411 certEntry->SetIsEnabled(ETrue); |
4338 EAP_TRACE_DATA_DEBUG_SYMBIAN( ( "EapTlsPeapUtils::GetConfigurationL - Filling CA cert entry, SubjectKeyID:", |
4412 |
4339 certEntry->iSubjectKeyID.Ptr(), certEntry->iSubjectKeyID.Size() ) ); |
4413 aSettings.iCertificates.AppendL(certEntry); |
4340 |
4414 aSettings.iCertificatesPresent = ETrue; |
4341 CleanupStack::PopAndDestroy(certEntry); |
4415 |
|
4416 EAP_TRACE_DATA_DEBUG_SYMBIAN( ( "EapTlsPeapUtils::GetConfigurationL(): Filling CA cert entry, SubjectKeyID:", |
|
4417 certEntry->GetSubjectKeyId().Ptr(), |
|
4418 certEntry->GetSubjectKeyId().Length() ) ); |
|
4419 |
|
4420 EAP_TRACE_SETTINGS(certEntry); |
|
4421 |
|
4422 CleanupStack::Pop(certEntry); |
4342 } |
4423 } |
4343 } while (view.NextL() != EFalse); |
4424 } while (view.NextL() != EFalse); |
4344 } |
4425 } |
4345 |
4426 |
4346 CleanupStack::PopAndDestroy(3); // view, colset, buf |
4427 CleanupStack::PopAndDestroy(colSet); |
4347 |
4428 CleanupStack::PopAndDestroy(&view); |
4348 aSettings.iCertificatesPresent = ETrue; |
4429 CleanupStack::PopAndDestroy(buf); |
4349 |
4430 |
4350 EAP_TRACE_DEBUG_SYMBIAN((_L("**************** GetConfigurationL - Returning the below values: ***************\n")) ); |
|
4351 EAP_TRACE_DEBUG_SYMBIAN((_L("GetConfigurationL - Return these values for EAPType=%d"),aSettings.iEAPType) ); |
|
4352 EAP_TRACE_DEBUG_SYMBIAN((_L("GetConfigurationL - present=%d, Username=%S"),aSettings.iUsernamePresent, &(aSettings.iUsername)) ); |
|
4353 EAP_TRACE_DEBUG_SYMBIAN((_L("GetConfigurationL - present=%d, Password=%S"),aSettings.iPasswordPresent, &(aSettings.iPassword)) ); |
|
4354 EAP_TRACE_DEBUG_SYMBIAN((_L("GetConfigurationL - present=%d, Realm=%S"),aSettings.iRealmPresent, &(aSettings.iRealm)) ); |
|
4355 EAP_TRACE_DEBUG_SYMBIAN((_L("GetConfigurationL - present=%d, UsePseudonyms=%d"),aSettings.iUsePseudonymsPresent, aSettings.iUsePseudonyms) ); |
|
4356 EAP_TRACE_DEBUG_SYMBIAN((_L("GetConfigurationL - present=%d, VerifyServerRealm=%d"), |
|
4357 aSettings.iVerifyServerRealmPresent, aSettings.iVerifyServerRealm) ); |
|
4358 |
|
4359 EAP_TRACE_DEBUG_SYMBIAN((_L("GetConfigurationL - present=%d, RequireClientAuthentication=%d"), |
|
4360 aSettings.iRequireClientAuthenticationPresent, aSettings.iRequireClientAuthentication) ); |
|
4361 |
|
4362 EAP_TRACE_DEBUG_SYMBIAN((_L("GetConfigurationL - present=%d, SessionValidityTime=%d minutes"), |
|
4363 aSettings.iSessionValidityTimePresent, aSettings.iSessionValidityTime) ); |
|
4364 |
|
4365 EAP_TRACE_DEBUG_SYMBIAN((_L("GetConfigurationL - present=%d, CipherSuites Count=%d"), |
|
4366 aSettings.iCipherSuitesPresent, aSettings.iCipherSuites.Count()) ); |
|
4367 |
|
4368 EAP_TRACE_DEBUG_SYMBIAN((_L("GetConfigurationL - present=%d, PEAPv0Allowed=%d, PEAPv1Allowed=%d, PEAPv2Allowed=%d"), |
|
4369 aSettings.iPEAPVersionsPresent, aSettings.iPEAPv0Allowed,aSettings.iPEAPv1Allowed, aSettings.iPEAPv2Allowed ) ); |
|
4370 |
|
4371 EAP_TRACE_DEBUG_SYMBIAN((_L("GetConfigurationL - present=%d, Certificates Count=%d"), |
|
4372 aSettings.iCertificatesPresent, aSettings.iCertificates.Count()) ); |
|
4373 |
|
4374 EAP_TRACE_DEBUG_SYMBIAN((_L("GetConfigurationL - Certificate details below: \n")) ); |
|
4375 for( TInt n=0; n < aSettings.iCertificates.Count(); n++ ) |
|
4376 { |
|
4377 EAP_TRACE_DEBUG_SYMBIAN((_L("GetConfigurationL - Certificate type:%d \n"), aSettings.iCertificates[n].iCertType) ); |
|
4378 |
|
4379 EAP_TRACE_DEBUG_SYMBIAN((_L("GetConfigurationL - certificates - present=%d, SubjectName=%S"), |
|
4380 aSettings.iCertificates[n].iSubjectNamePresent, &(aSettings.iCertificates[n].iSubjectName)) ); |
|
4381 |
|
4382 EAP_TRACE_DEBUG_SYMBIAN((_L("GetConfigurationL - certificates - present=%d, IssuerName=%S"), |
|
4383 aSettings.iCertificates[n].iIssuerNamePresent, &(aSettings.iCertificates[n].iIssuerName)) ); |
|
4384 |
|
4385 EAP_TRACE_DEBUG_SYMBIAN((_L("GetConfigurationL - certificates - present=%d, SerialNumber=%S"), |
|
4386 aSettings.iCertificates[n].iSerialNumberPresent, &(aSettings.iCertificates[n].iSerialNumber)) ); |
|
4387 |
|
4388 EAP_TRACE_DEBUG_SYMBIAN((_L("GetConfigurationL - certificates - SubjectKeyID present=%d"), |
|
4389 aSettings.iCertificates[n].iSubjectKeyIDPresent ) ); |
|
4390 |
|
4391 EAP_TRACE_DATA_DEBUG_SYMBIAN( ( "SubjectKeyID:", aSettings.iCertificates[n].iSubjectKeyID.Ptr(), |
|
4392 aSettings.iCertificates[n].iSubjectKeyID.Size() ) ); |
|
4393 |
|
4394 EAP_TRACE_DEBUG_SYMBIAN((_L("GetConfigurationL - certificates - Thumbprint present=%d"), |
|
4395 aSettings.iCertificates[n].iThumbprintPresent ) ); |
|
4396 |
|
4397 EAP_TRACE_DATA_DEBUG_SYMBIAN( ( "Thumbprint:", aSettings.iCertificates[n].iThumbprint.Ptr(), |
|
4398 aSettings.iCertificates[n].iThumbprint.Size() ) ); |
|
4399 } |
|
4400 |
|
4401 #ifdef USE_FAST_EAP_TYPE |
|
4402 |
|
4403 EAP_TRACE_DEBUG_SYMBIAN((_L("GetConfigurationL - present=%d, AuthProvModeAllowed=%d"), |
|
4404 aSettings.iAuthProvModeAllowedPresent, aSettings.iAuthProvModeAllowed) ); |
|
4405 |
|
4406 EAP_TRACE_DEBUG_SYMBIAN((_L("GetConfigurationL - present=%d, UnauthProvModeAllowed=%d"), |
|
4407 aSettings.iUnauthProvModeAllowedPresent, aSettings.iUnauthProvModeAllowed) ); |
|
4408 |
|
4409 EAP_TRACE_DEBUG_SYMBIAN((_L("GetConfigurationL - present=%d, WarnADHPNoPAC=%d"), |
|
4410 aSettings.iWarnADHPNoPACPresent, aSettings.iWarnADHPNoPAC) ); |
|
4411 |
|
4412 EAP_TRACE_DEBUG_SYMBIAN((_L("GetConfigurationL - present=%d, WarnADHPNoMatchingPAC=%d"), |
|
4413 aSettings.iWarnADHPNoMatchingPACPresent, aSettings.iWarnADHPNoMatchingPAC) ); |
|
4414 |
|
4415 EAP_TRACE_DEBUG_SYMBIAN((_L("GetConfigurationL - present=%d, WarnNotDefaultServer=%d"), |
|
4416 aSettings.iWarnNotDefaultServerPresent, aSettings.iWarnNotDefaultServer) ); |
|
4417 |
|
4418 EAP_TRACE_DEBUG_SYMBIAN((_L("GetConfigurationL - present=%d, PAC Group Ref=%S"), |
|
4419 aSettings.iPACGroupReferencePresent, &(aSettings.iPACGroupReference)) ); |
|
4420 |
|
4421 #endif //#ifdef USE_FAST_EAP_TYPE |
|
4422 |
|
4423 EAP_TRACE_DEBUG_SYMBIAN((_L("**************** GetConfigurationL - Returning the above values: ***************\n")) ); |
|
4424 |
|
4425 |
|
4426 ////////////////////// |
4431 ////////////////////// |
4427 // Encapsulated types |
4432 // Encapsulated types |
4428 ////////////////////// |
4433 ////////////////////// |
4429 |
4434 |
4430 // Encapsulated types are only for EAP-PEAP, EAP-TTLS and EAP-FAST. Not for EAP-TLS. |
4435 // Encapsulated types are only for EAP-PEAP, EAP-TTLS and EAP-FAST. Not for EAP-TLS. |
4457 aIndexType, |
4460 aIndexType, |
4458 aIndex, |
4461 aIndex, |
4459 aTunnelingType, |
4462 aTunnelingType, |
4460 aEapType)); |
4463 aEapType)); |
4461 |
4464 |
4462 if( error != KErrNone ) |
4465 if( error != KErrNone ) |
4463 { |
4466 { |
4464 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::GetConfigurationL - ########### Getting Expanded Tunneling types from the DB failed ############ \n") ) ); |
4467 EAP_TRACE_DEBUG_SYMBIAN((_L("ERROR: EapTlsPeapUtils::GetConfigurationL(): ########### Getting Expanded Tunneling types from the DB failed ############ \n") ) ); |
4465 |
4468 |
4466 enabledEAPTypes.ResetAndDestroy(); |
4469 enabledEAPTypes.ResetAndDestroy(); |
4467 disabledEAPTypes.ResetAndDestroy(); |
4470 disabledEAPTypes.ResetAndDestroy(); |
4468 enabledEAPTypes.Close(); |
4471 enabledEAPTypes.Close(); |
4469 disabledEAPTypes.Close(); |
4472 disabledEAPTypes.Close(); |
4470 |
4473 |
4471 User::Leave(KErrGeneral); |
4474 User::Leave(KErrGeneral); |
4472 } |
4475 } |
4473 |
4476 |
4474 // There should be some enabled EAP types (atleast one). |
4477 |
4475 if (enabledEAPTypes.Count() == 0) |
4478 { |
4476 { |
4479 RPointerArray<TEapExpandedType> aPlugins; |
4477 // Nothing enabled. Some problem. |
4480 |
4478 // We should get all the available EAP plugins on the device and make them enabled as default. |
4481 // This works if we do not leave from the block. |
4479 |
4482 PointerArrayResetAndDestroy<TEapExpandedType> aAutomaticPlugins(&aPlugins, EFalse); |
4480 RImplInfoPtrArray eapImplArray; |
4483 |
4481 |
4484 EapPluginTools aPluginTool; |
4482 TRAP(error, REComSession::ListImplementationsL(KEapTypeInterfaceUid, eapImplArray)); |
4485 |
4483 if (error != KErrNone) |
4486 TEapExpandedType aSymbTunnelingType; |
4484 { |
4487 |
4485 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::GetConfigurationL - ########### Getting Expanded Tunneling types - Listing ECOM plugins failed ############ \n") ) ); |
4488 error = CEapConversion::ConvertInternalTypeToExpandedEAPType( |
4486 |
4489 &aEapType, |
4487 enabledEAPTypes.ResetAndDestroy(); |
4490 &aSymbTunnelingType); |
4488 disabledEAPTypes.ResetAndDestroy(); |
4491 |
4489 enabledEAPTypes.Close(); |
4492 if (error == KErrNone) |
4490 disabledEAPTypes.Close(); |
4493 { |
4491 |
4494 TRAP(error, (aPluginTool.ListAllEapPluginsL(aIndexType, aSymbTunnelingType, aPlugins))); |
4492 User::Leave(KErrNotFound); |
4495 if (error != KErrNone) |
4493 } |
4496 { |
4494 |
4497 EAP_TRACE_DEBUG_SYMBIAN((_L("ERROR: EapTlsPeapUtils::GetConfigurationL(): aPluginTool.ListAllEapPluginsL() failed, EAP-type=0xfe%06x%08x, index_type=%d, index=%d, error=%d.\n"), |
|
4498 aEapType.get_vendor_id(), |
|
4499 aEapType.get_vendor_type(), |
|
4500 aIndexType, |
|
4501 aIndex, |
|
4502 error)); |
|
4503 } |
|
4504 } |
|
4505 |
4495 EAP_TRACE_DEBUG_SYMBIAN( |
4506 EAP_TRACE_DEBUG_SYMBIAN( |
4496 (_L("GetConfigurationL - ListImplementationsL - No: of available EAP plugin implementations=%d \n"), |
4507 (_L("EapTlsPeapUtils::GetConfigurationL(): ListImplementationsL(): No: of available EAP plugin implementations=%d, enabledEAPTypes.Count()=%d, disabledEAPTypes.Count()=%d\n"), |
4497 eapImplArray.Count() ) ); |
4508 aPlugins.Count(), |
4498 |
4509 enabledEAPTypes.Count(), |
4499 SExpandedEAPType* expandedEAPTmp; |
4510 disabledEAPTypes.Count())); |
4500 |
4511 |
4501 // Add the EAP types to enabledEAPTypes array now. |
4512 if (error == KErrNone) |
4502 |
4513 { |
4503 for (TInt i = 0; i < eapImplArray.Count(); i++) |
4514 // Filter out unimplemented enabled EAP-methods. |
4504 { |
4515 error = FilterEapMethods( |
4505 if (aEapType == eap_type_peap) |
4516 &enabledEAPTypes, |
|
4517 &aPlugins); |
|
4518 } |
|
4519 |
|
4520 if (error == KErrNone) |
|
4521 { |
|
4522 // Filter out unimplemented disabled EAP-methods. |
|
4523 error = FilterEapMethods( |
|
4524 &disabledEAPTypes, |
|
4525 &aPlugins); |
|
4526 } |
|
4527 |
|
4528 if (error == KErrNone) |
|
4529 { |
|
4530 // Add rest of the implemented EAP-methods to array of disabled EAP-methods. |
|
4531 EAP_TRACE_DEBUG_SYMBIAN( |
|
4532 (_L("EapTlsPeapUtils::GetConfigurationL(): ListImplementationsL(): Before adding disabled, No: of available EAP plugin implementations=%d, enabledEAPTypes.Count()=%d, disabledEAPTypes.Count()=%d\n"), |
|
4533 aPlugins.Count(), |
|
4534 enabledEAPTypes.Count(), |
|
4535 disabledEAPTypes.Count())); |
|
4536 |
|
4537 for (TInt plugin_ind = 0; plugin_ind < aPlugins.Count(); ++plugin_ind) |
4506 { |
4538 { |
4507 // Some EAP types are not allowed inside EAP-PEAP. |
4539 const TEapExpandedType * const plugin_type = aPlugins[plugin_ind]; |
4508 if (CEapType::IsDisallowedInsidePEAP(*eapImplArray[i])) |
4540 if (plugin_type == 0) |
4509 { |
4541 { |
4510 continue; |
4542 error = KErrNoMemory; |
|
4543 break; |
4511 } |
4544 } |
4512 |
4545 |
4513 expandedEAPTmp = new SExpandedEAPType; |
4546 TEapExpandedType * const disabled_eap_type = new TEapExpandedType; |
4514 if (expandedEAPTmp == 0) |
4547 if (disabled_eap_type != 0) |
4515 { |
4548 { |
4516 enabledEAPTypes.ResetAndDestroy(); |
4549 *disabled_eap_type = *plugin_type; |
4517 disabledEAPTypes.ResetAndDestroy(); |
4550 |
4518 enabledEAPTypes.Close(); |
4551 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::GetConfigurationL(): Adds disabled EAP-type=0xfe%06x%08x\n"), |
4519 disabledEAPTypes.Close(); |
4552 disabled_eap_type->GetVendorId(), |
4520 |
4553 disabled_eap_type->GetVendorType())); |
4521 eapImplArray.ResetAndDestroy(); |
4554 |
4522 eapImplArray.Close(); |
4555 error = disabledEAPTypes.Append( disabled_eap_type ); |
4523 |
4556 if (error != KErrNone) |
4524 User::Leave(KErrNoMemory); |
4557 { |
|
4558 break; |
|
4559 } |
4525 } |
4560 } |
4526 |
4561 } // for() |
4527 CleanupStack::PushL(expandedEAPTmp); |
4562 |
4528 |
4563 } |
4529 expandedEAPTmp->iExpandedEAPType.Copy(eapImplArray[i]->DataType()); |
4564 |
4530 |
4565 EAP_TRACE_DEBUG_SYMBIAN( |
4531 enabledEAPTypes.Append(expandedEAPTmp); |
4566 (_L("EapTlsPeapUtils::GetConfigurationL(): ListImplementationsL(): After adding disabled, No: of available EAP plugin implementations=%d, enabledEAPTypes.Count()=%d, disabledEAPTypes.Count()=%d\n"), |
4532 |
4567 aPlugins.Count(), |
4533 CleanupStack::Pop(expandedEAPTmp); |
4568 enabledEAPTypes.Count(), |
|
4569 disabledEAPTypes.Count())); |
|
4570 |
|
4571 } |
|
4572 |
|
4573 // This leave must be outside the previous block. |
|
4574 User::LeaveIfError(error); |
|
4575 |
|
4576 |
|
4577 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::GetConfigurationL(): No: of available tunneled types for this EAP=%d \n"), |
|
4578 enabledEAPTypes.Count())); |
|
4579 |
|
4580 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::GetConfigurationL(): No: of disabled tunneled types for this EAP=%d \n"), |
|
4581 disabledEAPTypes.Count())); |
|
4582 |
|
4583 // enabledEAPTypes contains the EAP types now (expanded). |
|
4584 // Fill aSettings.iEnabledEncapsulatedEAPExpandedTypes here. |
|
4585 |
|
4586 { |
|
4587 TEapExpandedType EapType; |
|
4588 |
|
4589 for (TInt i = 0; i < enabledEAPTypes.Count(); i++) |
|
4590 { |
|
4591 error = EapType.SetValue( |
|
4592 enabledEAPTypes[i]->GetValue().Ptr(), |
|
4593 enabledEAPTypes[i]->GetValue().Length()); |
|
4594 if (error != KErrNone) |
|
4595 { |
|
4596 enabledEAPTypes.ResetAndDestroy(); |
|
4597 disabledEAPTypes.ResetAndDestroy(); |
|
4598 enabledEAPTypes.Close(); |
|
4599 disabledEAPTypes.Close(); |
|
4600 |
|
4601 User::Leave(KErrNoMemory); |
4534 } |
4602 } |
4535 |
4603 |
4536 if (aEapType == eap_type_ttls) |
4604 error = aSettings.iEnabledEncapsulatedEAPExpandedTypes.Append(EapType); |
|
4605 if (error != KErrNone) |
4537 { |
4606 { |
4538 // Some EAP types are not allowed inside EAP-TTLS. |
4607 enabledEAPTypes.ResetAndDestroy(); |
4539 if (CEapType::IsDisallowedInsideTTLS(*eapImplArray[i])) |
4608 disabledEAPTypes.ResetAndDestroy(); |
4540 { |
4609 enabledEAPTypes.Close(); |
4541 continue; |
4610 disabledEAPTypes.Close(); |
4542 } |
4611 |
4543 |
4612 User::Leave(KErrNoMemory); |
4544 expandedEAPTmp = new SExpandedEAPType; |
|
4545 if (expandedEAPTmp == 0) |
|
4546 { |
|
4547 enabledEAPTypes.ResetAndDestroy(); |
|
4548 disabledEAPTypes.ResetAndDestroy(); |
|
4549 enabledEAPTypes.Close(); |
|
4550 disabledEAPTypes.Close(); |
|
4551 |
|
4552 eapImplArray.ResetAndDestroy(); |
|
4553 eapImplArray.Close(); |
|
4554 |
|
4555 User::Leave(KErrNoMemory); |
|
4556 } |
|
4557 |
|
4558 CleanupStack::PushL(expandedEAPTmp); |
|
4559 |
|
4560 expandedEAPTmp->iExpandedEAPType.Copy(eapImplArray[i]->DataType()); |
|
4561 |
|
4562 enabledEAPTypes.Append(expandedEAPTmp); |
|
4563 |
|
4564 CleanupStack::Pop(expandedEAPTmp); |
|
4565 } |
4613 } |
4566 |
4614 |
4567 #ifdef USE_FAST_EAP_TYPE |
4615 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::GetConfigurationL(): enabled EAP-type=0xfe%06x%08x\n"), |
4568 |
4616 EapType.GetVendorId(), |
4569 if (aEapType == eap_type_fast) |
4617 EapType.GetVendorType())); |
|
4618 } |
|
4619 |
|
4620 EAP_TRACE_DEBUG_SYMBIAN( |
|
4621 (_L("EapTlsPeapUtils::GetConfigurationL(): aSettings.iEnabledEncapsulatedEAPExpandedTypes.Count()=%d \n"), |
|
4622 aSettings.iEnabledEncapsulatedEAPExpandedTypes.Count())); |
|
4623 |
|
4624 aSettings.iEnabledEncapsulatedEAPExpandedTypesPresent = ETrue; |
|
4625 |
|
4626 } |
|
4627 |
|
4628 { |
|
4629 TEapExpandedType EapType; |
|
4630 |
|
4631 for (TInt i = 0; i < disabledEAPTypes.Count(); i++) |
|
4632 { |
|
4633 error = EapType.SetValue( |
|
4634 disabledEAPTypes[i]->GetValue().Ptr(), |
|
4635 disabledEAPTypes[i]->GetValue().Length()); |
|
4636 if (error != KErrNone) |
4570 { |
4637 { |
4571 // Some EAP types are not allowed inside EAP-FAST. |
4638 enabledEAPTypes.ResetAndDestroy(); |
4572 if (CEapType::IsDisallowedInsidePEAP(*eapImplArray[i])) |
4639 disabledEAPTypes.ResetAndDestroy(); |
4573 { |
4640 enabledEAPTypes.Close(); |
4574 continue; |
4641 disabledEAPTypes.Close(); |
4575 } |
4642 |
4576 |
4643 User::Leave(KErrNoMemory); |
4577 expandedEAPTmp = new SExpandedEAPType; |
|
4578 if (expandedEAPTmp == 0) |
|
4579 { |
|
4580 enabledEAPTypes.ResetAndDestroy(); |
|
4581 disabledEAPTypes.ResetAndDestroy(); |
|
4582 enabledEAPTypes.Close(); |
|
4583 disabledEAPTypes.Close(); |
|
4584 |
|
4585 eapImplArray.ResetAndDestroy(); |
|
4586 eapImplArray.Close(); |
|
4587 |
|
4588 User::Leave(KErrNoMemory); |
|
4589 } |
|
4590 |
|
4591 CleanupStack::PushL(expandedEAPTmp); |
|
4592 |
|
4593 expandedEAPTmp->iExpandedEAPType.Copy(eapImplArray[i]->DataType()); |
|
4594 |
|
4595 enabledEAPTypes.Append(expandedEAPTmp); |
|
4596 |
|
4597 CleanupStack::Pop(expandedEAPTmp); |
|
4598 } |
4644 } |
4599 #endif // #ifdef USE_FAST_EAP_TYPE |
4645 |
4600 |
4646 error = aSettings.iDisabledEncapsulatedEAPExpandedTypes.Append(EapType); |
4601 } // End: for (TInt i = 0; i < eapImplArray.Count(); i++) |
4647 if (error != KErrNone) |
4602 |
4648 { |
4603 eapImplArray.ResetAndDestroy(); |
4649 enabledEAPTypes.ResetAndDestroy(); |
4604 eapImplArray.Close(); |
4650 disabledEAPTypes.ResetAndDestroy(); |
4605 |
4651 enabledEAPTypes.Close(); |
4606 } // End: if (enabledEAPTypes.Count() == 0) |
4652 disabledEAPTypes.Close(); |
4607 |
4653 |
4608 EAP_TRACE_DEBUG_SYMBIAN( |
4654 User::Leave(KErrNoMemory); |
4609 (_L("EapTlsPeapUtils::GetConfigurationL - No: of available tunneled types for this EAP=%d \n"), |
4655 } |
4610 enabledEAPTypes.Count())); |
4656 |
4611 |
4657 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::GetConfigurationL(): disabled EAP-type=0xfe%06x%08x\n"), |
4612 // enabledEAPTypes contains the EAP types now (expanded). |
4658 EapType.GetVendorId(), |
4613 // Fill aSettings.iEncapsulatedEAPTypes here. |
4659 EapType.GetVendorType())); |
4614 |
4660 } |
4615 for (TInt i = 0; i < enabledEAPTypes.Count(); i++) |
4661 |
4616 { |
|
4617 eap_expanded_type_c expEAPTmp; |
|
4618 |
|
4619 // This will read the expanded EAP from enabledEAPTypes[i]->iExpandedEAPType to expEAPTmp. |
|
4620 // This makes easy to get the vendor type. |
|
4621 eap_expanded_type_c::read_type( 0, |
|
4622 0, |
|
4623 enabledEAPTypes[i]->iExpandedEAPType.Ptr(), |
|
4624 KExpandedEAPTypeSize, |
|
4625 &expEAPTmp); |
|
4626 |
|
4627 // We need to fill only the vendor type to aSettings.iEncapsulatedEAPTypes |
|
4628 aSettings.iEncapsulatedEAPTypes.Append(expEAPTmp.get_vendor_type()); |
|
4629 |
|
4630 EAP_TRACE_DEBUG_SYMBIAN( |
4662 EAP_TRACE_DEBUG_SYMBIAN( |
4631 (_L("EapTlsPeapUtils::GetConfigurationL - Available encapsulated type for this EAP(%d)=%d\n"), |
4663 (_L("EapTlsPeapUtils::GetConfigurationL(): aSettings.iDisabledEncapsulatedEAPExpandedTypes.Count()=%d \n"), |
4632 aEapVendorType, expEAPTmp.get_vendor_type())); |
4664 aSettings.iDisabledEncapsulatedEAPExpandedTypes.Count())); |
4633 } |
4665 |
4634 |
4666 aSettings.iDisabledEncapsulatedEAPExpandedTypesPresent = ETrue; |
4635 EAP_TRACE_DEBUG_SYMBIAN( |
4667 |
4636 (_L("EapTlsPeapUtils::GetConfigurationL - aSettings.iEncapsulatedEAPTypes.Count()=%d \n"), |
4668 } |
4637 aSettings.iEncapsulatedEAPTypes.Count())); |
4669 |
|
4670 EAP_TRACE_SETTINGS(&aSettings); |
4638 |
4671 |
4639 enabledEAPTypes.ResetAndDestroy(); |
4672 enabledEAPTypes.ResetAndDestroy(); |
4640 disabledEAPTypes.ResetAndDestroy(); |
4673 disabledEAPTypes.ResetAndDestroy(); |
4641 enabledEAPTypes.Close(); |
4674 enabledEAPTypes.Close(); |
4642 disabledEAPTypes.Close(); |
4675 disabledEAPTypes.Close(); |
4643 |
4676 |
4644 aSettings.iEncapsulatedEAPTypesPresent = ETrue; |
|
4645 |
|
4646 #else // for Normal EAP types. |
|
4647 |
|
4648 TEapArray eapArray; |
|
4649 |
|
4650 TRAPD(err, GetEapDataL( |
|
4651 aDatabase, |
|
4652 0, |
|
4653 eapArray, |
|
4654 aIndexType, |
|
4655 aIndex, |
|
4656 aTunnelingType, |
|
4657 aEapType)); |
|
4658 if (err != KErrNone) |
|
4659 { |
|
4660 eapArray.ResetAndDestroy(); |
|
4661 eapArray.Close(); |
|
4662 User::Leave(KErrGeneral); |
|
4663 } |
|
4664 |
|
4665 RImplInfoPtrArray eapImplArray; |
|
4666 |
|
4667 if (eapArray.Count() == 0) |
|
4668 { |
|
4669 // The array was empty. By default all types are enabled. |
|
4670 TRAP(err, REComSession::ListImplementationsL(KEapTypeInterfaceUid, eapImplArray)); |
|
4671 if (err != KErrNone) |
|
4672 { |
|
4673 eapArray.ResetAndDestroy(); |
|
4674 eapArray.Close(); |
|
4675 User::Leave(KErrGeneral); |
|
4676 } |
|
4677 |
|
4678 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::GetConfigurationL - ListImplementationsL - No: of available implementations=%d \n"), eapImplArray.Count() ) ); |
|
4679 |
|
4680 TEap *eap; |
|
4681 for (TInt i = 0; i < eapImplArray.Count(); i++) |
|
4682 { |
|
4683 if (CEapType::IsDisallowedInsidePEAP(*eapImplArray[i])) |
|
4684 { |
|
4685 continue; |
|
4686 } |
|
4687 |
|
4688 eap = new TEap; |
|
4689 if (eap == 0) |
|
4690 { |
|
4691 eapArray.ResetAndDestroy(); |
|
4692 eapArray.Close(); |
|
4693 eapImplArray.ResetAndDestroy(); |
|
4694 eapImplArray.Close(); |
|
4695 User::Leave(KErrGeneral); |
|
4696 } |
|
4697 eap->UID.Copy(eapImplArray[i]->DataType()); |
|
4698 eap->Enabled = ETrue; |
|
4699 eapArray.Append(eap); |
|
4700 } |
|
4701 } |
|
4702 |
|
4703 TInt i(0); |
|
4704 |
|
4705 for (i = 0; i < eapArray.Count(); i++) |
|
4706 { |
|
4707 if (eapArray[i]->Enabled) |
|
4708 { |
|
4709 TLex8 tmp(eapArray[i]->UID); |
|
4710 TUint val(0); |
|
4711 tmp.Val(val); |
|
4712 aSettings.iEncapsulatedEAPTypes.Append(val); |
|
4713 |
|
4714 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::GetConfigurationL - Available encapsulated type for this EAP =%d \n"), val ) ); |
|
4715 } |
|
4716 } |
|
4717 |
|
4718 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::GetConfigurationL - eapArray.Count()=%d \n"),eapArray.Count() ) ); |
|
4719 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::GetConfigurationL - aSettings.iEncapsulatedEAPTypes.Count()=%d \n"),aSettings.iEncapsulatedEAPTypes.Count() ) ); |
|
4720 |
|
4721 eapArray.ResetAndDestroy(); |
|
4722 eapArray.Close(); |
|
4723 eapImplArray.ResetAndDestroy(); |
|
4724 eapImplArray.Close(); |
|
4725 |
|
4726 aSettings.iEncapsulatedEAPTypesPresent = ETrue; |
|
4727 |
|
4728 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
|
4729 |
|
4730 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::GetConfigurationL - End \n") ) ); |
|
4731 |
4677 |
4732 } // EapTlsPeapUtils::GetConfigurationL() |
4678 } // EapTlsPeapUtils::GetConfigurationL() |
4733 |
4679 |
|
4680 // --------------------------------------------------------- |
4734 |
4681 |
4735 void EapTlsPeapUtils::CopySettingsL( |
4682 void EapTlsPeapUtils::CopySettingsL( |
4736 RDbNamedDatabase& aDatabase, |
4683 RDbNamedDatabase& aDatabase, |
4737 const TDesC& aTableName, |
4684 const TDesC& aTableName, |
4738 const TIndexType aSrcIndexType, |
4685 const TIndexType aSrcIndexType, |
4887 |
4850 |
4888 #ifdef USE_FAST_EAP_TYPE |
4851 #ifdef USE_FAST_EAP_TYPE |
4889 TPtrC fastSpecialSettings; |
4852 TPtrC fastSpecialSettings; |
4890 #endif |
4853 #endif |
4891 |
4854 |
4892 switch (aEapVendorType) |
4855 if (aEapType == eap_type_tls) |
4893 { |
4856 { |
4894 case eap_type_tls: |
4857 dbname.Set(KTlsDatabaseName); |
4895 { |
4858 settings.Set(KTlsDatabaseTableName); |
4896 dbname.Set(KTlsDatabaseName); |
4859 usercerts.Set(KTlsAllowedUserCertsDatabaseTableName); |
4897 settings.Set(KTlsDatabaseTableName); |
4860 cacerts.Set(KTlsAllowedCACertsDatabaseTableName); |
4898 usercerts.Set(KTlsAllowedUserCertsDatabaseTableName); |
4861 ciphersuites.Set(KTlsAllowedCipherSuitesDatabaseTableName); |
4899 cacerts.Set(KTlsAllowedCACertsDatabaseTableName); |
4862 } |
4900 ciphersuites.Set(KTlsAllowedCipherSuitesDatabaseTableName); |
4863 else if (aEapType == eap_type_peap) |
4901 } |
4864 { |
4902 break; |
4865 dbname.Set(KPeapDatabaseName); |
4903 |
4866 settings.Set(KPeapDatabaseTableName); |
4904 case eap_type_peap: |
4867 usercerts.Set(KPeapAllowedUserCertsDatabaseTableName); |
4905 { |
4868 cacerts.Set(KPeapAllowedCACertsDatabaseTableName); |
4906 dbname.Set(KPeapDatabaseName); |
4869 ciphersuites.Set(KPeapAllowedCipherSuitesDatabaseTableName); |
4907 settings.Set(KPeapDatabaseTableName); |
4870 } |
4908 usercerts.Set(KPeapAllowedUserCertsDatabaseTableName); |
4871 else if (aEapType == eap_type_ttls) |
4909 cacerts.Set(KPeapAllowedCACertsDatabaseTableName); |
4872 { |
4910 ciphersuites.Set(KPeapAllowedCipherSuitesDatabaseTableName); |
4873 dbname.Set(KTtlsDatabaseName); |
4911 } |
4874 settings.Set(KTtlsDatabaseTableName); |
4912 break; |
4875 usercerts.Set(KTtlsAllowedUserCertsDatabaseTableName); |
4913 |
4876 cacerts.Set(KTtlsAllowedCACertsDatabaseTableName); |
4914 case eap_type_ttls: |
4877 ciphersuites.Set(KTtlsAllowedCipherSuitesDatabaseTableName); |
4915 { |
4878 } |
4916 dbname.Set(KTtlsDatabaseName); |
|
4917 settings.Set(KTtlsDatabaseTableName); |
|
4918 usercerts.Set(KTtlsAllowedUserCertsDatabaseTableName); |
|
4919 cacerts.Set(KTtlsAllowedCACertsDatabaseTableName); |
|
4920 ciphersuites.Set(KTtlsAllowedCipherSuitesDatabaseTableName); |
|
4921 } |
|
4922 break; |
|
4923 |
|
4924 #ifdef USE_FAST_EAP_TYPE |
4879 #ifdef USE_FAST_EAP_TYPE |
4925 |
4880 else if (aEapType == eap_type_fast) |
4926 case eap_type_fast: |
4881 { |
4927 { |
4882 dbname.Set(KFastDatabaseName); |
4928 dbname.Set(KFastDatabaseName); |
4883 settings.Set(KFastGeneralSettingsDBTableName); // This is general settings for FAST. |
4929 settings.Set(KFastGeneralSettingsDBTableName); // This is general settings for FAST. |
4884 fastSpecialSettings.Set(KFastSpecialSettingsDBTableName); |
4930 fastSpecialSettings.Set(KFastSpecialSettingsDBTableName); |
4885 |
4931 |
4886 usercerts.Set(KFastAllowedUserCertsDatabaseTableName); |
4932 usercerts.Set(KFastAllowedUserCertsDatabaseTableName); |
4887 cacerts.Set(KFastAllowedCACertsDatabaseTableName); |
4933 cacerts.Set(KFastAllowedCACertsDatabaseTableName); |
4888 ciphersuites.Set(KFastAllowedCipherSuitesDatabaseTableName); |
4934 ciphersuites.Set(KFastAllowedCipherSuitesDatabaseTableName); |
4889 } |
4935 } |
|
4936 break; |
|
4937 #endif |
4890 #endif |
4938 |
4891 else if (aEapType == eap_expanded_type_ttls_plain_pap.get_type()) |
4939 case eap_type_ttls_plain_pap: |
4892 { |
4940 { |
4893 dbname.Set( KTtlsDatabaseName ); |
4941 dbname.Set( KTtlsDatabaseName ); |
4894 settings.Set( KTtlsDatabaseTableName ); |
4942 settings.Set( KTtlsDatabaseTableName ); |
4895 } |
4943 } |
4896 else |
4944 break; |
4897 { |
4945 |
|
4946 default: |
|
4947 // Should never happen |
4898 // Should never happen |
4948 User::Leave(KErrArgument); |
4899 User::Leave(KErrArgument); |
4949 } |
4900 } |
4950 |
4901 |
4951 RDbs session; |
4902 RDbNamedDatabase aDatabase; |
4952 RDbNamedDatabase database; |
4903 RFs aFileServerSession; |
4953 |
4904 |
4954 // Connect to the DBMS server. |
4905 TInt error(KErrNone); |
4955 User::LeaveIfError(session.Connect()); |
4906 TFileName aPrivateDatabasePathName; |
4956 CleanupClosePushL(session); |
4907 |
4957 |
4908 error = aFileServerSession.Connect(); |
4958 #ifdef SYMBIAN_SECURE_DBMS |
4909 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::DeleteConfigurationL(): - aFileServerSession.Connect(), error=%d\n"), error)); |
4959 |
4910 User::LeaveIfError(error); |
4960 // Create the secure shared database with the specified secure policy. |
4911 |
4961 // Database will be created in the data caging path for DBMS (C:\private\100012a5). |
4912 EapPluginTools::CreateDatabaseLC( |
4962 |
4913 aDatabase, |
4963 TInt err = database.Create(session, dbname, KSecureUIDFormat); |
4914 aFileServerSession, |
4964 |
4915 error, |
4965 if(err == KErrNone) |
4916 dbname, |
|
4917 aPrivateDatabasePathName); |
|
4918 |
|
4919 if(error == KErrNone) |
4966 { |
4920 { |
4967 // Database was created so it was empty. No need for further actions. |
4921 // Database was created so it was empty. No need for further actions. |
4968 database.Destroy(); |
4922 aDatabase.Destroy(); |
4969 CleanupStack::PopAndDestroy(); |
4923 CleanupStack::PopAndDestroy(&aDatabase); |
|
4924 CleanupStack::PopAndDestroy(&aFileServerSession); |
4970 return; |
4925 return; |
4971 |
4926 } |
4972 } |
4927 else if (error != KErrAlreadyExists) |
4973 else if (err != KErrAlreadyExists) |
4928 { |
4974 { |
4929 User::LeaveIfError(error); |
4975 User::LeaveIfError(err); |
4930 } |
4976 } |
4931 |
4977 |
4932 EAP_TRACE_DEBUG_SYMBIAN((_L("EapLeapDbUtils::DeleteConfigurationL(): - calls aDatabase.Open()\n"))); |
4978 // Database existed, open it. |
4933 |
4979 User::LeaveIfError(database.Open(session, dbname, KSecureUIDFormat)); |
4934 error = aDatabase.Open(aFileServerSession, aPrivateDatabasePathName); |
4980 CleanupClosePushL(database); |
4935 |
4981 |
4936 EAP_TRACE_DEBUG_SYMBIAN((_L("EapLeapDbUtils::DeleteConfigurationL(): - Opened private DB for %S. error=%d\n"), |
4982 #else |
4937 &dbname, |
4983 // For non-secured database. The database will be created in the old location (c:\system\data). |
4938 error)); |
4984 |
4939 |
4985 RFs fsSession; |
4940 User::LeaveIfError(error); |
4986 User::LeaveIfError(fsSession.Connect()); |
4941 |
4987 CleanupClosePushL(fsSession); |
|
4988 TInt err = database.Create(fsSession, dbname); |
|
4989 |
|
4990 if(err == KErrNone) |
|
4991 { |
|
4992 // Database was created so it was empty. No need for further actions. |
|
4993 database.Destroy(); |
|
4994 CleanupStack::PopAndDestroy(2); // fsSession, database session |
|
4995 return; |
|
4996 |
|
4997 } |
|
4998 else if (err != KErrAlreadyExists) |
|
4999 { |
|
5000 User::LeaveIfError(err); |
|
5001 } |
|
5002 |
|
5003 CleanupStack::PopAndDestroy(); // close fsSession |
|
5004 |
|
5005 User::LeaveIfError(database.Open(session, dbname)); |
|
5006 CleanupClosePushL(database); |
|
5007 |
|
5008 #endif // #ifdef SYMBIAN_SECURE_DBMS |
|
5009 |
4942 |
5010 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
4943 HBufC* buf = HBufC::NewLC(KMaxSqlQueryLength); |
5011 TPtr sqlStatement = buf->Des(); |
4944 TPtr sqlStatement = buf->Des(); |
5012 |
4945 |
5013 EAP_TRACE_DEBUG_SYMBIAN( |
4946 EAP_TRACE_DEBUG_SYMBIAN( |
5014 (_L("EapTlsPeapUtils::DeleteConfigurationL - Deleting the tables\n"))); |
4947 (_L("EapTlsPeapUtils::DeleteConfigurationL - Deleting the tables\n"))); |
5015 |
4948 |
5016 _LIT(KSQL, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d"); |
4949 _LIT(KSQL, "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d"); |
5017 |
4950 |
5018 //--------------------- Deletion 1 ----------------------------// |
4951 //--------------------- Deletion 1 ----------------------------// |
5019 |
4952 |
5020 // For all EAPs delete the settings table. |
4953 // For all EAPs delete the settings table. |
5021 // For EAP-FAST, this is delting the general settings table. |
4954 // For EAP-FAST, this is delting the general settings table. |
5022 |
4955 |
5023 sqlStatement.Format(KSQL, &settings, |
4956 sqlStatement.Format(KSQL, |
5024 &KServiceType, aIndexType, &KServiceIndex, aIndex, &KTunnelingType, aTunnelingVendorType); |
4957 &settings, |
|
4958 &KServiceType, |
|
4959 aIndexType, |
|
4960 &KServiceIndex, |
|
4961 aIndex, |
|
4962 &KTunnelingTypeVendorId, |
|
4963 aTunnelingType.get_vendor_id(), |
|
4964 &KTunnelingType, |
|
4965 aTunnelingType.get_vendor_type()); |
5025 |
4966 |
5026 // Evaluate view |
4967 // Evaluate view |
5027 RDbView view; |
4968 RDbView view; |
5028 User::LeaveIfError(view.Prepare(database,TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
4969 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
5029 CleanupClosePushL(view); |
4970 CleanupClosePushL(view); |
5030 User::LeaveIfError(view.EvaluateAll()); |
4971 User::LeaveIfError(view.EvaluateAll()); |
5031 |
4972 |
5032 // Delete rows |
4973 // Delete rows |
5033 if (view.FirstL()) |
4974 if (view.FirstL()) |
5034 { |
4975 { |
5035 do { |
4976 do { |
5036 view.DeleteL(); |
4977 view.DeleteL(); |
5037 } while (view.NextL() != EFalse); |
4978 } while (view.NextL() != EFalse); |
5038 } |
4979 } |
5039 |
4980 |
5040 CleanupStack::PopAndDestroy(); // view |
4981 CleanupStack::PopAndDestroy(&view); |
5041 |
4982 |
5042 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::DeleteConfigurationL: Deleted %s (general) settings table"), settings.Ptr())); |
4983 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::DeleteConfigurationL(): Deleted %s (general) settings table"), settings.Ptr())); |
5043 |
4984 |
5044 ////////////////////////////////////////// |
4985 ////////////////////////////////////////// |
5045 // This is only for plain PAP settings. // |
4986 // This is only for plain PAP settings. // |
5046 ////////////////////////////////////////// |
4987 ////////////////////////////////////////// |
5047 if ( aEapVendorType == eap_type_ttls_plain_pap ) |
4988 if ( aEapType == eap_expanded_type_ttls_plain_pap.get_type() ) |
5048 { |
4989 { |
5049 CleanupStack::PopAndDestroy(3); // buf, database, session |
4990 CleanupStack::PopAndDestroy(buf); |
5050 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::DeleteConfigurationL: Return"))); |
4991 CleanupStack::PopAndDestroy(&aDatabase); |
|
4992 CleanupStack::PopAndDestroy(&aFileServerSession); |
|
4993 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::DeleteConfigurationL(): Return PAP"))); |
5051 // we return here in case of pap because there is nothing to do else. |
4994 // we return here in case of pap because there is nothing to do else. |
5052 return; |
4995 return; |
5053 } |
4996 } |
5054 |
4997 |
5055 //--------------------- Deletion 2 ----------------------------// |
4998 //--------------------- Deletion 2 ----------------------------// |
5056 |
4999 |
5057 // For all EAPs delte the User cert table |
5000 // For all EAPs delete the User cert table |
5058 |
5001 // KSQL2 is "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d" |
5059 // KSQL2 is "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d" |
5002 |
5060 |
5003 sqlStatement.Format(KSQL, |
5061 sqlStatement.Format(KSQL, &usercerts, |
5004 &usercerts, |
5062 &KServiceType, aIndexType, &KServiceIndex, aIndex, &KTunnelingType, aTunnelingVendorType); |
5005 &KServiceType, |
|
5006 aIndexType, |
|
5007 &KServiceIndex, |
|
5008 aIndex, |
|
5009 &KTunnelingTypeVendorId, |
|
5010 aTunnelingType.get_vendor_id(), |
|
5011 &KTunnelingType, |
|
5012 aTunnelingType.get_vendor_type()); |
5063 |
5013 |
5064 // Evaluate view |
5014 // Evaluate view |
5065 |
5015 |
5066 User::LeaveIfError(view.Prepare(database,TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
5016 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
5067 CleanupClosePushL(view); |
5017 CleanupClosePushL(view); |
5068 User::LeaveIfError(view.EvaluateAll()); |
5018 User::LeaveIfError(view.EvaluateAll()); |
5069 |
5019 |
5070 if (view.FirstL()) |
5020 if (view.FirstL()) |
5071 { |
5021 { |
5072 do { |
5022 do { |
5073 view.DeleteL(); |
5023 view.DeleteL(); |
5074 } while (view.NextL() != EFalse); |
5024 } while (view.NextL() != EFalse); |
5075 } |
5025 } |
5076 |
5026 |
5077 CleanupStack::PopAndDestroy(); // view |
5027 CleanupStack::PopAndDestroy(&view); |
5078 |
5028 |
5079 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::DeleteConfigurationL: Deleted USER certs table"))); |
5029 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::DeleteConfigurationL(): Deleted USER certs table"))); |
5080 |
5030 |
5081 //--------------------- Deletion 3 ----------------------------// |
5031 //--------------------- Deletion 3 ----------------------------// |
5082 |
5032 |
5083 // For all EAPs delete the CA cert table |
5033 // For all EAPs delete the CA cert table |
5084 |
5034 |
5085 // KSQL3 is "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d" |
5035 // KSQL3 is "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d" |
5086 |
5036 |
5087 sqlStatement.Format(KSQL, &cacerts, |
5037 sqlStatement.Format(KSQL, |
5088 &KServiceType, aIndexType, &KServiceIndex, aIndex, &KTunnelingType, aTunnelingVendorType); |
5038 &cacerts, |
|
5039 &KServiceType, |
|
5040 aIndexType, |
|
5041 &KServiceIndex, |
|
5042 aIndex, |
|
5043 &KTunnelingTypeVendorId, |
|
5044 aTunnelingType.get_vendor_id(), |
|
5045 &KTunnelingType, |
|
5046 aTunnelingType.get_vendor_type()); |
5089 |
5047 |
5090 // Evaluate view |
5048 // Evaluate view |
5091 |
5049 |
5092 User::LeaveIfError(view.Prepare(database,TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
5050 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
5093 CleanupClosePushL(view); |
5051 CleanupClosePushL(view); |
5094 User::LeaveIfError(view.EvaluateAll()); |
5052 User::LeaveIfError(view.EvaluateAll()); |
5095 |
5053 |
5096 if (view.FirstL()) |
5054 if (view.FirstL()) |
5097 { |
5055 { |
5098 do { |
5056 do { |
5099 view.DeleteL(); |
5057 view.DeleteL(); |
5100 } while (view.NextL() != EFalse); |
5058 } while (view.NextL() != EFalse); |
5101 } |
5059 } |
5102 |
5060 |
5103 CleanupStack::PopAndDestroy(); // view |
5061 CleanupStack::PopAndDestroy(&view); |
5104 |
5062 |
5105 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::DeleteConfigurationL: Deleted CA certs table"))); |
5063 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::DeleteConfigurationL(): Deleted CA certs table"))); |
5106 |
5064 |
5107 //--------------------- Deletion 4 ----------------------------// |
5065 //--------------------- Deletion 4 ----------------------------// |
5108 |
5066 |
5109 // For all EAPs delete the Cipher suite table |
5067 // For all EAPs delete the Cipher suite table |
5110 |
5068 |
5111 // KSQL4 is "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d" |
5069 // KSQL4 is "SELECT * FROM %S WHERE %S=%d AND %S=%d AND %S=%d AND %S=%d" |
5112 |
5070 |
5113 sqlStatement.Format(KSQL, &ciphersuites, |
5071 sqlStatement.Format(KSQL, |
5114 &KServiceType, aIndexType, &KServiceIndex, aIndex, &KTunnelingType, aTunnelingVendorType); |
5072 &ciphersuites, |
|
5073 &KServiceType, |
|
5074 aIndexType, |
|
5075 &KServiceIndex, |
|
5076 aIndex, |
|
5077 &KTunnelingTypeVendorId, |
|
5078 aTunnelingType.get_vendor_id(), |
|
5079 &KTunnelingType, |
|
5080 aTunnelingType.get_vendor_type()); |
5115 |
5081 |
5116 // Evaluate view |
5082 // Evaluate view |
5117 |
5083 |
5118 User::LeaveIfError(view.Prepare(database,TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
5084 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
5119 CleanupClosePushL(view); |
5085 CleanupClosePushL(view); |
5120 User::LeaveIfError(view.EvaluateAll()); |
5086 User::LeaveIfError(view.EvaluateAll()); |
5121 |
5087 |
5122 if (view.FirstL()) |
5088 if (view.FirstL()) |
5123 { |
5089 { |
5124 do { |
5090 do { |
5125 view.DeleteL(); |
5091 view.DeleteL(); |
5126 } while (view.NextL() != EFalse); |
5092 } while (view.NextL() != EFalse); |
5127 } |
5093 } |
5128 |
5094 |
5129 CleanupStack::PopAndDestroy(&view); // Close view |
5095 CleanupStack::PopAndDestroy(&view); |
5130 |
5096 |
5131 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::DeleteConfigurationL: Deleted cipher suits table"))); |
5097 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::DeleteConfigurationL(): Deleted cipher suits table"))); |
5132 |
5098 |
5133 |
5099 |
5134 #ifdef USE_FAST_EAP_TYPE |
5100 #ifdef USE_FAST_EAP_TYPE |
5135 |
5101 |
5136 if(aEapVendorType == eap_type_fast) |
5102 if(aEapType == eap_type_fast) |
5137 { |
5103 { |
5138 //--------------------- Deletion 5 ----------------------------// |
5104 //--------------------- Deletion 5 ----------------------------// |
5139 |
5105 |
5140 // For EAP-FAST, delete the special settings table |
5106 // For EAP-FAST, delete the special settings table |
5141 |
5107 |
5142 sqlStatement.Format(KSQL, &fastSpecialSettings, |
5108 sqlStatement.Format(KSQL, |
5143 &KServiceType, aIndexType, &KServiceIndex, aIndex, &KTunnelingType, aTunnelingVendorType); |
5109 &fastSpecialSettings, |
|
5110 &KServiceType, |
|
5111 aIndexType, |
|
5112 &KServiceIndex, |
|
5113 aIndex, |
|
5114 &KTunnelingTypeVendorId, |
|
5115 aTunnelingType.get_vendor_id(), |
|
5116 &KTunnelingType, |
|
5117 aTunnelingType.get_vendor_type()); |
5144 |
5118 |
5145 // Evaluate view |
5119 // Evaluate view |
5146 |
5120 |
5147 User::LeaveIfError(view.Prepare(database,TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
5121 User::LeaveIfError(view.Prepare(aDatabase, TDbQuery(sqlStatement), TDbWindow::EUnlimited)); |
5148 CleanupClosePushL(view); |
5122 CleanupClosePushL(view); |
5149 User::LeaveIfError(view.EvaluateAll()); |
5123 User::LeaveIfError(view.EvaluateAll()); |
5150 |
5124 |
5151 if (view.FirstL()) |
5125 if (view.FirstL()) |
5152 { |
5126 { |
5153 do { |
5127 do { |
5154 view.DeleteL(); |
5128 view.DeleteL(); |
5155 } while (view.NextL() != EFalse); |
5129 } while (view.NextL() != EFalse); |
5156 } |
5130 } |
5157 |
5131 |
5158 CleanupStack::PopAndDestroy(&view); // Close view |
5132 CleanupStack::PopAndDestroy(&view); |
5159 |
5133 |
5160 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::DeleteConfigurationL: Deleted EAP-FAST Special settings table"))); |
5134 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::DeleteConfigurationL(): Deleted EAP-FAST Special settings table"))); |
5161 |
5135 |
5162 } // End: if(aEapVendorType == eap_type_fast) |
5136 } // End: if(aEapVendorType == eap_type_fast) |
5163 |
5137 |
5164 #endif // End: #ifdef USE_FAST_EAP_TYPE |
5138 #endif // End: #ifdef USE_FAST_EAP_TYPE |
5165 |
5139 |
5166 // Close database |
5140 CleanupStack::PopAndDestroy(buf); |
5167 CleanupStack::PopAndDestroy(3); // buf, database, session |
5141 CleanupStack::PopAndDestroy(&aDatabase); |
5168 |
5142 CleanupStack::PopAndDestroy(&aFileServerSession); |
5169 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::DeleteConfigurationL: End"))); |
5143 |
|
5144 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::DeleteConfigurationL: End"))); |
5170 |
5145 |
5171 } // EapTlsPeapUtils::DeleteConfigurationL() |
5146 } // EapTlsPeapUtils::DeleteConfigurationL() |
5172 |
5147 |
5173 |
5148 |
5174 // --------------------------------------------------------- |
5149 // --------------------------------------------------------- |
5687 case EDbColUint32: |
5711 case EDbColUint32: |
5688 { |
5712 { |
5689 |
5713 |
5690 #if defined (USE_FAST_EAP_TYPE) |
5714 #if defined (USE_FAST_EAP_TYPE) |
5691 |
5715 |
5692 EAP_TRACE_DEBUG_SYMBIAN( |
5716 EAP_TRACE_DEBUG_SYMBIAN((_L("WARNING: eap_am_type_tls_peap_symbian_c::authentication_finishedL(): HACK to set Unauth Prov mode set to default (NO)!"))); |
5693 (_L("eap_am_type_tls_peap_symbian_c::authentication_finishedL WARNING, HACK to set Unauth Prov mode set to default (NO)!"))); |
5717 |
5694 |
5718 view.SetColL(KDefaultColumnInView_One, EEapDbFalse); |
5695 view.SetColL(KDefaultColumnInView_One, EFASTUnauthProvModeAllowedNo); |
|
5696 |
5719 |
5697 #endif // End: #if defined (USE_FAST_EAP_TYPE) |
5720 #endif // End: #if defined (USE_FAST_EAP_TYPE) |
5698 } |
5721 } |
5699 break; |
5722 break; |
5700 |
5723 |
5701 case EDbColInt64: |
5724 case EDbColInt64: |
5702 { |
5725 { |
5703 // Do some lexical analysis to get TInt64 value here and set it in DB. |
5726 // Do some lexical analysis to get TInt64 value here and set it in DB. |
5704 |
5727 |
5705 EAP_TRACE_DEBUG_SYMBIAN( |
5728 EAP_TRACE_DEBUG_SYMBIAN((_L("ERROR: EapTlsPeapUtils::SetEapSettingsDataL(): EDbColInt64 not supported here yet!\n"))); |
5706 (_L("EapTlsPeapUtils::SetEapSettingsDataL: ERROR: EDbColInt64 not supported here yet!\n"))); |
|
5707 |
5729 |
5708 User::Leave(KErrNotSupported); |
5730 User::Leave(KErrNotSupported); |
5709 } |
5731 } |
5710 break; |
5732 break; |
5711 |
5733 |
5712 case EDbColLongBinary: |
5734 case EDbColLongBinary: |
5713 { |
5735 { |
5714 // This needs special handling. (readstream). Not needed in this DB yet. |
5736 // This needs special handling. (readstream). Not needed in this DB yet. |
5715 EAP_TRACE_DEBUG_SYMBIAN( |
5737 EAP_TRACE_DEBUG_SYMBIAN((_L("ERROR: EapTlsPeapUtils::SetEapSettingsDataL(): EDbColLongBinary not supported in this DB!\n"))); |
5716 (_L("EapTlsPeapUtils::SetEapSettingsDataL: ERROR: EDbColLongBinary not supported in this DB!\n"))); |
|
5717 |
5738 |
5718 User::Leave(KErrNotSupported); |
5739 User::Leave(KErrNotSupported); |
5719 } |
5740 } |
5720 break; |
5741 break; |
5721 |
5742 |
5722 default: |
5743 default: |
5723 EAP_TRACE_DEBUG_SYMBIAN( |
5744 EAP_TRACE_DEBUG_SYMBIAN((_L("ERROR: EapTlsPeapUtils::SetEapSettingsDataL: Unsupported DB field! \n"))); |
5724 (_L("EapTlsPeapUtils::SetEapSettingsDataL: ERROR: Unsupported DB field! \n"))); |
|
5725 |
5745 |
5726 User::Leave(KErrNotSupported); |
5746 User::Leave(KErrNotSupported); |
5727 break; |
5747 break; |
5728 } |
5748 } |
5729 |
5749 |
5730 CleanupStack::PopAndDestroy(dbColVal8); |
5750 CleanupStack::PopAndDestroy(dbColVal8); |
5731 |
5751 |
5732 } // End: if(view.ColCount() == KDefaultColumnInView_One) |
5752 } // End: if(view.ColCount() == KDefaultColumnInView_One) |
5733 else |
5753 else |
5734 { |
5754 { |
5735 EAP_TRACE_DEBUG_SYMBIAN( |
5755 EAP_TRACE_DEBUG_SYMBIAN((_L("ERROR: EapTlsPeapUtils::SetEapSettingsDataL(): Too many columns in DB view, count=%d \n"), |
5736 (_L("EapTlsPeapUtils::SetEapSettingsDataL: ERROR: Too many columns in DB view, count=%d \n"), |
|
5737 view.ColCount())); |
5756 view.ColCount())); |
5738 |
5757 |
5739 User::Leave(KErrNotFound); |
5758 User::Leave(KErrNotFound); |
5740 } |
5759 } |
5741 } // End: if (view.FirstL()) |
5760 } // End: if (view.FirstL()) |
5742 |
5761 |
5743 // Now it should go to the DB. |
5762 // Now it should go to the DB. |
5744 view.PutL(); |
5763 view.PutL(); |
5745 |
5764 |
5746 CleanupStack::PopAndDestroy( &view ); // Close view. |
5765 CleanupStack::PopAndDestroy( &view ); |
5747 |
5766 |
5748 EAP_TRACE_DEBUG_SYMBIAN( |
5767 EAP_TRACE_DEBUG_SYMBIAN( |
5749 (_L("EapTlsPeapUtils::SetEapSettingsDataL: End \n"))); |
5768 (_L("EapTlsPeapUtils::SetEapSettingsDataL: End \n"))); |
5750 } |
5769 } |
|
5770 |
|
5771 // --------------------------------------------------------- |
5751 |
5772 |
5752 /* |
5773 /* |
5753 * Alter table for added column, if doesn't exist |
5774 * Alter table for added column, if doesn't exist |
5754 * |
5775 * |
5755 */ |
5776 */ |
5756 void EapTlsPeapUtils::AlterTableL( |
5777 void EapTlsPeapUtils::AlterTableL( |
5757 RDbNamedDatabase& aDb, |
5778 RDbNamedDatabase& aDb, |
5758 TAlterTableCmd aCmd, |
5779 TAlterTableCmd aCmd, |
5759 const TDesC& aTableName, |
5780 const TDesC& aTableName, |
5760 const TDesC& aColumnName, |
5781 const TDesC& aColumnName, |
5761 const TDesC& aColumnDef ) |
5782 const TDesC& aColumnDef ) |
5762 { |
5783 { |
5763 |
5784 EAP_TRACE_DEBUG_SYMBIAN( |
5764 CDbColSet* colSet = aDb.ColSetL( aTableName ); |
5785 (_L("EapTlsPeapUtils::AlterTableL(): -Start- aTableName=\"%S\", aColumnName=\"%S\", aColumnDef=\"%S\"\n"), |
5765 User::LeaveIfNull( colSet ); |
5786 &aTableName, |
5766 CleanupStack::PushL( colSet ); |
5787 &aColumnName, |
5767 |
5788 &aColumnDef)); |
5768 EAP_TRACE_DEBUG_SYMBIAN( ( _L( |
5789 |
5769 "EapTlsPeapUtils::AlterTableL() \ |
5790 EAP_TRACE_RETURN_STRING_SYMBIAN(_L("returns: EapTlsPeapUtils::AlterTableL()\n")); |
5770 Number of columns in %S table is %d.\n" ), |
5791 |
5771 &aTableName, colSet->Count() ) ); |
5792 CDbColSet* colSet = aDb.ColSetL( aTableName ); |
5772 |
5793 User::LeaveIfNull( colSet ); |
5773 if ( aCmd == EAddColumn ) |
5794 CleanupStack::PushL( colSet ); |
|
5795 |
|
5796 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::AlterTableL() Number of columns in \"%S\" table is %d.\n" ), |
|
5797 &aTableName, |
|
5798 colSet->Count())); |
|
5799 |
|
5800 if ( aCmd == EAddColumn ) |
|
5801 { |
|
5802 // Check if there is a target column |
|
5803 if( colSet->ColNo( aColumnName ) != KDbNullColNo ) |
5774 { |
5804 { |
5775 // Check if there is a target column |
5805 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::AlterTableL() Column \"%S\" exists already in table \"%S\".\n" ), |
5776 if( colSet->ColNo( aColumnName ) != KDbNullColNo ) |
5806 &aColumnName, |
5777 { |
5807 &aTableName)); |
5778 EAP_TRACE_DEBUG_SYMBIAN( ( _L( |
5808 CleanupStack::PopAndDestroy( colSet ); |
5779 "EapTlsPeapUtils::AlterTableL() \ |
5809 return; |
5780 Column %S exists already in table %S.\n" ), |
|
5781 &aColumnName, &aTableName ) ); |
|
5782 CleanupStack::PopAndDestroy( colSet ); |
|
5783 return; |
|
5784 } |
|
5785 } |
5810 } |
5786 else |
5811 } |
|
5812 else |
|
5813 { |
|
5814 // Check if there is a target column |
|
5815 if( colSet->ColNo( aColumnName ) == KDbNullColNo ) |
5787 { |
5816 { |
5788 // Check if there is a target column |
5817 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::AlterTableL() Column \"%S\" does not exists already in table \"%S\".\n" ), |
5789 if( colSet->ColNo( aColumnName ) == KDbNullColNo ) |
5818 &aColumnName, |
5790 { |
5819 &aTableName)); |
5791 EAP_TRACE_DEBUG_SYMBIAN( ( _L( |
5820 CleanupStack::PopAndDestroy( colSet ); |
5792 "EapTlsPeapUtils::AlterTableL() \ |
5821 return; |
5793 Column %S does not exists already in table %S.\n" ), |
|
5794 &aColumnName, &aTableName ) ); |
|
5795 CleanupStack::PopAndDestroy( colSet ); |
|
5796 return; |
|
5797 } |
|
5798 } |
5822 } |
5799 |
5823 } |
5800 HBufC* buf = HBufC::NewLC( KMaxSqlQueryLength ); |
5824 |
5801 TPtr sqlStatement = buf->Des(); |
5825 HBufC* buf = HBufC::NewLC( KMaxSqlQueryLength ); |
5802 |
5826 TPtr sqlStatement = buf->Des(); |
5803 _LIT( KSqlAddCol, "ALTER TABLE %S ADD %S %S" ); |
5827 |
5804 _LIT( KSqlRemoveCol, "ALTER TABLE %S DROP %S" ); |
5828 _LIT( KSqlAddCol, "ALTER TABLE %S ADD %S %S" ); |
5805 |
5829 _LIT( KSqlRemoveCol, "ALTER TABLE %S DROP %S" ); |
5806 if ( aCmd == EAddColumn ) |
5830 |
5807 { |
5831 if ( aCmd == EAddColumn ) |
5808 sqlStatement.Format( KSqlAddCol, &aTableName, |
5832 { |
5809 &aColumnName, &aColumnDef ); |
5833 sqlStatement.Format(KSqlAddCol, |
5810 } |
5834 &aTableName, |
5811 else |
5835 &aColumnName, |
5812 { |
5836 &aColumnDef); |
5813 sqlStatement.Format( KSqlRemoveCol, &aTableName, |
5837 } |
5814 &aColumnName ); |
5838 else |
5815 } |
5839 { |
5816 |
5840 sqlStatement.Format(KSqlRemoveCol, |
5817 EAP_TRACE_DEBUG_SYMBIAN( ( _L( |
5841 &aTableName, |
5818 "EapTlsPeapUtils::AlterTableL(): sqlStatement=%S\n"), |
5842 &aColumnName); |
5819 &sqlStatement ) ); |
5843 } |
5820 |
5844 |
5821 User::LeaveIfError( aDb.Execute( sqlStatement ) ); |
5845 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::AlterTableL(): sqlStatement=%S\n"), |
5822 CleanupStack::PopAndDestroy( buf ); |
5846 &sqlStatement)); |
5823 CleanupStack::PopAndDestroy( colSet ); |
5847 |
5824 |
5848 User::LeaveIfError( aDb.Execute( sqlStatement ) ); |
5825 CDbColSet* alteredColSet = aDb.ColSetL( aTableName ); |
5849 CleanupStack::PopAndDestroy( buf ); |
5826 User::LeaveIfNull( alteredColSet ); |
5850 CleanupStack::PopAndDestroy( colSet ); |
5827 EAP_TRACE_DEBUG_SYMBIAN( ( _L( |
5851 |
5828 "EapTlsPeapUtils::AlterTableL() \ |
5852 CDbColSet* alteredColSet = aDb.ColSetL( aTableName ); |
5829 Number of columns in %S table after adding is %d.\n" ), |
5853 User::LeaveIfNull( alteredColSet ); |
5830 &aTableName, alteredColSet->Count() ) ); |
5854 |
5831 delete alteredColSet; |
5855 EAP_TRACE_DEBUG_SYMBIAN((_L("EapTlsPeapUtils::AlterTableL() Number of columns in %S table after adding is %d.\n" ), |
5832 |
5856 &aTableName, |
5833 } // EapTlsPeapUtils::AlterTableL() |
5857 alteredColSet->Count())); |
|
5858 |
|
5859 delete alteredColSet; |
|
5860 |
|
5861 } // EapTlsPeapUtils::AlterTableL() |
|
5862 |
|
5863 // --------------------------------------------------------- |
5834 |
5864 |
5835 // End of file |
5865 // End of file |
5836 |
5866 |
5837 |
5867 |