|
1 /* |
|
2 * Copyright (c) 2002-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: Services for authentication object management |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "WimServer.h" |
|
22 #include "Wimi.h" //WIMI definitions |
|
23 #include "WimClsv.h" |
|
24 #include "WimAuthObjHandler.h" |
|
25 #include "WimMemMgmt.h" |
|
26 #include "WimResponse.h" |
|
27 #include "WimUtilityFuncs.h" |
|
28 #include "WimSecurityDlgHandler.h" |
|
29 #include "WimTrace.h" |
|
30 #include "WimCallbackImpl.h" |
|
31 #include "WimCleanup.h" |
|
32 #include "JavaUtils.h" |
|
33 #include <random.h> |
|
34 |
|
35 #ifdef _DEBUG |
|
36 _LIT( KWimAuthObjPanic, "WimAuthObj" ); |
|
37 #endif |
|
38 |
|
39 |
|
40 // ============================ MEMBER FUNCTIONS =============================== |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // CWimAuthObjHandler::CWimAuthObjHandler |
|
44 // C++ default constructor can NOT contain any code, that |
|
45 // might leave. |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 CWimAuthObjHandler::CWimAuthObjHandler() : CActive( EPriorityStandard ) |
|
49 { |
|
50 _WIMTRACE(_L("WIM | WIMServer | CWimAuthObjHandler::CWimAuthObjHandler | Begin")); |
|
51 iDisablePINBlocked = EFalse; |
|
52 iUnblockPING = EFalse; |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CWimAuthObjHandler::ConstructL |
|
57 // Symbian 2nd phase constructor can leave. |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 void CWimAuthObjHandler::ConstructL() |
|
61 { |
|
62 _WIMTRACE(_L("WIM | WIMServer | CWimAuthObjHandler::ConstructL | Begin")); |
|
63 CActiveScheduler::Add( this ); |
|
64 iWimUtilFuncs = CWimUtilityFuncs::NewL(); |
|
65 iWimSecDlg = CWimSecurityDlgHandler::NewL(); |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CWimAuthObjHandler::NewL |
|
70 // Two-phased constructor. |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 CWimAuthObjHandler* CWimAuthObjHandler::NewL() |
|
74 { |
|
75 _WIMTRACE(_L("WIM | WIMServer | CWimAuthObjHandler::NewL | Begin")); |
|
76 CWimAuthObjHandler* self = new( ELeave ) CWimAuthObjHandler; |
|
77 CleanupStack::PushL( self ); |
|
78 self->ConstructL(); |
|
79 CleanupStack::Pop( self ); |
|
80 return self; |
|
81 } |
|
82 |
|
83 // Destructor |
|
84 CWimAuthObjHandler::~CWimAuthObjHandler() |
|
85 { |
|
86 _WIMTRACE(_L("WIM | WIMServer | CWimAuthObjHandler::~CWimAuthObjHandler | Begin")); |
|
87 Cancel(); |
|
88 delete iWimUtilFuncs; |
|
89 delete iWimSecDlg; |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // CWimAuthObjHandler::GetPINCountL |
|
94 // Fetches the count of PINs in WIM. |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 void CWimAuthObjHandler::GetPINCountL( const RMessage2& aMessage ) const |
|
98 { |
|
99 _WIMTRACE(_L("WIM | WIMServer | CWimAuthObjHandler::GetPINCountL | Begin")); |
|
100 WIMI_Ref_pt pWimStruct = const_cast<WIMI_Ref_pt>( aMessage.Ptr0() ); |
|
101 TUint16 pinNum; |
|
102 WIMI_RefList_t refList; |
|
103 WIMI_STAT status = WIMI_Ok; |
|
104 |
|
105 status = WIMI_GetPINList( pWimStruct, &pinNum, &refList ); |
|
106 |
|
107 if ( status == WIMI_Ok ) |
|
108 { |
|
109 free_WIMI_RefList_t( refList ); |
|
110 TPckgBuf<TUint> pckg( pinNum ); |
|
111 aMessage.WriteL( 1, pckg ); |
|
112 } |
|
113 aMessage.Complete( CWimUtilityFuncs::MapWIMError( status ) ); |
|
114 } |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // CWimAuthObjHandler::GetPINRefListL |
|
118 // Get reference list for PINs. |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 void CWimAuthObjHandler::GetPINRefListL( |
|
122 const RMessage2& aMessage, |
|
123 CWimMemMgmt* aWimMgmt ) |
|
124 { |
|
125 _WIMTRACE(_L("WIM | WIMServer | CWimAuthObjHandler::GetPINRefListL | Begin")); |
|
126 WIMI_Ref_pt pWimStruct = const_cast<WIMI_Ref_pt>( aMessage.Ptr0() ); |
|
127 __ASSERT_ALWAYS( pWimStruct, User::Leave( KErrArgument ) ); |
|
128 HBufC8* buf = iWimUtilFuncs->DesLC( 2, aMessage ); |
|
129 TUint32* pinArr = ( TUint32* )( buf->Des().Ptr() ); |
|
130 TUint16 pinNum; |
|
131 WIMI_RefList_t pinRefLst; |
|
132 WIMI_STAT status = WIMI_Ok; |
|
133 |
|
134 status = WIMI_GetPINList( pWimStruct, &pinNum, &pinRefLst ); |
|
135 |
|
136 if ( status == WIMI_Ok ) |
|
137 { |
|
138 aWimMgmt->AppendWIMRefLstL( pinRefLst ); // takes ownership |
|
139 TPckgBuf<TUint32> lstAddr( ( TUint32 ) pinRefLst ); |
|
140 for ( TUint8 index = 0; index < pinNum; index++ ) |
|
141 { |
|
142 pinArr[index] = ( TUint32 ) pinRefLst[index]; |
|
143 } |
|
144 |
|
145 iPinGRef = const_cast< WIMI_Ref_pt >( pinRefLst[0] ); |
|
146 |
|
147 aMessage.WriteL( 1, lstAddr ); |
|
148 aMessage.WriteL( 2, buf->Des() ); |
|
149 } |
|
150 CleanupStack::PopAndDestroy( buf ); |
|
151 aMessage.Complete( CWimUtilityFuncs::MapWIMError( status ) ); |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // CWimAuthObjHandler::GetPINInfoL |
|
156 // Get detailed information about the PIN. |
|
157 // ----------------------------------------------------------------------------- |
|
158 // |
|
159 void CWimAuthObjHandler::GetPINInfoL( const RMessage2& aMessage ) |
|
160 { |
|
161 _WIMTRACE(_L("WIM | WIMServer | CWimAuthObjHandler::GetPINInfoL | Begin")); |
|
162 WIMI_Ref_pt pPinStruct = const_cast<WIMI_Ref_pt>( aMessage.Ptr0() ); |
|
163 __ASSERT_ALWAYS( pPinStruct, User::Leave( KErrArgument ) ); |
|
164 TUint8 flags; |
|
165 TUint8 minLength; |
|
166 TUint8 pinNumber = 0; |
|
167 WIMI_BinData_t ptLabel; |
|
168 WIMI_STAT status = WIMI_Ok; |
|
169 |
|
170 if ( pPinStruct ) |
|
171 { |
|
172 iPinValue.Zero(); |
|
173 TRequestStatus status1; |
|
174 CWimCallBack::SetSignTextRequestStatus( &status1 ); |
|
175 status = WIMI_VerifyPINReq( NULL,pPinStruct, |
|
176 ( TUint8 )iPinValue.Length(), |
|
177 ( TUint8* )iPinValue.Ptr() ); |
|
178 |
|
179 if ( status != WIMI_Ok ) |
|
180 { |
|
181 aMessage.Complete( CWimUtilityFuncs::MapWIMError( status ) ); |
|
182 return; |
|
183 } |
|
184 |
|
185 User::WaitForRequest( status1 ); |
|
186 CWimCallBack::SetSignTextRequestStatus( NULL ); |
|
187 WIMI_Ref_t* cmeWimRef = NULL; |
|
188 |
|
189 status = WIMI_GetPINStatus( pPinStruct, |
|
190 &cmeWimRef, |
|
191 &flags, |
|
192 &minLength, |
|
193 &pinNumber, |
|
194 &ptLabel ); |
|
195 |
|
196 if ( status == WIMI_Ok ) |
|
197 { |
|
198 // Code MAY NOT leave before cmeWimRef and ptLabel.pb_buf are deallocated. |
|
199 |
|
200 TPckgBuf<TWimPinStruct> infoPckg; |
|
201 TInt readErr = aMessage.Read( 1, infoPckg ); |
|
202 if( readErr ) |
|
203 { |
|
204 free_WIMI_Ref_t( cmeWimRef ); |
|
205 WSL_OS_Free( ptLabel.pb_buf ); |
|
206 // Code can leave after this point. |
|
207 User::Leave( readErr ); |
|
208 } |
|
209 |
|
210 TBuf<KLabelLen> label; |
|
211 label.Copy( TPtr8( ptLabel.pb_buf, |
|
212 ptLabel.ui_buf_length, |
|
213 ptLabel.ui_buf_length ) ); |
|
214 |
|
215 // Possible values of iStatus are: |
|
216 // EEnabled = 0x80, |
|
217 // EChangeDisabled = 0x40, |
|
218 // EUnblockDisabled = 0x20, |
|
219 // EDisableAllowed = 0x10, |
|
220 |
|
221 if( status1.Int() == KErrLocked ) |
|
222 { |
|
223 infoPckg().iStatus = flags & KPINStatusMask; |
|
224 infoPckg().iStatus = infoPckg().iStatus | KWimAuthObjectBlocked; |
|
225 } |
|
226 else if( iDisablePINBlocked ) |
|
227 { |
|
228 infoPckg().iStatus = flags & KPINStatusMask; |
|
229 infoPckg().iStatus = infoPckg().iStatus | KWimAuthObjectBlocked; |
|
230 } |
|
231 else |
|
232 { |
|
233 infoPckg().iStatus = flags & KPINStatusMask; |
|
234 } |
|
235 |
|
236 infoPckg().iPinNumber = pinNumber; |
|
237 infoPckg().iLabel = label; |
|
238 |
|
239 TInt writeErr = aMessage.Write( 1, infoPckg ); |
|
240 |
|
241 free_WIMI_Ref_t( cmeWimRef ); |
|
242 WSL_OS_Free( ptLabel.pb_buf ); |
|
243 // Code can leave after this point. |
|
244 User::LeaveIfError( writeErr ); |
|
245 } |
|
246 } |
|
247 else |
|
248 { |
|
249 status = WIMI_ERR_BadParameters; |
|
250 } |
|
251 aMessage.Complete( CWimUtilityFuncs::MapWIMError( status ) ); |
|
252 } |
|
253 |
|
254 // ----------------------------------------------------------------------------- |
|
255 // CWimAuthObjHandler::GetPINsInfoL |
|
256 // Get detailed information about the all of the PINs on a certain SecMod. |
|
257 // ----------------------------------------------------------------------------- |
|
258 // |
|
259 void CWimAuthObjHandler::GetPINsInfoL( const RMessage2& aMessage ) |
|
260 { |
|
261 //Get pin number and reflist |
|
262 _WIMTRACE(_L("WIM | WIMServer | CWimAuthObjHandler::GetPINsInfoL | Begin")); |
|
263 WIMI_Ref_pt pWimStruct = const_cast<WIMI_Ref_pt>( aMessage.Ptr0() ); |
|
264 |
|
265 TUint16 pinNum; |
|
266 WIMI_RefList_t refList; |
|
267 WIMI_STAT status = WIMI_Ok; |
|
268 |
|
269 status = WIMI_GetPINList( pWimStruct, &pinNum, &refList ); |
|
270 CleanupPushWimRefListL( refList ); |
|
271 |
|
272 CArrayFixFlat<TWimPinStruct>* pinsInfo = new( ELeave ) CArrayFixFlat<TWimPinStruct>( pinNum ); |
|
273 CleanupStack::PushL( pinsInfo ); |
|
274 |
|
275 RArray<WIMI_Ref_pt> pinRefsArray; |
|
276 CleanupClosePushL( pinRefsArray ); |
|
277 |
|
278 if( status == WIMI_Ok ) |
|
279 { |
|
280 if( pinNum != aMessage.Int2() ) |
|
281 { |
|
282 status = WIMI_ERR_Internal; |
|
283 CleanupStack::PopAndDestroy( 3, refList ); // pinRefsArray, pinsInfo, refList |
|
284 aMessage.Complete( CWimUtilityFuncs::MapWIMError( status ) ); |
|
285 return; |
|
286 } |
|
287 for ( TUint8 index = 0; index < pinNum; index++ ) |
|
288 { |
|
289 pinRefsArray.Append( refList[index] ); |
|
290 } |
|
291 } |
|
292 else |
|
293 { |
|
294 CleanupStack::PopAndDestroy( 3, refList ); // pinRefsArray, pinsInfo, refList |
|
295 aMessage.Complete( CWimUtilityFuncs::MapWIMError( status ) ); |
|
296 return; |
|
297 } |
|
298 |
|
299 //Get pin details bt pin reference |
|
300 for ( TUint8 index = 0; index < pinNum; index++ ) |
|
301 { |
|
302 WIMI_Ref_pt pPinStruct = pinRefsArray[ index ]; |
|
303 |
|
304 __ASSERT_ALWAYS( pPinStruct, User::Leave( KErrArgument ) ); |
|
305 |
|
306 TUint8 flags; |
|
307 TUint8 minLength; |
|
308 TUint8 pinNumber = 0; |
|
309 WIMI_BinData_t ptLabel; |
|
310 WIMI_STAT status = WIMI_Ok; |
|
311 |
|
312 TRequestStatus status1; |
|
313 |
|
314 iPinValue.Zero(); |
|
315 |
|
316 CWimCallBack::SetSignTextRequestStatus( &status1 ); |
|
317 |
|
318 status = WIMI_VerifyPINReq( NULL,pPinStruct, |
|
319 ( TUint8 )iPinValue.Length(), |
|
320 ( TUint8* )iPinValue.Ptr() ); |
|
321 |
|
322 _WIMTRACE2(_L("WIM | WIMServer | CWimAuthObjHandler::GetPINsInfoL status %d "), status ); |
|
323 |
|
324 if ( status != WIMI_Ok ) |
|
325 { |
|
326 CleanupStack::PopAndDestroy( 3, refList ); // pinRefsArray, pinsInfo, refList |
|
327 aMessage.Complete( CWimUtilityFuncs::MapWIMError( status ) ); |
|
328 return; |
|
329 } |
|
330 |
|
331 User::WaitForRequest( status1 ); |
|
332 |
|
333 CWimCallBack::SetSignTextRequestStatus( NULL ); |
|
334 |
|
335 WIMI_Ref_t* cmeWimRef = NULL; |
|
336 |
|
337 status = WIMI_GetPINStatus( pPinStruct, |
|
338 &cmeWimRef, |
|
339 &flags, |
|
340 &minLength, |
|
341 &pinNumber, |
|
342 &ptLabel ); |
|
343 |
|
344 if ( status == WIMI_Ok ) |
|
345 { |
|
346 free_WIMI_Ref_t( cmeWimRef ); |
|
347 CleanupPushWimBufL( ptLabel ); |
|
348 |
|
349 TWimPinStruct pinStruct; |
|
350 pinStruct.iLabel.Copy( TPtr8( ptLabel.pb_buf, |
|
351 ptLabel.ui_buf_length, |
|
352 ptLabel.ui_buf_length ) ); |
|
353 CleanupStack::PopAndDestroy( ptLabel.pb_buf ); |
|
354 |
|
355 // Possible values of iStatus are: |
|
356 // EEnabled = 0x80, |
|
357 // EChangeDisabled = 0x40, |
|
358 // EUnblockDisabled = 0x20, |
|
359 // EDisableAllowed = 0x10, |
|
360 |
|
361 if( status1.Int() == KErrLocked ) |
|
362 { |
|
363 pinStruct.iStatus = flags & KPINStatusMask; |
|
364 pinStruct.iStatus = pinStruct.iStatus | KWimAuthObjectBlocked; |
|
365 } |
|
366 else if( iDisablePINBlocked ) |
|
367 { |
|
368 pinStruct.iStatus = flags & KPINStatusMask; |
|
369 pinStruct.iStatus = pinStruct.iStatus | KWimAuthObjectBlocked; |
|
370 } |
|
371 else |
|
372 { |
|
373 pinStruct.iStatus = flags & KPINStatusMask; |
|
374 } |
|
375 pinStruct.iPinNumber = pinNumber; |
|
376 |
|
377 pinsInfo->AppendL( pinStruct ); |
|
378 } |
|
379 else |
|
380 { |
|
381 status = WIMI_ERR_BadParameters; |
|
382 break; |
|
383 } |
|
384 } |
|
385 |
|
386 TInt16 length = ( TInt16 )pinsInfo->Count()*( sizeof( TWimPinStruct ) ); |
|
387 |
|
388 TPtrC8 pinInfoPtr; |
|
389 |
|
390 pinInfoPtr.Set( (TText8*)&(*pinsInfo)[0], length ); |
|
391 |
|
392 if( status == WIMI_Ok ) |
|
393 { |
|
394 aMessage.WriteL( 1, pinInfoPtr ); |
|
395 } |
|
396 |
|
397 CleanupStack::PopAndDestroy( 3, refList ); // pinRefsArray, pinsInfo, refList |
|
398 |
|
399 aMessage.Complete( CWimUtilityFuncs::MapWIMError( status ) ); |
|
400 } |
|
401 |
|
402 // ----------------------------------------------------------------------------- |
|
403 // CWimAuthObjHandler::VerifyDisabledPINRequestL |
|
404 // Verifies Disabled PIN number. |
|
405 // ----------------------------------------------------------------------------- |
|
406 // |
|
407 void CWimAuthObjHandler::VerifyDisabledPINRequestL( |
|
408 const RMessage2& aMessage ) |
|
409 { |
|
410 __ASSERT_DEBUG( iResponseID == NULL, User::Panic( KWimAuthObjPanic, KErrGeneral ) ); |
|
411 iResponseID = new ( ELeave )CWimResponse( aMessage ); |
|
412 iResponseID->iOpcode = EVerifyDisabledPinReq; |
|
413 |
|
414 if( iDisablePINBlocked ) |
|
415 { |
|
416 iResponseID->iStatus = WIMI_ERR_PINBlocked; |
|
417 iResponseID->CompleteMsgAndDelete(); |
|
418 iResponseID = NULL; |
|
419 } |
|
420 else |
|
421 { |
|
422 iResponseID->iStatus = WIMI_Ok; |
|
423 iResponseID->CompleteMsgAndDelete(); |
|
424 iResponseID = NULL; |
|
425 } |
|
426 } |
|
427 |
|
428 // ----------------------------------------------------------------------------- |
|
429 // CWimAuthObjHandler::VerifyPINRequestL |
|
430 // Verifies PIN number. |
|
431 // ----------------------------------------------------------------------------- |
|
432 // |
|
433 void CWimAuthObjHandler::VerifyPINRequestL( |
|
434 const RMessage2& aMessage, |
|
435 TBool aShowDialog ) |
|
436 { |
|
437 _WIMTRACE(_L("WIM|WIMServer|CWimAuthObjHandler::VerifyPINRequestL|Begin")); |
|
438 |
|
439 __ASSERT_DEBUG( iResponseID == NULL, User::Panic( KWimAuthObjPanic, KErrGeneral ) ); |
|
440 iResponseID = new ( ELeave )CWimResponse( aMessage ); |
|
441 iResponseID->iOpcode = EVerifyPinReq; |
|
442 |
|
443 __ASSERT_DEBUG( iTrId == NULL, User::Panic( KWimAuthObjPanic, KErrGeneral ) ); |
|
444 iTrId = iWimUtilFuncs->TrIdLC( iResponseID, EWimMgmtReq ); |
|
445 CleanupStack::Pop( iTrId ); |
|
446 |
|
447 iShowDialog = aShowDialog; |
|
448 |
|
449 if ( aShowDialog ) // Ask PIN from user |
|
450 { |
|
451 _WIMTRACE(_L("WIM|WIMServer|CWimAuthObjHandler::Verify|Show dialog")); |
|
452 TPckgBuf<TPINParams> infoPckg; |
|
453 aMessage.ReadL( 1, infoPckg ); |
|
454 _WIMTRACE(_L("WIM|WIMServer|CWimAuthObjHandler::Verify|PINParamas read")); |
|
455 |
|
456 iPinParams.iPINLabel = infoPckg().iPINLabel; |
|
457 iPinParams.iTokenLabel = infoPckg().iTokenLabel; |
|
458 iPinParams.iMinLength = infoPckg().iMinLength; |
|
459 iPinParams.iMaxLength = infoPckg().iMaxLength; |
|
460 |
|
461 _WIMTRACE(_L("WIM|WIMServer|CWimAuthObjHandler::Verify|Call dialog")); |
|
462 |
|
463 iRetry = EFalse; |
|
464 |
|
465 VerifyPINAskPIN(); |
|
466 |
|
467 } |
|
468 else // Do not ask PIN from user, just try if PIN is blocked with empty PIN |
|
469 { |
|
470 iRequest = EVerifyPINAskPIN; |
|
471 iStatus = KRequestPending; |
|
472 SetActive(); |
|
473 iPinValue.Zero(); |
|
474 TRequestStatus* status = &iStatus; |
|
475 User::RequestComplete( status, KErrNone ); |
|
476 } |
|
477 } |
|
478 |
|
479 // ----------------------------------------------------------------------------- |
|
480 // CWimAuthObjHandler::VerifyPINAskPIN |
|
481 // |
|
482 // ----------------------------------------------------------------------------- |
|
483 // |
|
484 void CWimAuthObjHandler::VerifyPINAskPIN() |
|
485 { |
|
486 iRequest = EVerifyPINAskPIN; |
|
487 iStatus = KRequestPending; |
|
488 SetActive(); |
|
489 iWimSecDlg->EnterPIN( iRetry, |
|
490 iPinParams, |
|
491 iPinValue, |
|
492 iStatus ); |
|
493 } |
|
494 |
|
495 // ----------------------------------------------------------------------------- |
|
496 // CWimAuthObjHandler::ContinueVerifyPINReqL |
|
497 // Continue verify PIN request. Calls WIMI. |
|
498 // ----------------------------------------------------------------------------- |
|
499 // |
|
500 void CWimAuthObjHandler::ContinueVerifyPINReqL( ) |
|
501 { |
|
502 __ASSERT_DEBUG( iResponseID, User::Panic( KWimAuthObjPanic, KErrGeneral ) ); |
|
503 WIMI_Ref_pt pPINref = const_cast<WIMI_Ref_pt>( (iResponseID->iMessage).Ptr0() ); |
|
504 |
|
505 HBufC8* pinBuf = HBufC8::NewLC( iPinValue.Length() ); |
|
506 TPtr8 pinPtr = pinBuf->Des(); |
|
507 pinPtr.Copy( iPinValue ); |
|
508 |
|
509 if ( iShowDialog ) |
|
510 { |
|
511 iStatus = KRequestPending; |
|
512 TRequestStatus* status = &iStatus; |
|
513 |
|
514 iRequest = EVerifyPINCallBackResponse; |
|
515 SetActive(); |
|
516 |
|
517 iResponseID->iStatus = WIMI_VerifyPINReq( iTrId, |
|
518 pPINref, |
|
519 ( TUint8 )pinPtr.Length(), |
|
520 ( TUint8* )pinPtr.Ptr() ); |
|
521 |
|
522 if ( iResponseID->iStatus != WIMI_Ok ) |
|
523 { |
|
524 iRequest = EWIMIError; |
|
525 User::RequestComplete( status, iResponseID->iStatus ); |
|
526 } |
|
527 } |
|
528 else |
|
529 { |
|
530 iResponseID->iStatus = WIMI_VerifyPINReq( iTrId, |
|
531 pPINref, |
|
532 ( TUint8 )pinPtr.Length(), |
|
533 ( TUint8* )pinPtr.Ptr() ); |
|
534 |
|
535 if ( iResponseID->iStatus != WIMI_Ok ) |
|
536 { |
|
537 iResponseID->CompleteMsgAndDelete(); |
|
538 iResponseID = NULL; |
|
539 delete iTrId; |
|
540 iTrId = NULL; |
|
541 } |
|
542 } |
|
543 |
|
544 CleanupStack::PopAndDestroy( pinBuf ); |
|
545 } |
|
546 |
|
547 // ----------------------------------------------------------------------------- |
|
548 // CWimAuthObjHandler::CancelVerifyPin |
|
549 // Cancel verify Pin operation |
|
550 // ----------------------------------------------------------------------------- |
|
551 // |
|
552 void CWimAuthObjHandler::CancelVerifyPin( const RMessage2& aMessage ) |
|
553 { |
|
554 if( IsActive() ) |
|
555 { |
|
556 Cancel(); |
|
557 } |
|
558 |
|
559 aMessage.Complete( KErrNone ); |
|
560 } |
|
561 |
|
562 // ----------------------------------------------------------------------------- |
|
563 // CWimAuthObjHandler::EnablePINReqL |
|
564 // Enables/disables PIN query. |
|
565 // ----------------------------------------------------------------------------- |
|
566 // |
|
567 void CWimAuthObjHandler::EnablePINReqL( const RMessage2& aMessage ) |
|
568 { |
|
569 _WIMTRACE(_L("WIM|WIMServer|CWimAuthObjHandler::EnablePINReqL|Begin")); |
|
570 |
|
571 __ASSERT_DEBUG( iResponseID == NULL, User::Panic( KWimAuthObjPanic, KErrGeneral ) ); |
|
572 iResponseID = new( ELeave )CWimResponse( aMessage ); |
|
573 iResponseID->iOpcode =EEnablePINReq; |
|
574 |
|
575 __ASSERT_DEBUG( iTrId == NULL, User::Panic( KWimAuthObjPanic, KErrGeneral ) ); |
|
576 iTrId = iWimUtilFuncs->TrIdLC( iResponseID, EWimMgmtReq ); |
|
577 CleanupStack::Pop( iTrId ); |
|
578 |
|
579 TPckgBuf<TPINStateRequest> statePckg; |
|
580 aMessage.ReadL( 1, statePckg ); |
|
581 |
|
582 TPckgBuf<TPINParams> infoPckg; |
|
583 aMessage.ReadL( 2, infoPckg ); |
|
584 |
|
585 iPinParams.iPINLabel = infoPckg().iPINLabel; |
|
586 iPinParams.iTokenLabel = infoPckg().iTokenLabel; |
|
587 iPinParams.iMinLength = infoPckg().iMinLength; |
|
588 iPinParams.iMaxLength = infoPckg().iMaxLength; |
|
589 |
|
590 iEnablePinQuery = statePckg().iEnable; |
|
591 |
|
592 iRetry = EFalse; |
|
593 |
|
594 EnablePINAskPIN(); |
|
595 |
|
596 } |
|
597 |
|
598 void CWimAuthObjHandler::EnablePINAskPIN() |
|
599 { |
|
600 if ( iEnablePinQuery ) |
|
601 { |
|
602 iRequest = EEnablePINAskPIN; |
|
603 } |
|
604 else |
|
605 { |
|
606 iRequest = EDisablePINAskPIN; |
|
607 } |
|
608 |
|
609 iStatus = KRequestPending; |
|
610 SetActive(); |
|
611 // Query PIN code from the user by using security dialog |
|
612 iWimSecDlg->EnablePIN( iEnablePinQuery, |
|
613 iRetry, |
|
614 iPinParams, |
|
615 iPinValue, |
|
616 iStatus ); |
|
617 } |
|
618 |
|
619 // ----------------------------------------------------------------------------- |
|
620 // CWimAuthObjHandler::ContinueEnablePINReqL |
|
621 // Continue enable/disable PIN query request. Calls WIMI. |
|
622 // ----------------------------------------------------------------------------- |
|
623 // |
|
624 void CWimAuthObjHandler::ContinueEnablePINReqL() |
|
625 { |
|
626 __ASSERT_DEBUG( iResponseID, User::Panic( KWimAuthObjPanic, KErrGeneral ) ); |
|
627 WIMI_Ref_pt pPINref = const_cast<WIMI_Ref_pt>( (iResponseID->iMessage).Ptr0() ); |
|
628 |
|
629 HBufC8* pinBuf = HBufC8::NewLC( iPinValue.Length() ); |
|
630 TPtr8 pinPtr = pinBuf->Des(); |
|
631 pinPtr.Copy( iPinValue ); |
|
632 |
|
633 iStatus = KRequestPending; |
|
634 TRequestStatus* status = &iStatus; |
|
635 |
|
636 if ( iEnablePinQuery ) |
|
637 { |
|
638 iRequest = EEnablePINCallBackResponse; |
|
639 } |
|
640 else |
|
641 { |
|
642 iRequest = EDisablePINCallBackResponse; |
|
643 } |
|
644 SetActive(); |
|
645 |
|
646 iResponseID->iStatus = WIMI_EnablePINReq( iTrId, |
|
647 pPINref, |
|
648 ( TUint8 )pinPtr.Length(), |
|
649 ( TUint8* )pinPtr.Ptr(), |
|
650 iEnablePinQuery ); |
|
651 |
|
652 if ( iResponseID->iStatus != WIMI_Ok ) |
|
653 { |
|
654 iRequest = EWIMIError; |
|
655 User::RequestComplete( status, iResponseID->iStatus ); |
|
656 } |
|
657 CleanupStack::PopAndDestroy( pinBuf ); |
|
658 } |
|
659 |
|
660 // ----------------------------------------------------------------------------- |
|
661 // CWimAuthObjHandler::CancelEnablePinL |
|
662 // Cancel enable Pin operation |
|
663 // ----------------------------------------------------------------------------- |
|
664 // |
|
665 void CWimAuthObjHandler::CancelEnablePin( const RMessage2& aMessage ) |
|
666 { |
|
667 if( IsActive() ) |
|
668 { |
|
669 Cancel(); |
|
670 } |
|
671 |
|
672 aMessage.Complete( KErrNone ); |
|
673 } |
|
674 |
|
675 // ----------------------------------------------------------------------------- |
|
676 // CWimAuthObjHandler::ChangePINRequestL |
|
677 // Changes a PIN number. |
|
678 // ----------------------------------------------------------------------------- |
|
679 // |
|
680 void CWimAuthObjHandler::ChangePINRequestL( const RMessage2& aMessage ) |
|
681 { |
|
682 _WIMTRACE(_L("WIM | WIMServer | CWimAuthObjHandler::ChangePINRequestL | Begin")); |
|
683 |
|
684 __ASSERT_DEBUG( iResponseID == NULL, User::Panic( KWimAuthObjPanic, KErrGeneral ) ); |
|
685 iResponseID = new ( ELeave ) CWimResponse( aMessage ); |
|
686 iResponseID->iOpcode = EChangePINReq; |
|
687 |
|
688 __ASSERT_DEBUG( iTrId == NULL, User::Panic( KWimAuthObjPanic, KErrGeneral ) ); |
|
689 iTrId = iWimUtilFuncs->TrIdLC( iResponseID, EWimMgmtReq ); |
|
690 CleanupStack::Pop( iTrId ); |
|
691 |
|
692 TPckgBuf<TPINParams> infoPckg; |
|
693 aMessage.ReadL( 1, infoPckg ); |
|
694 |
|
695 iPinParams.iPINLabel = infoPckg().iPINLabel; |
|
696 iPinParams.iTokenLabel = infoPckg().iTokenLabel; |
|
697 iPinParams.iMinLength = infoPckg().iMinLength; |
|
698 iPinParams.iMaxLength = infoPckg().iMaxLength; |
|
699 |
|
700 iRetry = EFalse; |
|
701 |
|
702 ChangePINAskPIN(); |
|
703 } |
|
704 |
|
705 // ----------------------------------------------------------------------------- |
|
706 // CWimAuthObjHandler::ChangePINAskPIN |
|
707 // |
|
708 // ----------------------------------------------------------------------------- |
|
709 // |
|
710 void CWimAuthObjHandler::ChangePINAskPIN() |
|
711 { |
|
712 iRequest = EChangePINAskPIN; |
|
713 iStatus = KRequestPending; |
|
714 SetActive(); |
|
715 // Query PIN code from the user by using security dialog |
|
716 iWimSecDlg->ChangePINValue( iRetry, |
|
717 iPinParams, |
|
718 iOldPinValue, |
|
719 iNewPinValue, |
|
720 iStatus ); |
|
721 } |
|
722 |
|
723 // ----------------------------------------------------------------------------- |
|
724 // CWimAuthObjHandler::ContinueChangePINReqL |
|
725 // Continue change PIN request. Calls WIMI. |
|
726 // ----------------------------------------------------------------------------- |
|
727 // |
|
728 void CWimAuthObjHandler::ContinueChangePINReqL() |
|
729 { |
|
730 __ASSERT_DEBUG( iResponseID, User::Panic( KWimAuthObjPanic, KErrGeneral ) ); |
|
731 WIMI_Ref_pt pPINref = const_cast<WIMI_Ref_pt>( (iResponseID->iMessage).Ptr0() ); |
|
732 |
|
733 HBufC8* pinOldBuf = HBufC8::NewLC( iOldPinValue.Length() ); |
|
734 HBufC8* pinNewBuf = HBufC8::NewLC( iNewPinValue.Length() ); |
|
735 |
|
736 TPtr8 oldPin = pinOldBuf->Des(); |
|
737 oldPin.Copy( iOldPinValue ); |
|
738 TPtr8 newPin = pinNewBuf->Des(); |
|
739 newPin.Copy( iNewPinValue ); |
|
740 |
|
741 iStatus = KRequestPending; |
|
742 TRequestStatus* status = &iStatus; |
|
743 iRequest = EChangePINCallBackResponse; |
|
744 SetActive(); |
|
745 |
|
746 iResponseID->iStatus = WIMI_ChangePINReq( iTrId, |
|
747 pPINref, |
|
748 ( TUint8 )oldPin.Length(), |
|
749 ( TUint8* )oldPin.Ptr() , |
|
750 ( TUint8 )newPin.Length(), |
|
751 ( TUint8* )newPin.Ptr() ); |
|
752 if ( iResponseID->iStatus != WIMI_Ok ) |
|
753 { |
|
754 iRequest = EWIMIError; |
|
755 User::RequestComplete( status, iResponseID->iStatus ); |
|
756 } |
|
757 CleanupStack::PopAndDestroy( 2, pinOldBuf ); // pinNewBuf, pinOldBuf |
|
758 } |
|
759 |
|
760 // ----------------------------------------------------------------------------- |
|
761 // CWimAuthObjHandler::CancelChangePin |
|
762 // Cancel change Pin operation |
|
763 // ----------------------------------------------------------------------------- |
|
764 // |
|
765 void CWimAuthObjHandler::CancelChangePin( const RMessage2& aMessage ) |
|
766 { |
|
767 if( IsActive() ) |
|
768 { |
|
769 Cancel(); |
|
770 } |
|
771 |
|
772 aMessage.Complete( KErrNone ); |
|
773 } |
|
774 |
|
775 // ----------------------------------------------------------------------------- |
|
776 // CWimAuthObjHandler::UnblockPinReqL |
|
777 // Unblocks blocked PIN. |
|
778 // ----------------------------------------------------------------------------- |
|
779 // |
|
780 void CWimAuthObjHandler::UnblockPinReqL( const RMessage2& aMessage ) |
|
781 { |
|
782 _WIMTRACE(_L("WIM | WIMServer | CWimAuthObjHandler::UnblockPinReqL | Begin")); |
|
783 |
|
784 __ASSERT_DEBUG( iResponseID == NULL, User::Panic( KWimAuthObjPanic, KErrGeneral ) ); |
|
785 iResponseID = new ( ELeave ) CWimResponse( aMessage ); |
|
786 iResponseID->iOpcode = EUnblockPinReq; |
|
787 |
|
788 __ASSERT_DEBUG( iTrId == NULL, User::Panic( KWimAuthObjPanic, KErrGeneral ) ); |
|
789 iTrId = iWimUtilFuncs->TrIdLC( iResponseID, EWimMgmtReq ); |
|
790 CleanupStack::Pop( iTrId ); |
|
791 |
|
792 TPckgBuf<TPINParams> blockedPINPckg; |
|
793 aMessage.ReadL( 1, blockedPINPckg ); |
|
794 |
|
795 iPinParams.iPINLabel = blockedPINPckg().iPINLabel; |
|
796 iPinParams.iTokenLabel = blockedPINPckg().iTokenLabel; |
|
797 iPinParams.iMinLength = blockedPINPckg().iMinLength; |
|
798 iPinParams.iMaxLength = blockedPINPckg().iMaxLength; |
|
799 |
|
800 iUnblockingPinParams.iPINLabel = KUnblockingPinLabel; |
|
801 iUnblockingPinParams.iTokenLabel = blockedPINPckg().iTokenLabel; |
|
802 iUnblockingPinParams.iMinLength = blockedPINPckg().iMinLength; |
|
803 iUnblockingPinParams.iMaxLength = KMaxPINLength; |
|
804 |
|
805 iRetry = EFalse; |
|
806 |
|
807 UnblockPINAskPIN(); |
|
808 } |
|
809 |
|
810 void CWimAuthObjHandler::UnblockPINAskPIN() |
|
811 { |
|
812 iRequest = EUnblockPINAskPIN; |
|
813 iStatus = KRequestPending; |
|
814 SetActive(); |
|
815 // Query PIN code from the user by using security dialog |
|
816 iWimSecDlg->UnblockPIN( iRetry, |
|
817 iPinParams, |
|
818 iUnblockingPinParams, |
|
819 iUnblockingPinValue, |
|
820 iNewPinValue, |
|
821 iStatus ); |
|
822 } |
|
823 |
|
824 // ----------------------------------------------------------------------------- |
|
825 // CWimAuthObjHandler::ContinueUnblockPinReqL |
|
826 // Continue Unblock PIN request. Calls WIMI. |
|
827 // ----------------------------------------------------------------------------- |
|
828 // |
|
829 void CWimAuthObjHandler::ContinueUnblockPinReqL() |
|
830 { |
|
831 __ASSERT_DEBUG( iResponseID, User::Panic( KWimAuthObjPanic, KErrGeneral ) ); |
|
832 WIMI_Ref_pt pPINref = const_cast< WIMI_Ref_pt>( (iResponseID->iMessage).Ptr0() ); |
|
833 |
|
834 if( iPinGRef == pPINref ) |
|
835 { |
|
836 iUnblockPING = ETrue; |
|
837 } |
|
838 else |
|
839 { |
|
840 iUnblockPING = EFalse; |
|
841 } |
|
842 |
|
843 HBufC8* unblockPinBuf = HBufC8::NewLC( iUnblockingPinValue.Length() ); |
|
844 HBufC8* newPinBuf = HBufC8::NewLC( iNewPinValue.Length() ); |
|
845 |
|
846 TPtr8 unblockingPin = unblockPinBuf->Des(); |
|
847 unblockingPin.Copy( iUnblockingPinValue ); |
|
848 |
|
849 TPtr8 newPin = newPinBuf->Des(); |
|
850 newPin.Copy( iNewPinValue ); |
|
851 |
|
852 iStatus = KRequestPending; |
|
853 TRequestStatus* status =&iStatus; |
|
854 iRequest = EUnblockPINCallBackResponse; |
|
855 SetActive(); |
|
856 |
|
857 iResponseID->iStatus = WIMI_UnblockPINReq( iTrId, |
|
858 pPINref, |
|
859 ( TUint8 )unblockingPin.Length(), |
|
860 ( TUint8* )unblockingPin.Ptr(), |
|
861 ( TUint8 )newPin.Length(), |
|
862 ( TUint8* )newPin.Ptr() ); |
|
863 |
|
864 if ( iResponseID->iStatus != WIMI_Ok ) |
|
865 { |
|
866 iRequest = EWIMIError; |
|
867 User::RequestComplete( status, iResponseID->iStatus ); |
|
868 } |
|
869 CleanupStack::PopAndDestroy( 2, unblockPinBuf ); // newPinBuf, unblockPinBuf |
|
870 |
|
871 } |
|
872 |
|
873 // ----------------------------------------------------------------------------- |
|
874 // CWimAuthObjHandler::CancelUnblockPinL |
|
875 // Cancel Unblock Pin operation |
|
876 // ----------------------------------------------------------------------------- |
|
877 // |
|
878 void CWimAuthObjHandler::CancelUnblockPin( const RMessage2& aMessage ) |
|
879 { |
|
880 if( IsActive() ) |
|
881 { |
|
882 Cancel(); |
|
883 } |
|
884 |
|
885 aMessage.Complete( KErrNone ); |
|
886 } |
|
887 |
|
888 // ----------------------------------------------------------------------------- |
|
889 // CWimAuthObjHandler::RunL |
|
890 // Continue authentication request after PIN is asked |
|
891 // ----------------------------------------------------------------------------- |
|
892 // |
|
893 void CWimAuthObjHandler::RunL() |
|
894 { |
|
895 _WIMTRACE3(_L("WIM|WIMServer|CWimAuthObjHandler::RunL|iRequest=%d, status=%d"), iRequest, iStatus.Int()); |
|
896 |
|
897 switch ( iRequest ) |
|
898 { |
|
899 // Verify PIN request |
|
900 case EVerifyPINAskPIN: |
|
901 { |
|
902 iRetry = ETrue; |
|
903 |
|
904 if( iStatus.Int() == KErrCancel ) |
|
905 { |
|
906 _WIMTRACE2(_L("WIM|WIMServer|CWimAuthObjHandler::RunL|User cancel %d "), iStatus.Int()); |
|
907 if( iResponseID ) |
|
908 { |
|
909 iResponseID->iStatus = WIMI_ERR_UserCancelled; |
|
910 iResponseID->CompleteMsgAndDelete(); |
|
911 iResponseID = NULL; |
|
912 } |
|
913 if( iTrId ) |
|
914 { |
|
915 delete iTrId; |
|
916 iTrId = NULL; |
|
917 } |
|
918 |
|
919 } |
|
920 else |
|
921 { |
|
922 if( iShowDialog ) |
|
923 { |
|
924 CWimCallBack::SetSignTextRequestStatus( &iStatus ); |
|
925 } |
|
926 ContinueVerifyPINReqL(); |
|
927 } |
|
928 break; |
|
929 } |
|
930 |
|
931 case EVerifyPINCallBackResponse: |
|
932 { |
|
933 CWimCallBack::SetSignTextRequestStatus( NULL ); |
|
934 if( iStatus.Int() == WIMI_ERR_BadPIN ) |
|
935 { |
|
936 VerifyPINAskPIN(); |
|
937 } |
|
938 else if ( iStatus.Int() == WIMI_ERR_PINBlocked ) |
|
939 { |
|
940 iRequest = EShowPINBlocked; |
|
941 iWimSecDlg->ShowPINBlocked( iPinParams, iStatus ); |
|
942 SetActive(); |
|
943 } |
|
944 else if ( iStatus.Int() == WIMI_ERR_CardIOError ) |
|
945 { |
|
946 iRequest = EShowCardIsRemoved; |
|
947 iStatus = KRequestPending; |
|
948 TRequestStatus* status = &iStatus; |
|
949 SetActive(); |
|
950 User::RequestComplete( status, KErrNone ); |
|
951 } |
|
952 else if ( iStatus.Int() == WIMI_ERR_UserCancelled ) |
|
953 { |
|
954 iStatus = KRequestPending; |
|
955 iRequest = EIdle; |
|
956 TRequestStatus* status = &iStatus; |
|
957 SetActive(); |
|
958 User::RequestComplete( status, KErrNone ); |
|
959 } |
|
960 else |
|
961 { |
|
962 iStatus = KRequestPending; |
|
963 iRequest = EIdle; |
|
964 TRequestStatus* status = &iStatus; |
|
965 SetActive(); |
|
966 User::RequestComplete( status, KErrNone ); |
|
967 } |
|
968 break; |
|
969 } |
|
970 |
|
971 // Change PIN request |
|
972 case EChangePINAskPIN: |
|
973 { |
|
974 iRetry = ETrue; |
|
975 if( iStatus.Int() == KErrCancel ) |
|
976 { |
|
977 if( iResponseID ) |
|
978 { |
|
979 iResponseID->iStatus = WIMI_ERR_UserCancelled; |
|
980 iResponseID->CompleteMsgAndDelete(); |
|
981 iResponseID = NULL; |
|
982 } |
|
983 if( iTrId ) |
|
984 { |
|
985 delete iTrId; |
|
986 iTrId = NULL; |
|
987 } |
|
988 } |
|
989 else |
|
990 { |
|
991 CWimCallBack::SetSignTextRequestStatus( &iStatus ); |
|
992 ContinueChangePINReqL(); |
|
993 } |
|
994 break; |
|
995 } |
|
996 |
|
997 case EChangePINCallBackResponse: |
|
998 { |
|
999 CWimCallBack::SetSignTextRequestStatus( NULL ); |
|
1000 if( iStatus.Int() == WIMI_ERR_BadPIN ) |
|
1001 { |
|
1002 ChangePINAskPIN(); |
|
1003 } |
|
1004 else if ( iStatus.Int() == WIMI_ERR_PINBlocked ) |
|
1005 { |
|
1006 iRequest = EShowPINBlocked; |
|
1007 iWimSecDlg->ShowPINBlocked( iPinParams, iStatus ); |
|
1008 SetActive(); |
|
1009 } |
|
1010 else if ( iStatus.Int() == WIMI_ERR_CardIOError ) |
|
1011 { |
|
1012 iRequest = EShowCardIsRemoved; |
|
1013 iStatus = KRequestPending; |
|
1014 TRequestStatus* status = &iStatus; |
|
1015 SetActive(); |
|
1016 User::RequestComplete( status, KErrNone ); |
|
1017 } |
|
1018 else if ( iStatus.Int() == WIMI_ERR_UserCancelled ) |
|
1019 { |
|
1020 iStatus = KRequestPending; |
|
1021 iRequest = EIdle; |
|
1022 TRequestStatus* status = &iStatus; |
|
1023 SetActive(); |
|
1024 User::RequestComplete( status, KErrNone ); |
|
1025 } |
|
1026 else |
|
1027 { |
|
1028 iStatus = KRequestPending; |
|
1029 iRequest = EIdle; |
|
1030 TRequestStatus* status = &iStatus; |
|
1031 SetActive(); |
|
1032 User::RequestComplete( status, KErrNone ); |
|
1033 } |
|
1034 break; |
|
1035 } |
|
1036 |
|
1037 // Enable/Disable PIN query request |
|
1038 case EEnablePINAskPIN: // Flow trough |
|
1039 case EDisablePINAskPIN: |
|
1040 { |
|
1041 iRetry = ETrue; |
|
1042 if( iStatus.Int() == KErrCancel ) |
|
1043 { |
|
1044 if( iResponseID ) |
|
1045 { |
|
1046 iResponseID->iStatus = WIMI_ERR_UserCancelled; |
|
1047 iResponseID->CompleteMsgAndDelete(); |
|
1048 iResponseID = NULL; |
|
1049 } |
|
1050 if( iTrId ) |
|
1051 { |
|
1052 delete iTrId; |
|
1053 iTrId = NULL; |
|
1054 } |
|
1055 } |
|
1056 else |
|
1057 { |
|
1058 CWimCallBack::SetSignTextRequestStatus( &iStatus ); |
|
1059 ContinueEnablePINReqL(); |
|
1060 } |
|
1061 break; |
|
1062 } |
|
1063 |
|
1064 case EEnablePINCallBackResponse: |
|
1065 case EDisablePINCallBackResponse: |
|
1066 { |
|
1067 CWimCallBack::SetSignTextRequestStatus( NULL ); |
|
1068 if( iStatus.Int() == WIMI_ERR_BadPIN ) |
|
1069 { |
|
1070 EnablePINAskPIN(); |
|
1071 } |
|
1072 else if ( iStatus.Int() == WIMI_ERR_PINBlocked ) |
|
1073 { |
|
1074 iRequest = EShowPINBlocked; |
|
1075 iWimSecDlg->ShowPINBlocked( iPinParams, iStatus ); |
|
1076 SetActive(); |
|
1077 if( iEnablePinQuery ) |
|
1078 { |
|
1079 iDisablePINBlocked = ETrue; |
|
1080 } |
|
1081 } |
|
1082 else if ( iStatus.Int() == WIMI_ERR_CardIOError ) |
|
1083 { |
|
1084 iRequest = EShowCardIsRemoved; |
|
1085 iStatus = KRequestPending; |
|
1086 TRequestStatus* status = &iStatus; |
|
1087 SetActive(); |
|
1088 User::RequestComplete( status, KErrNone ); |
|
1089 } |
|
1090 else if ( iStatus.Int() == WIMI_ERR_UserCancelled ) |
|
1091 { |
|
1092 iStatus = KRequestPending; |
|
1093 iRequest = EIdle; |
|
1094 TRequestStatus* status = &iStatus; |
|
1095 SetActive(); |
|
1096 User::RequestComplete( status, KErrNone ); |
|
1097 } |
|
1098 else |
|
1099 { |
|
1100 iStatus = KRequestPending; |
|
1101 iRequest = EIdle; |
|
1102 TRequestStatus* status = &iStatus; |
|
1103 SetActive(); |
|
1104 User::RequestComplete( status, KErrNone ); |
|
1105 } |
|
1106 break; |
|
1107 } |
|
1108 |
|
1109 // Unblock PIN request |
|
1110 case EUnblockPINAskPIN: |
|
1111 { |
|
1112 iRetry = ETrue; |
|
1113 if( iStatus.Int() == KErrCancel ) |
|
1114 { |
|
1115 if( iResponseID ) |
|
1116 { |
|
1117 iResponseID->iStatus = WIMI_ERR_UserCancelled; |
|
1118 iResponseID->CompleteMsgAndDelete(); |
|
1119 iResponseID = NULL; |
|
1120 } |
|
1121 if( iTrId ) |
|
1122 { |
|
1123 delete iTrId; |
|
1124 iTrId = NULL; |
|
1125 } |
|
1126 } |
|
1127 else |
|
1128 { |
|
1129 CWimCallBack::SetSignTextRequestStatus( &iStatus ); |
|
1130 ContinueUnblockPinReqL(); |
|
1131 } |
|
1132 break; |
|
1133 } |
|
1134 case EUnblockPINCallBackResponse: |
|
1135 { |
|
1136 CWimCallBack::SetSignTextRequestStatus( NULL ); |
|
1137 if( iStatus.Int() == WIMI_ERR_BadPIN ) |
|
1138 { |
|
1139 UnblockPINAskPIN(); |
|
1140 } |
|
1141 else if ( iStatus.Int() == WIMI_ERR_PINBlocked ) |
|
1142 { |
|
1143 iRequest = EShowPINBlocked; |
|
1144 iWimSecDlg->ShowPINTotalBlocked( iPinParams, iStatus ); |
|
1145 SetActive(); |
|
1146 } |
|
1147 else if ( iStatus.Int() == WIMI_ERR_CardIOError ) |
|
1148 { |
|
1149 iRequest = EShowCardIsRemoved; |
|
1150 iStatus = KRequestPending; |
|
1151 TRequestStatus* status = &iStatus; |
|
1152 SetActive(); |
|
1153 User::RequestComplete( status, KErrNone ); |
|
1154 } |
|
1155 else if ( iStatus.Int() == WIMI_ERR_UserCancelled ) |
|
1156 { |
|
1157 iStatus = KRequestPending; |
|
1158 iRequest = EIdle; |
|
1159 TRequestStatus* status = &iStatus; |
|
1160 SetActive(); |
|
1161 User::RequestComplete( status, KErrNone ); |
|
1162 } |
|
1163 else |
|
1164 { |
|
1165 iStatus = KRequestPending; |
|
1166 iRequest = EIdle; |
|
1167 TRequestStatus* status = &iStatus; |
|
1168 SetActive(); |
|
1169 User::RequestComplete( status, KErrNone ); |
|
1170 |
|
1171 if( iDisablePINBlocked && iUnblockPING ) |
|
1172 { |
|
1173 iDisablePINBlocked = EFalse; |
|
1174 } |
|
1175 } |
|
1176 break; |
|
1177 } |
|
1178 |
|
1179 case EShowPINBlocked: |
|
1180 { |
|
1181 if( iResponseID ) |
|
1182 { |
|
1183 iResponseID->iStatus = WIMI_ERR_PINBlocked; |
|
1184 iResponseID->CompleteMsgAndDelete(); |
|
1185 iResponseID = NULL; |
|
1186 } |
|
1187 if( iTrId ) |
|
1188 { |
|
1189 delete iTrId; |
|
1190 iTrId = NULL; |
|
1191 } |
|
1192 |
|
1193 iStatus = KRequestPending; |
|
1194 iRequest = EIdle; |
|
1195 TRequestStatus* status = &iStatus; |
|
1196 SetActive(); |
|
1197 User::RequestComplete( status, KErrNone ); |
|
1198 break; |
|
1199 } |
|
1200 |
|
1201 case EShowCardIsRemoved: |
|
1202 { |
|
1203 if( iResponseID ) |
|
1204 { |
|
1205 iResponseID->iStatus = WIMI_ERR_CardIOError; |
|
1206 iResponseID->CompleteMsgAndDelete(); |
|
1207 iResponseID = NULL; |
|
1208 } |
|
1209 if( iTrId ) |
|
1210 { |
|
1211 delete iTrId; |
|
1212 iTrId = NULL; |
|
1213 } |
|
1214 |
|
1215 iStatus = KRequestPending; |
|
1216 iRequest = EIdle; |
|
1217 TRequestStatus* status = &iStatus; |
|
1218 SetActive(); |
|
1219 User::RequestComplete( status, KErrNone ); |
|
1220 break; |
|
1221 } |
|
1222 |
|
1223 case EWIMIError: |
|
1224 { |
|
1225 CWimCallBack::SetSignTextRequestStatus( NULL ); |
|
1226 if( iResponseID ) |
|
1227 { |
|
1228 iResponseID->iStatus = ( TUint )iStatus.Int(); |
|
1229 iResponseID->CompleteMsgAndDelete(); |
|
1230 iResponseID = NULL; |
|
1231 } |
|
1232 if( iTrId ) |
|
1233 { |
|
1234 delete iTrId; |
|
1235 iTrId = NULL; |
|
1236 } |
|
1237 break; |
|
1238 } |
|
1239 |
|
1240 // Idle request, do nothing |
|
1241 case EIdle: |
|
1242 _WIMTRACE(_L("WIM|WIMServer|CWimAuthObjHandler::RunL|Idle")); |
|
1243 break; |
|
1244 |
|
1245 // Illegal request |
|
1246 default: |
|
1247 _WIMTRACE(_L("WIM|WIMServer|CWimAuthObjHandler::RunL|Unknown request")); |
|
1248 __ASSERT_DEBUG( EFalse, User::Panic( KWimAuthObjPanic, KErrNotSupported ) ); |
|
1249 break; |
|
1250 } |
|
1251 |
|
1252 } |
|
1253 |
|
1254 // ----------------------------------------------------------------------------- |
|
1255 // CWimAuthObjHandler::DoCancel |
|
1256 // Asynchronous request cancelled |
|
1257 // ----------------------------------------------------------------------------- |
|
1258 // |
|
1259 void CWimAuthObjHandler::DoCancel() |
|
1260 { |
|
1261 _WIMTRACE(_L("WIM|WIMServer|CWimAuthObjHandler::DoCancel")); |
|
1262 if( iRequest == EEnablePINCallBackResponse || |
|
1263 iRequest == EUnblockPINCallBackResponse || |
|
1264 iRequest == EDisablePINCallBackResponse || |
|
1265 iRequest == EChangePINCallBackResponse || |
|
1266 iRequest == EVerifyPINCallBackResponse ) |
|
1267 { |
|
1268 CWimCallBack::CancelPinOperation(); |
|
1269 } |
|
1270 if( iRequest == EEnablePINAskPIN || |
|
1271 iRequest == EUnblockPINAskPIN || |
|
1272 iRequest == EDisablePINAskPIN || |
|
1273 iRequest == EChangePINAskPIN || |
|
1274 iRequest == EVerifyPINAskPIN ) |
|
1275 { |
|
1276 iWimSecDlg->Cancel(); |
|
1277 } |
|
1278 } |
|
1279 |
|
1280 // ----------------------------------------------------------------------------- |
|
1281 // CWimAuthObjHandler::RunError |
|
1282 // RunL leaved, handle error here. Note that message is completed by |
|
1283 // CWimResponse that is deleted by CleanupStack when some function leaves. |
|
1284 // ----------------------------------------------------------------------------- |
|
1285 // |
|
1286 TInt CWimAuthObjHandler::RunError( TInt aError ) |
|
1287 { |
|
1288 _WIMTRACE(_L("WIM|WIMServer|CWimAuthObjHandler::RunError")); |
|
1289 CWimCallBack::SetSignTextRequestStatus( NULL ); |
|
1290 if( iResponseID ) |
|
1291 { |
|
1292 iResponseID->iStatus = ( TUint16 ) aError; |
|
1293 iResponseID->CompleteMsgAndDelete(); |
|
1294 iResponseID = NULL; |
|
1295 } |
|
1296 |
|
1297 if( iTrId ) |
|
1298 { |
|
1299 delete iTrId; |
|
1300 iTrId = NULL; |
|
1301 } |
|
1302 |
|
1303 return KErrNone; |
|
1304 } |
|
1305 |
|
1306 |
|
1307 // ----------------------------------------------------------------------------- |
|
1308 // CWimAuthObjHandler::RetrieveAuthObjectsInfo |
|
1309 // ----------------------------------------------------------------------------- |
|
1310 // |
|
1311 void CWimAuthObjHandler::RetrieveAuthObjectsInfo( const RMessage2& aMessage ) |
|
1312 { |
|
1313 //Get pin number and reflist |
|
1314 _WIMTRACE(_L("WIM | WIMServer | RetrieveAuthObjectsInfo() | start ")); |
|
1315 WIMI_Ref_t* wimRef = WIMI_GetWIMRef( 0 ); |
|
1316 |
|
1317 TInt count = aMessage.Int2(); |
|
1318 |
|
1319 TInt authIdLength = count * sizeof( TInt ); |
|
1320 TInt authobjLength = count* sizeof( TJavaPINParams ); |
|
1321 |
|
1322 RArray<TInt> authIdList( count ); |
|
1323 |
|
1324 TInt temp = 0; |
|
1325 for( TInt i = 0; i < count ; i++ ) |
|
1326 { |
|
1327 authIdList.Append(temp); |
|
1328 } |
|
1329 |
|
1330 RArray<TJavaPINParams> authobjsList( count ); |
|
1331 |
|
1332 TPtr8 authIdLstPtr( (TText8*)&authIdList[0], authIdLength, authIdLength ); |
|
1333 |
|
1334 TInt err = aMessage.Read(0, authIdLstPtr ); |
|
1335 if ( err!= KErrNone ) |
|
1336 { |
|
1337 aMessage.Complete( err ); |
|
1338 return; |
|
1339 } |
|
1340 |
|
1341 for ( TInt i = 0 ; i < authIdList.Count() ; i++ ) |
|
1342 { |
|
1343 TJavaPINParams authobject; |
|
1344 WIMI_STAT status = WIMI_Ok; |
|
1345 |
|
1346 TUint32 authId = authIdList[i]; |
|
1347 |
|
1348 WIMI_BinData_t ptLabel; |
|
1349 TUint16 flags; |
|
1350 TUint8 pinNumber = 0; |
|
1351 TUint8 minLength; |
|
1352 TUint8 maxLength; |
|
1353 TUint8 pinType; |
|
1354 TUint8 storedLength; |
|
1355 TUint8 PinReference; |
|
1356 TUint8 padChar; |
|
1357 |
|
1358 status = WIMI_GetAuthObjInfo( wimRef, |
|
1359 &authId, |
|
1360 &ptLabel, |
|
1361 &flags, |
|
1362 &pinNumber, |
|
1363 &minLength, |
|
1364 &maxLength, |
|
1365 &pinType, |
|
1366 &storedLength, |
|
1367 &PinReference, |
|
1368 &padChar ); |
|
1369 |
|
1370 if( status == WIMI_Ok ) |
|
1371 { |
|
1372 TBuf<KLabelLen> label; |
|
1373 label.Copy( TPtr8( ptLabel.pb_buf, |
|
1374 ptLabel.ui_buf_length, |
|
1375 ptLabel.ui_buf_length ) ); |
|
1376 |
|
1377 authobject.iPINLabel = label; |
|
1378 authobject.iFlags = flags; |
|
1379 authobject.iAuthId = authId; |
|
1380 authobject.iPinNumber =pinNumber; |
|
1381 authobject.iMinLength = minLength; |
|
1382 authobject.iMaxLength = maxLength; |
|
1383 authobject.iPinType = pinType; |
|
1384 authobject.iStoredLength = storedLength; |
|
1385 authobject.iPinReference = PinReference; |
|
1386 authobject.iPadChar = padChar; |
|
1387 |
|
1388 authobjsList.Append( authobject ); |
|
1389 } |
|
1390 else |
|
1391 { |
|
1392 _WIMTRACE2(_L("WIM | WIMServer | RetrieveAuthObjectsInfo() | WIMI_GetAuthObjInfo returns error %d"), status); |
|
1393 //information did not found or error occured so return empty authOjbect |
|
1394 TBuf<KLabelLen> label; |
|
1395 authobject.iPINLabel = label; |
|
1396 authobject.iFlags = KErrNotFound; |
|
1397 authobject.iPinNumber =KErrNotFound; |
|
1398 authobject.iMinLength = KErrNotFound; |
|
1399 authobject.iMaxLength = KErrNotFound; |
|
1400 authobject.iPinType = KErrNotFound; |
|
1401 authobject.iStoredLength = KErrNotFound; |
|
1402 authobject.iPinReference = KErrNotFound; |
|
1403 authobject.iPadChar = KErrNotFound; |
|
1404 authobjsList.Append( authobject ); |
|
1405 } |
|
1406 } |
|
1407 |
|
1408 TPtrC8 authObjsInfoLstPtr; |
|
1409 authObjsInfoLstPtr.Set( (TText8*)&authobjsList[0], authobjLength ); |
|
1410 |
|
1411 err = aMessage.Write( 1, authObjsInfoLstPtr ); |
|
1412 free_WIMI_Ref_t( wimRef ); |
|
1413 |
|
1414 aMessage.Complete( err ); |
|
1415 } |
|
1416 |
|
1417 // End of File |