|
1 /* |
|
2 * Copyright (c) 2001-2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: EAP and WLAN authentication protocols. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // This is enumeration of EAPOL source code. |
|
20 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES) |
|
21 #undef EAP_FILE_NUMBER_ENUM |
|
22 #define EAP_FILE_NUMBER_ENUM 292 |
|
23 #undef EAP_FILE_NUMBER_DATE |
|
24 #define EAP_FILE_NUMBER_DATE 1127594498 |
|
25 #endif //#if defined(USE_EAP_MINIMUM_RELEASE_TRACES) |
|
26 |
|
27 |
|
28 // INCLUDE FILES |
|
29 |
|
30 #include "EapMsChapV2.h" |
|
31 #include "eap_am_type_mschapv2_symbian.h" |
|
32 #include "eap_type_mschapv2.h" |
|
33 #include "EapMsChapV2Global.h" |
|
34 #include <EapTypeInfo.h> |
|
35 #include "EapMsChapV2DbUtils.h" |
|
36 |
|
37 #include <EapMsChapV2UiConnection.h> |
|
38 #include "EapMschapv2Ui.h" |
|
39 |
|
40 // LOCAL CONSTANTS |
|
41 |
|
42 // The version number of this interface. |
|
43 const TUint KInterfaceVersion = 1; |
|
44 |
|
45 |
|
46 // ================= MEMBER FUNCTIONS ======================= |
|
47 |
|
48 |
|
49 CEapMsChapV2::CEapMsChapV2(const TIndexType aIndexType, |
|
50 const TInt aIndex, const eap_type_value_e aEapType /* =eap_type_mschapv2 */) |
|
51 : iIndexType(aIndexType) |
|
52 , iIndex(aIndex) |
|
53 , iTunnelingType(eap_type_none) |
|
54 , iEapType(aEapType) |
|
55 { |
|
56 } |
|
57 |
|
58 // ---------------------------------------------------------- |
|
59 |
|
60 CEapMsChapV2* CEapMsChapV2::NewL(SIapInfo *aIapInfo) |
|
61 { |
|
62 return new (ELeave) CEapMsChapV2(aIapInfo->indexType, aIapInfo->index); |
|
63 } |
|
64 |
|
65 // ---------------------------------------------------------- |
|
66 |
|
67 CEapMsChapV2* CEapMsChapV2::NewPlainMSCHAPv2L(SIapInfo *aIapInfo) |
|
68 { |
|
69 return new (ELeave) CEapMsChapV2( |
|
70 aIapInfo->indexType, |
|
71 aIapInfo->index, |
|
72 #if defined(USE_EAP_EXPANDED_TYPES) |
|
73 eap_expanded_type_ttls_plain_mschapv2.get_type() |
|
74 #else |
|
75 eap_type_plain_mschapv2 |
|
76 #endif //#if defined(USE_EAP_EXPANDED_TYPES) |
|
77 ); |
|
78 } |
|
79 |
|
80 |
|
81 // ---------------------------------------------------------- |
|
82 |
|
83 CEapMsChapV2::~CEapMsChapV2() |
|
84 { |
|
85 } |
|
86 |
|
87 // ---------------------------------------------------------- |
|
88 |
|
89 #ifdef USE_EAP_SIMPLE_CONFIG |
|
90 |
|
91 eap_base_type_c* CEapMsChapV2::GetStackInterfaceL(abs_eap_am_tools_c* const aTools, |
|
92 abs_eap_base_type_c* const aPartner, |
|
93 const bool is_client_when_true, |
|
94 const eap_am_network_id_c * const receive_network_id, |
|
95 abs_eap_configuration_if_c * const /*configuration_if*/) |
|
96 |
|
97 #else |
|
98 |
|
99 eap_base_type_c* CEapMsChapV2::GetStackInterfaceL(abs_eap_am_tools_c* const aTools, |
|
100 abs_eap_base_type_c* const aPartner, |
|
101 const bool is_client_when_true, |
|
102 const eap_am_network_id_c * const receive_network_id) |
|
103 |
|
104 #endif // #ifdef USE_EAP_SIMPLE_CONFIG |
|
105 { |
|
106 // Create AM |
|
107 eap_am_type_mschapv2_symbian_c* amEapType = eap_am_type_mschapv2_symbian_c::NewL( |
|
108 aTools, |
|
109 aPartner, |
|
110 iIndexType, |
|
111 iIndex, |
|
112 iTunnelingType, |
|
113 is_client_when_true, |
|
114 receive_network_id); |
|
115 if (amEapType->get_is_valid() == false) |
|
116 { |
|
117 amEapType->shutdown(); |
|
118 delete amEapType; |
|
119 User::Leave(KErrGeneral); |
|
120 } |
|
121 eap_base_type_c* type = 0; |
|
122 |
|
123 type = new eap_type_mschapv2_c( |
|
124 aTools, |
|
125 aPartner, |
|
126 amEapType, |
|
127 true /* free_am */, |
|
128 is_client_when_true, |
|
129 receive_network_id); |
|
130 |
|
131 if (type == 0) |
|
132 { |
|
133 // Out of memory |
|
134 amEapType->shutdown(); |
|
135 delete amEapType; |
|
136 User::Leave(KErrNoMemory); |
|
137 } |
|
138 else if (type->get_is_valid() == false) |
|
139 { |
|
140 type->shutdown(); |
|
141 // amEapType is freed by eap_type_mschapv2_c |
|
142 delete type; |
|
143 User::Leave(KErrGeneral); |
|
144 } |
|
145 return type; |
|
146 |
|
147 } |
|
148 |
|
149 // ---------------------------------------------------------- |
|
150 |
|
151 TUint CEapMsChapV2::GetInterfaceVersion() |
|
152 { |
|
153 return KInterfaceVersion; |
|
154 } |
|
155 |
|
156 |
|
157 // ---------------------------------------------------------- |
|
158 TInt CEapMsChapV2::InvokeUiL() |
|
159 { |
|
160 TInt buttonId(0); |
|
161 |
|
162 #ifdef USE_EAP_EXPANDED_TYPES |
|
163 |
|
164 CEapMsChapV2UiConnection uiConn(iIndexType, iIndex, |
|
165 iTunnelingType.get_vendor_type(), iEapType.get_vendor_type()); |
|
166 |
|
167 #else |
|
168 |
|
169 CEapMsChapV2UiConnection uiConn(iIndexType, iIndex, iTunnelingType, (TInt)iEapType); |
|
170 |
|
171 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
|
172 |
|
173 CEapMsChapV2Ui* ui = CEapMsChapV2Ui::NewL(&uiConn); |
|
174 CleanupStack::PushL(ui); |
|
175 buttonId = ui->InvokeUiL(); |
|
176 CleanupStack::PopAndDestroy(ui); |
|
177 return buttonId; |
|
178 } |
|
179 |
|
180 |
|
181 // ---------------------------------------------------------- |
|
182 CEapTypeInfo* CEapMsChapV2::GetInfoLC() |
|
183 { |
|
184 CEapTypeInfo* info = new(ELeave) CEapTypeInfo( |
|
185 (TDesC&)KReleaseDate, |
|
186 (TDesC&)KEapTypeVersion, |
|
187 (TDesC&)KManufacturer); |
|
188 |
|
189 CleanupStack::PushL(info); |
|
190 return info; |
|
191 } |
|
192 |
|
193 // ---------------------------------------------------------- |
|
194 |
|
195 void CEapMsChapV2::DeleteConfigurationL() |
|
196 { |
|
197 EapMsChapV2DbUtils::DeleteConfigurationL(iIndexType, iIndex, iTunnelingType); |
|
198 } |
|
199 |
|
200 // ---------------------------------------------------------- |
|
201 |
|
202 void CEapMsChapV2::SetTunnelingType(const TInt aTunnelingType) |
|
203 { |
|
204 #ifdef USE_EAP_EXPANDED_TYPES |
|
205 |
|
206 // Vendor id is eap_type_vendor_id_ietf always in this plugin. |
|
207 iTunnelingType.set_eap_type_values(eap_type_vendor_id_ietf, aTunnelingType); |
|
208 |
|
209 #else |
|
210 |
|
211 iTunnelingType = static_cast<eap_type_value_e>(aTunnelingType); |
|
212 |
|
213 #endif //#ifdef USE_EAP_EXPANDED_TYPES |
|
214 } |
|
215 |
|
216 // ---------------------------------------------------------- |
|
217 void CEapMsChapV2::SetIndexL( |
|
218 const TIndexType aIndexType, |
|
219 const TInt aIndex) |
|
220 { |
|
221 // First delete the target configuration |
|
222 TIndexType tmpIndexType = iIndexType; |
|
223 TInt tmpIndex = iIndex; |
|
224 |
|
225 iIndexType = aIndexType; |
|
226 iIndex = aIndex; |
|
227 |
|
228 TInt err(KErrNone); |
|
229 TRAP(err, DeleteConfigurationL()); |
|
230 // Ignore error on purpose |
|
231 |
|
232 // Return the indices |
|
233 iIndexType = tmpIndexType; |
|
234 iIndex = tmpIndex; |
|
235 |
|
236 RDbNamedDatabase db; |
|
237 |
|
238 RDbs session; |
|
239 |
|
240 EapMsChapV2DbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType); |
|
241 |
|
242 CleanupClosePushL(session); |
|
243 CleanupClosePushL(db); |
|
244 |
|
245 EapMsChapV2DbUtils::SetIndexL( |
|
246 db, |
|
247 iIndexType, |
|
248 iIndex, |
|
249 iTunnelingType, |
|
250 aIndexType, |
|
251 aIndex, |
|
252 iTunnelingType); |
|
253 |
|
254 iIndexType = aIndexType; |
|
255 iIndex = aIndex; |
|
256 |
|
257 CleanupStack::PopAndDestroy(2); // db |
|
258 } |
|
259 |
|
260 void CEapMsChapV2::SetConfigurationL(const EAPSettings& aSettings) |
|
261 { |
|
262 RDbNamedDatabase db; |
|
263 |
|
264 RDbs session; |
|
265 |
|
266 // This also creates the IAP entry if it doesn't exist |
|
267 EapMsChapV2DbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType); |
|
268 |
|
269 CleanupClosePushL(session); |
|
270 CleanupClosePushL(db); |
|
271 |
|
272 EapMsChapV2DbUtils::SetConfigurationL( |
|
273 db, |
|
274 aSettings, |
|
275 iIndexType, |
|
276 iIndex, |
|
277 iTunnelingType); |
|
278 |
|
279 CleanupStack::PopAndDestroy(2); // db, session |
|
280 } |
|
281 |
|
282 void CEapMsChapV2::GetConfigurationL(EAPSettings& aSettings) |
|
283 { |
|
284 RDbNamedDatabase db; |
|
285 |
|
286 RDbs session; |
|
287 |
|
288 // This also creates the IAP entry if it doesn't exist |
|
289 EapMsChapV2DbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType); |
|
290 |
|
291 CleanupClosePushL(session); |
|
292 CleanupClosePushL(db); |
|
293 |
|
294 EapMsChapV2DbUtils::GetConfigurationL( |
|
295 db, |
|
296 aSettings, |
|
297 iIndexType, |
|
298 iIndex, |
|
299 iTunnelingType); |
|
300 |
|
301 CleanupStack::PopAndDestroy(2); // db, session |
|
302 } |
|
303 |
|
304 void CEapMsChapV2::CopySettingsL( |
|
305 const TIndexType aDestinationIndexType, |
|
306 const TInt aDestinationIndex) |
|
307 { |
|
308 // First delete the target configuration |
|
309 TIndexType tmpIndexType = iIndexType; |
|
310 TInt tmpIndex = iIndex; |
|
311 |
|
312 iIndexType = aDestinationIndexType; |
|
313 iIndex = aDestinationIndex; |
|
314 |
|
315 TInt err(KErrNone); |
|
316 TRAP(err, DeleteConfigurationL()); |
|
317 // Ignore error on purpose |
|
318 |
|
319 // Return the indices |
|
320 iIndexType = tmpIndexType; |
|
321 iIndex = tmpIndex; |
|
322 |
|
323 RDbNamedDatabase db; |
|
324 |
|
325 RDbs session; |
|
326 |
|
327 EapMsChapV2DbUtils::OpenDatabaseL(db, session, iIndexType, iIndex, iTunnelingType); |
|
328 |
|
329 CleanupClosePushL(session); |
|
330 CleanupClosePushL(db); |
|
331 |
|
332 EapMsChapV2DbUtils::CopySettingsL( |
|
333 db, |
|
334 iIndexType, |
|
335 iIndex, |
|
336 iTunnelingType, |
|
337 aDestinationIndexType, |
|
338 aDestinationIndex, |
|
339 iTunnelingType); |
|
340 |
|
341 CleanupStack::PopAndDestroy(2); // db |
|
342 |
|
343 } |
|
344 |
|
345 // End of file |