|
1 /* |
|
2 * Copyright (c) 2000 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 terminalsecurity components |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <utf.h> |
|
21 #include <e32svr.h> |
|
22 #include <e32math.h> |
|
23 #include <gsmerror.h> |
|
24 |
|
25 #include "SCPServer.h" |
|
26 #include "SCPSession.h" |
|
27 |
|
28 #ifdef SCP_USE_POLICY_ENGINE |
|
29 #include <PolicyEngineClient.h> |
|
30 #include <PolicyEngineXACML.h> |
|
31 #include <RequestContext.h> |
|
32 #include "DMUtilObserver.h" |
|
33 #include "SCPParamDBController.h" |
|
34 #endif // SCP_USE_POLICY_ENGINE |
|
35 |
|
36 //#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
37 #include "SCPPluginManager.h" |
|
38 #include "SCPPluginEventHandler.h" |
|
39 #include <SCPParamObject.h> |
|
40 #include "SCP_IDs.h" |
|
41 // For Central Repository |
|
42 #include <centralrepository.h> |
|
43 #include "SCPCodePrivateCRKeys.h" |
|
44 #include "SCPLockCode.h" |
|
45 #include <TerminalControl3rdPartyAPI.h> |
|
46 //#endif // __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
47 |
|
48 #include <mmtsy_names.h> |
|
49 |
|
50 #include "SCPDebug.h" |
|
51 #include <featmgr.h> |
|
52 // For Device encryption |
|
53 #include <DevEncEngineConstants.h> |
|
54 #include <DevEncSession.h> |
|
55 |
|
56 // ==================== LOCAL FUNCTIONS ==================== |
|
57 |
|
58 // --------------------------------------------------------- |
|
59 // PanicServer Panics the server thread |
|
60 // |
|
61 // Status : Approved |
|
62 // --------------------------------------------------------- |
|
63 // |
|
64 GLDEF_C void PanicServer(TSCPServPanic aPanic) |
|
65 { |
|
66 _LIT( KTxtServerPanic,"SCP Server panic" ); |
|
67 User::Panic( KTxtServerPanic, aPanic ); |
|
68 } |
|
69 |
|
70 // ================= MEMBER FUNCTIONS ======================= |
|
71 |
|
72 // --------------------------------------------------------- |
|
73 // CSession2* CSCPServer::CSCPServer() |
|
74 // C++ default constructor |
|
75 // |
|
76 // Status : Approved |
|
77 // --------------------------------------------------------- |
|
78 // |
|
79 CSCPServer::CSCPServer(TInt aPriority) |
|
80 : CPolicyServer( aPriority, CSCPServerPolicy ), |
|
81 iConfiguration( &iRfs ), |
|
82 iALPeriodRep( NULL ), |
|
83 iShutdownTimer( NULL ), |
|
84 iOverrideForCleanup(EFalse) { |
|
85 Dprint( (_L("--> CSCPServer::CSCPServer()") )); |
|
86 |
|
87 Dprint( (_L("<-- CSCPServer::CSCPServer()") )); |
|
88 } |
|
89 |
|
90 |
|
91 |
|
92 // --------------------------------------------------------- |
|
93 // CSession2* CSCPServer::ConstructL() |
|
94 // Symbian 2nd phase constructor |
|
95 // |
|
96 // Status : Approved |
|
97 // --------------------------------------------------------- |
|
98 // |
|
99 void CSCPServer::ConstructL() |
|
100 { |
|
101 Dprint(_L("[CSCPServer]-> ConstructL() >>>")); |
|
102 |
|
103 TRAPD( errf, FeatureManager::InitializeLibL() ); |
|
104 if( errf != KErrNone ) |
|
105 { |
|
106 User::Leave(errf); |
|
107 } |
|
108 |
|
109 StartL( KSCPServerName ); |
|
110 |
|
111 User::LeaveIfError( iRfs.Connect() ); |
|
112 |
|
113 iConfiguration.Initialize(); |
|
114 |
|
115 // Assign default config flag |
|
116 iConfiguration.iConfigFlag = KSCPConfigUnknown; |
|
117 |
|
118 // Assign the default codes |
|
119 iConfiguration.iSecCode.Zero(); |
|
120 iConfiguration.iSecCode.Append( KSCPDefaultSecCode ); |
|
121 |
|
122 //#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
123 if(FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
124 { |
|
125 // Reset code block parameters |
|
126 iConfiguration.iFailedAttempts = 0; |
|
127 iConfiguration.iBlockedAtTime = KSCPNotBlocked; |
|
128 |
|
129 iPluginEventHandler = CSCPPluginEventHandler::NewL( &iRfs ); |
|
130 |
|
131 iPluginManager = CSCPPluginManager::NewL( this ); |
|
132 |
|
133 // Hash the default code |
|
134 TBuf<KSCPMaxHashLength> hashBuf; |
|
135 hashBuf.Zero(); |
|
136 |
|
137 HBufC* codeHBuf = HBufC::NewLC( KSCPPasscodeMaxLength + 1 ); |
|
138 TPtr codeBuf = codeHBuf->Des(); |
|
139 codeBuf.Zero(); |
|
140 |
|
141 codeBuf.Copy( KSCPDefaultEnchSecCode ); |
|
142 iPluginEventHandler->HashInput( codeBuf, hashBuf ); |
|
143 |
|
144 iConfiguration.iEnhSecCode.Zero(); |
|
145 iConfiguration.iEnhSecCode.Append( hashBuf ); |
|
146 |
|
147 CleanupStack::PopAndDestroy( codeHBuf ); |
|
148 } |
|
149 //#endif |
|
150 |
|
151 // Assign the default max timeout |
|
152 iConfiguration.iMaxTimeout = KSCPDefaultMaxTO; |
|
153 iConfiguration.iBlockedInOOS = 0; |
|
154 |
|
155 // Read the configuration, overwriting the default values |
|
156 TInt ret = KErrNone; |
|
157 TRAPD( err, ret = iConfiguration.ReadSetupL() ); |
|
158 if ( ( err != KErrNone ) || ( ret != KErrNone ) ) |
|
159 { |
|
160 Dprint( (_L("CSCPServer::ConstructL(): ERROR reading the \ |
|
161 configuration file: %d"), err )); |
|
162 } |
|
163 else |
|
164 { |
|
165 Dprint( (_L("CSCPServer::ConstructL(): Configration read OK") )); |
|
166 } |
|
167 |
|
168 Dprint( (_L("CSCPServer::ConstructL(): Connecting to CenRep") )); |
|
169 iALPeriodRep = CRepository::NewL( KCRUidSecuritySettings ); |
|
170 |
|
171 // Check for factory settings |
|
172 CheckIfRfsPerformedL(); |
|
173 Dprint(_L("[CSCPServer]-> ConstructL() <<< ")); |
|
174 } |
|
175 |
|
176 |
|
177 |
|
178 |
|
179 // --------------------------------------------------------- |
|
180 // CSession2* CSCPServer::NewL() |
|
181 // Static constructor. |
|
182 // |
|
183 // Status : Approved |
|
184 // --------------------------------------------------------- |
|
185 // |
|
186 CSCPServer* CSCPServer::NewL() |
|
187 { |
|
188 Dprint( (_L("--> CSCPServer::NewL()") )); |
|
189 |
|
190 CSCPServer *pS = new (ELeave) CSCPServer( EPriority ); |
|
191 |
|
192 CleanupStack::PushL( pS ); |
|
193 pS->ConstructL(); |
|
194 CleanupStack::Pop( pS ); |
|
195 |
|
196 Dprint( (_L("<-- CSCPServer::NewL()") )); |
|
197 return pS; |
|
198 } |
|
199 |
|
200 |
|
201 |
|
202 // --------------------------------------------------------- |
|
203 // CSession2* CSCPServer::~CSCPServer () |
|
204 // Destructor |
|
205 // |
|
206 // Status : Approved |
|
207 // --------------------------------------------------------- |
|
208 // |
|
209 CSCPServer::~CSCPServer() |
|
210 { |
|
211 Dprint( (_L("--> CSCPServer::~CSCPServer()") )); |
|
212 |
|
213 TRAPD( err, iConfiguration.WriteSetupL() ); |
|
214 if ( err != KErrNone ) |
|
215 { |
|
216 Dprint( (_L("CSCPServer::~CSCPServer(): ERROR writing the \ |
|
217 configuration file: %d"), err )); |
|
218 } |
|
219 |
|
220 delete iALPeriodRep; |
|
221 iALPeriodRep = NULL; |
|
222 |
|
223 //#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
224 if(FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
225 { |
|
226 |
|
227 delete iPluginManager; |
|
228 iPluginManager = NULL; |
|
229 |
|
230 delete iPluginEventHandler; |
|
231 iPluginEventHandler = NULL; |
|
232 } |
|
233 FeatureManager::UnInitializeLib(); |
|
234 //#endif // __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
235 |
|
236 if ( iPhone.SubSessionHandle() ) |
|
237 { |
|
238 iPhone.Close(); |
|
239 } |
|
240 |
|
241 if ( iTelServ.Handle() ) |
|
242 { |
|
243 iTelServ.Close(); |
|
244 } |
|
245 |
|
246 if ( iRfs.Handle() ) |
|
247 { |
|
248 iRfs.Close(); |
|
249 } |
|
250 |
|
251 Dprint( (_L("<-- CSCPServer::~CSCPServer()") )); |
|
252 } |
|
253 |
|
254 |
|
255 |
|
256 // --------------------------------------------------------- |
|
257 // CSession2* CSCPServer::NewSessionL (const TVersion &aVersion, const RMessage2& aMsg ) |
|
258 // Checks the version and creates a new session if it matches the server version. |
|
259 // |
|
260 // Status : Approved |
|
261 // --------------------------------------------------------- |
|
262 // |
|
263 CSession2* CSCPServer::NewSessionL (const TVersion &aVersion, |
|
264 const RMessage2& aMsg ) const |
|
265 { |
|
266 Dprint( (_L("--> CSCPServer::NewSessionL()") )); |
|
267 (void)aMsg; |
|
268 |
|
269 // Check we're the right version |
|
270 TVersion v( KSCPServMajorVersionNumber, KSCPServMinorVersionNumber, |
|
271 KSCPServBuildVersionNumber ); |
|
272 |
|
273 if ( !User::QueryVersionSupported(v, aVersion) ) |
|
274 User::Leave( KErrNotSupported ); |
|
275 |
|
276 Dprint( (_L("<-- CSCPServer::NewSessionL()") )); |
|
277 |
|
278 return CSCPSession::NewL( (CSCPServer&)( *this ) ); |
|
279 } |
|
280 |
|
281 |
|
282 |
|
283 // --------------------------------------------------------- |
|
284 // TInt CSCPServer::ThreadFunctionStage2() |
|
285 // Constructs the active scheduler and the server object, and |
|
286 // runs the server. |
|
287 // |
|
288 // Status : Approved |
|
289 // --------------------------------------------------------- |
|
290 // |
|
291 TInt CSCPServer::ThreadFunctionStage2L() |
|
292 { |
|
293 Dprint( (_L("--> CSCPServer::ThreadFunctionStage2()") )); |
|
294 |
|
295 // Naming the server thread after the server helps to debug panics |
|
296 User::LeaveIfError( User::RenameThread( KSCPServerName ) ); |
|
297 |
|
298 // Construct the active scheduler |
|
299 CActiveScheduler* activeScheduler = new (ELeave) CActiveScheduler; |
|
300 CleanupStack::PushL(activeScheduler); |
|
301 |
|
302 // Install active scheduler |
|
303 // We don't need to check whether an active scheduler is already installed |
|
304 // as this is a new thread, so there won't be one |
|
305 CActiveScheduler::Install( activeScheduler ); |
|
306 |
|
307 // Construct our server |
|
308 CSCPServer* server = CSCPServer::NewL(); |
|
309 CleanupStack::PushL( server ); |
|
310 |
|
311 RProcess::Rendezvous(KErrNone); |
|
312 |
|
313 // Start handling requests |
|
314 Dprint( (_L("CSCPServer: Server started") )); |
|
315 CActiveScheduler::Start(); |
|
316 |
|
317 CleanupStack::PopAndDestroy( server ); |
|
318 CleanupStack::PopAndDestroy( activeScheduler ); |
|
319 |
|
320 Dprint( (_L("<-- CSCPServer::ThreadFunctionStage2()") )); |
|
321 return KErrNone; |
|
322 } |
|
323 |
|
324 |
|
325 |
|
326 // --------------------------------------------------------- |
|
327 // TInt CSCPServer::ThreadFunction( TAny* ) |
|
328 // First-stage server entry point, creates the cleanup stack, |
|
329 // and calls the actual server worker function. |
|
330 // |
|
331 // Status : Approved |
|
332 // --------------------------------------------------------- |
|
333 // |
|
334 TInt CSCPServer::ThreadFunction(TAny* /*aNone*/) |
|
335 { |
|
336 Dprint( (_L("--> CSCPServer::ThreadFunction()") )); |
|
337 |
|
338 __UHEAP_MARK; |
|
339 |
|
340 CTrapCleanup* cleanupStack = CTrapCleanup::New(); |
|
341 if ( !cleanupStack ) |
|
342 { |
|
343 PanicServer( ECreateTrapCleanup ); |
|
344 } |
|
345 |
|
346 TRAPD( err, ThreadFunctionStage2L() ); |
|
347 if ( err != KErrNone ) |
|
348 { |
|
349 PanicServer( ESvrStartServer ); |
|
350 } |
|
351 |
|
352 delete cleanupStack; |
|
353 cleanupStack = NULL; |
|
354 |
|
355 __UHEAP_MARKEND; |
|
356 |
|
357 Dprint( (_L("<-- CSCPServer::ThreadFunction()") )); |
|
358 return KErrNone; |
|
359 } |
|
360 |
|
361 |
|
362 // --------------------------------------------------------- |
|
363 // void CSCPServer::GetEtelHandlesL() |
|
364 // Opens the handles to the Etel API, if not open, and copies |
|
365 // their addresses to the given pointers, if available. |
|
366 // |
|
367 // Status : Approved |
|
368 // --------------------------------------------------------- |
|
369 // |
|
370 void CSCPServer::GetEtelHandlesL( RTelServer** aTelServ, RMobilePhone** aPhone ) |
|
371 { |
|
372 if ( !iTelServ.Handle() ) |
|
373 { |
|
374 // Connect to Etel |
|
375 User::LeaveIfError( iTelServ.Connect() ); |
|
376 |
|
377 Dprint( (_L("CSCPServer::GetEtelHandlesL(): TelServ connected OK") )); |
|
378 } |
|
379 |
|
380 if ( !iPhone.SubSessionHandle() ) |
|
381 { |
|
382 // Load the phone module |
|
383 TInt err = iTelServ.LoadPhoneModule( KMmTsyModuleName ); |
|
384 if ( err != KErrAlreadyExists ) |
|
385 { |
|
386 User::LeaveIfError( err ); |
|
387 } |
|
388 Dprint( (_L("CSCPServer::GetEtelHandlesL(): LoadPhoneModule OK") )); |
|
389 |
|
390 // Open the multimode TSY |
|
391 User::LeaveIfError( iPhone.Open( iTelServ, KMmTsyPhoneName ) ); |
|
392 |
|
393 Dprint( (_L("CSCPServer::GetEtelHandlesL(): MM-Phone connected OK") )); |
|
394 } |
|
395 |
|
396 if ( aTelServ ) |
|
397 { |
|
398 *aTelServ = &iTelServ; |
|
399 } |
|
400 |
|
401 if ( aPhone ) |
|
402 { |
|
403 *aPhone = &iPhone; |
|
404 } |
|
405 } |
|
406 |
|
407 |
|
408 // --------------------------------------------------------- |
|
409 // TInt CSCPServer::GetCode( TDes& aCode ) |
|
410 // Writes the stored ISA code to aCode |
|
411 // |
|
412 // Status : Approved |
|
413 // --------------------------------------------------------- |
|
414 // |
|
415 TInt CSCPServer::GetCode( TDes& aCode ) |
|
416 { |
|
417 Dprint( (_L("--> CSCPServer::GetCode()") )); |
|
418 |
|
419 aCode.Zero(); |
|
420 aCode.Copy( iConfiguration.iSecCode ); |
|
421 |
|
422 Dprint( (_L("<-- CSCPServer::GetCode()") )); |
|
423 return KErrNone; |
|
424 } |
|
425 |
|
426 |
|
427 |
|
428 // --------------------------------------------------------- |
|
429 // TInt CSCPServer::StoreCode( TDes& aCode ) |
|
430 // Sets the stored ISA code to aCode and saves it to flash |
|
431 // |
|
432 // Status : Approved |
|
433 // --------------------------------------------------------- |
|
434 // |
|
435 TInt CSCPServer::StoreCode( TDes& aCode ) |
|
436 { |
|
437 Dprint( (_L("--> CSCPServer::StoreCode()") )); |
|
438 |
|
439 TInt ret = KErrNone; |
|
440 |
|
441 iConfiguration.iSecCode.Zero(); |
|
442 iConfiguration.iSecCode.Copy( aCode ); |
|
443 |
|
444 // Unset the invalid configuration flag |
|
445 iConfiguration.iConfigFlag = KSCPConfigOK; |
|
446 |
|
447 // The code has changed, write the new value instantly to flash |
|
448 TRAPD( err, iConfiguration.WriteSetupL() ); |
|
449 if ( err != KErrNone ) |
|
450 { |
|
451 Dprint( (_L("CSCPServer::~CSCPServer(): ERROR writing the configuration\ |
|
452 file: %d"), err )); |
|
453 ret = err; |
|
454 } |
|
455 |
|
456 Dprint( (_L("<-- CSCPServer::StoreCode(): %d"), ret )); |
|
457 |
|
458 return ret; |
|
459 } |
|
460 |
|
461 |
|
462 |
|
463 // --------------------------------------------------------- |
|
464 // CSCPServer::ChangeISACodeL() |
|
465 // Initializes the TSY and calls the function to change |
|
466 // the ISA-side code. Automatically uses the old code stored |
|
467 // on the server. |
|
468 // |
|
469 // Status : Approved |
|
470 // --------------------------------------------------------- |
|
471 // |
|
472 void CSCPServer::ChangeISACodeL( RMobilePhone::TMobilePassword& aNewPassword ) |
|
473 { |
|
474 Dprint( (_L("--> CSCPServer::ChangeISACodeL()") )); |
|
475 |
|
476 RMobilePhone::TMobilePassword oldPassword; |
|
477 TInt ret; |
|
478 |
|
479 // Check the given code |
|
480 if ( !IsValidISACode( aNewPassword ) ) |
|
481 { |
|
482 Dprint( (_L("CSCPServer::ChangeISACodeL(): ERROR:\ |
|
483 Invalid code format") )); |
|
484 User::Leave( KErrArgument ); |
|
485 } |
|
486 |
|
487 // No access to the ISA side in emulator |
|
488 GetEtelHandlesL(); |
|
489 |
|
490 // Fetch the stored ISA password from the server |
|
491 |
|
492 ret = GetCode( oldPassword ); |
|
493 if ( ret != KErrNone ) |
|
494 { |
|
495 Dprint( (_L("CSCPServer::ChangeISACodeL(): ERROR:\ |
|
496 Failed to get stored code") )); |
|
497 User::Leave( ret ); |
|
498 } |
|
499 |
|
500 TRequestStatus status = KErrNone; |
|
501 |
|
502 #ifndef __WINS__ |
|
503 // No access to the ISA side in emulator, for WINS the call always succeeds |
|
504 |
|
505 RMobilePhone::TMobilePhonePasswordChangeV1 changeInfo; |
|
506 changeInfo.iOldPassword = oldPassword; |
|
507 changeInfo.iNewPassword = aNewPassword; |
|
508 |
|
509 RMobilePhone::TMobilePhoneSecurityCode securityCode = |
|
510 RMobilePhone::ESecurityCodePhonePassword; |
|
511 |
|
512 Dprint( (_L("CSCPServer::ChangeISACodeL(): Trying to change\ |
|
513 the code, values %s, %s"), oldPassword.PtrZ(), aNewPassword.PtrZ() )); |
|
514 |
|
515 iPhone.ChangeSecurityCode(status, securityCode, changeInfo ); |
|
516 |
|
517 // This is a quick call, just wait here |
|
518 User::WaitForRequest( status ); |
|
519 |
|
520 #endif // WINS |
|
521 ret = status.Int(); |
|
522 |
|
523 if ( ret == KErrNone ) |
|
524 { |
|
525 Dprint( (_L("CSCPServer::ChangeISACodeL(): Code change OK") )); |
|
526 |
|
527 // Update the stored code in the server |
|
528 if ( StoreCode( aNewPassword ) != KErrNone ) |
|
529 { |
|
530 Dprint( (_L("CSCPServer::ChangeISACodeL():\ |
|
531 Failed to store the new code!") )); |
|
532 ret = KErrGeneral; |
|
533 } |
|
534 } |
|
535 else |
|
536 { |
|
537 Dprint( (_L("CSCPServer::ChangeISACodeL(): FAILED:\ |
|
538 ChangeSecurityCode returned %d"), ret )); |
|
539 } |
|
540 |
|
541 User::LeaveIfError( ret ); |
|
542 Dprint( (_L("<-- CSCPServer::ChangeISACodeL()") )); |
|
543 } |
|
544 |
|
545 |
|
546 |
|
547 // --------------------------------------------------------- |
|
548 // TInt CSCPServer::CheckIfRfsPerformedL() |
|
549 // Checks if RFS has been run from the DMUtil server. |
|
550 // |
|
551 // Status : Approved |
|
552 // --------------------------------------------------------- |
|
553 // |
|
554 void CSCPServer::CheckIfRfsPerformedL() |
|
555 { |
|
556 Dprint( (_L("--> CSCPServer::CheckIfRfsPerformedL()") )); |
|
557 |
|
558 TBool resetServer = EFalse; |
|
559 |
|
560 #ifdef SCP_USE_POLICY_ENGINE |
|
561 Dprint( (_L("--> CSCPServer::CheckIfRfsPerformedL() : checking if Rfs performed") )); |
|
562 TRAPD(err,TDMUtilPassiveObserver::IsRFSPerformedL()); |
|
563 if ( err == 1 ) |
|
564 { |
|
565 resetServer = ETrue; |
|
566 } |
|
567 else if ( err == 0) |
|
568 { |
|
569 Dprint( (_L("--> CSCPServer::CheckIfRfsPerformedL() : Rfs is not performed") )); |
|
570 } |
|
571 else |
|
572 { |
|
573 Dprint( (_L("--> CSCPServer::CheckIfRfsPerformedL() : Leave occured. Ignore it.") )); |
|
574 } |
|
575 #endif // SCP_USE_POLICY_ENGINE |
|
576 |
|
577 if ( resetServer ) |
|
578 { |
|
579 Dprint( (_L("CSCPServer::CheckIfRfsPerformedL(): Rfs performed, resetting parameters") )); |
|
580 |
|
581 // Reset max. period |
|
582 iConfiguration.iMaxTimeout = 0; |
|
583 |
|
584 //#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
585 if(FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
586 { |
|
587 // Reset the common plugin parameter storage |
|
588 TRAPD( err, iPluginEventHandler->ResetConfigurationL() ); |
|
589 if ( err != KErrNone ) |
|
590 { |
|
591 Dprint( (_L("CSCPServer::CheckIfRfsPerformedL(): ERROR resetting the plugin\ |
|
592 configuration: %d"), err )); |
|
593 } |
|
594 |
|
595 // Reset the plugin's private storage |
|
596 CSCPParamObject* inParams = CSCPParamObject::NewL(); |
|
597 CleanupStack::PushL( inParams ); |
|
598 |
|
599 inParams->Set( KSCPParamContext, KSCPContextRfs ); |
|
600 |
|
601 CSCPParamObject* reply = |
|
602 iPluginManager->PostEvent( KSCPEventReset, *inParams ); |
|
603 CleanupStack::PopAndDestroy( inParams ); |
|
604 |
|
605 // Ignore the reply, no plugin should request any actions |
|
606 if ( reply != NULL ) |
|
607 { |
|
608 delete reply; |
|
609 } |
|
610 } |
|
611 //#endif // __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
612 |
|
613 } |
|
614 |
|
615 Dprint( (_L("<-- CSCPServer::CheckIfRfsPerformedL()") )); |
|
616 } |
|
617 |
|
618 |
|
619 |
|
620 |
|
621 // --------------------------------------------------------- |
|
622 // void CSCPServer::ValidateConfigurationL() |
|
623 // Checks if the correct ISA code is stored on the server. |
|
624 // This method is used to counter the 3-button format function |
|
625 // available on some devices. |
|
626 // |
|
627 // Status : Approved |
|
628 // --------------------------------------------------------- |
|
629 // |
|
630 void CSCPServer::ValidateConfigurationL( TInt aMode ) |
|
631 { |
|
632 Dprint( (_L("--> CSCPServer::ValidateConfigurationL()") )); |
|
633 |
|
634 if ( iConfiguration.iConfigFlag == KSCPConfigOK ) |
|
635 { |
|
636 // The configuration has already been checked, exit |
|
637 Dprint( (_L("CSCPServer::ValidateConfigurationL(): Configuration is non-default.") )); |
|
638 User::Leave( KErrNone ); |
|
639 } |
|
640 else if ( aMode == KSCPInitial ) |
|
641 { |
|
642 // Return here, must be checked by complete mode |
|
643 User::Leave( KErrAccessDenied ); |
|
644 } |
|
645 |
|
646 RMobilePhone::TMobilePassword storedCode; |
|
647 storedCode.Zero(); |
|
648 |
|
649 User::LeaveIfError( GetCode( storedCode ) ); |
|
650 TInt hashedISAcode; |
|
651 TSCPSecCode hashedCode; |
|
652 //#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
653 if(FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
654 { |
|
655 /*TInt*/ hashedISAcode = HashISACode( iConfiguration.iEnhSecCode ); |
|
656 // TSCPSecCode hashedCode; |
|
657 hashedCode.Zero(); |
|
658 hashedCode.AppendNum( hashedISAcode ); |
|
659 } |
|
660 //#endif // __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
661 |
|
662 Dprint( (_L("CSCPServer::ValidateConfigurationL(): Checking code: %s"), storedCode.PtrZ() )); |
|
663 |
|
664 // Check that the ISA code is stored correctly |
|
665 TRAPD( err, CheckISACodeL( storedCode ) ); |
|
666 if ( err == KErrNone ) |
|
667 { |
|
668 iConfiguration.iConfigFlag = KSCPConfigOK; |
|
669 } |
|
670 else if ( err == KErrAccessDenied ) |
|
671 { |
|
672 iConfiguration.iConfigFlag = KSCPConfigInvalid; |
|
673 } |
|
674 else if ( err == KErrLocked ) |
|
675 { |
|
676 Dprint( (_L("CSCPServer::ValidateConfigurationL(): ISA code locked.") )); |
|
677 } |
|
678 else |
|
679 { |
|
680 Dprint( (_L("CSCPServer::ValidateConfigurationL(): ERROR in validation.") )); |
|
681 } |
|
682 |
|
683 //#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
684 if(FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
685 { |
|
686 if ( err == KErrNone ) |
|
687 { |
|
688 // Check that the codes are in-sync with each other. Especially the default ISA code must |
|
689 // be changed according to the default enhanced code. |
|
690 if ( storedCode.Compare( hashedCode ) != 0 ) |
|
691 { |
|
692 Dprint( (_L("CSCPServer::ValidateConfigurationL(): Correct ISA code stored.\ |
|
693 Changing ISA code to match enhanced code => %d"), hashedISAcode )); |
|
694 |
|
695 storedCode.Copy( hashedCode ); |
|
696 // Change the ISA code to match the hashed code |
|
697 ChangeISACodeL( storedCode ); |
|
698 } |
|
699 } |
|
700 else if ( ( err == KErrAccessDenied ) && ( storedCode.Compare( hashedCode ) != 0 ) ) |
|
701 { |
|
702 // Try again with the hashed code |
|
703 TRAP( err, CheckISACodeL( hashedCode ) ); |
|
704 |
|
705 if ( err == KErrNone ) |
|
706 { |
|
707 Dprint( (_L("CSCPServer::ValidateConfigurationL(): Hashed code is correct.\ |
|
708 Storing hashed code(%d)"), hashedISAcode )); |
|
709 |
|
710 if ( StoreCode( hashedCode ) == KErrNone ) |
|
711 { |
|
712 iConfiguration.iConfigFlag = KSCPConfigOK; |
|
713 } |
|
714 } |
|
715 } |
|
716 } |
|
717 //#endif // __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
718 |
|
719 TRAPD( err2, iConfiguration.WriteSetupL() ); |
|
720 if ( err2 != KErrNone ) |
|
721 { |
|
722 Dprint( (_L("CSCPServer::ValidateConfigurationL(): WARNING: failed to write configuration\ |
|
723 : %d"), err2 )); |
|
724 } |
|
725 |
|
726 User::LeaveIfError( err ); |
|
727 |
|
728 Dprint( (_L("<-- CSCPServer::ValidateConfigurationL()") )); |
|
729 } |
|
730 |
|
731 |
|
732 |
|
733 |
|
734 // --------------------------------------------------------- |
|
735 // void CSCPServer::CheckISACodeL( ) |
|
736 // Verifies the given ISA code. |
|
737 // |
|
738 // Status : Approved |
|
739 // --------------------------------------------------------- |
|
740 // |
|
741 void CSCPServer::CheckISACodeL( RMobilePhone::TMobilePassword aCode ) |
|
742 { |
|
743 TInt ret = KErrNone; |
|
744 |
|
745 #ifdef __WINS__ |
|
746 |
|
747 (void)aCode; |
|
748 |
|
749 #endif // __WINS__ |
|
750 |
|
751 RMobilePhone::TMobilePhoneSecurityCode secCodeType; |
|
752 secCodeType = RMobilePhone::ESecurityCodePhonePassword; |
|
753 |
|
754 RMobilePhone::TMobilePassword required_fourth; |
|
755 |
|
756 TRequestStatus status = KRequestPending; |
|
757 |
|
758 GetEtelHandlesL(); |
|
759 |
|
760 #ifndef __WINS__ // We cannot check the code in WINS, always return KErrNone. |
|
761 |
|
762 iPhone.VerifySecurityCode( status, secCodeType, aCode, required_fourth ); |
|
763 |
|
764 // This should be quick, wait here |
|
765 User::WaitForRequest( status ); |
|
766 |
|
767 ret = status.Int(); |
|
768 |
|
769 #endif // !__WINS__ |
|
770 |
|
771 if ( ret == KErrNone ) |
|
772 { |
|
773 // Code OK |
|
774 Dprint( (_L("CSCPServer::CheckISACodeL(): ISA code OK") )); |
|
775 iConfiguration.iBlockedInOOS = 0; |
|
776 } |
|
777 else |
|
778 { |
|
779 if ( ( ret == KErrAccessDenied ) || ( ret == KErrGsm0707IncorrectPassword ) ) |
|
780 { |
|
781 Dprint( (_L("CSCPServer::CheckISACodeL(): ISA code NOT OK") )); |
|
782 if (iConfiguration.iBlockedInOOS == 1) |
|
783 { |
|
784 iConfiguration.iBlockedInOOS = 0; |
|
785 Dprint( (_L("CSCPServer::CheckISACodeL():iBlockedInOOS = 0, KErrAccessDenied") )); |
|
786 } |
|
787 ret = KErrAccessDenied; |
|
788 } |
|
789 else if ( ( ret == KErrGsmSSPasswordAttemptsViolation ) || ( ret == KErrLocked ) ) |
|
790 { |
|
791 Dprint( (_L("CSCPServer::CheckISACodeL(): ISA code BLOCKED") )); |
|
792 if (ret==KErrGsmSSPasswordAttemptsViolation) |
|
793 { |
|
794 Dprint( (_L("CSCPServer::CheckISACodeL(): KErrGsmSSPasswordAttemptsViolation") )); |
|
795 } |
|
796 else |
|
797 { |
|
798 Dprint( (_L("CSCPServer::CheckISACodeL(): KErrLocked") )); |
|
799 } |
|
800 ret = KErrLocked; |
|
801 if (iConfiguration.iBlockedInOOS == 0) |
|
802 { |
|
803 iConfiguration.iBlockedInOOS = 1; |
|
804 Dprint( (_L("CSCPServer::CheckISACodeL():iBlockedInOOS = 1, KSCPErrCodeBlockStarted") )); |
|
805 ret = KSCPErrCodeBlockStarted; |
|
806 } |
|
807 } |
|
808 else |
|
809 { |
|
810 Dprint( (_L("CSCPServer::CheckISACodeL(): ERROR reply checking ISA code: %d"), |
|
811 status.Int() )); |
|
812 } |
|
813 } |
|
814 TRAPD( err, iConfiguration.WriteSetupL() ); |
|
815 if ( err != KErrNone ) |
|
816 { |
|
817 Dprint( (_L("CSCPServer::StoreEnhCode(): WARNING:\ |
|
818 failed to write configuration: %d"), err )); |
|
819 } |
|
820 |
|
821 User::LeaveIfError( ret ); |
|
822 } |
|
823 |
|
824 |
|
825 //#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
826 |
|
827 // --------------------------------------------------------- |
|
828 // CSCPServer::HashISACode() |
|
829 // Creates a 5-digit ISA code from the given MD5 digest. |
|
830 // |
|
831 // Status : Approved |
|
832 // --------------------------------------------------------- |
|
833 // |
|
834 TInt CSCPServer::HashISACode( TDes& aHashBuf ) |
|
835 { |
|
836 // aHashBuf must be a MD5 hash digest |
|
837 if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
838 { |
|
839 return KErrNotSupported; |
|
840 } |
|
841 if ( aHashBuf.Length() < KSCPMD5HashLen ) |
|
842 { |
|
843 PanicServer( EBadHashDigest ); |
|
844 } |
|
845 |
|
846 // Compute the hash sum as four 32-bit integers. |
|
847 TInt64 hashSum = *(reinterpret_cast<TInt32*>(&aHashBuf[0])) + |
|
848 *(reinterpret_cast<TInt32*>(&aHashBuf[4])) + |
|
849 *(reinterpret_cast<TInt32*>(&aHashBuf[8])) + |
|
850 *(reinterpret_cast<TInt32*>(&aHashBuf[12])); |
|
851 |
|
852 // Create a five-digit security code from this number |
|
853 TInt ISAcode = ( hashSum % 90000 ) + 10000; |
|
854 Dprint( (_L("CSCPServer::HashISACode(): Hashed ISA code is %d"), ISAcode )); |
|
855 |
|
856 return ISAcode; |
|
857 } |
|
858 |
|
859 |
|
860 // --------------------------------------------------------- |
|
861 // TInt CSCPServer::StoreEnhCode( TDes& aCode ) |
|
862 // Sets the stored enhanced code to aCode and saves it to flash |
|
863 // |
|
864 // Status : Approved |
|
865 // --------------------------------------------------------- |
|
866 // |
|
867 TInt CSCPServer::StoreEnhCode( TDes& aCode, TSCPSecCode* aNewDOSCode /*=NULL*/) |
|
868 { |
|
869 |
|
870 if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
871 { |
|
872 return KErrNotSupported; |
|
873 } |
|
874 Dprint( (_L("CSCPServer::StoreEnhCode()") )); |
|
875 |
|
876 // Hash the code and save it |
|
877 TBuf<KSCPMaxHashLength> hashBuf; |
|
878 hashBuf.Zero(); |
|
879 iPluginEventHandler->HashInput( aCode, hashBuf ); |
|
880 |
|
881 TInt ISAcode = HashISACode( hashBuf ); |
|
882 |
|
883 RMobilePhone::TMobilePassword newCode; |
|
884 newCode.Zero(); |
|
885 newCode.AppendNum( ISAcode ); |
|
886 |
|
887 // Change the ISA code |
|
888 TRAPD( err, ChangeISACodeL( newCode ) ); |
|
889 |
|
890 if ( err == KErrNone ) |
|
891 { |
|
892 iConfiguration.iEnhSecCode.Zero(); |
|
893 iConfiguration.iEnhSecCode.Copy( hashBuf ); |
|
894 |
|
895 if ( aNewDOSCode != NULL ) |
|
896 { |
|
897 // Copy the updated DOS code |
|
898 (*aNewDOSCode).Copy( newCode ); |
|
899 } |
|
900 |
|
901 TRAPD( err, iConfiguration.WriteSetupL() ); |
|
902 if ( err != KErrNone ) |
|
903 { |
|
904 Dprint( (_L("CSCPServer::StoreEnhCode(): WARNING:\ |
|
905 failed to write configuration: %d"), err )); |
|
906 |
|
907 } |
|
908 else |
|
909 { |
|
910 /* Get the very first character of the new lock code and set the default input mode of the |
|
911 lock code query on the basis of the first character. */ |
|
912 ch = aCode[0]; |
|
913 |
|
914 CRepository* repository = NULL; |
|
915 def_mode = ch.IsDigit() ? 0 : 1; |
|
916 TRAPD(err, repository = CRepository::NewL( KCRUidSCPParameters )); |
|
917 if (err == KErrNone) |
|
918 { |
|
919 err = repository->Set( KSCPLockCodeDefaultInputMode , def_mode ); |
|
920 delete repository; |
|
921 } |
|
922 |
|
923 /* Set the value in the cenrep that the default lock code has been changed if it is not |
|
924 * already set |
|
925 * */ |
|
926 TRAP(err, repository = CRepository :: NewL(KCRUidSCPLockCode)); |
|
927 |
|
928 if(err == KErrNone) { |
|
929 err = repository->Set(KSCPLockCodeDefaultLockCode, 0); |
|
930 delete repository; |
|
931 } |
|
932 } |
|
933 } |
|
934 else |
|
935 { |
|
936 Dprint( (_L("CSCPServer::StoreEnhCode(): ERROR:\ |
|
937 failed to change ISA code, aborting storage operation: %d"), err )); |
|
938 |
|
939 } |
|
940 |
|
941 return err; |
|
942 } |
|
943 |
|
944 //#endif // __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
945 |
|
946 |
|
947 |
|
948 |
|
949 // --------------------------------------------------------- |
|
950 // TBool CSCPServer::IsOperationInProgress( TSCPAdminCommand aCommand ) |
|
951 // Loops through the sessions on the server and and calls the |
|
952 // query command to check if the given operation is in progress. |
|
953 // |
|
954 // Status : Approved |
|
955 // --------------------------------------------------------- |
|
956 // |
|
957 TBool CSCPServer::IsOperationInProgress( TSCPAdminCommand aCommand ) |
|
958 { |
|
959 Dprint( (_L("--> CSCPServer::IsOperationInProgress()") )); |
|
960 |
|
961 // Iterate through the sessions and find out if one has started the given operation |
|
962 TBool ret = EFalse; |
|
963 |
|
964 iSessionIter.SetToFirst(); |
|
965 CSCPSession* curSession = NULL; |
|
966 while ( ( curSession = static_cast<CSCPSession*>( iSessionIter++ ) ) != NULL ) |
|
967 { |
|
968 if ( curSession->IsOperationInProgress( aCommand ) ) |
|
969 { |
|
970 ret = ETrue; |
|
971 break; |
|
972 } |
|
973 } |
|
974 |
|
975 Dprint( (_L("<-- CSCPServer::IsOperationInProgress(): %d"), ret )); |
|
976 return ret; |
|
977 } |
|
978 |
|
979 |
|
980 |
|
981 |
|
982 // --------------------------------------------------------- |
|
983 // TBool CSCPServer::AcknowledgementReceived( TSCPAdminCommand aCommand ) |
|
984 // Loops through the sessions on the server, sends the acknowledgements, |
|
985 // and checks if one was waiting for it (ETrue). |
|
986 // |
|
987 // Status : Approved |
|
988 // --------------------------------------------------------- |
|
989 // |
|
990 TBool CSCPServer::AcknowledgementReceived( TSCPAdminCommand aCommand ) |
|
991 { |
|
992 Dprint( (_L("--> CSCPServer::AcknowledgementReceived()") )); |
|
993 |
|
994 // Iterate through the sessions and propagate the acknowledgement. |
|
995 // Set the return parameter, if one was waiting for the ack |
|
996 TBool ret = EFalse; |
|
997 |
|
998 iSessionIter.SetToFirst(); |
|
999 CSCPSession* curSession = NULL; |
|
1000 while ( ( curSession = static_cast<CSCPSession*>( iSessionIter++ ) ) != NULL ) |
|
1001 { |
|
1002 if ( curSession->AcknowledgeOperation( aCommand ) ) ret = ETrue; |
|
1003 } |
|
1004 |
|
1005 Dprint( (_L("<-- CSCPServer::AcknowledgementReceived(): %d"), ret )); |
|
1006 return ret; |
|
1007 } |
|
1008 |
|
1009 |
|
1010 |
|
1011 |
|
1012 // --------------------------------------------------------- |
|
1013 // TInt CSCPServer::SetAutolockPeriod() |
|
1014 // Sets the autolock period in either SharedData or CenRep. |
|
1015 // |
|
1016 // Status : Approved |
|
1017 // --------------------------------------------------------- |
|
1018 // |
|
1019 TInt CSCPServer :: SetAutolockPeriodL(TInt aValue) { |
|
1020 Dprint( (_L("CSCPServer::SetAutolockPeriodL(): Setting the value") )); |
|
1021 |
|
1022 TInt ret = KErrNone; |
|
1023 |
|
1024 |
|
1025 // Change the value in CenRep |
|
1026 ret = iALPeriodRep->Set( KSettingsAutoLockTime, aValue ); |
|
1027 |
|
1028 Dprint( (_L("[CSCPServer]-> SetAutolockPeriodL() <<<") )); |
|
1029 return ret; |
|
1030 } |
|
1031 |
|
1032 // --------------------------------------------------------- |
|
1033 // TInt CSCPServer::GetAutolockPeriodL( TInt& aValue ) |
|
1034 // Gets the autolock period from either SharedData or CenRep. |
|
1035 // |
|
1036 // Status : Approved |
|
1037 // --------------------------------------------------------- |
|
1038 // |
|
1039 TInt CSCPServer::GetAutolockPeriodL( TInt& aValue ) |
|
1040 { |
|
1041 TInt ret = KErrNone; |
|
1042 |
|
1043 Dprint( (_L("CSCPServer::GetAutolockPeriodL(): Getting the value") )); |
|
1044 |
|
1045 // Fetch the value from CenRep |
|
1046 ret = iALPeriodRep->Get( KSettingsAutoLockTime, aValue ); |
|
1047 |
|
1048 return ret; |
|
1049 } |
|
1050 |
|
1051 |
|
1052 |
|
1053 |
|
1054 // --------------------------------------------------------- |
|
1055 // CSCPServer::ChangeCodePolicy() |
|
1056 // Sets the new policy either internally or through the policy |
|
1057 // engine. |
|
1058 // |
|
1059 // Status : Approved |
|
1060 // --------------------------------------------------------- |
|
1061 // |
|
1062 TInt CSCPServer::ChangeCodePolicy( const TDesC& aValue ) |
|
1063 { |
|
1064 TInt ret = KErrNone; |
|
1065 |
|
1066 TLex lex( aValue ); |
|
1067 TInt value; |
|
1068 |
|
1069 ret = lex.Val( value ); |
|
1070 |
|
1071 if ( ret == KErrNone ) |
|
1072 { |
|
1073 if ( ( value < 0 ) || ( value > 1 ) ) |
|
1074 { |
|
1075 ret = KErrArgument; |
|
1076 } |
|
1077 else |
|
1078 { |
|
1079 Dprint( (_L("CSCPServer::ChangeCodePolicy(): %d"), value )); |
|
1080 |
|
1081 #ifdef SCP_USE_POLICY_ENGINE |
|
1082 |
|
1083 RPolicyEngine policyEngine; |
|
1084 ret = policyEngine.Connect(); |
|
1085 |
|
1086 RPolicyManagement policyManagement; |
|
1087 if ( ret == KErrNone ) |
|
1088 { |
|
1089 ret = policyManagement.Open( policyEngine ); |
|
1090 } |
|
1091 |
|
1092 TParserResponse response; |
|
1093 |
|
1094 if ( ret == KErrNone ) |
|
1095 { |
|
1096 Dprint( (_L("CSCPServer::ChangeCodePolicy(): Executing operation") )); |
|
1097 if ( value == 1 ) |
|
1098 { |
|
1099 // Allow change |
|
1100 ret = policyManagement.ExecuteOperation( |
|
1101 KSCPCodePolicyAllowOperation, |
|
1102 response |
|
1103 ); |
|
1104 } |
|
1105 else |
|
1106 { |
|
1107 // Deny change |
|
1108 ret = policyManagement.ExecuteOperation( |
|
1109 KSCPCodePolicyDisallowOperation, |
|
1110 response |
|
1111 ); |
|
1112 } |
|
1113 |
|
1114 if ( ret == KErrNone ) |
|
1115 { |
|
1116 const TDesC8& retMsg = response.GetReturnMessage(); |
|
1117 |
|
1118 if ( retMsg.Compare( KSCPOKResponse ) != 0 ) |
|
1119 { |
|
1120 #ifdef _DEBUG |
|
1121 TBuf<256> dummyBuf; |
|
1122 dummyBuf.Copy( retMsg ); |
|
1123 Dprint( (_L("CSCPServer::ChangeCodePolicy(): Response not OK:\ |
|
1124 %S"), &dummyBuf )); |
|
1125 #endif |
|
1126 |
|
1127 // We must check this for an error as well |
|
1128 ret = KErrGeneral; |
|
1129 } |
|
1130 } |
|
1131 } |
|
1132 |
|
1133 if ( policyManagement.SubSessionHandle() ) |
|
1134 { |
|
1135 policyManagement.Close(); |
|
1136 } |
|
1137 |
|
1138 if ( policyEngine.Handle() ) |
|
1139 { |
|
1140 policyEngine.Close(); |
|
1141 } |
|
1142 |
|
1143 #else // !SCP_USE_POLICY_ENGINE |
|
1144 |
|
1145 iCodePolicy = value; |
|
1146 |
|
1147 #endif // SCP_USE_POLICY_ENGINE |
|
1148 } |
|
1149 } |
|
1150 |
|
1151 Dprint( (_L("<-- CSCPServer::ChangeCodePolicy(): %d"), ret )); |
|
1152 return ret; |
|
1153 } |
|
1154 |
|
1155 |
|
1156 |
|
1157 |
|
1158 // --------------------------------------------------------- |
|
1159 // CSCPServer:GetCodePolicy() |
|
1160 // Gets the policy from internal storage of from the policy |
|
1161 // engine. |
|
1162 // |
|
1163 // Status : Approved |
|
1164 // --------------------------------------------------------- |
|
1165 // |
|
1166 TInt CSCPServer::GetCodePolicy( TDes& aValue ) |
|
1167 { |
|
1168 Dprint( (_L("--> CSCPServer::GetCodePolicy()") )); |
|
1169 TInt ret = KErrNone; |
|
1170 |
|
1171 aValue.Zero(); |
|
1172 |
|
1173 #ifdef SCP_USE_POLICY_ENGINE |
|
1174 TResponse response; |
|
1175 RPolicyEngine policyEngine; |
|
1176 ret = policyEngine.Connect(); |
|
1177 |
|
1178 RPolicyRequest policyRequest; |
|
1179 if ( ret == KErrNone ) |
|
1180 { |
|
1181 ret = policyRequest.Open( policyEngine ); |
|
1182 } |
|
1183 |
|
1184 if(ret == KErrNone) { |
|
1185 TRequestContext context; |
|
1186 |
|
1187 using namespace PolicyEngineXACML; |
|
1188 TRAPD( err , |
|
1189 context.AddResourceAttributeL( KResourceId, |
|
1190 KDeviceLockPasscodeVisibility, |
|
1191 KStringDataType) |
|
1192 ); |
|
1193 if ( err == KErrNone ) |
|
1194 { |
|
1195 ret = policyRequest.MakeRequest( context, response ); |
|
1196 } |
|
1197 else |
|
1198 { |
|
1199 ret = err; |
|
1200 } |
|
1201 } |
|
1202 |
|
1203 if ( ret == KErrNone ) |
|
1204 { |
|
1205 if ( response.GetResponseValue() == EResponsePermit ) |
|
1206 { |
|
1207 // Allow security code change |
|
1208 aValue.AppendNum( 1 ); |
|
1209 } |
|
1210 else |
|
1211 { |
|
1212 // Do not allow security code change |
|
1213 aValue.AppendNum( 0 ); |
|
1214 } |
|
1215 } |
|
1216 |
|
1217 if ( policyRequest.SubSessionHandle() ) |
|
1218 { |
|
1219 policyRequest.Close(); |
|
1220 } |
|
1221 |
|
1222 if ( policyEngine.Handle() ) |
|
1223 { |
|
1224 policyEngine.Close(); |
|
1225 } |
|
1226 |
|
1227 #else // !SCP_USE_POLICY_ENGINE |
|
1228 |
|
1229 aValue.AppendNum( iCodePolicy ); |
|
1230 |
|
1231 #endif // SCP_USE_POLICY_ENGINE |
|
1232 |
|
1233 Dprint((_L("[CSCPServer] <<< GetCodePolicy(): %d"), ret)); |
|
1234 return ret; |
|
1235 } |
|
1236 |
|
1237 |
|
1238 |
|
1239 |
|
1240 // --------------------------------------------------------- |
|
1241 // TInt CSCPServer::SetParameterValueL( TSCPParameterID aID, TDesC& aValue ) |
|
1242 // Handles the setting of the parameter values. |
|
1243 // |
|
1244 // Status : Approved |
|
1245 // --------------------------------------------------------- |
|
1246 // |
|
1247 TInt CSCPServer::SetParameterValueL( TInt aID, const TDesC& aValue, TUint32 aCallerIdentity ) |
|
1248 { |
|
1249 Dprint( (_L("--> CSCPServer::SetParameterValueL( %d )"), aID )); |
|
1250 |
|
1251 #ifdef __SCP_DEBUG |
|
1252 // Used to "emulate 3-button boot" in debug builds |
|
1253 if ( aID == 9999 ) |
|
1254 { |
|
1255 iConfiguration.iConfigFlag = KSCPConfigUnknown; |
|
1256 iConfiguration.iSecCode = KSCPDefaultSecCode; |
|
1257 return KErrNone; |
|
1258 } |
|
1259 #endif // __SCP_DEBUG |
|
1260 |
|
1261 TInt lRetStatus(KErrNone); |
|
1262 Dprint(_L("[CSCPServer]-> Initiating branching on parameter...")); |
|
1263 |
|
1264 switch ( aID ) |
|
1265 { |
|
1266 case ( ESCPAutolockPeriod ): |
|
1267 // Flow through |
|
1268 case ( ESCPMaxAutolockPeriod ): |
|
1269 { |
|
1270 // Convert the value, and set it |
|
1271 TInt value; |
|
1272 TLex lex(aValue); |
|
1273 lRetStatus = lex.Val(value); |
|
1274 |
|
1275 |
|
1276 if((lRetStatus != KErrNone ) || ( value < 0) || ( value > KSCPAutolockPeriodMaximum )) { |
|
1277 lRetStatus = KErrArgument; |
|
1278 break; |
|
1279 } |
|
1280 |
|
1281 //Check if the device memory is encrypted or not. |
|
1282 TBool encryptionEnabled = IsDeviceMemoryEncrypted(); |
|
1283 |
|
1284 // Value OK |
|
1285 if(aID == ESCPMaxAutolockPeriod) |
|
1286 { |
|
1287 if ( encryptionEnabled ) |
|
1288 { |
|
1289 Dprint(_L("Memory is encrypted")); |
|
1290 if (( 0 == value) || value > KMaxAutolockPeriod) |
|
1291 { |
|
1292 Dprint((_L("Denying setting of max auto lock as value is %d"), value)); |
|
1293 User::Leave( KErrPermissionDenied ); |
|
1294 } |
|
1295 |
|
1296 } |
|
1297 else |
|
1298 { |
|
1299 Dprint(_L("Memory is decrypted, hence no restrictions to max autolock")); |
|
1300 } |
|
1301 |
|
1302 Dprint(_L("[CSCPServer]-> Branched to ESCPMaxAutolockPeriod...")); |
|
1303 CSCPParamDBController* lParamDB = CSCPParamDBController :: NewLC(); |
|
1304 lRetStatus = SetBestPolicyL(RTerminalControl3rdPartySession :: EMaxTimeout, aValue, aCallerIdentity, lParamDB); |
|
1305 |
|
1306 if(lRetStatus == KErrNone) |
|
1307 { |
|
1308 // Do we have to change the Autolock period as well? |
|
1309 TInt currentALperiod; |
|
1310 lRetStatus = GetAutolockPeriodL(currentALperiod); |
|
1311 |
|
1312 if(lRetStatus == KErrNone) |
|
1313 { |
|
1314 if((iConfiguration.iMaxTimeout > 0) && ((iConfiguration.iMaxTimeout < currentALperiod) || (currentALperiod == 0))) |
|
1315 { |
|
1316 Dprint((_L("[CSCPServer]-> Changing AL period to Max. AL period (Current ALP: %d, Max. ALP: %d)"), currentALperiod, value)); |
|
1317 lRetStatus = SetAutolockPeriodL(value); |
|
1318 } |
|
1319 } |
|
1320 else |
|
1321 { |
|
1322 Dprint((_L("[CSCPServer]-> ERROR: Couldn't get the Autolock period: %d"), lRetStatus)); |
|
1323 } |
|
1324 } |
|
1325 |
|
1326 CleanupStack :: PopAndDestroy(); //lParamDB |
|
1327 } |
|
1328 |
|
1329 else |
|
1330 { // Autolock Period |
|
1331 |
|
1332 //Code is commented as it is already taken care by the below condition #1343 irrespective of the drive encryption state. |
|
1333 /* if ( 0 == value ) |
|
1334 { |
|
1335 if ( encryptionEnabled ) |
|
1336 { |
|
1337 Dprint(_L("Permission denied!")); |
|
1338 User::Leave( KErrPermissionDenied ); |
|
1339 } |
|
1340 }*/ |
|
1341 |
|
1342 Dprint(_L("[CSCPServer]-> Branched to ESCPAutolockPeriod...")); |
|
1343 // Check if this value is not allowed by the Max. Autolock period |
|
1344 if ((iConfiguration.iMaxTimeout > 0) && ((iConfiguration.iMaxTimeout < value) || (value == 0))) { |
|
1345 Dprint((_L("[CSCPServer]-> ERROR: The value %d for AL period not allowed (Max. AL period: %d)"), value, iConfiguration.iMaxTimeout)); |
|
1346 |
|
1347 lRetStatus = KErrArgument; |
|
1348 } |
|
1349 else { |
|
1350 lRetStatus = SetAutolockPeriodL(value); |
|
1351 |
|
1352 if(lRetStatus != KErrNone) { |
|
1353 Dprint((_L("[CSCPServer]-> ERROR: Couldn't set the Autolock period: %d"), lRetStatus)); |
|
1354 } |
|
1355 } |
|
1356 } |
|
1357 } |
|
1358 break; |
|
1359 case ESCPCodeChangePolicy: |
|
1360 Dprint(_L("[CSCPServer]-> Branched to ESCPCodeChangePolicy...")); |
|
1361 lRetStatus = ChangeCodePolicy( aValue ); |
|
1362 break; |
|
1363 default: { |
|
1364 //#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
1365 Dprint(_L("[CSCPServer]-> Branched to default condition, aID=%d"), aID); |
|
1366 |
|
1367 if(FeatureManager :: FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) { |
|
1368 RPointerArray<HBufC> lSpecStrArray; |
|
1369 CleanupClosePushL(lSpecStrArray); |
|
1370 |
|
1371 Dprint(_L("[CSCPServer]-> Creating an instance of the private DB...")); |
|
1372 CSCPParamDBController* lParamDB = CSCPParamDBController :: NewLC(); |
|
1373 Dprint(_L("[CSCPServer]-> Private DB instance created successfully...")); |
|
1374 |
|
1375 Dprint(_L("[CSCPServer]-> Creating ParamObject...")); |
|
1376 CSCPParamObject* lInParams = CSCPParamObject :: NewLC(); |
|
1377 Dprint(_L("[CSCPServer]-> ParamObject created successfully...")); |
|
1378 |
|
1379 //lInParams->Set(KSCPParamIdentity, aCallerIdentity); |
|
1380 |
|
1381 /* |
|
1382 * Map KSCPParamIdentity with the SID of TCServer (not aCallerIdentity) |
|
1383 */ |
|
1384 lInParams->Set(KSCPParamIdentity, this->Message().SecureId()); |
|
1385 |
|
1386 switch(aID) { |
|
1387 case RTerminalControl3rdPartySession :: EPasscodeAllowSpecific: |
|
1388 case RTerminalControl3rdPartySession :: EPasscodeClearSpecificStrings: { |
|
1389 RPointerArray<HBufC> lSharedStrArray; |
|
1390 CleanupClosePushL(lSharedStrArray); |
|
1391 |
|
1392 /* If the choice is EPasscodeAllowSpecific then parse the specific strings mentioned and |
|
1393 * list the specific strings in an Array (multiple specific strings can be seperated with a single space) |
|
1394 * The Memory alloted for each of the tokens representing each individual specific string will be |
|
1395 * deallocated when the array lSpecStrArray is cleared by a call to ResetAndDestroy(). |
|
1396 */ |
|
1397 if(aID == RTerminalControl3rdPartySession :: EPasscodeAllowSpecific) { |
|
1398 TLex16 lex (aValue); |
|
1399 lex.Mark(); |
|
1400 |
|
1401 while(!lex.Eos()) { |
|
1402 while(lex.Peek() != ' ' && !lex.Eos()) { |
|
1403 lex.Inc(); |
|
1404 } |
|
1405 |
|
1406 const TDesC& lToken = lex.MarkedToken(); |
|
1407 HBufC* lBuff(NULL); |
|
1408 TRAP(lRetStatus, lBuff = HBufC :: NewL(lToken.Length())); |
|
1409 |
|
1410 if(lRetStatus != KErrNone) { |
|
1411 lSpecStrArray.ResetAndDestroy(); |
|
1412 User :: Leave(lRetStatus); |
|
1413 } |
|
1414 |
|
1415 lBuff->Des().Append(lToken); |
|
1416 lSpecStrArray.Append(lBuff); |
|
1417 lex.Inc(); |
|
1418 lex.Mark(); |
|
1419 } |
|
1420 } |
|
1421 else { |
|
1422 lRetStatus = lParamDB->GetValuesL(RTerminalControl3rdPartySession :: EPasscodeDisallowSpecific, |
|
1423 lSpecStrArray, aCallerIdentity); |
|
1424 } |
|
1425 |
|
1426 TInt lCnt = lSpecStrArray.Count(); |
|
1427 lInParams->Set(KSCPParamID, RTerminalControl3rdPartySession :: EPasscodeAllowSpecific); |
|
1428 |
|
1429 for(TInt i=0; i < lCnt; i++) { |
|
1430 HBufC* lPtr = lSpecStrArray[i]; |
|
1431 TBool lIsShared(EFalse); |
|
1432 |
|
1433 TRAPD(lErr, lIsShared = lParamDB->IsParamValueSharedL(lSpecStrArray[i], aCallerIdentity)); |
|
1434 |
|
1435 if(lErr != KErrNone) { |
|
1436 lSpecStrArray.ResetAndDestroy(); |
|
1437 lSharedStrArray.ResetAndDestroy(); |
|
1438 User :: Leave(lErr); |
|
1439 } |
|
1440 |
|
1441 if(EFalse == lIsShared) { |
|
1442 TUint16* ptr = const_cast<TUint16*>(lPtr->Des().Ptr()); |
|
1443 TPtr valBuf(ptr, lPtr->Des().Length(), lPtr->Des().Length()); |
|
1444 lInParams->Set(KSCPParamValue, valBuf); |
|
1445 |
|
1446 CSCPParamObject* reply = iPluginManager->PostEvent(KSCPEventConfigurationQuery, *lInParams); |
|
1447 |
|
1448 if((reply != NULL) && (reply->Get(KSCPParamStatus, lRetStatus) == KErrNone)) { |
|
1449 if(lRetStatus != KErrNone) { |
|
1450 lSpecStrArray.ResetAndDestroy(); |
|
1451 lSharedStrArray.ResetAndDestroy(); |
|
1452 User :: Leave(lRetStatus); |
|
1453 } |
|
1454 |
|
1455 delete reply; |
|
1456 } |
|
1457 } |
|
1458 else { |
|
1459 lSpecStrArray.Remove(i); |
|
1460 lSharedStrArray.Append(lPtr); |
|
1461 i--; |
|
1462 lCnt--; |
|
1463 } |
|
1464 } |
|
1465 |
|
1466 /* |
|
1467 * Drop all the 'disallow strings' that are not shared between any other applications from the database. |
|
1468 */ |
|
1469 TRAPD(lErr, lRetStatus = lParamDB->DropValuesL(RTerminalControl3rdPartySession :: EPasscodeDisallowSpecific, lSpecStrArray)); |
|
1470 |
|
1471 if(lErr != KErrNone) { |
|
1472 lSpecStrArray.ResetAndDestroy(); |
|
1473 lSharedStrArray.ResetAndDestroy(); |
|
1474 User :: Leave(lErr); |
|
1475 } |
|
1476 |
|
1477 if(lRetStatus == KErrNone) { |
|
1478 /* |
|
1479 * Drop the entries of 'disallow strings' of only the called application |
|
1480 * (Any application that shares these 'disallow strings' will not be affected) |
|
1481 */ |
|
1482 TRAP(lErr, lRetStatus = lParamDB->DropValuesL(RTerminalControl3rdPartySession :: EPasscodeDisallowSpecific, |
|
1483 lSharedStrArray, aCallerIdentity)); |
|
1484 |
|
1485 if(lErr != KErrNone) { |
|
1486 lSpecStrArray.ResetAndDestroy(); |
|
1487 lSharedStrArray.ResetAndDestroy(); |
|
1488 User :: Leave(lErr); |
|
1489 } |
|
1490 |
|
1491 if(lRetStatus != KErrNone) { |
|
1492 Dprint(_L("[CSCPServer]-> Unable to drop 'disallow strings' from the private database...")); |
|
1493 } |
|
1494 } |
|
1495 else { |
|
1496 Dprint(_L("[CSCPServer]-> Unable to drop unshared 'disallow strings' from the private database...")); |
|
1497 } |
|
1498 |
|
1499 lSharedStrArray.ResetAndDestroy(); |
|
1500 CleanupStack :: PopAndDestroy(); // lSharedStrArray |
|
1501 } |
|
1502 break; |
|
1503 default: { |
|
1504 lInParams->Set(KSCPParamID, aID); |
|
1505 TUint16* ptr = const_cast<TUint16*>(aValue.Ptr()); |
|
1506 TPtr valBuf(ptr, aValue.Length(), aValue.Length()); |
|
1507 lInParams->Set(KSCPParamValue, valBuf); |
|
1508 |
|
1509 Dprint(_L("[CSCPServer]-> INFO: Posting the event to the plugins...")); |
|
1510 CSCPParamObject* reply = iPluginManager->PostEvent(KSCPEventConfigurationQuery, *lInParams); |
|
1511 |
|
1512 if((reply != NULL) && (reply->Get(KSCPParamStatus, lRetStatus) == KErrNone)) { |
|
1513 if(lRetStatus == KErrNone) { |
|
1514 Dprint(_L("[CSCPServer]-> INFO: The event was consumed by one of the plugins, initiating storage activities (if any)...")); |
|
1515 // Check if the plugin wishes to save the parameters itself |
|
1516 TInt storage = KSCPStorageCommon; |
|
1517 reply->Get(KSCPParamStorage, storage); |
|
1518 |
|
1519 if(storage == KSCPStoragePrivate) { |
|
1520 switch(aID) { |
|
1521 /* The plugin will take care of storing the values for EPasscodeDisallowSpecific, this is to make sure the |
|
1522 * value is updated accordingly even in the private database (which is used as a reference to set the best policy-done |
|
1523 * as per MfE-Part 3 requirement |
|
1524 */ |
|
1525 case RTerminalControl3rdPartySession :: EPasscodeDisallowSpecific: { |
|
1526 TLex16 lex (aValue); |
|
1527 lex.Mark(); |
|
1528 |
|
1529 while(!lex.Eos()) { |
|
1530 while(lex.Peek() != ' ' && !lex.Eos()) { |
|
1531 lex.Inc(); |
|
1532 } |
|
1533 |
|
1534 const TDesC& lToken = lex.MarkedToken(); |
|
1535 HBufC* lBuff(NULL); |
|
1536 TInt lErr(KErrNone); |
|
1537 TRAP(lErr, lBuff = HBufC :: NewL(lToken.Length())); |
|
1538 |
|
1539 if(lErr != KErrNone) { |
|
1540 lSpecStrArray.ResetAndDestroy(); |
|
1541 delete reply; |
|
1542 User :: Leave(lErr); |
|
1543 } |
|
1544 |
|
1545 lBuff->Des().Append(lToken); |
|
1546 lSpecStrArray.Append(lBuff); |
|
1547 lex.Inc(); |
|
1548 lex.Mark(); |
|
1549 } |
|
1550 |
|
1551 TInt lRet(KErrNone); |
|
1552 |
|
1553 TRAP(lRet, lRetStatus = lParamDB->SetValuesL(RTerminalControl3rdPartySession :: EPasscodeDisallowSpecific, |
|
1554 lSpecStrArray, aCallerIdentity)); |
|
1555 |
|
1556 if(lRet != KErrNone) { |
|
1557 lRetStatus = lRet; |
|
1558 } |
|
1559 } |
|
1560 break; |
|
1561 default: |
|
1562 // Don't store the parameter, the plugin will handle this |
|
1563 Dprint((_L("[CSCPServer]-> Param %d stored in private storage..."), aID)); |
|
1564 break; |
|
1565 } |
|
1566 } |
|
1567 else { |
|
1568 Dprint((_L("[CSCPServer]-> Param %d stored in common storage..."), aID)); |
|
1569 lRetStatus = SetBestPolicyL(aID, aValue, aCallerIdentity, lParamDB); |
|
1570 } |
|
1571 } |
|
1572 } |
|
1573 else { |
|
1574 Dprint(_L("[CSCPServer]-> INFO: Event posting failed, reply=%d"), reply); |
|
1575 } |
|
1576 |
|
1577 delete reply; |
|
1578 break; |
|
1579 } |
|
1580 } |
|
1581 |
|
1582 lSpecStrArray.ResetAndDestroy(); |
|
1583 CleanupStack :: PopAndDestroy(3); // lSpecStrArray, lParamDB, lInParams |
|
1584 } |
|
1585 //#endif // __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
1586 break; |
|
1587 } |
|
1588 } |
|
1589 |
|
1590 Dprint((_L("[CSCPServer]-> <<< SetParameterValueL(): %d"), lRetStatus)); |
|
1591 return lRetStatus; |
|
1592 } |
|
1593 // --------------------------------------------------------- |
|
1594 // TInt CSCPServer::GetParameterValueL( TSCPParameterID aID, TDes& aValue ) |
|
1595 // Handles the fetching of parameter values. |
|
1596 // |
|
1597 // Status : Approved |
|
1598 // --------------------------------------------------------- |
|
1599 // |
|
1600 TInt CSCPServer::GetParameterValueL( TInt aID, TDes& aValue, TUint32 aCallerIdentity ) |
|
1601 { |
|
1602 Dprint( (_L("CSCPServer::GetParameterValueL( %d )"), aID )); |
|
1603 TInt ret = KErrNone; |
|
1604 |
|
1605 switch ( aID ) |
|
1606 { |
|
1607 case ( ESCPAutolockPeriod ): |
|
1608 { |
|
1609 // Get the actual autolock period |
|
1610 TInt value; |
|
1611 if ( GetAutolockPeriodL( value ) != KErrNone ) |
|
1612 { |
|
1613 Dprint( (_L("CSCPServer::SetParameterValueL(): ERROR: Couldn't \ |
|
1614 get the Autolock period") )); |
|
1615 } |
|
1616 else |
|
1617 { |
|
1618 aValue.Zero(); |
|
1619 aValue.AppendNum(value); |
|
1620 } |
|
1621 } |
|
1622 break; |
|
1623 |
|
1624 case ( ESCPMaxAutolockPeriod ): |
|
1625 { |
|
1626 // Just fetch the value into the buffer |
|
1627 aValue.Zero(); |
|
1628 aValue.AppendNum( iConfiguration.iMaxTimeout ); |
|
1629 } |
|
1630 break; |
|
1631 |
|
1632 case ( ESCPCodeChangePolicy ): |
|
1633 { |
|
1634 ret = GetCodePolicy( aValue ); |
|
1635 } |
|
1636 break; |
|
1637 |
|
1638 default: |
|
1639 ret = KErrNotSupported; |
|
1640 |
|
1641 //#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
1642 if(FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
1643 { |
|
1644 |
|
1645 // "Ask" the plugins, if this caller is allowed to access this value or |
|
1646 // if the value is in private storage, retrieve the value. |
|
1647 CSCPParamObject* inParams = CSCPParamObject::NewL(); |
|
1648 CleanupStack::PushL( inParams ); |
|
1649 inParams->Set( KSCPParamID, aID ); |
|
1650 inParams->Set( KSCPParamIdentity, aCallerIdentity ); |
|
1651 |
|
1652 CSCPParamObject* repParams = |
|
1653 iPluginManager->PostEvent( KSCPEventRetrieveConfiguration, *inParams ); |
|
1654 |
|
1655 CleanupStack::PopAndDestroy( inParams ); |
|
1656 |
|
1657 TBool getFromCommonStorage = ETrue; |
|
1658 TInt status; |
|
1659 if ( ( repParams != NULL ) && |
|
1660 ( repParams->Get( KSCPParamStatus, status ) == KErrNone ) ) |
|
1661 { |
|
1662 ret = status; |
|
1663 if ( ret != KErrNone ) |
|
1664 { |
|
1665 getFromCommonStorage = EFalse; |
|
1666 Dprint( (_L("CSCPServer::GetParameterValueL():\ |
|
1667 Retrieve configuration for param %d not OK: %d"), aID, ret )); |
|
1668 } |
|
1669 else |
|
1670 { |
|
1671 // Has the plugin sent the value? |
|
1672 TInt valueLen = repParams->GetParamLength( KSCPParamValue ); |
|
1673 if ( valueLen > 0 ) |
|
1674 { |
|
1675 getFromCommonStorage = EFalse; |
|
1676 // Try to retrieve the value (Get will check for overflow) |
|
1677 ret = repParams->Get( KSCPParamValue, aValue ); |
|
1678 } |
|
1679 } |
|
1680 } |
|
1681 |
|
1682 if ( getFromCommonStorage ) |
|
1683 { |
|
1684 // OK, no objection, so try to get the value from common storage |
|
1685 ret = iPluginEventHandler->GetParameters().Get( aID, aValue ); |
|
1686 } |
|
1687 |
|
1688 if ( repParams != NULL ) |
|
1689 { |
|
1690 delete repParams; |
|
1691 } |
|
1692 } |
|
1693 //#endif // __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
1694 |
|
1695 break; |
|
1696 } |
|
1697 |
|
1698 Dprint( (_L("<-- CSCPServer::GetParameterValueL(): %d"), ret )); |
|
1699 return ret; |
|
1700 } |
|
1701 |
|
1702 |
|
1703 |
|
1704 |
|
1705 // --------------------------------------------------------- |
|
1706 // static TBool CSCPServer::IsValidISACode( TDes& aCode ) |
|
1707 // Checks that the given string is a valid ISA security code. |
|
1708 // That is, exacly 5 chars, and contains only digits. |
|
1709 // |
|
1710 // Status : Approved |
|
1711 // --------------------------------------------------------- |
|
1712 // |
|
1713 |
|
1714 TBool CSCPServer::IsValidISACode( TDes& aCode ) |
|
1715 { |
|
1716 TBool ret = ETrue; |
|
1717 |
|
1718 if ( aCode.Length() != KSCPCodeMaxLen ) |
|
1719 { |
|
1720 ret = EFalse; |
|
1721 } |
|
1722 else |
|
1723 { |
|
1724 for ( TInt i = 0; i < aCode.Length(); i++ ) |
|
1725 { |
|
1726 if ( !( ((TChar)aCode[i]).IsDigit() ) ) |
|
1727 { |
|
1728 ret = EFalse; |
|
1729 } |
|
1730 } |
|
1731 } |
|
1732 |
|
1733 return ret; |
|
1734 } |
|
1735 |
|
1736 |
|
1737 |
|
1738 |
|
1739 // --------------------------------------------------------- |
|
1740 // void CSCPServer::SessionClosed() |
|
1741 // Checks if this was the final session. If so, exit the |
|
1742 // server thread. |
|
1743 // |
|
1744 // Status : Approved |
|
1745 // --------------------------------------------------------- |
|
1746 // |
|
1747 |
|
1748 void CSCPServer::SessionClosed() |
|
1749 { |
|
1750 iSessionIter.SetToFirst(); |
|
1751 iSessionIter++; // Skip the closing session |
|
1752 |
|
1753 if ( iSessionIter++ == NULL ) |
|
1754 { |
|
1755 // No more sessions |
|
1756 Dprint( (_L("CSCPServer::SessionClosed(): No more sessions, starting timeout") )); |
|
1757 |
|
1758 //#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
1759 if(FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
1760 { |
|
1761 // Save the plugin configuration |
|
1762 TRAP_IGNORE( iPluginEventHandler->WritePluginConfigurationL() ); |
|
1763 } |
|
1764 //#endif // __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
1765 |
|
1766 // Start shutdown timer |
|
1767 TRAPD( err, iShutdownTimer = CSCPTimer::NewL( KSCPServerShutdownTimeout, |
|
1768 NULL, |
|
1769 this ) ); |
|
1770 if ( err != KErrNone ) |
|
1771 { |
|
1772 // Cannot create the timer! |
|
1773 // No more sessions |
|
1774 Dprint( (_L("CSCPServer::SessionClosed(): ERROR: Timer creation failed! Exiting.."))); |
|
1775 iShutdownTimer = NULL; |
|
1776 Timeout( NULL ); |
|
1777 } |
|
1778 } |
|
1779 } |
|
1780 |
|
1781 |
|
1782 |
|
1783 // --------------------------------------------------------- |
|
1784 // void CSCPServer::SessionOpened() |
|
1785 // Stops the shutdown timer, if started. |
|
1786 // |
|
1787 // Status : Approved |
|
1788 // --------------------------------------------------------- |
|
1789 // |
|
1790 void CSCPServer::SessionOpened() |
|
1791 { |
|
1792 // Stop the shutdown timer |
|
1793 if ( iShutdownTimer != NULL ) |
|
1794 { |
|
1795 delete iShutdownTimer; |
|
1796 iShutdownTimer = NULL; |
|
1797 } |
|
1798 } |
|
1799 |
|
1800 |
|
1801 |
|
1802 |
|
1803 // --------------------------------------------------------- |
|
1804 // void CSCPServer::Timeout() |
|
1805 // Shuts down the server stopping the active scheduler since |
|
1806 // the shutdown timer has elapsed. |
|
1807 // |
|
1808 // Status : Approved |
|
1809 // --------------------------------------------------------- |
|
1810 // |
|
1811 void CSCPServer::Timeout( TAny* aParam ) |
|
1812 { |
|
1813 (void)aParam; |
|
1814 |
|
1815 delete iShutdownTimer; |
|
1816 iShutdownTimer = NULL; |
|
1817 |
|
1818 Dprint( (_L("CSCPServer::Timeout(): Shutting down SCP server") )); |
|
1819 |
|
1820 CActiveScheduler::Stop(); |
|
1821 } |
|
1822 |
|
1823 |
|
1824 |
|
1825 // ********************** NEW FEATURES ********************>>>> |
|
1826 |
|
1827 //#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
1828 |
|
1829 // --------------------------------------------------------- |
|
1830 // CSCPServer::IsValidEnhCode() |
|
1831 // Checks that the given buffer is an alphanumeric string |
|
1832 // and its length is between the minimum and maximum. |
|
1833 // |
|
1834 // Status : Approved |
|
1835 // --------------------------------------------------------- |
|
1836 // |
|
1837 TBool CSCPServer::IsValidEnhCode( TDes& aCode ) |
|
1838 { |
|
1839 |
|
1840 if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
1841 { |
|
1842 return KErrNotSupported; |
|
1843 } |
|
1844 TBool ret = ETrue; |
|
1845 |
|
1846 // Check length |
|
1847 if ( ( aCode.Length() < KSCPPasscodeMinLength ) || |
|
1848 ( aCode.Length() > KSCPPasscodeMaxLength ) ) |
|
1849 { |
|
1850 ret = EFalse; |
|
1851 } |
|
1852 |
|
1853 // Check the characters |
|
1854 if ( ret ) |
|
1855 { |
|
1856 for ( TInt i = 0; i < aCode.Length(); i++ ) |
|
1857 { |
|
1858 TChar curChar = aCode[i]; |
|
1859 TChar::TCategory chCat = curChar.GetCategory(); |
|
1860 if ( curChar < 1 || curChar > 126 || curChar.IsSpace() ) |
|
1861 /* if ( ( !curChar.IsAlphaDigit() ) && ( chCat != TChar::ENdCategory ) ) */ |
|
1862 { |
|
1863 ret = EFalse; |
|
1864 } |
|
1865 } |
|
1866 } |
|
1867 |
|
1868 return ret; |
|
1869 } |
|
1870 |
|
1871 |
|
1872 // --------------------------------------------------------- |
|
1873 // CSCPServer::IsCodeBlocked() |
|
1874 // Checks if the code is blocked, and zeroes the attempt counter |
|
1875 // when necessary. |
|
1876 // |
|
1877 // Status : Approved |
|
1878 // --------------------------------------------------------- |
|
1879 // |
|
1880 TBool CSCPServer::IsCodeBlocked() |
|
1881 { |
|
1882 |
|
1883 if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
1884 { |
|
1885 return KErrNotSupported; |
|
1886 } |
|
1887 TBool ret = EFalse; |
|
1888 |
|
1889 if ( iConfiguration.iBlockedAtTime.Compare( KSCPNotBlocked ) == 0 ) |
|
1890 { |
|
1891 ret = EFalse; |
|
1892 } |
|
1893 else |
|
1894 { |
|
1895 TTime curTime; |
|
1896 curTime.UniversalTime(); |
|
1897 |
|
1898 TTimeIntervalMinutes interval = KSCPCodeBlockedTimeMin; |
|
1899 |
|
1900 TInt64 savedTime; |
|
1901 TLex lex( iConfiguration.iBlockedAtTime ); |
|
1902 ret = lex.Val( savedTime ); |
|
1903 |
|
1904 if ( ret == KErrNone ) |
|
1905 { |
|
1906 TTime configTime( savedTime ); |
|
1907 if ( ( configTime + interval ) > curTime ) |
|
1908 { |
|
1909 Dprint( (_L("CSCPServer::IsCodeBlocked(): Code BLOCKED") )); |
|
1910 // Restart the timer |
|
1911 iConfiguration.iBlockedAtTime.Zero(); |
|
1912 iConfiguration.iBlockedAtTime.AppendNum( curTime.Int64() ); |
|
1913 |
|
1914 ret = ETrue; |
|
1915 } |
|
1916 else |
|
1917 { |
|
1918 // Not blocked anymore |
|
1919 |
|
1920 Dprint( (_L("CSCPServer::IsCodeBlocked(): Resetting code block") )); |
|
1921 iConfiguration.iFailedAttempts = 0; |
|
1922 iConfiguration.iBlockedAtTime.Zero(); |
|
1923 iConfiguration.iBlockedAtTime.Copy( KSCPNotBlocked ); |
|
1924 |
|
1925 ret = EFalse; |
|
1926 } |
|
1927 |
|
1928 TRAPD( err, iConfiguration.WriteSetupL() ); |
|
1929 if ( err != KErrNone ) |
|
1930 { |
|
1931 Dprint( (_L("CSCPServer::IsCodeBlocked(): WARNING:\ |
|
1932 failed to write configuration: %d"), err )); |
|
1933 |
|
1934 } |
|
1935 } |
|
1936 } |
|
1937 |
|
1938 return ret; |
|
1939 } |
|
1940 |
|
1941 |
|
1942 |
|
1943 |
|
1944 // --------------------------------------------------------- |
|
1945 // CSCPServer::SendInvalidDOSCode() |
|
1946 // Resets the DOS password attempts if required and verifies the |
|
1947 // code. |
|
1948 // |
|
1949 // Status : Approved |
|
1950 // --------------------------------------------------------- |
|
1951 // |
|
1952 void CSCPServer::SendInvalidDOSCode( RMobilePhone::TMobilePassword& aCodeToSend ) |
|
1953 { |
|
1954 |
|
1955 if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
1956 { |
|
1957 return ; |
|
1958 } |
|
1959 // Reset the DOS-side PSW-attempts by changing the code to the same one |
|
1960 RMobilePhone::TMobilePassword correctPsw; |
|
1961 TRAPD( err, |
|
1962 GetCode( correctPsw ); |
|
1963 ChangeISACodeL( correctPsw ); |
|
1964 ); |
|
1965 if ( err != KErrNone ) |
|
1966 { |
|
1967 Dprint( (_L("CSCPServer::SendInvalidDOSCode(): WARNING:\ |
|
1968 DOS code change failed, where it shouldn't have: %d"), err )); |
|
1969 } |
|
1970 |
|
1971 // Send the incorrect code to DOS side |
|
1972 TRAPD( ret, CheckISACodeL( aCodeToSend ) ); |
|
1973 #ifndef __WINS__ |
|
1974 if ( ( ret != KErrAccessDenied ) && ( ret != KErrGsm0707IncorrectPassword ) ) |
|
1975 { |
|
1976 Dprint( (_L("CSCPServer::SendInvalidDOSCode(): WARNING:\ |
|
1977 invalid DOS code validation error: %d"), ret )); |
|
1978 } |
|
1979 #endif // __WINS__ |
|
1980 } |
|
1981 |
|
1982 |
|
1983 |
|
1984 |
|
1985 // --------------------------------------------------------- |
|
1986 // CSCPServer::IsCorrectEnhCode() |
|
1987 // Checks if the given code is the correct enhanced code. |
|
1988 // If the configuration is not up-to-date, the code will be hashed |
|
1989 // and verified from the ISA-side. |
|
1990 // |
|
1991 // Status : Approved |
|
1992 // --------------------------------------------------------- |
|
1993 // |
|
1994 TInt CSCPServer::IsCorrectEnhCode( TDes& aCode, TInt aFlags ) |
|
1995 { |
|
1996 |
|
1997 if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
1998 { |
|
1999 return KErrNotSupported; |
|
2000 } |
|
2001 TInt ret = KErrAccessDenied; |
|
2002 |
|
2003 // Hash the code |
|
2004 TBuf<KSCPMaxHashLength> hashBuf; |
|
2005 hashBuf.Zero(); |
|
2006 iPluginEventHandler->HashInput( aCode, hashBuf ); |
|
2007 |
|
2008 TInt ISACode = HashISACode( hashBuf ); |
|
2009 |
|
2010 RMobilePhone::TMobilePassword pswCandidate; |
|
2011 pswCandidate.Zero(); |
|
2012 pswCandidate.AppendNum( ISACode ); |
|
2013 |
|
2014 TBool enhancedCodeMatches = EFalse; |
|
2015 if ( hashBuf.Compare( iConfiguration.iEnhSecCode ) == 0 ) |
|
2016 { |
|
2017 enhancedCodeMatches = ETrue; |
|
2018 } |
|
2019 |
|
2020 // Check if the code is blocked (don't check if we're out-of-sync) |
|
2021 if ( ( iConfiguration.iConfigFlag == KSCPConfigOK ) && ( IsCodeBlocked() ) ) |
|
2022 { |
|
2023 if ( aFlags & KSCPEtelRequest ) |
|
2024 { |
|
2025 // Check if the code is correct |
|
2026 if ( enhancedCodeMatches ) |
|
2027 { |
|
2028 // Mess-up the code |
|
2029 RMobilePhone::TMobilePassword codeToSend; |
|
2030 codeToSend.Zero(); |
|
2031 codeToSend.AppendNum( ISACode + 1 ); |
|
2032 |
|
2033 SendInvalidDOSCode( codeToSend ); |
|
2034 } |
|
2035 else |
|
2036 { |
|
2037 // OK, the code is already invalid |
|
2038 SendInvalidDOSCode( pswCandidate ); |
|
2039 } |
|
2040 } |
|
2041 return KErrLocked; |
|
2042 } |
|
2043 |
|
2044 TBool writeSetup = EFalse; |
|
2045 |
|
2046 if ( iConfiguration.iConfigFlag == KSCPConfigOK ) |
|
2047 { |
|
2048 // Normal situation: we have the correct code stored. |
|
2049 // Compare the hashes (hashing error will result in EFalse ) |
|
2050 if ( enhancedCodeMatches ) |
|
2051 { |
|
2052 ret = KErrNone; |
|
2053 |
|
2054 if ( aFlags & KSCPEtelRequest ) |
|
2055 { |
|
2056 // Send the correct code to DOS side |
|
2057 TRAP( ret, CheckISACodeL( pswCandidate ) ); |
|
2058 } |
|
2059 |
|
2060 if ( ret == KErrNone ) |
|
2061 { |
|
2062 if ( iConfiguration.iFailedAttempts > 0 ) |
|
2063 { |
|
2064 iConfiguration.iFailedAttempts = 0; |
|
2065 Dprint( (_L("CSCPServer::IsCorrectEnhCode():KErrAccessDenied: iFailedAttempts (%d)."), iConfiguration.iFailedAttempts )); |
|
2066 writeSetup = ETrue; |
|
2067 } |
|
2068 } |
|
2069 else |
|
2070 { |
|
2071 Dprint( (_L("CSCPServer::IsCorrectEnhCode(): WARNING:\ |
|
2072 ISA code validation failed, where it shouldn't have: %d"), ret )); |
|
2073 } |
|
2074 } |
|
2075 else |
|
2076 { |
|
2077 ret = KErrAccessDenied; |
|
2078 |
|
2079 iConfiguration.iFailedAttempts++; |
|
2080 Dprint( (_L("CSCPServer::IsCorrectEnhCode():KErrAccessDenied: iFailedAttempts (%d)."), iConfiguration.iFailedAttempts )); |
|
2081 writeSetup = ETrue; |
|
2082 |
|
2083 if ( iConfiguration.iFailedAttempts == KSCPCodeBlockLimit ) |
|
2084 { |
|
2085 // Block the code |
|
2086 TTime curTime; |
|
2087 curTime.UniversalTime(); |
|
2088 |
|
2089 iConfiguration.iBlockedAtTime.Zero(); |
|
2090 iConfiguration.iBlockedAtTime.AppendNum( curTime.Int64() ); |
|
2091 |
|
2092 // The code will be blocked for now on |
|
2093 ret = KSCPErrCodeBlockStarted; |
|
2094 } |
|
2095 |
|
2096 if ( aFlags & KSCPEtelRequest ) |
|
2097 { |
|
2098 SendInvalidDOSCode( pswCandidate ); |
|
2099 } |
|
2100 } |
|
2101 } |
|
2102 else |
|
2103 { |
|
2104 // iConfiguration.iConfigFlag == KSCPConfigInvalid or KSCPConfigUnknown |
|
2105 |
|
2106 // We might be out-of-sync, no idea about the real code. |
|
2107 // Check if the DOS code hashed from the given code is correct. |
|
2108 Dprint( (_L("CSCPServer::IsCorrectEnhCode(): Attempting to correct OoS situation.") )); |
|
2109 |
|
2110 TRAP( ret, CheckISACodeL( pswCandidate ) ); |
|
2111 |
|
2112 if ( ret == KErrNone ) |
|
2113 { |
|
2114 // OK, we must assume that this is the correct code, since |
|
2115 // the hashed DOS code is correct. Save the codes, and return OK. |
|
2116 |
|
2117 Dprint( (_L("CSCPServer::IsCorrectEnhCode(): Given code has the correct hash (%d)\ |
|
2118 , saving codes."), ISACode )); |
|
2119 |
|
2120 iConfiguration.iEnhSecCode.Zero(); |
|
2121 iConfiguration.iEnhSecCode.Copy( hashBuf ); |
|
2122 |
|
2123 iConfiguration.iSecCode.Zero(); |
|
2124 iConfiguration.iSecCode.AppendNum( ISACode ); |
|
2125 |
|
2126 // Unset the invalid configuration flag |
|
2127 iConfiguration.iConfigFlag = KSCPConfigOK; |
|
2128 writeSetup = ETrue; |
|
2129 } |
|
2130 else |
|
2131 { |
|
2132 |
|
2133 Dprint( (_L("CSCPServer::IsCorrectEnhCode(): Given code does not have the \ |
|
2134 correct hash: ret; %d user enter password: %d"), ret )); |
|
2135 TRAP( ret, CheckISACodeL( aCode ) ); |
|
2136 if (ret == KErrNone) |
|
2137 { |
|
2138 //store this code in our interal storage as it is used as oldpassword while changing at ISA side in next command |
|
2139 //ChangeISACodeL. |
|
2140 iConfiguration.iSecCode.Zero(); |
|
2141 iConfiguration.iSecCode.Append( aCode ); |
|
2142 TRAP(ret,ChangeISACodeL(pswCandidate)); |
|
2143 } |
|
2144 if (ret == KErrNone) |
|
2145 { |
|
2146 iConfiguration.iEnhSecCode.Zero(); |
|
2147 iConfiguration.iEnhSecCode.Copy( hashBuf ); |
|
2148 |
|
2149 iConfiguration.iSecCode.Zero(); |
|
2150 iConfiguration.iSecCode.AppendNum( ISACode ); |
|
2151 |
|
2152 // Unset the invalid configuration flag |
|
2153 iConfiguration.iConfigFlag = KSCPConfigOK; |
|
2154 writeSetup = ETrue; |
|
2155 } |
|
2156 } |
|
2157 } |
|
2158 |
|
2159 // Write setup if needed |
|
2160 if ( writeSetup ) |
|
2161 { |
|
2162 TRAPD( err, iConfiguration.WriteSetupL() ); |
|
2163 if ( err != KErrNone ) |
|
2164 { |
|
2165 Dprint( (_L("CSCPServer::IsCorrectEnhCode(): WARNING:\ |
|
2166 failed to write configuration: %d"), err )); |
|
2167 } |
|
2168 } |
|
2169 |
|
2170 return ret; |
|
2171 } |
|
2172 |
|
2173 |
|
2174 |
|
2175 // --------------------------------------------------------- |
|
2176 // CSCPServer::CheckCodeAndGiveISA() |
|
2177 // Check the given code, and notify the plugins of the result. |
|
2178 // |
|
2179 // Status : Approved |
|
2180 // --------------------------------------------------------- |
|
2181 // |
|
2182 TInt CSCPServer::CheckCodeAndGiveISAL( TDes& aCodeToCheck, |
|
2183 TDes& aISACodeToReturn, |
|
2184 CSCPParamObject*& aRetParams, |
|
2185 TInt aFlags ) |
|
2186 { |
|
2187 |
|
2188 if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
2189 { |
|
2190 return KErrNotSupported; |
|
2191 } |
|
2192 TInt ret = KErrNone; |
|
2193 TInt status = KErrNone; |
|
2194 |
|
2195 // Check the code, note that IsCorrectEnhCode might change the stored code, |
|
2196 // so we'll get the code after the call. |
|
2197 |
|
2198 TBool isSuccessful = EFalse; |
|
2199 |
|
2200 status = IsCorrectEnhCode( aCodeToCheck, aFlags ); |
|
2201 |
|
2202 if ( status == KErrLocked ) |
|
2203 { |
|
2204 // If the code is locked, no attempts count as failed or successful |
|
2205 return status; |
|
2206 } |
|
2207 else if ( status == KErrNone ) |
|
2208 { |
|
2209 // OK, successful authentication |
|
2210 TSCPSecCode realCode; |
|
2211 ret = GetCode( realCode ); |
|
2212 |
|
2213 User::LeaveIfError( ret ); |
|
2214 |
|
2215 aISACodeToReturn.Copy( realCode ); |
|
2216 isSuccessful = ETrue; |
|
2217 } |
|
2218 else // KSCPErrCodeBlockStarted or KErrAccessDenied |
|
2219 { |
|
2220 // Authentication attempt failed |
|
2221 TSCPSecCode realCode; |
|
2222 ret = GetCode( realCode ); |
|
2223 |
|
2224 User::LeaveIfError( ret ); |
|
2225 |
|
2226 TSCPSecCode fakeCode; |
|
2227 do |
|
2228 { |
|
2229 // Create a fake code, which is between 10000-99999 |
|
2230 fakeCode.Zero(); |
|
2231 TUint32 code = Math::Random(); |
|
2232 code = code % 90000 + 10000; |
|
2233 fakeCode.AppendNum( code ); |
|
2234 } while ( fakeCode.Compare( realCode ) == 0 ); |
|
2235 |
|
2236 aISACodeToReturn.Copy( fakeCode ); |
|
2237 |
|
2238 if ( status == KSCPErrCodeBlockStarted ) |
|
2239 { |
|
2240 status = KErrLocked; // Set this as the external error code |
|
2241 } |
|
2242 } |
|
2243 |
|
2244 // Send information about the authentication attempt to the plugins |
|
2245 CSCPParamObject* inParams = CSCPParamObject::NewL(); |
|
2246 CleanupStack::PushL( inParams ); |
|
2247 inParams->Set( KSCPParamContext, KSCPContextQueryPsw ); |
|
2248 |
|
2249 if ( isSuccessful ) |
|
2250 { |
|
2251 // Authentication successful |
|
2252 inParams->Set( KSCPParamStatus, KErrNone ); |
|
2253 } |
|
2254 else |
|
2255 { |
|
2256 // Authentication failed |
|
2257 inParams->Set( KSCPParamStatus, KErrAccessDenied ); |
|
2258 } |
|
2259 |
|
2260 CSCPParamObject* repParams = |
|
2261 iPluginManager->PostEvent( KSCPEventAuthenticationAttempted, *inParams ); |
|
2262 |
|
2263 CleanupStack::PopAndDestroy( inParams ); |
|
2264 |
|
2265 if ( repParams != NULL ) |
|
2266 { |
|
2267 // No status information here, just propagate the paramobject |
|
2268 aRetParams = repParams; // pointer ownership changed |
|
2269 } |
|
2270 |
|
2271 return status; |
|
2272 } |
|
2273 |
|
2274 |
|
2275 |
|
2276 |
|
2277 // --------------------------------------------------------- |
|
2278 // CSCPServer::CheckAndChangeEnhCodeL() |
|
2279 // Check the given code, and if correct, send it to the plugins |
|
2280 // for validation. |
|
2281 // |
|
2282 // Status : Approved |
|
2283 // --------------------------------------------------------- |
|
2284 // |
|
2285 TInt CSCPServer::CheckAndChangeEnhCodeL( TDes& aOldPass, |
|
2286 TDes& aNewPass, |
|
2287 CSCPParamObject*& aRetParams, |
|
2288 TSCPSecCode& aNewDOSCode ) |
|
2289 { |
|
2290 |
|
2291 if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
2292 { |
|
2293 return KErrNotSupported; |
|
2294 } |
|
2295 TInt ret = KErrNone; |
|
2296 |
|
2297 ret = IsCorrectEnhCode( aOldPass, 0 ); |
|
2298 if ( ret == KErrNone ) |
|
2299 { |
|
2300 // Authentication successful |
|
2301 CSCPParamObject* inParams = CSCPParamObject::NewL(); |
|
2302 CleanupStack::PushL( inParams ); |
|
2303 |
|
2304 inParams->Set( KSCPParamStatus, KErrNone ); |
|
2305 inParams->Set( KSCPParamContext, KSCPContextChangePsw ); |
|
2306 CSCPParamObject* repParams = |
|
2307 iPluginManager->PostEvent( KSCPEventAuthenticationAttempted, *inParams ); |
|
2308 |
|
2309 if ( repParams != NULL ) |
|
2310 { |
|
2311 // Ignore the return params at this point |
|
2312 delete repParams; |
|
2313 } |
|
2314 |
|
2315 inParams->Reset(); |
|
2316 |
|
2317 // Validate the code |
|
2318 inParams->Set( KSCPParamPassword, aNewPass ); |
|
2319 |
|
2320 repParams = iPluginManager->PostEvent( KSCPEventValidate, *inParams ); |
|
2321 |
|
2322 CleanupStack::PopAndDestroy( inParams ); |
|
2323 |
|
2324 if ( repParams != NULL ) |
|
2325 { |
|
2326 // Check if the validation failed |
|
2327 TInt status; |
|
2328 if ( repParams->Get( KSCPParamStatus, status ) == KErrNone ) |
|
2329 { |
|
2330 if ( status != KErrNone ) |
|
2331 { |
|
2332 ret = status; |
|
2333 } |
|
2334 } |
|
2335 |
|
2336 aRetParams = repParams; // pointer ownership changed |
|
2337 } |
|
2338 |
|
2339 // Set the new code, if it was OK |
|
2340 if ( ret == KErrNone ) |
|
2341 { |
|
2342 if ( IsValidEnhCode( aNewPass ) ) |
|
2343 { |
|
2344 ret = StoreEnhCode( aNewPass, &aNewDOSCode ); |
|
2345 } |
|
2346 else |
|
2347 { |
|
2348 // Invalid code format! Should not happen at this point, but make sure. |
|
2349 ret = KErrArgument; |
|
2350 } |
|
2351 |
|
2352 if ( ret == KErrNone ) |
|
2353 { |
|
2354 CSCPParamObject* inParams = CSCPParamObject::NewL(); |
|
2355 CleanupStack::PushL( inParams ); |
|
2356 inParams->Set( KSCPParamPassword, aNewPass ); |
|
2357 |
|
2358 CSCPParamObject* repParams = |
|
2359 iPluginManager->PostEvent( KSCPEventPasswordChanged, *inParams ); |
|
2360 |
|
2361 CleanupStack::PopAndDestroy( inParams ); |
|
2362 |
|
2363 if ( repParams != NULL ) |
|
2364 { |
|
2365 // Ignore the return params at this point |
|
2366 delete repParams; |
|
2367 } |
|
2368 } |
|
2369 } |
|
2370 } |
|
2371 else |
|
2372 { |
|
2373 if ( ( ret == KErrAccessDenied ) || ( ret == KSCPErrCodeBlockStarted ) ) |
|
2374 { |
|
2375 // Authentication failed |
|
2376 CSCPParamObject* inParams = CSCPParamObject::NewL(); |
|
2377 CleanupStack::PushL( inParams ); |
|
2378 |
|
2379 inParams->Set( KSCPParamStatus, KErrAccessDenied ); |
|
2380 inParams->Set( KSCPParamContext, KSCPContextChangePsw ); |
|
2381 CSCPParamObject* repParams = |
|
2382 iPluginManager->PostEvent( KSCPEventAuthenticationAttempted, *inParams ); |
|
2383 |
|
2384 CleanupStack::PopAndDestroy( inParams ); |
|
2385 |
|
2386 if ( repParams != NULL ) |
|
2387 { |
|
2388 // No status information here, just propagate the paramobject |
|
2389 aRetParams = repParams; // pointer ownership changed |
|
2390 } |
|
2391 |
|
2392 if ( ret == KSCPErrCodeBlockStarted ) |
|
2393 { |
|
2394 ret = KErrLocked; // Set this as the external error code |
|
2395 } |
|
2396 } |
|
2397 } |
|
2398 |
|
2399 return ret; |
|
2400 } |
|
2401 |
|
2402 |
|
2403 |
|
2404 |
|
2405 // --------------------------------------------------------- |
|
2406 // CSCPServer::GetEventHandlerL() |
|
2407 // Return a pointer to the event handler object. |
|
2408 // |
|
2409 // Status : Approved |
|
2410 // --------------------------------------------------------- |
|
2411 // |
|
2412 MSCPPluginEventHandler* CSCPServer::GetEventHandlerL() |
|
2413 { |
|
2414 if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
2415 { |
|
2416 return NULL; |
|
2417 } |
|
2418 return iPluginEventHandler; |
|
2419 } |
|
2420 |
|
2421 |
|
2422 |
|
2423 // --------------------------------------------------------- |
|
2424 // CSCPServer::IsPasswordChangeAllowedL() |
|
2425 // Check from the plugins if the password is allowed to be changed. |
|
2426 // |
|
2427 // Status : Approved |
|
2428 // --------------------------------------------------------- |
|
2429 |
|
2430 TInt CSCPServer::IsPasswordChangeAllowedL( CSCPParamObject*& aRetParams ) |
|
2431 { |
|
2432 |
|
2433 if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
2434 { |
|
2435 return KErrNotSupported; |
|
2436 } |
|
2437 TInt ret = KErrNone; |
|
2438 |
|
2439 // Post the event to the plugins to find out if the password can |
|
2440 // be changed |
|
2441 |
|
2442 CSCPParamObject* inParams = CSCPParamObject::NewL(); |
|
2443 CleanupStack::PushL( inParams ); |
|
2444 |
|
2445 // No additional parameters |
|
2446 |
|
2447 CSCPParamObject* repParams = |
|
2448 iPluginManager->PostEvent( KSCPEventPasswordChangeQuery, *inParams ); |
|
2449 |
|
2450 CleanupStack::PopAndDestroy( inParams ); |
|
2451 |
|
2452 if ( repParams != NULL ) |
|
2453 { |
|
2454 // Check status |
|
2455 TInt status; |
|
2456 if ( repParams->Get( KSCPParamStatus, status ) == KErrNone ) |
|
2457 { |
|
2458 if ( status != KErrNone ) |
|
2459 { |
|
2460 ret = status; |
|
2461 } |
|
2462 } |
|
2463 |
|
2464 aRetParams = repParams; // pointer ownership changed |
|
2465 } |
|
2466 |
|
2467 return ret; |
|
2468 } |
|
2469 |
|
2470 |
|
2471 // --------------------------------------------------------- |
|
2472 // CSCPServer::IsDeviceMemoryEncrypted |
|
2473 // Checks if phone memory is encrypted or not. |
|
2474 // --------------------------------------------------------- |
|
2475 TBool CSCPServer::IsDeviceMemoryEncrypted() |
|
2476 { |
|
2477 Dprint(_L("CSCPServer::IsDeviceMemoryEncrypted >>")); |
|
2478 |
|
2479 TBool ret(EFalse); |
|
2480 |
|
2481 //First check if the feature is supported on device |
|
2482 TRAPD(ferr, FeatureManager::InitializeLibL()); |
|
2483 if (ferr != KErrNone) |
|
2484 { |
|
2485 Dprint(_L("feature mgr initialization error, %d"), ferr); |
|
2486 return EFalse; |
|
2487 } |
|
2488 ret = FeatureManager::FeatureSupported( KFeatureIdFfDeviceEncryptionFeature); |
|
2489 FeatureManager::UnInitializeLib(); |
|
2490 |
|
2491 //If feature is supported, check if any drive is encrypted. |
|
2492 if (ret) |
|
2493 { |
|
2494 CDevEncSession* devEncSession = new CDevEncSession( EDriveC ); |
|
2495 |
|
2496 if (!devEncSession) |
|
2497 { |
|
2498 Dprint(_L("Can't instantiate device encryption session..")); |
|
2499 return EFalse; |
|
2500 } |
|
2501 |
|
2502 TInt err = devEncSession->Connect(); |
|
2503 if (err == KErrNone) |
|
2504 { |
|
2505 //Session with device encryption is established. Check if any drive is encrypted |
|
2506 TInt encStatus (KErrNone); |
|
2507 TInt err = devEncSession->DiskStatus( encStatus ); |
|
2508 Dprint(_L("err = %d, encstatus = %d"), err, encStatus); |
|
2509 if ( err == KErrNone && encStatus != EDecrypted ) |
|
2510 { |
|
2511 Dprint(_L("Memory is encrypted")); |
|
2512 ret = ETrue; |
|
2513 } |
|
2514 else |
|
2515 { |
|
2516 Dprint(_L("Memory is not encrypted")); |
|
2517 ret = EFalse; |
|
2518 } |
|
2519 } |
|
2520 else |
|
2521 { |
|
2522 Dprint(_L("Error %d while establishing connection with device encryption engine"), err); |
|
2523 ret = EFalse; |
|
2524 } |
|
2525 |
|
2526 delete devEncSession; devEncSession = NULL; |
|
2527 } |
|
2528 |
|
2529 Dprint(_L("CSCPServer::IsDeviceMemoryEncrypted, ret = %d <<"), ret); |
|
2530 return ret; |
|
2531 } |
|
2532 |
|
2533 |
|
2534 /** |
|
2535 * Sets the best policy for the parameters that are under conflict. This is part of changes done for MFE-requirement part3. |
|
2536 * @params aID: The ID of the parameter that needs to be set |
|
2537 * aValue: Value of the parameter identified in aID |
|
2538 * aCalledIdentity: The UID of the called application/process |
|
2539 * |
|
2540 * @return TInt: KErrNone is successful, otherwise a system error code |
|
2541 */ |
|
2542 TInt CSCPServer :: SetBestPolicyL( TInt aID, const TDesC& aValue, TUint32 aCallerIdentity, CSCPParamDBController* aParamDB ) { |
|
2543 Dprint( (_L("[CSCPServer]-> SetBestPolicyL() >>>"))); |
|
2544 Dprint( (_L("[CSCPServer]-> ParamID=%d "), aID, aValue)); |
|
2545 Dprint( (_L("[CSCPServer]-> ParamValue=%d "), aValue)); |
|
2546 |
|
2547 TBool lFirstTime(EFalse); |
|
2548 TInt32 lNumValue (-1); |
|
2549 TInt32 lNumValDB (-1); |
|
2550 TInt32 lRetStatus = KErrNone; |
|
2551 |
|
2552 switch(aID) { |
|
2553 case RTerminalControl3rdPartySession :: EMaxTimeout: |
|
2554 case RTerminalControl3rdPartySession :: EPasscodeMinLength: |
|
2555 case RTerminalControl3rdPartySession :: EPasscodeMaxLength: |
|
2556 case RTerminalControl3rdPartySession :: EPasscodeRequireUpperAndLower: |
|
2557 case RTerminalControl3rdPartySession :: EPasscodeRequireCharsAndNumbers: |
|
2558 case RTerminalControl3rdPartySession :: EPasscodeExpiration: |
|
2559 case RTerminalControl3rdPartySession :: EPasscodeMaxRepeatedCharacters: |
|
2560 case RTerminalControl3rdPartySession :: EPasscodeMinChangeTolerance: |
|
2561 case RTerminalControl3rdPartySession :: EPasscodeMinChangeInterval: |
|
2562 case RTerminalControl3rdPartySession :: EPasscodeCheckSpecificStrings: |
|
2563 case RTerminalControl3rdPartySession :: EPasscodeMaxAttempts: |
|
2564 case RTerminalControl3rdPartySession :: EPasscodeConsecutiveNumbers: |
|
2565 case RTerminalControl3rdPartySession :: EPasscodeHistoryBuffer: |
|
2566 case RTerminalControl3rdPartySession :: EPasscodeMinSpecialCharacters: |
|
2567 case RTerminalControl3rdPartySession :: EPasscodeDisallowSimple: |
|
2568 break; |
|
2569 case RTerminalControl3rdPartySession :: EPasscodeClearSpecificStrings: |
|
2570 case RTerminalControl3rdPartySession :: EPasscodeDisallowSpecific: |
|
2571 case RTerminalControl3rdPartySession :: EPasscodeAllowSpecific: |
|
2572 return KErrNotSupported; |
|
2573 default: |
|
2574 // No best policy check required for parameters other than the above 19 (Only 19 of the current parameters conflict!) |
|
2575 TUint16* ptr = const_cast<TUint16*>( aValue.Ptr()); |
|
2576 TPtr valBuf( ptr, aValue.Length(), aValue.Length()); |
|
2577 lRetStatus = iPluginEventHandler->GetParameters().Set( aID, valBuf); |
|
2578 return lRetStatus; |
|
2579 } |
|
2580 |
|
2581 TLex lex( aValue ); |
|
2582 // Convert the parameter value to its numeric equivalent |
|
2583 if (lex.Val( lNumValue ) != KErrNone) { |
|
2584 return KErrArgument; |
|
2585 } |
|
2586 |
|
2587 if(iOverrideForCleanup) { |
|
2588 Dprint( _L("[CSCPServer]-> SetBestPolicy() Overriding decision logic...")); |
|
2589 lRetStatus = aParamDB->DropValuesL(aID); |
|
2590 } |
|
2591 else { |
|
2592 // Fetch the previous value of the parameter from the private database |
|
2593 switch(aID) { |
|
2594 case RTerminalControl3rdPartySession :: EMaxTimeout: |
|
2595 case RTerminalControl3rdPartySession :: EPasscodeMinLength: |
|
2596 case RTerminalControl3rdPartySession :: EPasscodeMaxLength: |
|
2597 case RTerminalControl3rdPartySession :: EPasscodeRequireUpperAndLower: |
|
2598 case RTerminalControl3rdPartySession :: EPasscodeRequireCharsAndNumbers: |
|
2599 case RTerminalControl3rdPartySession :: EPasscodeExpiration: |
|
2600 case RTerminalControl3rdPartySession :: EPasscodeMaxRepeatedCharacters: |
|
2601 case RTerminalControl3rdPartySession :: EPasscodeMinChangeTolerance: |
|
2602 case RTerminalControl3rdPartySession :: EPasscodeMinChangeInterval: |
|
2603 case RTerminalControl3rdPartySession :: EPasscodeCheckSpecificStrings: |
|
2604 case RTerminalControl3rdPartySession :: EPasscodeMaxAttempts: |
|
2605 case RTerminalControl3rdPartySession :: EPasscodeConsecutiveNumbers: |
|
2606 case RTerminalControl3rdPartySession :: EPasscodeHistoryBuffer: |
|
2607 case RTerminalControl3rdPartySession :: EPasscodeMinSpecialCharacters: |
|
2608 case RTerminalControl3rdPartySession :: EPasscodeDisallowSimple: { |
|
2609 Dprint( (_L("[CSCPServer]-> Fetching the value of parameter '%d' from private database..."), aID)); |
|
2610 |
|
2611 TInt32 lAppID; |
|
2612 |
|
2613 lRetStatus = aParamDB->GetValueL(aID, lNumValDB, lAppID); |
|
2614 |
|
2615 switch(lRetStatus) { |
|
2616 case KErrNotFound: { |
|
2617 TInt lLSValue(0); |
|
2618 lFirstTime = ETrue; |
|
2619 |
|
2620 switch(aID) { |
|
2621 case RTerminalControl3rdPartySession :: EMaxTimeout: |
|
2622 case RTerminalControl3rdPartySession :: EPasscodeMaxRepeatedCharacters: |
|
2623 case RTerminalControl3rdPartySession :: EPasscodeExpiration: |
|
2624 case RTerminalControl3rdPartySession :: EPasscodeMinChangeTolerance: |
|
2625 case RTerminalControl3rdPartySession :: EPasscodeMinChangeInterval: |
|
2626 case RTerminalControl3rdPartySession :: EPasscodeMaxAttempts: |
|
2627 case RTerminalControl3rdPartySession :: EPasscodeMaxLength: |
|
2628 case RTerminalControl3rdPartySession :: EPasscodeDisallowSimple: |
|
2629 /* For these parameters, if it is the first time that the values are being |
|
2630 set then no decision is imposed regarding the best policy... |
|
2631 */ |
|
2632 break; |
|
2633 default: |
|
2634 // Get the default values for the parameter... |
|
2635 lRetStatus = iPluginEventHandler->GetParameters().Get(aID, lLSValue); |
|
2636 break; |
|
2637 } |
|
2638 |
|
2639 lNumValDB = lLSValue; |
|
2640 Dprint((_L("[CSCPServer]-> Unable to fetch the value of parameter '%d' from private database, value from internal tree=%d"), aID, lLSValue)); |
|
2641 } |
|
2642 break; |
|
2643 case KErrNone: |
|
2644 break; |
|
2645 default: |
|
2646 Dprint((_L("[CSCPServer]-> Failed to fetch parameter '%d' from the private database. ErrCode=%d"), aID, lRetStatus)); |
|
2647 return lRetStatus; |
|
2648 } |
|
2649 break; |
|
2650 } |
|
2651 } |
|
2652 |
|
2653 if(lNumValue == lNumValDB) { |
|
2654 Dprint(_L("[CSCPServer]-> INFO: New parameter value and value from the database are the same. Overriding SetBestPolicy()...")); |
|
2655 return KErrNone; |
|
2656 } |
|
2657 |
|
2658 lRetStatus = KErrNone; |
|
2659 |
|
2660 // Decision code that verifies if policy is strongest |
|
2661 switch(aID) { |
|
2662 case RTerminalControl3rdPartySession :: EMaxTimeout: |
|
2663 case RTerminalControl3rdPartySession :: EPasscodeMaxRepeatedCharacters: |
|
2664 case RTerminalControl3rdPartySession :: EPasscodeExpiration: |
|
2665 case RTerminalControl3rdPartySession :: EPasscodeMinChangeTolerance: |
|
2666 case RTerminalControl3rdPartySession :: EPasscodeMinChangeInterval: |
|
2667 case RTerminalControl3rdPartySession :: EPasscodeMaxAttempts: |
|
2668 if(!lFirstTime && ((lNumValue > lNumValDB) || (lNumValue == 0))) { |
|
2669 lRetStatus = KErrArgument; |
|
2670 } |
|
2671 break; |
|
2672 case RTerminalControl3rdPartySession :: EPasscodeMaxLength: |
|
2673 if(!lFirstTime && (lNumValue < lNumValDB)) { |
|
2674 lRetStatus = KErrArgument; |
|
2675 } |
|
2676 break; |
|
2677 case RTerminalControl3rdPartySession :: EPasscodeMinLength: |
|
2678 case RTerminalControl3rdPartySession :: EPasscodeHistoryBuffer: |
|
2679 case RTerminalControl3rdPartySession :: EPasscodeMinSpecialCharacters: |
|
2680 if(lNumValue < lNumValDB) { |
|
2681 lRetStatus = KErrArgument; |
|
2682 } |
|
2683 break; |
|
2684 case RTerminalControl3rdPartySession :: EPasscodeRequireUpperAndLower: |
|
2685 case RTerminalControl3rdPartySession :: EPasscodeRequireCharsAndNumbers: |
|
2686 case RTerminalControl3rdPartySession :: EPasscodeCheckSpecificStrings: |
|
2687 case RTerminalControl3rdPartySession :: EPasscodeConsecutiveNumbers: |
|
2688 case RTerminalControl3rdPartySession :: EPasscodeDisallowSimple: |
|
2689 if(lNumValue == false && lNumValDB == true) { |
|
2690 lRetStatus = KErrArgument; |
|
2691 } |
|
2692 break; |
|
2693 } |
|
2694 |
|
2695 if(lRetStatus != KErrNone) { |
|
2696 return KErrArgument; |
|
2697 } |
|
2698 |
|
2699 // Update the best policy to the DB as well as the local storage tree |
|
2700 Dprint((_L("[CSCPServer]-> Updating the value of parameter '%d' to private database...UID=%d"), aID, aCallerIdentity)); |
|
2701 |
|
2702 lRetStatus = aParamDB->SetValueL(aID, lNumValue, aCallerIdentity); |
|
2703 } |
|
2704 |
|
2705 Dprint(_L("[CSCPServer]-> lRetStatus after DB operation = %d "), lRetStatus); |
|
2706 /* Update is NOT ATOMIC!!! |
|
2707 * If the earlier aParamDB->SetValueL() was successful, there is a chance that |
|
2708 * the config.ini and the DB are out of sync if the operation iConfiguration.WriteSetupL() |
|
2709 * is not successful (disk space not enough etc) or when the WriteToFileL() in ParamObject |
|
2710 * from iPluginEventHandler->GetParameters() fails. |
|
2711 * (WriteToFileL() is called in some destructor when the SCPServer terminates) |
|
2712 */ |
|
2713 if (lRetStatus == KErrNone) { |
|
2714 switch (aID) { |
|
2715 case RTerminalControl3rdPartySession :: EMaxTimeout: |
|
2716 iConfiguration.iMaxTimeout = lNumValue; |
|
2717 lRetStatus = iConfiguration.WriteSetupL(); |
|
2718 Dprint(_L("[CSCPServer]-> After setting EMaxTimeout lRetStatus = %d "), lRetStatus); |
|
2719 break; |
|
2720 default: |
|
2721 TUint16* ptr = const_cast<TUint16*>(aValue.Ptr()); |
|
2722 TPtr valBuf(ptr, aValue.Length(), aValue.Length()); |
|
2723 lRetStatus = iPluginEventHandler->GetParameters().Set(aID, valBuf); |
|
2724 Dprint(_L("[CSCPServer]-> After setting (%d ) lRetStatus = %d "), aID, lRetStatus); |
|
2725 break; |
|
2726 } |
|
2727 } |
|
2728 |
|
2729 Dprint(_L("[CSCPServer]-> SetBestPolicyL() lRetStatus = %d <<<"), lRetStatus); |
|
2730 return lRetStatus; |
|
2731 } |
|
2732 |
|
2733 TInt CSCPServer :: PerformCleanupL(HBufC8* aAppIDBuffer, RArray<const TParamChange>& aChangeArray, RPointerArray<HBufC8>& aParamValArray) { |
|
2734 Dprint( (_L("[CSCPServer]-> PerformCleanupL() >>>"))); |
|
2735 |
|
2736 if(!aAppIDBuffer) { |
|
2737 return KErrArgument; |
|
2738 } |
|
2739 |
|
2740 TInt32 lAppCount = aAppIDBuffer->Length(); |
|
2741 |
|
2742 if(lAppCount < 1) { |
|
2743 return KErrArgument; |
|
2744 } |
|
2745 |
|
2746 lAppCount /= sizeof(TInt32); |
|
2747 |
|
2748 TPtr8 bufPtr = aAppIDBuffer->Des(); |
|
2749 |
|
2750 TInt lStatus(KErrNone); |
|
2751 CSCPParamDBController* lParamDB = CSCPParamDBController :: NewLC(); |
|
2752 |
|
2753 RDesReadStream lBufReadStream(bufPtr); |
|
2754 CleanupClosePushL(lBufReadStream); |
|
2755 |
|
2756 Dprint(_L("[CSCPServer]-> INFO: Total items received for cleanup is %d"), lAppCount); |
|
2757 |
|
2758 RArray <TInt> lParamIds; |
|
2759 CleanupClosePushL(lParamIds); |
|
2760 |
|
2761 TBool lSubOpsFailed = EFalse; |
|
2762 HBufC* lDefValueBuf = HBufC :: NewLC(20); |
|
2763 |
|
2764 // Loop through each of the byte packed application ID's specified in aAppIDBuffer and clean them up iteratively |
|
2765 for(TInt i=0; i < lAppCount; i++) { |
|
2766 TInt32 lAppID = lBufReadStream.ReadInt32L(); |
|
2767 Dprint((_L("[CSCPServer]-> Initiating cleanup on %d "), lAppID)); |
|
2768 |
|
2769 |
|
2770 lParamIds.Reset(); |
|
2771 lStatus = lParamDB->ListParamsUsedByAppL(lParamIds, lAppID); |
|
2772 |
|
2773 Dprint(_L("[CSCPServer]-> Status of ListParamsUsedByAppL() = %d"), lStatus); |
|
2774 |
|
2775 TInt lCount = lParamIds.Count(); |
|
2776 |
|
2777 Dprint(_L("[CSCPServer]-> lCount=%d"), lCount); |
|
2778 |
|
2779 // Make sure that LockCodeMinChangeTolerance is always cleanedup before LockCodeHistoryBuffer |
|
2780 if(lCount > 1) { |
|
2781 Dprint(_L("[CSCPServer]-> Updating the cleanup order for EPasscodeMinChangeTolerance and EPasscodeHistoryBuffer if needed...")); |
|
2782 TInt lHistBuffIndex = -1; |
|
2783 TInt lMinTolIndex = -1; |
|
2784 |
|
2785 for(TInt i=0; i < lCount; i++) { |
|
2786 if(lHistBuffIndex >= 0 && lMinTolIndex >= 0) { |
|
2787 // If both the indexes have been found, stop the search |
|
2788 break; |
|
2789 } |
|
2790 |
|
2791 switch(lParamIds[i]) { |
|
2792 case RTerminalControl3rdPartySession :: EPasscodeMinChangeTolerance: |
|
2793 lMinTolIndex = i; |
|
2794 break; |
|
2795 case RTerminalControl3rdPartySession :: EPasscodeHistoryBuffer: |
|
2796 lHistBuffIndex = i; |
|
2797 break; |
|
2798 } |
|
2799 } |
|
2800 |
|
2801 // This step is required only if both the parameters are marked for cleanup |
|
2802 if(lHistBuffIndex >= 0 && lMinTolIndex >= 0) { |
|
2803 /* Switch the cleanup order of the two parameters |
|
2804 * This step is needed because ListParamsUsedByAppL() always returns the parameters |
|
2805 * in Ascending order and because LockCodeMinChangeTolerance is always required to be |
|
2806 * cleanedup before LockCodeHistoryBuffer |
|
2807 */ |
|
2808 lParamIds[lHistBuffIndex] = RTerminalControl3rdPartySession :: EPasscodeMinChangeTolerance; |
|
2809 lParamIds[lMinTolIndex] = RTerminalControl3rdPartySession :: EPasscodeHistoryBuffer; |
|
2810 Dprint(_L("[CSCPServer]-> Switching the cleanup order of EPasscodeHistoryBuffer and EPasscodeMinChangeTolerance")); |
|
2811 Dprint(_L("[CSCPServer]-> Old Index of EPasscodeHistoryBuffer=%d"), lHistBuffIndex); |
|
2812 Dprint(_L("[CSCPServer]-> Old Index of EPasscodeMinChangeTolerance=%d"), lMinTolIndex); |
|
2813 } |
|
2814 } |
|
2815 |
|
2816 for(TInt j=0; j < lCount; j++) { |
|
2817 TInt lCurrParamID = lParamIds[j]; |
|
2818 lDefValueBuf->Des().Zero(); |
|
2819 lDefValueBuf->Des().Format(_L("%d "), 0); |
|
2820 // Initialize the default values here... |
|
2821 switch(lCurrParamID) { |
|
2822 case RTerminalControl3rdPartySession :: EMaxTimeout: |
|
2823 // lDefValueBuf already has the default value, 0 initialized... |
|
2824 lCurrParamID = ESCPMaxAutolockPeriod; |
|
2825 break; |
|
2826 case RTerminalControl3rdPartySession :: EPasscodeMinLength: |
|
2827 lDefValueBuf->Des().Format(_L("%d"), 4); |
|
2828 break; |
|
2829 case RTerminalControl3rdPartySession :: EPasscodeMaxLength: |
|
2830 lDefValueBuf->Des().Format(_L("%d"), 255); |
|
2831 break; |
|
2832 default: |
|
2833 // lDefValueBuf already has the default value, 0 initialized... |
|
2834 break; |
|
2835 } |
|
2836 |
|
2837 switch(lCurrParamID) { |
|
2838 case RTerminalControl3rdPartySession :: EPasscodeDisallowSpecific: { |
|
2839 RPointerArray<HBufC> lDesArr; |
|
2840 CleanupClosePushL(lDesArr); |
|
2841 |
|
2842 lStatus = lParamDB->GetValuesL(lCurrParamID, lDesArr, lAppID); |
|
2843 |
|
2844 if(KErrNone == lStatus) { |
|
2845 iOverrideForCleanup = ETrue; |
|
2846 TInt lDesCount = lDesArr.Count(); |
|
2847 |
|
2848 for(TInt k=0; k < lDesCount; k++) { |
|
2849 TRAP(lStatus, lStatus = SetParameterValueL(lCurrParamID, lDesArr[k]->Des(), lAppID)); |
|
2850 if(KErrNone != lStatus) { |
|
2851 Dprint(_L("[CSCPServer]-> ERROR: Unable to cleanup parameter %d error %d"), lParamIds[j], lStatus); |
|
2852 lSubOpsFailed = ETrue; |
|
2853 } |
|
2854 } |
|
2855 |
|
2856 iOverrideForCleanup = EFalse; |
|
2857 } |
|
2858 |
|
2859 lDesArr.ResetAndDestroy(); |
|
2860 CleanupStack :: PopAndDestroy(1); // lDesArray |
|
2861 } |
|
2862 break; |
|
2863 default: { |
|
2864 iOverrideForCleanup = ETrue; |
|
2865 TRAP(lStatus, lStatus = SetParameterValueL(lCurrParamID, lDefValueBuf->Des(), lAppID)); |
|
2866 iOverrideForCleanup = EFalse; |
|
2867 |
|
2868 if(KErrNone == lStatus) { |
|
2869 HBufC8* lTmpBuffer = HBufC8 :: NewL(lDefValueBuf->Length()); |
|
2870 lTmpBuffer->Des().Copy(lDefValueBuf->Des()); |
|
2871 |
|
2872 const TParamChange lChange(lParamIds[j], lTmpBuffer->Des()); |
|
2873 aChangeArray.AppendL(lChange); |
|
2874 |
|
2875 // No need to destroy lTmpBuffer, it will be cleaned up by the caller (on cleanup of aParamValArray) |
|
2876 aParamValArray.AppendL(lTmpBuffer); |
|
2877 } |
|
2878 } |
|
2879 } |
|
2880 |
|
2881 if(KErrNone != lStatus) { |
|
2882 Dprint(_L("[CSCPServer]-> ERROR: Unable to cleanup parameter %d error %d"), lParamIds[j], lStatus); |
|
2883 lSubOpsFailed = ETrue; |
|
2884 } |
|
2885 } |
|
2886 } |
|
2887 |
|
2888 Dprint( (_L("[CSCPServer]-> PerformCleanupL() <<<"))); |
|
2889 CleanupStack :: PopAndDestroy(4); // lParamIds lParamDB lBufReadStream lDefValueBuf |
|
2890 return (lSubOpsFailed) ? KErrGeneral : KErrNone; |
|
2891 } |
|
2892 |
|
2893 //#endif // __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
2894 // <<<< ********************** NEW FEATURES ******************** |
|
2895 |
|
2896 // ================= OTHER EXPORTED FUNCTIONS ============== |
|
2897 |
|
2898 // __ARMI__ / |
|
2899 |
|
2900 // --------------------------------------------------------- |
|
2901 // E32Main EXE entry point |
|
2902 // Returns: TInt: Process exit value |
|
2903 // |
|
2904 // Status : Approved |
|
2905 // --------------------------------------------------------- |
|
2906 // |
|
2907 GLDEF_C TInt E32Main() |
|
2908 { |
|
2909 return CSCPServer::ThreadFunction(NULL); |
|
2910 } |
|
2911 |
|
2912 |
|
2913 |
|
2914 // End of File |
|
2915 |