From 77834bd6e589e4729affa79fd2308b2e015d0b0a Mon Sep 17 00:00:00 2001 From: sandaru daminda Date: Tue, 3 Mar 2020 07:15:40 +0000 Subject: [PATCH] Add maximum fails attempts to passcode policy --- .../android/common/bean/PasscodePolicy.java | 29 +++++++++------ .../public/js/operation-bar.js | 3 +- .../public/js/operation-mod.js | 6 ++-- .../public/js/android-policy-edit.js | 15 ++++++++ .../public/templates/android-policy-edit.hbs | 36 +++++++++---------- .../public/templates/android-policy-view.hbs | 34 +++++++++--------- .../public/js/android-policy-operations.js | 15 ++++++++ .../templates/android-policy-operations.hbs | 32 ++++++++--------- 8 files changed, 106 insertions(+), 64 deletions(-) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/PasscodePolicy.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/PasscodePolicy.java index 8cd56e51ec..3d29bb60dc 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/PasscodePolicy.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.common/src/main/java/org/wso2/carbon/device/mgt/mobile/android/common/bean/PasscodePolicy.java @@ -31,13 +31,20 @@ import java.io.Serializable; + "password policy") public class PasscodePolicy extends AndroidOperation implements Serializable { - @ApiModelProperty(name = "maxFailedAttempts", value = "The maximum number of times the end-user can enter" - + " his/her device passcode incorrectly. EMM will take different courses of action based on the" - + " OS when the failed attempts exceed the maximum failed attempts. Android devices will be " - + "automatically reset to the original factory settings", required = true) - - @Max(10) - private int maxFailedAttempts; + @ApiModelProperty(name = "maxFailedAttemptsDeviceLock", value = "The maximum number of times the end-user can enter" + + " his/her device passcode incorrectly. EMM will take different courses of action based on the" + + " OS when the failed attempts exceed the maximum failed attempts. Android devices will be " + + "automatically locked and admin can unlock the device", required = true) + + @Max(10) + private int maxFailedAttemptsDeviceLock; + @ApiModelProperty(name = "maxFailedAttemptsDeviceWipe", value = "The maximum number of times the end-user can enter" + + " his/her device passcode incorrectly. EMM will take different courses of action based on the" + + " OS when the failed attempts exceed the maximum failed attempts. Android devices will be " + + "automatically wiped to factory settings", required = true) + + @Max(10) + private int maxFailedAttemptsDeviceWipe; @ApiModelProperty(name = "minLength", value = "The minimum number of alphanumerical values that the " + "end-user can enter as his/her passcode", required = true) @Max(15) @@ -63,12 +70,12 @@ public class PasscodePolicy extends AndroidOperation implements Serializable { + "Minimum length\n" + "Minimum complex characters", required = true) private boolean allowSimple; - public int getMaxFailedAttempts() { - return maxFailedAttempts; + public int getMaxFailedAttemptsDeviceLock(){ + return maxFailedAttemptsDeviceLock; } - public void setMaxFailedAttempts(int maxFailedAttempts) { - this.maxFailedAttempts = maxFailedAttempts; + public int getMaxFailedAttemptsDeviceWipe(){ + return maxFailedAttemptsDeviceWipe; } public int getMinLength() { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/public/js/operation-bar.js b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/public/js/operation-bar.js index 3aa3e7d42a..f25c056939 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/public/js/operation-bar.js +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-bar/public/js/operation-bar.js @@ -481,7 +481,8 @@ var generatePayload = function (operationCode, operationData, deviceList) { "minComplexChars": operationData["passcodePolicyMinComplexChars"], "maxPINAgeInDays": operationData["passcodePolicyMaxPasscodeAgeInDays"], "pinHistory": operationData["passcodePolicyPasscodeHistory"], - "maxFailedAttempts": operationData["passcodePolicyMaxFailedAttempts"] + "maxFailedAttemptsDeviceLock": operationData["maximumNumberOfFailedAttemptsBeforeDeviceLock"], + "maxFailedAttemptsDeviceWipe": operationData["maximumNumberOfFailedAttemptsBeforeDeviceWipe"] } }; break; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-mod/public/js/operation-mod.js b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-mod/public/js/operation-mod.js index 98c10f832d..5d640f106f 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-mod/public/js/operation-mod.js +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.operation-mod/public/js/operation-mod.js @@ -135,7 +135,8 @@ var androidOperationModule = function () { "passcodePolicyMinComplexChars": operationPayload["minComplexChars"], "passcodePolicyMaxPasscodeAgeInDays": operationPayload["maxPINAgeInDays"], "passcodePolicyPasscodeHistory": operationPayload["pinHistory"], - "passcodePolicyMaxFailedAttempts": operationPayload["maxFailedAttempts"], + "maximumNumberOfFailedAttemptsBeforeDeviceLock": operationPayload["maxFailedAttemptsDeviceLock"], + "maximumNumberOfFailedAttemptsBeforeDeviceWipe": operationPayload["maxFailedAttemptsDeviceWipe"] "passcodePolicyMaxTimeToLock": operationPayload["maxTimeToLock"], "passcodePolicyWPExist": operationPayload["passcodePolicyWPExist"] }; @@ -576,9 +577,10 @@ var androidOperationModule = function () { "minComplexChars": operationData["passcodePolicyMinComplexChars"], "maxPINAgeInDays": operationData["passcodePolicyMaxPasscodeAgeInDays"], "pinHistory": operationData["passcodePolicyPasscodeHistory"], - "maxFailedAttempts": operationData["passcodePolicyMaxFailedAttempts"], "maxTimeToLock": operationData["passcodePolicyMaxTimeToLock"], "passcodePolicyWPExist": operationData["passcodePolicyWPExist"] + "maxFailedAttemptsDeviceLock": operationData["maximumNumberOfFailedAttemptsBeforeDeviceLock"], + "maxFailedAttemptsDeviceWipe": operationData["maximumNumberOfFailedAttemptsBeforeDeviceWipe"] } }; workProfilePasscode = {}; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/js/android-policy-edit.js b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/js/android-policy-edit.js index 4b2bc2bf25..02059ce19c 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/js/android-policy-edit.js +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/js/android-policy-edit.js @@ -368,6 +368,21 @@ var validatePolicyProfile = function () { } } + //validating davice lock fail attempts for device wipe + var passcodePolicyMaxfailAttemptsForDeviceLock = $("input#Maximum-number-of-failed-attempts-before-device-lock").val(); + var passcodePolicyMaxfailAttemptsForDeviceWipe = $("input#Maximum-number-of-failed-attempts-before-device-wipe").val(); + + if (passcodePolicyMaxfailAttemptsForDeviceLock && passcodePolicyMaxfailAttemptsForDeviceWipe) { + if (passcodePolicyMaxfailAttemptsForDeviceLock >= passcodePolicyMaxfailAttemptsForDeviceWipe) { + validationStatus = { + "error": true, + "subErrorMsg": "Provided maximum faild attempts for device wipe should be grater than device lock fail attempts.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + // validating second and last input: passcodePolicyPasscodeHistory if (continueToCheckNextInputs) { var passcodePolicyPasscodeHistory = $("input#passcode-policy-passcode-history").val(); diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/templates/android-policy-edit.hbs b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/templates/android-policy-edit.hbs index f57a3bd5c0..838369bb90 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/templates/android-policy-edit.hbs +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/templates/android-policy-edit.hbs @@ -325,27 +325,27 @@
-
+ +
+ - +
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-view/public/templates/android-policy-view.hbs b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-view/public/templates/android-policy-view.hbs index 98e0abca3f..ae3bfc105a 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-view/public/templates/android-policy-view.hbs +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-view/public/templates/android-policy-view.hbs @@ -309,27 +309,29 @@
-
+ +
+ - +
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/js/android-policy-operations.js b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/js/android-policy-operations.js index 12b893c494..9da7dfc227 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/js/android-policy-operations.js +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/js/android-policy-operations.js @@ -310,6 +310,21 @@ var validatePolicyProfile = function () { } } + //validating davice lock fail attempts for device wipe + var passcodePolicyMaxfailAttemptsForDeviceLock = $("input#Maximum-number-of-failed-attempts-before-device-lock").val(); + var passcodePolicyMaxfailAttemptsForDeviceWipe = $("input#Maximum-number-of-failed-attempts-before-device-wipe").val(); + + if (passcodePolicyMaxfailAttemptsForDeviceLock && passcodePolicyMaxfailAttemptsForDeviceWipe) { + if (passcodePolicyMaxfailAttemptsForDeviceLock >= passcodePolicyMaxfailAttemptsForDeviceWipe) { + validationStatus = { + "error": true, + "subErrorMsg": "Provided maximum faild attempts for device wipe should be grater than device lock fail attempts.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + // validating second and last input: passcodePolicyPasscodeHistory if (continueToCheckNextInputs) { var passcodePolicyPasscodeHistory = $("input#passcode-policy-passcode-history").val(); diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/templates/android-policy-operations.hbs b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/templates/android-policy-operations.hbs index 4a026c6526..67eb789a90 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/templates/android-policy-operations.hbs +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/templates/android-policy-operations.hbs @@ -332,28 +332,28 @@ data-key="passcodePolicyPasscodeHistory" maxlength="2">
+
maximumNumberOfFailedAttemptsBeforeDeviceLock + + +
+
-