666 // Status : Approved |
650 // Status : Approved |
667 // --------------------------------------------------------- |
651 // --------------------------------------------------------- |
668 // |
652 // |
669 void CSCPServer::ValidateConfigurationL( TInt aMode ) |
653 void CSCPServer::ValidateConfigurationL( TInt aMode ) |
670 { |
654 { |
671 Dprint( (_L("--> CSCPServer::ValidateConfigurationL()") )); |
655 if (aMode == KSCPInitial) { |
672 RDebug::Print(_L("--> CSCPServer::ValidateConfigurationL()")); |
656 // Return here, must be checked by complete mode |
673 TInt startupReason(ENormalStartup); |
657 RDebug::Print(_L("--> CSCPServer::ValidateConfigurationL()@@aMode == KSCPInitial ")); |
674 RProperty::Get(KPSUidStartup, KPSStartupReason, startupReason); |
658 User::Leave(KErrAccessDenied); |
675 Dprint( (_L("CSCPServer::ValidateConfigurationL(): startupReason = %d"), startupReason)); |
659 } |
676 if((startupReason == ENormalRFSReset)||(startupReason == EDeepRFSReset)||(startupReason == EFirmwareUpdate)||(iConfiguration.iConfigFlag == KSCPConfigUnknown)) |
660 |
677 { |
661 RMobilePhone::TMobilePassword storedCode; |
678 |
|
679 RMobilePhone::TMobilePassword storedCode; |
|
680 storedCode.Zero(); |
662 storedCode.Zero(); |
681 User::LeaveIfError(GetCode(storedCode)); |
663 User::LeaveIfError(GetCode(storedCode)); |
682 |
664 TBool isDefaultLockcode = ETrue; |
683 |
665 TInt err = KErrNone; |
684 Dprint( (_L("CSCPServer::ValidateConfigurationL(): Checking code: %s"), storedCode.PtrZ() )); |
666 |
685 // Check that the ISA code is stored correctly |
667 RMobilePhone::TMobilePassword defaultLockcode; |
686 TRAPD( err, CheckISACodeL( storedCode ) ); |
668 defaultLockcode.Zero(); |
687 //Bool for the correction of Defaultlockcode cenrep |
669 defaultLockcode.Copy(KSCPDefaultSecCode); |
688 TBool lCorrectDefaultlockcode = EFalse; |
670 if (storedCode.Compare(KSCPDefaultSecCode) == 0) { |
689 |
671 RDebug::Print(_L("--> CSCPServer::ValidateConfigurationL()@config has KSCPDefaultSecCode ")); |
690 Dprint( (_L("CSCPServer::ValidateConfigurationL(): iConfigFlag = %d, iConfigChecked = %d"), iConfiguration.iConfigFlag, iConfiguration.iConfigChecked)); |
672 TRAP( err, CheckISACodeL( defaultLockcode ) ); |
691 |
673 if (err == KErrNone) { |
692 if ((iConfiguration.iConfigFlag == KSCPConfigOK) |
674 RDebug::Print(_L("--> CSCPServer::ValidateConfigurationL()@ISA also has KSCPDefaultSecCode ")); |
693 && (iConfiguration.iConfigChecked) && (err == KErrNone)) |
675 iConfiguration.iConfigFlag = KSCPConfigOK; |
694 { |
676 isDefaultLockcode = ETrue; |
695 // The configuration has already been checked, exit |
677 } |
696 Dprint( (_L("CSCPServer::ValidateConfigurationL(): Configuration is non-default.") )); |
678 else { |
697 User::Leave( KErrNone ); |
679 RDebug::Print(_L("--> CSCPServer::ValidateConfigurationL()@ISA doesn't has KSCPDefaultSecCode ")); |
698 } |
680 iConfiguration.iConfigFlag = KSCPConfigInvalid; |
699 else if ( aMode == KSCPInitial ) |
681 iConfiguration.iFailedAttempts++; |
700 { |
682 isDefaultLockcode = EFalse; |
701 // Return here, must be checked by complete mode |
683 } |
702 User::Leave( KErrAccessDenied ); |
684 } |
703 } |
685 else { |
704 |
686 RDebug::Print(_L("CSCPServer::CheckISACodeL(): config lock code %s"), storedCode.PtrZ()); |
705 |
687 TRAP( err, CheckISACodeL( storedCode ) ); |
706 TInt hashedISAcode; |
688 if (err == KErrNone) { |
707 TSCPSecCode hashedCode; |
689 RDebug::Print(_L("--> CSCPServer::ValidateConfigurationL()@ISA and config are in SYNC !! ")); |
708 //#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS |
690 iConfiguration.iConfigFlag = KSCPConfigOK; |
709 if(FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
691 isDefaultLockcode = EFalse; |
710 { |
692 } |
711 /*TInt*/ hashedISAcode = HashISACode( iConfiguration.iEnhSecCode ); |
693 else { |
712 // TSCPSecCode hashedCode; |
694 iConfiguration.iSecCode.Zero(); |
713 hashedCode.Zero(); |
695 iConfiguration.iSecCode.Append(KSCPDefaultSecCode); |
714 hashedCode.AppendNum( hashedISAcode ); |
696 RDebug::Print(_L("--> CSCPServer::ValidateConfigurationL()@May be ISA has KSCPDefaultSecCode ")); |
|
697 TRAP(err,ChangeISACodeL(storedCode)); |
|
698 if (err == KErrNone) { |
|
699 RDebug::Print(_L("--> CSCPServer::ValidateConfigurationL()chnaged ISA code with config value ")); |
|
700 iConfiguration.iConfigFlag = KSCPConfigOK; |
|
701 isDefaultLockcode = EFalse; |
|
702 } |
|
703 else |
|
704 { |
|
705 RDebug::Print(_L("--> CSCPServer::ValidateConfigurationL()it shouldn't reach this :( ")); |
|
706 } |
|
707 } |
|
708 } |
|
709 |
|
710 CRepository* repository = CRepository::NewL(KCRUidSCPLockCode); |
|
711 CleanupStack::PushL(repository); |
|
712 if (isDefaultLockcode ) { |
|
713 RDebug::Print(_L("--> CSCPServer::ValidateConfigurationL()setting def. lockcode to 12345 ")); |
|
714 repository->Set(KSCPLockCodeDefaultLockCode, 12345); |
|
715 } |
|
716 else { |
|
717 RDebug::Print(_L("--> CSCPServer::ValidateConfigurationL()setting def. lockcode to 0 ")); |
|
718 repository->Set(KSCPLockCodeDefaultLockCode, 0); |
|
719 } |
|
720 CleanupStack::PopAndDestroy(repository); |
|
721 |
|
722 TRAP( err, iConfiguration.WriteSetupL() ); |
|
723 if (err != KErrNone) { |
|
724 Dprint( (_L("CSCPServer::ValidateConfigurationL(): WARNING: failed to write configuration\ |
|
725 : %d"), err )); |
|
726 } |
|
727 |
|
728 if (iConfiguration.iConfigFlag == KSCPConfigOK) { |
|
729 RDebug::Print(_L("--> CSCPServer::ValidateConfigurationL()@iConfigFlag == KSCPConfigOK ")); |
|
730 err = KErrNone; |
|
731 } |
|
732 else { |
|
733 RDebug::Print(_L("--> CSCPServer::ValidateConfigurationL()@iConfigFlag == KErrAccessDenied ")); |
|
734 err = KErrAccessDenied; |
|
735 } |
|
736 |
|
737 User::LeaveIfError(err); |
715 } |
738 } |
716 //#endif // __SAP_DEVICE_LOCK_ENHANCEMENTS |
739 |
717 |
|
718 |
|
719 |
|
720 |
|
721 if (err != KErrNone) |
|
722 { |
|
723 lCorrectDefaultlockcode = ETrue; |
|
724 } |
|
725 if ( err == KErrNone ) |
|
726 { |
|
727 iConfiguration.iConfigFlag = KSCPConfigOK; |
|
728 } |
|
729 else if ( err == KErrAccessDenied ) |
|
730 { |
|
731 iConfiguration.iConfigFlag = KSCPConfigInvalid; |
|
732 } |
|
733 else if ( err == KErrLocked ) |
|
734 { |
|
735 Dprint( (_L("CSCPServer::ValidateConfigurationL(): ISA code locked.") )); |
|
736 } |
|
737 else |
|
738 { |
|
739 Dprint( (_L("CSCPServer::ValidateConfigurationL(): ERROR in validation.") )); |
|
740 } |
|
741 |
|
742 //#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
743 if(FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
744 { |
|
745 if ( err == KErrNone ) |
|
746 { |
|
747 // Check that the codes are in-sync with each other. Especially the default ISA code must |
|
748 // be changed according to the default enhanced code. |
|
749 if ( storedCode.Compare( hashedCode ) != 0 ) |
|
750 { |
|
751 Dprint( (_L("CSCPServer::ValidateConfigurationL(): Correct ISA code stored.\ |
|
752 Changing ISA code to match enhanced code => %d"), hashedISAcode )); |
|
753 |
|
754 storedCode.Copy( hashedCode ); |
|
755 // Change the ISA code to match the hashed code |
|
756 ChangeISACodeL( storedCode ); |
|
757 } |
|
758 } |
|
759 else if ( ( err == KErrAccessDenied ) && ( storedCode.Compare( hashedCode ) != 0 ) ) |
|
760 { |
|
761 // Try again with the hashed code |
|
762 TRAP( err, CheckISACodeL( hashedCode ) ); |
|
763 |
|
764 if ( err == KErrNone ) |
|
765 { |
|
766 Dprint( (_L("CSCPServer::ValidateConfigurationL(): Hashed code is correct.\ |
|
767 Storing hashed code(%d)"), hashedISAcode )); |
|
768 |
|
769 if ( StoreCode( hashedCode ) == KErrNone ) |
|
770 { |
|
771 iConfiguration.iConfigFlag = KSCPConfigOK; |
|
772 lCorrectDefaultlockcode = ETrue; |
|
773 } |
|
774 } |
|
775 } |
|
776 |
|
777 //If Correction of Defaultlockcode cenrep is required for the mismatch between Config and ISA |
|
778 if (lCorrectDefaultlockcode) |
|
779 { |
|
780 TInt lDefCode = -1; |
|
781 CRepository* lRepository = CRepository::NewL(KCRUidSCPLockCode); |
|
782 CleanupStack::PushL(lRepository); |
|
783 TInt lRet = lRepository->Get(KSCPLockCodeDefaultLockCode, |
|
784 lDefCode); |
|
785 if (lRet == KErrNone && lDefCode != -1) |
|
786 { |
|
787 if (lDefCode == 12345) |
|
788 { |
|
789 //Although lock code is already set, due to some unexpected condition |
|
790 //like C drive wipe, cenrep status is wrongly shown. Correcting it here. |
|
791 lRepository->Set(KSCPLockCodeDefaultLockCode, 0); |
|
792 Dprint( (_L("RSCPClient::ValidateConfigurationL(): Corrected the Default lock code cenrep status to 0") )); |
|
793 } |
|
794 else if (lDefCode == 0) |
|
795 { |
|
796 //If only ISA side is formatted, then the lock code on ISA side is default; |
|
797 //Cenrep status remains wrongly as the lock code is already set. Correcting it here. |
|
798 lRepository->Set(KSCPLockCodeDefaultLockCode, 12345); |
|
799 Dprint( (_L("RSCPClient::ValidateConfigurationL(): Corrected the Default lock code cenrep status to 12345") )); |
|
800 } |
|
801 } |
|
802 CleanupStack::PopAndDestroy(lRepository); |
|
803 } |
|
804 } |
|
805 //#endif // __SAP_DEVICE_LOCK_ENHANCEMENTS |
|
806 //Set the flag to True, after config is validated |
|
807 iConfiguration.iConfigChecked = ETrue; |
|
808 |
|
809 TRAPD( err2, iConfiguration.WriteSetupL() ); |
|
810 if ( err2 != KErrNone ) |
|
811 { |
|
812 Dprint( (_L("CSCPServer::ValidateConfigurationL(): WARNING: failed to write configuration\ |
|
813 : %d"), err2 )); |
|
814 } |
|
815 |
|
816 User::LeaveIfError( err ); |
|
817 } |
|
818 Dprint( (_L("<-- CSCPServer::ValidateConfigurationL()") )); |
|
819 } |
|
820 |
740 |
821 |
741 |
822 |
742 |
823 |
743 |
824 // --------------------------------------------------------- |
744 // --------------------------------------------------------- |
871 Dprint( (_L("CSCPServer::CheckISACodeL(): ISA code NOT OK") )); |
794 Dprint( (_L("CSCPServer::CheckISACodeL(): ISA code NOT OK") )); |
872 if (iConfiguration.iBlockedInOOS == 1) |
795 if (iConfiguration.iBlockedInOOS == 1) |
873 { |
796 { |
874 iConfiguration.iBlockedInOOS = 0; |
797 iConfiguration.iBlockedInOOS = 0; |
875 Dprint( (_L("CSCPServer::CheckISACodeL():iBlockedInOOS = 0, KErrAccessDenied") )); |
798 Dprint( (_L("CSCPServer::CheckISACodeL():iBlockedInOOS = 0, KErrAccessDenied") )); |
|
799 RDebug::Print(_L("--> CSCPServer::CheckISACodeL()@@iBlockedInOOS = 0, KErrAccessDenie")); |
876 } |
800 } |
877 ret = KErrAccessDenied; |
801 ret = KErrAccessDenied; |
878 } |
802 } |
879 else if ( ( ret == KErrGsmSSPasswordAttemptsViolation ) || ( ret == KErrLocked ) ) |
803 else if ( ( ret == KErrGsmSSPasswordAttemptsViolation ) || ( ret == KErrLocked ) ) |
880 { |
804 { |
881 Dprint( (_L("CSCPServer::CheckISACodeL(): ISA code BLOCKED") )); |
805 Dprint( (_L("CSCPServer::CheckISACodeL(): ISA code BLOCKED") )); |
882 if (ret==KErrGsmSSPasswordAttemptsViolation) |
806 if (ret==KErrGsmSSPasswordAttemptsViolation) |
883 { |
807 { |
884 Dprint( (_L("CSCPServer::CheckISACodeL(): KErrGsmSSPasswordAttemptsViolation") )); |
808 Dprint( (_L("CSCPServer::CheckISACodeL(): KErrGsmSSPasswordAttemptsViolation") )); |
|
809 RDebug::Print(_L("--> CSCPServer::CheckISACodeL()@@KErrGsmSSPasswordAttemptsViolation")); |
885 } |
810 } |
886 else |
811 else |
887 { |
812 { |
888 Dprint( (_L("CSCPServer::CheckISACodeL(): KErrLocked") )); |
813 Dprint( (_L("CSCPServer::CheckISACodeL(): KErrLocked") )); |
|
814 RDebug::Print(_L("--> CSCPServer::CheckISACodeL()@@KErrLocked")); |
889 } |
815 } |
890 ret = KErrLocked; |
816 ret = KErrLocked; |
891 if (iConfiguration.iBlockedInOOS == 0) |
817 if (iConfiguration.iBlockedInOOS == 0) |
892 { |
818 { |
893 iConfiguration.iBlockedInOOS = 1; |
819 iConfiguration.iBlockedInOOS = 1; |
894 Dprint( (_L("CSCPServer::CheckISACodeL():iBlockedInOOS = 1, KSCPErrCodeBlockStarted") )); |
820 Dprint( (_L("CSCPServer::CheckISACodeL():iBlockedInOOS = 1, KSCPErrCodeBlockStarted") )); |
|
821 RDebug::Print(_L("--> CSCPServer::CheckISACodeL()@@@@@")); |
895 ret = KSCPErrCodeBlockStarted; |
822 ret = KSCPErrCodeBlockStarted; |
896 } |
823 } |
897 } |
824 } |
898 else |
825 else |
899 { |
826 { |
900 Dprint( (_L("CSCPServer::CheckISACodeL(): ERROR reply checking ISA code: %d"), |
827 Dprint( (_L("CSCPServer::CheckISACodeL(): ERROR reply checking ISA code: %d"), |
901 status.Int() )); |
828 status.Int() )); |
|
829 RDebug::Print(_L("--> CSCPServer::ValidateConfigurationL()")); |
902 } |
830 } |
903 } |
831 } |
904 TRAPD( err, iConfiguration.WriteSetupL() ); |
832 TRAPD( err, iConfiguration.WriteSetupL() ); |
905 if ( err != KErrNone ) |
833 if ( err != KErrNone ) |
906 { |
834 { |
1349 #endif // __SCP_DEBUG |
1278 #endif // __SCP_DEBUG |
1350 |
1279 |
1351 TInt lRetStatus(KErrNone); |
1280 TInt lRetStatus(KErrNone); |
1352 Dprint(_L("[CSCPServer]-> Initiating branching on parameter...")); |
1281 Dprint(_L("[CSCPServer]-> Initiating branching on parameter...")); |
1353 |
1282 |
1354 switch ( aID ) |
1283 switch(aID) { |
1355 { |
1284 case ESCPAutolockPeriod: |
1356 case ( ESCPAutolockPeriod ): |
1285 case ESCPMaxAutolockPeriod: { |
1357 // Flow through |
|
1358 case ( ESCPMaxAutolockPeriod ): |
|
1359 { |
|
1360 // Convert the value, and set it |
1286 // Convert the value, and set it |
1361 TInt value; |
1287 TInt value; |
1362 TLex lex(aValue); |
1288 TLex lex(aValue); |
1363 lRetStatus = lex.Val(value); |
1289 lRetStatus = lex.Val(value); |
1364 |
|
1365 |
1290 |
1366 if((lRetStatus != KErrNone ) || ( value < 0) || ( value > KSCPAutolockPeriodMaximum )) { |
1291 if((lRetStatus != KErrNone ) || ( value < 0) || ( value > KSCPAutolockPeriodMaximum )) { |
1367 lRetStatus = KErrArgument; |
1292 lRetStatus = KErrArgument; |
1368 break; |
1293 break; |
1369 } |
1294 } |
1370 |
1295 |
1371 //Check if the device memory is encrypted or not. |
1296 //Check if the device memory is encrypted or not. |
1372 TBool encryptionEnabled = IsDeviceMemoryEncrypted(); |
1297 TBool encryptionEnabled = IsDeviceMemoryEncrypted(); |
|
1298 CSCPParamDBController* lParamDB = CSCPParamDBController :: NewLC(); |
1373 |
1299 |
1374 // Value OK |
1300 // Value OK |
1375 if(aID == ESCPMaxAutolockPeriod) |
1301 if(aID == ESCPMaxAutolockPeriod) { |
1376 { |
1302 if( encryptionEnabled ) { |
1377 if ( encryptionEnabled ) |
1303 Dprint(_L("[CSCPServer]-> Memory is encrypted")); |
1378 { |
1304 |
1379 Dprint(_L("Memory is encrypted")); |
1305 if(( 0 == value) || value > KMaxAutolockPeriod) { |
1380 if (( 0 == value) || value > KMaxAutolockPeriod) |
1306 Dprint((_L("[CSCPServer]-> Denying setting of max auto lock as value is %d"), value)); |
1381 { |
1307 User :: Leave( KErrPermissionDenied ); |
1382 Dprint((_L("Denying setting of max auto lock as value is %d"), value)); |
1308 } |
1383 User::Leave( KErrPermissionDenied ); |
1309 } |
1384 } |
1310 else { |
1385 |
|
1386 } |
|
1387 else |
|
1388 { |
|
1389 Dprint(_L("Memory is decrypted, hence no restrictions to max autolock")); |
1311 Dprint(_L("Memory is decrypted, hence no restrictions to max autolock")); |
1390 } |
1312 } |
1391 |
1313 |
1392 Dprint(_L("[CSCPServer]-> Branched to ESCPMaxAutolockPeriod...")); |
1314 Dprint(_L("[CSCPServer]-> Branched to ESCPMaxAutolockPeriod...")); |
1393 CSCPParamDBController* lParamDB = CSCPParamDBController :: NewLC(); |
|
1394 lRetStatus = SetBestPolicyL(RTerminalControl3rdPartySession :: EMaxTimeout, aValue, aCallerIdentity, lParamDB); |
1315 lRetStatus = SetBestPolicyL(RTerminalControl3rdPartySession :: EMaxTimeout, aValue, aCallerIdentity, lParamDB); |
1395 |
1316 |
1396 if(lRetStatus == KErrNone) |
1317 if(lRetStatus == KErrNone) { |
1397 { |
|
1398 // Do we have to change the Autolock period as well? |
1318 // Do we have to change the Autolock period as well? |
1399 TInt currentALperiod; |
1319 TInt currentALperiod; |
1400 lRetStatus = GetAutolockPeriodL(currentALperiod); |
1320 lRetStatus = GetAutolockPeriodL(currentALperiod); |
1401 |
1321 |
1402 if(lRetStatus == KErrNone) |
1322 if(lRetStatus == KErrNone) { |
1403 { |
1323 if( (iConfiguration.iMaxTimeout > 0) && |
1404 if((iConfiguration.iMaxTimeout > 0) && ((iConfiguration.iMaxTimeout < currentALperiod) || (currentALperiod == 0))) |
1324 ((iConfiguration.iMaxTimeout < currentALperiod) || |
1405 { |
1325 (currentALperiod == 0))) { |
|
1326 |
1406 Dprint((_L("[CSCPServer]-> Changing AL period to Max. AL period (Current ALP: %d, Max. ALP: %d)"), currentALperiod, value)); |
1327 Dprint((_L("[CSCPServer]-> Changing AL period to Max. AL period (Current ALP: %d, Max. ALP: %d)"), currentALperiod, value)); |
1407 lRetStatus = SetAutolockPeriodL(value); |
1328 //lRetStatus = SetAutolockPeriodL(value); |
|
1329 /* |
|
1330 * Call to SetBestPolicyL will not check for Stronger/Weaker. The value of ETimeout just gets stored in |
|
1331 * both the internal DB and the CenRep |
|
1332 */ |
|
1333 lRetStatus = SetBestPolicyL(RTerminalControl3rdPartySession :: ETimeout, aValue, aCallerIdentity, lParamDB); |
1408 } |
1334 } |
1409 } |
1335 } |
1410 else |
1336 else { |
1411 { |
|
1412 Dprint((_L("[CSCPServer]-> ERROR: Couldn't get the Autolock period: %d"), lRetStatus)); |
1337 Dprint((_L("[CSCPServer]-> ERROR: Couldn't get the Autolock period: %d"), lRetStatus)); |
1413 } |
1338 } |
1414 } |
1339 } |
1415 |
1340 } |
1416 CleanupStack :: PopAndDestroy(); //lParamDB |
1341 // Autolock Period |
1417 } |
1342 else { |
1418 |
1343 //Code is commented as it is already taken care by the below condition #1343 irrespective of the drive encryption state. |
1419 else |
1344 /* if ( 0 == value ) { |
1420 { // Autolock Period |
1345 if(encryptionEnabled) { |
1421 |
|
1422 //Code is commented as it is already taken care by the below condition #1343 irrespective of the drive encryption state. |
|
1423 /* if ( 0 == value ) |
|
1424 { |
|
1425 if ( encryptionEnabled ) |
|
1426 { |
|
1427 Dprint(_L("Permission denied!")); |
1346 Dprint(_L("Permission denied!")); |
1428 User::Leave( KErrPermissionDenied ); |
1347 User :: Leave(KErrPermissionDenied); |
1429 } |
1348 } |
1430 }*/ |
1349 }*/ |
1431 |
1350 |
1432 Dprint(_L("[CSCPServer]-> Branched to ESCPAutolockPeriod...")); |
1351 Dprint(_L("[CSCPServer]-> Branched to ESCPAutolockPeriod...")); |
1433 // Check if this value is not allowed by the Max. Autolock period |
1352 // Check if this value is not allowed by the Max. Autolock period |
1434 if ((iConfiguration.iMaxTimeout > 0) && ((iConfiguration.iMaxTimeout < value) || (value == 0))) { |
1353 if ((iConfiguration.iMaxTimeout > 0) && ((iConfiguration.iMaxTimeout < value) || (value == 0))) { |
1435 Dprint((_L("[CSCPServer]-> ERROR: The value %d for AL period not allowed (Max. AL period: %d)"), value, iConfiguration.iMaxTimeout)); |
1354 Dprint((_L("[CSCPServer]-> ERROR: The value %d for AL period not allowed (Max. AL period: %d)"), value, iConfiguration.iMaxTimeout)); |
1436 |
1355 |
1437 lRetStatus = KErrArgument; |
1356 lRetStatus = KErrArgument; |
1438 } |
1357 } |
1439 else { |
1358 else { |
1440 lRetStatus = SetAutolockPeriodL(value); |
1359 //lRetStatus = SetAutolockPeriodL(value); |
|
1360 /* |
|
1361 * Call to SetBestPolicyL will not check for Stronger/Weaker. The value of ETimeout just gets stored in |
|
1362 * both the internal DB and the CenRep |
|
1363 */ |
|
1364 lRetStatus = SetBestPolicyL(RTerminalControl3rdPartySession :: ETimeout, aValue, aCallerIdentity, lParamDB); |
1441 |
1365 |
1442 if(lRetStatus != KErrNone) { |
1366 if(lRetStatus != KErrNone) { |
1443 Dprint((_L("[CSCPServer]-> ERROR: Couldn't set the Autolock period: %d"), lRetStatus)); |
1367 Dprint((_L("[CSCPServer]-> ERROR: Couldn't set the Autolock period: %d"), lRetStatus)); |
1444 } |
1368 } |
1445 } |
1369 } |
1446 } |
1370 } |
|
1371 |
|
1372 CleanupStack :: PopAndDestroy(); //lParamDB |
1447 } |
1373 } |
1448 break; |
1374 break; |
1449 case ESCPCodeChangePolicy: |
1375 case ESCPCodeChangePolicy: |
1450 Dprint(_L("[CSCPServer]-> Branched to ESCPCodeChangePolicy...")); |
1376 Dprint(_L("[CSCPServer]-> Branched to ESCPCodeChangePolicy...")); |
1451 lRetStatus = ChangeCodePolicy( aValue ); |
1377 lRetStatus = ChangeCodePolicy( aValue ); |
2190 } |
2123 } |
2191 } |
2124 } |
2192 else |
2125 else |
2193 { |
2126 { |
2194 // iConfiguration.iConfigFlag == KSCPConfigInvalid or KSCPConfigUnknown |
2127 // iConfiguration.iConfigFlag == KSCPConfigInvalid or KSCPConfigUnknown |
2195 |
2128 |
2196 // We might be out-of-sync, no idea about the real code. |
2129 // We might be out-of-sync, no idea about the real code. |
2197 // Check if the DOS code hashed from the given code is correct. |
2130 // Check if the DOS code hashed from the given code is correct. |
2198 Dprint( (_L("CSCPServer::IsCorrectEnhCode(): Attempting to correct OoS situation.") )); |
2131 Dprint( (_L("CSCPServer::IsCorrectEnhCode(): Attempting to correct OoS situation.") )); |
2199 |
2132 if (IsCodeBlocked()) { |
|
2133 Dprint( (_L("CSCPServer::IsCorrectEnhCode(): OOS ->KErrLocked ") )); |
|
2134 return KErrLocked; |
|
2135 } |
2200 TRAP( ret, CheckISACodeL( pswCandidate ) ); |
2136 TRAP( ret, CheckISACodeL( pswCandidate ) ); |
2201 |
2137 |
2202 if ( ret == KErrNone ) |
2138 if (ret == KErrNone) { |
2203 { |
|
2204 // OK, we must assume that this is the correct code, since |
2139 // OK, we must assume that this is the correct code, since |
2205 // the hashed DOS code is correct. Save the codes, and return OK. |
2140 // the hashed DOS code is correct. Save the codes, and return OK. |
2206 |
2141 |
2207 Dprint( (_L("CSCPServer::IsCorrectEnhCode(): Given code has the correct hash (%d)\ |
2142 Dprint( (_L("CSCPServer::IsCorrectEnhCode(): Given code has the correct hash (%d)\ |
2208 , saving codes."), ISACode )); |
2143 , saving codes."), ISACode )); |
2209 |
2144 |
2210 iConfiguration.iEnhSecCode.Zero(); |
2145 iConfiguration.iEnhSecCode.Zero(); |
2211 iConfiguration.iEnhSecCode.Copy( hashBuf ); |
2146 iConfiguration.iEnhSecCode.Copy(hashBuf); |
2212 |
2147 |
2213 iConfiguration.iSecCode.Zero(); |
2148 iConfiguration.iSecCode.Zero(); |
2214 iConfiguration.iSecCode.AppendNum( ISACode ); |
2149 iConfiguration.iSecCode.AppendNum(ISACode); |
2215 |
2150 |
2216 // Unset the invalid configuration flag |
2151 // Unset the invalid configuration flag |
2217 iConfiguration.iConfigFlag = KSCPConfigOK; |
2152 iConfiguration.iConfigFlag = KSCPConfigOK; |
2218 writeSetup = ETrue; |
2153 writeSetup = ETrue; |
2219 } |
2154 } |
2220 else |
2155 else { |
2221 { |
2156 ret = KErrAccessDenied; |
2222 |
2157 |
2223 Dprint( (_L("CSCPServer::IsCorrectEnhCode(): Given code does not have the \ |
2158 iConfiguration.iFailedAttempts++; |
2224 correct hash: ret; %d user enter password: %d"), ret )); |
2159 Dprint( (_L("CSCPServer::IsCorrectEnhCode():@@@: iFailedAttempts (%d)."), iConfiguration.iFailedAttempts )); |
2225 TRAP( ret, CheckISACodeL( aCode ) ); |
|
2226 if (ret == KErrNone) |
|
2227 { |
|
2228 //store this code in our interal storage as it is used as oldpassword while changing at ISA side in next command |
|
2229 //ChangeISACodeL. |
|
2230 iConfiguration.iSecCode.Zero(); |
|
2231 iConfiguration.iSecCode.Append( aCode ); |
|
2232 TRAP(ret,ChangeISACodeL(pswCandidate)); |
|
2233 } |
|
2234 if (ret == KErrNone) |
|
2235 { |
|
2236 iConfiguration.iEnhSecCode.Zero(); |
|
2237 iConfiguration.iEnhSecCode.Copy( hashBuf ); |
|
2238 |
|
2239 iConfiguration.iSecCode.Zero(); |
|
2240 iConfiguration.iSecCode.AppendNum( ISACode ); |
|
2241 |
|
2242 // Unset the invalid configuration flag |
|
2243 iConfiguration.iConfigFlag = KSCPConfigOK; |
|
2244 writeSetup = ETrue; |
2160 writeSetup = ETrue; |
2245 } |
2161 |
2246 } |
2162 if (iConfiguration.iFailedAttempts == KSCPCodeBlockLimit) { |
2247 } |
2163 Dprint( (_L("CSCPServer::IsCorrectEnhCode(): KSCPCodeBlockLimit ") )); |
|
2164 // Block the code |
|
2165 TTime curTime; |
|
2166 curTime.UniversalTime(); |
|
2167 |
|
2168 iConfiguration.iBlockedAtTime.Zero(); |
|
2169 iConfiguration.iBlockedAtTime.AppendNum(curTime.Int64()); |
|
2170 |
|
2171 // The code will be blocked for now on |
|
2172 ret = KSCPErrCodeBlockStarted; |
|
2173 } |
|
2174 } |
|
2175 |
|
2176 } |
2248 |
2177 |
2249 // Write setup if needed |
2178 // Write setup if needed |
2250 if ( writeSetup ) |
2179 if ( writeSetup ) |
2251 { |
2180 { |
|
2181 Dprint( (_L("CSCPServer::IsCorrectEnhCode(): 7 ") )); |
2252 TRAPD( err, iConfiguration.WriteSetupL() ); |
2182 TRAPD( err, iConfiguration.WriteSetupL() ); |
2253 if ( err != KErrNone ) |
2183 if ( err != KErrNone ) |
2254 { |
2184 { |
2255 Dprint( (_L("CSCPServer::IsCorrectEnhCode(): WARNING:\ |
2185 Dprint( (_L("CSCPServer::IsCorrectEnhCode(): WARNING:\ |
2256 failed to write configuration: %d"), err )); |
2186 failed to write configuration: %d"), err )); |
2830 * from iPluginEventHandler->GetParameters() fails. |
2770 * from iPluginEventHandler->GetParameters() fails. |
2831 * (WriteToFileL() is called in some destructor when the SCPServer terminates) |
2771 * (WriteToFileL() is called in some destructor when the SCPServer terminates) |
2832 */ |
2772 */ |
2833 if (lRetStatus == KErrNone) { |
2773 if (lRetStatus == KErrNone) { |
2834 switch (aID) { |
2774 switch (aID) { |
|
2775 case RTerminalControl3rdPartySession :: ETimeout: |
|
2776 lRetStatus = SetAutolockPeriodL(TInt(lNumValue)); |
|
2777 Dprint(_L("[CSCPServer]-> After setting ETimeout lRetStatus = %d "), lRetStatus); |
|
2778 break; |
|
2779 |
2835 case RTerminalControl3rdPartySession :: EMaxTimeout: |
2780 case RTerminalControl3rdPartySession :: EMaxTimeout: |
2836 iConfiguration.iMaxTimeout = lNumValue; |
2781 iConfiguration.iMaxTimeout = lNumValue; |
2837 lRetStatus = iConfiguration.WriteSetupL(); |
2782 lRetStatus = iConfiguration.WriteSetupL(); |
2838 Dprint(_L("[CSCPServer]-> After setting EMaxTimeout lRetStatus = %d "), lRetStatus); |
2783 Dprint(_L("[CSCPServer]-> After setting EMaxTimeout lRetStatus = %d "), lRetStatus); |
2839 break; |
2784 break; |
|
2785 |
2840 default: |
2786 default: |
2841 TUint16* ptr = const_cast<TUint16*>(aValue.Ptr()); |
2787 TUint16* ptr = const_cast<TUint16*>(aValue.Ptr()); |
2842 TPtr valBuf(ptr, aValue.Length(), aValue.Length()); |
2788 TPtr valBuf(ptr, aValue.Length(), aValue.Length()); |
2843 lRetStatus = iPluginEventHandler->GetParameters().Set(aID, valBuf); |
2789 lRetStatus = iPluginEventHandler->GetParameters().Set(aID, valBuf); |
2844 Dprint(_L("[CSCPServer]-> After setting (%d ) lRetStatus = %d "), aID, lRetStatus); |
2790 Dprint(_L("[CSCPServer]-> After setting (%d ) lRetStatus = %d "), aID, lRetStatus); |
2929 lParamIds[lMinTolIndex] = RTerminalControl3rdPartySession :: EPasscodeHistoryBuffer; |
2875 lParamIds[lMinTolIndex] = RTerminalControl3rdPartySession :: EPasscodeHistoryBuffer; |
2930 Dprint(_L("[CSCPServer]-> Switching the cleanup order of EPasscodeHistoryBuffer and EPasscodeMinChangeTolerance")); |
2876 Dprint(_L("[CSCPServer]-> Switching the cleanup order of EPasscodeHistoryBuffer and EPasscodeMinChangeTolerance")); |
2931 Dprint(_L("[CSCPServer]-> Old Index of EPasscodeHistoryBuffer=%d"), lHistBuffIndex); |
2877 Dprint(_L("[CSCPServer]-> Old Index of EPasscodeHistoryBuffer=%d"), lHistBuffIndex); |
2932 Dprint(_L("[CSCPServer]-> Old Index of EPasscodeMinChangeTolerance=%d"), lMinTolIndex); |
2878 Dprint(_L("[CSCPServer]-> Old Index of EPasscodeMinChangeTolerance=%d"), lMinTolIndex); |
2933 } |
2879 } |
|
2880 |
|
2881 /* |
|
2882 * If both ETimeout and EMaxTimeout are marked for cleanup then interchange the cleanup order of |
|
2883 * ETimeout and EMaxTimeout since AutoLock (ETimeout) cannot be disabled |
|
2884 * if MaxAutolock (EMaxTimeout) is still enabled |
|
2885 */ |
|
2886 if( lParamIds[0] == RTerminalControl3rdPartySession :: ETimeout && |
|
2887 lParamIds[1] == RTerminalControl3rdPartySession :: EMaxTimeout) { |
|
2888 |
|
2889 lParamIds[0] = RTerminalControl3rdPartySession :: EMaxTimeout; |
|
2890 lParamIds[1] = RTerminalControl3rdPartySession :: ETimeout; |
|
2891 } |
2934 } |
2892 } |
2935 |
2893 |
2936 for(TInt j=0; j < lCount; j++) { |
2894 for(TInt j=0; j < lCount; j++) { |
2937 TInt lCurrParamID = lParamIds[j]; |
2895 TInt lCurrParamID = lParamIds[j]; |
2938 lDefValueBuf->Des().Zero(); |
2896 lDefValueBuf->Des().Zero(); |
2939 lDefValueBuf->Des().Format(_L("%d "), 0); |
2897 lDefValueBuf->Des().Format(_L("%d "), 0); |
|
2898 |
2940 // Initialize the default values here... |
2899 // Initialize the default values here... |
2941 switch(lCurrParamID) { |
2900 switch(lCurrParamID) { |
|
2901 case RTerminalControl3rdPartySession :: ETimeout: |
|
2902 // lDefValueBuf already has the default value, 0 initialized... |
|
2903 lCurrParamID = ESCPAutolockPeriod; |
|
2904 break; |
2942 case RTerminalControl3rdPartySession :: EMaxTimeout: |
2905 case RTerminalControl3rdPartySession :: EMaxTimeout: |
2943 // lDefValueBuf already has the default value, 0 initialized... |
2906 // lDefValueBuf already has the default value, 0 initialized... |
2944 lCurrParamID = ESCPMaxAutolockPeriod; |
2907 lCurrParamID = ESCPMaxAutolockPeriod; |
2945 break; |
2908 break; |
2946 case RTerminalControl3rdPartySession :: EPasscodeMinLength: |
2909 case RTerminalControl3rdPartySession :: EPasscodeMinLength: |