957 // to the server. |
956 // to the server. |
958 // |
957 // |
959 // Status : Approved |
958 // Status : Approved |
960 // --------------------------------------------------------- |
959 // --------------------------------------------------------- |
961 // |
960 // |
962 void CSCPSession::HandleChangeEnhCodeMessageL( const RMessage2 &aMessage ) |
961 void CSCPSession :: HandleChangeEnhCodeMessageL(const RMessage2 &aMessage) { |
|
962 |
|
963 Dprint(_L("[CSCPSession]-> HandleChangeEnhCodeMessage() >>>")); |
|
964 |
|
965 if(!FeatureManager :: FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) { |
|
966 FeatureManager :: UnInitializeLib(); |
|
967 User :: Leave(KErrNotSupported); |
|
968 } |
|
969 |
|
970 TInt oldPasswordLen = aMessage.GetDesLength(0); |
|
971 TInt newPasswordLen = aMessage.GetDesLength(1); |
|
972 |
|
973 if ((newPasswordLen == 0) || (oldPasswordLen == 0)) { |
|
974 // We cannot accept an empty code |
|
975 Dprint(_L("[CSCPSession]-> ERROR: Input buffers are empty!!")); |
|
976 User :: Leave(KErrArgument); |
|
977 } |
|
978 |
|
979 TInt lErr = KErrNone; |
|
980 HBufC* oldPassBuf = HBufC :: NewLC(oldPasswordLen); |
|
981 HBufC* newPassBuf = HBufC :: NewLC(newPasswordLen); |
|
982 |
|
983 TPtr oldPassPtr = oldPassBuf->Des(); |
|
984 TPtr newPassPtr = newPassBuf->Des(); |
|
985 |
|
986 // Read the strings, slot 0 = old password, slot 1 = new password |
|
987 aMessage.ReadL(0, oldPassPtr); |
|
988 aMessage.ReadL(1, newPassPtr); |
|
989 |
|
990 // A buffer for the updated DOS password |
|
991 TSCPSecCode newDosCode; |
|
992 newDosCode.Zero(); |
|
993 |
|
994 CSCPParamObject* addParams = NULL; |
|
995 lErr = iServer.CheckAndChangeEnhCodeL(oldPassPtr, newPassPtr, addParams, newDosCode); |
|
996 CleanupStack :: PushL(addParams); |
|
997 |
|
998 if (addParams != NULL) { |
|
999 ReadFailedPoliciestoMsgBufferL(addParams, aMessage, 2); |
|
1000 } |
|
1001 |
|
1002 CleanupStack :: PopAndDestroy(1); //addParams |
|
1003 |
|
1004 if(lErr == KErrNone) { |
|
1005 /* Get the very first character of the new lock code and set the default input mode of the |
|
1006 lock code query on the basis of the first character. */ |
|
1007 ch = newPassPtr[0]; |
|
1008 def_mode = ch.IsDigit() ? 0 : 1; |
|
1009 |
|
1010 CRepository* repository = CRepository :: NewLC(KCRUidSCPParameters); |
|
1011 User :: LeaveIfError(repository->Set(KSCPLockCodeDefaultInputMode, def_mode)); |
|
1012 CleanupStack :: PopAndDestroy(repository); |
|
1013 |
|
1014 /* Set the value in the cenrep that the default lock code has been changed if it is not |
|
1015 * already set |
|
1016 * */ |
|
1017 repository = CRepository :: NewLC(KCRUidSCPLockCode); |
|
1018 User :: LeaveIfError(repository->Set(KSCPLockCodeDefaultLockCode, 0)); |
|
1019 CleanupStack :: PopAndDestroy(repository); |
|
1020 } |
|
1021 |
|
1022 CleanupStack :: PopAndDestroy(2); //newPassBuf, oldPassBuf |
|
1023 |
|
1024 Dprint(_L("[CSCPSession]-> HandleChangeEnhCodeMessage() lErr=%d <<<"), lErr); |
|
1025 User :: LeaveIfError(lErr); |
|
1026 } |
|
1027 |
|
1028 // --------------------------------------------------------- |
|
1029 // void CSCPSession::HandleQueryChangeMessageL() |
|
1030 // Check from the server, if the password is allowed to be changed. |
|
1031 // |
|
1032 // Status : Approved |
|
1033 // --------------------------------------------------------- |
|
1034 // |
|
1035 |
|
1036 void CSCPSession::HandleQueryChangeMessageL( const RMessage2 &aMessage ) |
963 { |
1037 { |
964 |
1038 Dprint( (_L("--> CSCPSession::HandleQueryChangeMessage()") )); |
965 if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
1039 if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
966 { |
1040 { |
|
1041 Dprint( (_L("--> CSCPSession::HandleQueryChangeMessage() .. Feature not Supported !!") )); |
967 FeatureManager::UnInitializeLib(); |
1042 FeatureManager::UnInitializeLib(); |
968 User::Leave(KErrNotSupported); |
1043 User::Leave(KErrNotSupported); |
969 } |
1044 } |
970 Dprint( (_L("--> CSCPSession::HandleChangeEnhCodeMessage()") )); |
|
971 |
|
972 HBufC* oldPassBuf = NULL; |
|
973 HBufC* newPassBuf = NULL; |
|
974 |
|
975 TInt oldPasswordLen = aMessage.GetDesLength(0); |
|
976 TInt newPasswordLen = aMessage.GetDesLength(1); |
|
977 |
|
978 if ( ( newPasswordLen == 0 ) || ( oldPasswordLen == 0 ) ) |
|
979 { |
|
980 // We cannot accept an empty code |
|
981 Dprint( (_L("<-- ERROR: CSCPSession::HandleChangeEnhCodeMessage():\ |
|
982 returning KErrArgument, buffer empty") )); |
|
983 User::Leave( KErrArgument ); |
|
984 } |
|
985 else |
|
986 { |
|
987 oldPassBuf = HBufC::NewLC( oldPasswordLen ); |
|
988 newPassBuf = HBufC::NewLC( newPasswordLen ); |
|
989 } |
|
990 |
|
991 TPtr oldPassPtr = oldPassBuf->Des(); |
|
992 TPtr newPassPtr = newPassBuf->Des(); |
|
993 |
|
994 // Read the strings, slot 0 = old password, slot 1 = new password |
|
995 TRAPD( err, aMessage.ReadL( 0, oldPassPtr ) ); |
|
996 TRAP( err, aMessage.ReadL( 1, newPassPtr ) ); |
|
997 |
|
998 // A buffer for the updated DOS password |
|
999 TSCPSecCode newDosCode; |
|
1000 newDosCode.Zero(); |
|
1001 |
1045 |
1002 CSCPParamObject* addParams = NULL; |
1046 CSCPParamObject* addParams = NULL; |
1003 if ( err != KErrNone ) |
|
1004 { |
|
1005 Dprint( (_L("<-- ERROR: CSCPSession::HandleChangeEnhCodeMessage():\ |
|
1006 failed to read the strings to server side: %d"), err )); |
|
1007 } |
|
1008 else |
|
1009 { |
|
1010 err = iServer.CheckAndChangeEnhCodeL( oldPassPtr, newPassPtr, addParams, newDosCode ); |
|
1011 } |
|
1012 |
|
1013 // If additional parameters are passed to client side, add them to slot 2 |
|
1014 if ( addParams != NULL ) |
|
1015 { |
|
1016 HBufC8* paramBuf; |
|
1017 TInt pRet = addParams->GetBuffer( paramBuf ); |
|
1018 |
|
1019 if ( pRet != KErrNone ) |
|
1020 { |
|
1021 Dprint( (_L("WARNING: CSCPSession::HandleAuthenticationMessage():\ |
|
1022 failed to get additional parameter buffer: %d"), pRet )); |
|
1023 } |
|
1024 else |
|
1025 { |
|
1026 TPtr8 paramPtr = paramBuf->Des(); |
|
1027 if ( aMessage.GetDesMaxLength( 2 ) >= paramPtr.Length() ) |
|
1028 { |
|
1029 aMessage.Write( 2, paramPtr ); |
|
1030 } |
|
1031 else |
|
1032 { |
|
1033 Dprint( (_L("WARNING: CSCPSession::HandleAuthenticationMessage():\ |
|
1034 WARNING: not enough space for additional parameters") )); |
|
1035 } |
|
1036 |
|
1037 delete paramBuf; |
|
1038 } |
|
1039 |
|
1040 delete addParams; |
|
1041 } |
|
1042 |
|
1043 if ( err == KErrNone ) |
|
1044 { |
|
1045 // Copy the new DOS code to slot 3 |
|
1046 TInt ret = aMessage.Write( 3, newDosCode ); |
|
1047 if ( ret != KErrNone ) |
|
1048 { |
|
1049 Dprint( (_L("WARNING: CSCPSession::HandleAuthenticationMessage():\ |
|
1050 WARNING: failed to write the new DOS code to client-side") )); |
|
1051 } |
|
1052 else |
|
1053 { |
|
1054 /* Get the very first character of the new lock code and set the default input mode of the |
|
1055 lock code query on the basis of the first character. */ |
|
1056 ch = newPassPtr[0]; |
|
1057 def_mode = ch.IsDigit() ? 0 : 1; |
|
1058 |
|
1059 CRepository* repository = CRepository :: NewL(KCRUidSCPParameters); |
|
1060 CleanupStack::PushL( repository ); |
|
1061 |
|
1062 User::LeaveIfError(repository->Set( KSCPLockCodeDefaultInputMode , def_mode) ); |
|
1063 CleanupStack :: PopAndDestroy(repository); |
|
1064 |
|
1065 /* Set the value in the cenrep that the default lock code has been changed if it is not |
|
1066 * already set |
|
1067 * */ |
|
1068 repository = CRepository :: NewL(KCRUidSCPLockCode); |
|
1069 CleanupStack :: PushL(repository); |
|
1070 User :: LeaveIfError(repository->Set(KSCPLockCodeDefaultLockCode, 0)); |
|
1071 CleanupStack::PopAndDestroy( repository ); |
|
1072 repository = NULL; |
|
1073 } |
|
1074 } |
|
1075 |
|
1076 oldPassPtr.Zero(); |
|
1077 newPassPtr.Zero(); |
|
1078 CleanupStack::PopAndDestroy( newPassBuf ); |
|
1079 CleanupStack::PopAndDestroy( oldPassBuf ); |
|
1080 |
|
1081 Dprint( (_L("<-- CSCPSession::HandleChangeEnhCodeMessage(): %d"), err )); |
|
1082 |
|
1083 if ( err != KErrNone ) |
|
1084 { |
|
1085 User::Leave( err ); |
|
1086 } |
|
1087 } |
|
1088 |
|
1089 |
|
1090 // --------------------------------------------------------- |
|
1091 // void CSCPSession::HandleQueryChangeMessageL() |
|
1092 // Check from the server, if the password is allowed to be changed. |
|
1093 // |
|
1094 // Status : Approved |
|
1095 // --------------------------------------------------------- |
|
1096 // |
|
1097 |
|
1098 void CSCPSession::HandleQueryChangeMessageL( const RMessage2 &aMessage ) |
|
1099 { |
|
1100 if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) |
|
1101 { |
|
1102 FeatureManager::UnInitializeLib(); |
|
1103 User::Leave(KErrNotSupported); |
|
1104 } |
|
1105 Dprint( (_L("--> CSCPSession::HandleQueryChangeMessage()") )); |
|
1106 |
|
1107 CSCPParamObject* addParams = NULL; |
|
1108 |
1047 |
1109 TInt ret = iServer.IsPasswordChangeAllowedL( addParams ); |
1048 TInt ret = iServer.IsPasswordChangeAllowedL( addParams ); |
1110 |
1049 if (ret != KErrNone) |
1111 // Return the reply in slot 0 |
1050 { |
1112 |
1051 ReadFailedPoliciestoMsgBufferL(addParams,aMessage,0); |
1113 TPckg<TInt> retPackage(ret); |
1052 } |
1114 aMessage.WriteL(0, retPackage ); |
1053 if (addParams != NULL) |
1115 |
1054 delete addParams; |
1116 // If additional parameters are passed to client side, add them to slot 1 |
1055 |
1117 if ( addParams != NULL ) |
|
1118 { |
|
1119 HBufC8* paramBuf; |
|
1120 TInt pRet = addParams->GetBuffer( paramBuf ); |
|
1121 |
|
1122 if ( pRet != KErrNone ) |
|
1123 { |
|
1124 Dprint( (_L("WARNING: CSCPSession::HandleAuthenticationMessage():\ |
|
1125 failed to get additional parameter buffer: %d"), pRet )); |
|
1126 } |
|
1127 else |
|
1128 { |
|
1129 TPtr8 paramPtr = paramBuf->Des(); |
|
1130 if ( aMessage.GetDesMaxLength( 1 ) >= paramPtr.Length() ) |
|
1131 { |
|
1132 aMessage.Write( 1, paramPtr ); |
|
1133 } |
|
1134 else |
|
1135 { |
|
1136 Dprint( (_L("WARNING: CSCPSession::HandleAuthenticationMessage():\ |
|
1137 WARNING: not enough space for additional parameters") )); |
|
1138 } |
|
1139 |
|
1140 delete paramBuf; |
|
1141 } |
|
1142 |
|
1143 delete addParams; |
|
1144 } |
|
1145 |
|
1146 Dprint( (_L("<-- CSCPSession::HandleQueryChangeMessage()") )); |
1056 Dprint( (_L("<-- CSCPSession::HandleQueryChangeMessage()") )); |
1147 } |
1057 } |
1148 |
1058 |
1149 |
1059 |
1150 //#endif // __SAP_DEVICE_LOCK_ENHANCEMENTS |
1060 //#endif // __SAP_DEVICE_LOCK_ENHANCEMENTS |
1553 Dprint(_L("[CSCPSession]-> NotifyAllStakeHoldersL() <<<")); |
1474 Dprint(_L("[CSCPSession]-> NotifyAllStakeHoldersL() <<<")); |
1554 return KErrNone; |
1475 return KErrNone; |
1555 } |
1476 } |
1556 |
1477 |
1557 TInt CSCPSession :: HandleCleanupL(const RMessage2& aMessage) { |
1478 TInt CSCPSession :: HandleCleanupL(const RMessage2& aMessage) { |
1558 Dprint((_L("[CSCPSession]-> HandleCleanupL() >>>"))); |
|
1559 |
|
1560 if( (aMessage.SecureId().iId != KSCPServerSIDTerminalControl) && |
|
1561 (aMessage.SecureId().iId != KSCPEvntHndlrUid)) { |
|
1562 |
|
1563 Dprint((_L("[CSCPSession]-> ERROR: caller app id=%ld. Permission denied..."), aMessage.SecureId().iId)); |
|
1564 User :: Leave(KErrPermissionDenied); |
|
1565 } |
|
1566 |
|
1567 // Copy the client data into a local buffer |
1479 // Copy the client data into a local buffer |
1568 TInt32 lCount = aMessage.GetDesLength(1); |
1480 TInt32 lCount = aMessage.GetDesLength(1); |
|
1481 |
|
1482 /* // If the caller is not SCPEventHandler the deny access |
|
1483 if(aMessage.SecureId() != KSCPEvntHndlrUid) { |
|
1484 return KErrPermissionDenied; |
|
1485 }*/ |
1569 |
1486 |
1570 // Atleast one application id has to be present in the received message (atleast 8 bytes) |
1487 // Atleast one application id has to be present in the received message (atleast 8 bytes) |
1571 if(lCount < sizeof(TInt32)) { |
1488 if(lCount < sizeof(TInt32)) { |
1572 return KErrArgument; |
1489 return KErrArgument; |
1573 } |
1490 } |
1574 |
1491 |
1575 TInt lStatus = KErrNone; |
|
1576 RArray<const TParamChange> lChangeArray; |
1492 RArray<const TParamChange> lChangeArray; |
1577 CleanupClosePushL(lChangeArray); |
1493 CleanupClosePushL(lChangeArray); |
1578 |
1494 |
1579 RPointerArray<HBufC8> lParamValArray; |
1495 RPointerArray<HBufC8> lParamValArray; |
1580 CleanupClosePushL(lParamValArray); |
1496 CleanupClosePushL(lParamValArray); |
1581 |
1497 |
1582 HBufC8* lBuffer = HBufC8 :: NewLC(lCount); |
1498 HBufC8* lBuffer = HBufC8 :: NewLC(lCount); |
1583 TPtr8 bufPtr = lBuffer->Des(); |
1499 TPtr8 bufPtr = lBuffer->Des(); |
1584 aMessage.ReadL(1, bufPtr); |
1500 aMessage.ReadL(1, bufPtr); |
|
1501 |
|
1502 TInt lStatus = KErrNone; |
1585 |
1503 |
1586 TRAPD(lErr, lStatus = iServer.PerformCleanupL(lBuffer, lChangeArray, lParamValArray)); |
1504 TRAPD(lErr, lStatus = iServer.PerformCleanupL(lBuffer, lChangeArray, lParamValArray)); |
1587 |
1505 |
1588 if(lErr != KErrNone) { |
1506 if(lErr != KErrNone) { |
1589 Dprint(_L("[CSCPSession]-> ERROR: SCPServer was unable to complete the operation lErr=%d"), lErr); |
1507 Dprint(_L("[CSCPSession]-> ERROR: SCPServer was unable to complete the operation lErr=%d"), lErr); |
1674 CleanupStack :: PopAndDestroy(); //lChangeArray |
1591 CleanupStack :: PopAndDestroy(); //lChangeArray |
1675 return; |
1592 return; |
1676 } |
1593 } |
1677 |
1594 |
1678 Dprint(_L("[CSCPSession]->INFO: Initiating notification to all the StakeHolders...")); |
1595 Dprint(_L("[CSCPSession]->INFO: Initiating notification to all the StakeHolders...")); |
1679 TRAPD(lErr, NotifyAllStakeHoldersL(lChangeArray, aCallerID)); |
1596 TRAP_IGNORE( NotifyAllStakeHoldersL(lChangeArray, aCallerID)); |
1680 Dprint(_L("[CSCPSession]->INFO: Notification to all the StakeHolders complete...")); |
1597 Dprint(_L("[CSCPSession]->INFO: Notification to all the StakeHolders complete...")); |
1681 CleanupStack :: PopAndDestroy(); //lChangeArray |
1598 CleanupStack :: PopAndDestroy(); //lChangeArray |
1682 } |
1599 } |
|
1600 |
|
1601 void CSCPSession :: ReadFailedPoliciestoMsgBufferL(CSCPParamObject*& aParamObject, const RMessage2& aMessage, TInt aSlotNumber) { |
|
1602 Dprint((_L("[CSCPSession]-> ReadFailedPoliciestoMsgBufferL() >>>"))); |
|
1603 //get failed polices array from param object |
|
1604 const RArray<TInt>& failedPolicesArray = aParamObject->GetFailedPolices(); |
|
1605 |
|
1606 // extra one for failed policies count |
|
1607 HBufC8* failedPoliciesBuf = HBufC8 :: NewLC((EDevicelockTotalPolicies+1) * sizeof(TInt32)); |
|
1608 TPtr8 failedpoliciesBufPtr = failedPoliciesBuf->Des(); |
|
1609 |
|
1610 RDesWriteStream writeStream(failedpoliciesBufPtr); |
|
1611 CleanupClosePushL(writeStream); |
|
1612 |
|
1613 writeStream.WriteInt32L(failedPolicesArray.Count()); |
|
1614 |
|
1615 for(int count =0; count < failedPolicesArray.Count(); count++) { |
|
1616 writeStream.WriteInt32L(failedPolicesArray[count]); |
|
1617 } |
|
1618 |
|
1619 writeStream.CommitL(); |
|
1620 aMessage.WriteL(aSlotNumber, failedPoliciesBuf->Des()); |
|
1621 CleanupStack :: PopAndDestroy(2); //writeStream, failedPoliciesBuf |
|
1622 Dprint((_L("[CSCPSession]-> ReadFailedPoliciestoMsgBufferL() <<<"))); |
|
1623 } |
|
1624 |
|
1625 void CSCPSession :: ValidateLockcodeAgainstPoliciesL(const RMessage2& aMessage) { |
|
1626 Dprint((_L("[CSCPSession]-> ValidateLockcodeAgainstPolicies() <<<"))); |
|
1627 TInt lRet = KErrNone; |
|
1628 HBufC* lockcodeBuf = NULL; |
|
1629 CSCPParamObject* addParams = NULL; |
|
1630 TInt lockcodeLen = aMessage.GetDesLength(0); |
|
1631 Dprint( (_L("CSCPSession :: ValidateLockcodeAgainstPoliciesL: lockcodeLen ->%d"), lockcodeLen )); |
|
1632 if (lockcodeLen == 0) { |
|
1633 User :: Leave(KErrArgument); |
|
1634 } |
|
1635 else { |
|
1636 lockcodeBuf = HBufC :: NewLC(lockcodeLen); |
|
1637 } |
|
1638 |
|
1639 TPtr lockcodeptr = lockcodeBuf->Des(); |
|
1640 TRAP( lRet, aMessage.ReadL( 0, lockcodeptr ) ); |
|
1641 User :: LeaveIfError(lRet); |
|
1642 |
|
1643 lRet = iServer.ValidateLockcodeAgainstPoliciesL(lockcodeptr, addParams); |
|
1644 |
|
1645 if(addParams) { |
|
1646 CleanupStack :: PushL(addParams); |
|
1647 } |
|
1648 |
|
1649 if (lRet != KErrNone) { |
|
1650 ReadFailedPoliciestoMsgBufferL(addParams, aMessage, 1); |
|
1651 } |
|
1652 |
|
1653 if(addParams) { |
|
1654 CleanupStack :: PopAndDestroy(addParams); |
|
1655 } |
|
1656 |
|
1657 CleanupStack :: PopAndDestroy(1); // lockcodeBuf |
|
1658 Dprint((_L("[CSCPSession]-> ValidateLockcodeAgainstPolicies() <<<"))); |
|
1659 User :: LeaveIfError(lRet); |
|
1660 } |