diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseService.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseService.java index 8ba820d18..348a9008d 100644 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseService.java +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseService.java @@ -19,17 +19,11 @@ package org.wso2.carbon.device.mgt.iot.androidsense.service.impl; import org.wso2.carbon.apimgt.annotations.api.API; -import org.wso2.carbon.apimgt.annotations.api.Permission; +import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.DeviceType; import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.Feature; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; + +import javax.ws.rs.*; import javax.ws.rs.core.Response; @DeviceType(value = "android_sense") @@ -45,7 +39,7 @@ public interface AndroidSenseService { @Path("device/{deviceId}/words") @POST @Feature(code = "keywords", name = "Add Keywords", description = "Send keywords to the device") - @Permission(scope = "android_sense_user", permissions = {"/permission/admin/device-mgt/user/operations"}) + @Scope(key = "device:android-sense:enroll", name = "", description = "") Response sendKeyWords(@PathParam("deviceId") String deviceId, @QueryParam("keywords") String keywords); /** @@ -57,13 +51,13 @@ public interface AndroidSenseService { @Path("device/{deviceId}/words/threshold") @POST @Feature(code = "threshold", name = "Add a Threshold", description = "Set a threshold for word in the device") - @Permission(scope = "android_sense_user", permissions = {"/permission/admin/device-mgt/user/operations"}) + @Scope(key = "device:android-sense:enroll", name = "", description = "") Response sendThreshold(@PathParam("deviceId") String deviceId, @QueryParam("threshold") String threshold); @Path("device/{deviceId}/words") @DELETE @Feature(code = "remove", name = "Remove Keywords", description = "Remove the keywords") - @Permission(scope = "android_sense_user", permissions = {"/permission/admin/device-mgt/user/operations"}) + @Scope(key = "device:android-sense:enroll", name = "", description = "") Response removeKeyWords(@PathParam("deviceId") String deviceId, @QueryParam("words") String words); /** @@ -72,7 +66,7 @@ public interface AndroidSenseService { @Path("stats/{deviceId}/sensors/{sensorName}") @GET @Consumes("application/json") - @Permission(scope = "android_sense_user", permissions = {"/permission/admin/device-mgt/user/stats"}) + @Scope(key = "device:android-sense:enroll", name = "", description = "") @Produces("application/json") Response getAndroidSenseDeviceStats(@PathParam("deviceId") String deviceId, @PathParam("sensorName") String sensor, @QueryParam("from") long from, @QueryParam("to") long to); @@ -82,7 +76,7 @@ public interface AndroidSenseService { */ @Path("device/{device_id}/register") @POST - @Permission(scope = "android_sense_user", permissions = {"/permission/admin/device-mgt/user/devices"}) + @Scope(key = "device:android-sense:enroll", name = "", description = "") Response register(@PathParam("device_id") String deviceId, @QueryParam("deviceName") String deviceName); } diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.analytics-view/analytics-view.js b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.analytics-view/analytics-view.js index 070e9f2df..144acffcc 100644 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.analytics-view/analytics-view.js +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.analytics-view/analytics-view.js @@ -27,7 +27,7 @@ function onRequest(context) { "backendApiUri": devicemgtProps["httpsURL"] + "/android_sense/stats/" }; } else if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) { - var deviceModule = require("/app/modules/device.js").deviceModule; + var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var device = deviceModule.viewDevice(deviceType, deviceId); if (device && device.status != "error") { return { diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view/device-view.js b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view/device-view.js index 4424670e3..4df1abcff 100644 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view/device-view.js +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view/device-view.js @@ -25,7 +25,7 @@ function onRequest(context) { ]; if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) { - var deviceModule = require("/app/modules/device.js").deviceModule; + var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var device = deviceModule.viewDevice(deviceType, deviceId); if (device && device.status != "error") { return { diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/analytics-view.js b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/analytics-view.js index a0a8c1602..8d783f1ab 100644 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/analytics-view.js +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/analytics-view.js @@ -18,7 +18,7 @@ function onRequest(context) { var device = context.unit.params.device; - var devicemgtProps = require("/app/conf/reader/main.js")["conf"]; + var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var constants = require("/app/modules/constants.js"); var websocketEndpoint = devicemgtProps["httpsURL"].replace("https", "wss"); var tokenPair = session.get(constants.ACCESS_TOKEN_PAIR_IDENTIFIER); diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.js b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.js index 2fad1ce56..0badb0355 100644 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.js +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.js @@ -18,7 +18,7 @@ function onRequest(context){ var viewModel = {}; - var devicemgtProps = require("/app/conf/reader/main.js")["conf"]; + var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; viewModel.hostName = devicemgtProps["httpsWebURL"]; return viewModel; } \ No newline at end of file diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoService.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoService.java index afe0c89b1..9e0c97ec3 100644 --- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoService.java +++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoService.java @@ -19,16 +19,11 @@ package org.wso2.carbon.device.mgt.iot.arduino.service.impl; import org.wso2.carbon.apimgt.annotations.api.API; -import org.wso2.carbon.apimgt.annotations.api.Permission; +import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.DeviceType; import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.Feature; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; + +import javax.ws.rs.*; import javax.ws.rs.core.Response; @API(name = "arduino", version = "1.0.0", context = "/arduino", tags = {"arduino"}) @@ -38,12 +33,12 @@ public interface ArduinoService { @Path("device/{deviceId}/bulb") @POST @Feature(code = "bulb", name = "Control Bulb", description = "Control Bulb on Arduino Uno") - @Permission(scope = "arduino_user", permissions = {"/permission/admin/device-mgt/user/operations"}) + @Scope(key = "device:arduino:enroll", name = "", description = "") Response switchBulb(@PathParam("deviceId") String deviceId, @QueryParam("state") String state); @Path("device/{deviceId}/controls") @GET - @Permission(scope = "arduino_device", permissions = {"/permission/admin/device-mgt/user/operations"}) + @Scope(key = "device:arduino:enroll", name = "", description = "") Response readControls(@PathParam("deviceId") String deviceId); /** @@ -53,7 +48,7 @@ public interface ArduinoService { @GET @Consumes("application/json") @Produces("application/json") - @Permission(scope = "arduino_user", permissions = {"/permission/admin/device-mgt/user/stats"}) + @Scope(key = "device:arduino:enroll", name = "", description = "") Response getArduinoTemperatureStats(@PathParam("deviceId") String deviceId, @QueryParam("from") long from, @QueryParam("to") long to); @@ -63,7 +58,7 @@ public interface ArduinoService { @Path("device/download") @GET @Produces("application/octet-stream") - @Permission(scope = "arduino_user", permissions = {"/permission/admin/device-mgt/user/devices"}) + @Scope(key = "device:arduino:enroll", name = "", description = "") Response downloadSketch(@QueryParam("deviceName") String customDeviceName); } diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.analytics-view/analytics-view.js b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.analytics-view/analytics-view.js index 4f5c58b55..ef49dbe96 100644 --- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.analytics-view/analytics-view.js +++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.analytics-view/analytics-view.js @@ -17,7 +17,7 @@ */ function onRequest(context) { - var devicemgtProps = require("/app/conf/reader/main.js")["conf"]; + var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var devices = context.unit.params.devices; var deviceType = context.uriParams.deviceType; @@ -29,7 +29,7 @@ function onRequest(context) { "backendApiUri": devicemgtProps["httpsURL"] + "/arduino/device/stats/" }; } else if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) { - var deviceModule = require("/app/modules/device.js").deviceModule; + var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var device = deviceModule.viewDevice(deviceType, deviceId); if (device && device.status != "error") { return { diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/device-view.js b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/device-view.js index 333564290..3ec4bb34c 100644 --- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/device-view.js +++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/device-view.js @@ -25,7 +25,7 @@ function onRequest(context) { ]; if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) { - var deviceModule = require("/app/modules/device.js").deviceModule; + var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var device = deviceModule.viewDevice(deviceType, deviceId); if (device && device.status != "error") { return {"device": device, "backendApiUri" : devicemgtProps["httpsURL"] + "/arduino/", "autoCompleteParams" : autoCompleteParams}; diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/analytics-view.js b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/analytics-view.js index d5b886085..655c182d1 100644 --- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/analytics-view.js +++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/analytics-view.js @@ -19,7 +19,7 @@ function onRequest(context) { var log = new Log("stats.js"); var device = context.unit.params.device; - var devicemgtProps = require("/app/conf/reader/main.js")["conf"]; + var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var constants = require("/app/modules/constants.js"); var websocketEndpoint = devicemgtProps["wssURL"].replace("https", "wss"); var tokenPair = session.get(constants.ACCESS_TOKEN_PAIR_IDENTIFIER); diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/api/policy-api.jag b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/api/policy-api.jag index fb9e2215d..43379ec75 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/api/policy-api.jag +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/api/policy-api.jag @@ -23,7 +23,7 @@ var uriMatcher = new URIMatcher(String(uri)); var log = new Log("api/policy-api.jag"); var constants = require("/app/modules/constants.js"); -var policyModule = require("/app/modules/policy.js").policyModule; +var policyModule = require("/app/modules/business-controllers/policy.js")["policyModule"]; var deviceType, deviceId; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/iot.page.register/register.js b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/iot.page.register/register.js index b3cbd10f1..f359aabc9 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/iot.page.register/register.js +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/iot.page.register/register.js @@ -23,7 +23,7 @@ * @returns {*} A context object that returns the dynamic state of this page to be presented */ function onRequest(context) { - var devicemgtProps = require("/app/conf/reader/main.js")["conf"]; + var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var page = {}; page["usernameJSRegEx"] = devicemgtProps.userValidationConfig.usernameJSRegEx; page["usernameHelpText"] = devicemgtProps.userValidationConfig.usernameHelpMsg; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.operation-bar/operation-bar.js b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.operation-bar/operation-bar.js index 49f417285..d1a58b9bd 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.operation-bar/operation-bar.js +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.operation-bar/operation-bar.js @@ -18,7 +18,7 @@ function onRequest(context) { var log = new Log("operation.js"); - var operationModule = require("/app/modules/operation.js").operationModule; + var operationModule = require("/app/modules/business-controllers/operation.js")["operationModule"]; var device = context.unit.params.device; var autoCompleteParams = context.unit.params.autoCompleteParams; var controlOperations = operationModule.getControlOperations(device.type); diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/edit.js b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/edit.js index 36b130ca0..3f4446f30 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/edit.js +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/edit.js @@ -19,7 +19,7 @@ function onRequest(context) { var log = new Log("policy-view-edit-unit backend js"); log.debug("calling policy-view-edit-unit"); - var userModule = require("/app/modules/user.js").userModule; + var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; context.roles = userModule.getRoles().content; return context; } \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/view.js b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/view.js index 36b130ca0..3f4446f30 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/view.js +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/view.js @@ -19,7 +19,7 @@ function onRequest(context) { var log = new Log("policy-view-edit-unit backend js"); log.debug("calling policy-view-edit-unit"); - var userModule = require("/app/modules/user.js").userModule; + var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; context.roles = userModule.getRoles().content; return context; } \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/wizard.js b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/wizard.js index 1404144fe..a08faad08 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/wizard.js +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/wizard.js @@ -22,8 +22,8 @@ function onRequest(context) { var DTYPE_CONF_DEVICE_TYPE_KEY = "deviceType"; var DTYPE_CONF_DEVICE_TYPE_LABEL_KEY = "label"; - var userModule = require("/app/modules/user.js")["userModule"]; - var deviceModule = require("/app/modules/device.js").deviceModule; + var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; + var deviceModule = require("/app/modules/business-controllers/device.js").deviceModule; var utility = require('/app/modules/utility.js').utility; var response = userModule.getRoles(); var wizardPage = {}; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/pom.xml b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/pom.xml index e27711dd3..2b0116e9d 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/pom.xml +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/pom.xml @@ -192,7 +192,7 @@ smackx - commons-codec.wso2 + commons-codec commons-codec diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/CertificateKeystoreConfig.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/CertificateKeystoreConfig.java new file mode 100644 index 000000000..972975a64 --- /dev/null +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/CertificateKeystoreConfig.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * you may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.device.mgt.iot.devicetype.config; + + +import org.wso2.carbon.device.mgt.iot.devicetype.util.DeviceTypeConfigUtil; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Class for holding CertificateKeystore data. + */ +@XmlRootElement(name = "CertificateKeystore") +public class CertificateKeystoreConfig { + + private String certificateKeystoreLocation; + private String certificateKeystoreType; + private String certificateKeystorePassword; + private String caCertAlias; + private String caPrivateKeyPassword; + private String raCertAlias; + private String raPrivateKeyPassword; + + @XmlElement(name = "CertificateKeystoreLocation", required = true) + public String getCertificateKeystoreLocation() { + return certificateKeystoreLocation; + } + + public void setCertificateKeystoreLocation(String certificateKeystoreLocation) { + if (certificateKeystoreLocation != null && certificateKeystoreLocation.toLowerCase(). + contains(DeviceTypeConfigUtil.CARBON_HOME_ENTRY)) { + certificateKeystoreLocation = certificateKeystoreLocation.replace(DeviceTypeConfigUtil.CARBON_HOME_ENTRY, + System.getProperty(DeviceTypeConfigUtil.CARBON_HOME)); + } + this.certificateKeystoreLocation = certificateKeystoreLocation; + } + + @XmlElement(name = "CertificateKeystoreType", required = true) + public String getCertificateKeystoreType() { + return certificateKeystoreType; + } + + public void setCertificateKeystoreType(String certificateKeystoreType) { + this.certificateKeystoreType = certificateKeystoreType; + } + + @XmlElement(name = "CertificateKeystorePassword", required = true) + public String getCertificateKeystorePassword() { + return certificateKeystorePassword; + } + + public void setCertificateKeystorePassword(String certificateKeystorePassword) { + this.certificateKeystorePassword = certificateKeystorePassword; + } + + @XmlElement(name = "CACertAlias", required = true) + public String getCACertAlias() { + return caCertAlias; + } + + public void setCACertAlias(String caCertAlias) { + this.caCertAlias = caCertAlias; + } + + @XmlElement(name = "CAPrivateKeyPassword", required = true) + public String getCAPrivateKeyPassword() { + return caPrivateKeyPassword; + } + + public void setCAPrivateKeyPassword(String caPrivateKeyPassword) { + this.caPrivateKeyPassword = caPrivateKeyPassword; + } + + @XmlElement(name = "RACertAlias", required = true) + public String getRACertAlias() { + return raCertAlias; + } + + public void setRACertAlias(String raCertAlias) { + this.raCertAlias = raCertAlias; + } + + @XmlElement(name = "RAPrivateKeyPassword", required = true) + public String getRAPrivateKeyPassword() { + return raPrivateKeyPassword; + } + + public void setRAPrivateKeyPassword(String raPrivateKeyPassword) { + this.raPrivateKeyPassword = raPrivateKeyPassword; + } +} diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/DeviceManagementConfiguration.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/DeviceManagementConfiguration.java index ffda827a6..55b816566 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/DeviceManagementConfiguration.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/config/DeviceManagementConfiguration.java @@ -30,6 +30,7 @@ public class DeviceManagementConfiguration { private DeviceManagementConfigRepository deviceManagementConfigRepository; private PushNotificationConfig pushNotificationConfig; private String deviceType; + private CertificateKeystoreConfig certificateKeystoreConfig; private static final Log log = LogFactory.getLog(DeviceManagementConfiguration.class); @@ -63,4 +64,13 @@ public class DeviceManagementConfiguration { this.pushNotificationConfig = pushNotificationConfig; } + @XmlElement(name = "CertificateKeystore", required = false) + public CertificateKeystoreConfig getCertificateKeystoreConfig() { + return certificateKeystoreConfig; + } + + public void setCertificateKeystoreConfig( + CertificateKeystoreConfig certificateKeystoreConfig) { + this.certificateKeystoreConfig = certificateKeystoreConfig; + } } diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/util/DeviceTypeConfigUtil.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/util/DeviceTypeConfigUtil.java index 4184c1a3e..a32a88bdf 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/util/DeviceTypeConfigUtil.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/util/DeviceTypeConfigUtil.java @@ -31,6 +31,9 @@ import java.io.File; public class DeviceTypeConfigUtil { + public static final String CARBON_HOME = "carbon.home"; + public static final String CARBON_HOME_ENTRY = "${carbon.home}"; + public static Document convertToDocument(File file) throws DeviceTypeConfigurationException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiService.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiService.java index 299f7be26..00236ddbe 100644 --- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiService.java +++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiService.java @@ -19,16 +19,11 @@ package org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl; import org.wso2.carbon.apimgt.annotations.api.API; -import org.wso2.carbon.apimgt.annotations.api.Permission; +import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.DeviceType; import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.Feature; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; + +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @@ -39,7 +34,7 @@ public interface RaspberryPiService { @Path("device/{deviceId}/bulb") @POST @Feature(code = "bulb", name = "Bulb On / Off", description = "Switch on/off Raspberry Pi agent's bulb. (On / Off)") - @Permission(scope = "raspberrypi_user", permissions = {"/permission/admin/device-mgt/user/operations"}) + @Scope(key = "device:raspberrypi:enroll", name = "", description = "") Response switchBulb(@PathParam("deviceId") String deviceId, @QueryParam("state") String state); /** @@ -49,7 +44,7 @@ public interface RaspberryPiService { @GET @Consumes("application/json") @Produces("application/json") - @Permission(scope = "raspberrypi_user", permissions = {"/permission/admin/device-mgt/user/stats"}) + @Scope(key = "device:raspberrypi:enroll", name = "", description = "") Response getRaspberryPiTemperatureStats(@PathParam("deviceId") String deviceId, @QueryParam("from") long from, @QueryParam("to") long to); @@ -59,7 +54,7 @@ public interface RaspberryPiService { @Path("device/download") @GET @Produces(MediaType.APPLICATION_JSON) - @Permission(scope = "raspberrypi_user", permissions = {"/permission/admin/device-mgt/user/devices"}) + @Scope(key = "device:raspberrypi:enroll", name = "", description = "") Response downloadSketch(@QueryParam("deviceName") String deviceName, @QueryParam("sketch_type") String sketchType); } diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/analytics-view.js b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/analytics-view.js index 3d9d7ef10..f9b7d0801 100644 --- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/analytics-view.js +++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/analytics-view.js @@ -17,7 +17,7 @@ */ function onRequest(context) { - var devicemgtProps = require("/app/conf/reader/main.js")["conf"]; + var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var devices = context.unit.params.devices; var deviceType = context.uriParams.deviceType; @@ -29,7 +29,7 @@ function onRequest(context) { "backendApiUri": devicemgtProps["httpsURL"] + "/raspberrypi/device/stats/" }; } else if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) { - var deviceModule = require("/app/modules/device.js").deviceModule; + var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var device = deviceModule.viewDevice(deviceType, deviceId); if (device && device.status != "error") { return { diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/device-view.js b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/device-view.js index e42064688..62305b58e 100644 --- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/device-view.js +++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/device-view.js @@ -25,7 +25,7 @@ function onRequest(context) { ]; if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) { - var deviceModule = require("/app/modules/device.js").deviceModule; + var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var device = deviceModule.viewDevice(deviceType, deviceId); if (device && device.status != "error") { return {"device": device, "backendApiUri" : devicemgtProps["httpsURL"] + "/raspberrypi/", "autoCompleteParams" : autoCompleteParams}; diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/analytics-view.js b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/analytics-view.js index d5b886085..655c182d1 100644 --- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/analytics-view.js +++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/analytics-view.js @@ -19,7 +19,7 @@ function onRequest(context) { var log = new Log("stats.js"); var device = context.unit.params.device; - var devicemgtProps = require("/app/conf/reader/main.js")["conf"]; + var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var constants = require("/app/modules/constants.js"); var websocketEndpoint = devicemgtProps["wssURL"].replace("https", "wss"); var tokenPair = session.get(constants.ACCESS_TOKEN_PAIR_IDENTIFIER); diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/pom.xml b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/pom.xml index f9280d521..a5dffc290 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/pom.xml +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/pom.xml @@ -125,7 +125,7 @@ - commons-codec.wso2 + commons-codec commons-codec diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/pom.xml b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/pom.xml index b124944ff..a91cf4275 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/pom.xml +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/pom.xml @@ -134,7 +134,7 @@ - commons-codec.wso2 + commons-codec commons-codec diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/pom.xml b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/pom.xml index a23269b76..53d5cfba2 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/pom.xml +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/pom.xml @@ -69,7 +69,7 @@ provided - commons-codec.wso2 + commons-codec commons-codec @@ -208,7 +208,7 @@ - commons-codec.wso2 + commons-codec commons-codec diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmService.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmService.java index 9f380dcde..9d89050fb 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmService.java +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmService.java @@ -19,7 +19,7 @@ package org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl; import org.wso2.carbon.apimgt.annotations.api.API; -import org.wso2.carbon.apimgt.annotations.api.Permission; +import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.DeviceType; import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.Feature; @@ -48,7 +48,7 @@ public interface VirtualFireAlarmService { */ @POST @Path("device/{deviceId}/buzz") - @Permission(scope = "virtual_firealarm_user", permissions = {"/permission/admin/device-mgt/user/operations"}) + @Scope(key = "device:firealarm:enroll", name = "", description = "") @Feature(code = "buzz", name = "Buzzer On / Off", description = "Switch on/off Virtual Fire Alarm Buzzer. (On / Off)") Response switchBuzzer(@PathParam("deviceId") String deviceId, @FormParam("state") String state); @@ -58,7 +58,7 @@ public interface VirtualFireAlarmService { */ @Path("device/stats/{deviceId}") @GET - @Permission(scope = "virtual_firealarm_user", permissions = {"/permission/admin/device-mgt/user/stats"}) + @Scope(key = "device:firealarm:enroll", name = "", description = "") @Consumes("application/json") @Produces("application/json") Response getVirtualFirealarmStats(@PathParam("deviceId") String deviceId, @QueryParam("from") long from, @@ -67,7 +67,7 @@ public interface VirtualFireAlarmService { @Path("device/download") @GET @Produces("application/zip") - @Permission(scope = "virtual_firealarm_user", permissions = {"/permission/admin/device-mgt/user/devices"}) + @Scope(key = "device:firealarm:enroll", name = "", description = "") Response downloadSketch(@QueryParam("deviceName") String deviceName, @QueryParam("sketchType") String sketchType); } diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml index 4dfe501c3..8a5c0077a 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml @@ -98,7 +98,7 @@ - commons-codec.wso2 + commons-codec commons-codec diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/VirtualFirealarmSecurityManager.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/VirtualFirealarmSecurityManager.java index 257ed36c6..9f318e165 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/VirtualFirealarmSecurityManager.java +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/util/VirtualFirealarmSecurityManager.java @@ -22,8 +22,11 @@ import org.apache.commons.codec.binary.Base64; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.certificate.mgt.core.exception.KeystoreException; -import org.wso2.carbon.certificate.mgt.core.util.ConfigurationUtil; +import org.wso2.carbon.device.mgt.iot.devicetype.config.CertificateKeystoreConfig; +import org.wso2.carbon.device.mgt.iot.devicetype.config.DeviceManagementConfiguration; +import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.constants.VirtualFireAlarmConstants; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.exception.VirtualFirealarmDeviceMgtPluginException; +import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.internal.VirtualFirealarmManagementDataHolder; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; @@ -46,11 +49,11 @@ import java.security.SignatureException; import java.security.UnrecoverableKeyException; import java.security.cert.CertificateException; - public class VirtualFirealarmSecurityManager { private static final Log log = LogFactory.getLog(VirtualFirealarmSecurityManager.class); private static PrivateKey serverPrivateKey; + private static CertificateKeystoreConfig certificateKeystoreConfig; private static final String SIGNATURE_ALG = "SHA1withRSA"; private static final String CIPHER_PADDING = "RSA/ECB/PKCS1Padding"; @@ -58,26 +61,34 @@ public class VirtualFirealarmSecurityManager { } - public static void initVerificationManager() { - serverPrivateKey = retrievePrivateKey(ConfigurationUtil.CA_CERT_ALIAS, - ConfigurationUtil.KEYSTORE_CA_CERT_PRIV_PASSWORD); + private static CertificateKeystoreConfig getCertKeyStoreConfig() { + if (certificateKeystoreConfig == null) { + DeviceManagementConfiguration deviceManagementConfiguration = VirtualFirealarmManagementDataHolder.getInstance(). + getDeviceTypeConfigService().getConfiguration( + VirtualFireAlarmConstants.DEVICE_TYPE, + VirtualFireAlarmConstants.DEVICE_TYPE_PROVIDER_DOMAIN); + certificateKeystoreConfig = deviceManagementConfiguration.getCertificateKeystoreConfig(); + } + return certificateKeystoreConfig; } - public static PrivateKey retrievePrivateKey(String alias, String password){ + public static void initVerificationManager() { + serverPrivateKey = retrievePrivateKey(); + } + + public static PrivateKey retrievePrivateKey() { PrivateKey privateKey = null; InputStream inputStream = null; KeyStore keyStore; - + CertificateKeystoreConfig certificateKeystoreConfig = getCertKeyStoreConfig(); try { - keyStore = KeyStore.getInstance(ConfigurationUtil.getConfigEntry(ConfigurationUtil.CERTIFICATE_KEYSTORE)); - inputStream = new FileInputStream(ConfigurationUtil.getConfigEntry( - ConfigurationUtil.PATH_CERTIFICATE_KEYSTORE)); + keyStore = KeyStore.getInstance(certificateKeystoreConfig.getCertificateKeystoreType()); + inputStream = new FileInputStream(certificateKeystoreConfig.getCertificateKeystoreLocation()); - keyStore.load(inputStream, ConfigurationUtil.getConfigEntry(ConfigurationUtil.CERTIFICATE_KEYSTORE_PASSWORD) - .toCharArray()); + keyStore.load(inputStream, certificateKeystoreConfig.getCertificateKeystorePassword().toCharArray()); - privateKey = (PrivateKey) (keyStore.getKey(ConfigurationUtil.getConfigEntry(alias), - ConfigurationUtil.getConfigEntry(password).toCharArray())); + privateKey = (PrivateKey) (keyStore.getKey(certificateKeystoreConfig.getCACertAlias(), + certificateKeystoreConfig.getCAPrivateKeyPassword().toCharArray())); } catch (KeyStoreException e) { String errorMsg = "Could not load KeyStore of given type in [certificate-config.xml] file." ; @@ -94,9 +105,6 @@ public class VirtualFirealarmSecurityManager { } catch (IOException e) { String errorMsg = "Input output issue occurred when loading KeyStore"; log.error(errorMsg, e); - } catch (KeystoreException e) { - String errorMsg = "An error occurred whilst trying load Configs for KeyStoreReader"; - log.error(errorMsg, e); } catch (UnrecoverableKeyException e) { String errorMsg = "Key is unrecoverable when retrieving CA private key"; log.error(errorMsg, e); diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/pom.xml b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/pom.xml index 0fa58551c..1cf6753b6 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/pom.xml +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/pom.xml @@ -57,7 +57,7 @@ provided - commons-codec.wso2 + commons-codec commons-codec @@ -171,7 +171,7 @@ - commons-codec.wso2 + commons-codec commons-codec diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/analytics-view.js b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/analytics-view.js index 276b35824..2e8285abf 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/analytics-view.js +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/analytics-view.js @@ -17,7 +17,7 @@ */ function onRequest(context) { - var devicemgtProps = require("/app/conf/reader/main.js")["conf"]; + var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var devices = context.unit.params.devices; var deviceType = context.uriParams.deviceType; @@ -29,7 +29,7 @@ function onRequest(context) { "backendApiUri": devicemgtProps["httpsURL"] + "/virtual_firealarm/device/stats/" }; } else if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) { - var deviceModule = require("/app/modules/device.js").deviceModule; + var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var device = deviceModule.viewDevice(deviceType, deviceId); if (device && device.status != "error") { return { diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/device-view.js b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/device-view.js index 4dd97dd23..2e3ea2abf 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/device-view.js +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/device-view.js @@ -25,7 +25,7 @@ function onRequest(context) { ]; if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) { - var deviceModule = require("/app/modules/device.js").deviceModule; + var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var device = deviceModule.viewDevice(deviceType, deviceId); if (device && device.status != "error") { return {"device": device, "backendApiUri" : devicemgtProps["httpsURL"] + "/virtual_firealarm/", "autoCompleteParams" : autoCompleteParams}; diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/analytics-view.js b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/analytics-view.js index 7493d6897..e4b0e14b0 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/analytics-view.js +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/analytics-view.js @@ -19,7 +19,7 @@ function onRequest(context) { var log = new Log("stats.js"); var device = context.unit.params.device; - var devicemgtProps = require("/app/conf/reader/main.js")["conf"]; + var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var constants = require("/app/modules/constants.js"); var websocketEndpoint = devicemgtProps["wssURL"].replace("https", "wss"); var jwtService = carbon.server.osgiService('org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService'); diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AndroidPlatformConfiguration.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AndroidPlatformConfiguration.java index 19623877e..be290151d 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AndroidPlatformConfiguration.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/AndroidPlatformConfiguration.java @@ -23,7 +23,6 @@ import io.swagger.annotations.ApiModelProperty; import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; import javax.validation.constraints.Size; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -52,7 +51,6 @@ public class AndroidPlatformConfiguration implements Serializable { ) @NotNull @Size(min = 2, max = 10) - @Pattern(regexp = "^[A-Za-z0-9]*$") private String type; @ApiModelProperty( name = "configuration", diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EventBeanWrapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EventBeanWrapper.java index c6efc2131..c4fb13e07 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EventBeanWrapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/wrapper/EventBeanWrapper.java @@ -21,7 +21,6 @@ package org.wso2.carbon.mdm.services.android.bean.wrapper; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import javax.validation.constraints.Pattern; import javax.validation.constraints.Size; /** @@ -33,7 +32,6 @@ public class EventBeanWrapper { @ApiModelProperty(name = "deviceIdentifier", value = "DeviceIdentifier to be need to retrieve/publish Event.", required = true) @Size(min = 2, max = 45) - @Pattern(regexp = "^[A-Za-z0-9]*$") private String deviceIdentifier; @ApiModelProperty(name = "payload", value = "Event payload.", required = true) private String payload; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/GlobalThrowableMapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/GlobalThrowableMapper.java index f324a2d0f..631c3e6ae 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/GlobalThrowableMapper.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/GlobalThrowableMapper.java @@ -50,32 +50,41 @@ public class GlobalThrowableMapper implements ExceptionMapper { if (e instanceof JsonParseException) { String errorMessage = "Malformed request body."; - log.error(errorMessage); + if (log.isDebugEnabled()) { + log.error(errorMessage, e); + } return AndroidDeviceUtils.buildBadRequestException(errorMessage).getResponse(); - } if (e instanceof NotFoundException) { return ((NotFoundException) e).getResponse(); } - if (e instanceof ConstraintViolationException) { - log.error("Constraint violation", e); - return Response.status(Response.Status.BAD_REQUEST).header("Content-Type", "application/json") - .entity(400l).build(); + if (e instanceof BadRequestException) { + return ((BadRequestException) e).getResponse(); } if (e instanceof UnexpectedServerErrorException) { - log.error("Unexpected server error", e); + if (log.isDebugEnabled()) { + log.error("Unexpected server error", e); + } return ((UnexpectedServerErrorException) e).getResponse(); } if (e instanceof ConstraintViolationException) { return ((ParameterValidationException) e).getResponse(); } if (e instanceof IllegalArgumentException) { - log.error("Illegal exception.", e); - return Response.status(Response.Status.BAD_REQUEST).header("Content-Type", "application/json") - .entity(400l).build(); + ErrorDTO errorDetail = new ErrorDTO(); + errorDetail.setCode((long) 400); + errorDetail.setMoreInfo(""); + errorDetail.setMessage(""); + errorDetail.setDescription(e.getMessage()); + return Response + .status(Response.Status.BAD_REQUEST) + .entity(errorDetail) + .build(); } if (e instanceof ClientErrorException) { - log.error("Client error", e); + if (log.isDebugEnabled()) { + log.error("Client error", e); + } return ((ClientErrorException) e).getResponse(); } if (e instanceof AuthenticationException) { @@ -90,11 +99,15 @@ public class GlobalThrowableMapper implements ExceptionMapper { .build(); } if (e instanceof ForbiddenException) { - log.error("Resource forbidden", e); + if (log.isDebugEnabled()) { + log.error("Resource forbidden", e); + } return ((ForbiddenException) e).getResponse(); } //unknown exception log and return - log.error("An Unknown exception has been captured by global exception mapper.", e); + if (log.isDebugEnabled()) { + log.error("An Unknown exception has been captured by global exception mapper.", e); + } return Response.status(Response.Status.INTERNAL_SERVER_ERROR).header("Content-Type", "application/json") .entity(e500).build(); } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementAdminService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementAdminService.java index 1ef39dcc6..a23eedb33 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementAdminService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementAdminService.java @@ -19,6 +19,8 @@ package org.wso2.carbon.mdm.services.android.services; import io.swagger.annotations.*; +import org.wso2.carbon.apimgt.annotations.api.API; +import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; import org.wso2.carbon.mdm.services.android.bean.wrapper.*; @@ -30,6 +32,10 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; +@API(name = "Android Device Management Administrative Service", version = "1.0.0", + context = "api/device-mgt/android/v1.0/admin/devices", + tags = {"devicemgt_android"}) + @Path("/admin/devices") @Api(value = "Android Device Management Administrative Service", description = "Device management related admin APIs.") @Produces(MediaType.APPLICATION_JSON) @@ -85,6 +91,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new lock operation.") }) + @Scope(key = "device:android:operation:lock", name = "Lock device", description = "") Response configureDeviceLock( @ApiParam(name = "deviceLockBeanWrapper", value = "Device lock configurations with device IDs") DeviceLockBeanWrapper deviceLockBeanWrapper); @@ -138,6 +145,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new un-lock operation.") }) + @Scope(key = "device:android:operation:unlock", name = "Unlock device", description = "") Response configureDeviceUnlock( @ApiParam(name = "deviceIDs", value = "DeviceIds to be enable device unlock operation") List deviceIDs); @@ -190,6 +198,7 @@ public interface DeviceManagementAdminService { code = 500, message = "Internal Server Error. \n " + "Server error occurred while adding a new get-location operation.")}) + @Scope(key = "device:android:operation:location", name = "Get device location", description = "") Response getDeviceLocation( @ApiParam(name = "deviceIDs", value = "DeviceIDs to be requested to get device location") List deviceIDs); @@ -242,6 +251,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new clear password operation.") }) + @Scope(key = "device:android:operation:clear-password", name = "Clear password of device", description = "") Response removePassword( @ApiParam(name = "deviceIDs", value = "DeviceIds to be requested to remove password") List deviceIDs); @@ -294,6 +304,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new control camera operation.") }) + @Scope(key = "device:android:operation:camera", name = "Enable/Disable camera", description = "") Response configureCamera( @ApiParam(name = "cameraBeanWrapper", value = "Camera enable/disable configurations with device IDs") CameraBeanWrapper cameraBeanWrapper); @@ -349,6 +360,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new device info operation.") }) + @Scope(key = "device:android:operation:info", name = "Get device information", description = "") Response getDeviceInformation( @ApiParam(name = "deviceIds", value = "Device IDs to be requested to get device information") List deviceIDs); @@ -457,6 +469,7 @@ public interface DeviceManagementAdminService { code = 500, message = "Internal Server Error. \n " + "Server error occurred while adding a enterprise wipe operation.")}) + @Scope(key = "device:android:operation:enterprise-wipe", name = "Enterprise wipe", description = "") Response wipeDevice(@ApiParam(name = "deviceIDs", value = "Device IDs to be requested to do enterprise-wipe") List deviceIDs); @@ -508,6 +521,7 @@ public interface DeviceManagementAdminService { code = 500, message = "Internal Server Error. \n " + "Server error occurred while adding a device wipe operation.")}) + @Scope(key = "device:android:operation:wipe", name = "Factory reset device", description = "") Response wipeData( @ApiParam(name = "wipeDataBeanWrapper", value = "Configurations and DeviceIds needed to do wipe-data") WipeDataBeanWrapper wipeDataBeanWrapper); @@ -564,6 +578,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new get-applications operation.") }) + @Scope(key = "device:android:operation:applications", name = "Get installed applications", description = "") Response getApplications( @ApiParam(name = "deviceIDs", value = "Device Ids needed to get applications that are already installed") List deviceIDs); @@ -616,6 +631,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new device ring operation.") }) + @Scope(key = "device:android:operation:ring", name = "Ring device", description = "") Response ringDevice( @ApiParam(name = "deviceIDs", value = "Device Ids needed for ring") List deviceIDs); @@ -668,6 +684,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new device reboot operation.") }) + @Scope(key = "device:android:operation:reboot", name = "Reboot device", description = "") Response rebootDevice( @ApiParam(name = "deviceIDs", value = "Device Ids needed for reboot.") List deviceIDs); @@ -720,6 +737,7 @@ public interface DeviceManagementAdminService { "Server error occurred while adding a new device mute operation.") }) @Path("/mute") + @Scope(key = "device:android:operation:mute", name = "Mute device", description = "") Response muteDevice( @ApiParam(name = "deviceIDs", value = "DeviceIDs need to be muted") List deviceIDs); @@ -775,6 +793,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new install-application operation.") }) + @Scope(key = "device:android:operation:install-app", name = "Install applications", description = "") Response installApplication( @ApiParam(name = "applicationInstallationBeanWrapper", value = "Properties of installed apps and device IDs") ApplicationInstallationBeanWrapper applicationInstallationBeanWrapper); @@ -830,6 +849,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new update-application operation.") }) + @Scope(key = "device:android:operation:update-app", name = "Update installed applications", description = "") Response updateApplication( @ApiParam(name = "applicationUpdateBeanWrapper", value = "Properties of updated apps and device IDs") ApplicationUpdateBeanWrapper applicationUpdateBeanWrapper); @@ -882,6 +902,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new uninstall-application operation.") }) + @Scope(key = "device:android:operation:uninstall-app", name = "Uninstall applications", description = "") Response uninstallApplication( @ApiParam(name = "applicationUninstallationBeanWrapper", value = "applicationUninstallationConfigs and Device Ids") @@ -936,6 +957,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new blacklist-applications operation.") }) + @Scope(key = "device:android:operation:blacklist-app", name = "Blacklist applications", description = "") Response blacklistApplications( @ApiParam(name = "blacklistApplicationsBeanWrapper", value = "BlacklistApplications " + "Configuration and DeviceIds") @@ -990,6 +1012,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new upgrade firmware operation.") }) + @Scope(key = "device:android:operation:upgrade", name = "Upgrade firmware", description = "") Response upgradeFirmware( @ApiParam(name = "upgradeFirmwareBeanWrapper", value = "Firmware upgrade configuration and DeviceIds") @@ -1044,6 +1067,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new configure VPN operation.") }) + @Scope(key = "device:android:operation:vpn", name = "Add VPN profiles", description = "") Response configureVPN( @ApiParam(name = "vpnBeanWrapper", value = "VPN configuration and DeviceIds") @@ -1097,6 +1121,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new send notification operation.") }) + @Scope(key = "device:android:operation:notification", name = "Send notifications", description = "") Response sendNotification( @ApiParam(name = "notificationBeanWrapper", value = "Notification Configurations and device Ids") @@ -1150,6 +1175,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new configure wifi operation.") }) + @Scope(key = "device:android:operation:wifi", name = "Add WiFi configurations", description = "") Response configureWifi( @ApiParam(name = "wifiBeanWrapper", value = "WifiConfigurations and Device Ids") WifiBeanWrapper wifiBeanWrapper); @@ -1202,6 +1228,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new encrypt storage operation.") }) + @Scope(key = "device:android:operation:encrypt", name = "Encrypt device", description = "") Response encryptStorage( @ApiParam(name = "encryptionBeanWrapper", value = "Configurations and deviceIds need to be done data encryption") @@ -1255,6 +1282,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new change lock code operation.") }) + @Scope(key = "device:android:operation:change-lock", name = "Change password of device", description = "") Response changeLockCode( @ApiParam(name = "lockCodeBeanWrapper", value = "Configurations and device Ids need to be done change lock code") @@ -1308,6 +1336,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new set password policy operation.") }) + @Scope(key = "device:android:operation:password-policy", name = "Set password policy", description = "") Response setPasswordPolicy( @ApiParam(name = "passwordPolicyBeanWrapper", value = "Password Policy Configurations and Device Ids") @@ -1361,6 +1390,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new set webclip operation.") }) + @Scope(key = "device:android:operation:webclip", name = "Add webclips", description = "") Response setWebClip( @ApiParam(name = "webClipBeanWrapper", value = "Configurations to need set web clip on device and device Ids") diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java index f760130ed..71fcdba84 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java @@ -19,6 +19,8 @@ package org.wso2.carbon.mdm.services.android.services; import io.swagger.annotations.*; +import org.wso2.carbon.apimgt.annotations.api.API; +import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidApplication; import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidDevice; @@ -32,6 +34,10 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; +@API(name = "Android Device Management", version = "1.0.0", + context = "api/device-mgt/android/v1.0/devices", + tags = {"devicemgt_android"}) + @Api(value = "Android Device Management", description = "This carries all the resources related to Android device management functionalities") @Path("/devices") @@ -81,6 +87,7 @@ public interface DeviceManagementService { message = "Internal Server Error. \n " + "Server error occurred while updating the application list.") }) + @Scope(key = "device:android:enroll", name = "Enroll Android device", description = "") Response updateApplicationList( @ApiParam( name = "id", @@ -134,6 +141,7 @@ public interface DeviceManagementService { code = 500, message = "Internal Server Error. \n Server error occurred while fetching policies.") }) + @Scope(key = "device:android:enroll", name = "Enroll Android device", description = "") Response getPendingOperations( @ApiParam( name = "id", @@ -198,6 +206,7 @@ public interface DeviceManagementService { message = "Internal Server Error. \n " + "Server error occurred while adding a new policy.") }) + Response enrollDevice(@ApiParam(name = "device", value = "Device Information to be enroll") @Valid AndroidDevice device); @@ -236,6 +245,7 @@ public interface DeviceManagementService { code = 500, message = "Internal Server Error. \n Server error occurred while fetching the enrollment status of the Android device.") }) + @Scope(key = "device:android:enroll", name = "Enroll Android device", description = "") Response isEnrolled( @ApiParam( name = "id", @@ -289,6 +299,7 @@ public interface DeviceManagementService { message = "Internal Server Error. \n " + "Server error occurred while updating the device enrollment.") }) + @Scope(key = "device:android:enroll", name = "Enroll Android device", description = "") Response modifyEnrollment( @ApiParam( name = "id", @@ -318,6 +329,7 @@ public interface DeviceManagementService { message = "Internal Server Error. \n " + "Server error occurred while dis-enrolling the device.") }) + @Scope(key = "device:android:disenroll", name = "Enroll Android device", description = "") Response disEnrollDevice( @ApiParam( name = "id", diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java index 780e4d116..44d915028 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java @@ -19,6 +19,8 @@ package org.wso2.carbon.mdm.services.android.services; import io.swagger.annotations.*; +import org.wso2.carbon.apimgt.annotations.api.API; +import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.mdm.services.android.bean.AndroidPlatformConfiguration; import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException; @@ -28,6 +30,10 @@ import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +@API(name = "Android Configuration Management", version = "1.0.0", + context = "api/device-mgt/android/v1.0/configuration", + tags = {"devicemgt_android"}) + @Api(value = "Android Configuration Management", description = "This API carries all resource associated with " + "manipulating the general configurations of Android platform") @Path("/configuration") @@ -75,6 +81,7 @@ public interface DeviceTypeConfigurationService { code = 500, message = "Internal Server Error. \n Server error occurred while fetching Android platform configuration.") }) + @Scope(key = "configuration:view", name = "View configurations", description = "") Response getConfiguration( @ApiParam( name = "If-Modified-Since", @@ -124,6 +131,7 @@ public interface DeviceTypeConfigurationService { message = "Internal Server Error. \n " + "Server error occurred while modifying Android platform configuration.") }) + @Scope(key = "configuration:manage", name = "Add configurations", description = "") Response updateConfiguration( @ApiParam(name = "configuration", value = "AndroidPlatformConfiguration") @@ -171,6 +179,7 @@ public interface DeviceTypeConfigurationService { code = 500, message = "Internal Server Error. \n Server error occurred while fetching Android license configuration.") }) + @Scope(key = "device:android:enroll", name = "Enroll Android device", description = "") Response getLicense( @ApiParam( name = "If-Modified-Since", diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/EventReceiverService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/EventReceiverService.java index cc77bb42f..9e6ed2b7d 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/EventReceiverService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/EventReceiverService.java @@ -19,16 +19,21 @@ package org.wso2.carbon.mdm.services.android.services; import io.swagger.annotations.*; +import org.wso2.carbon.apimgt.annotations.api.API; +import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.mdm.services.android.bean.DeviceState; import org.wso2.carbon.mdm.services.android.bean.wrapper.EventBeanWrapper; import javax.validation.Valid; -import javax.validation.constraints.Pattern; import javax.validation.constraints.Size; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +@API(name = "Android Event Receiver", version = "1.0.0", + context = "api/device-mgt/android/v1.0/events", + tags = {"devicemgt_android"}) + @Api(value = "Event Receiver", description = "Event publishing/retrieving related APIs.To enable Eventing need to" + " configure as ref-https://docs.wso2.com/display/EMM210/Managing+Event+Publishing+with+WSO2+Data+Analytics+Server, " + "https://docs.wso2.com/display/EMM210/Creating+a+New+Event+Stream+and+Receiver") @@ -85,6 +90,7 @@ public interface EventReceiverService { message = "Internal Server Error. \n " + "Server error occurred while publishing events.") }) + @Scope(key = "device:android:event:write", name = "Publish events to DAS", description = "") Response publishEvents( @ApiParam( name = "eventBeanWrapper", @@ -134,14 +140,13 @@ public interface EventReceiverService { code = 500, message = "Error occurred while getting published events for specific device.") }) - + @Scope(key = "device:android:event:read", name = "View events", description = "") Response retrieveAlerts( @ApiParam( name = "id", value = "Device Identifier to be need to retrieve events.", required = true) @Size(min = 2, max = 45) - @Pattern(regexp = "^[A-Za-z0-9]*$") @QueryParam("id") String deviceId, @ApiParam( name = "from", @@ -155,7 +160,6 @@ public interface EventReceiverService { name = "type", value = "Type of the Alert to be need to retrieve events.") @Size(min = 2, max = 45) - @Pattern(regexp = "^[A-Za-z0-9]*$") @QueryParam("type") String type, @ApiParam( name = "If-Modified-Since", diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementAdminServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementAdminServiceImpl.java index f0253db39..20283b727 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementAdminServiceImpl.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementAdminServiceImpl.java @@ -25,21 +25,52 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation; import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation; -import org.wso2.carbon.mdm.services.android.bean.*; -import org.wso2.carbon.mdm.services.android.bean.wrapper.*; +import org.wso2.carbon.mdm.services.android.bean.ApplicationInstallation; +import org.wso2.carbon.mdm.services.android.bean.ApplicationUninstallation; +import org.wso2.carbon.mdm.services.android.bean.ApplicationUpdate; +import org.wso2.carbon.mdm.services.android.bean.BlacklistApplications; +import org.wso2.carbon.mdm.services.android.bean.Camera; +import org.wso2.carbon.mdm.services.android.bean.DeviceEncryption; +import org.wso2.carbon.mdm.services.android.bean.DeviceLock; +import org.wso2.carbon.mdm.services.android.bean.ErrorResponse; +import org.wso2.carbon.mdm.services.android.bean.LockCode; +import org.wso2.carbon.mdm.services.android.bean.Notification; +import org.wso2.carbon.mdm.services.android.bean.PasscodePolicy; +import org.wso2.carbon.mdm.services.android.bean.UpgradeFirmware; +import org.wso2.carbon.mdm.services.android.bean.Vpn; +import org.wso2.carbon.mdm.services.android.bean.WebClip; +import org.wso2.carbon.mdm.services.android.bean.Wifi; +import org.wso2.carbon.mdm.services.android.bean.WipeData; +import org.wso2.carbon.mdm.services.android.bean.wrapper.ApplicationInstallationBeanWrapper; +import org.wso2.carbon.mdm.services.android.bean.wrapper.ApplicationUninstallationBeanWrapper; +import org.wso2.carbon.mdm.services.android.bean.wrapper.ApplicationUpdateBeanWrapper; +import org.wso2.carbon.mdm.services.android.bean.wrapper.BlacklistApplicationsBeanWrapper; +import org.wso2.carbon.mdm.services.android.bean.wrapper.CameraBeanWrapper; +import org.wso2.carbon.mdm.services.android.bean.wrapper.DeviceLockBeanWrapper; +import org.wso2.carbon.mdm.services.android.bean.wrapper.EncryptionBeanWrapper; +import org.wso2.carbon.mdm.services.android.bean.wrapper.LockCodeBeanWrapper; +import org.wso2.carbon.mdm.services.android.bean.wrapper.NotificationBeanWrapper; +import org.wso2.carbon.mdm.services.android.bean.wrapper.PasswordPolicyBeanWrapper; +import org.wso2.carbon.mdm.services.android.bean.wrapper.UpgradeFirmwareBeanWrapper; +import org.wso2.carbon.mdm.services.android.bean.wrapper.VpnBeanWrapper; +import org.wso2.carbon.mdm.services.android.bean.wrapper.WebClipBeanWrapper; +import org.wso2.carbon.mdm.services.android.bean.wrapper.WifiBeanWrapper; +import org.wso2.carbon.mdm.services.android.bean.wrapper.WipeDataBeanWrapper; import org.wso2.carbon.mdm.services.android.exception.BadRequestException; import org.wso2.carbon.mdm.services.android.exception.UnexpectedServerErrorException; import org.wso2.carbon.mdm.services.android.services.DeviceManagementAdminService; import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils; import org.wso2.carbon.mdm.services.android.util.AndroidConstants; -import javax.validation.Valid; import javax.ws.rs.Consumes; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.List; @Path("/admin/devices") @@ -48,6 +79,7 @@ import java.util.List; public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminService { private static final Log log = LogFactory.getLog(DeviceManagementAdminServiceImpl.class); + private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ssXXX"; @POST @Path("/lock-devices") @@ -573,6 +605,14 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); } UpgradeFirmware upgradeFirmware = upgradeFirmwareBeanWrapper.getOperation(); + + //validate date + if(upgradeFirmware != null && upgradeFirmware.getSchedule() != null){ + SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT); + sdf.setLenient(false); + Date date = sdf.parse(upgradeFirmware.getSchedule()); + } + ProfileOperation operation = new ProfileOperation(); operation.setCode(AndroidConstants.OperationCodes.UPGRADE_FIRMWARE); operation.setType(Operation.Type.PROFILE); @@ -588,6 +628,11 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe log.error(errorMessage, e); throw new UnexpectedServerErrorException( new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); + } catch (ParseException e) { + String errorMessage = "Issue in validating the schedule date"; + log.error(errorMessage); + throw new BadRequestException( + new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); } } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java index 69c0c5def..dad6393e0 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java @@ -260,7 +260,16 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { @Override public Response modifyEnrollment(@PathParam("id") String id, @Valid AndroidDevice androidDevice) { Device device = new Device(); + String msg = ""; device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); + if(androidDevice.getEnrolmentInfo().getDateOfEnrolment() <= 0){ + msg = "Invalid Enrollment date."; + return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); + } + if(androidDevice.getEnrolmentInfo().getDateOfLastUpdate() <= 0){ + msg = "Invalid Last Updated date."; + return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); + } device.setEnrolmentInfo(androidDevice.getEnrolmentInfo()); device.getEnrolmentInfo().setOwner(AndroidAPIUtils.getAuthenticatedUser()); device.setDeviceInfo(androidDevice.getDeviceInfo()); @@ -281,7 +290,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { "carries the id '" + id + "' has not been updated").build(); } } catch (DeviceManagementException e) { - String msg = "Error occurred while modifying enrollment of the Android device that carries the id '" + + msg = "Error occurred while modifying enrollment of the Android device that carries the id '" + id + "'"; log.error(msg, e); throw new UnexpectedServerErrorException( diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/EventReceiverServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/EventReceiverServiceImpl.java index c933c4bb1..cf6677189 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/EventReceiverServiceImpl.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/EventReceiverServiceImpl.java @@ -33,7 +33,6 @@ import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils; import org.wso2.carbon.mdm.services.android.util.Message; import javax.validation.Valid; -import javax.validation.constraints.Pattern; import javax.validation.constraints.Size; import javax.ws.rs.*; import javax.ws.rs.core.Response; @@ -78,11 +77,10 @@ public class EventReceiverServiceImpl implements EventReceiverService { @Override public Response retrieveAlerts(@QueryParam("id") @Size(min = 2, max = 45) - @Pattern(regexp = "^[A-Za-z0-9]*$") String deviceId, + String deviceId, @QueryParam("from") long from, @QueryParam("to") long to, @Size(min = 2, max = 45) - @Pattern(regexp = "^[A-Za-z0-9]*$") @QueryParam("type") String type, @HeaderParam("If-Modified-Since") String ifModifiedSince) { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java index 89fc4481a..19db99ddd 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java @@ -129,8 +129,14 @@ public class AndroidAPIUtils { DeviceIDHolder deviceIDHolder = deviceUtils.validateDeviceIdentifiers(deviceIDs); List validDeviceIds = deviceIDHolder.getValidDeviceIDList(); - Activity activity = getDeviceManagementService().addOperation( - DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, operation, validDeviceIds); + Activity activity = null; + if(validDeviceIds.size() > 0) { + activity = getDeviceManagementService().addOperation( + DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, operation, validDeviceIds); + } else { + throw new IllegalArgumentException("Invalid device Identifiers found"); + } + // if (activity != null) { // GCMService gcmService = getGCMService(); // if (gcmService.isGCMEnabled()) { @@ -142,11 +148,7 @@ public class AndroidAPIUtils { // getGCMService().sendNotification(operation.getCode(), devices); // } // } - if (!deviceIDHolder.getErrorDeviceIdList().isEmpty()) { - throw new BadRequestException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(deviceUtils. - convertErrorMapIntoErrorMessage(deviceIDHolder.getErrorDeviceIdList())).build()); - } + return Response.status(Response.Status.CREATED).entity(activity).build(); } @@ -283,6 +285,9 @@ public class AndroidAPIUtils { OperationCodes.DEVICE_INFO.equals(operation.getCode())) { try { + if (log.isDebugEnabled()){ + log.debug("Operation response: " + operation.getOperationResponse()); + } Device device = new Gson().fromJson(operation.getOperationResponse(), Device.class); org.wso2.carbon.device.mgt.common.device.details.DeviceInfo deviceInfo = convertDeviceToInfo(device); updateDeviceInfo(deviceIdentifier, deviceInfo); @@ -401,8 +406,6 @@ public class AndroidAPIUtils { } } else { if (prop.getName().equalsIgnoreCase("CPU_INFO")) { - deviceInfo.setTotalRAMMemory(Double.parseDouble(getProperty(prop.getValue(), "User"))); - deviceInfo.getDeviceDetailsMap().put("cpuUser", getProperty(prop.getValue(), "User")); deviceInfo.getDeviceDetailsMap().put("cpuSystem", diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/META-INF/permissions.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/META-INF/permissions.xml index 61aa4a1ae..d85ab6971 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/META-INF/permissions.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/META-INF/permissions.xml @@ -39,6 +39,13 @@ GET + + Modify Tenant configuration + /device-mgt/admin/platform-configs/add + /configuration + PUT + + Add Tenant configuration /device-mgt/admin/platform-configs/add diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/cxf-servlet.xml index f6095bd02..5423cba71 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -51,7 +51,7 @@ - + diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/web.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/web.xml index 48eeb393e..b39cda673 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/web.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/web.xml @@ -49,7 +49,7 @@ managed-api-enabled - false + true managed-api-owner 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.device-view/device-view.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.device-view/device-view.js index da9c9809f..4407e222f 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.device-view/device-view.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.device-view/device-view.js @@ -22,7 +22,7 @@ function onRequest(context) { var deviceId = request.getParameter("id"); if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) { - var deviceModule = require("/app/modules/device.js").deviceModule; + var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var device = deviceModule.viewDevice(deviceType, deviceId); if (device) { 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/policy-wizard.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/policy-wizard.hbs index 0669d1ca6..fe04c3ce6 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/policy-wizard.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/policy-wizard.hbs @@ -1 +1,29 @@ -{{unit "mdm.unit.policy.wizard"}} \ No newline at end of file +
+
+

ADD POLICY

+
+
+
+
+
+

Step 2: Configure profile

+
+ +
+
+
+      +    Loading platform features . . . +

+
+
+
+ Back + Continue +
+
+
+
+
\ No newline at end of file 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.type-view/type-view.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.type-view/type-view.js index a24959159..ac41dedd7 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.type-view/type-view.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.type-view/type-view.js @@ -18,7 +18,7 @@ function onRequest(context){ var viewModel = {}; - var devicemgtProps = require("/app/conf/reader/main.js")["conf"]; + var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; viewModel.hostName = devicemgtProps["httpsURL"]; return viewModel; } \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/app-conf.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/app-conf.json index 75c4efe2b..b26d93b60 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/app-conf.json +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/app-conf.json @@ -1,5 +1,5 @@ { - "appName": "Enterprise Mobility Manager", + "appName": "WSO2 Enterprise Mobility Manager", "cachingEnabled": true, "debuggingEnabled": false, "permissionRoot": "/", diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json index 6e61307cd..8eb7bfc3c 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json @@ -1,6 +1,5 @@ { "appContext": "/emm/", - "clientName": "emm", "webAgentContext" : "/emm-web-agent/", "apiContext": "api", "httpsURL" : "%https.ip%", @@ -12,13 +11,23 @@ "enrollmentDir": "/emm-web-agent/enrollment", "iOSConfigRoot" : "%https.ip%/ios-enrollment/", "iOSAPIRoot" : "%https.ip%/ios/", - "dynamicClientRegistrationEndPoint" : "https://localhost:9443/dynamic-client-web/register/", "adminService": "%https.ip%", - "idPServer":"%https.ip%/oauth2/token", - "callBackUrl":"%https.ip%/api/device-mgt/v1.0", - "adminUser":"admin@carbon.super", - "adminRole":"admin", - "usernameLength":30, + "oauthProvider": { + "appRegistration": { + "appType": "webapp", + "clientName": "emm", + "owner": "admin@carbon.super", + "dynamicClientAppRegistrationServiceURL": "%https.ip%/dynamic-client-web/register", + "apiManagerClientAppRegistrationServiceURL": "%https.ip%/api-application-registration/register/tenants", + "grantType": "password refresh_token urn:ietf:params:oauth:grant-type:saml2-bearer", + "tokenScope": "admin", + "callbackUrl": "%https.ip%/api/device-mgt/v1.0" + }, + "tokenServiceURL": "%https.ip%/oauth2/token" + }, + "adminUser": "admin@carbon.super", + "adminRole": "admin", + "usernameLength": 30, "pageSize":10, "ssoConfiguration" : { "enabled" : false, @@ -52,7 +61,7 @@ "roleNameHelpMsg" : "should be in minimum 3 characters long and do not include any whitespaces." }, "generalConfig" : { - "host" : "https://localhost:9443", + "host" : "%https.ip%", "companyName" : "WSO2 Carbon Device Manager", "browserTitle" : "WSO2 Device Manager", "copyrightPrefix" : "\u00A9 %date-year%, ", @@ -61,17 +70,53 @@ "copyrightSuffix" : " All Rights Reserved." }, "scopes" : [ - "license-add", "license-view", "device-view", - "device-info", "device-list", "device-view-own", "device-modify", "device-search", - "operation-install", "operation-view", "operation-modify", "operation-uninstall", - "group-add", "group-share", "group-modify", "group-view", "group-remove", - "certificate-modify", "certificate-view", - "configuration-view", "configuration-modify", - "policy-view", "policy-modify", - "device-notification-view", "device-notification-modify", - "feature-view", - "roles-view", "roles-modify", "roles-remove", "roles-add", - "user-password-reset", "user-password-modify", "user-modify", "user-view", "user-invite", "user-remove", "user-add" + "user:manage", + "user:view", + "device-type:admin:view", + "device:view", + "notification:view", + "device:admin:view", + "application:manage", + "activity:view", + "user:admin:reset-password", + "policy:manage", + "policy:view", + "role:manage", + "role:view", + "configuration:view", + "configuration:modify", + "device:android:operation:reboot", + "device:android:operation:camera", + "device:android:operation:vpn", + "device:android:operation:lock", + "device:android:operation:ring", + "device:android:operation:update-app", + "device:android:operation:wipe", + "device:android:operation:encrypt", + "device:android:operation:blacklist-app", + "device:android:operation:applications", + "device:android:operation:enterprise-wipe", + "device:android:operation:info", + "device:android:operation:wifi", + "device:android:operation:uninstall-app", + "device:android:operation:change-lock", + "device:android:operation:notification", + "device:android:operation:upgrade", + "device:android:operation:unlock", + "device:android:operation:mute", + "device:android:operation:location", + "device:android:operation:webclip", + "device:android:operation:clear-password", + "device:android:operation:password-policy", + "device:android:operation:install-app", + "device:android:event:write", + "device:android:event:read", + "device:android:enroll", + "configuration:manage", + "configuration:view", + "device:android:enroll", + "certificate:view", + "certificate:manage" ], "isOAuthEnabled" : true, "backendRestEndpoints" : { diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.hbs index e90d78c9b..85b0141d7 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.hbs +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.hbs @@ -48,7 +48,7 @@ View {{#if permissions.ADD_POLICY}} - + @@ -79,7 +79,7 @@ View {{#if permissions.ADD_USER}} - + @@ -110,7 +110,7 @@ View {{#if permissions.ADD_ROLE}} - + diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.js index 8d4576dd9..e9b07a654 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.js +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.js @@ -17,12 +17,14 @@ */ function onRequest(context) { - var userModule = require("/app/modules/user.js")["userModule"]; + var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var generalConfig = context.app.conf["generalConfig"]; + var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; - context["permissions"] = userModule.getUIPermissions(); - new Log().info("## Permissions : "+ stringify(userModule.getUIPermissions())); - context["enrollmentURL"] = generalConfig["host"] + generalConfig["enrollmentDir"]; - - return context; + var viewModel = {}; + viewModel.permissions = userModule.getUIPermissions(); + new Log().debug("## Permissions : " + stringify(userModule.getUIPermissions())); + //TODO: Move enrollment URL into app-conf.json + viewModel.enrollmentURL = mdmProps.generalConfig.host + mdmProps.enrollmentDir; + return viewModel; } \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.device.view/view.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.device.view/view.hbs new file mode 100644 index 000000000..ab7bf0fce --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.device.view/view.hbs @@ -0,0 +1,44 @@ +{{! + Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + + WSO2 Inc. licenses this file to you under the Apache License, + Version 2.0 (the "License"); you may not use this file except + in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +}} +{{unit "cdmf.unit.ui.title" pageTitle="Device Details"}} +{{unit "cdmf.unit.lib.service-invoker-utility"}} +{{unit "cdmf.unit.lib.handlebars"}} + +{{#zone "breadcrumbs"}} +
  • + + + +
  • +
  • + + Devices + +
  • +
  • + + Device Details + +
  • +{{/zone}} + +{{#zone "content"}} + {{unit "cdmf.unit.lib.data-table"}} + {{unit "cdmf.unit.device.operation-mod"}} + {{unit "cdmf.unit.device.view"}} +{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.device.view/view.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.device.view/view.js new file mode 100644 index 000000000..21ce99302 --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.device.view/view.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +function onRequest(context){ + var utility = require("/app/modules/utility.js").utility; + context.handlebars.registerHelper('equal', function (lvalue, rvalue, options) { + if (arguments.length < 3) + throw new Error("Handlebars Helper equal needs 2 parameters"); + if( lvalue!=rvalue ) { + return options.inverse(this); + } else { + return options.fn(this); + } + }); + + var deviceType = context.uriParams.deviceType; + return {"deviceViewUnitName": utility.getTenantedDeviceUnitName(deviceType, "device-view")}; +} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.device.view/view.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.device.view/view.json new file mode 100644 index 000000000..04395bd8f --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.device.view/view.json @@ -0,0 +1,4 @@ +{ + "version": "1.0.0", + "extends": "cdmf.page.device.view" +} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/devices.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/devices.hbs new file mode 100644 index 000000000..2e5c1b3e9 --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/devices.hbs @@ -0,0 +1,123 @@ +{{! + Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + + WSO2 Inc. licenses this file to you under the Apache License, + Version 2.0 (the "License"); you may not use this file except + in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +}} +{{unit "cdmf.unit.ui.title" pageTitle="Device Management"}} + +{{unit "cdmf.unit.data-tables-extended"}} + +{{#zone "breadcrumbs"}} +
  • + + + +
  • +
  • + + Devices + +
  • +{{/zone}} + +{{#zone "navbarActions"}} + {{#if permissions.enroll}} +
  • + + + + + + Enroll Device + +
  • + {{/if}} +{{/zone}} + +{{#zone "content"}} + +
    + +     + Loading devices . . . +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    By Device NameBy OwnerBy StatusBy PlatformBy Ownership
    +
    + {{unit "mdm.unit.device.operation-bar"}} +
    +
    +

    Enabling Device Operations

    +

    To enable device operations, select the desired platform from above filter.

    +
    +
    +
    +
    + +{{/zone}} + +{{#zone "bottomJs"}} + + {{js "js/device-listing.js"}} +{{/zone}} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/devices.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/devices.js new file mode 100644 index 000000000..f1339b9e4 --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/devices.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +function onRequest(context){ + var userModule = require("/app/modules/business-controllers/user.js").userModule; + var constants = require("/app/modules/constants.js"); + var viewModel = {}; + var permissions = []; + if(userModule.isAuthorized("/permission/admin/device-mgt/emm-admin/devices/list")){ + permissions.push("LIST_DEVICES"); + if (userModule.isAuthorized("/permission/admin/device-mgt/emm-admin/devices/view")) { + permissions.push("VIEW_DEVICES"); + } + }else if(userModule.isAuthorized("/permission/admin/device-mgt/user/devices/list")){ + permissions.push("LIST_OWN_DEVICES"); + if (userModule.isAuthorized("/permission/admin/device-mgt/user/devices/view")) { + permissions.push("VIEW_OWN_DEVICES"); + } + }else if(userModule.isAuthorized("/permission/admin/device-mgt/emm-admin/policies/list")){ + permissions.push("LIST_POLICIES"); + } + var currentUser = session.get(constants.USER_SESSION_KEY); + viewModel.permissions = stringify(permissions); + viewModel.currentUser = currentUser; + return viewModel; +} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/devices.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/devices.json new file mode 100644 index 000000000..4886bfc3c --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/devices.json @@ -0,0 +1,4 @@ +{ + "version": "1.0.0", + "extends": "cdmf.page.devices" +} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/public/images/TemperatureController.png b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/public/images/TemperatureController.png new file mode 100644 index 000000000..e16b48d8e Binary files /dev/null and b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/public/images/TemperatureController.png differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/public/images/android.png b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/public/images/android.png new file mode 100755 index 000000000..7fee78a64 Binary files /dev/null and b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/public/images/android.png differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/public/images/ios.png b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/public/images/ios.png new file mode 100644 index 000000000..4b09796f8 Binary files /dev/null and b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/public/images/ios.png differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/public/js/device-listing.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/public/js/device-listing.js new file mode 100644 index 000000000..a515fbd0d --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/public/js/device-listing.js @@ -0,0 +1,520 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Following function would execute + * when a user clicks on the list item + * initial mode and with out select mode. + */ +function InitiateViewOption(url) { + if ($(".select-enable-btn").text() == "Select") { + $(location).attr('href', url); + } +} + +(function () { + var cache = {}; + var permissionSet = {}; + var validateAndReturn = function (value) { + return (value == undefined || value == null) ? "Unspecified" : value; + }; + Handlebars.registerHelper("deviceMap", function (device) { + device.owner = validateAndReturn(device.owner); + device.ownership = validateAndReturn(device.ownership); + var arr = device.properties; + if (arr){ + device.properties = arr.reduce(function (total, current) { + total[current.name] = validateAndReturn(current.value); + return total; + }, {}); + } + }); + + //This method is used to setup permission for device listing + $.setPermission = function (permission) { + permissionSet[permission] = true; + }; + + $.hasPermission = function (permission) { + return permissionSet[permission]; + }; +})(); + +/* + * Setting-up global variables. + */ +var deviceCheckbox = "#ast-container .ctrl-wr-asset .itm-select input[type='checkbox']"; +var assetContainer = "#ast-container"; + +/* + * DOM ready functions. + */ +$(document).ready(function () { + /* Adding selected class for selected devices */ + $(deviceCheckbox).each(function () { + addDeviceSelectedClass(this); + }); + + var i; + var permissionList = $("#permission").data("permission"); + for (i = 0; i < permissionList.length; i++) { + $.setPermission(permissionList[i]); + } + + /* for device list sorting drop down */ + $(".ctrl-filter-type-switcher").popover({ + html : true, + content : function () { + return $("#content-filter-types").html(); + } + }); + + $(".ast-container").on("click", ".claim-btn", function(e){ + e.stopPropagation(); + var deviceId = $(this).data("deviceid"); + var deviceListing = $("#device-listing"); + var currentUser = deviceListing.data("current-user"); + var serviceURL = "/temp-controller-agent/enrollment/claim?username=" + currentUser; + var deviceIdentifier = {id: deviceId, type: "TemperatureController"}; + invokerUtil.put(serviceURL, deviceIdentifier, function(message){ + console.log(message); + }, function(message){ + console.log(message.content); + }); + }); +}); + +/* + * On Select All Device button click function. + * + * @param button: Select All Device button + */ +function selectAllDevices(button) { + if(!$(button).data('select')){ + $(deviceCheckbox).each(function(index){ + $(this).prop('checked', true); + addDeviceSelectedClass(this); + }); + $(button).data('select', true); + $(button).html('Deselect All Devices'); + }else{ + $(deviceCheckbox).each(function(index){ + $(this).prop('checked', false); + addDeviceSelectedClass(this); + }); + $(button).data('select', false); + $(button).html('Select All Devices'); + } +} + +/* + * On listing layout toggle buttons click function. + * + * @param view: Selected view type + * @param selection: Selection button + */ +function changeDeviceView(view, selection) { + $(".view-toggle").each(function() { + $(this).removeClass("selected"); + }); + $(selection).addClass("selected"); + if (view == "list") { + $(assetContainer).addClass("list-view"); + } else { + $(assetContainer).removeClass("list-view"); + } +} + +/* + * Add selected style class to the parent element function. + * + * @param checkbox: Selected checkbox + */ +function addDeviceSelectedClass(checkbox) { + if ($(checkbox).is(":checked")) { + $(checkbox).closest(".ctrl-wr-asset").addClass("selected device-select"); + } else { + $(checkbox).closest(".ctrl-wr-asset").removeClass("selected device-select"); + } +} + +function toTitleCase(str) { + return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}); +} + +function loadDevices(searchType, searchParam){ + var deviceListing = $("#device-listing"); + var currentUser = deviceListing.data("currentUser"); + + var serviceURL; + if ($.hasPermission("LIST_DEVICES")) { + //serviceURL = "/mdm-admin/devices"; + serviceURL = "/api/device-mgt/v1.0/devices"; + } else if ($.hasPermission("LIST_OWN_DEVICES")) { + //Get authenticated users devices + serviceURL = "/api/device-mgt/v1.0/devices?user="+currentUser; + //serviceURL = "/mdm-admin/users/devices?username="+currentUser; + } else { + $("#loading-content").remove(); + $('#device-table').addClass('hidden'); + $('#device-listing-status-msg').text('Permission denied.'); + $("#device-listing-status").removeClass(' hidden'); + return; + } + + function getPropertyValue(deviceProperties, propertyName) { + var property; + for (var i =0; i < deviceProperties.length; i++) { + property = deviceProperties[i]; + if (property.name == propertyName) { + return property.value; + } + } + return {}; + } + + var fnCreatedRow = function( nRow, aData, iDataIndex ) { + $(nRow).attr('data-type', 'selectable'); + $(nRow).attr('data-deviceid', aData.deviceIdentifier); + $(nRow).attr('data-devicetype', aData.deviceType); + } + + + var columns = [ + { + class : 'remove-padding icon-only content-fill viewEnabledIcon', + data : 'icon', + render: function (data, type, row, meta) { + var deviceType = row.deviceType; + var deviceIdentifier = row.deviceIdentifier; + var url = "#"; + if (status != 'REMOVED') { + url = "device/" + deviceType + "?id=" + deviceIdentifier; + } + return '
    ' + } + },{ + class: 'fade-edge', + data: 'name', + render: function ( name, type, row, meta ) { + var model = row.model; + var vendor = row.vendor; + var html = '

    Device ' + name + '

    '; + if (model) { + html += '
    (' + vendor + '-' + model + ')
    '; + } + return html; + } + },{ + class: 'fade-edge remove-padding-top', + data: 'user', + render: function ( user, type, row, meta ) { + return '
    ' + user + '
    '; + } + },{ + class: 'fade-edge remove-padding-top', + data: 'status', + render: function ( status, type, row, meta ) { + var html; + switch (status) { + case 'ACTIVE' : + html = ' Active'; + break; + case 'INACTIVE' : + html = ' Inactive'; + break; + case 'BLOCKED' : + html = ' Blocked'; + break; + case 'REMOVED' : + html = ' Removed'; + break; + } + return '
    '+html+'
    '; + } + },{ + className: 'fade-edge remove-padding-top', + data: 'deviceType', + render: function ( deviceType, type, row, meta ) { + return '
    ' + deviceType + '
    '; + } + },{ + className: 'fade-edge remove-padding-top', + data: 'ownership', + render: function ( ownership, type, row, meta ) { + return '
    ' + ownership + '
    '; + } + } + ]; + + + var dataFilter = function(data){ + data = JSON.parse(data); + + var objects = []; + + $(data.devices).each(function( index ) { + objects.push( + { + model: getPropertyValue(data.devices[index].properties, 'DEVICE_MODEL'), + vendor: getPropertyValue(data.devices[index].properties, 'VENDOR'), + owner: data.devices[index].enrolmentInfo.owner, + status: data.devices[index].enrolmentInfo.status, + ownership: data.devices[index].enrolmentInfo.ownership, + deviceType: data.devices[index].type, + deviceIdentifier: data.devices[index].deviceIdentifier, + name : data.devices[index].name + } + ); + }); + + json = { + "recordsTotal": data.count, + "recordsFiltered": data.count, + "data": objects + }; + return JSON.stringify( json ); + }; + + + $('#device-grid').datatables_extended_serverside_paging(null, '/api/device-mgt/v1.0/devices', dataFilter, columns, fnCreatedRow, + function( oSettings ) { + $(".icon .text").res_text(0.2); + $('#device-grid').removeClass('hidden'); + $("#loading-content").remove(); + }, { + "placeholder": "Search By Device Name", + "searchKey" : "name" + }); + + // $('#device-grid').datatables_extended({ + // serverSide: true, + // processing: false, + // searching: true, + // ordering: false, + // filter: false, + // pageLength : 16, + // ajax: { url : '/emm/api/devices', data : {url : serviceURL}, + // dataSrc: function (json) { + // $('#device-grid').removeClass('hidden'); + // $("#loading-content").remove(); + // var $list = $("#device-table :input[type='search']"); + // $list.each(function(){ + // $(this).addClass("hidden"); + // }); + // return json.devices; + // } + // }, + // columnDefs: [ + // { targets: 0, data: 'name', className: 'remove-padding icon-only content-fill viewEnabledIcon' , render: function ( data, type, row, meta ) { + // var deviceType = row.type; + // var deviceIdentifier = row.deviceIdentifier; + // var url = "#"; + // if (status != 'REMOVED') { + // url = "devices/view?type=" + deviceType + "&id=" + deviceIdentifier; + // } + // return '
    '; + // }}, + // { targets: 1, data: 'name', className: 'fade-edge' , render: function ( name, type, row, meta ) { + // var model = getPropertyValue(row.properties, 'DEVICE_MODEL'); + // var vendor = getPropertyValue(row.properties, 'VENDOR'); + // var html = '

    Device ' + name + '

    '; + // if (model) { + // html += '
    (' + vendor + '-' + model + ')
    '; + // } + // return html; + // }}, + // { targets: 2, data: 'enrolmentInfo.owner', className: 'fade-edge remove-padding-top'}, + // { targets: 3, data: 'enrolmentInfo.status', className: 'fade-edge remove-padding-top' , + // render: function ( status, type, row, meta ) { + // var html; + // switch (status) { + // case 'ACTIVE' : + // html = ' Active'; + // break; + // case 'INACTIVE' : + // html = ' Inactive'; + // break; + // case 'BLOCKED' : + // html = ' Blocked'; + // break; + // case 'REMOVED' : + // html = ' Removed'; + // break; + // } + // return html; + // }}, + // { targets: 4, data: 'type' , className: 'fade-edge remove-padding-top' }, + // { targets: 5, data: 'enrolmentInfo.ownership' , className: 'fade-edge remove-padding-top' }, + // { targets: 6, data: 'enrolmentInfo.status' , className: 'text-right content-fill text-left-on-grid-view no-wrap' , + // render: function ( status, type, row, meta ) { + // var deviceType = row.type; + // var deviceIdentifier = row.deviceIdentifier; + // var html = ''; + // return html; + // }} + // ], + // "createdRow": function( row, data, dataIndex ) { + // $(row).attr('data-type', 'selectable'); + // $(row).attr('data-deviceid', data.deviceIdentifier); + // $(row).attr('data-devicetype', data.type); + // var model = getPropertyValue(data.properties, 'DEVICE_MODEL'); + // var vendor = getPropertyValue(data.properties, 'VENDOR'); + // var owner = data.enrolmentInfo.owner; + // var status = data.enrolmentInfo.status; + // var ownership = data.enrolmentInfo.ownership; + // var deviceType = data.type; + // $.each($('td', row), function (colIndex) { + // switch(colIndex) { + // case 1: + // $(this).attr('data-search', model + ',' + vendor); + // $(this).attr('data-display', model); + // break; + // case 2: + // $(this).attr('data-grid-label', "Owner"); + // $(this).attr('data-search', owner); + // $(this).attr('data-display', owner); + // break; + // case 3: + // $(this).attr('data-grid-label', "Status"); + // $(this).attr('data-search', status); + // $(this).attr('data-display', status); + // break; + // case 4: + // $(this).attr('data-grid-label', "Type"); + // $(this).attr('data-search', deviceType); + // $(this).attr('data-display', deviceType); + // break; + // case 5: + // $(this).attr('data-grid-label', "Ownership"); + // $(this).attr('data-search', ownership); + // $(this).attr('data-display', ownership); + // break; + // } + // }); + // }, + // "fnDrawCallback": function( oSettings ) { + // $(".icon .text").res_text(0.2); + // } + // }); + $(deviceCheckbox).click(function () { + addDeviceSelectedClass(this); + }); +} + +/* + * Setting-up global variables. + */ +var deviceCheckbox = "#ast-container .ctrl-wr-asset .itm-select input[type='checkbox']"; +var assetContainer = "#ast-container"; + +function openCollapsedNav(){ + $('.wr-hidden-nav-toggle-btn').addClass('active'); + $('#hiddenNav').slideToggle('slideDown', function(){ + if($(this).css('display') == 'none'){ + $('.wr-hidden-nav-toggle-btn').removeClass('active'); + } + }); +} + +function initPage() { + var currentUser = $("#device-listing").data("currentUser"); + var serviceURL; + if ($.hasPermission("LIST_DEVICES")) { + serviceURL ="/api/device-mgt/v1.0/devices" + } else if ($.hasPermission("LIST_OWN_DEVICES")) { + //Get authenticated users devices + serviceURL = "/api/device-mgt/v1.0/devices?user=" + currentUser; + } + invokerUtil.get( + serviceURL, + function (data) { + if (data) { + data = JSON.parse(data); + if (data.devices.length > 0) { + loadDevices(); + } else { + $("#loading-content").remove(); + $("#device-listing-status-msg").text("No enrolled device is found."); + $("#device-listing-status").removeClass(' hidden'); + } + } + }, function (message) { + initPage(); + } + ); +} + +/* + * DOM ready functions. + */ +$(document).ready(function () { + initPage(); + + /* Adding selected class for selected devices */ + $(deviceCheckbox).each(function () { + addDeviceSelectedClass(this); + }); + + var i; + var permissionList = $("#permission").data("permission"); + for (i = 0; i < permissionList.length; i++) { + $.setPermission(permissionList[i]); + } + + /* for device list sorting drop down */ + $(".ctrl-filter-type-switcher").popover({ + html : true, + content : function () { + return $("#content-filter-types").html(); + } + }); + + $(".ast-container").on("click", ".claim-btn", function(e){ + e.stopPropagation(); + var deviceId = $(this).data("deviceid"); + var deviceListing = $("#device-listing"); + var currentUser = deviceListing.data("current-user"); + var serviceURL = "/temp-controller-agent/enrollment/claim?username=" + currentUser; + var deviceIdentifier = {id: deviceId, type: "TemperatureController"}; + invokerUtil.put(serviceURL, deviceIdentifier, function(message){ + console.log(message); + }, function(message){ + console.log(message.content); + }); + }); + + /* for data tables*/ + $('[data-toggle="tooltip"]').tooltip(); + + $("[data-toggle=popover]").popover(); + + $(".ctrl-filter-type-switcher").popover({ + html : true, + content: function() { + return $('#content-filter-types').html(); + } + }); + + $('#nav').affix({ + offset: { + top: $('header').height() + } + }); + +}); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/public/templates/device-listing.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/public/templates/device-listing.hbs new file mode 100644 index 000000000..8e5f2d2f8 --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/public/templates/device-listing.hbs @@ -0,0 +1,42 @@ + {{#each devices}} + {{deviceMap this}} + + +
    + +
    + + +

    Device {{name}}

    + {{#if properties.DEVICE_MODEL}} +
    ({{properties.VENDOR}} - {{properties.DEVICE_MODEL}})
    + {{/if}} + + {{enrolmentInfo.owner}} + + {{#equal enrolmentInfo.status "ACTIVE"}} Active{{/equal}} + {{#equal enrolmentInfo.status "INACTIVE"}} Inactive{{/equal}} + {{#equal enrolmentInfo.status "BLOCKED"}} Blocked{{/equal}} + {{#equal enrolmentInfo.status "REMOVED"}} Removed{{/equal}} + + {{type}} + {{enrolmentInfo.ownership}} + + + + + {{/each}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.policies/policies.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.policies/policies.hbs new file mode 100644 index 000000000..54c837ab7 --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.policies/policies.hbs @@ -0,0 +1,643 @@ +{{! + Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + + WSO2 Inc. licenses this file to you under the Apache License, + Version 2.0 (the "License"); you may not use this file except + in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +}} +{{unit "cdmf.unit.ui.title" pageTitle="Policy Management"}} +{{unit "cdmf.unit.data-tables-extended"}} + +{{#zone "topCss"}} + +{{/zone}} + +{{#zone "breadcrumbs"}} +
  • + + + +
  • +
  • + + Policies + +
  • +{{/zone}} + +{{#zone "navbarActions"}} + {{#if permissions.ADD_ADMIN_POLICY}} +
  • + + + + + + Add Policy + +
  • + {{/if}} + {{#if permissions.CHANGE_POLICY_PRIORITY}} + {{#equal noPolicy false}} +
  • + + + + + + Policy Priority + +
  • + {{/equal}} + {{/if}} +
  • + + + + + + Apply Changes To Devices + +
  • +{{/zone}} + +{{#zone "content"}} + {{#equal isUpdated true}} + + {{/equal}} + {{#equal noPolicy true}} +
    + +
    + {{/equal}} + {{#equal noPolicy false}} +
    + + Loading policies . . . +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{#each policyListToView}} + + + + + + + + + + + + {{/each}} +
    + + + {{/equal}} +
    + + + +
    +
    +
    +
    +

    Do you really want to remove the selected policy(s)?

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    Done. Selected policy was successfully removed.

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    An unexpected error occurred. Please try again later.

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    + You cannot remove policies that have been already applied to devices. + Please deselect active policies from your selection and try again. +

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    Do you really want to publish the selected policy(s)?

    + +
    + Yes + No +
    +
    +
    +
    +
    + +
    +
    +
    +
    +

    Done. Selected policy was successfully published.

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    An unexpected error occurred. Please try again later.

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    Do you really want to unpublish the selected policy(s)?

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    Done. Selected policy was successfully unpublished.

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    An unexpected error occurred. Please try again later.

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    Done. New Policy priorities were successfully updated.

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    An unexpected error occurred. Please try again later.

    +

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    Do you really want to apply changes to all policies?

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    Done. Changes applied successfully.

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    An unexpected error occurred. Please try again later.

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    + + + + + Action cannot be performed ! +

    +

    + Please select a policy or a list of policies to un-publish. +

    + + +
    +
    +
    +
    +
    +
    +
    +
    +

    + + + + + Action cannot be performed ! +

    +

    + You cannot select already inactive policies to be unpublished. + Please deselect inactive policies and try again. +

    + + +
    +
    +
    +
    +
    +
    +
    +
    +

    + + + + + Action cannot be performed ! +

    +

    + You cannot select already active policies. Please deselect active policies and try again. +

    + + +
    +
    +
    +
    +
    +
    +
    +
    +

    + + + + + Action cannot be performed ! +

    +

    + Please select a policy or a list of policies to publish. +

    + + +
    +
    +
    +
    +
    +
    +
    +
    +

    + + + + + Action cannot be performed ! +

    +

    + Please select a policy or a list of policies to remove. +

    + + +
    +
    +
    +
    +{{/zone}} + +{{#zone "bottomJs"}} + {{js "js/policy-list.js"}} +{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.policies/policies.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.policies/policies.js new file mode 100644 index 000000000..7c329ca7c --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.policies/policies.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +function onRequest(context) { + context.handlebars.registerHelper('equal', function (lvalue, rvalue, options) { + if (arguments.length < 3) { + throw new Error("Handlebars Helper equal needs 2 parameters"); + } + if (lvalue != rvalue) { + return options.inverse(this); + } else { + return options.fn(this); + } + }); + var page = {}; + var policyModule = require("/app/modules/business-controllers/policy.js")["policyModule"]; + var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; + var response = policyModule.getAllPolicies(); + if (response["status"] == "success") { + var policyListToView = response["content"]; + page["policyListToView"] = policyListToView; + var policyCount = policyListToView.length; + if (policyCount == 0) { + page["policyListingStatusMsg"] = "No policy is available to be displayed."; + page["noPolicy"] = true; + } else { + page["noPolicy"] = false; + page["isUpdated"] = response["updated"]; + } + } else { + // here, response["status"] == "error" + page["policyListingStatusMsg"] = "An unexpected error occurred. Please try again later."; + page["noPolicy"] = true; + } + + if (userModule.isAuthorized("/permission/admin/device-mgt/policies/remove")) { + page["removePermitted"] = true; + } + if (userModule.isAuthorized("/permission/admin/device-mgt/policies/update")) { + page["editPermitted"] = true; + } + page.permissions = userModule.getUIPermissions(); + return page; +} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.policies/policies.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.policies/policies.json new file mode 100644 index 000000000..53a1aada9 --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.policies/policies.json @@ -0,0 +1,6 @@ +{ + "version": "1.0.0", + "uri": "/policies", + "extends": "cdmf.page.policies", + "layout": "cdmf.layout.default" +} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.policies/public/js/policy-list.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.policies/public/js/policy-list.js new file mode 100644 index 000000000..978d6f0bd --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.policies/public/js/policy-list.js @@ -0,0 +1,361 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* sorting function */ +var sortUpdateBtn = "#sortUpdateBtn"; +// var sortedIDs; +// var dataTableSelection = ".DTTT_selected"; +$('#policy-grid').datatables_extended(); +// $(".icon .text").res_text(0.2); + +var saveNewPrioritiesButton = "#save-new-priorities-button"; +var saveNewPrioritiesButtonEnabled = Boolean($(saveNewPrioritiesButton).data("enabled")); +if (saveNewPrioritiesButtonEnabled) { + $(saveNewPrioritiesButton).removeClass("hide"); +} + +/** + * Following function would execute + * when a user clicks on the list item + * initial mode and with out select mode. + */ +function InitiateViewOption() { + $(location).attr('href', $(this).data("url")); +} + +//var addSortableIndexNumbers = function () { +// $(".wr-sortable .list-group-item").not(".ui-sortable-placeholder").each(function (i) { +// $(".wr-sort-index", this).html(i + 1); +// }); +//}; + +//var sortElements = function () { +// addSortableIndexNumbers(); +// var sortableElem = ".wr-sortable"; +// $(sortableElem).sortable({ +// beforeStop: function () { +// sortedIDs = $(this).sortable("toArray"); +// addSortableIndexNumbers(); +// $(sortUpdateBtn).prop("disabled", false); +// } +// }); +// $(sortableElem).disableSelection(); +//}; + +/** + * Modal related stuff are as follows. + */ + +var modalPopup = ".wr-modalpopup"; +var modalPopupContainer = modalPopup + " .modalpopup-container"; +var modalPopupContent = modalPopup + " .modalpopup-content"; +var body = "body"; + +/* + * set popup maximum height function. + */ +function setPopupMaxHeight() { + var maxHeight = "max-height"; + var marginTop = "margin-top"; + var body = "body"; + $(modalPopupContent).css(maxHeight, ($(body).height() - ($(body).height() / 100 * 30))); + $(modalPopupContainer).css(marginTop, (-($(modalPopupContainer).height() / 2))); +} + +/* + * show popup function. + */ +function showPopup() { + $(modalPopup).show(); + setPopupMaxHeight(); +} + +/* + * hide popup function. + */ +function hidePopup() { + $(modalPopupContent).html(''); + $(modalPopup).hide(); +} + +/* + * Function to get selected policies. + */ +function getSelectedPolicyStates() { + var policyList = []; + var thisTable = $(".DTTT_selected").closest('.dataTables_wrapper').find('.dataTable').dataTable(); + thisTable.api().rows().every(function () { + if ($(this.node()).hasClass('DTTT_selected')) { + policyList.push($(thisTable.api().row(this).node()).data('status')); + } + }); + + return policyList; +} + +/* + * Function to get selected policies. + */ +function getSelectedPolicies() { + var policyList = []; + var thisTable = $(".DTTT_selected").closest('.dataTables_wrapper').find('.dataTable').dataTable(); + thisTable.api().rows().every(function () { + if ($(this.node()).hasClass('DTTT_selected')) { + policyList.push($(thisTable.api().row(this).node()).data('id')); + } + }); + + return policyList; +} + +$(document).ready(function () { +// sortElements(); + +// var policyRoles = $("#policy-roles").text(); +// var policyUsers = $("#policy-users").text(); +// +// if (!policyRoles) { +// $("#policy-roles").hide(); +// } +// if (!policyUsers) { +// $("#policy-users").hide(); +// } + + /** + * ******************************************** + * Click functions related to Policy Listing + * ******************************************** + */ + + // [1] logic for running apply-changes-for-devices use-case + + var applyChangesButtonId = "#appbar-btn-apply-changes"; + + var isUpdated = $("#is-updated").val(); + if (!isUpdated) { + // if no updated policies found, hide button from app bar + $(applyChangesButtonId).addClass("hidden"); + } else { + // if updated policies found, show button from app bar + $(applyChangesButtonId).removeClass("hidden"); + } + + // click-event function for applyChangesButton + $(applyChangesButtonId).click(function () { + var serviceURL = "/api/device-mgt/v1.0/policies/apply-changes"; + $(modalPopupContent).html($('#change-policy-modal-content').html()); + showPopup(); + + $("a#change-policy-yes-link").click(function () { + invokerUtil.put( + serviceURL, + null, + // on success + function (data, textStatus, jqXHR) { + if (jqXHR.status == 200) { + $(modalPopupContent).html($('#change-policy-success-content').html()); + showPopup(); + $("a#change-policy-success-link").click(function () { + hidePopup(); + location.reload(); + }); + } + }, + // on error + function (jqXHR) { + console.log(stringify(jqXHR.data)); + $(modalPopupContent).html($("#change-policy-error-content").html()); + showPopup(); + $("a#change-policy-error-link").click(function () { + hidePopup(); + }); + } + ); + }); + + $("a#change-policy-cancel-link").click(function () { + hidePopup(); + }); + }); + + // [2] logic for un-publishing a selected set of Active, Active/Updated policies + + $(".policy-unpublish-link").click(function () { + var policyList = getSelectedPolicies(); + var statusList = getSelectedPolicyStates(); + if (($.inArray("Inactive/Updated", statusList) > -1) || ($.inArray("Inactive", statusList) > -1)) { + // if policies found in Inactive or Inactive/Updated states with in the selection, + // pop-up an error saying + // "You cannot select already inactive policies. Please deselect inactive policies and try again." + $(modalPopupContent).html($("#errorPolicyUnPublishSelection").html()); + showPopup(); + } else { + var serviceURL = "/api/device-mgt/v1.0/policies/deactivate-policy"; + if (policyList.length == 0) { + $(modalPopupContent).html($("#errorPolicyUnPublish").html()); + } else { + $(modalPopupContent).html($("#unpublish-policy-modal-content").html()); + } + showPopup(); + + // on-click function for policy un-publishing "yes" button + $("a#unpublish-policy-yes-link").click(function () { + invokerUtil.put( + serviceURL, + policyList, + // on success + function (data, textStatus, jqXHR) { + if (jqXHR.status == 200 && data) { + $(modalPopupContent).html($("#unpublish-policy-success-content").html()); + $("a#unpublish-policy-success-link").click(function () { + hidePopup(); + location.reload(); + }); + } + }, + // on error + function (jqXHR) { + console.log(stringify(jqXHR.data)); + $(modalPopupContent).html($("#unpublish-policy-error-content").html()); + $("a#unpublish-policy-error-link").click(function () { + hidePopup(); + }); + } + ); + }); + + // on-click function for policy un-publishing "cancel" button + $("a#unpublish-policy-cancel-link").click(function () { + hidePopup(); + }); + } + }); + + // [3] logic for publishing a selected set of Inactive, Inactive/Updated policies + + $(".policy-publish-link").click(function () { + var policyList = getSelectedPolicies(); + var statusList = getSelectedPolicyStates(); + if (($.inArray("Active/Updated", statusList) > -1) || ($.inArray("Active", statusList) > -1)) { + // if policies found in Active or Active/Updated states with in the selection, + // pop-up an error saying + // "You cannot select already active policies. Please deselect active policies and try again." + $(modalPopupContent).html($("#active-policy-selection-error").html()); + showPopup(); + } else { + var serviceURL = "/api/device-mgt/v1.0/policies/activate-policy"; + if (policyList.length == 0) { + $(modalPopupContent).html($("#policy-publish-error").html()); + } else { + $(modalPopupContent).html($("#publish-policy-modal-content").html()); + } + showPopup(); + + // on-click function for policy removing "yes" button + $("a#publish-policy-yes-link").click(function () { + invokerUtil.put( + serviceURL, + policyList, + // on success + function (data, textStatus, jqXHR) { + if (jqXHR.status == 200 && data) { + $(modalPopupContent).html($("#publish-policy-success-content").html()); + $("a#publish-policy-success-link").click(function () { + hidePopup(); + location.reload(); + }); + } + }, + // on error + function (jqXHR) { + console.log(stringify(jqXHR.data)); + $(modalPopupContent).html($("#publish-policy-error-content").html()); + $("a#publish-policy-error-link").click(function () { + hidePopup(); + }); + } + ); + }); + + // on-click function for policy removing "cancel" button + $("a#publish-policy-cancel-link").click(function () { + hidePopup(); + }); + } + }); + + // [4] logic for removing a selected set of policies + + $(".policy-remove-link").click(function () { + var policyList = getSelectedPolicies(); + var statusList = getSelectedPolicyStates(); + if (($.inArray("Active/Updated", statusList) > -1) || ($.inArray("Active", statusList) > -1)) { + // if policies found in Active or Active/Updated states with in the selection, + // pop-up an error saying + // "You cannot remove already active policies. Please deselect active policies and try again." + $(modalPopupContent).html($("#active-policy-selection-error").html()); + showPopup(); + } else { + var serviceURL = "/api/device-mgt/v1.0/policies/remove-policy"; + if (policyList.length == 0) { + $(modalPopupContent).html($("#policy-remove-error").html()); + } else { + $(modalPopupContent).html($("#remove-policy-modal-content").html()); + } + showPopup(); + + // on-click function for policy removing "yes" button + $("a#remove-policy-yes-link").click(function () { + invokerUtil.post( + serviceURL, + policyList, + // on success + function (data, textStatus, jqXHR) { + if (jqXHR.status == 200 && data) { + $(modalPopupContent).html($("#remove-policy-success-content").html()); + $("a#remove-policy-success-link").click(function () { + hidePopup(); + location.reload(); + }); + } + }, + // on error + function (jqXHR) { + console.log(stringify(jqXHR.data)); + $(modalPopupContent).html($("#remove-policy-error-content").html()); + $("a#remove-policy-error-link").click(function () { + hidePopup(); + }); + } + ); + }); + + // on-click function for policy removing "cancel" button + $("a#remove-policy-cancel-link").click(function () { + hidePopup(); + }); + } + }); + + $("#loading-content").remove(); + if ($("#policy-listing-status-msg").text()) { + $("#policy-listing-status").removeClass("hidden"); + } + $("#policy-grid").removeClass("hidden"); + // $(".icon .text").res_text(0.2); +}); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/operation-bar.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/operation-bar.hbs index 468bae0c4..e4a17d8f0 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/operation-bar.hbs +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/operation-bar.hbs @@ -15,10 +15,14 @@ specific language governing permissions and limitations under the License. }} -
    +{{#zone "content"}} +
    + {{unit "mdm.unit.device.operation-mod"}} +
    +{{/zone}} {{#zone "bottomJs"}} - {{js "js/operation-bar.js"}} + {{js "js/operation-bar.js"}} {{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/public/js/operation-bar.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/public/js/operation-bar.js index fe6c85bd0..1e65ffb33 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/public/js/operation-bar.js +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/public/js/operation-bar.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * WSO2 Inc. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except @@ -103,13 +103,15 @@ function loadOperationBar(deviceType) { var operationBar = $("#operations-bar"); var operationBarSrc = operationBar.attr("src"); var platformType = deviceType; + //var selectedDeviceID = deviceId; $.template("operations-bar", operationBarSrc, function (template) { - var serviceURL = "/devicemgt_admin/features/" + platformType; + //var serviceURL = "/mdm-admin/features/" + platformType; + var serviceURL = "/api/device-mgt/v1.0/devices/"+platformType+"/*/features"; var successCallback = function (data) { var viewModel = {}; data = JSON.parse(data).filter(function (current) { var iconName; - switch (deviceType) { + switch(deviceType) { case platformTypeConstants.ANDROID: iconName = operationModule.getAndroidIconForFeature(current.code); current.type = deviceType; @@ -140,6 +142,7 @@ function loadOperationBar(deviceType) { function runOperation(operationName) { var deviceIdList = getSelectedDeviceIds(); var list = getDevicesByTypes(deviceIdList); + console.log(list); var successCallback = function (data) { if (operationName == "NOTIFICATION") { @@ -157,7 +160,7 @@ function runOperation(operationName) { var payload, serviceEndPoint; if (list[platformTypeConstants.IOS]) { payload = operationModule. - generatePayload(platformTypeConstants.IOS, operationName, list[platformTypeConstants.IOS]); + generatePayload(platformTypeConstants.IOS, operationName, list[platformTypeConstants.IOS]); serviceEndPoint = operationModule.getIOSServiceEndpoint(operationName); } else if (list[platformTypeConstants.ANDROID]) { payload = operationModule @@ -165,14 +168,15 @@ function runOperation(operationName) { serviceEndPoint = operationModule.getAndroidServiceEndpoint(operationName); } else if (list[platformTypeConstants.WINDOWS]) { payload = operationModule. - generatePayload(platformTypeConstants.WINDOWS, operationName, list[platformTypeConstants.WINDOWS]); + generatePayload(platformTypeConstants.WINDOWS, operationName, list[platformTypeConstants.WINDOWS]); serviceEndPoint = operationModule.getWindowsServiceEndpoint(operationName); } if (operationName == "NOTIFICATION") { var errorMsgWrapper = "#notification-error-msg"; var errorMsg = "#notification-error-msg span"; - var message = $("#message").val(); - if (!message) { + var messageTitle = $("#messageTitle").val(); + var messageText = $("#messageText").val(); + if (!(messageTitle && messageText)) { $(errorMsg).text("Enter a message. It cannot be empty."); $(errorMsgWrapper).removeClass("hidden"); } else { @@ -181,6 +185,7 @@ function runOperation(operationName) { hidePopup(); } } else { + console.log(serviceEndPoint); invokerUtil.post(serviceEndPoint, payload, successCallback, errorCallback); $(modalPopupContent).removeData(); hidePopup(); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-mod/public/js/operation-mod.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-mod/public/js/operation-mod.js index b35faac5a..3f1219765 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-mod/public/js/operation-mod.js +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-mod/public/js/operation-mod.js @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * WSO2 Inc. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except * in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -37,12 +37,50 @@ var operationModule = function () { // Constants to define Android Operation Constants var androidOperationConstants = { "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", + "VPN_OPERATION_CODE": "VPN", "CAMERA_OPERATION_CODE": "CAMERA", "ENCRYPT_STORAGE_OPERATION_CODE": "ENCRYPT_STORAGE", "WIFI_OPERATION_CODE": "WIFI", "WIPE_OPERATION_CODE": "WIPE_DATA", "NOTIFICATION_OPERATION_CODE": "NOTIFICATION", - "CHANGE_LOCK_CODE_OPERATION_CODE": "CHANGE_LOCK_CODE" + "WORK_PROFILE_CODE": "WORK_PROFILE", + "CHANGE_LOCK_CODE_OPERATION_CODE": "CHANGE_LOCK_CODE", + "LOCK_OPERATION_CODE": "DEVICE_LOCK", + "UPGRADE_FIRMWARE": "UPGRADE_FIRMWARE", + "DISALLOW_ADJUST_VOLUME": "DISALLOW_ADJUST_VOLUME", + "DISALLOW_CONFIG_BLUETOOTH" : "DISALLOW_CONFIG_BLUETOOTH", + "DISALLOW_CONFIG_CELL_BROADCASTS" : "DISALLOW_CONFIG_CELL_BROADCASTS", + "DISALLOW_CONFIG_CREDENTIALS" : "DISALLOW_CONFIG_CREDENTIALS", + "DISALLOW_CONFIG_MOBILE_NETWORKS" : "DISALLOW_CONFIG_MOBILE_NETWORKS", + "DISALLOW_CONFIG_TETHERING" : "DISALLOW_CONFIG_TETHERING", + "DISALLOW_CONFIG_VPN" : "DISALLOW_CONFIG_VPN", + "DISALLOW_CONFIG_WIFI" : "DISALLOW_CONFIG_WIFI", + "DISALLOW_APPS_CONTROL" : "DISALLOW_APPS_CONTROL", + "DISALLOW_CREATE_WINDOWS" : "DISALLOW_CREATE_WINDOWS", + "DISALLOW_CROSS_PROFILE_COPY_PASTE" : "DISALLOW_CROSS_PROFILE_COPY_PASTE", + "DISALLOW_DEBUGGING_FEATURES" : "DISALLOW_DEBUGGING_FEATURES", + "DISALLOW_FACTORY_RESET" : "DISALLOW_FACTORY_RESET", + "DISALLOW_ADD_USER" : "DISALLOW_ADD_USER", + "DISALLOW_INSTALL_APPS" : "DISALLOW_INSTALL_APPS", + "DISALLOW_INSTALL_UNKNOWN_SOURCES" : "DISALLOW_INSTALL_UNKNOWN_SOURCES", + "DISALLOW_MODIFY_ACCOUNTS" : "DISALLOW_MODIFY_ACCOUNTS", + "DISALLOW_MOUNT_PHYSICAL_MEDIA" : "DISALLOW_MOUNT_PHYSICAL_MEDIA", + "DISALLOW_NETWORK_RESET" : "DISALLOW_NETWORK_RESET", + "DISALLOW_OUTGOING_BEAM" : "DISALLOW_OUTGOING_BEAM", + "DISALLOW_OUTGOING_CALLS" : "DISALLOW_OUTGOING_CALLS", + "DISALLOW_REMOVE_USER" : "DISALLOW_REMOVE_USER", + "DISALLOW_SAFE_BOOT" : "DISALLOW_SAFE_BOOT", + "DISALLOW_SHARE_LOCATION" : "DISALLOW_SHARE_LOCATION", + "DISALLOW_SMS" : "DISALLOW_SMS", + "DISALLOW_UNINSTALL_APPS" : "DISALLOW_UNINSTALL_APPS", + "DISALLOW_UNMUTE_MICROPHONE" : "DISALLOW_UNMUTE_MICROPHONE", + "DISALLOW_USB_FILE_TRANSFER" : "DISALLOW_USB_FILE_TRANSFER", + "ALLOW_PARENT_PROFILE_APP_LINKING" : "ALLOW_PARENT_PROFILE_APP_LINKING", + "ENSURE_VERIFY_APPS" : "ENSURE_VERIFY_APPS", + "AUTO_TIME" : "AUTO_TIME", + "SET_SCREEN_CAPTURE_DISABLED" : "SET_SCREEN_CAPTURE_DISABLED", + "SET_STATUS_BAR_DISABLED" : "SET_STATUS_BAR_DISABLED", + "APPLICATION_OPERATION_CODE":"APP-RESTRICTION" }; // Constants to define Windows Operation Constants @@ -58,6 +96,7 @@ var operationModule = function () { var iosOperationConstants = { "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", "RESTRICTIONS_OPERATION_CODE": "RESTRICTION", + "VPN_OPERATION_CODE": "VPN", "WIFI_OPERATION_CODE": "WIFI", "EMAIL_OPERATION_CODE": "EMAIL", "AIRPLAY_OPERATION_CODE": "AIR_PLAY", @@ -66,13 +105,19 @@ var operationModule = function () { "NOTIFICATION_OPERATION_CODE": "NOTIFICATION", "CALENDAR_SUBSCRIPTION_OPERATION_CODE": "CALENDAR_SUBSCRIPTION", "APN_OPERATION_CODE": "APN", - "CELLULAR_OPERATION_CODE": "CELLULAR" + "DOMAIN_CODE": "DOMAIN", + "CELLULAR_OPERATION_CODE": "CELLULAR", + "PER_APP_VPN_OPERATION_CODE": "PER_APP_VPN", + "APP_TO_PER_APP_VPN_MAPPING_OPERATION_CODE": "APP_TO_PER_APP_VPN_MAPPING" }; publicMethods.getIOSServiceEndpoint = function (operationCode) { var featureMap = { "DEVICE_LOCK": "lock", - "ALARM": "alarm", + "VPN": "vpn", + "PER_APP_VPN": "perappvpn", + "APP_TO_PER_APP_VPN_MAPPING": "apptoperappvpnmapping", + "RING": "ring", "LOCATION": "location", "NOTIFICATION": "notification", "AIR_PLAY": "airplay", @@ -182,6 +227,76 @@ var operationModule = function () { "restrictionsAutonomousSingleAppModePermittedAppIDs": operationPayload["autonomousSingleAppModePermittedAppIDs"] }; break; + case iosOperationConstants["VPN_OPERATION_CODE"]: + var pptp = false; + var l2tp = false; + if (operationPayload["vpnType"] == "PPTP") { + pptp = true; + } else if (operationPayload["vpnType"] == "L2TP") { + l2tp = true; + } + + payload = { + "userDefinedName": operationPayload["userDefinedName"], + "overridePrimary": operationPayload["overridePrimary"], + "onDemandEnabled": operationPayload["onDemandEnabled"], + "onDemandMatchDomainsAlways": operationPayload["onDemandMatchDomainsAlways"], + "onDemandMatchDomainsNever": operationPayload["onDemandMatchDomainsNever"], + "onDemandMatchDomainsOnRetry": operationPayload["onDemandMatchDomainsOnRetry"], + "onDemandRules": operationPayload["onDemandRules"], + "vendorConfigs": operationPayload["vendorConfigs"], + "vpnType": operationPayload["vpnType"], + "pptpAuthName": pptp ? operationPayload.ppp["authName"] : "", + "pptpTokenCard": pptp ? operationPayload.ppp["tokenCard"] : "", + "pptpAuthPassword": pptp ? operationPayload.ppp["authPassword"] : "", + "pptpCommRemoteAddress": pptp ? operationPayload.ppp["commRemoteAddress"] : "", + "pptpRSASecureID": pptp ? operationPayload.ppp["RSASecureID"] : "", + "pptpCCPEnabled": pptp ? operationPayload.ppp["CCPEnabled"] : "", + "pptpCCPMPPE40Enabled": pptp ? operationPayload.ppp["CCPMPPE40Enabled"] : "", + "pptpCCPMPPE128Enabled": pptp ? operationPayload.ppp["CCPMPPE128Enabled"] : "", + "l2tpAuthName": l2tp ? operationPayload.ppp["authName"] : "", + "l2tpTokenCard": l2tp ? operationPayload.ppp["tokenCard"] : "", + "l2tpAuthPassword": l2tp ? operationPayload.ppp["authPassword"] : "", + "l2tpCommRemoteAddress": l2tp ? operationPayload.ppp["commRemoteAddress"] : "", + "l2tpRSASecureID": l2tp ? operationPayload.ppp["RSASecureID"] : "", + "ipsecRemoteAddress": operationPayload.ipSec["remoteAddress"], + "ipsecAuthenticationMethod": operationPayload.ipSec["authenticationMethod"], + "ipsecLocalIdentifier": operationPayload.ipSec["localIdentifier"], + "ipsecSharedSecret": operationPayload.ipSec["sharedSecret"], + "ipsecPayloadCertificateUUID": operationPayload.ipSec["payloadCertificateUUID"], + "ipsecXAuthEnabled": operationPayload.ipSec["XAuthEnabled"], + "ipsecXAuthName": operationPayload.ipSec["XAuthName"], + "ipsecPromptForVPNPIN": operationPayload.ipSec["promptForVPNPIN"], + "ikev2RemoteAddress": operationPayload.ikEv2["remoteAddress"], + "ikev2LocalIdentifier": operationPayload.ikEv2["localIdentifier"], + "ikev2RemoteIdentifier": operationPayload.ikEv2["remoteIdentifier"], + "ikev2AuthenticationMethod": operationPayload.ikEv2["authenticationMethod"], + "ikev2SharedSecret": operationPayload.ikEv2["sharedSecret"], + "ikev2PayloadCertificateUUID": operationPayload.ikEv2["payloadCertificateUUID"], + "ikev2ExtendedAuthEnabled": operationPayload.ikEv2["extendedAuthEnabled"], + "ikev2AuthName": operationPayload.ikEv2["authName"], + "ikev2AuthPassword": operationPayload.ikEv2["authPassword"], + "ikev2DeadPeerDetectionInterval": operationPayload.ikEv2["deadPeerDetectionInterval"], + "ikev2ServerCertificateIssuerCommonName": operationPayload.ikEv2["serverCertificateIssuerCommonName"], + "ikev2ServerCertificateCommonName": operationPayload.ikEv2["serverCertificateCommonName"] + }; + break; + case iosOperationConstants["PER_APP_VPN_OPERATION_CODE"]: + payload = { + "operation": { + "VPNUUID": operationPayload["PER-APP-VPNUUID"], + "safariDomains": operationPayload["safariDomains"], + "onDemandMatchAppEnabled": operationPayload["onDemandMatchAppEnabled"] + } + }; + break; + case iosOperationConstants["APP_TO_PER_APP_VPN_MAPPING_OPERATION_CODE"]: + payload = { + "operation": { + "appLayerVPNMappings": operationPayload["appLayerVPNMappings"] + } + }; + break; case iosOperationConstants["WIFI_OPERATION_CODE"]: payload = { "wifiHiddenNetwork": operationPayload["hiddenNetwork"], @@ -222,31 +337,31 @@ var operationModule = function () { break; case iosOperationConstants["EMAIL_OPERATION_CODE"]: payload = { - "emailAccountDescription": operationPayload["emailAccountDescription"], - "emailAccountName": operationPayload["emailAccountName"], - "emailAccountType": operationPayload["emailAccountType"], - "emailAddress": operationPayload["emailAddress"], - "emailIncomingMailServerAuthentication": operationPayload["incomingMailServerAuthentication"], - "emailIncomingMailServerHostname": operationPayload["incomingMailServerHostName"], - "emailIncomingMailServerPort": operationPayload["incomingMailServerPortNumber"], - "emailIncomingUseSSL": operationPayload["incomingMailServerUseSSL"], - "emailIncomingMailServerUsername": operationPayload["incomingMailServerUsername"], - "emailIncomingMailServerPassword": operationPayload["incomingPassword"], - "emailOutgoingMailServerPassword": operationPayload["outgoingPassword"], - "emailOutgoingPasswordSameAsIncomingPassword": operationPayload["outgoingPasswordSameAsIncomingPassword"], - "emailOutgoingMailServerAuthentication": operationPayload["outgoingMailServerAuthentication"], - "emailOutgoingMailServerHostname": operationPayload["outgoingMailServerHostName"], - "emailOutgoingMailServerPort": operationPayload["outgoingMailServerPortNumber"], - "emailOutgoingUseSSL": operationPayload["outgoingMailServerUseSSL"], - "emailOutgoingMailServerUsername": operationPayload["outgoingMailServerUsername"], - "emailPreventMove": operationPayload["preventMove"], - "emailPreventAppSheet": operationPayload["preventAppSheet"], - "emailDisableMailRecentSyncing": operationPayload["disableMailRecentSyncing"], - "emailIncomingMailServerIMAPPathPrefix": operationPayload["incomingMailServerIMAPPathPrefix"], - "emailSMIMEEnabled": operationPayload["smimeenabled"], - "emailSMIMESigningCertificateUUID": operationPayload["smimesigningCertificateUUID"], - "emailSMIMEEncryptionCertificateUUID": operationPayload["smimeencryptionCertificateUUID"], - "emailSMIMEEnablePerMessageSwitch": operationPayload["smimeenablePerMessageSwitch"] + "emailAccountDescription": operationPayload["emailAccountDescription"], + "emailAccountName": operationPayload["emailAccountName"], + "emailAccountType": operationPayload["emailAccountType"], + "emailAddress": operationPayload["emailAddress"], + "emailIncomingMailServerAuthentication": operationPayload["incomingMailServerAuthentication"], + "emailIncomingMailServerHostname": operationPayload["incomingMailServerHostName"], + "emailIncomingMailServerPort": operationPayload["incomingMailServerPortNumber"], + "emailIncomingUseSSL": operationPayload["incomingMailServerUseSSL"], + "emailIncomingMailServerUsername": operationPayload["incomingMailServerUsername"], + "emailIncomingMailServerPassword": operationPayload["incomingPassword"], + "emailOutgoingMailServerPassword": operationPayload["outgoingPassword"], + "emailOutgoingPasswordSameAsIncomingPassword": operationPayload["outgoingPasswordSameAsIncomingPassword"], + "emailOutgoingMailServerAuthentication": operationPayload["outgoingMailServerAuthentication"], + "emailOutgoingMailServerHostname": operationPayload["outgoingMailServerHostName"], + "emailOutgoingMailServerPort": operationPayload["outgoingMailServerPortNumber"], + "emailOutgoingUseSSL": operationPayload["outgoingMailServerUseSSL"], + "emailOutgoingMailServerUsername": operationPayload["outgoingMailServerUsername"], + "emailPreventMove": operationPayload["preventMove"], + "emailPreventAppSheet": operationPayload["preventAppSheet"], + "emailDisableMailRecentSyncing": operationPayload["disableMailRecentSyncing"], + "emailIncomingMailServerIMAPPathPrefix": operationPayload["incomingMailServerIMAPPathPrefix"], + "emailSMIMEEnabled": operationPayload["smimeenabled"], + "emailSMIMESigningCertificateUUID": operationPayload["smimesigningCertificateUUID"], + "emailSMIMEEncryptionCertificateUUID": operationPayload["smimeencryptionCertificateUUID"], + "emailSMIMEEnablePerMessageSwitch": operationPayload["smimeenablePerMessageSwitch"] }; break; case iosOperationConstants["AIRPLAY_OPERATION_CODE"]: @@ -367,6 +482,112 @@ var operationModule = function () { } }; break; + case iosOperationConstants["VPN_OPERATION_CODE"]: + operationType = operationTypeConstants["PROFILE"]; + var ppp = {}; + var ipSec = {}; + var ikev2 = {}; + if (operationData["vpnType"] == "PPTP") { + ppp = { + "authName": operationData["pptpAuthName"], + "tokenCard": operationData["pptpTokenCard"], + "authPassword": operationData["pptpAuthPassword"], + "commRemoteAddress": operationData["pptpCommRemoteAddress"], + "RSASecureID": operationData["pptpRSASecureID"], + "CCPEnabled": operationData["pptpCCPEnabled"], + "CCPMPPE40Enabled": operationData["pptpCCPMPPE40Enabled"], + "CCPMPPE128Enabled": operationData["pptpCCPMPPE128Enabled"] + }; + } else if (operationData["vpnType"] == "L2TP") { + ppp = { + "authName": operationData["l2tpAuthName"], + "tokenCard": operationData["l2tpTokenCard"], + "authPassword": operationData["l2tpAuthPassword"], + "commRemoteAddress": operationData["l2tpCommRemoteAddress"], + "RSASecureID": operationData["l2tpRSASecureID"] + }; + } else if (operationData["vpnType"] == "IPSec") { + ipSec = { + "remoteAddress" : operationData["ipsecRemoteAddress"], + "authenticationMethod" : operationData["ipsecAuthenticationMethod"], + "localIdentifier" : operationData["ipsecLocalIdentifier"], + "sharedSecret" : operationData["ipsecSharedSecret"], + "payloadCertificateUUID" : operationData["ipsecPayloadCertificateUUID"], + "XAuthEnabled" : operationData["ipsecXAuthEnabled"], + "XAuthName" : operationData["ipsecXAuthName"], + "promptForVPNPIN" : operationData["ipsecPromptForVPNPIN"] + }; + } else if (operationData["vpnType"] == "IKEv2") { + ikev2 = { + "remoteAddress" : operationData["ikev2RemoteAddress"], + "localIdentifier" : operationData["ikev2LocalIdentifier"], + "remoteIdentifier" : operationData["ikev2RemoteIdentifier"], + "authenticationMethod" : operationData["ikev2AuthenticationMethod"], + "sharedSecret" : operationData["ikev2SharedSecret"], + "payloadCertificateUUID" : operationData["ikev2PayloadCertificateUUID"], + "extendedAuthEnabled" : operationData["ikev2ExtendedAuthEnabled"], + "authName" : operationData["ikev2AuthName"], + "authPassword" : operationData["ikev2AuthPassword"], + "deadPeerDetectionInterval" : operationData["ikev2DeadPeerDetectionInterval"], + "serverCertificateIssuerCommonName" : operationData["ikev2ServerCertificateIssuerCommonName"], + "serverCertificateCommonName" : operationData["ikev2ServerCertificateCommonName"] + }; + } + + var domainsAlways = new Array(); + for (var i = 0; i < operationData["onDemandMatchDomainsAlways"].length; i++) { + domainsAlways.push(operationData["onDemandMatchDomainsAlways"][i].domain); + } + + var domainsNever = new Array(); + for (var i = 0; i < operationData["onDemandMatchDomainsNever"].length; i++) { + domainsNever.push(operationData["onDemandMatchDomainsNever"][i].domain); + } + + var domainsRetry = new Array(); + for (var i = 0; i < operationData["onDemandMatchDomainsOnRetry"].length; i++) { + domainsRetry.push(operationData["onDemandMatchDomainsOnRetry"][i].domain); + } + + payload = { + "operation": { + "userDefinedName": operationData["userDefinedName"], + "overridePrimary": operationData["overridePrimary"], + "onDemandEnabled": operationData["onDemandEnabled"], + "onDemandMatchDomainsAlways": domainsAlways, + "onDemandMatchDomainsNever": domainsNever, + "onDemandMatchDomainsOnRetry": domainsRetry, + "onDemandRules" : operationData["onDemandRules"], + "vendorConfigs" : operationData["vendorConfigs"], + "vpnType" : operationData["vpnType"], + "ppp": ppp, + "ipSec": ipSec, + "ikEv2": ikev2 + } + }; + break; + case iosOperationConstants["PER_APP_VPN_OPERATION_CODE"]: + operationType = operationTypeConstants["PROFILE"]; + var domains = new Array(); + for (var i = 0; i < operationData["safariDomains"].length; i++) { + domains.push(operationData["safariDomains"][i].domain); + } + payload = { + "operation": { + "VPNUUID": operationData["VPNUUID"], + "safariDomains": domains, + "onDemandMatchAppEnabled": operationData["onDemandMatchAppEnabled"] + } + }; + break; + case iosOperationConstants["APP_TO_PER_APP_VPN_MAPPING_OPERATION_CODE"]: + operationType = operationTypeConstants["PROFILE"]; + payload = { + "operation": { + "appLayerVPNMappings": operationData["appLayerVPNMappings"] + } + }; + break; case iosOperationConstants["RESTRICTIONS_OPERATION_CODE"]: operationType = operationTypeConstants["PROFILE"]; payload = { @@ -528,6 +749,15 @@ var operationModule = function () { } }; break; + case iosOperationConstants["DOMAIN_CODE"]: + operationType = operationTypeConstants["PROFILE"]; + payload = { + "operation": { + "emailDomains": operationData["emailDomains"], + "webDomains": operationData["webDomains"] + } + }; + break; case iosOperationConstants["CELLULAR_OPERATION_CODE"]: operationType = operationTypeConstants["PROFILE"]; payload = { @@ -544,7 +774,7 @@ var operationModule = function () { operationType = operationTypeConstants["PROFILE"]; payload = { "operation": { - "message": operationData["message"] + "message" : operationData["message"] } }; break; @@ -584,9 +814,7 @@ var operationModule = function () { }; break; case androidOperationConstants["CAMERA_OPERATION_CODE"]: - payload = { - "cameraEnabled": operationPayload["enabled"] - }; + payload = operationPayload; break; case androidOperationConstants["ENCRYPT_STORAGE_OPERATION_CODE"]: payload = { @@ -596,7 +824,29 @@ var operationModule = function () { case androidOperationConstants["WIFI_OPERATION_CODE"]: payload = { "wifiSSID": operationPayload["ssid"], - "wifiPassword": operationPayload["password"] + "wifiPassword": operationPayload["password"], + "wifiType": operationPayload["type"], + "wifiEAP": operationPayload["eap"], + "wifiPhase2": operationPayload["phase2"], + "wifiProvisioning": operationPayload["provisioning"], + "wifiIdentity": operationPayload["identity"], + "wifiAnoIdentity": operationPayload["anonymousIdentity"], + "wifiCaCert" : operationPayload["cacert"], + "wifiCaCertName" : operationPayload["cacertName"] + }; + break; + case androidOperationConstants["VPN_OPERATION_CODE"]: + payload = { + "serverAddress": operationPayload["serverAddress"], + "serverPort": operationPayload["serverPort"], + "sharedSecret": operationPayload["sharedSecret"], + "dnsServer": operationPayload["dnsServer"] + }; + break; + case androidOperationConstants["APPLICATION_OPERATION_CODE"]: + payload = { + "restrictionType": operationPayload["restriction-type"], + "restrictedApplications": operationPayload["restricted-applications"] }; break; } @@ -611,7 +861,40 @@ var operationModule = function () { operationType = operationTypeConstants["PROFILE"]; payload = { "operation": { - "enabled": operationData["cameraEnabled"] + "CAMERA" : operationData["cameraEnabled"], + "DISALLOW_ADJUST_VOLUME" : operationData["disallowAdjustVolumeEnabled"], + "DISALLOW_CONFIG_BLUETOOTH" : operationData["disallowConfigBluetooth"], + "DISALLOW_CONFIG_CELL_BROADCASTS" : operationData["disallowConfigCellBroadcasts"], + "DISALLOW_CONFIG_CREDENTIALS" : operationData["disallowConfigCredentials"], + "DISALLOW_CONFIG_MOBILE_NETWORKS" : operationData["disallowConfigMobileNetworks"], + "DISALLOW_CONFIG_TETHERING" : operationData["disallowConfigTethering"], + "DISALLOW_CONFIG_VPN" : operationData["disallowConfigVpn"], + "DISALLOW_CONFIG_WIFI" : operationData["disallowConfigWifi"], + "DISALLOW_APPS_CONTROL" : operationData["disallowAppControl"], + "DISALLOW_CREATE_WINDOWS" : operationData["disallowCreateWindows"], + "DISALLOW_CROSS_PROFILE_COPY_PASTE" : operationData["disallowCrossProfileCopyPaste"], + "DISALLOW_DEBUGGING_FEATURES" : operationData["disallowDebugging"], + "DISALLOW_FACTORY_RESET" : operationData["disallowFactoryReset"], + "DISALLOW_ADD_USER" : operationData["disallowAddUser"], + "DISALLOW_INSTALL_APPS" : operationData["disallowInstallApps"], + "DISALLOW_INSTALL_UNKNOWN_SOURCES" : operationData["disallowInstallUnknownSources"], + "DISALLOW_MODIFY_ACCOUNTS" : operationData["disallowModifyAccounts"], + "DISALLOW_MOUNT_PHYSICAL_MEDIA" : operationData["disallowMountPhysicalMedia"], + "DISALLOW_NETWORK_RESET" : operationData["disallowNetworkReset"], + "DISALLOW_OUTGOING_BEAM" : operationData["disallowOutgoingBeam"], + "DISALLOW_OUTGOING_CALLS" : operationData["disallowOutgoingCalls"], + "DISALLOW_REMOVE_USER" : operationData["disallowRemoveUser"], + "DISALLOW_SAFE_BOOT" : operationData["disallowSafeBoot"], + "DISALLOW_SHARE_LOCATION" : operationData["disallowLocationSharing"], + "DISALLOW_SMS" : operationData["disallowSMS"], + "DISALLOW_UNINSTALL_APPS" : operationData["disallowUninstallApps"], + "DISALLOW_UNMUTE_MICROPHONE" : operationData["disallowUnmuteMicrophone"], + "DISALLOW_USB_FILE_TRANSFER" : operationData["disallowUSBFileTransfer"], + "ALLOW_PARENT_PROFILE_APP_LINKING" : operationData["disallowParentProfileAppLinking"], + "ENSURE_VERIFY_APPS" : operationData["ensureVerifyApps"], + "AUTO_TIME" : operationData["enableAutoTime"], + "SET_SCREEN_CAPTURE_DISABLED" : operationData["diableScreenCapture"], + "SET_STATUS_BAR_DISABLED" : operationData["disableStatusBar"] } }; break; @@ -619,7 +902,7 @@ var operationModule = function () { operationType = operationTypeConstants["PROFILE"]; payload = { "operation": { - "lockCode": operationData["lockCode"] + "lockCode" : operationData["lockCode"] } }; break; @@ -627,7 +910,7 @@ var operationModule = function () { operationType = operationTypeConstants["PROFILE"]; payload = { "operation": { - "encrypted": operationData["encryptStorageEnabled"] + "encrypted" : operationData["encryptStorageEnabled"] } }; break; @@ -635,7 +918,18 @@ var operationModule = function () { operationType = operationTypeConstants["PROFILE"]; payload = { "operation": { - "message": operationData["message"] + //"message" : operationData["message"] + "messageText": operationData["messageText"], + "messageTitle": operationData["messageTitle"] + } + }; + break; + case androidOperationConstants["UPGRADE_FIRMWARE"]: + operationType = operationTypeConstants["PROFILE"]; + payload = { + "operation": { + "schedule" : operationData["schedule"], + "server" : operationData["server"] } }; break; @@ -643,7 +937,7 @@ var operationModule = function () { operationType = operationTypeConstants["PROFILE"]; payload = { "operation": { - "pin": operationData["pin"] + "pin" : operationData["pin"] } }; break; @@ -652,7 +946,47 @@ var operationModule = function () { payload = { "operation": { "ssid": operationData["wifiSSID"], - "password": operationData["wifiPassword"] + "type": operationData["wifiType"], + "password" : operationData["wifiPassword"], + "eap" : operationData["wifiEAP"], + "phase2" : operationData["wifiPhase2"], + "provisioning" : operationData["wifiProvisioning"], + "identity" : operationData["wifiIdentity"], + "anonymousIdentity" : operationData["wifiAnoIdentity"], + "cacert" : operationData["wifiCaCert"], + "cacertName" : operationData["wifiCaCertName"] + } + }; + break; + case androidOperationConstants["VPN_OPERATION_CODE"]: + operationType = operationTypeConstants["PROFILE"]; + payload = { + "operation": { + "serverAddress": operationData["serverAddress"], + "serverPort": operationData["serverPort"], + "sharedSecret": operationData["sharedSecret"], + "dnsServer": operationData["dnsServer"] + } + }; + break; + case androidOperationConstants["LOCK_OPERATION_CODE"]: + operationType = operationTypeConstants["PROFILE"]; + payload = { + "operation": { + "message" : operationData["lock-message"], + "isHardLockEnabled" : operationData["hard-lock"] + } + }; + break; + case androidOperationConstants["WORK_PROFILE_CODE"]: + operationType = operationTypeConstants["PROFILE"]; + payload = { + "operation": { + "profileName": operationData["workProfilePolicyProfileName"], + "enableSystemApps": operationData["workProfilePolicyEnableSystemApps"], + "hideSystemApps": operationData["workProfilePolicyHideSystemApps"], + "unhideSystemApps": operationData["workProfilePolicyUnhideSystemApps"], + "enablePlaystoreApps": operationData["workProfilePolicyEnablePlaystoreApps"] } }; break; @@ -670,6 +1004,14 @@ var operationModule = function () { } }; break; + case androidOperationConstants["APPLICATION_OPERATION_CODE"]: + payload = { + "operation": { + "restriction-type": operationData["restrictionType"], + "restricted-applications": operationData["restrictedApplications"] + } + }; + break; default: // If the operation is neither of above, it is a command operation operationType = operationTypeConstants["COMMAND"]; @@ -686,28 +1028,31 @@ var operationModule = function () { publicMethods.getAndroidServiceEndpoint = function (operationCode) { var featureMap = { - "WIFI": "wifi", - "CAMERA": "camera", - "DEVICE_LOCK": "lock", + "WIFI": "configure-wifi", + "CAMERA": "control-camera", + "VPN": "configure-vpn", + "DEVICE_LOCK": "lock-devices", + "DEVICE_UNLOCK": "unlock-devices", "DEVICE_LOCATION": "location", "CLEAR_PASSWORD": "clear-password", "APPLICATION_LIST": "get-application-list", - "DEVICE_RING": "ring-device", - "DEVICE_REBOOT": "reboot-device", + "DEVICE_RING": "ring", + "DEVICE_REBOOT": "reboot", "UPGRADE_FIRMWARE": "upgrade-firmware", "DEVICE_MUTE": "mute", - "NOTIFICATION": "notification", - "ENCRYPT_STORAGE": "encrypt", + "NOTIFICATION": "send-notification", + "ENCRYPT_STORAGE": "encrypt-storage", "CHANGE_LOCK_CODE": "change-lock-code", - "WEBCLIP": "webclip", + "WEBCLIP": "set-webclip", "INSTALL_APPLICATION": "install-application", "UNINSTALL_APPLICATION": "uninstall-application", "BLACKLIST_APPLICATIONS": "blacklist-applications", - "PASSCODE_POLICY": "password-policy", + "PASSCODE_POLICY": "set-password-policy", "ENTERPRISE_WIPE": "enterprise-wipe", - "WIPE_DATA": "wipe-data" + "WIPE_DATA": "wipe" }; - return "/mdm-android-agent/operation/" + featureMap[operationCode]; + //return "/mdm-android-agent/operation/" + featureMap[operationCode]; + return "/api/device-mgt/android/v1.0/admin/devices/" + featureMap[operationCode]; }; /** @@ -754,7 +1099,7 @@ var operationModule = function () { operationType = operationTypeConstants["PROFILE"]; payload = { "operation": { - "enabled": operationData["cameraEnabled"] + "enabled" : operationData["cameraEnabled"] } }; break; @@ -762,7 +1107,7 @@ var operationModule = function () { operationType = operationTypeConstants["PROFILE"]; payload = { "operation": { - "lockCode": operationData["lockCode"] + "lockCode" : operationData["lockCode"] } }; break; @@ -770,7 +1115,7 @@ var operationModule = function () { operationType = operationTypeConstants["PROFILE"]; payload = { "operation": { - "encrypted": operationData["encryptStorageEnabled"] + "encrypted" : operationData["encryptStorageEnabled"] } }; break; @@ -778,7 +1123,7 @@ var operationModule = function () { operationType = operationTypeConstants["PROFILE"]; payload = { "operation": { - "message": operationData["message"] + "message" : operationData["message"] } }; break; @@ -852,9 +1197,10 @@ var operationModule = function () { "DEVICE_RING": "fw-dial-up", "DEVICE_REBOOT": "fw-refresh", "UPGRADE_FIRMWARE": "fw-up-arrow", - "DEVICE_MUTE": "fw-incoming-call", + "DEVICE_MUTE": "fw-mute", "NOTIFICATION": "fw-message", - "CHANGE_LOCK_CODE": "fw-security" + "CHANGE_LOCK_CODE": "fw-security", + "DEVICE_UNLOCK": "fw-lock" }; return featureMap[operationCode]; }; @@ -891,7 +1237,7 @@ var operationModule = function () { "LOCATION": "fw-map-location", "ENTERPRISE_WIPE": "fw-clear", "NOTIFICATION": "fw-message", - "ALARM": "fw-dial-up" + "RING": "fw-dial-up" }; return featureMap[operationCode]; }; @@ -904,9 +1250,7 @@ var operationModule = function () { */ $.fn.filterByData = function (prop, val) { return this.filter( - function () { - return $(this).data(prop) == val; - } + function () {return $(this).data(prop) == val;} ); }; @@ -928,7 +1272,7 @@ var operationModule = function () { var key = operationDataObj.data("key"); var value; if (operationDataObj.is(":text") || operationDataObj.is("textarea") || - operationDataObj.is(":password")) { + operationDataObj.is(":password") || operationDataObj.is(":hidden")) { value = operationDataObj.val(); } else if (operationDataObj.is(":checkbox")) { value = operationDataObj.is(":checked"); @@ -941,7 +1285,8 @@ var operationModule = function () { if (operationDataObj.hasClass("one-column-input-array")) { $(".child-input", this).each(function () { childInput = $(this); - if (childInput.is(":text") || childInput.is("textarea") || childInput.is(":password")) { + if (childInput.is(":text") || childInput.is("textarea") || childInput.is(":password") + || childInput.is(":hidden")) { childInputValue = childInput.val(); } else if (childInput.is(":checkbox")) { childInputValue = childInput.is(":checked"); @@ -967,7 +1312,8 @@ var operationModule = function () { var joinedInput; $(".child-input", this).each(function () { childInput = $(this); - if (childInput.is(":text") || childInput.is("textarea") || childInput.is(":password")) { + if (childInput.is(":text") || childInput.is("textarea") || childInput.is(":password") + || childInput.is(":hidden")) { childInputValue = childInput.val(); } else if (childInput.is(":checkbox")) { childInputValue = childInput.is(":checked"); @@ -998,7 +1344,8 @@ var operationModule = function () { $(".child-input", this).each(function () { childInput = $(this); childInputKey = childInput.data("child-key"); - if (childInput.is(":text") || childInput.is("textarea") || childInput.is(":password")) { + if (childInput.is(":text") || childInput.is("textarea") || childInput.is(":password") + || childInput.is(":hidden")) { childInputValue = childInput.val(); } else if (childInput.is(":checkbox")) { childInputValue = childInput.is(":checked"); @@ -1026,6 +1373,7 @@ var operationModule = function () { operationData[key] = value; } ); + switch (platformType) { case platformTypeConstants["ANDROID"]: payload = privateMethods.generateAndroidOperationPayload(operationCode, operationData, deviceList); @@ -1089,58 +1437,17 @@ var operationModule = function () { // var childInputValue; if (operationDataObj.hasClass("one-column-input-array")) { // generating input fields to populate complex value - for (i = 0; i < value.length; ++i) { - operationDataObj.parent().find("a").filterByData("click-event", "add-form").click(); - } - // traversing through each child input - $(".child-input", this).each(function () { - childInput = $(this); - var childInputValue = value[childInputIndex]; - // populating extracted value in the UI according to the input type - if (childInput.is(":text") || - childInput.is("textarea") || - childInput.is(":password") || - childInput.is("select")) { - childInput.val(childInputValue); - } else if (childInput.is(":checkbox")) { - operationDataObj.prop("checked", childInputValue); + if (value) { + for (i = 0; i < value.length; ++i) { + operationDataObj.parent().find("a").filterByData("click-event", "add-form").click(); } - // incrementing childInputIndex - childInputIndex++; - }); - } else if (operationDataObj.hasClass("valued-check-box-array")) { - // traversing through each child input - $(".child-input", this).each(function () { - childInput = $(this); - // check if corresponding value of current checkbox exists in the array of values - if (value.indexOf(childInput.data("value")) != -1) { - // if YES, set checkbox as checked - childInput.prop("checked", true); - } - }); - } else if (operationDataObj.hasClass("multi-column-joined-input-array")) { - // generating input fields to populate complex value - for (i = 0; i < value.length; ++i) { - operationDataObj.parent().find("a").filterByData("click-event", "add-form").click(); - } - var columnCount = operationDataObj.data("column-count"); - var multiColumnJoinedInputArrayIndex = 0; - // handling scenarios specifically - if (operationDataObj.attr("id") == "wifi-mcc-and-mncs") { // traversing through each child input $(".child-input", this).each(function () { childInput = $(this); - var multiColumnJoinedInput = value[multiColumnJoinedInputArrayIndex]; - var childInputValue; - if ((childInputIndex % columnCount) == 0) { - childInputValue = multiColumnJoinedInput.substring(3, 0) - } else { - childInputValue = multiColumnJoinedInput.substring(3); - // incrementing childInputIndex - multiColumnJoinedInputArrayIndex++; - } + var childInputValue = value[childInputIndex]; // populating extracted value in the UI according to the input type if (childInput.is(":text") || + childInput.is(":hidden") || childInput.is("textarea") || childInput.is(":password") || childInput.is("select")) { @@ -1152,35 +1459,87 @@ var operationModule = function () { childInputIndex++; }); } - } else if (operationDataObj.hasClass("multi-column-key-value-pair-array")) { - // generating input fields to populate complex value - for (i = 0; i < value.length; ++i) { - operationDataObj.parent().find("a").filterByData("click-event", "add-form").click(); - } - columnCount = operationDataObj.data("column-count"); - var multiColumnKeyValuePairArrayIndex = 0; + } else if (operationDataObj.hasClass("valued-check-box-array")) { // traversing through each child input $(".child-input", this).each(function () { childInput = $(this); - var multiColumnKeyValuePair = value[multiColumnKeyValuePairArrayIndex]; - var childInputKey = childInput.data("child-key"); - var childInputValue = multiColumnKeyValuePair[childInputKey]; - // populating extracted value in the UI according to the input type - if (childInput.is(":text") || - childInput.is("textarea") || - childInput.is(":password") || - childInput.is("select")) { - childInput.val(childInputValue); - } else if (childInput.is(":checkbox")) { - operationDataObj.prop("checked", childInputValue); + // check if corresponding value of current checkbox exists in the array of values + if (value) { + if (value.indexOf(childInput.data("value")) != -1) { + // if YES, set checkbox as checked + childInput.prop("checked", true); + } } - // incrementing multiColumnKeyValuePairArrayIndex for the next row of inputs - if ((childInputIndex % columnCount) == (columnCount - 1)) { - multiColumnKeyValuePairArrayIndex++; - } - // incrementing childInputIndex - childInputIndex++; }); + } else if (operationDataObj.hasClass("multi-column-joined-input-array")) { + // generating input fields to populate complex value + if (value) { + for (i = 0; i < value.length; ++i) { + operationDataObj.parent().find("a").filterByData("click-event", "add-form").click(); + } + var columnCount = operationDataObj.data("column-count"); + var multiColumnJoinedInputArrayIndex = 0; + // handling scenarios specifically + if (operationDataObj.attr("id") == "wifi-mcc-and-mncs") { + // traversing through each child input + $(".child-input", this).each(function () { + childInput = $(this); + var multiColumnJoinedInput = value[multiColumnJoinedInputArrayIndex]; + var childInputValue; + if ((childInputIndex % columnCount) == 0) { + childInputValue = multiColumnJoinedInput.substring(3, 0) + } else { + childInputValue = multiColumnJoinedInput.substring(3); + // incrementing childInputIndex + multiColumnJoinedInputArrayIndex++; + } + // populating extracted value in the UI according to the input type + if (childInput.is(":text") || + childInput.is(":hidden") || + childInput.is("textarea") || + childInput.is(":password") || + childInput.is("select")) { + childInput.val(childInputValue); + } else if (childInput.is(":checkbox")) { + operationDataObj.prop("checked", childInputValue); + } + // incrementing childInputIndex + childInputIndex++; + }); + } + } + } else if (operationDataObj.hasClass("multi-column-key-value-pair-array")) { + // generating input fields to populate complex value + if (value) { + for (i = 0; i < value.length; ++i) { + operationDataObj.parent().find("a").filterByData("click-event", "add-form").click(); + } + columnCount = operationDataObj.data("column-count"); + var multiColumnKeyValuePairArrayIndex = 0; + // traversing through each child input + $(".child-input", this).each(function () { + childInput = $(this); + var multiColumnKeyValuePair = value[multiColumnKeyValuePairArrayIndex]; + var childInputKey = childInput.data("child-key"); + var childInputValue = multiColumnKeyValuePair[childInputKey]; + // populating extracted value in the UI according to the input type + if (childInput.is(":text") || + childInput.is(":hidden") || + childInput.is("textarea") || + childInput.is(":password") || + childInput.is("select")) { + childInput.val(childInputValue); + } else if (childInput.is(":checkbox")) { + operationDataObj.prop("checked", childInputValue); + } + // incrementing multiColumnKeyValuePairArrayIndex for the next row of inputs + if ((childInputIndex % columnCount) == (columnCount - 1)) { + multiColumnKeyValuePairArrayIndex++; + } + // incrementing childInputIndex + childInputIndex++; + }); + } } } } @@ -1199,8 +1558,29 @@ var operationModule = function () { for (var i = 0; i < operationCodes.length; ++i) { var operationCode = operationCodes[i]; var payload = publicMethods.generatePayload(platformType, operationCode, null); - generatedProfile[operationCode] = payload["operation"]; + + if(platformType == platformTypeConstants["ANDROID"] && + operationCodes[i] == androidOperationConstants["CAMERA_OPERATION_CODE"]){ + var operations = payload["operation"]; + for (var key in operations){ + operationCode = key; + var restriction = false; + if(operations[key]){ + restriction = true; + } + var payloadResult = { + "operation": { + "enabled" : restriction + } + }; + generatedProfile[operationCode] = payloadResult["operation"]; + } + + } else { + generatedProfile[operationCode] = payload["operation"]; + } } + console.log(generatedProfile); return generatedProfile; }; @@ -1213,14 +1593,125 @@ var operationModule = function () { */ publicMethods.populateProfile = function (platformType, payload) { var i, configuredOperations = []; + var restrictions = {}; for (i = 0; i < payload.length; ++i) { var configuredFeature = payload[i]; var featureCode = configuredFeature["featureCode"]; var operationPayload = configuredFeature["content"]; + if(platformType == platformTypeConstants["ANDROID"]){ + var restriction = JSON.parse(operationPayload); + if(featureCode == androidOperationConstants["CAMERA_OPERATION_CODE"]){ + restrictions["cameraEnabled"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_ADJUST_VOLUME"]){ + restrictions["disallowAdjustVolumeEnabled"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_BLUETOOTH"]){ + restrictions["disallowConfigBluetooth"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_CELL_BROADCASTS"]){ + restrictions["disallowConfigCellBroadcasts"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_CREDENTIALS"]){ + restrictions["disallowConfigCredentials"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_MOBILE_NETWORKS"]){ + restrictions["disallowConfigMobileNetworks"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_TETHERING"]){ + restrictions["disallowConfigTethering"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_VPN"]){ + restrictions["disallowConfigVpn"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_WIFI"]){ + restrictions["disallowConfigWifi"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_APPS_CONTROL"]){ + restrictions["disallowAppControl"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_CREATE_WINDOWS"]){ + restrictions["disallowCreateWindows"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_CROSS_PROFILE_COPY_PASTE"]){ + restrictions["disallowCrossProfileCopyPaste"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_DEBUGGING_FEATURES"]){ + restrictions["disallowDebugging"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_FACTORY_RESET"]){ + restrictions["disallowFactoryReset"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_ADD_USER"]){ + restrictions["disallowAddUser"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_INSTALL_APPS"]){ + restrictions["disallowInstallApps"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_INSTALL_UNKNOWN_SOURCES"]){ + restrictions["disallowInstallUnknownSources"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_MODIFY_ACCOUNTS"]){ + restrictions["disallowModifyAccounts"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_MOUNT_PHYSICAL_MEDIA"]){ + restrictions["disallowMountPhysicalMedia"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_NETWORK_RESET"]){ + restrictions["disallowNetworkReset"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_OUTGOING_BEAM"]){ + restrictions["disallowOutgoingBeam"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_OUTGOING_CALLS"]){ + restrictions["disallowOutgoingCalls"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_REMOVE_USER"]){ + restrictions["disallowRemoveUser"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_SAFE_BOOT"]){ + restrictions["disallowSafeBoot"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_SHARE_LOCATION"]){ + restrictions["disallowLocationSharing"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_SMS"]){ + restrictions["disallowSMS"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_UNINSTALL_APPS"]){ + restrictions["disallowUninstallApps"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_UNMUTE_MICROPHONE"]){ + restrictions["disallowUnmuteMicrophone"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["DISALLOW_USB_FILE_TRANSFER"]){ + restrictions["disallowUSBFileTransfer"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["ALLOW_PARENT_PROFILE_APP_LINKING"]){ + restrictions["disallowParentProfileAppLinking"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["ENSURE_VERIFY_APPS"]){ + restrictions["ensureVerifyApps"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["AUTO_TIME"]){ + restrictions["enableAutoTime"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["SET_SCREEN_CAPTURE_DISABLED"]){ + restrictions["diableScreenCapture"] = restriction["enabled"]; + continue; + } else if (featureCode == androidOperationConstants["SET_STATUS_BAR_DISABLED"]){ + restrictions["disableStatusBar"] = restriction["enabled"]; + continue; + } + } //push the feature-code to the configuration array configuredOperations.push(featureCode); publicMethods.populateUI(platformType, featureCode, operationPayload); } + if (typeof restrictions.cameraEnabled !== 'undefined') { + configuredOperations.push(androidOperationConstants["CAMERA_OPERATION_CODE"]); + publicMethods.populateUI(platformType, androidOperationConstants["CAMERA_OPERATION_CODE"], JSON.stringify(restrictions)); + } return configuredOperations; }; diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/img/device_icons/TemperatureController.png b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/img/device_icons/TemperatureController.png new file mode 100644 index 000000000..e16b48d8e Binary files /dev/null and b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/img/device_icons/TemperatureController.png differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/img/device_icons/android.png b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/img/device_icons/android.png new file mode 100755 index 000000000..7fee78a64 Binary files /dev/null and b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/img/device_icons/android.png differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/img/device_icons/ios.png b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/img/device_icons/ios.png new file mode 100644 index 000000000..4b09796f8 Binary files /dev/null and b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/img/device_icons/ios.png differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/img/graph.png b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/img/graph.png new file mode 100644 index 000000000..dd819ef4f Binary files /dev/null and b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/img/graph.png differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/js/device-detail.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/js/device-detail.js new file mode 100644 index 000000000..074095034 --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/js/device-detail.js @@ -0,0 +1,318 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +var InitiateViewOption = null; + +(function () { + var deviceId = $(".device-id"); + var deviceIdentifier = deviceId.data("deviceid"); + var deviceType = deviceId.data("type"); + var payload = [deviceIdentifier]; + var operationTable; + var serviceUrl; + + if (deviceType == "ios") { + serviceUrl = "/ios/operation/deviceinfo"; + } else if (deviceType == "android") { + //var serviceUrl = "/mdm-android-agent/operation/device-info"; + serviceUrl = "/api/device-mgt/android/v1.0/admin/devices/info"; + } + + if (serviceUrl) { + invokerUtil.post( + serviceUrl, + payload, + // success-callback + function () { + $(".panel-body").show(); + }, + // error-callback + function () { + var defaultInnerHTML = + "

    Device data may not have been updated. Please refresh to try again.

    "; + $(".panel-body").append(defaultInnerHTML); + } + ); + } + + $(".media.tab-responsive [data-toggle=tab]").on("shown.bs.tab", function (e) { + var activeTabPane = $(e.target).attr("href"), + activeCollapsePane = $(activeTabPane).find("[data-toggle=collapse]").data("target"), + activeCollapsePaneSiblings = $(activeTabPane).siblings().find("[data-toggle=collapse]").data("target"), + activeListGroupItem = $(".media .list-group-item.active"); + + $(activeCollapsePaneSiblings).collapse("hide"); + $(activeCollapsePane).collapse("show"); + positionArrow(activeListGroupItem); + + $(".panel-heading .caret-updown").removeClass("fw-sort-down"); + $(".panel-heading.collapsed .caret-updown").addClass("fw-sort-up"); + }); + + $(".media.tab-responsive .tab-content").on("shown.bs.collapse", function (e) { + var activeTabPane = $(e.target).parent().attr("id"); + $(".media.tab-responsive [data-toggle=tab][href=#" + activeTabPane + "]").tab("show"); + $(".panel-heading .caret-updown").removeClass("fw-sort-up"); + $(".panel-heading.collapsed .caret-updown").addClass("fw-sort-down"); + }); + + function positionArrow(selectedTab) { + var selectedTabHeight = $(selectedTab).outerHeight(); + var arrowPosition = 0; + var totalHeight = 0; + var arrow = $(".media .panel-group.tab-content .arrow-left"); + var parentHeight = $(arrow).parent().outerHeight(); + +// if($(selectedTab).prev().length){ +// $(selectedTab).prevAll().each(function() { +// totalHeight += $(this).outerHeight(); +// }); +// arrowPosition = totalHeight + (selectedTabHeight / 2); +// }else{ +// arrowPosition = selectedTabHeight / 2; +// } + + if(arrowPosition >= parentHeight){ + parentHeight = arrowPosition + 10; + $(arrow).parent().height(parentHeight); + }else{ + $(arrow).parent().removeAttr("style"); + } + $(arrow).css("top", arrowPosition - 10); + } + + $(document).ready(function() { + $(".device-detail-body").removeClass("hidden"); + $("#loading-content").remove(); + loadOperationBar(deviceType); + loadOperationsLog(false); + loadApplicationsList(); + loadPolicyCompliance(); + + $("#refresh-policy").click(function () { + $("#policy-spinner").removeClass("hidden"); + loadPolicyCompliance(); + }); + + $("#refresh-apps").click(function () { + $("#apps-spinner").removeClass("hidden"); + loadApplicationsList(); + }); + + $("#refresh-operations").click(function () { + $("#operations-spinner").removeClass("hidden"); + loadOperationsLog(true); + }); + }); + + function loadOperationsLog(update) { + var operationsLogTable = "#operations-log-table"; + if (update) { + operationTable = $(operationsLogTable).DataTable(); + operationTable.ajax.reload(false); + return; + } + operationTable = $(operationsLogTable).datatables_extended({ + serverSide: true, + processing: false, + searching: false, + ordering: false, + pageLength : 10, + order: [], + ajax: { + url: "/emm/api/operation/paginate", + data: {deviceId : deviceIdentifier, deviceType: deviceType}, + dataSrc: function (json) { + $("#operations-spinner").addClass("hidden"); + $("#operations-log-container").empty(); + return json.data; + } + }, + columnDefs: [ + {targets: 0, data: "code" }, + {targets: 1, data: "status", render: + function (status) { + var html; + switch (status) { + case "COMPLETED" : + html = " Completed"; + break; + case "PENDING" : + html = " Pending"; + break; + case "ERROR" : + html = " Error"; + break; + case "IN_PROGRESS" : + html = " In Progress"; + break; + case "REPEATED" : + html = " Repeated"; + break; + } + return html; + } + }, + {targets: 2, data: "createdTimeStamp", render: + function (date) { + var value = String(date); + return value.slice(0, 16); + } + } + ], + "createdRow": function(row, data) { + $(row).attr("data-type", "selectable"); + $(row).attr("data-id", data["id"]); + $.each($("td", row), + function(colIndex) { + switch(colIndex) { + case 1: + $(this).attr("data-grid-label", "Code"); + $(this).attr("data-display", data["code"]); + break; + case 2: + $(this).attr("data-grid-label", "Status"); + $(this).attr("data-display", data["status"]); + break; + case 3: + $(this).attr("data-grid-label", "Created Timestamp"); + $(this).attr("data-display", data["createdTimeStamp"]); + break; + } + } + ); + } + }); + } + + function loadApplicationsList() { + var applicationsList = $("#applications-list"); + var applicationListingTemplate = applicationsList.attr("src"); + var deviceId = applicationsList.data("device-id"); + var deviceType = applicationsList.data("device-type"); + + $.template("application-list", applicationListingTemplate, function (template) { + var serviceURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/applications"; + invokerUtil.get( + serviceURL, + // success-callback + function (data, textStatus, jqXHR) { + if (jqXHR.status == 200 && data) { + data = JSON.parse(data); + $("#apps-spinner").addClass("hidden"); + if (data.length > 0) { + for (var i = 0; i < data.length; i++) { + data[i]["name"] = decodeURIComponent(data[i]["name"]); + data[i]["platform"] = deviceType; + } + + var viewModel = {}; + viewModel["applications"] = data; + viewModel["deviceType"] = deviceType; + var content = template(viewModel); + $("#applications-list-container").html(content); + } else { + $("#applications-list-container"). + html("


     No applications found. " + + "please try refreshing the list in a while.

    "); + } + } + }, + // error-callback + function () { + $("#applications-list-container"). + html("

     Loading application list " + + "was not successful. please try refreshing the list in a while.

    "); + }); + }); + } + + function loadPolicyCompliance() { + var policyCompliance = $("#policy-view"); + var policyComplianceTemplate = policyCompliance.attr("src"); + var deviceId = policyCompliance.data("device-id"); + var deviceType = policyCompliance.data("device-type"); + var activePolicy = null; + + $.template( + "policy-view", + policyComplianceTemplate, + function (template) { + var getEffectivePolicyURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/effective-policy"; + var getDeviceComplianceURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/compliance-data"; + + invokerUtil.get( + getEffectivePolicyURL, + // success-callback + function (data, textStatus, jqXHR) { + if (jqXHR.status == 200 && data) { + data = JSON.parse(data); + $("#policy-spinner").addClass("hidden"); + if (data["active"] == true) { + activePolicy = data; + invokerUtil.get( + getDeviceComplianceURL, + // success-callback + function (data, textStatus, jqXHR) { + if (jqXHR.status == 200 && data) { + var viewModel = {}; + viewModel["policy"] = activePolicy; + viewModel["deviceType"] = deviceType; + data = JSON.parse(data); + var content; + if (data["complianceData"]) { + if (data["complianceData"]["complianceFeatures"] && + data["complianceData"]["complianceFeatures"].length > 0) { + viewModel["compliance"] = "NON-COMPLIANT"; + viewModel["complianceFeatures"] = data["complianceData"]["complianceFeatures"]; + content = template(viewModel); + $("#policy-list-container").html(content); + } else { + viewModel["compliance"] = "COMPLIANT"; + content = template(viewModel); + $("#policy-list-container").html(content); + $("#policy-compliance-table").addClass("hidden"); + } + } else { + $("#policy-list-container"). + html("

    This device " + + "has no policy applied.

    "); + } + } + }, + // error-callback + function () { + $("#policy-list-container"). + html("

    Loading policy compliance related data " + + "was not successful. please try refreshing data in a while.

    "); + } + ); + } + } + }, + // error-callback + function () { + $("#policy-list-container"). + html("

    Loading policy compliance related data " + + "was not successful. please try refreshing data in a while.

    "); + } + ); + } + ); + } +}()); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/js/load-map.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/js/load-map.js new file mode 100644 index 000000000..895f75b94 --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/js/load-map.js @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +var map; + +function loadLeafletMap() { + var deviceLocationID = "#device-location", + lat = $(deviceLocationID).data("lat"), + long = $(deviceLocationID).data("long"), + container = "device-location", + zoomLevel = 13, + tileSet = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", + attribution = "© OpenStreetMap contributors"; + + if (lat && long) { + map = L.map(container).setView([lat, long], zoomLevel); + L.tileLayer(tileSet, {attribution: attribution}).addTo(map); + L.marker([lat, long]).addTo(map).bindPopup("Device is here...").openPopup(); + + $("#map-error").hide(); + $("#device-location").show(); + } else { + $("#device-location").hide(); + $("#map-error").show(); + } +} + +$(document).ready(function () { + $("a[data-toggle='tab']").on("shown.bs.tab", function() { + var url = $(this).prop("href"); + var hash = url.substring(url.indexOf("#") + 1); + + if (hash == "device_location") { + if (!map) { + loadLeafletMap(); + } + } + }); +}); \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/templates/applications-list.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/templates/applications-list.hbs new file mode 100644 index 000000000..3b55136af --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/templates/applications-list.hbs @@ -0,0 +1,31 @@ + \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/templates/operations-log.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/templates/operations-log.hbs new file mode 100644 index 000000000..cc5db5117 --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/templates/operations-log.hbs @@ -0,0 +1,24 @@ + + + + + + + + + + {{#each operations}} + + + + + + {{/each}} +
    + +
    Operation CodeStatusRequest created at
    {{code}} + {{#equal status "COMPLETED"}} Completed{{/equal}} + {{#equal status "PENDING"}} Pending{{/equal}} + {{#equal status "ERROR"}} Error{{/equal}} + {{#equal status "IN_PROGRESS"}} In Progress{{/equal}} + {{createdTimeStamp}}
    \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/templates/policy-compliance.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/templates/policy-compliance.hbs new file mode 100644 index 000000000..d20ca7a9c --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/templates/policy-compliance.hbs @@ -0,0 +1,79 @@ +
    + +
    +
    + + {{#equal deviceType "android"}} + + {{/equal}} + {{#equal deviceType "ios"}} + + {{/equal}} + {{#equal deviceType "windows"}} + + {{/equal}} + + +

    {{policy.policyName}}

    + {{deviceType}} +
    +
    +
    +
    +
    +
    + Ownership Type : {{policy.ownershipType}} +
    +
    +
    +
    + Compliance Type : {{policy.compliance}} +
    +
    +
    +
    + Compliance : + {{#equal compliance "COMPLIANT"}} + Compliant + {{/equal}} + {{#equal compliance "NON-COMPLIANT"}} + Not Compliant + {{/equal}} +
    +
    +
    +
    + +
    +
    +
    + + + + + + + + + {{#each complianceFeatures}} + + + + + {{/each}} +
    + +
    FeatureCompliance
    {{featureCode}} + {{#equal compliance true}} Compliant{{/equal}} + {{#equal compliance false}} Not Compliant{{/equal}} +
    \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/view.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/view.hbs new file mode 100644 index 000000000..1eb7f0e3c --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/view.hbs @@ -0,0 +1,378 @@ +{{#zone "content"}} + {{#defineZone "device-detail-top"}} +
    +
    + +
    +
    + {{/defineZone}} +
    +
    +
    +
    +
    +
    +
    Device Overview
    + {{#defineZone "device-detail-properties"}} + + + + + + + {{#if device.viewModel.model}} + + + + + {{/if}} + + + + + {{#if device.viewModel.udid}} + + + + + {{/if}} + {{#if device.viewModel.os_build_date}} + + + + + {{/if}} + {{#if device.viewModel.phoneNumber}} + + + + + {{/if}} + + + + + +
    Device{{device.viewModel.vendor}} {{device.properties.model}}
    Model{{device.viewModel.model}}
    IMEI{{device.viewModel.imei}}
    UDID{{device.viewModel.udid}}
    Firmware Build Date{{device.viewModel.os_build_date}}
    Phone Number{{device.viewModel.phoneNumber}}
    Status + {{#equal device.status "ACTIVE"}}  Active{{/equal}} + {{#equal device.status "INACTIVE"}}  Inactive{{/equal}} + {{#equal device.status "BLOCKED"}}  Blocked{{/equal}} + {{#equal device.status "REMOVED"}}  Removed{{/equal}} +
    + {{/defineZone}} +
    Operations
    +
    + {{unit "mdm.unit.device.operation-bar" deviceType=device.type}} +
    +
    +
    +
    + +
    + {{#defineZone "device-detail-properties"}} +
    +
    + + +
    + + +
    +

           Loading Device Details . . .
    +
    +
    + +
    +
    +
    + + + +
    +
    +
    + There is no active policy for this device. +
    +
    +
    +
    +
    +
    + + +
    +
    +
    +
    + Device location cannot be retrieved. +
    +
    +
    +
    +
    + + +
    + +
    +
    +
    +

    + No applications found. please try refreshing the list in a while. +

    +

    +
    +
    +
    +
    +
    + + +
    + +
    +
    + There are no operations, performed yet on this device. +
    +
    +
    + + + + + + + + + + +
    Operation CodeStatusRequest created at
    +
    +
    +
    +
    +
    + {{/defineZone}} +
    +
    +{{/zone}} +{{#zone "bottomJs"}} + + + + {{js "js/device-detail.js"}} + + {{js "js/load-map.js"}} +{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/view.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/view.js new file mode 100644 index 000000000..fe0d3a643 --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/view.js @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +function onRequest(context) { + var log = new Log("view.js"); + var deviceType = context.uriParams.deviceType; + var deviceId = request.getParameter("id"); + var deviceData = {}; + + if (deviceType && deviceId) { + var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; + var response = deviceModule.viewDevice(deviceType, deviceId); + if (response["status"] == "success") { + var device = response["content"]; + var viewModel = {}; + var deviceInfo = device["properties"]["DEVICE_INFO"]; + if (deviceInfo && String(deviceInfo.toString()).length > 0) { + deviceInfo = parse(stringify(deviceInfo)); + if (device["type"] == "ios") { + deviceInfo = parse(deviceInfo); + viewModel["imei"] = device["properties"]["IMEI"]; + viewModel["phoneNumber"] = deviceInfo["PhoneNumber"]; + viewModel["udid"] = deviceInfo["UDID"]; + viewModel["BatteryLevel"] = Math.round(deviceInfo["BatteryLevel"] * 100); + viewModel["DeviceCapacity"] = Math.round(deviceInfo["DeviceCapacity"] * 100) / 100; + viewModel["AvailableDeviceCapacity"] = Math. + round(deviceInfo["AvailableDeviceCapacity"] * 100) / 100; + viewModel["DeviceCapacityUsed"] = Math. + round((viewModel["DeviceCapacity"] - viewModel["AvailableDeviceCapacity"]) * 100) / 100; + viewModel["DeviceCapacityPercentage"] = Math. + round(viewModel["AvailableDeviceCapacity"] / viewModel["DeviceCapacity"] * 10000) / 100; + viewModel["location"] = { + latitude: device["properties"]["LATITUDE"], + longitude: device["properties"]["LONGITUDE"] + }; + } else if (device["type"] == "android") { + viewModel["imei"] = device["properties"]["IMEI"]; + viewModel["model"] = device["properties"]["DEVICE_MODEL"]; + viewModel["vendor"] = device["properties"]["VENDOR"]; + var osBuildDate = device["properties"]["OS_BUILD_DATE"]; + if (osBuildDate != null && osBuildDate != "0") { + var formattedDate = new Date(osBuildDate * 1000); + viewModel["os_build_date"] = formattedDate; + } + viewModel["internal_memory"] = {}; + viewModel["external_memory"] = {}; + viewModel["location"] = { + latitude: device["properties"]["LATITUDE"], + longitude: device["properties"]["LONGITUDE"] + }; + var info = {}; + var infoList = parse(deviceInfo); + if (infoList != null && infoList != undefined) { + for (var j = 0; j < infoList.length; j++) { + info[infoList[j].name] = infoList[j].value; + } + } + deviceInfo = info; + viewModel["BatteryLevel"] = deviceInfo["BATTERY_LEVEL"]; + viewModel["internal_memory"]["FreeCapacity"] = Math. + round(deviceInfo["INTERNAL_AVAILABLE_MEMORY"] * 100)/100; + viewModel["internal_memory"]["DeviceCapacityPercentage"] = Math. + round(deviceInfo["INTERNAL_AVAILABLE_MEMORY"] + / deviceInfo["INTERNAL_TOTAL_MEMORY"] * 10000) / 100; + viewModel["external_memory"]["FreeCapacity"] = Math. + round(deviceInfo["EXTERNAL_AVAILABLE_MEMORY"] * 100) / 100; + viewModel["external_memory"]["DeviceCapacityPercentage"] = Math. + round(deviceInfo["EXTERNAL_AVAILABLE_MEMORY"] + / deviceInfo["EXTERNAL_TOTAL_MEMORY"] * 10000) / 100; + } else if (device["type"] == "windows") { + viewModel["imei"] = device["properties"]["IMEI"]; + viewModel["model"] = device["properties"]["DEVICE_MODEL"]; + viewModel["vendor"] = device["properties"]["VENDOR"]; + viewModel["internal_memory"] = {}; + viewModel["external_memory"] = {}; + viewModel["location"] = { + latitude: device["properties"]["LATITUDE"], + longitude: device["properties"]["LONGITUDE"] + }; + } + device["viewModel"] = viewModel; + } + deviceData["device"] = device; + } + return deviceData; + } +} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/view.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/view.json new file mode 100644 index 000000000..787e8b1dc --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/view.json @@ -0,0 +1,4 @@ +{ + "version": "1.0.0", + "extends": "cdmf.unit.device.view" +} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/create.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/create.hbs new file mode 100644 index 000000000..6794312bd --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/create.hbs @@ -0,0 +1,288 @@ +{{#zone "content"}} +
    +
    + + + + + + + + + + +
    +

    +    +    Loading policy creation wizard . . . +

    +
    + + + +
    +
    +{{/zone}} +{{#zone "bottomJs"}} + + + + {{js "/js/policy-create.js"}} +{{/zone}} + diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/create.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/create.js new file mode 100644 index 000000000..012efb08e --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/create.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +function onRequest() { + var log = new Log("/app/units/mdm.unit.policy.create"); + + var CONF_DEVICE_TYPE_KEY = "deviceType"; + var CONF_DEVICE_TYPE_LABEL_KEY = "label"; + + var utility = require("/app/modules/utility.js")["utility"]; + var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; + + var viewModelData = {}; + viewModelData["types"] = []; + var typesListResponse = userModule.getPlatforms(); + var deviceTypes = typesListResponse["content"]["deviceTypes"]; + + if (typesListResponse["status"] == "success") { + for (var i = 0; i < deviceTypes.length; i++) { + var content = {}; + var deviceType = deviceTypes[i]; + content["name"] = deviceType; + var configs = utility.getDeviceTypeConfig(deviceType); + var deviceTypeLabel = deviceType; + if (configs && configs[CONF_DEVICE_TYPE_KEY][CONF_DEVICE_TYPE_LABEL_KEY]) { + deviceTypeLabel = configs[CONF_DEVICE_TYPE_KEY][CONF_DEVICE_TYPE_LABEL_KEY]; + } + var policyWizard = new File("/app/units/" + utility.getTenantedDeviceUnitName(deviceType, "policy-wizard")); + + log.error("/app/units/" + utility.getTenantedDeviceUnitName(deviceType, "policy-wizard")); + + if (policyWizard.isExists()) { + content["icon"] = utility.getDeviceThumb(deviceType); + content["label"] = deviceTypeLabel; + viewModelData["types"].push(content); + } + } + } + + var result = userModule.getRolesByUserStore(); + if (result["status"] == "success") { + viewModelData["roles"] = result["content"]; + } + + return viewModelData; +} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/create.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/create.json new file mode 100644 index 000000000..54fae3dcb --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/create.json @@ -0,0 +1,4 @@ +{ + "version" : "1.0.0", + "extends" : "cdmf.unit.policy.create" +} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/js/policy-create.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/public/js/policy-create.js similarity index 79% rename from components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/js/policy-create.js rename to components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/public/js/policy-create.js index fafc43318..be9a56826 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/js/policy-create.js +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/public/js/policy-create.js @@ -1,28 +1,26 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * WSO2 Inc. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except * in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ var validateStep = {}; -var skipStep = {}; var stepForwardFrom = {}; var stepBackFrom = {}; var policy = {}; var configuredOperations = []; -var currentlyEffected = {}; // Constants to define platform types available var platformTypeConstants = { @@ -32,7 +30,7 @@ var platformTypeConstants = { }; // Constants to define platform types ids. -var platformTypeIds = { +var platformIds = { "ANDROID": 1, "IOS": 3, "WINDOWS": 2 @@ -47,17 +45,11 @@ var androidOperationConstants = { "ENCRYPT_STORAGE_OPERATION": "encrypt-storage", "ENCRYPT_STORAGE_OPERATION_CODE": "ENCRYPT_STORAGE", "WIFI_OPERATION": "wifi", - "WIFI_OPERATION_CODE": "WIFI" -}; - -// Constants to define Android Operation Constants -var windowsOperationConstants = { - "PASSCODE_POLICY_OPERATION": "passcode-policy", - "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", - "CAMERA_OPERATION": "camera", - "CAMERA_OPERATION_CODE": "CAMERA", - "ENCRYPT_STORAGE_OPERATION": "encrypt-storage", - "ENCRYPT_STORAGE_OPERATION_CODE": "ENCRYPT_STORAGE" + "WIFI_OPERATION_CODE": "WIFI", + "VPN_OPERATION": "vpn", + "VPN_OPERATION_CODE": "VPN", + "APPLICATION_OPERATION":"app-restriction", + "APPLICATION_OPERATION_CODE":"APP-RESTRICTION" }; // Constants to define iOS Operation Constants @@ -81,13 +73,35 @@ var iosOperationConstants = { "APN_OPERATION": "apn", "APN_OPERATION_CODE": "APN", "CELLULAR_OPERATION": "cellular", - "CELLULAR_OPERATION_CODE": "CELLULAR" + "CELLULAR_OPERATION_CODE": "CELLULAR", + "DOMAIN": "DOMAIN", + "VPN_OPERATION_CODE": "VPN", + "VPN_OPERATION": "vpn", + "PER_APP_VPN_OPERATION_CODE": "PER_APP_VPN", + "PER_APP_VPN_OPERATION": "per-app-vpn", + "APP_TO_PER_APP_VPN_MAPPING_OPERATION_CODE": "APP_TO_PER_APP_VPN_MAPPING", + "APP_TO_PER_APP_VPN_MAPPING_OPERATION": "app-to-per-app-vpn-mapping" +}; + +// Constants to define Android Operation Constants +var windowsOperationConstants = { + "PASSCODE_POLICY_OPERATION": "passcode-policy", + "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", + "CAMERA_OPERATION": "camera", + "CAMERA_OPERATION_CODE": "CAMERA", + "ENCRYPT_STORAGE_OPERATION": "encrypt-storage", + "ENCRYPT_STORAGE_OPERATION_CODE": "ENCRYPT_STORAGE" }; /** - * Method to update the visibility (i.e. disabled or enabled view) - * of grouped input according to the values - * that they currently possess. + * @namespace $ + * The $ is just a function. + * It is actually an alias for the function called jQuery. + * For ex: $(this) means jQuery(this) and S.fn.x means jQuery.fn.x + */ + +/** + * Method to update the visibility of grouped input. * @param domElement HTML grouped-input element with class name "grouped-input" */ var updateGroupedInputVisibility = function (domElement) { @@ -108,32 +122,76 @@ var updateGroupedInputVisibility = function (domElement) { } }; -skipStep["policy-platform"] = function (policyPayloadObj) { - policy["name"] = policyPayloadObj["policyName"]; - policy["platform"] = policyPayloadObj["profile"]["deviceType"]["name"]; - policy["platformId"] = policyPayloadObj["profile"]["deviceType"]["id"]; - var userRoleInput = $("#user-roles-input"); - var ownershipInput = $("#ownership-input"); - var userInput = $("#users-input"); - var actionInput = $("#action-input"); - var policyNameInput = $("#policy-name-input"); - var policyDescriptionInput = $("#policy-description-input"); - currentlyEffected["roles"] = policyPayloadObj.roles; - currentlyEffected["users"] = policyPayloadObj.users; - userRoleInput.val(currentlyEffected["roles"]).trigger("change"); - userInput.val(currentlyEffected["users"]).trigger("change"); +var validateInline = {}; +var clearInline = {}; - if (currentlyEffected["users"].length > 0) { - $("#users-radio-btn").prop("checked", true) - $("#users-select-field").show(); - $("#user-roles-select-field").hide(); +var enableInlineError = function (inputField, errorMsg, errorSign) { + var fieldIdentifier = "#" + inputField; + var errorMsgIdentifier = "#" + inputField + " ." + errorMsg; + var errorSignIdentifier = "#" + inputField + " ." + errorSign; + + if (inputField) { + $(fieldIdentifier).addClass(" has-error has-feedback"); } - ownershipInput.val(policyPayloadObj.ownershipType); - actionInput.val(policyPayloadObj.compliance); - policyNameInput.val(policyPayloadObj["policyName"]); - policyDescriptionInput.val(policyPayloadObj["description"]); + + if (errorMsg) { + $(errorMsgIdentifier).removeClass(" hidden"); + } + + if (errorSign) { + $(errorSignIdentifier).removeClass(" hidden"); + } +}; + +var disableInlineError = function (inputField, errorMsg, errorSign) { + var fieldIdentifier = "#" + inputField; + var errorMsgIdentifier = "#" + inputField + " ." + errorMsg; + var errorSignIdentifier = "#" + inputField + " ." + errorSign; + + if (inputField) { + $(fieldIdentifier).removeClass(" has-error has-feedback"); + } + + if (errorMsg) { + $(errorMsgIdentifier).addClass(" hidden"); + } + + if (errorSign) { + $(errorSignIdentifier).addClass(" hidden"); + } +}; + +/** + *clear inline validation messages. + */ +clearInline["policy-name"] = function () { + disableInlineError("policyNameField", "nameEmpty", "nameError"); +}; + + +/** + * Validate if provided policy name is valid against RegEx configures. + */ +validateInline["policy-name"] = function () { + var policyName = $("input#policy-name-input").val(); + if (policyName && inputIsValidAgainstLength(policyName, 1, 30)) { + disableInlineError("policyNameField", "nameEmpty", "nameError"); + } else { + enableInlineError("policyNameField", "nameEmpty", "nameError"); + } +}; + +$("#policy-name-input").focus(function(){ + clearInline["policy-name"](); +}).blur(function(){ + validateInline["policy-name"](); +}); + +stepForwardFrom["policy-platform"] = function (actionButton) { + policy["platform"] = $(actionButton).data("platform"); + policy["platformId"] = $(actionButton).data("platform-type"); // updating next-page wizard title with selected platform - $("#policy-profile-page-wizard-title").text("EDIT " + policy["platform"] + " POLICY - " + policy["name"]); + $("#policy-profile-page-wizard-title").text("ADD " + policy["platform"] + " POLICY"); var deviceType = policy["platform"]; var hiddenOperationsByDeviceType = $("#hidden-operations-" + deviceType); @@ -144,23 +202,10 @@ skipStep["policy-platform"] = function (policyPayloadObj) { function () { $.template(hiddenOperationsByDeviceTypeCacheKey, hiddenOperationsByDeviceTypeSrc, function (template) { var content = template(); - // pushing profile feature input elements $(".wr-advance-operations").html(content); - // populating values and getting the list of configured features - var configuredOperations = operationModule. - populateProfile(policy["platform"], policyPayloadObj["profile"]["profileFeaturesList"]); - // updating grouped input visibility according to the populated values $(".wr-advance-operations li.grouped-input").each(function () { updateGroupedInputVisibility(this); }); - // enabling previously configured options of last update - for (var i = 0; i < configuredOperations.length; ++i) { - var configuredOperation = configuredOperations[i]; - $(".operation-data").filterByData("operation-code", configuredOperation). - find(".panel-title .wr-input-control.switch input[type=checkbox]").each(function () { - $(this).click(); - }); - } }); }, 250 // time delayed for the execution of above function, 250 milliseconds @@ -321,9 +366,162 @@ validateStep["policy-profile"] = function () { // updating validationStatusArray with validationStatus validationStatusArray.push(validationStatus); } + + if ($.inArray(androidOperationConstants["VPN_OPERATION_CODE"], configuredOperations) != -1) { + // if WIFI is configured + operation = androidOperationConstants["VPN_OPERATION"]; + // initializing continueToCheckNextInputs to true + continueToCheckNextInputs = true; + + var serverAddress = $("input#vpn-server-address").val(); + if (!serverAddress) { + validationStatus = { + "error": true, + "subErrorMsg": "Server address is required. You cannot proceed.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + + if (continueToCheckNextInputs) { + var serverPort = $("input#vpn-server-port").val(); + if (!serverPort) { + validationStatus = { + "error": true, + "subErrorMsg": "VPN server port is required. You cannot proceed.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (!$.isNumeric(serverPort)) { + validationStatus = { + "error": true, + "subErrorMsg": "VPN server port requires a number input.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (!inputIsValidAgainstRange(serverPort, 0, 65535)) { + validationStatus = { + "error": true, + "subErrorMsg": "VPN server port is not within the range " + + "of valid port numbers.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + + // at-last, if the value of continueToCheckNextInputs is still true + // this means that no error is found + if (continueToCheckNextInputs) { + validationStatus = { + "error": false, + "okFeature": operation + }; + } + + // updating validationStatusArray with validationStatus + validationStatusArray.push(validationStatus); + } + if ($.inArray(androidOperationConstants["APPLICATION_OPERATION_CODE"], configuredOperations) != -1) { + //If application restriction configured + operation = androidOperationConstants["APPLICATION_OPERATION"]; + // Initializing continueToCheckNextInputs to true + continueToCheckNextInputs = true; + + var appRestrictionType = $("#app-restriction-type").val(); + + var restrictedApplicationsGridChildInputs = "div#restricted-applications .child-input"; + + if (!appRestrictionType) { + validationStatus = { + "error": true, + "subErrorMsg": "Applications restriction type is not provided.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + + if (continueToCheckNextInputs) { + if ($(restrictedApplicationsGridChildInputs).length == 0) { + validationStatus = { + "error": true, + "subErrorMsg": "Applications are not provided in application restriction list.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + else { + childInputCount = 0; + childInputArray = []; + emptyChildInputCount = 0; + duplicatesExist = false; + // Looping through each child input + $(restrictedApplicationsGridChildInputs).each(function () { + childInputCount++; + if (childInputCount % 2 == 0) { + // If child input is of second column + childInput = $(this).val(); + childInputArray.push(childInput); + // Updating emptyChildInputCount + if (!childInput) { + // If child input field is empty + emptyChildInputCount++; + } + } + }); + // Checking for duplicates + initialChildInputArrayLength = childInputArray.length; + if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { + for (m = 0; m < (initialChildInputArrayLength - 1); m++) { + poppedChildInput = childInputArray.pop(); + for (n = 0; n < childInputArray.length; n++) { + if (poppedChildInput == childInputArray[n]) { + duplicatesExist = true; + break; + } + } + if (duplicatesExist) { + break; + } + } + } + // Updating validationStatus + if (emptyChildInputCount > 0) { + // If empty child inputs are present + validationStatus = { + "error": true, + "subErrorMsg": "One or more package names of " + + "applications are empty.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (duplicatesExist) { + // If duplicate input is present + validationStatus = { + "error": true, + "subErrorMsg": "Duplicate values exist with " + + "for package names.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + + } + } + + if (continueToCheckNextInputs) { + validationStatus = { + "error": false, + "okFeature": operation + }; + } + + // Updating validationStatusArray with validationStatus + validationStatusArray.push(validationStatus); + + } } - } - if (policy["platform"] == platformTypeConstants["WINDOWS"]) { + }if (policy["platform"] == platformTypeConstants["WINDOWS"]) { if (configuredOperations.length == 0) { // updating validationStatus validationStatus = { @@ -968,6 +1166,70 @@ validateStep["policy-profile"] = function () { // updating validationStatusArray with validationStatus validationStatusArray.push(validationStatus); } + + if ($.inArray(iosOperationConstants["VPN_OPERATION_CODE"], configuredOperations) != -1) { + // if WIFI is configured + operation = iosOperationConstants["VPN_OPERATION"]; + // initializing continueToCheckNextInputs to true + continueToCheckNextInputs = true; + + var connectionName = $("input#vpn-connection-name").val(); + if (!connectionName) { + validationStatus = { + "error": true, + "subErrorMsg": "Connection Name is required. You cannot proceed.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + // at-last, if the value of continueToCheckNextInputs is still true + // this means that no error is found + if (continueToCheckNextInputs) { + validationStatus = { + "error": false, + "okFeature": operation + }; + } + + // updating validationStatusArray with validationStatus + validationStatusArray.push(validationStatus); + } + + if ($.inArray(iosOperationConstants["PER_APP_VPN_OPERATION_CODE"], configuredOperations) != -1) { + operation = iosOperationConstants["PER_APP_VPN_OPERATION"]; + continueToCheckNextInputs = true; + + var uuid = $("input#per-app-vpn-uuid").val(); + if (!uuid) { + validationStatus = { + "error": true, + "subErrorMsg": "VPN UUID is required. You cannot proceed.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + // at-last, if the value of continueToCheckNextInputs is still true + // this means that no error is found + if (continueToCheckNextInputs) { + validationStatus = { + "error": false, + "okFeature": operation + }; + } + validationStatusArray.push(validationStatus); + } + + if ($.inArray(iosOperationConstants["APP_TO_PER_APP_VPN_MAPPING_OPERATION_CODE"], configuredOperations) != -1) { + operation = iosOperationConstants["APP_TO_PER_APP_VPN_MAPPING_OPERATION"]; + continueToCheckNextInputs = true; + if (continueToCheckNextInputs) { + validationStatus = { + "error": false, + "okFeature": operation + }; + } + validationStatusArray.push(validationStatus); + } // Validating EMAIL if ($.inArray(iosOperationConstants["EMAIL_OPERATION_CODE"], configuredOperations) != -1) { // if EMAIL is configured @@ -1033,7 +1295,7 @@ validateStep["policy-profile"] = function () { if (continueToCheckNextInputs) { var emailOutgoingMailServerPort = $("input#email-outgoing-mail-server-port").val(); - if (emailOutgoingMailServerPort && emailOutgoingMailServerPort != '') { + if (emailOutgoingMailServerPort) { if (!$.isNumeric(emailOutgoingMailServerPort)) { validationStatus = { "error": true, @@ -1221,6 +1483,154 @@ validateStep["policy-profile"] = function () { // updating validationStatusArray with validationStatus validationStatusArray.push(validationStatus); } + + // Validating Domains + if ($.inArray(iosOperationConstants["DOMAIN"], configuredOperations) != -1) { + // if DOMAIN is configured + operation = iosOperationConstants["DOMAIN"]; + + continueToCheckNextInputs = true; + + var airplayCredentialsGridChildInputs = "div#unmarked-email-domains .child-input"; + var airplayDestinationsGridChildInputs = "div#safari-web-domains .child-input"; + if ($(airplayCredentialsGridChildInputs).length == 0 && + $(airplayDestinationsGridChildInputs).length == 0) { + validationStatus = { + "error": true, + "subErrorMsg": "Manage Domains have zero configurations attached.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + + if (continueToCheckNextInputs) { + if ($(airplayCredentialsGridChildInputs).length > 0) { + childInputCount = 0; + childInputArray = []; + emptyChildInputCount = 0; + duplicatesExist = false; + // looping through each child input + $(airplayCredentialsGridChildInputs).each(function () { + childInputCount++; + if (childInputCount % 2 == 1) { + // if child input is of first column + childInput = $(this).val(); + childInputArray.push(childInput); + // updating emptyChildInputCount + if (!childInput) { + // if child input field is empty + emptyChildInputCount++; + } + } + }); + // checking for duplicates + initialChildInputArrayLength = childInputArray.length; + if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { + for (m = 0; m < (initialChildInputArrayLength - 1); m++) { + poppedChildInput = childInputArray.pop(); + for (n = 0; n < childInputArray.length; n++) { + if (poppedChildInput == childInputArray[n]) { + duplicatesExist = true; + break; + } + } + if (duplicatesExist) { + break; + } + } + } + // updating validationStatus + if (emptyChildInputCount > 0) { + // if empty child inputs are present + validationStatus = { + "error": true, + "subErrorMsg": "One or more email domains of " + + "unmarked email domains are empty.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (duplicatesExist) { + // if duplicate input is present + validationStatus = { + "error": true, + "subErrorMsg": "Duplicate values exist with " + + "email domains of unmarked email domains.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + } + + if (continueToCheckNextInputs) { + if ($(airplayDestinationsGridChildInputs).length > 0) { + childInputCount = 0; + childInputArray = []; + emptyChildInputCount = 0; + duplicatesExist = false; + // looping through each child input + $(airplayDestinationsGridChildInputs).each(function () { + childInputCount++; + if (childInputCount % 2 == 1) { + // if child input is of first column + childInput = $(this).val(); + childInputArray.push(childInput); + // updating emptyChildInputCount + if (!childInput) { + // if child input field is empty + emptyChildInputCount++; + } + } + }); + // checking for duplicates + initialChildInputArrayLength = childInputArray.length; + if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { + for (m = 0; m < (initialChildInputArrayLength - 1); m++) { + poppedChildInput = childInputArray.pop(); + for (n = 0; n < childInputArray.length; n++) { + if (poppedChildInput == childInputArray[n]) { + duplicatesExist = true; + break; + } + } + if (duplicatesExist) { + break; + } + } + } + // updating validationStatus + if (emptyChildInputCount > 0) { + // if empty child inputs are present + validationStatus = { + "error": true, + "subErrorMsg": "One or more managed safari web domains of " + + "unmarked email domains are empty.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (duplicatesExist) { + // if duplicate input is present + validationStatus = { + "error": true, + "subErrorMsg": "Duplicate values exist with " + + "managed safari web domains of unmarked email domains.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + } + + if (continueToCheckNextInputs) { + validationStatus = { + "error": false, + "okFeature": operation + }; + } + + validationStatusArray.push(validationStatus); + } + // Validating LDAP if ($.inArray(iosOperationConstants["LDAP_OPERATION_CODE"], configuredOperations) != -1) { // if LDAP is configured @@ -1424,16 +1834,16 @@ validateStep["policy-profile"] = function () { // looping through each child input $(apnConfigurationsGridChildInputs).each(function () { childInputCount++; - if (childInputCount % 5 == 1) { - // if child input is of first column - childInput = $(this).val(); - childInputArray.push(childInput); - // updating emptyChildInputCount - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } + //if (childInputCount % 5 == 1) { + // if child input is of first column + childInput = $(this).val(); + childInputArray.push(childInput); + // updating emptyChildInputCount + if (!childInput) { + // if child input field is empty + emptyChildInputCount++; } + //} }); // checking for duplicates initialChildInputArrayLength = childInputArray.length; @@ -1645,7 +2055,7 @@ validateStep["policy-profile"] = function () { stepForwardFrom["policy-profile"] = function () { policy["profile"] = operationModule.generateProfile(policy["platform"], configuredOperations); // updating next-page wizard title with selected platform - $("#policy-criteria-page-wizard-title").text("EDIT " + policy["platform"] + " POLICY - " + policy["name"]); + $("#policy-criteria-page-wizard-title").text("ADD " + policy["platform"] + " POLICY"); // updating ownership type options according to platform if (policy["platform"] == platformTypeConstants["IOS"] || policy["platform"] == platformTypeConstants["WINDOWS"]) { @@ -1657,13 +2067,32 @@ stepForwardFrom["policy-profile"] = function () { } }; +stepBackFrom["policy-profile"] = function () { + // reinitialize configuredOperations + configuredOperations = []; + // clearing already-loaded platform specific hidden-operations html content from the relevant div + // so that, the wrong content would not be shown at the first glance, in case + // the user selects a different platform + $(".wr-advance-operations").html( + "
    " + + "
    " + + "" + + "Loading Platform Features . . ." + + "
    " + + "
    " + + "
    " + ); +}; + stepForwardFrom["policy-criteria"] = function () { $("input[type='radio'].select-users-radio").each(function () { if ($(this).is(':radio')) { if ($(this).is(":checked")) { if ($(this).attr("id") == "users-radio-btn") { policy["selectedUsers"] = $("#users-input").val(); + policy["selectedUserRoles"] = null; } else if ($(this).attr("id") == "user-roles-radio-btn") { + policy["selectedUsers"] = null; policy["selectedUserRoles"] = $("#user-roles-input").val(); } } @@ -1671,8 +2100,8 @@ stepForwardFrom["policy-criteria"] = function () { }); policy["selectedNonCompliantAction"] = $("#action-input").find(":selected").data("action"); policy["selectedOwnership"] = $("#ownership-input").val(); - // updating next-page wizard title with selected platform - $("#policy-naming-page-wizard-title").text("EDIT " + policy["platform"] + " POLICY - " + policy["name"]); + //updating next-page wizard title with selected platform + $("#policy-naming-page-wizard-title").text("ADD " + policy["platform"] + " POLICY"); }; /** @@ -1759,6 +2188,10 @@ validateStep["policy-naming"] = function () { return wizardIsToBeContinued; }; +validateStep["policy-platform"] = function () { + return false; +}; + validateStep["policy-naming-publish"] = function () { var validationStatus = {}; @@ -1796,28 +2229,29 @@ stepForwardFrom["policy-naming-publish"] = function () { policy["policyName"] = $("#policy-name-input").val(); policy["description"] = $("#policy-description-input").val(); //All data is collected. Policy can now be updated. - updatePolicy(policy, "publish"); + savePolicy(policy, true, "/api/device-mgt/v1.0/policies/"); }; + stepForwardFrom["policy-naming"] = function () { policy["policyName"] = $("#policy-name-input").val(); policy["description"] = $("#policy-description-input").val(); //All data is collected. Policy can now be updated. - updatePolicy(policy, "save"); + savePolicy(policy, false, "/api/device-mgt/v1.0/policies/"); }; -var updatePolicy = function (policy, state) { +var savePolicy = function (policy, isActive, serviceURL) { var profilePayloads = []; // traverses key by key in policy["profile"] var key; for (key in policy["profile"]) { - if (policy["platformId"] == platformTypeIds["WINDOWS"] && key == windowsOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]) { + if (policy["platformId"] == platformIds["WINDOWS"] && + key == windowsOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]) { policy["profile"][key].enablePassword = true; } - if (policy["profile"].hasOwnProperty(key)) { profilePayloads.push({ "featureCode": key, - "deviceTypeId": policy["platformId"], + "deviceType": policy["platform"], "content": policy["profile"][key] }); } @@ -1825,7 +2259,8 @@ var updatePolicy = function (policy, state) { $.each(profilePayloads, function (i, item) { $.each(item.content, function (key, value) { - if (value === "" || value === undefined) { + //cannot add a true check since it will catch value = false as well + if (value === null || value === undefined || value === "") { item.content[key] = null; } }); @@ -1836,11 +2271,10 @@ var updatePolicy = function (policy, state) { "description": policy["description"], "compliance": policy["selectedNonCompliantAction"], "ownershipType": policy["selectedOwnership"], + "active": isActive, "profile": { "profileName": policy["policyName"], - "deviceType": { - "id": policy["platformId"] - }, + "deviceType": policy["platform"], "profileFeaturesList": profilePayloads } }; @@ -1854,52 +2288,17 @@ var updatePolicy = function (policy, state) { payload["roles"] = []; } - var serviceURL = "/devicemgt_admin/policies/" + getParameterByName("id"); - invokerUtil.put( + console.log(JSON.stringify(payload)); + + invokerUtil.post( serviceURL, payload, - // on success function () { - if (state == "save") { - var policyList = []; - policyList.push(getParameterByName("id")); - serviceURL = "/devicemgt_admin/policies/inactivate"; - invokerUtil.put( - serviceURL, - policyList, - // on success - function () { - $(".add-policy").addClass("hidden"); - $(".policy-message").removeClass("hidden"); - }, - // on error - function (daa) { - console.log(data); - } - ); - } else if (state == "publish") { - var policyList = []; - policyList.push(getParameterByName("id")); - serviceURL = "/devicemgt_admin/policies/activate"; - invokerUtil.put( - serviceURL, - policyList, - // on success - function () { - $(".add-policy").addClass("hidden"); - $(".policy-naming").addClass("hidden"); - $(".policy-message").removeClass("hidden"); - }, - // on error - function (data) { - console.log(data); - } - ); - } + $(".add-policy").addClass("hidden"); + $(".policy-naming").addClass("hidden"); + $(".policy-message").removeClass("hidden"); }, - // on error - function () { - + function (data) { } ); }; @@ -1913,6 +2312,56 @@ var showAdvanceOperation = function (operation, button) { $(hiddenOperation + '[data-operation="' + operation + '"]').siblings().hide(); }; + +/** + * This method will display appropriate fields based on wifi type + * @param select + */ +var changeAndroidWifiPolicy = function (select) { + slideDownPaneAgainstValueSet(select, 'control-wifi-password', ['wep', 'wpa', '802eap']); + slideDownPaneAgainstValueSet(select, 'control-wifi-eap', ['802eap']); + slideDownPaneAgainstValueSet(select, 'control-wifi-phase2', ['802eap']); + slideDownPaneAgainstValueSet(select, 'control-wifi-identity', ['802eap']); + slideDownPaneAgainstValueSet(select, 'control-wifi-anoidentity', ['802eap']); + slideDownPaneAgainstValueSet(select, 'control-wifi-cacert', ['802eap']); +}; + +/** + * This method will display appropriate fields based on wifi EAP type + * @param select + * @param superSelect + */ +var changeAndroidWifiPolicyEAP = function (select, superSelect) { + slideDownPaneAgainstValueSet(select, 'control-wifi-password', ['peap', 'ttls', 'pwd' ,'fast', 'leap']); + slideDownPaneAgainstValueSet(select, 'control-wifi-phase2', ['peap', 'ttls', 'fast']); + slideDownPaneAgainstValueSet(select, 'control-wifi-provisioning', ['fast']); + slideDownPaneAgainstValueSet(select, 'control-wifi-identity', ['peap', 'tls', 'ttls', 'pwd', 'fast', 'leap']); + slideDownPaneAgainstValueSet(select, 'control-wifi-anoidentity', ['peap', 'ttls']); + slideDownPaneAgainstValueSet(select, 'control-wifi-cacert', ['peap', 'tls', 'ttls']); + if (superSelect.value != '802eap') { + changeAndroidWifiPolicy(superSelect); + } +}; + +/** + * This method will encode the file-input and enter the values to given input files + * @param fileInput + * @param fileHiddenInput + * @param fileNameHiddenInput + */ +var base64EncodeFile = function (fileInput, fileHiddenInput, fileNameHiddenInput) { + var file = fileInput.files[0]; + if (file) { + var reader = new FileReader(); + reader.onload = function(readerEvt) { + var binaryString = readerEvt.target.result; + fileHiddenInput.value = (btoa(binaryString)); + fileNameHiddenInput.value = file.name.substr(0,file.name.lastIndexOf(".")); + }; + reader.readAsBinaryString(file); + } +}; + /** * Method to slide down a provided pane upon provided value set. * @@ -1922,6 +2371,10 @@ var showAdvanceOperation = function (operation, button) { */ var slideDownPaneAgainstValueSet = function (selectElement, paneID, valueSet) { var selectedValueOnChange = $(selectElement).find("option:selected").val(); + if ($(selectElement).is("input:checkbox")) { + selectedValueOnChange = $(selectElement).is(":checked").toString(); + } + var i, slideDownVotes = 0; for (i = 0; i < valueSet.length; i++) { if (selectedValueOnChange == valueSet[i]) { @@ -2019,23 +2472,9 @@ var showHideHelpText = function (addFormContainer) { } }; -// End of functions related to grid-input-view - -/** - * This method will return query parameter value given its name. - * @param name Query parameter name - * @returns {string} Query parameter value - */ -var getParameterByName = function (name) { - name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); - var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), - results = regex.exec(location.search); - return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); -}; - function formatRepo(user) { if (user.loading) { - return user.text + return user.text; } if (!user.username) { return; @@ -2058,25 +2497,63 @@ function formatRepoSelection(user) { return user.username || user.text; } +function promptErrorPolicyPlatform(errorMsg) { + var mainErrorMsgWrapper = "#policy-platform-main-error-msg"; + var mainErrorMsg = mainErrorMsgWrapper + " span"; + $(mainErrorMsg).text(errorMsg); + $(mainErrorMsgWrapper).removeClass("hidden"); +} + +// End of functions related to grid-input-view + + $(document).ready(function () { - - // Adding initial state of wizard-steps. - - var policyPayloadObj; - invokerUtil.get( - "/devicemgt_admin/policies/" + getParameterByName("id"), - // on success - function (data) { - data = JSON.parse(data); - policyPayloadObj = data["responseContent"]; - skipStep["policy-platform"](policyPayloadObj); + $("#users-input").select2({ + multiple: true, + tags: false, + ajax: { + url: "/emm/api/invoker/execute/", + method: "POST", + dataType: 'json', + delay: 250, + id: function (user) { + return user.username; + }, + data: function (params) { + var postData = {}; + postData.requestMethod = "GET"; + postData.requestURL = "/api/device-mgt/v1.0/users/search/usernames?filter=" + params.term; + postData.requestPayload = null; + return JSON.stringify(postData); + }, + processResults: function (data) { + var newData = []; + $.each(data, function (index, value) { + value.id = value.username; + newData.push(value); + }); + return { + results: newData + }; + }, + cache: true }, - // on error - function (data) { - console.log(data); - // should be redirected to an error page - } - ); + escapeMarkup: function (markup) { + return markup; + }, // let our custom formatter work + minimumInputLength: 1, + templateResult: formatRepo, // omitted for brevity, see the source of this page + templateSelection: formatRepoSelection // omitted for brevity, see the source of this page + }); + + $("#loading-content").remove(); + $(".policy-platform").removeClass("hidden"); + // Adding initial state of wizard-steps. + $("#policy-platform-wizard-steps").html($(".wr-steps").html()); + + $("select.select2[multiple=multiple]").select2({ + "tags": false + }); $("#users-select-field").hide(); $("#user-roles-select-field").show(); @@ -2093,7 +2570,7 @@ $(document).ready(function () { }); // Support for special input type "ANY" on user(s) & user-role(s) selection - $("#user-roles-input,#user-input").select2({ + $("#user-roles-input").select2({ "tags": false }).on("select2:select", function (e) { if (e.params.data.id == "ANY") { @@ -2102,11 +2579,6 @@ $(document).ready(function () { $("option[value=ANY]", this).prop("selected", false).parent().trigger("change"); } }); - $("#policy-profile-wizard-steps").html($(".wr-steps").html()); - - $("select.select2[multiple=multiple]").select2({ - "tags": false - }); // Maintains an array of configured features of the profile var advanceOperations = ".wr-advance-operations"; @@ -2318,4 +2790,4 @@ $(document).ready(function () { } }); -}); \ No newline at end of file +}); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/public/templates/hidden-operations-android.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/public/templates/hidden-operations-android.hbs new file mode 100644 index 000000000..9eb9fac82 --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/public/templates/hidden-operations-android.hbs @@ -0,0 +1,1273 @@ +
    + + +
    + +
    +
    + +
    + + + +
    + +
    + +
    + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    +
    +
    +
    + + + +
    +
    + +
    + +
    +
    +
    + +
    + +
    + +
    +
    +
    + +
    +
    + +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    + +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    + +
    + +
    +
    +
    +
    +
    + + + +
    +
    + +
    + + Un-check following checkbox in case you do not need the device to be encrypted. +
    +
    +
    + +
    +
    +
    +
    +
    + + + +
    +
    + +
    + Please note that * sign represents required fields of data. +
    +
    + +
    + + + +
    +
    + + +
    + + + + + + + + + +
    +
    +
    + + +
    +
    + +
    + + + + + + +
    + +
    + + + + + + + + + + + + + + +
    No:Application Name/DescriptionPackage Name
    + No entries added yet . +
    + + + + + + + + + + +
    +
    +
    +
    +
    + + + +
    +
    + +
    + Please note that * sign represents required fields of data. +
    +
    + +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + +
    + + + +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    +
    +
    + + +
    +
    \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/public/templates/hidden-operations-ios.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/public/templates/hidden-operations-ios.hbs new file mode 100644 index 000000000..ef6f2d368 --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/public/templates/hidden-operations-ios.hbs @@ -0,0 +1,4832 @@ +
    + + +
    + +
    +
    + +
    + + + +
    + +
    + +
    + +
    + +
    + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    +
    +
    +
    + + + +
    +
    + +
    +Please note that * sign represents required fields of data. +
    +
    + + +
    + + +
    +
    + +
    +
    + +
    + +
    + +
    + + + + + + + + + + + + + + +
    No:KeyValue
    + No entries added yet . +
    + + + + + + + + + + +
    +
    +
    + + +
    + + + + +
    +
    +
    + + + +
    +
    + +
    + Please note that * sign represents required fields of data. +
    +
    + + +
    + + +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + +
    No:Safari Domain
    + No entries added yet . +
    + + + + + + + + + + +
    +
    +
    +
    +
    + +
    + Please note that * sign represents required fields of data. +
    +
    + + +
    + +
    + + + + + + + + + + + + + + +
    No:App IdentifierVPN UUID
    + No entries added yet . +
    + + + + + + + + + + +
    +
    +
    +
    +
    + + + +
    +
    + +
    + + +
    + + +
    + +
    + + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + + +
    + +
    + + +
    + + + +
    + + +
    + + + +
    + + +
    + + + + + + + + + + + + + +
    No:Roaming Consortium OI
    + No entries added yet . +
    + + + + + + + + + +
    +
    + +
    + +
    + + +
    + + + + + + + + + + + + + +
    No:NAI Realm Name
    + No entries added yet . +
    + + + + + + + + + +
    +
    + +
    + +
    + + +
    + + + + + + + + + + + + + + +
    No:Mobile Country Code ( MCC )Mobile Network Code ( MNC )
    + No entries added yet . +
    + + + + + + + + + + +
    +
    +
    +
    +
    + + + +
    +
    + +
    + + + +
    + + +
    + +
    + + +
    + +
    + +
    + + +
    + +
    + +
    + + +
    + +
    + + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + + +
    + +
    + + +
    + +
    + +
    + +
    + +
    + +
    +Incoming Mail Settings : +
    + +
    + + +
    + +
    + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    +Outgoing Mail Settings : +
    + +
    + + +
    + +
    + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + +
    + +
    + + +
    + +
    +
    +
    + + + +
    +
    + +
    + + + +
    + + +
    + + + + + + + + + + + + + + +
    No:Device NamePassword
    + No entries added yet . +
    + + + + + + + + + + +
    +
    + +
    + +
    + + +
    + + + + + + + + + + + + + +
    No:Destination
    + No entries added yet . +
    + + + + + + + + + +
    +
    + +
    +
    +
    + + + +
    +
    + +
    + + + +
    + + +
    + + + + + + + + + + + + + +
    No:Email Domain
    + No entries added yet . +
    + + + + + + + + + +
    +
    + +
    + +
    + + +
    + + + + + + + + + + + + + +
    No:Safari Web Domain
    + No entries added yet . +
    + + + + + + + + + +
    +
    + +
    +
    +
    + + + +
    +
    + +
    + + + +
    + + +
    + +
    + + +
    + +
    + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + + + + + + + + + + + + + + + +
    No:DescriptionSearch BaseScope
    + No entries added yet . +
    + + + + + + + + + + + +
    +
    + +
    +
    +
    + + + +
    +
    + +
    + + + +
    + + +
    + +
    + + +
    + +
    + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    +
    +
    + + + +
    +
    + +
    + + + +
    + + +
    + +
    + + +
    + +
    + +
    + +
    + + +
    + +
    + + +
    + +
    +
    +
    + + + +
    +
    + +
    + + + +
    + + +
    + + + + + + + + + + + + + + + + + +
    No:APNUsernamePasswordProxyPort
    + No entries added yet . +
    + + + + + + + + + + + + + +
    +
    + +
    +
    +
    + + + +
    +
    + +
    + + + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + + + + + + + + + + + + + + + + + + +
    No:APNAuth.TypeUsernamePasswordProxyPort
    + No entries added yet . +
    + + + + + + + + + + + + + + +
    +
    + +
    +
    +
    + + + +
    +
    + +
    + + + +Restrictions on Device Functionality : +
    +
    +
      +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
        +
      • +
        + +
        +
      • +
      • +
        + +
        +
      • +
      • +
        + +
        +
      • +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    +
    +
    +Restrictions on Applications : +
    +
    +
      +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
        +
      • +
        + +
        +
      • +
      • +
        + +
        +
      • +
      • +
        + +
        +
      • +
      • +
        + +
        +
      • +
      • +
        + + +
        +
      • +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    • +
      + +
      +
    • +
    +
    + + + +
    +
    +
    + + +
    +
    + +
    + + + + + +
    + + +
    + + + + + + + + + + + + + + +
    No:Application Name/DescriptionPackage Name
    + No entries added yet . +
    + + + + + + + + + + +
    +
    +
    +
    +
    + +
    +
    \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/public/templates/hidden-operations-windows.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/public/templates/hidden-operations-windows.hbs new file mode 100644 index 000000000..2547a69ce --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/public/templates/hidden-operations-windows.hbs @@ -0,0 +1,566 @@ +
    + + +
    + +
    +
    + +
    + + + +
    + +
    + +
    + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    +
    +
    +
    + + + +
    +
    + +
    + + Un-check following checkbox in case you need to disable camera. +
    +
    +
    + +
    +
    +
    +
    +
    + + + +
    +
    + +
    + + Un-check following checkbox in case you need to disable storage-encryption. +
    +
    +
    + +
    +
    +
    +
    +
    + + +
    +
    + +
    + + + + + +
    + +
    + + + + + + + + + + + + + + +
    No:Application Name/DescriptionPackage Name
    + No entries added yet . +
    + + + + + + + + + + +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.hbs index 9c913a932..4f499fddd 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.hbs +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.hbs @@ -1,239 +1,233 @@ -{{! - Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - - WSO2 Inc. licenses this file to you under the Apache License, - Version 2.0 (the "License"); you may not use this file except - in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -}} +{{#zone "content"}}
    -
    +
    - + - + + + + + +
    +
    +

    EDIT POLICY

    +
    +
    +
    +
    +
    +

    Step 1: Edit current profile

    +
    + +
    +
    +
    +    + +  Loading platform features . . . +
    +
    +
    +
    + +
    +
    +
    +
    + + + +
    +
    +{{/zone}} {{#zone "bottomJs"}} - - - - {{js "js/policy-create.js"}} + + + + + + + {{js "js/edit.js"}} {{/zone}} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.js index 94f7423c1..dfb1cbe95 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.js +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.js @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * WSO2 Inc. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except * in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -19,8 +19,18 @@ function onRequest(context) { var log = new Log("policy-view-edit-unit backend js"); log.debug("calling policy-view-edit-unit"); - var userModule = require("/app/modules/user.js").userModule; - context.roles = userModule.getRoles().content; - context.users = userModule.getUsersByUsername().content; + + var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; + + var rolesResult = userModule.getRoles(); + if (rolesResult.status == "success") { + context.roles = rolesResult.content; + } + + var usersResult = userModule.getUsers(); + if (usersResult.status == "success") { + context.users = usersResult.content; + } + return context; } \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.json index fd2590129..395c829c5 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.json +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.json @@ -1,3 +1,4 @@ { - "version" : "1.0.0" + "version" : "1.0.0", + "extends" : "cdmf.unit.policy.edit" } \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/js/edit.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/js/edit.js new file mode 100644 index 000000000..89252aaf1 --- /dev/null +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/js/edit.js @@ -0,0 +1,2554 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +var validateStep = {}; +var skipStep = {}; +var stepForwardFrom = {}; +var stepBackFrom = {}; +var policy = {}; +var configuredOperations = []; +var currentlyEffected = {}; + +var validateInline = {}; +var clearInline = {}; + +var enableInlineError = function (inputField, errorMsg, errorSign) { + var fieldIdentifier = "#" + inputField; + var errorMsgIdentifier = "#" + inputField + " ." + errorMsg; + var errorSignIdentifier = "#" + inputField + " ." + errorSign; + + if (inputField) { + $(fieldIdentifier).addClass(" has-error has-feedback"); + } + + if (errorMsg) { + $(errorMsgIdentifier).removeClass(" hidden"); + } + + if (errorSign) { + $(errorSignIdentifier).removeClass(" hidden"); + } +}; + +var disableInlineError = function (inputField, errorMsg, errorSign) { + var fieldIdentifier = "#" + inputField; + var errorMsgIdentifier = "#" + inputField + " ." + errorMsg; + var errorSignIdentifier = "#" + inputField + " ." + errorSign; + + if (inputField) { + $(fieldIdentifier).removeClass(" has-error has-feedback"); + } + + if (errorMsg) { + $(errorMsgIdentifier).addClass(" hidden"); + } + + if (errorSign) { + $(errorSignIdentifier).addClass(" hidden"); + } +}; + +/** + *clear inline validation messages. + */ +clearInline["policy-name"] = function () { + disableInlineError("policy-name-field", "nameEmpty", "nameError"); +}; + + +/** + * Validate if provided policy name is valid against RegEx configures. + */ +validateInline["policy-name"] = function () { + var policyName = $("input#policy-name-input").val(); + if (policyName && inputIsValidAgainstLength(policyName, 1, 30)) { + disableInlineError("policy-name-field", "nameEmpty", "nameError"); + } else { + enableInlineError("policy-name-field", "nameEmpty", "nameError"); + } +}; + +$("#policy-name-input").focus(function(){ + clearInline["policy-name"](); +}).blur(function(){ + validateInline["policy-name"](); +}); + +// Constants to define platform types available +var platformTypeConstants = { + "ANDROID": "android", + "IOS": "ios", + "WINDOWS": "windows" +}; + +// Constants to define platform types ids. +var platformTypeIds = { + "ANDROID": 1, + "IOS": 3, + "WINDOWS": 2 +}; + +// Constants to define Android Operation Constants +var androidOperationConstants = { + "PASSCODE_POLICY_OPERATION": "passcode-policy", + "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", + "CAMERA_OPERATION": "camera", + "CAMERA_OPERATION_CODE": "CAMERA", + "ENCRYPT_STORAGE_OPERATION": "encrypt-storage", + "ENCRYPT_STORAGE_OPERATION_CODE": "ENCRYPT_STORAGE", + "WIFI_OPERATION": "wifi", + "WIFI_OPERATION_CODE": "WIFI", + "APPLICATION_OPERATION":"app-restriction", + "APPLICATION_OPERATION_CODE":"APP-RESTRICTION" +}; + +// Constants to define Android Operation Constants +var windowsOperationConstants = { + "PASSCODE_POLICY_OPERATION": "passcode-policy", + "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", + "CAMERA_OPERATION": "camera", + "CAMERA_OPERATION_CODE": "CAMERA", + "ENCRYPT_STORAGE_OPERATION": "encrypt-storage", + "ENCRYPT_STORAGE_OPERATION_CODE": "ENCRYPT_STORAGE" +}; + +// Constants to define iOS Operation Constants +var iosOperationConstants = { + "PASSCODE_POLICY_OPERATION": "passcode-policy", + "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", + "RESTRICTIONS_OPERATION": "restrictions", + "RESTRICTIONS_OPERATION_CODE": "RESTRICTION", + "WIFI_OPERATION": "wifi", + "WIFI_OPERATION_CODE": "WIFI", + "EMAIL_OPERATION": "email", + "EMAIL_OPERATION_CODE": "EMAIL", + "AIRPLAY_OPERATION": "airplay", + "AIRPLAY_OPERATION_CODE": "AIR_PLAY", + "LDAP_OPERATION": "ldap", + "LDAP_OPERATION_CODE": "LDAP", + "CALENDAR_OPERATION": "calendar", + "CALENDAR_OPERATION_CODE": "CALDAV", + "CALENDAR_SUBSCRIPTION_OPERATION": "calendar-subscription", + "CALENDAR_SUBSCRIPTION_OPERATION_CODE": "CALENDAR_SUBSCRIPTION", + "APN_OPERATION": "apn", + "APN_OPERATION_CODE": "APN", + "CELLULAR_OPERATION": "cellular", + "CELLULAR_OPERATION_CODE": "CELLULAR" +}; + +/** + * Method to update the visibility (i.e. disabled or enabled view) + * of grouped input according to the values + * that they currently possess. + * @param domElement HTML grouped-input element with class name "grouped-input" + */ +var updateGroupedInputVisibility = function (domElement) { + if ($(".parent-input:first", domElement).is(":checked")) { + if ($(".grouped-child-input:first", domElement).hasClass("disabled")) { + $(".grouped-child-input:first", domElement).removeClass("disabled"); + } + $(".child-input", domElement).each(function () { + $(this).prop('disabled', false); + }); + } else { + if (!$(".grouped-child-input:first", domElement).hasClass("disabled")) { + $(".grouped-child-input:first", domElement).addClass("disabled"); + } + $(".child-input", domElement).each(function () { + $(this).prop('disabled', true); + }); + } +}; + +skipStep["policy-platform"] = function (policyPayloadObj) { + policy["name"] = policyPayloadObj["policyName"]; + policy["platform"] = policyPayloadObj["profile"]["deviceType"]; + + var userRoleInput = $("#user-roles-input"); + var ownershipInput = $("#ownership-input"); + var userInput = $("#users-input"); + var actionInput = $("#action-input"); + var policyNameInput = $("#policy-name-input"); + var policyDescriptionInput = $("#policy-description-input"); + + currentlyEffected["roles"] = policyPayloadObj.roles; + currentlyEffected["users"] = policyPayloadObj.users; + + if (currentlyEffected["roles"].length > 0) { + $("#user-roles-radio-btn").prop("checked", true); + $("#user-roles-select-field").show(); + $("#users-select-field").hide(); + userRoleInput.val(currentlyEffected["roles"]).trigger("change"); + } else if (currentlyEffected["users"].length > 0) { + $("#users-radio-btn").prop("checked", true); + $("#users-select-field").show(); + $("#user-roles-select-field").hide(); + userInput.val(currentlyEffected["users"]).trigger("change"); + } + + ownershipInput.val(policyPayloadObj.ownershipType); + actionInput.val(policyPayloadObj.compliance); + policyNameInput.val(policyPayloadObj["policyName"]); + policyDescriptionInput.val(policyPayloadObj["description"]); + // updating next-page wizard title with selected platform + $("#policy-profile-page-wizard-title").text("EDIT " + policy["platform"] + " POLICY - " + policy["name"]); + + var deviceType = policy["platform"]; + var hiddenOperationsByDeviceType = $("#hidden-operations-" + deviceType); + var hiddenOperationsByDeviceTypeCacheKey = deviceType + "HiddenOperations"; + var hiddenOperationsByDeviceTypeSrc = hiddenOperationsByDeviceType.attr("src"); + + setTimeout( + function () { + $.template(hiddenOperationsByDeviceTypeCacheKey, hiddenOperationsByDeviceTypeSrc, function (template) { + var content = template(); + // pushing profile feature input elements + $(".wr-advance-operations").html(content); + // populating values and getting the list of configured features + var configuredOperations = operationModule. + populateProfile(policy["platform"], policyPayloadObj["profile"]["profileFeaturesList"]); + // updating grouped input visibility according to the populated values + $(".wr-advance-operations li.grouped-input").each(function () { + updateGroupedInputVisibility(this); + }); + // enabling previously configured options of last update + for (var i = 0; i < configuredOperations.length; ++i) { + var configuredOperation = configuredOperations[i]; + $(".operation-data").filterByData("operation-code", configuredOperation). + find(".panel-title .wr-input-control.switch input[type=checkbox]"). + each(function () {$(this).click();}); + } + }); + }, + 250 // time delayed for the execution of above function, 250 milliseconds + ); +}; + +/** + * Checks if provided number is valid against a range. + * + * @param numberInput Number Input + * @param min Minimum Limit + * @param max Maximum Limit + * @returns {boolean} Returns true if input is within the specified range + */ +var inputIsValidAgainstRange = function (numberInput, min, max) { + return (numberInput == min || (numberInput > min && numberInput < max) || numberInput == max); +}; + +/** + * Checks if provided input is valid against RegEx input. + * + * @param regExp Regular expression + * @param input Input string to check + * @returns {boolean} Returns true if input matches RegEx + */ +var inputIsValidAgainstRegExp = function (regExp, input) { + return regExp.test(input); +}; + +validateStep["policy-profile"] = function () { + var validationStatusArray = []; + var validationStatus; + var operation; + + // starting validation process and updating validationStatus + if (policy["platform"] == platformTypeConstants["ANDROID"]) { + if (configuredOperations.length == 0) { + // updating validationStatus + validationStatus = { + "error": true, + "mainErrorMsg": "You cannot continue. Zero configured features." + }; + // updating validationStatusArray with validationStatus + validationStatusArray.push(validationStatus); + } else { + // validating each and every configured Operation + // Validating PASSCODE_POLICY + if ($.inArray(androidOperationConstants["PASSCODE_POLICY_OPERATION_CODE"], configuredOperations) != -1) { + // if PASSCODE_POLICY is configured + operation = androidOperationConstants["PASSCODE_POLICY_OPERATION"]; + // initializing continueToCheckNextInputs to true + var continueToCheckNextInputs = true; + + // validating first input: passcodePolicyMaxPasscodeAgeInDays + var passcodePolicyMaxPasscodeAgeInDays = $("input#passcode-policy-max-passcode-age-in-days").val(); + if (passcodePolicyMaxPasscodeAgeInDays) { + if (!$.isNumeric(passcodePolicyMaxPasscodeAgeInDays)) { + validationStatus = { + "error": true, + "subErrorMsg": "Provided passcode age is not a number.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (!inputIsValidAgainstRange(passcodePolicyMaxPasscodeAgeInDays, 1, 730)) { + validationStatus = { + "error": true, + "subErrorMsg": "Provided passcode age is not with in the range of 1-to-730.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + + // validating second and last input: passcodePolicyPasscodeHistory + if (continueToCheckNextInputs) { + var passcodePolicyPasscodeHistory = $("input#passcode-policy-passcode-history").val(); + if (passcodePolicyPasscodeHistory) { + if (!$.isNumeric(passcodePolicyPasscodeHistory)) { + validationStatus = { + "error": true, + "subErrorMsg": "Provided passcode history is not a number.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (!inputIsValidAgainstRange(passcodePolicyPasscodeHistory, 1, 50)) { + validationStatus = { + "error": true, + "subErrorMsg": "Provided passcode history is not with in the range of 1-to-50.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + } + + // at-last, if the value of continueToCheckNextInputs is still true + // this means that no error is found + if (continueToCheckNextInputs) { + validationStatus = { + "error": false, + "okFeature": operation + }; + } + + // updating validationStatusArray with validationStatus + validationStatusArray.push(validationStatus); + } + // Validating CAMERA + if ($.inArray(androidOperationConstants["CAMERA_OPERATION_CODE"], configuredOperations) != -1) { + // if CAMERA is configured + operation = androidOperationConstants["CAMERA_OPERATION"]; + // updating validationStatus + validationStatus = { + "error": false, + "okFeature": operation + }; + // updating validationStatusArray with validationStatus + validationStatusArray.push(validationStatus); + } + // Validating ENCRYPT_STORAGE + if ($.inArray(androidOperationConstants["ENCRYPT_STORAGE_OPERATION_CODE"], configuredOperations) != -1) { + // if ENCRYPT_STORAGE is configured + operation = androidOperationConstants["ENCRYPT_STORAGE_OPERATION"]; + // updating validationStatus + validationStatus = { + "error": false, + "okFeature": operation + }; + // updating validationStatusArray with validationStatus + validationStatusArray.push(validationStatus); + } + // Validating WIFI + if ($.inArray(androidOperationConstants["WIFI_OPERATION_CODE"], configuredOperations) != -1) { + // if WIFI is configured + operation = androidOperationConstants["WIFI_OPERATION"]; + // initializing continueToCheckNextInputs to true + continueToCheckNextInputs = true; + + var wifiSSID = $("input#wifi-ssid").val(); + if (!wifiSSID) { + validationStatus = { + "error": true, + "subErrorMsg": "WIFI SSID is not given. You cannot proceed.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + + // at-last, if the value of continueToCheckNextInputs is still true + // this means that no error is found + if (continueToCheckNextInputs) { + validationStatus = { + "error": false, + "okFeature": operation + }; + } + + // updating validationStatusArray with validationStatus + validationStatusArray.push(validationStatus); + } + if ($.inArray(androidOperationConstants["APPLICATION_OPERATION_CODE"], configuredOperations) != -1) { + //If application restriction configured + operation = androidOperationConstants["APPLICATION_OPERATION"]; + // Initializing continueToCheckNextInputs to true + continueToCheckNextInputs = true; + + var appRestrictionType = $("#app-restriction-type").val(); + + var restrictedApplicationsGridChildInputs = "div#restricted-applications .child-input"; + + if (!appRestrictionType) { + validationStatus = { + "error": true, + "subErrorMsg": "Applications restriction type is not provided.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + + if (continueToCheckNextInputs) { + if ($(restrictedApplicationsGridChildInputs).length == 0) { + validationStatus = { + "error": true, + "subErrorMsg": "Applications are not provided in application restriction list.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + else { + childInputCount = 0; + childInputArray = []; + emptyChildInputCount = 0; + duplicatesExist = false; + // Looping through each child input + $(restrictedApplicationsGridChildInputs).each(function () { + childInputCount++; + if (childInputCount % 2 == 0) { + // If child input is of second column + childInput = $(this).val(); + childInputArray.push(childInput); + // Updating emptyChildInputCount + if (!childInput) { + // If child input field is empty + emptyChildInputCount++; + } + } + }); + // Checking for duplicates + initialChildInputArrayLength = childInputArray.length; + if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { + for (m = 0; m < (initialChildInputArrayLength - 1); m++) { + poppedChildInput = childInputArray.pop(); + for (n = 0; n < childInputArray.length; n++) { + if (poppedChildInput == childInputArray[n]) { + duplicatesExist = true; + break; + } + } + if (duplicatesExist) { + break; + } + } + } + // Updating validationStatus + if (emptyChildInputCount > 0) { + // If empty child inputs are present + validationStatus = { + "error": true, + "subErrorMsg": "One or more package names of " + + "applications are empty.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (duplicatesExist) { + // If duplicate input is present + validationStatus = { + "error": true, + "subErrorMsg": "Duplicate values exist with " + + "for package names.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + + } + } + + if (continueToCheckNextInputs) { + validationStatus = { + "error": false, + "okFeature": operation + }; + } + + // Updating validationStatusArray with validationStatus + validationStatusArray.push(validationStatus); + + + } + } + } if (policy["platform"] == platformTypeConstants["WINDOWS"]) { + if (configuredOperations.length == 0) { + // updating validationStatus + validationStatus = { + "error": true, + "mainErrorMsg": "You cannot continue. Zero configured features." + }; + // updating validationStatusArray with validationStatus + validationStatusArray.push(validationStatus); + } else { + // validating each and every configured Operation + // Validating PASSCODE_POLICY + if ($.inArray(windowsOperationConstants["PASSCODE_POLICY_OPERATION_CODE"], configuredOperations) != -1) { + // if PASSCODE_POLICY is configured + operation = windowsOperationConstants["PASSCODE_POLICY_OPERATION"]; + // initializing continueToCheckNextInputs to true + var continueToCheckNextInputs = true; + + // validating first input: passcodePolicyMaxPasscodeAgeInDays + var passcodePolicyMaxPasscodeAgeInDays = $("input#passcode-policy-max-passcode-age-in-days").val(); + if (passcodePolicyMaxPasscodeAgeInDays) { + if (!$.isNumeric(passcodePolicyMaxPasscodeAgeInDays)) { + validationStatus = { + "error": true, + "subErrorMsg": "Provided passcode age is not a number.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (!inputIsValidAgainstRange(passcodePolicyMaxPasscodeAgeInDays, 1, 730)) { + validationStatus = { + "error": true, + "subErrorMsg": "Provided passcode age is not with in the range of 1-to-730.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + + // validating second and last input: passcodePolicyPasscodeHistory + if (continueToCheckNextInputs) { + var passcodePolicyPasscodeHistory = $("input#passcode-policy-passcode-history").val(); + if (passcodePolicyPasscodeHistory) { + if (!$.isNumeric(passcodePolicyPasscodeHistory)) { + validationStatus = { + "error": true, + "subErrorMsg": "Provided passcode history is not a number.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (!inputIsValidAgainstRange(passcodePolicyPasscodeHistory, 1, 50)) { + validationStatus = { + "error": true, + "subErrorMsg": "Provided passcode history is not with in the range of 1-to-50.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + } + + // at-last, if the value of continueToCheckNextInputs is still true + // this means that no error is found + if (continueToCheckNextInputs) { + validationStatus = { + "error": false, + "okFeature": operation + }; + } + + // updating validationStatusArray with validationStatus + validationStatusArray.push(validationStatus); + } + // Validating CAMERA + if ($.inArray(windowsOperationConstants["CAMERA_OPERATION_CODE"], configuredOperations) != -1) { + // if CAMERA is configured + operation = windowsOperationConstants["CAMERA_OPERATION"]; + // updating validationStatus + validationStatus = { + "error": false, + "okFeature": operation + }; + // updating validationStatusArray with validationStatus + validationStatusArray.push(validationStatus); + } + // Validating ENCRYPT_STORAGE + if ($.inArray(windowsOperationConstants["ENCRYPT_STORAGE_OPERATION_CODE"], configuredOperations) != -1) { + // if ENCRYPT_STORAGE is configured + operation = windowsOperationConstants["ENCRYPT_STORAGE_OPERATION"]; + // updating validationStatus + validationStatus = { + "error": false, + "okFeature": operation + }; + // updating validationStatusArray with validationStatus + validationStatusArray.push(validationStatus); + } + + } + } else if (policy["platform"] == platformTypeConstants["IOS"]) { + if (configuredOperations.length == 0) { + // updating validationStatus + validationStatus = { + "error": true, + "mainErrorMsg": "You cannot continue. Zero configured features." + }; + // updating validationStatusArray with validationStatus + validationStatusArray.push(validationStatus); + } else { + // validating each and every configured Operation + // Validating PASSCODE_POLICY + if ($.inArray(iosOperationConstants["PASSCODE_POLICY_OPERATION_CODE"], configuredOperations) != -1) { + // if PASSCODE_POLICY is configured + operation = iosOperationConstants["PASSCODE_POLICY_OPERATION"]; + // initializing continueToCheckNextInputs to true + continueToCheckNextInputs = true; + + // validating first input: passcodePolicyMaxPasscodeAgeInDays + passcodePolicyMaxPasscodeAgeInDays = $("input#passcode-policy-max-passcode-age-in-days").val(); + if (passcodePolicyMaxPasscodeAgeInDays) { + if (!$.isNumeric(passcodePolicyMaxPasscodeAgeInDays)) { + validationStatus = { + "error": true, + "subErrorMsg": "Provided passcode age is not a number.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (!inputIsValidAgainstRange(passcodePolicyMaxPasscodeAgeInDays, 1, 730)) { + validationStatus = { + "error": true, + "subErrorMsg": "Provided passcode age is not with in the range of 1-to-730.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + + // validating second and last input: passcodePolicyPasscodeHistory + if (continueToCheckNextInputs) { + passcodePolicyPasscodeHistory = $("input#passcode-policy-passcode-history").val(); + if (passcodePolicyPasscodeHistory) { + if (!$.isNumeric(passcodePolicyPasscodeHistory)) { + validationStatus = { + "error": true, + "subErrorMsg": "Provided passcode history is not a number.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (!inputIsValidAgainstRange(passcodePolicyPasscodeHistory, 1, 50)) { + validationStatus = { + "error": true, + "subErrorMsg": "Provided passcode history is not with in the range of 1-to-50.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + } + + // at-last, if the value of continueToCheckNextInputs is still true + // this means that no error is found + if (continueToCheckNextInputs) { + validationStatus = { + "error": false, + "okFeature": operation + }; + } + + // updating validationStatusArray with validationStatus + validationStatusArray.push(validationStatus); + } + // Validating RESTRICTIONS + if ($.inArray(iosOperationConstants["RESTRICTIONS_OPERATION_CODE"], configuredOperations) != -1) { + // if RESTRICTION is configured + operation = iosOperationConstants["RESTRICTIONS_OPERATION"]; + // initializing continueToCheckNextInputs to true + continueToCheckNextInputs = true; + + // getting input values to be validated + var restrictionsAutonomousSingleAppModePermittedAppIDsGridChildInputs = + "div#restrictions-autonomous-single-app-mode-permitted-app-ids .child-input"; + if ($(restrictionsAutonomousSingleAppModePermittedAppIDsGridChildInputs).length > 0) { + var childInput; + var childInputArray = []; + var emptyChildInputCount = 0; + var duplicatesExist = false; + // looping through each child input + $(restrictionsAutonomousSingleAppModePermittedAppIDsGridChildInputs).each(function () { + childInput = $(this).val(); + childInputArray.push(childInput); + if (!childInput) { + // if child input field is empty + emptyChildInputCount++; + } + }); + // checking for duplicates + var initialChildInputArrayLength = childInputArray.length; + if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { + var m, poppedChildInput; + for (m = 0; m < (initialChildInputArrayLength - 1); m++) { + poppedChildInput = childInputArray.pop(); + var n; + for (n = 0; n < childInputArray.length; n++) { + if (poppedChildInput == childInputArray[n]) { + duplicatesExist = true; + break; + } + } + if (duplicatesExist) { + break; + } + } + } + // updating validationStatus + if (emptyChildInputCount > 0) { + // if empty child inputs are present + validationStatus = { + "error": true, + "subErrorMsg": "One or more permitted App ID entries in " + + "Autonomous Single App Mode are empty.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (duplicatesExist) { + validationStatus = { + "error": true, + "subErrorMsg": "Duplicate values exist with permitted App ID entries in " + + "Autonomous Single App Mode.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + + // at-last, if the value of continueToCheckNextInputs is still true + // this means that no error is found + if (continueToCheckNextInputs) { + validationStatus = { + "error": false, + "okFeature": operation + }; + } + + // updating validationStatusArray with validationStatus + validationStatusArray.push(validationStatus); + } + // Validating WIFI + if ($.inArray(iosOperationConstants["WIFI_OPERATION_CODE"], configuredOperations) != -1) { + // if WIFI is configured + operation = iosOperationConstants["WIFI_OPERATION"]; + // initializing continueToCheckNextInputs to true + continueToCheckNextInputs = true; + + // getting input values to be validated + wifiSSID = $("input#wifi-ssid").val(); + var wifiDomainName = $("input#wifi-domain-name").val(); + if (!wifiSSID && !wifiDomainName) { + validationStatus = { + "error": true, + "subErrorMsg": "Both Wi-Fi SSID and Wi-Fi Domain Name are not given. You cannot proceed.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + + if (continueToCheckNextInputs) { + // getting proxy-setup value + var wifiProxyType = $("select#wifi-proxy-type").find("option:selected").attr("value"); + if (wifiProxyType == "Manual") { + // adds up additional fields to be validated + var wifiProxyServer = $("input#wifi-proxy-server").val(); + if (!wifiProxyServer) { + validationStatus = { + "error": true, + "subErrorMsg": "Wi-Fi Proxy Server is required. You cannot proceed.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + + if (continueToCheckNextInputs) { + var wifiProxyPort = $("input#wifi-proxy-port").val(); + if (!wifiProxyPort) { + validationStatus = { + "error": true, + "subErrorMsg": "Wi-Fi Proxy Port is required. You cannot proceed.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (!$.isNumeric(wifiProxyPort)) { + validationStatus = { + "error": true, + "subErrorMsg": "Wi-Fi Proxy Port requires a number input.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (!inputIsValidAgainstRange(wifiProxyPort, 0, 65535)) { + validationStatus = { + "error": true, + "subErrorMsg": "Wi-Fi Proxy Port is not within the range " + + "of valid port numbers.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + } + } + + if (continueToCheckNextInputs) { + // getting encryption-type value + var wifiEncryptionType = $("select#wifi-encryption-type").find("option:selected").attr("value"); + if (wifiEncryptionType != "None") { + var wifiPayloadCertificateAnchorUUIDsGridChildInputs = + "div#wifi-payload-certificate-anchor-uuids .child-input"; + if ($(wifiPayloadCertificateAnchorUUIDsGridChildInputs).length > 0) { + emptyChildInputCount = 0; + childInputArray = []; + duplicatesExist = false; + // looping through each child input + $(wifiPayloadCertificateAnchorUUIDsGridChildInputs).each(function () { + childInput = $(this).val(); + childInputArray.push(childInput); + if (!childInput) { + // if child input field is empty + emptyChildInputCount++; + } + }); + // checking for duplicates + initialChildInputArrayLength = childInputArray.length; + if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { + for (m = 0; m < (initialChildInputArrayLength - 1); m++) { + poppedChildInput = childInputArray.pop(); + for (n = 0; n < childInputArray.length; n++) { + if (poppedChildInput == childInputArray[n]) { + duplicatesExist = true; + break; + } + } + if (duplicatesExist) { + break; + } + } + } + // updating validationStatus + if (emptyChildInputCount > 0) { + // if empty child inputs are present + validationStatus = { + "error": true, + "subErrorMsg": "One or more Payload Certificate " + + "Anchor UUIDs are empty.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (duplicatesExist) { + validationStatus = { + "error": true, + "subErrorMsg": "Duplicate values exist " + + "with Payload Certificate Anchor UUIDs.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + + if (continueToCheckNextInputs) { + var wifiTLSTrustedServerNamesGridChildInputs = + "div#wifi-tls-trusted-server-names .child-input"; + if ($(wifiTLSTrustedServerNamesGridChildInputs).length > 0) { + emptyChildInputCount = 0; + childInputArray = []; + duplicatesExist = false; + // looping through each child input + $(wifiTLSTrustedServerNamesGridChildInputs).each(function () { + childInput = $(this).val(); + childInputArray.push(childInput); + if (!childInput) { + // if child input field is empty + emptyChildInputCount++; + } + }); + // checking for duplicates + initialChildInputArrayLength = childInputArray.length; + if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { + for (m = 0; m < (initialChildInputArrayLength - 1); m++) { + poppedChildInput = childInputArray.pop(); + for (n = 0; n < childInputArray.length; n++) { + if (poppedChildInput == childInputArray[n]) { + duplicatesExist = true; + break; + } + } + if (duplicatesExist) { + break; + } + } + } + // updating validationStatus + if (emptyChildInputCount > 0) { + // if empty child inputs are present + validationStatus = { + "error": true, + "subErrorMsg": "One or more TLS Trusted Server Names are empty.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (duplicatesExist) { + validationStatus = { + "error": true, + "subErrorMsg": "Duplicate values exist " + + "with TLS Trusted Server Names.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + } + } + } + + if (continueToCheckNextInputs) { + var wifiRoamingConsortiumOIsGridChildInputs = "div#wifi-roaming-consortium-ois .child-input"; + if ($(wifiRoamingConsortiumOIsGridChildInputs).length > 0) { + emptyChildInputCount = 0; + var outOfAllowedLengthCount = 0; + var invalidAgainstRegExCount = 0; + childInputArray = []; + duplicatesExist = false; + // looping through each child input + $(wifiRoamingConsortiumOIsGridChildInputs).each(function () { + childInput = $(this).val(); + childInputArray.push(childInput); + if (!childInput) { + // if child input field is empty + emptyChildInputCount++; + } else if (!inputIsValidAgainstLength(childInput, 6, 6) && !inputIsValidAgainstLength(childInput, 10, 10)) { + outOfAllowedLengthCount++; + } else if (!inputIsValidAgainstRegExp(/^[a-fA-F0-9]+$/, childInput)) { + invalidAgainstRegExCount++; + } + }); + // checking for duplicates + initialChildInputArrayLength = childInputArray.length; + if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { + for (m = 0; m < (initialChildInputArrayLength - 1); m++) { + poppedChildInput = childInputArray.pop(); + for (n = 0; n < childInputArray.length; n++) { + if (poppedChildInput == childInputArray[n]) { + duplicatesExist = true; + break; + } + } + if (duplicatesExist) { + break; + } + } + } + // updating validationStatus + if (emptyChildInputCount > 0) { + // if empty child inputs are present + validationStatus = { + "error": true, + "subErrorMsg": "One or more Roaming Consortium OIs are empty.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (outOfAllowedLengthCount > 0) { + // if outOfMaxAllowedLength input is present + validationStatus = { + "error": true, + "subErrorMsg": "One or more Roaming Consortium OIs " + + "are out of allowed length.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (invalidAgainstRegExCount > 0) { + // if invalid inputs in terms of hexadecimal format are present + validationStatus = { + "error": true, + "subErrorMsg": "One or more Roaming Consortium OIs " + + "contain non-hexadecimal characters.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (duplicatesExist) { + validationStatus = { + "error": true, + "subErrorMsg": "Duplicate values exist with Roaming Consortium OIs.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + } + + if (continueToCheckNextInputs) { + var wifiNAIRealmNamesGridChildInputs = "div#wifi-nai-realm-names .child-input"; + if ($(wifiNAIRealmNamesGridChildInputs).length > 0) { + emptyChildInputCount = 0; + childInputArray = []; + duplicatesExist = false; + // looping through each child input + $(wifiNAIRealmNamesGridChildInputs).each(function () { + childInput = $(this).val(); + childInputArray.push(childInput); + if (!childInput) { + // if child input field is empty + emptyChildInputCount++; + } + }); + // checking for duplicates + initialChildInputArrayLength = childInputArray.length; + if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { + for (m = 0; m < (initialChildInputArrayLength - 1); m++) { + poppedChildInput = childInputArray.pop(); + for (n = 0; n < childInputArray.length; n++) { + if (poppedChildInput == childInputArray[n]) { + duplicatesExist = true; + break; + } + } + if (duplicatesExist) { + break; + } + } + } + // updating validationStatus + if (emptyChildInputCount > 0) { + // if empty child inputs are present + validationStatus = { + "error": true, + "subErrorMsg": "One or more NAI Realm Names are empty.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (duplicatesExist) { + validationStatus = { + "error": true, + "subErrorMsg": "Duplicate values exist with NAI Realm Names.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + } + + if (continueToCheckNextInputs) { + var wifiMCCAndMNCsGridChildInputs = "div#wifi-mcc-and-mncs .child-input"; + if ($(wifiMCCAndMNCsGridChildInputs).length > 0) { + var childInputCount = 0; + var stringPair; + emptyChildInputCount = 0; + outOfAllowedLengthCount = 0; + var notNumericInputCount = 0; + childInputArray = []; + duplicatesExist = false; + // looping through each child input + $(wifiMCCAndMNCsGridChildInputs).each(function () { + childInput = $(this).val(); + // pushing each string pair to childInputArray + childInputCount++; + if (childInputCount % 2 == 1) { + // initialize stringPair value + stringPair = ""; + // append first part of the string + stringPair += childInput; + } else { + // append second part of the string + stringPair += childInput; + childInputArray.push(stringPair); + } + // updating emptyChildInputCount & outOfAllowedLengthCount + if (!childInput) { + // if child input field is empty + emptyChildInputCount++; + } else if (!$.isNumeric(childInput)) { + notNumericInputCount++; + } else if (!inputIsValidAgainstLength(childInput, 3, 3)) { + outOfAllowedLengthCount++; + } + }); + // checking for duplicates + initialChildInputArrayLength = childInputArray.length; + if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { + for (m = 0; m < (initialChildInputArrayLength - 1); m++) { + poppedChildInput = childInputArray.pop(); + for (n = 0; n < childInputArray.length; n++) { + if (poppedChildInput == childInputArray[n]) { + duplicatesExist = true; + break; + } + } + if (duplicatesExist) { + break; + } + } + } + // updating validationStatus + if (emptyChildInputCount > 0) { + // if empty child inputs are present + validationStatus = { + "error": true, + "subErrorMsg": "One or more MCC/MNC pairs are empty.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (notNumericInputCount > 0) { + // if notNumeric input is present + validationStatus = { + "error": true, + "subErrorMsg": "One or more MCC/MNC pairs are not numeric.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (outOfAllowedLengthCount > 0) { + // if outOfAllowedLength input is present + validationStatus = { + "error": true, + "subErrorMsg": "One or more MCC/MNC pairs " + + "do not fulfill the accepted length of 6 digits.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (duplicatesExist) { + validationStatus = { + "error": true, + "subErrorMsg": "Duplicate values exist with MCC/MNC pairs.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + } + + // at-last, if the value of continueToCheckNextInputs is still true + // this means that no error is found + if (continueToCheckNextInputs) { + validationStatus = { + "error": false, + "okFeature": operation + }; + } + + // updating validationStatusArray with validationStatus + validationStatusArray.push(validationStatus); + } + // Validating EMAIL + if ($.inArray(iosOperationConstants["EMAIL_OPERATION_CODE"], configuredOperations) != -1) { + // if EMAIL is configured + operation = iosOperationConstants["EMAIL_OPERATION"]; + // initializing continueToCheckNextInputs to true + continueToCheckNextInputs = true; + + var emailAddress = $("input#email-address").val(); + if (emailAddress && !inputIsValidAgainstRegExp(/^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$/, emailAddress)) { + validationStatus = { + "error": true, + "subErrorMsg": "Email Address is not valid.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + + if (continueToCheckNextInputs) { + var emailIncomingMailServerHostname = $("input#email-incoming-mail-server-hostname").val(); + if (!emailIncomingMailServerHostname) { + validationStatus = { + "error": true, + "subErrorMsg": "Incoming Mail Server Hostname is empty. You cannot proceed.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + + if (continueToCheckNextInputs) { + var emailIncomingMailServerPort = $("input#email-incoming-mail-server-port").val(); + if (emailIncomingMailServerPort && emailIncomingMailServerPort != '') { + if (!$.isNumeric(emailIncomingMailServerPort)) { + validationStatus = { + "error": true, + "subErrorMsg": "Incoming Mail Server Port requires a number input.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (!inputIsValidAgainstRange(emailIncomingMailServerPort, 0, 65535)) { + validationStatus = { + "error": true, + "subErrorMsg": "Incoming Mail Server Port is not within the range " + + "of valid port numbers.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + } + + if (continueToCheckNextInputs) { + var emailOutgoingMailServerHostname = $("input#email-outgoing-mail-server-hostname").val(); + if (!emailOutgoingMailServerHostname) { + validationStatus = { + "error": true, + "subErrorMsg": "Outgoing Mail Server Hostname is empty. You cannot proceed.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + + if (continueToCheckNextInputs) { + var emailOutgoingMailServerPort = $("input#email-outgoing-mail-server-port").val(); + if (emailOutgoingMailServerPort && emailOutgoingMailServerPort != '') { + if (!$.isNumeric(emailOutgoingMailServerPort)) { + validationStatus = { + "error": true, + "subErrorMsg": "Outgoing Mail Server Port requires a number input.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (!inputIsValidAgainstRange(emailOutgoingMailServerPort, 0, 65535)) { + validationStatus = { + "error": true, + "subErrorMsg": "Outgoing Mail Server Port is not within the range " + + "of valid port numbers.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + } + + // at-last, if the value of continueToCheckNextInputs is still true + // this means that no error is found + if (continueToCheckNextInputs) { + validationStatus = { + "error": false, + "okFeature": operation + }; + } + + // updating validationStatusArray with validationStatus + validationStatusArray.push(validationStatus); + } + // Validating AIRPLAY + if ($.inArray(iosOperationConstants["AIRPLAY_OPERATION_CODE"], configuredOperations) != -1) { + // if AIRPLAY is configured + operation = iosOperationConstants["AIRPLAY_OPERATION"]; + // initializing continueToCheckNextInputs to true + continueToCheckNextInputs = true; + + var airplayCredentialsGridChildInputs = "div#airplay-credentials .child-input"; + var airplayDestinationsGridChildInputs = "div#airplay-destinations .child-input"; + if ($(airplayCredentialsGridChildInputs).length == 0 && + $(airplayDestinationsGridChildInputs).length == 0) { + validationStatus = { + "error": true, + "subErrorMsg": "AirPlay settings have zero configurations attached.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + + if (continueToCheckNextInputs) { + if ($(airplayCredentialsGridChildInputs).length > 0) { + childInputCount = 0; + childInputArray = []; + emptyChildInputCount = 0; + duplicatesExist = false; + // looping through each child input + $(airplayCredentialsGridChildInputs).each(function () { + childInputCount++; + if (childInputCount % 2 == 1) { + // if child input is of first column + childInput = $(this).val(); + childInputArray.push(childInput); + // updating emptyChildInputCount + if (!childInput) { + // if child input field is empty + emptyChildInputCount++; + } + } + }); + // checking for duplicates + initialChildInputArrayLength = childInputArray.length; + if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { + for (m = 0; m < (initialChildInputArrayLength - 1); m++) { + poppedChildInput = childInputArray.pop(); + for (n = 0; n < childInputArray.length; n++) { + if (poppedChildInput == childInputArray[n]) { + duplicatesExist = true; + break; + } + } + if (duplicatesExist) { + break; + } + } + } + // updating validationStatus + if (emptyChildInputCount > 0) { + // if empty child inputs are present + validationStatus = { + "error": true, + "subErrorMsg": "One or more Device Names of " + + "AirPlay Credentials are empty.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (duplicatesExist) { + // if duplicate input is present + validationStatus = { + "error": true, + "subErrorMsg": "Duplicate values exist with " + + "Device Names of AirPlay Credentials.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + } + + if (continueToCheckNextInputs) { + if ($(airplayDestinationsGridChildInputs).length > 0) { + childInputArray = []; + emptyChildInputCount = 0; + invalidAgainstRegExCount = 0; + duplicatesExist = false; + // looping through each child input + $(airplayDestinationsGridChildInputs).each(function () { + childInput = $(this).val(); + childInputArray.push(childInput); + // updating emptyChildInputCount + if (!childInput) { + // if child input field is empty + emptyChildInputCount++; + } else if (!inputIsValidAgainstRegExp( + /([a-z|A-Z|0-9][a-z|A-Z|0-9][:]){5}([a-z|A-Z|0-9][a-z|A-Z|0-9])$/, childInput)) { + // if child input field is invalid against RegEx + invalidAgainstRegExCount++ + } + }); + // checking for duplicates + initialChildInputArrayLength = childInputArray.length; + if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { + for (m = 0; m < (initialChildInputArrayLength - 1); m++) { + poppedChildInput = childInputArray.pop(); + for (n = 0; n < childInputArray.length; n++) { + if (poppedChildInput == childInputArray[n]) { + duplicatesExist = true; + break; + } + } + if (duplicatesExist) { + break; + } + } + } + // updating validationStatus + if (emptyChildInputCount > 0) { + // if empty child inputs are present + validationStatus = { + "error": true, + "subErrorMsg": "One or more AirPlay Destination fields are empty.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (invalidAgainstRegExCount > 0) { + // if invalidAgainstRegEx inputs are present + validationStatus = { + "error": true, + "subErrorMsg": "One or more AirPlay Destination fields " + + "do not fulfill expected format.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (duplicatesExist) { + // if duplicate input is present + validationStatus = { + "error": true, + "subErrorMsg": "Duplicate values exist with AirPlay Destinations.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + } + + // at-last, if the value of continueToCheckNextInputs is still true + // this means that no error is found + if (continueToCheckNextInputs) { + validationStatus = { + "error": false, + "okFeature": operation + }; + } + + // updating validationStatusArray with validationStatus + validationStatusArray.push(validationStatus); + } + // Validating LDAP + if ($.inArray(iosOperationConstants["LDAP_OPERATION_CODE"], configuredOperations) != -1) { + // if LDAP is configured + operation = iosOperationConstants["LDAP_OPERATION"]; + // initializing continueToCheckNextInputs to true + continueToCheckNextInputs = true; + + var ldapAccountHostname = $("input#ldap-account-hostname").val(); + if (!ldapAccountHostname) { + validationStatus = { + "error": true, + "subErrorMsg": "LDAP Account Hostname URL is empty. You cannot proceed.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + + if (continueToCheckNextInputs) { + var ldapSearchSettingsGridChildInputs = "div#ldap-search-settings .child-input"; + if ($(ldapSearchSettingsGridChildInputs).length > 0) { + childInputCount = 0; + childInputArray = []; + emptyChildInputCount = 0; + duplicatesExist = false; + // looping through each child input + $(ldapSearchSettingsGridChildInputs).each(function () { + childInputCount++; + if (childInputCount % 3 == 2) { + // if child input is of second column + childInput = $(this).find("option:selected").attr("value"); + stringPair = ""; + stringPair += (childInput + " "); + } else if (childInputCount % 3 == 0) { + // if child input is of third column + childInput = $(this).val(); + stringPair += childInput; + childInputArray.push(stringPair); + // updating emptyChildInputCount + if (!childInput) { + // if child input field is empty + emptyChildInputCount++; + } + } + }); + // checking for duplicates + initialChildInputArrayLength = childInputArray.length; + if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { + for (m = 0; m < (initialChildInputArrayLength - 1); m++) { + poppedChildInput = childInputArray.pop(); + for (n = 0; n < childInputArray.length; n++) { + if (poppedChildInput == childInputArray[n]) { + duplicatesExist = true; + break; + } + } + if (duplicatesExist) { + break; + } + } + } + // updating validationStatus + if (emptyChildInputCount > 0) { + // if empty child inputs are present + validationStatus = { + "error": true, + "subErrorMsg": "One or more Search Setting Scope fields are empty.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (duplicatesExist) { + // if duplicate input is present + validationStatus = { + "error": true, + "subErrorMsg": "Duplicate values exist with " + + "Search Setting Search Base and Scope pairs.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + } + + // at-last, if the value of continueToCheckNextInputs is still true + // this means that no error is found + if (continueToCheckNextInputs) { + validationStatus = { + "error": false, + "okFeature": operation + }; + } + + // updating validationStatusArray with validationStatus + validationStatusArray.push(validationStatus); + } + // Validating CALENDAR + if ($.inArray(iosOperationConstants["CALENDAR_OPERATION_CODE"], configuredOperations) != -1) { + // if CALENDAR is configured + operation = iosOperationConstants["CALENDAR_OPERATION"]; + // initializing continueToCheckNextInputs to true + continueToCheckNextInputs = true; + + var calendarAccountHostname = $("input#calendar-account-hostname").val(); + if (!calendarAccountHostname) { + validationStatus = { + "error": true, + "subErrorMsg": "Account Hostname URL is empty. You cannot proceed.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + + if (continueToCheckNextInputs) { + var calendarAccountPort = $("input#calendar-account-port").val(); + if (!calendarAccountPort) { + validationStatus = { + "error": true, + "subErrorMsg": "Account Port is empty. You cannot proceed.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (!$.isNumeric(calendarAccountPort)) { + validationStatus = { + "error": true, + "subErrorMsg": "Account Port requires a number input.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (!inputIsValidAgainstRange(calendarAccountPort, 0, 65535)) { + validationStatus = { + "error": true, + "subErrorMsg": "Account Port is not within the range " + + "of valid port numbers.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + + // at-last, if the value of continueToCheckNextInputs is still true + // this means that no error is found + if (continueToCheckNextInputs) { + validationStatus = { + "error": false, + "okFeature": operation + }; + } + + // updating validationStatusArray with validationStatus + validationStatusArray.push(validationStatus); + } + // Validating CALENDAR_SUBSCRIPTION + if ($.inArray(iosOperationConstants["CALENDAR_SUBSCRIPTION_OPERATION_CODE"], configuredOperations) != -1) { + // if CALENDAR_SUBSCRIPTION is configured + operation = iosOperationConstants["CALENDAR_SUBSCRIPTION_OPERATION"]; + // initializing continueToCheckNextInputs to true + continueToCheckNextInputs = true; + + var calendarSubscriptionHostname = $("input#calendar-subscription-hostname").val(); + if (!calendarSubscriptionHostname) { + validationStatus = { + "error": true, + "subErrorMsg": "Account Hostname URL is empty. You cannot proceed.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + + // at-last, if the value of continueToCheckNextInputs is still true + // this means that no error is found + if (continueToCheckNextInputs) { + validationStatus = { + "error": false, + "okFeature": operation + }; + } + + // updating validationStatusArray with validationStatus + validationStatusArray.push(validationStatus); + } + // Validating APN + if ($.inArray(iosOperationConstants["APN_OPERATION_CODE"], configuredOperations) != -1) { + // if APN is configured + operation = iosOperationConstants["APN_OPERATION"]; + // initializing continueToCheckNextInputs to true + continueToCheckNextInputs = true; + + var apnConfigurationsGridChildInputs = "div#apn-configurations .child-input"; + if ($(apnConfigurationsGridChildInputs).length == 0) { + validationStatus = { + "error": true, + "subErrorMsg": "APN Settings have zero configurations attached.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if ($(apnConfigurationsGridChildInputs).length > 0) { + childInputCount = 0; + childInputArray = []; + // checking empty APN field count + emptyChildInputCount = 0; + duplicatesExist = false; + // looping through each child input + $(apnConfigurationsGridChildInputs).each(function () { + childInputCount++; + if (childInputCount % 5 == 1) { + // if child input is of first column + childInput = $(this).val(); + childInputArray.push(childInput); + // updating emptyChildInputCount + if (!childInput) { + // if child input field is empty + emptyChildInputCount++; + } + } + }); + // checking for duplicates + initialChildInputArrayLength = childInputArray.length; + if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { + for (m = 0; m < (initialChildInputArrayLength - 1); m++) { + poppedChildInput = childInputArray.pop(); + for (n = 0; n < childInputArray.length; n++) { + if (poppedChildInput == childInputArray[n]) { + duplicatesExist = true; + break; + } + } + if (duplicatesExist) { + break; + } + } + } + // updating validationStatus + if (emptyChildInputCount > 0) { + // if empty child inputs are present + validationStatus = { + "error": true, + "subErrorMsg": "One or more APN fields of Configurations are empty.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (duplicatesExist) { + // if duplicate input is present + validationStatus = { + "error": true, + "subErrorMsg": "Duplicate values exist with " + + "APN fields of Configurations.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + + // at-last, if the value of continueToCheckNextInputs is still true + // this means that no error is found + if (continueToCheckNextInputs) { + validationStatus = { + "error": false, + "okFeature": operation + }; + } + + // updating validationStatusArray with validationStatus + validationStatusArray.push(validationStatus); + } + // Validating CELLULAR + if ($.inArray(iosOperationConstants["CELLULAR_OPERATION_CODE"], configuredOperations) != -1) { + // if CELLULAR is configured + operation = iosOperationConstants["CELLULAR_OPERATION"]; + // initializing continueToCheckNextInputs to true + continueToCheckNextInputs = true; + + var cellularAttachAPNName = $("input#cellular-attach-apn-name").val(); + if (!cellularAttachAPNName) { + validationStatus = { + "error": true, + "subErrorMsg": "Cellular Configuration Name is empty. You cannot proceed.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + + if (continueToCheckNextInputs) { + var cellularAPNConfigurationsGridChildInputs = "div#cellular-apn-configurations .child-input"; + if ($(cellularAPNConfigurationsGridChildInputs).length > 0) { + childInputCount = 0; + childInputArray = []; + // checking empty APN field count + emptyChildInputCount = 0; + duplicatesExist = false; + // looping through each child input + $(cellularAPNConfigurationsGridChildInputs).each(function () { + childInputCount++; + if (childInputCount % 6 == 1) { + // if child input is of first column + childInput = $(this).val(); + childInputArray.push(childInput); + // updating emptyChildInputCount + if (!childInput) { + // if child input field is empty + emptyChildInputCount++; + } + } + }); + // checking for duplicates + initialChildInputArrayLength = childInputArray.length; + if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { + for (m = 0; m < (initialChildInputArrayLength - 1); m++) { + poppedChildInput = childInputArray.pop(); + for (n = 0; n < childInputArray.length; n++) { + if (poppedChildInput == childInputArray[n]) { + duplicatesExist = true; + break; + } + } + if (duplicatesExist) { + break; + } + } + } + // updating validationStatus + if (emptyChildInputCount > 0) { + // if empty child inputs are present + validationStatus = { + "error": true, + "subErrorMsg": "One or more APN fields of APN Configurations are empty.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (duplicatesExist) { + // if duplicate input is present + validationStatus = { + "error": true, + "subErrorMsg": "Duplicate values exist with " + + "APN fields of APN Configurations.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + } + + // at-last, if the value of continueToCheckNextInputs is still true + // this means that no error is found + if (continueToCheckNextInputs) { + validationStatus = { + "error": false, + "okFeature": operation + }; + } + + // updating validationStatusArray with validationStatus + validationStatusArray.push(validationStatus); + } + } + } + // ending validation process + + // start taking specific notifying actions upon validation + var wizardIsToBeContinued; + var errorCount = 0; + var mainErrorMsgWrapper, mainErrorMsg, + subErrorMsgWrapper, subErrorMsg, subErrorIcon, subOkIcon, featureConfiguredIcon; + var i; + for (i = 0; i < validationStatusArray.length; i++) { + validationStatus = validationStatusArray[i]; + if (validationStatus["error"]) { + errorCount++; + if (validationStatus["mainErrorMsg"]) { + mainErrorMsgWrapper = "#policy-profile-main-error-msg"; + mainErrorMsg = mainErrorMsgWrapper + " span"; + $(mainErrorMsg).text(validationStatus["mainErrorMsg"]); + $(mainErrorMsgWrapper).removeClass("hidden"); + } else if (validationStatus["subErrorMsg"]) { + subErrorMsgWrapper = "#" + validationStatus["erroneousFeature"] + "-feature-error-msg"; + subErrorMsg = subErrorMsgWrapper + " span"; + subErrorIcon = "#" + validationStatus["erroneousFeature"] + "-error"; + subOkIcon = "#" + validationStatus["erroneousFeature"] + "-ok"; + featureConfiguredIcon = "#" + validationStatus["erroneousFeature"] + "-configured"; + // hiding featureConfiguredState as the first step + if (!$(featureConfiguredIcon).hasClass("hidden")) { + $(featureConfiguredIcon).addClass("hidden"); + } + // updating error state and corresponding messages + $(subErrorMsg).text(validationStatus["subErrorMsg"]); + if ($(subErrorMsgWrapper).hasClass("hidden")) { + $(subErrorMsgWrapper).removeClass("hidden"); + } + if (!$(subOkIcon).hasClass("hidden")) { + $(subOkIcon).addClass("hidden"); + } + if ($(subErrorIcon).hasClass("hidden")) { + $(subErrorIcon).removeClass("hidden"); + } + } + } else { + if (validationStatus["okFeature"]) { + subErrorMsgWrapper = "#" + validationStatus["okFeature"] + "-feature-error-msg"; + subErrorIcon = "#" + validationStatus["okFeature"] + "-error"; + subOkIcon = "#" + validationStatus["okFeature"] + "-ok"; + featureConfiguredIcon = "#" + validationStatus["okFeature"] + "-configured"; + // hiding featureConfiguredState as the first step + if (!$(featureConfiguredIcon).hasClass("hidden")) { + $(featureConfiguredIcon).addClass("hidden"); + } + // updating success state and corresponding messages + if (!$(subErrorMsgWrapper).hasClass("hidden")) { + $(subErrorMsgWrapper).addClass("hidden"); + } + if (!$(subErrorIcon).hasClass("hidden")) { + $(subErrorIcon).addClass("hidden"); + } + if ($(subOkIcon).hasClass("hidden")) { + $(subOkIcon).removeClass("hidden"); + } + } + } + } + + wizardIsToBeContinued = (errorCount == 0); + return wizardIsToBeContinued; +}; + +stepForwardFrom["policy-profile"] = function () { + policy["profile"] = operationModule.generateProfile(policy["platform"], configuredOperations); + // updating next-page wizard title with selected platform + $("#policy-criteria-page-wizard-title").text("EDIT " + policy["platform"] + " POLICY - " + policy["name"]); + // updating ownership type options according to platform + if (policy["platform"] == platformTypeConstants["IOS"] || + policy["platform"] == platformTypeConstants["WINDOWS"]) { + var ownershipTypeSelectOptions = $("#ownership-input"); + ownershipTypeSelectOptions.empty(); + ownershipTypeSelectOptions.append($(""). + attr("value", "BYOD").text("BYOD (Bring Your Own Device)")); + ownershipTypeSelectOptions.attr("disabled", true); + } +}; + +stepForwardFrom["policy-criteria"] = function () { + $("input[type='radio'].select-users-radio").each(function () { + if ($(this).is(':radio')) { + if ($(this).is(":checked")) { + if ($(this).attr("id") == "users-radio-btn") { + policy["selectedUsers"] = $("#users-input").val(); + policy["selectedUserRoles"] = null; + } else if ($(this).attr("id") == "user-roles-radio-btn") { + policy["selectedUsers"] = null; + policy["selectedUserRoles"] = $("#user-roles-input").val(); + } + } + } + }); + policy["selectedNonCompliantAction"] = $("#action-input").find(":selected").data("action"); + policy["selectedOwnership"] = $("#ownership-input").val(); + // updating next-page wizard title with selected platform + $("#policy-naming-page-wizard-title").text("EDIT " + policy["platform"] + " POLICY - " + policy["name"]); +}; + +/** + * Checks if provided input is valid against provided length range. + * + * @param input Alphanumeric or non-alphanumeric input + * @param minLength Minimum Required Length + * @param maxLength Maximum Required Length + * @returns {boolean} Returns true if input matches the provided minimum length and maximum length + */ +var inputIsValidAgainstLength = function (input, minLength, maxLength) { + var length = input.length; + return (length == minLength || (length > minLength && length < maxLength) || length == maxLength); +}; + +validateStep["policy-criteria"] = function () { + var validationStatus = {}; + var selectedAssignees; + var selectedField = "Role(s)"; + + $("input[type='radio'].select-users-radio").each(function () { + if ($(this).is(":checked")) { + if ($(this).attr("id") == "users-radio-btn") { + selectedAssignees = $("#users-input").val(); + selectedField = "User(s)"; + } else if ($(this).attr("id") == "user-roles-radio-btn") { + selectedAssignees = $("#user-roles-input").val(); + } + return false; + } + }); + + if (selectedAssignees) { + validationStatus["error"] = false; + } else { + validationStatus["error"] = true; + validationStatus["mainErrorMsg"] = selectedField + " is a required field. It cannot be empty"; + } + + var wizardIsToBeContinued; + if (validationStatus["error"]) { + wizardIsToBeContinued = false; + var mainErrorMsgWrapper = "#policy-criteria-main-error-msg"; + var mainErrorMsg = mainErrorMsgWrapper + " span"; + $(mainErrorMsg).text(validationStatus["mainErrorMsg"]); + $(mainErrorMsgWrapper).removeClass("hidden"); + } else { + wizardIsToBeContinued = true; + } + + return wizardIsToBeContinued; +}; + +validateStep["policy-naming"] = function () { + var validationStatus = {}; + + // taking values of inputs to be validated + var policyName = $("input#policy-name-input").val(); + // starting validation process and updating validationStatus + if (!policyName) { + validationStatus["error"] = true; + validationStatus["mainErrorMsg"] = "Policy name is empty. You cannot proceed."; + } else if (!inputIsValidAgainstLength(policyName, 1, 30)) { + validationStatus["error"] = true; + validationStatus["mainErrorMsg"] = + "Policy name exceeds maximum allowed length."; + } else { + validationStatus["error"] = false; + } + // ending validation process + + // start taking specific actions upon validation + var wizardIsToBeContinued; + if (validationStatus["error"]) { + wizardIsToBeContinued = false; + var mainErrorMsgWrapper = "#policy-naming-main-error-msg"; + var mainErrorMsg = mainErrorMsgWrapper + " span"; + $(mainErrorMsg).text(validationStatus["mainErrorMsg"]); + $(mainErrorMsgWrapper).removeClass("hidden"); + } else { + wizardIsToBeContinued = true; + } + + return wizardIsToBeContinued; +}; + +validateStep["policy-naming-publish"] = function () { + var validationStatus = {}; + + // taking values of inputs to be validated + var policyName = $("input#policy-name-input").val(); + // starting validation process and updating validationStatus + if (!policyName) { + validationStatus["error"] = true; + validationStatus["mainErrorMsg"] = "Policy name is empty. You cannot proceed."; + } else if (!inputIsValidAgainstLength(policyName, 1, 30)) { + validationStatus["error"] = true; + validationStatus["mainErrorMsg"] = + "Policy name exceeds maximum allowed length."; + } else { + validationStatus["error"] = false; + } + // ending validation process + + // start taking specific actions upon validation + var wizardIsToBeContinued; + if (validationStatus["error"]) { + wizardIsToBeContinued = false; + var mainErrorMsgWrapper = "#policy-naming-main-error-msg"; + var mainErrorMsg = mainErrorMsgWrapper + " span"; + $(mainErrorMsg).text(validationStatus["mainErrorMsg"]); + $(mainErrorMsgWrapper).removeClass("hidden"); + } else { + wizardIsToBeContinued = true; + } + + return wizardIsToBeContinued; +}; + +stepForwardFrom["policy-naming-publish"] = function () { + policy["policyName"] = $("#policy-name-input").val(); + policy["description"] = $("#policy-description-input").val(); + //All data is collected. Policy can now be updated. + updatePolicy(policy, "publish"); +}; +stepForwardFrom["policy-naming"] = function () { + policy["policyName"] = $("#policy-name-input").val(); + policy["description"] = $("#policy-description-input").val(); + //All data is collected. Policy can now be updated. + updatePolicy(policy, "save"); +}; + +var updatePolicy = function (policy, state) { + var profilePayloads = []; + // traverses key by key in policy["profile"] + var key; + for (key in policy["profile"]) { + if (policy["platform"] == platformTypeConstants["WINDOWS"] && + key == windowsOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]) { + policy["profile"][windowsOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]].enablePassword = true; + } + + if (policy["profile"].hasOwnProperty(key)) { + profilePayloads.push({ + "featureCode": key, + "deviceType": policy["platform"], + "content": policy["profile"][key] + }); + } + } + + $.each(profilePayloads, function (i, item) { + $.each(item.content, function (key, value) { + if (value === null || value === undefined || value === "") { + item.content[key] = null; + } + }); + }); + + var payload = { + "policyName": policy["policyName"], + "description": policy["description"], + "compliance": policy["selectedNonCompliantAction"], + "ownershipType": policy["selectedOwnership"], + "profile": { + "profileName": policy["policyName"], + "deviceType": policy["platform"], + "profileFeaturesList": profilePayloads + } + }; + + if (policy["selectedUsers"]) { + payload["users"] = policy["selectedUsers"]; + payload["roles"] = []; + } else if (policy["selectedUserRoles"]) { + payload["users"] = []; + payload["roles"] = policy["selectedUserRoles"]; + } else { + payload["users"] = []; + payload["roles"] = []; + } + + var serviceURL = "/api/device-mgt/v1.0/policies/" + getParameterByName("id"); + invokerUtil.put( + serviceURL, + payload, + // on success + function (data, textStatus, jqXHR) { + if (jqXHR.status == 200) { + var policyList = []; + policyList.push(getParameterByName("id")); + if (state == "save") { + serviceURL = "/api/device-mgt/v1.0/policies/deactivate-policy"; + invokerUtil.put( + serviceURL, + policyList, + // on success + function (data, textStatus, jqXHR) { + if (jqXHR.status == 200) { + $(".add-policy").addClass("hidden"); + $(".policy-message").removeClass("hidden"); + } + }, + // on error + function (jqXHR) { + console.log("error in saving policy. Received error code : " + jqXHR.status); + } + ); + } else if (state == "publish") { + serviceURL = "/api/device-mgt/v1.0/policies/activate-policy"; + invokerUtil.put( + serviceURL, + policyList, + // on success + function (data, textStatus, jqXHR) { + if (jqXHR.status == 200) { + $(".add-policy").addClass("hidden"); + $(".policy-naming").addClass("hidden"); + $(".policy-message").removeClass("hidden"); + } + }, + // on error + function (jqXHR) { + console.log("error in publishing policy. Received error code : " + jqXHR.status); + } + ); + } + } + }, + // on error + function (jqXHR) { + console.log("error in updating policy. Received error code : " + jqXHR.status); + } + ); +}; + +// Start of HTML embedded invoke methods +var showAdvanceOperation = function (operation, button) { + $(button).addClass('selected'); + $(button).siblings().removeClass('selected'); + var hiddenOperation = ".wr-hidden-operations-content > div"; + $(hiddenOperation + '[data-operation="' + operation + '"]').show(); + $(hiddenOperation + '[data-operation="' + operation + '"]').siblings().hide(); +}; + +/** + * This method will display appropriate fields based on wifi type + * @param {object} wifi type select object + */ +var changeAndroidWifiPolicy = function (select) { + slideDownPaneAgainstValueSet(select, 'control-wifi-password', ['wep', 'wpa', '802eap']); + slideDownPaneAgainstValueSet(select, 'control-wifi-eap', ['802eap']); + slideDownPaneAgainstValueSet(select, 'control-wifi-phase2', ['802eap']); + slideDownPaneAgainstValueSet(select, 'control-wifi-identity', ['802eap']); + slideDownPaneAgainstValueSet(select, 'control-wifi-anoidentity', ['802eap']); + slideDownPaneAgainstValueSet(select, 'control-wifi-cacert', ['802eap']); +} + +/** + * This method will display appropriate fields based on wifi EAP type + * @param {object} wifi eap select object + * @param {object} wifi type select object + */ +var changeAndroidWifiPolicyEAP = function (select, superSelect) { + slideDownPaneAgainstValueSet(select, 'control-wifi-password', ['peap', 'ttls', 'pwd' ,'fast', 'leap']); + slideDownPaneAgainstValueSet(select, 'control-wifi-phase2', ['peap', 'ttls', 'fast']); + slideDownPaneAgainstValueSet(select, 'control-wifi-provisioning', ['fast']); + slideDownPaneAgainstValueSet(select, 'control-wifi-identity', ['peap', 'tls', 'ttls', 'pwd', 'fast', 'leap']); + slideDownPaneAgainstValueSet(select, 'control-wifi-anoidentity', ['peap', 'ttls']); + slideDownPaneAgainstValueSet(select, 'control-wifi-cacert', ['peap', 'tls', 'ttls']); + if(superSelect.value != '802eap'){ + changeAndroidWifiPolicy(superSelect); + } +} + +/** + * This method will encode the fileinput and enter the values to given input files + * @param {object} fileInput + * @param {object} fileHiddenInput + * @param {object} fileNameHiddenInput + */ +var base64EncodeFile = function (fileInput, fileHiddenInput, fileNameHiddenInput) { + var file = fileInput.files[0]; + if (file) { + var reader = new FileReader(); + reader.onload = function(readerEvt) { + var binaryString = readerEvt.target.result; + fileHiddenInput.value = (btoa(binaryString)); + fileNameHiddenInput.value = file.name.substr(0,file.name.lastIndexOf(".")); + }; + reader.readAsBinaryString(file); + } +} + + + +/** + * Method to slide down a provided pane upon provided value set. + * + * @param selectElement Select HTML Element to consider + * @param paneID HTML ID of div element to slide down + * @param valueSet Applicable Value Set + */ +var slideDownPaneAgainstValueSet = function (selectElement, paneID, valueSet) { + var selectedValueOnChange = $(selectElement).find("option:selected").val(); + if ($(selectElement).is("input:checkbox")) { + selectedValueOnChange = $(selectElement).is(":checked").toString(); + } + var i, slideDownVotes = 0; + for (i = 0; i < valueSet.length; i++) { + if (selectedValueOnChange == valueSet[i]) { + slideDownVotes++; + } + } + var paneSelector = "#" + paneID; + if (slideDownVotes > 0) { + if (!$(paneSelector).hasClass("expanded")) { + $(paneSelector).addClass("expanded"); + } + $(paneSelector).slideDown(); + } else { + if ($(paneSelector).hasClass("expanded")) { + $(paneSelector).removeClass("expanded"); + } + $(paneSelector).slideUp(); + /** now follows the code to reinitialize all inputs of the slidable pane */ + // reinitializing input fields into the defaults + $(paneSelector + " input").each( + function () { + if ($(this).is("input:text")) { + $(this).val($(this).data("default")); + } else if ($(this).is("input:password")) { + $(this).val(""); + } else if ($(this).is("input:checkbox")) { + $(this).prop("checked", $(this).data("default")); + // if this checkbox is the parent input of a grouped-input + if ($(this).hasClass("parent-input")) { + var groupedInput = $(this).parent().parent().parent(); + updateGroupedInputVisibility(groupedInput); + } + } + } + ); + // reinitializing select fields into the defaults + $(paneSelector + " select").each( + function () { + var defaultOption = $(this).data("default"); + $("option:eq(" + defaultOption + ")", this).prop("selected", "selected"); + } + ); + // collapsing expanded-panes (upon the selection of html-select-options) if any + $(paneSelector + " .expanded").each( + function () { + if ($(this).hasClass("expanded")) { + $(this).removeClass("expanded"); + } + $(this).slideUp(); + } + ); + // removing all entries of grid-input elements if exist + $(paneSelector + " .grouped-array-input").each( + function () { + var gridInputs = $(this).find("[data-add-form-clone]"); + if (gridInputs.length > 0) { + gridInputs.remove(); + } + var helpTexts = $(this).find("[data-help-text=add-form]"); + if (helpTexts.length > 0) { + helpTexts.show(); + } + } + ); + } +}; +// End of HTML embedded invoke methods + + +// Start of functions related to grid-input-view + +/** + * Method to set count id to cloned elements. + * @param {object} addFormContainer + */ +var setId = function (addFormContainer) { + $(addFormContainer).find("[data-add-form-clone]").each(function (i) { + $(this).attr("id", $(this).attr("data-add-form-clone").slice(1) + "-" + (i + 1)); + if ($(this).find(".index").length > 0) { + $(this).find(".index").html(i + 1); + } + }); +}; + +/** + * Method to set count id to cloned elements. + * @param {object} addFormContainer + */ +var showHideHelpText = function (addFormContainer) { + var helpText = "[data-help-text=add-form]"; + if ($(addFormContainer).find("[data-add-form-clone]").length > 0) { + $(addFormContainer).find(helpText).hide(); + } else { + $(addFormContainer).find(helpText).show(); + } +}; + +// End of functions related to grid-input-view + +/** + * This method will return query parameter value given its name. + * @param name Query parameter name + * @returns {string} Query parameter value + */ +var getParameterByName = function (name) { + name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); + var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), + results = regex.exec(location.search); + return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); +}; + +//function formatRepo(user) { +// if (user.loading) { +// return user.text +// } +// if (!user.username) { +// return; +// } +// var markup = '
    ' + +// '
    ' + +// '
    ' + +// '
    ' + user.username + '
    '; +// if (user.firstname) { +// markup += '
    ' + user.firstname + '
    '; +// } +// if (user.emailAddress) { +// markup += '
    ' + user.emailAddress + '
    '; +// } +// markup += '
    '; +// return markup; +//} +// +//function formatRepoSelection(user) { +// return user.username || user.text; +//} + +$(document).ready(function () { + // Adding initial state of wizard-steps. + invokerUtil.get( + "/api/device-mgt/v1.0/policies/" + getParameterByName("id"), + // on success + function (data, textStatus, jqXHR) { + if (jqXHR.status == 200 && data) { + var policy = JSON.parse(data); + skipStep["policy-platform"](policy); + } + }, + // on error + function (jqXHR) { + console.log(jqXHR); + // should be redirected to an error page + } + ); + + $("input[type='radio'].select-users-radio").change(function () { + if ($("#users-radio-btn").is(":checked")) { + $("#user-roles-select-field").hide(); + $("#users-select-field").show(); + } + if ($("#user-roles-radio-btn").is(":checked")) { + $("#users-select-field").hide(); + $("#user-roles-select-field").show(); + } + }); + + // Support for special input type "ANY" on user(s) & user-role(s) selection + $("#user-roles-input").select2({ + "tags": false + }).on("select2:select", function (e) { + if (e.params.data.id == "ANY") { + $(this).val("ANY").trigger("change"); + } else { + $("option[value=ANY]", this).prop("selected", false).parent().trigger("change"); + } + }); + + $("#users-input").select2({ + "tags": false + }).on("select2:select", function (e) { + if (e.params.data.id == "ANY") { + $(this).val("ANY").trigger("change"); + } else { + $("option[value=ANY]", this).prop("selected", false).parent().trigger("change"); + } + }); + + $("#policy-profile-wizard-steps").html($(".wr-steps").html()); + + // Maintains an array of configured features of the profile + var advanceOperations = ".wr-advance-operations"; + $(advanceOperations).on("click", ".wr-input-control.switch", function (event) { + var operationCode = $(this).parents(".operation-data").data("operation-code"); + var operation = $(this).parents(".operation-data").data("operation"); + var operationDataWrapper = $(this).data("target"); + // prevents event bubbling by figuring out what element it's being called from. + if (event.target.tagName == "INPUT") { + var featureConfiguredIcon; + if ($("input[type='checkbox']", this).is(":checked")) { + configuredOperations.push(operationCode); + // when a feature is enabled, if "zero-configured-features" msg is available, hide that. + var zeroConfiguredOperationsErrorMsg = "#policy-profile-main-error-msg"; + if (!$(zeroConfiguredOperationsErrorMsg).hasClass("hidden")) { + $(zeroConfiguredOperationsErrorMsg).addClass("hidden"); + } + // add configured-state-icon to the feature + featureConfiguredIcon = "#" + operation + "-configured"; + if ($(featureConfiguredIcon).hasClass("hidden")) { + $(featureConfiguredIcon).removeClass("hidden"); + } + } else { + //splicing the array if operation is present. + var index = $.inArray(operationCode, configuredOperations); + if (index != -1) { + configuredOperations.splice(index, 1); + } + // when a feature is disabled, clearing all its current configured, error or success states + var subErrorMsgWrapper = "#" + operation + "-feature-error-msg"; + var subErrorIcon = "#" + operation + "-error"; + var subOkIcon = "#" + operation + "-ok"; + featureConfiguredIcon = "#" + operation + "-configured"; + + if (!$(subErrorMsgWrapper).hasClass("hidden")) { + $(subErrorMsgWrapper).addClass("hidden"); + } + if (!$(subErrorIcon).hasClass("hidden")) { + $(subErrorIcon).addClass("hidden"); + } + if (!$(subOkIcon).hasClass("hidden")) { + $(subOkIcon).addClass("hidden"); + } + if (!$(featureConfiguredIcon).hasClass("hidden")) { + $(featureConfiguredIcon).addClass("hidden"); + } + // reinitializing input fields into the defaults + $(operationDataWrapper + " input").each( + function () { + if ($(this).is("input:text")) { + $(this).val($(this).data("default")); + } else if ($(this).is("input:password")) { + $(this).val(""); + } else if ($(this).is("input:checkbox")) { + $(this).prop("checked", $(this).data("default")); + // if this checkbox is the parent input of a grouped-input + if ($(this).hasClass("parent-input")) { + var groupedInput = $(this).parent().parent().parent(); + updateGroupedInputVisibility(groupedInput); + } + } + } + ); + // reinitializing select fields into the defaults + $(operationDataWrapper + " select").each( + function () { + var defaultOption = $(this).data("default"); + $("option:eq(" + defaultOption + ")", this).prop("selected", "selected"); + } + ); + // collapsing expanded-panes (upon the selection of html-select-options) if any + $(operationDataWrapper + " .expanded").each( + function () { + if ($(this).hasClass("expanded")) { + $(this).removeClass("expanded"); + } + $(this).slideUp(); + } + ); + // removing all entries of grid-input elements if exist + $(operationDataWrapper + " .grouped-array-input").each( + function () { + var gridInputs = $(this).find("[data-add-form-clone]"); + if (gridInputs.length > 0) { + gridInputs.remove(); + } + var helpTexts = $(this).find("[data-help-text=add-form]"); + if (helpTexts.length > 0) { + helpTexts.show(); + } + } + ); + } + } + }); + + // adding support for cloning multiple profiles per feature with cloneable class definitions + $(advanceOperations).on("click", ".multi-view.add.enabled", function () { + // get a copy of .cloneable and create new .cloned div element + var cloned = "

    " + $(".cloneable", $(this).parent().parent()).html() + "
    "; + // append newly created .cloned div element to panel-body + $(this).parent().parent().append(cloned); + // enable remove action of newly cloned div element + $(".cloned", $(this).parent().parent()).each( + function () { + if ($(".multi-view.remove", this).hasClass("disabled")) { + $(".multi-view.remove", this).removeClass("disabled"); + } + if (!$(".multi-view.remove", this).hasClass("enabled")) { + $(".multi-view.remove", this).addClass("enabled"); + } + } + ); + }); + + $(advanceOperations).on("click", ".multi-view.remove.enabled", function () { + $(this).parent().remove(); + }); + + // enabling or disabling grouped-input based on the status of a parent check-box + $(advanceOperations).on("click", ".grouped-input", function () { + updateGroupedInputVisibility(this); + }); + + // add form entry click function for grid inputs + $(advanceOperations).on("click", "[data-click-event=add-form]", function () { + var addFormContainer = $("[data-add-form-container=" + $(this).attr("href") + "]"); + var clonedForm = $("[data-add-form=" + $(this).attr("href") + "]").clone(). + find("[data-add-form-element=clone]").attr("data-add-form-clone", $(this).attr("href")); + + // adding class .child-input to capture text-input-array-values + $("input, select", clonedForm).addClass("child-input"); + + $(addFormContainer).append(clonedForm); + setId(addFormContainer); + showHideHelpText(addFormContainer); + }); + + // remove form entry click function for grid inputs + $(advanceOperations).on("click", "[data-click-event=remove-form]", function () { + var addFormContainer = $("[data-add-form-container=" + $(this).attr("href") + "]"); + + $(this).closest("[data-add-form-element=clone]").remove(); + setId(addFormContainer); + showHideHelpText(addFormContainer); + }); + + $(".wizard-stepper").click(function () { + // button clicked here can be either a continue button or a back button. + var currentStep = $(this).data("current"); + var validationIsRequired = $(this).data("validate"); + var wizardIsToBeContinued; + + if (validationIsRequired) { + wizardIsToBeContinued = validateStep[currentStep](); + } else { + wizardIsToBeContinued = true; + } + + if (wizardIsToBeContinued) { + // When moving back and forth, following code segment will + // remove if there are any visible error-messages. + var errorMsgWrappers = ".alert.alert-danger"; + $(errorMsgWrappers).each( + function () { + if (!$(this).hasClass("hidden")) { + $(this).addClass("hidden"); + } + } + ); + + var nextStep = $(this).data("next"); + var isBackBtn = $(this).data("is-back-btn"); + + // if current button is a continuation... + if (!isBackBtn) { + // initiate stepForwardFrom[*] functions to gather form data. + if (stepForwardFrom[currentStep]) { + stepForwardFrom[currentStep](this); + } + } else { + // initiate stepBackFrom[*] functions to rollback. + if (stepBackFrom[currentStep]) { + stepBackFrom[currentStep](); + } + } + + // following step occurs only at the last stage of the wizard. + if (!nextStep) { + window.location.href = $(this).data("direct"); + } + + // updating next wizard step as current. + $(".itm-wiz").each(function () { + var step = $(this).data("step"); + if (step == nextStep) { + $(this).addClass("itm-wiz-current"); + } else { + $(this).removeClass("itm-wiz-current"); + } + }); + + // adding next update of wizard-steps. + $("#" + nextStep + "-wizard-steps").html($(".wr-steps").html()); + + // hiding current section of the wizard and showing next section. + $("." + currentStep).addClass("hidden"); + $("." + nextStep).removeClass("hidden"); + } + }); + +}); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/templates/hidden-operations-android.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/templates/hidden-operations-android.hbs index d82da3c0f..4736d8ec3 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/templates/hidden-operations-android.hbs +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/templates/hidden-operations-android.hbs @@ -1,457 +1,1225 @@
    -
    - + + Wi-Fi Settings + + + + + + + + + Virtual Private Network + + + + + + + + + Work-Profile Configurations + + + + -
    - -
    -
    - + +
    + +
    +
    + +
    - + -
    - +
    -
    - +
    -
    - + +
    -
    - + +
    -
    - + +
    -
    - + +
    -
    -
    + +
    - +
    +
    + - -
    -
    - -
    - - Un-check following checkbox in case you need to disable camera. -
    -
    -
    - +
    +
    + Below restrictions will be applied on devices with Android version 5.0 Lollipop onwards only + +

    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    - -
    -
    - +
    +
    + + + +
    +
    + +
    + + Un-check following checkbox in case you do not need the device to be encrypted. +
    +
    +
    + -
    -
    -
    +
    +
    - +
    +
    + - -
    -
    - + + +
    +
    + +
    + + + + + +
    + +
    + + + + + + + + + + + + + + +
    No:Application Name/DescriptionPackage Name
    + No entries added yet . +
    + + + + + + + + + +
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    +
    + + + +
    +
    + +
    + Please note that * sign represents required fields of data. +
    +
    + +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + +
    + + + + +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/templates/hidden-operations-ios.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/templates/hidden-operations-ios.hbs index aec18bda8..612b913d6 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/templates/hidden-operations-ios.hbs +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/templates/hidden-operations-ios.hbs @@ -1,2923 +1,4679 @@
    -
    - + + +
    + +
    +
    + +
    + + -
    - -
    -
    - -
    - - - -
    - +
    -
    - +
    -
    - +
    -
    - + +
    -
    - + +
    -
    - + +
    -
    - + +
    -
    - + +
    -
    - + +
    -
    -
    + + +
    +
    +
    +
    + + + +
    +
    + +
    +Please note that * sign represents required fields of data. +
    +
    + + +
    + + +
    +
    + +
    +
    + +
    + +
    + +
    + + + + + + + + + + + + + + +
    No:KeyValue
    + No entries added yet . +
    + + + + + + + + + + +
    +
    +
    + + +
    + + + + +
    +
    +
    + + + +
    +
    + +
    + Please note that * sign represents required fields of data. +
    +
    + + +
    + + +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + +
    No:Safari Domain
    + No entries added yet . +
    + + + + + + + + + +
    - +
    +
    +
    + +
    + Please note that * sign represents required fields of data. +
    +
    - -
    -
    - -
    - - -
    - +
    + + + + + + + + + + + + + + +
    No:App IdentifierVPN UUID
    + No entries added yet . +
    + + + + + + + + + + +
    +
    +
    +
    +
    + -
    -