|
1 /* |
|
2 * Copyright (c) 2002 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: Implementation of authentication object list |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include "WimAuthenticationObjectList.h" |
|
22 #include "WimAuthenticationObject.h" |
|
23 #include "WimPin.h" |
|
24 #include "WimClsv.h" |
|
25 #include "WimTrace.h" |
|
26 #include "WimTokenListener.h" |
|
27 #include "WimImplementationUID.hrh" |
|
28 #include <mctauthobject.h> |
|
29 |
|
30 // ============================ MEMBER FUNCTIONS =============================== |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // CWimAuthenticationObjectList::CWimAuthenticationObjectList() |
|
34 // Default constructor |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 CWimAuthenticationObjectList::CWimAuthenticationObjectList( CWimToken& aToken ) : |
|
38 CActive( EPriorityHigh ), |
|
39 iToken( aToken ) |
|
40 { |
|
41 } |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CWimAuthenticationObjectList::NewL() |
|
45 // Two phased constructor |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 CWimAuthenticationObjectList* |
|
49 CWimAuthenticationObjectList::NewL( CWimToken& aToken ) |
|
50 { |
|
51 _WIMTRACE ( _L( "CWimAuthenticationObjectList::NewL()" ) ); |
|
52 CWimAuthenticationObjectList* that = |
|
53 new( ELeave ) CWimAuthenticationObjectList( aToken ); |
|
54 CleanupStack::PushL( that ); |
|
55 that->ConstructL(); |
|
56 CleanupStack::Pop( that ); |
|
57 return that; |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CWimAuthenticationObjectList::ConstructL() |
|
62 // Second phase constructor. |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 void CWimAuthenticationObjectList::ConstructL() |
|
66 { |
|
67 _WIMTRACE ( _L( "CWimAuthenticationObjectList::ConstructL()" ) ); |
|
68 CActiveScheduler::Add( this ); |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CWimKeyStore::DoRelease() |
|
73 // Deletes this interface on demand. |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 void CWimAuthenticationObjectList::DoRelease() |
|
77 { |
|
78 _WIMTRACE ( _L( "CWimAuthenticationObjectList::DoRelease()" ) ); |
|
79 delete this; |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // CWimAuthenticationObjectList::~CWimAuthenticationObjectList() |
|
84 // Destructor |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 CWimAuthenticationObjectList::~CWimAuthenticationObjectList() |
|
88 { |
|
89 _WIMTRACE ( |
|
90 _L( "CWimAuthenticationObjectList::~CWimAuthenticationObjectList()" ) ); |
|
91 Cancel(); |
|
92 TInt count = iAuthObjects.Count(); |
|
93 |
|
94 while ( count ) |
|
95 { |
|
96 CWimAuthenticationObject* entry = iAuthObjects[count - 1]; |
|
97 entry->Release(); |
|
98 iAuthObjects.Remove( count - 1 ); |
|
99 count--; |
|
100 } |
|
101 |
|
102 iAuthObjects.Close(); |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CWimAuthenticationObjectList::Token() |
|
107 // Returns a reference to current token (MCTToken) of this authentication |
|
108 // object list interface. |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 MCTToken& CWimAuthenticationObjectList::Token() |
|
112 { |
|
113 _WIMTRACE ( _L( "CWimAuthenticationObjectList::Token()" ) ); |
|
114 return iToken; |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CWimAuthenticationObjectList::List() |
|
119 // Lists all authentication objects. |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 void CWimAuthenticationObjectList::List( |
|
123 RMPointerArray<MCTAuthenticationObject>& aAuthObjects, |
|
124 TRequestStatus& aStatus ) |
|
125 { |
|
126 _WIMTRACE ( _L( "CWimAuthenticationObjectList::List()" ) ); |
|
127 |
|
128 if ( TokenRemoved() ) |
|
129 { |
|
130 return; |
|
131 } |
|
132 |
|
133 _WIMTRACE ( _L( "CWimAuthenticationObjectList::List() after TokenRemoved checking" ) ); |
|
134 aStatus = KRequestPending; |
|
135 iPhase = ECreateList; |
|
136 |
|
137 iClientStatus = &aStatus; |
|
138 iClientAuthObjects = &aAuthObjects; |
|
139 |
|
140 iStatus = KRequestPending; |
|
141 SetActive(); |
|
142 TRequestStatus* status = &iStatus; |
|
143 User::RequestComplete( status, KErrNone ); |
|
144 |
|
145 _WIMTRACE ( _L( "CWimAuthenticationObjectList::List() End" ) ); |
|
146 |
|
147 } |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // CWimAuthenticationObjectList::DoListL() |
|
151 // Fetches first all authentication objects from Wim. After that makes a copy |
|
152 // each of them for the client. |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
|
155 void CWimAuthenticationObjectList::DoListL( |
|
156 RMPointerArray<MCTAuthenticationObject>& aAuthObjects ) |
|
157 { |
|
158 _WIMTRACE ( _L( "CWimAuthenticationObjectList::DoListL()" ) ); |
|
159 |
|
160 TInt count = iAuthObjects.Count(); |
|
161 |
|
162 for ( TInt i = 0; i < count; i++ ) |
|
163 { |
|
164 |
|
165 //SecModUI will call Status() to get the PIN status later. |
|
166 //We donot need to send PIN status in the phase |
|
167 |
|
168 TUint32 status = 0; |
|
169 CWimAuthenticationObject* me = |
|
170 MakeAuthObjectL( iAuthObjects[i]->TokenWider(), |
|
171 iAuthObjects[i]->PinModule(), |
|
172 iAuthObjects[i]->Label(), |
|
173 iAuthObjects[i]->Type(), |
|
174 iAuthObjects[i]->Handle().iObjectId, |
|
175 status ); |
|
176 CleanupStack::PushL( me ); |
|
177 User::LeaveIfError( aAuthObjects.Append( me ) ); |
|
178 CleanupStack::Pop( me ); |
|
179 } |
|
180 } |
|
181 |
|
182 // ----------------------------------------------------------------------------- |
|
183 // CWimAuthenticationObjectList::CreateListL() |
|
184 // This function creates an internal array for authentication objects. |
|
185 // ----------------------------------------------------------------------------- |
|
186 // |
|
187 void CWimAuthenticationObjectList::CreateListL( TRequestStatus& aStatus ) |
|
188 { |
|
189 _WIMTRACE ( _L( "CWimAuthenticationObjectList::CreateListL()" ) ); |
|
190 |
|
191 // Delete previous ones |
|
192 TInt count = iAuthObjects.Count(); |
|
193 |
|
194 while ( count ) |
|
195 { |
|
196 CWimAuthenticationObject* entry = iAuthObjects[count - 1]; |
|
197 entry->Release(); |
|
198 iAuthObjects.Remove( count - 1 ); |
|
199 count--; |
|
200 } |
|
201 |
|
202 TInt ret = iToken.WimSecModule()->PinNrEntriesL( iPinNRs, aStatus ); |
|
203 |
|
204 if ( ret != KErrNone ) |
|
205 { |
|
206 User::Leave( ret ); |
|
207 } |
|
208 } |
|
209 |
|
210 // ----------------------------------------------------------------------------- |
|
211 // CWimAuthenticationObjectList::MakeAuthObjectL() |
|
212 // This function is called from two different places |
|
213 // ----------------------------------------------------------------------------- |
|
214 // |
|
215 CWimAuthenticationObject* |
|
216 CWimAuthenticationObjectList::MakeAuthObjectL( CWimToken& aToken, |
|
217 CWimPin& aPinModule, |
|
218 const TDesC& aLabel, |
|
219 TUid aType, |
|
220 TUint32 aHandle, |
|
221 TUint32 aStatus ) |
|
222 { |
|
223 _WIMTRACE ( _L( "CWimAuthenticationObjectList::MakeAuthObjectL()" ) ); |
|
224 CWimAuthenticationObject* me = |
|
225 CWimAuthenticationObject::NewLC( aToken, |
|
226 aPinModule, |
|
227 aLabel, |
|
228 aType, |
|
229 aHandle, |
|
230 aStatus ); |
|
231 CleanupStack::Pop( me ); |
|
232 return me; |
|
233 } |
|
234 |
|
235 // ----------------------------------------------------------------------------- |
|
236 // CWimAuthenticationObjectList::CancelList() |
|
237 // Because List is synchronous, there is nothing to do here. |
|
238 // ----------------------------------------------------------------------------- |
|
239 // |
|
240 void CWimAuthenticationObjectList::CancelList() |
|
241 { |
|
242 _WIMTRACE ( _L( "CWimAuthenticationObjectList::CancelList()" ) ); |
|
243 Cancel(); |
|
244 } |
|
245 |
|
246 // ----------------------------------------------------------------------------- |
|
247 // CWimAuthenticationObjectList::TokenRemoved() |
|
248 // Returns true or false indicating if token is removed |
|
249 // ----------------------------------------------------------------------------- |
|
250 // |
|
251 TBool CWimAuthenticationObjectList::TokenRemoved() |
|
252 { |
|
253 _WIMTRACE ( _L( "CWimAuthenticationObjectList::TokenRemoved()" ) ); |
|
254 // If token listener is not alive, then token is removed |
|
255 if ( iToken.TokenListener()->TokenStatus() != KRequestPending ) |
|
256 { |
|
257 return ETrue; |
|
258 } |
|
259 else |
|
260 { |
|
261 return EFalse; |
|
262 } |
|
263 } |
|
264 |
|
265 // ----------------------------------------------------------------------------- |
|
266 // CWimAuthenticationObjectList::RunL() |
|
267 // ----------------------------------------------------------------------------- |
|
268 // |
|
269 void CWimAuthenticationObjectList::RunL() |
|
270 { |
|
271 _WIMTRACE ( _L( "CWimAuthenticationObjectList::RunL()" ) ); |
|
272 switch ( iPhase ) |
|
273 { |
|
274 case ECreateList: |
|
275 { |
|
276 iPhase = ECreateListDone; |
|
277 iStatus = KRequestPending; |
|
278 SetActive(); |
|
279 //iPinNRs is initialized here |
|
280 CreateListL( iStatus ); |
|
281 break; |
|
282 } |
|
283 |
|
284 case ECreateListDone: |
|
285 { |
|
286 //Pin type is set here |
|
287 |
|
288 if ( iPinNRs ) // If PINs were found |
|
289 { |
|
290 TUid pintype = {WIM_PIN_G_UID}; // The first one is always PIN-G |
|
291 TInt count = iPinNRs->Count(); |
|
292 TUint32 status = 0; |
|
293 |
|
294 for ( TInt i = 0; i < count; i++ ) |
|
295 { |
|
296 CWimAuthenticationObject* me = |
|
297 MakeAuthObjectL( iToken, |
|
298 *( *iPinNRs )[i], |
|
299 ( *iPinNRs )[i]->Label(), |
|
300 pintype, |
|
301 ( *iPinNRs )[i]->PinNumber(), |
|
302 status ); |
|
303 CleanupStack::PushL( me ); |
|
304 User::LeaveIfError ( iAuthObjects.Append( me ) ); |
|
305 CleanupStack::Pop( me ); |
|
306 pintype.iUid = WIM_PIN_NR_UID; // The others are always PIN-NR |
|
307 } |
|
308 } |
|
309 iPhase = EDoList; |
|
310 iStatus = KRequestPending; |
|
311 SetActive(); |
|
312 TRequestStatus* status = &iStatus; |
|
313 User::RequestComplete( status, KErrNone ); |
|
314 break; |
|
315 } |
|
316 |
|
317 case EDoList: |
|
318 { |
|
319 _WIMTRACE ( _L( "CWimAuthenticationObjectList::RunL(): EDoList" ) ); |
|
320 DoListL( *iClientAuthObjects ); |
|
321 User::RequestComplete( iClientStatus, KErrNone ); |
|
322 break; |
|
323 } |
|
324 |
|
325 default: |
|
326 break; |
|
327 } |
|
328 |
|
329 } |
|
330 |
|
331 // ----------------------------------------------------------------------------- |
|
332 // CWimAuthenticationObjectList::DoCancel() |
|
333 // ----------------------------------------------------------------------------- |
|
334 // |
|
335 void CWimAuthenticationObjectList::DoCancel() |
|
336 { |
|
337 _WIMTRACE ( _L( "CWimAuthenticationObjectList::DoCancel()" ) ); |
|
338 User::RequestComplete( iClientStatus, KErrCancel ); |
|
339 } |
|
340 |
|
341 // ----------------------------------------------------------------------------- |
|
342 // CWimAuthenticationObjectList::RunError() |
|
343 // ----------------------------------------------------------------------------- |
|
344 // |
|
345 TInt CWimAuthenticationObjectList::RunError( TInt aError ) |
|
346 { |
|
347 _WIMTRACE ( _L( "CWimAuthenticationObjectList::RunError()" ) ); |
|
348 User::RequestComplete( iClientStatus, aError ); |
|
349 return KErrNone; |
|
350 } |
|
351 |
|
352 |
|
353 // End of File |