|
1 /* |
|
2 * Copyright (c) 2007-2009 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 "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: |
|
15 * Name : CSIPSecSIMCredentialsProvider.h |
|
16 * Part of : SIPSec |
|
17 * Version : SIP/6.0 |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 /** |
|
25 @internalComponent |
|
26 */ |
|
27 |
|
28 #ifndef __SIPSEC_SIMCREDENTIALSPROVIDER_H__ |
|
29 #define __SIPSEC_SIMCREDENTIALSPROVIDER_H__ |
|
30 |
|
31 // INCLUDES |
|
32 #include <etelmm.h> |
|
33 #include "CSIPSecUserCredentialsProvider.h" |
|
34 |
|
35 // FORWARD DECLARATIONS |
|
36 class CAsyncRetrieveAuthorizationInfo; |
|
37 class CSIPSecSIMRecord; |
|
38 |
|
39 |
|
40 // To run some test cases with the real code, instead of stub, comment the line |
|
41 // "#define USE_TEST_STUB" below. |
|
42 // Note that with that done, some AKA test cases are not executed, as they |
|
43 // crash. |
|
44 #if defined( CPPUNIT_TEST ) |
|
45 #define USE_TEST_STUB |
|
46 #endif |
|
47 |
|
48 #if defined( USE_TEST_STUB ) |
|
49 |
|
50 #include "timermanagerstub.h" |
|
51 #define SIPSECSTUB inline |
|
52 |
|
53 #else |
|
54 |
|
55 #define SIPSECSTUB |
|
56 |
|
57 #endif |
|
58 |
|
59 |
|
60 /** |
|
61 * @brief Class is observer of async call-backs from SIM |
|
62 * |
|
63 * @class MSIPSecIMSAuthenticationDataObserver CSIPSecSIMCredentialsProvider.h |
|
64 * "CSIPSecSIMCredentialsProvider.h" |
|
65 */ |
|
66 class MSIPSecIMSAuthenticationDataObserver |
|
67 { |
|
68 public: |
|
69 |
|
70 /** |
|
71 * Called when user name is been resolved |
|
72 */ |
|
73 virtual void Authorized() = 0; |
|
74 |
|
75 /** |
|
76 * Called when authorization failed |
|
77 */ |
|
78 virtual void AuthorizationFailedL() = 0; |
|
79 |
|
80 /** |
|
81 * Called when authentication finnishes |
|
82 */ |
|
83 virtual void AuthenticatedL() = 0; |
|
84 |
|
85 /** |
|
86 * Called when authentication fails |
|
87 * @param aReason Error code telling why authentication failed. |
|
88 */ |
|
89 virtual void AuthenticationFailedL( TInt aReason ) = 0; |
|
90 |
|
91 /** |
|
92 * Inform SIPSec FW that a non-IMS Authentication specific error occurred. |
|
93 * @param aError Error code |
|
94 * @param TBool ETrue if IMS authentication failed |
|
95 * EFalse if IMS Authorization failed |
|
96 * @return TInt Value to return from RunL to active scheduler. |
|
97 */ |
|
98 virtual TInt PassErrorToFramework( TInt aError, |
|
99 TBool aAuthenticate) const = 0; |
|
100 }; |
|
101 |
|
102 |
|
103 |
|
104 /** |
|
105 * @brief Class represent SIM authentication |
|
106 * |
|
107 * @class CSIPSecIMSAuthentication CSIPSecSIMCredentialsProvider.h |
|
108 * "CSIPSecSIMCredentialsProvider.h" |
|
109 */ |
|
110 class CSIPSecIMSAuthentication : public CActive |
|
111 { |
|
112 public: // Constructors and destructor |
|
113 /** |
|
114 * Constructs an object |
|
115 * @param aObserver credetnials provider |
|
116 * @return new instance, ownership is tranferred |
|
117 */ |
|
118 static CSIPSecIMSAuthentication* NewL( |
|
119 MSIPSecIMSAuthenticationDataObserver& aObserver ); |
|
120 |
|
121 /** |
|
122 * Destructor |
|
123 */ |
|
124 ~CSIPSecIMSAuthentication(); |
|
125 |
|
126 public: // New functions |
|
127 |
|
128 /** |
|
129 * Starts authentication |
|
130 * @param aPhone the mobile phone |
|
131 */ |
|
132 SIPSECSTUB void Request( RMobilePhone& aPhone ); |
|
133 |
|
134 /** |
|
135 * Returns the authenticate data |
|
136 * @return RMobilePhone::TImsAuthenticateDataV5 |
|
137 */ |
|
138 RMobilePhone::TImsAuthenticateDataV5& Response(); |
|
139 |
|
140 public: // From CActive |
|
141 |
|
142 void RunL(); |
|
143 |
|
144 TInt RunError( TInt aError ); |
|
145 |
|
146 void DoCancel(); |
|
147 |
|
148 private: // New functions, for internal use |
|
149 |
|
150 /** |
|
151 * Constructor |
|
152 * @param aObserver credentials provider |
|
153 */ |
|
154 CSIPSecIMSAuthentication( |
|
155 MSIPSecIMSAuthenticationDataObserver& aObserver ); |
|
156 |
|
157 private: // Data |
|
158 |
|
159 // Authentication data |
|
160 RMobilePhone::TImsAuthenticateDataV5 iData; |
|
161 |
|
162 // Observer |
|
163 MSIPSecIMSAuthenticationDataObserver& iObserver; |
|
164 |
|
165 // Points to CSIPSecSIMCredentialsProvider::iPhone. Must be remembered |
|
166 // until the asynchronous request completes, in case the request has to be |
|
167 // canceled. Not owned. |
|
168 RMobilePhone* iPhone; |
|
169 |
|
170 // Message which is sent to ETelServer |
|
171 // Having this as member variable helps to extend |
|
172 // its lifetime and help is InterProcess Communication. |
|
173 RMobilePhone::TImsAuthenticateDataV5Pckg iMessage; |
|
174 |
|
175 private: // For testing purposes |
|
176 |
|
177 #ifdef CPPUNIT_TEST |
|
178 friend class CSIPSecSIMCredentialsProviderTest; |
|
179 #endif |
|
180 }; |
|
181 |
|
182 |
|
183 |
|
184 /** |
|
185 * @brief Class represent SIM authorization |
|
186 * |
|
187 * @class CSIPSecIMSAuthorization CSIPSecSIMCredentialsProvider.h |
|
188 * "CSIPSecSIMCredentialsProvider.h" |
|
189 */ |
|
190 class CSIPSecIMSAuthorization : public CActive |
|
191 { |
|
192 public: // Constructors and destructor |
|
193 |
|
194 /** |
|
195 * Constructs an object |
|
196 * @param aObserver credentials provider |
|
197 * @return new instance, ownership is tranferred |
|
198 */ |
|
199 static CSIPSecIMSAuthorization* NewL( |
|
200 MSIPSecIMSAuthenticationDataObserver& aObserver ); |
|
201 |
|
202 /** |
|
203 * Destructor |
|
204 */ |
|
205 ~CSIPSecIMSAuthorization(); |
|
206 |
|
207 public: // New functions |
|
208 |
|
209 /** |
|
210 * Starts authorization |
|
211 * @param aPhone the mobile phone |
|
212 */ |
|
213 SIPSECSTUB void RequestL( RMobilePhone& aPhone ); |
|
214 |
|
215 /** |
|
216 * Returns the authorization data |
|
217 * @return RMobilePhone::CImsAuthorizationInfoV5 |
|
218 */ |
|
219 RMobilePhone::CImsAuthorizationInfoV5& Response(); |
|
220 |
|
221 public: // From CActive |
|
222 |
|
223 SIPSECSTUB void RunL(); |
|
224 |
|
225 TInt RunError( TInt aError ); |
|
226 |
|
227 void DoCancel(); |
|
228 |
|
229 private: // New functions, for internal use |
|
230 |
|
231 /** |
|
232 * Constructor |
|
233 * @param aObserver credentials provider |
|
234 */ |
|
235 CSIPSecIMSAuthorization( MSIPSecIMSAuthenticationDataObserver& aObserver ); |
|
236 |
|
237 /** |
|
238 * 2nd phase constructor |
|
239 */ |
|
240 void ConstructL(); |
|
241 |
|
242 private: // Data |
|
243 |
|
244 // Auth data, owned. |
|
245 RMobilePhone::CImsAuthorizationInfoV5* iData; |
|
246 |
|
247 // Retriever, owned. |
|
248 CAsyncRetrieveAuthorizationInfo* iRetriever; |
|
249 |
|
250 MSIPSecIMSAuthenticationDataObserver& iObserver; |
|
251 |
|
252 // For testing purposes |
|
253 #ifdef CPPUNIT_TEST |
|
254 friend class CSIPSecSIMCredentialsProviderTest; |
|
255 #endif |
|
256 }; |
|
257 |
|
258 |
|
259 |
|
260 |
|
261 |
|
262 /** |
|
263 * @brief Class represents SIM credentials provider |
|
264 * |
|
265 * @class CSIPSecIMSAuthorization CSIPSecSIMCredentialsProvider.h |
|
266 * "CSIPSecSIMCredentialsProvider.h" |
|
267 */ |
|
268 class CSIPSecSIMCredentialsProvider : |
|
269 public CSIPSecCredentialsProvider, |
|
270 public MSIPSecIMSAuthenticationDataObserver |
|
271 { |
|
272 public: // Constructors and destructor |
|
273 |
|
274 /** |
|
275 * Constructor |
|
276 * @param aRecord SIM record |
|
277 * @return New instance, ownership is tranferred |
|
278 */ |
|
279 static CSIPSecSIMCredentialsProvider* |
|
280 NewL( CSIPSecSIMRecord& aRecord ); |
|
281 |
|
282 /** |
|
283 * Destructor |
|
284 */ |
|
285 ~CSIPSecSIMCredentialsProvider(); |
|
286 |
|
287 public: // From CSIPSecCredentialsProvider |
|
288 |
|
289 void RequestL( TSIPSecDigestCtxSetup& aContext ); |
|
290 |
|
291 void Cancel(); |
|
292 |
|
293 public: // From MSIPSecIMSAuthenticationDataObserver |
|
294 |
|
295 void Authorized(); |
|
296 |
|
297 void AuthorizationFailedL(); |
|
298 |
|
299 void AuthenticatedL(); |
|
300 |
|
301 void AuthenticationFailedL( TInt aReason ); |
|
302 |
|
303 TInt PassErrorToFramework( TInt aError, TBool aAuthenticate) const; |
|
304 |
|
305 private: // Constructors, for internal use |
|
306 |
|
307 /** |
|
308 * Constructor |
|
309 * @param aRecord SIM record |
|
310 */ |
|
311 CSIPSecSIMCredentialsProvider( CSIPSecSIMRecord& aRecord ); |
|
312 |
|
313 /** |
|
314 * 2nd phase constructor |
|
315 */ |
|
316 SIPSECSTUB void ConstructL(); |
|
317 |
|
318 private: // New functions, for internal use |
|
319 |
|
320 /** |
|
321 * Obtain the name of the currently selected TSY phone module name. |
|
322 * @param aModuleName Place holder for name |
|
323 */ |
|
324 void GetTsyModuleNameL( TDes& aTsyModuleName ) const; |
|
325 |
|
326 /** |
|
327 * Load, open and initialize the phone. |
|
328 * @param aModuleName IN: TSY phone module name |
|
329 */ |
|
330 void PreparePhoneL( const TDes& aTsyModuleName ); |
|
331 |
|
332 /** |
|
333 * Requests user name |
|
334 */ |
|
335 void RequestUserNameL(); |
|
336 |
|
337 /** |
|
338 * Requests password |
|
339 */ |
|
340 void RequestPassword(); |
|
341 |
|
342 /** |
|
343 * Common part for the authorization and authentication failures. |
|
344 * @param aUserRecord User record |
|
345 */ |
|
346 void Failure( const CSIPSecUserRecord& aUserRecord ); |
|
347 |
|
348 private: // Data |
|
349 |
|
350 /** |
|
351 * Etel server |
|
352 */ |
|
353 RTelServer iEtelServer; |
|
354 |
|
355 /** |
|
356 * Phone instance |
|
357 */ |
|
358 RMobilePhone iPhone; |
|
359 |
|
360 /** |
|
361 * Authorization, owned |
|
362 */ |
|
363 CSIPSecIMSAuthorization* iAuthorization; |
|
364 |
|
365 /** |
|
366 * Authentication, owned |
|
367 */ |
|
368 CSIPSecIMSAuthentication* iAuthentication; |
|
369 |
|
370 /** |
|
371 * Outbound proxy, owned |
|
372 */ |
|
373 HBufC8* iOutboundProxy; |
|
374 |
|
375 private: // For testing purposes |
|
376 |
|
377 /** |
|
378 * Write a part of memory to log. |
|
379 * @param aMessage Message to write into the log |
|
380 * @param aData Memory area which is written to log as hex dump. |
|
381 */ |
|
382 void HexDumpToLog( const TDesC8& aMessage, |
|
383 const TDesC8& aData ) const; |
|
384 |
|
385 #ifdef CPPUNIT_TEST |
|
386 friend class CSIPSecProviderTest; |
|
387 friend class CSIPSecSIMCredentialsProviderTest; |
|
388 #endif |
|
389 }; |
|
390 |
|
391 |
|
392 #if defined( USE_TEST_STUB ) |
|
393 #include "CSIPSecSIMCredentialsProviderStub.inl" |
|
394 #endif |
|
395 |
|
396 #endif // end of __SIPSEC_SIMCREDENTIALSPROVIDER_H__ |
|
397 |
|
398 // End of File |