From 6ad6bbbdc0f91b3c9674019e716ec63227c6e491 Mon Sep 17 00:00:00 2001 From: Milan Perera Date: Thu, 8 Dec 2016 20:41:44 +0530 Subject: [PATCH 01/28] Commiting permission-scope mapping improvements --- .../service/impl/AndroidSenseService.java | 10 +++++----- .../mgt/iot/arduino/service/impl/ArduinoService.java | 8 ++++---- .../raspberrypi/service/impl/RaspberryPiService.java | 6 +++--- .../service/impl/VirtualFireAlarmService.java | 6 +++--- .../api/services/DeviceManagementAdminService.java | 12 ++++++------ .../windows/api/services/authbst/BSTProvider.java | 3 +-- 6 files changed, 22 insertions(+), 23 deletions(-) diff --git a/components/device-types/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/device-types/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 2c60c0b4df..6a215bf7c5 100644 --- a/components/device-types/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/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseService.java @@ -54,7 +54,7 @@ public interface AndroidSenseService { */ @Path("device/{deviceId}/words") @POST - @Scope(key = "device:android-sense:enroll", name = "", description = "") + //@Scope(key = "device:android-sense:enroll", name = "", description = "") Response sendKeyWords(@PathParam("deviceId") String deviceId, @QueryParam("keywords") String keywords); /** @@ -65,12 +65,12 @@ public interface AndroidSenseService { */ @Path("device/{deviceId}/words/threshold") @POST - @Scope(key = "device:android-sense:enroll", name = "", description = "") + //@Scope(key = "device:android-sense:enroll", name = "", description = "") Response sendThreshold(@PathParam("deviceId") String deviceId, @QueryParam("threshold") String threshold); @Path("device/{deviceId}/words") @DELETE - @Scope(key = "device:android-sense:enroll", name = "", description = "") + //@Scope(key = "device:android-sense:enroll", name = "", description = "") Response removeKeyWords(@PathParam("deviceId") String deviceId, @QueryParam("words") String words); /** @@ -79,7 +79,7 @@ public interface AndroidSenseService { @Path("stats/{deviceId}/sensors/{sensorName}") @GET @Consumes("application/json") - @Scope(key = "device:android-sense:enroll", name = "", description = "") + //@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); @@ -89,7 +89,7 @@ public interface AndroidSenseService { */ @Path("device/{device_id}/register") @POST - @Scope(key = "device:android-sense:enroll", name = "", description = "") + //@Scope(key = "device:android-sense:enroll", name = "", description = "") Response register(@PathParam("device_id") String deviceId, @QueryParam("deviceName") String deviceName); } diff --git a/components/device-types/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/device-types/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 cd0ef710b5..1dd0500134 100644 --- a/components/device-types/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/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoService.java @@ -48,12 +48,12 @@ public interface ArduinoService { @Path("device/{deviceId}/bulb") @POST - @Scope(key = "device:arduino:enroll", name = "", description = "") + //@Scope(key = "device:arduino:enroll", name = "", description = "") Response switchBulb(@PathParam("deviceId") String deviceId, @QueryParam("state") String state); @Path("device/{deviceId}/controls") @GET - @Scope(key = "device:arduino:enroll", name = "", description = "") + //@Scope(key = "device:arduino:enroll", name = "", description = "") Response readControls(@PathParam("deviceId") String deviceId); /** @@ -63,7 +63,7 @@ public interface ArduinoService { @GET @Consumes("application/json") @Produces("application/json") - @Scope(key = "device:arduino:enroll", name = "", description = "") + //@Scope(key = "device:arduino:enroll", name = "", description = "") Response getArduinoTemperatureStats(@PathParam("deviceId") String deviceId, @QueryParam("from") long from, @QueryParam("to") long to); @@ -73,7 +73,7 @@ public interface ArduinoService { @Path("device/download") @GET @Produces("application/octet-stream") - @Scope(key = "device:arduino:enroll", name = "", description = "") + //@Scope(key = "device:arduino:enroll", name = "", description = "") Response downloadSketch(@QueryParam("deviceName") String customDeviceName); } diff --git a/components/device-types/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/device-types/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 812c584394..816f3e6b9a 100644 --- a/components/device-types/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/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiService.java @@ -48,7 +48,7 @@ public interface RaspberryPiService { @Path("device/{deviceId}/bulb") @POST - @Scope(key = "device:raspberrypi:enroll", name = "", description = "") + //@Scope(key = "device:raspberrypi:enroll", name = "", description = "") Response switchBulb(@PathParam("deviceId") String deviceId, @QueryParam("state") String state); /** @@ -58,7 +58,7 @@ public interface RaspberryPiService { @GET @Consumes("application/json") @Produces("application/json") - @Scope(key = "device:raspberrypi:enroll", name = "", description = "") + //@Scope(key = "device:raspberrypi:enroll", name = "", description = "") Response getRaspberryPiTemperatureStats(@PathParam("deviceId") String deviceId, @QueryParam("from") long from, @QueryParam("to") long to); @@ -68,7 +68,7 @@ public interface RaspberryPiService { @Path("device/download") @GET @Produces(MediaType.APPLICATION_JSON) - @Scope(key = "device:raspberrypi:enroll", name = "", description = "") + //@Scope(key = "device:raspberrypi:enroll", name = "", description = "") Response downloadSketch(@QueryParam("deviceName") String deviceName, @QueryParam("sketch_type") String sketchType); } diff --git a/components/device-types/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/device-types/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 75db835b7b..62be0f612f 100644 --- a/components/device-types/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/device-types/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 @@ -63,7 +63,7 @@ public interface VirtualFireAlarmService { */ @POST @Path("device/{deviceId}/buzz") - @Scope(key = "device:firealarm:enroll", name = "", description = "") + //@Scope(key = "device:firealarm:enroll", name = "", description = "") Response switchBuzzer(@PathParam("deviceId") String deviceId, @FormParam("state") String state); @@ -72,7 +72,7 @@ public interface VirtualFireAlarmService { */ @Path("device/stats/{deviceId}") @GET - @Scope(key = "device:firealarm:enroll", name = "", description = "") + //@Scope(key = "device:firealarm:enroll", name = "", description = "") @Consumes("application/json") @Produces("application/json") Response getVirtualFirealarmStats(@PathParam("deviceId") String deviceId, @QueryParam("from") long from, @@ -81,7 +81,7 @@ public interface VirtualFireAlarmService { @Path("device/download") @GET @Produces("application/zip") - @Scope(key = "device:firealarm:enroll", name = "", description = "") + //@Scope(key = "device:firealarm:enroll", name = "", description = "") Response downloadSketch(@QueryParam("deviceName") String deviceName, @QueryParam("sketchType") String sketchType); } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java index 5e325938c5..ad2dc20080 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java @@ -24,7 +24,6 @@ import io.swagger.annotations.ExtensionProperty; import io.swagger.annotations.Extension; import io.swagger.annotations.Tag; import io.swagger.annotations.Api; -import org.wso2.carbon.apimgt.annotations.api.Permission; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsDeviceEnrolmentException; import javax.jws.WebService; @@ -68,31 +67,32 @@ public interface DeviceManagementAdminService { @POST @Path("/lock-devices") - @Permission(name = "Lock Device", permission = "/device-mgt/devices/owning-device/operations/windows/lock") + //@Permission(name = "Lock Device", permission = "/device-mgt/devices/owning-device/operations/windows/lock") Response lock(@HeaderParam("Accept") String headerParam, List deviceIds) throws WindowsDeviceEnrolmentException; @POST @Path("/disenroll-devices") - @Permission(name = "Disenroll Device", permission = "/device-mgt/devices/disenroll/windows") + //@Permission(name = "Disenroll Device", permission = "/device-mgt/devices/disenroll/windows") Response disenroll(@HeaderParam("Accept") String headerParam, List deviceIds) throws WindowsDeviceEnrolmentException; @POST @Path("/wipe-devices") - @Permission(name = "Wipe Device", permission = "/device-mgt/devices/owning-device/operations/windows/wipe") + //@Permission(name = "Wipe Device", permission = "/device-mgt/devices/owning-device/operations/windows/wipe") Response wipe(@HeaderParam("Accept") String headerParam, List deviceIds) throws WindowsDeviceEnrolmentException; @POST @Path("/ring-devices") - @Permission(name = "Ring Device", permission = "/device-mgt/devices/owning-device/operations/windows/ring") + //@Permission(name = "Ring Device", permission = "/device-mgt/devices/owning-device/operations/windows/ring") Response ring(@HeaderParam("Accept") String headerParam, List deviceIds) throws WindowsDeviceEnrolmentException; @POST @Path("/lock-reset-devices") - @Permission(name = "Lock-Reset Device", permission = "/device-mgt/devices/owning-device/operations/windows/lock-reset") + //@Permission(name = "Lock-Reset Device", permission = + // "/device-mgt/devices/owning-device/operations/windows/lock-reset") Response lockReset(@HeaderParam("Accept") String acceptHeader, List deviceIds) throws WindowsDeviceEnrolmentException; } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/authbst/BSTProvider.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/authbst/BSTProvider.java index 220d0e02da..e0736e3fcf 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/authbst/BSTProvider.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/authbst/BSTProvider.java @@ -18,7 +18,6 @@ package org.wso2.carbon.device.mgt.mobile.windows.api.services.authbst; -import org.wso2.carbon.apimgt.annotations.api.Permission; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsDeviceEnrolmentException; import org.wso2.carbon.device.mgt.mobile.windows.api.services.authbst.beans.Credentials; @@ -37,6 +36,6 @@ public interface BSTProvider { @POST @Consumes(MediaType.APPLICATION_JSON) @Path("/authentication") - @Permission(name = "Enroll Device", permission = "/device-mgt/devices/enroll/windows") + // @Permission(name = "Enroll Device", permission = "/device-mgt/devices/enroll/windows") Response getBST(Credentials credentials) throws WindowsDeviceEnrolmentException; } From 4dfc49474c4bddc5c0ca516c92bebc51884ba63e Mon Sep 17 00:00:00 2001 From: Milan Perera Date: Wed, 14 Dec 2016 08:53:28 +0530 Subject: [PATCH 02/28] Upgraded APIM and Identity OAuth module --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index f6181f3235..2b7ff94dc0 100644 --- a/pom.xml +++ b/pom.xml @@ -1267,7 +1267,7 @@ 5.2.2 - 5.1.3 + 5.1.1 5.1.1 [5.2.2, 6.0.0) @@ -1281,7 +1281,7 @@ 4.6.5 - 6.0.5 + 6.0.6-SNAPSHOT 3.0.4.wso2v1 From 8a384a6664ff5c7863a2cb955cecc442845197a2 Mon Sep 17 00:00:00 2001 From: Milan Perera Date: Thu, 5 Jan 2017 11:21:51 +0530 Subject: [PATCH 03/28] Updated to APIM latest snapshot version --- pom.xml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index fccb532f9f..b7464fb6b3 100644 --- a/pom.xml +++ b/pom.xml @@ -1266,14 +1266,8 @@ 4.7.2 - - - - - - 5.6.89 - 5.2.33 + 5.3.1 [5.2.0, 6.0.0) @@ -1286,10 +1280,7 @@ 4.7.0 - - - - 6.1.2 + 6.1.30-SNAPSHOT 3.0.4.wso2v1 From 1b56ebb831324e0433684c125f086b003e733920 Mon Sep 17 00:00:00 2001 From: Madawa Soysa Date: Fri, 16 Dec 2016 15:08:05 +0530 Subject: [PATCH 04/28] Improving scope annotations in android plugin --- .../pom.xml | 5 + .../DeviceManagementAdminService.java | 441 +++++++++++------- .../services/DeviceManagementService.java | 93 ++-- .../DeviceTypeConfigurationService.java | 57 ++- .../services/EventReceiverService.java | 35 +- .../android/util/AndroidConstants.java | 1 + 6 files changed, 370 insertions(+), 262 deletions(-) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml index 017ff5400c..c2ea041777 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml @@ -143,6 +143,11 @@ org.wso2.carbon.device.mgt.common provided + + org.wso2.carbon.devicemgt + org.wso2.carbon.apimgt.annotations + provided + org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.core 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 e24f6fbfad..d752a30779 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 @@ -24,15 +24,16 @@ import io.swagger.annotations.ExtensionProperty; import io.swagger.annotations.Extension; import io.swagger.annotations.Tag; import io.swagger.annotations.Api; -import io.swagger.annotations.AuthorizationScope; -import io.swagger.annotations.Authorization; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ResponseHeader; +import org.wso2.carbon.apimgt.annotations.api.Scope; +import org.wso2.carbon.apimgt.annotations.api.Scopes; import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; import org.wso2.carbon.mdm.services.android.bean.wrapper.*; +import org.wso2.carbon.mdm.services.android.util.AndroidConstants; import javax.validation.Valid; import javax.ws.rs.Consumes; @@ -64,6 +65,160 @@ import java.util.List; @Api(value = "Android Device Management Administrative Service", description = "Device management related admin APIs.") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) +@Scopes( + scopes = { + @Scope( + name = "Lock Device", + description = "Hard lock own device", + key = "cdmf:android:lock-devices", + permissions = {"/device-mgt/devices/owning-device/operations/android/lock"} + ), + @Scope( + name = "Unlock Device", + description = "Unlock permanently locked device", + key = "cdmf:android:unlock-devices", + permissions = {"/device-mgt/devices/owning-device/operations/android/unlock"} + ), + @Scope( + name = "Get Location", + description = "Request device location coordinates", + key = "cdmf:android:location", + permissions = {"/device-mgt/devices/owning-device/operations/android/location"} + ), + @Scope( + name = "Clear Password", + description = "Clear the password on Android devices", + key = "cdmf:android:clear-password", + permissions = {"/device-mgt/devices/owning-device/operations/android/clear-password"} + ), + @Scope( + name = "Control Camera", + description = "Enabling or Disabling the Camera on Android Devices", + key = "cdmf:android:control-camera", + permissions = {"/device-mgt/devices/owning-device/operations/android/camera"} + ), + @Scope( + name = "Get Info", + description = "Requesting device information from Android Devices", + key = "cdmf:android:info", + permissions = {"/device-mgt/devices/owning-device/operations/android/info"} + ), + @Scope( + name = "Get Logs", + description = "Requesting Logcat Details from Android Devices", + key = "cdmf:android:logcat", + permissions = {"/device-mgt/devices/owning-device/operations/android/logcat"} + ), + @Scope( + name = "Enterprise Wipe", + description = "Enterprise Wiping Android Devices", + key = "cdmf:android:enterprise-wipe", + permissions = {"/device-mgt/devices/owning-device/operations/android/enterprise-wipe"} + ), + @Scope( + name = "Factory Reset", + description = "Factory Resetting Android Devices", + key = "cdmf:android:wipe", + permissions = {"/device-mgt/devices/owning-device/operations/android/wipe"} + ), + @Scope( + name = "Get Installed Applications", + description = "Get list of installed applications", + key = "cdmf:android:applications", + permissions = {"/device-mgt/devices/owning-device/operations/android/applications"} + ), + @Scope( + name = "Ring Device", + description = "Ring Android devices", + key = "cdmf:android:ring", + permissions = {"/device-mgt/devices/owning-device/operations/android/ring"} + ), + @Scope( + name = "Reboot Device", + description = "Reboot Android devices", + key = "cdmf:android:reboot", + permissions = {"/device-mgt/devices/owning-device/operations/android/reboot"} + ), + @Scope( + name = "Mute Device", + description = "Mute Android devices", + key = "cdmf:android:mute", + permissions = {"/device-mgt/devices/owning-device/operations/android/mute"} + ), + @Scope( + name = "Install Applications", + description = "Installing an Application on Android Devices", + key = "cdmf:android:install-application", + permissions = {"/device-mgt/devices/owning-device/operations/android/install-app"} + ), + @Scope( + name = "Update Applications", + description = "Updating an Application on Android Devices", + key = "cdmf:android:update-application", + permissions = {"/device-mgt/devices/owning-device/operations/android/update-app"} + ), + @Scope( + name = "Uninstall Applications", + description = "Uninstalling an Application on Android Devices", + key = "cdmf:android:uninstall-application", + permissions = {"/device-mgt/devices/owning-device/operations/android/uninstall-app"} + ), + @Scope( + name = "Blacklist Applications", + description = "Blacklisting applications on Android Devices", + key = "cdmf:android:blacklist-applications", + permissions = {"/device-mgt/devices/owning-device/operations/android/blacklist-app"} + ), + @Scope( + name = "Upgrade Firmware", + description = "Upgrading Firmware of Android Devices", + key = "cdmf:android:upgrade-firmware", + permissions = {"/device-mgt/devices/owning-device/operations/android/upgrade"} + ), + @Scope( + name = "Configure VPN", + description = "Configure VPN on Android Device", + key = "cdmf:android:configure-vpn", + permissions = {"/device-mgt/devices/owning-device/operations/android/vpn"} + ), + @Scope( + name = "Send Notification", + description = "Sending a notification to Android Device", + key = "cdmf:android:send-notification", + permissions = {"/device-mgt/devices/owning-device/operations/android/send-notification"} + ), + @Scope( + name = "Configure Wi-Fi", + description = "Configure Wi-Fi on Android Device", + key = "cdmf:android:configure-wifi", + permissions = {"/device-mgt/devices/owning-device/operations/android/wifi"} + ), + @Scope( + name = "Encrypt Storage", + description = "Encrypting storage on Android Device", + key = "cdmf:android:encrypt-storage", + permissions = {"/device-mgt/devices/owning-device/operations/android/encrypt"} + ), + @Scope( + name = "Change Password", + description = "Changing the lock code of an Android Device", + key = "cdmf:android:change-lock-code", + permissions = {"/device-mgt/devices/owning-device/operations/android/change-lock-code"} + ), + @Scope( + name = "Password Policy", + description = "Set password policy of an Android Device", + key = "cdmf:android:set-password-policy", + permissions = {"/device-mgt/devices/owning-device/operations/android/password-policy"} + ), + @Scope( + name = "Add Web clip", + description = "Setting a Web Clip on Android Devices", + key = "cdmf:android:set-webclip", + permissions = {"/device-mgt/devices/owning-device/operations/android/webclip"} + ) + } +) public interface DeviceManagementAdminService { @POST @@ -76,13 +231,10 @@ public interface DeviceManagementAdminService { "permanently locks the device or screen locking an Android device.", response = Activity.class, tags = "Android Device Management Administrative Service", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/android/lock", - description = "Lock Device") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:lock-devices") + }) } ) @ApiResponses(value = { @@ -142,13 +294,10 @@ public interface DeviceManagementAdminService { notes = "Unlock devices that were locked permanently using the hard lock operation. Devices that are hard locked can only be unlocked by the EMM administrator.", response = Activity.class, tags = "Android Device Management Administrative Service", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/android/unlock", - description = "Unlock Device") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:unlock-devices") + }) } ) @ApiResponses(value = { @@ -208,13 +357,10 @@ public interface DeviceManagementAdminService { "Example: In situations where you have lost your device and need to find out where it is, you can use this REST API to get the location of the device.", response = Activity.class, tags = "Android Device Management Administrative Service", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/android/location", - description = "Get Device Location") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:location") + }) } ) @ApiResponses(value = { @@ -270,13 +416,10 @@ public interface DeviceManagementAdminService { notes = "Clear the password on Android devices", response = Activity.class, tags = "Android Device Management Administrative Service.", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/android/clear-password", - description = "Clear Password of Device") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:clear-password") + }) } ) @ApiResponses(value = { @@ -331,13 +474,11 @@ public interface DeviceManagementAdminService { notes = "Enable or disable the camera on Android devices.", response = Activity.class, tags = "Android Device Management Administrative Service", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope(scope = "/device-mgt/devices/owning-device/operations/android/camera", description = "Manage Camera") } - ) - } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:control-camera") + }) + } ) @ApiResponses(value = { @ApiResponse( code = 201, @@ -398,13 +539,10 @@ public interface DeviceManagementAdminService { "the list of operations that needs to be executed on the device", response = Activity.class, tags = "Android Device Management Administrative Service", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/android/info", - description = "Get Device Information") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:info") + }) } ) @ApiResponses(value = { @@ -464,13 +602,10 @@ public interface DeviceManagementAdminService { "the list of operations that needs to be executed on the device.", response = Activity.class, tags = "Android Device Management Administrative Service", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/android/logcat", - description = "Get Logs") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:logcat") + }) } ) @ApiResponses(value = { @@ -529,13 +664,10 @@ public interface DeviceManagementAdminService { "personal data intact. You are able to enterprise wipe Android devices using this REST API.", response = Activity.class, tags = "Android Device Management Administrative Service", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/android/enterprise-wipe", - description = "Enterprise Wipe") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:enterprise-wipe") + }) } ) @ApiResponses(value = { @@ -592,13 +724,10 @@ public interface DeviceManagementAdminService { "to restore them back to the original system.", response = Activity.class, tags = "Android Device Management Administrative Service", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/android/wipe", - description = "Factory Reset") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:wipe") + }) } ) @ApiResponses(value = { @@ -659,13 +788,10 @@ public interface DeviceManagementAdminService { "on the device.", response = Activity.class, tags = "Android Device Management Administrative Service", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/android/applications", - description = "Get Installed Application") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:applications") + }) } ) @ApiResponses(value = { @@ -722,13 +848,10 @@ public interface DeviceManagementAdminService { notes = "Ring Android devices.", response = Activity.class, tags = "Android Device Management Administrative Service", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/android/ring", - description = "Ring Device") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:ring") + }) } ) @ApiResponses(value = { @@ -785,13 +908,10 @@ public interface DeviceManagementAdminService { notes = "Reboot or restart your Android devices.", response = Activity.class, tags = "Android Device Management Administrative Service", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/android/reboot", - description = "Reboot Device") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:reboot") + }) } ) @ApiResponses(value = { @@ -840,6 +960,7 @@ public interface DeviceManagementAdminService { List deviceIDs); @POST + @Path("/mute") @ApiOperation( consumes = MediaType.APPLICATION_JSON, httpMethod = "POST", @@ -847,13 +968,10 @@ public interface DeviceManagementAdminService { notes = "Mute or enable a silent profile for Android devices.", response = Activity.class, tags = "Android Device Management Administrative Service", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/android/mute", - description = "Mute Device") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:mute") + }) } ) @ApiResponses(value = { @@ -894,7 +1012,6 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new device mute operation.") }) - @Path("/mute") Response muteDevice( @ApiParam( name = "deviceIDs", @@ -913,13 +1030,10 @@ public interface DeviceManagementAdminService { " the application installation will happen in silent mode, else the device user's consent will be required.", response = Activity.class, tags = "Android Device Management Administrative Service", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/android/install-app", - description = "Install Applications") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:install-application") + }) } ) @ApiResponses(value = { @@ -981,13 +1095,10 @@ public interface DeviceManagementAdminService { "mode, else the device user's consent is required.", response = Activity.class, tags = "Android Device Management Administrative Service", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/android/update-app", - description = "Update installed applications") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:update-application") + }) } ) @ApiResponses(value = { @@ -1046,13 +1157,10 @@ public interface DeviceManagementAdminService { notes = "Uninstall an application from Android devices.", response = Activity.class, tags = "Android Device Management Administrative Service", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/android/uninstall-app", - description = "Uninstall Applications") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:uninstall-application") + }) } ) @ApiResponses(value = { @@ -1115,13 +1223,10 @@ public interface DeviceManagementAdminService { "COPE devices. Applications can be blacklisted via the application restriction policy too.", response = Activity.class, tags = "Android Device Management Administrative Service", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/android/blacklist-app", - description = "Blacklist Applications") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:blacklist-applications") + }) } ) @ApiResponses(value = { @@ -1176,17 +1281,14 @@ public interface DeviceManagementAdminService { consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, httpMethod = "POST", - value = "UUpgrading Firmware of Android Devices", + value = "Upgrading Firmware of Android Devices", notes = "Upgrade the firmware of Android devices.", response = Activity.class, tags = "Android Device Management Administrative Service", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/android/upgrade", - description = "Upgrade Firmware") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:upgrade-firmware") + }) } ) @ApiResponses(value = { @@ -1247,13 +1349,10 @@ public interface DeviceManagementAdminService { notes = "Configure VPN on Android devices.", response = Activity.class, tags = "Android Device Management Administrative Service", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/android/vpn", - description = "Add VPN") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:configure-vpn") + }) } ) @ApiResponses(value = { @@ -1310,13 +1409,10 @@ public interface DeviceManagementAdminService { notes = "Send a notification or message to Android devices.", response = Activity.class, tags = "Android Device Management Administrative Service", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/android/send-notification", - description = "Send Notifications") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:send-notification") + }) } ) @ApiResponses(value = { @@ -1374,13 +1470,10 @@ public interface DeviceManagementAdminService { notes = "Configure Wi-Fi on Android devices.", response = Activity.class, tags = "Android Device Management Administrative Service", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/android/wifi", - description = "Add Wifi Configuration") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:configure-wifi") + }) } ) @ApiResponses(value = { @@ -1439,13 +1532,10 @@ public interface DeviceManagementAdminService { notes = "Encrypt the data stored on Android devices.", response = Activity.class, tags = "Android Device Management Administrative Service", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/android/encrypt", - description = "Encrypt Device") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:encrypt-storage") + }) } ) @ApiResponses(value = { @@ -1504,13 +1594,10 @@ public interface DeviceManagementAdminService { notes = "Change the lock code on Android devices.", response = Activity.class, tags = "Android Device Management Administrative Service", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/android/change-lock-code", - description = "Change Password of Device") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:change-lock-code") + }) } ) @ApiResponses(value = { @@ -1569,13 +1656,10 @@ public interface DeviceManagementAdminService { notes = "Set a password policy on Android devices.", response = Activity.class, tags = "Android Device Management Administrative Service", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/android/password-policy", - description = "Set Password Policy") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:set-password-policy") + }) } ) @ApiResponses(value = { @@ -1624,7 +1708,7 @@ public interface DeviceManagementAdminService { PasswordPolicyBeanWrapper passwordPolicyBeanWrapper); @POST - @Path("set-webclip") + @Path("/set-webclip") @ApiOperation( consumes = MediaType.APPLICATION_JSON, httpMethod = "POST", @@ -1632,13 +1716,10 @@ public interface DeviceManagementAdminService { notes = "Set a web clip on Android devices. A web clip is used to add a bookmark to a web application.", response = Activity.class, tags = "Android Device Management Administrative Service", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/android/webclip", - description = "Add Webclips") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:set-webclip") + }) } ) @ApiResponses(value = { 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 4bf71b564a..777c9582bc 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 @@ -18,22 +18,14 @@ */ package org.wso2.carbon.mdm.services.android.services; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Authorization; -import io.swagger.annotations.AuthorizationScope; -import io.swagger.annotations.Extension; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Info; -import io.swagger.annotations.ResponseHeader; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Tag; +import io.swagger.annotations.*; + +import org.wso2.carbon.apimgt.annotations.api.Scope; +import org.wso2.carbon.apimgt.annotations.api.Scopes; 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; +import org.wso2.carbon.mdm.services.android.util.AndroidConstants; import javax.validation.Valid; import javax.validation.constraints.NotNull; @@ -72,6 +64,22 @@ import java.util.List; @Path("/devices") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) +@Scopes( + scopes = { + @Scope( + name = "Enroll Device", + description = "Register an Android device", + key = "cdmf:android:enroll", + permissions = {"/device-mgt/devices/enroll/android"} + ), + @Scope( + name = "Un-enroll Device", + description = "Unregister an Android device", + key = "cdmf:android:disenroll", + permissions = {"/device-mgt/devices/disenroll/android"} + ) + } +) public interface DeviceManagementService { @PUT @@ -83,12 +91,10 @@ public interface DeviceManagementService { value = "Updating the Application Details on Android Devices", notes = "Update the details of the applications that are installed on Android devices.", tags = "Android Device Management", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope(scope = "/device-mgt/devices/enroll/android", - description = "Enroll Device") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:enroll") + }) } ) @ApiResponses(value = { @@ -150,12 +156,10 @@ public interface DeviceManagementService { "The server then updates the status of the operations that were carried out on the device.", response = Operation.class, tags = "Android Device Management", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope(scope = "/device-mgt/devices/enroll/android", - description = "Enroll Device") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:enroll") + }) } ) @ApiResponses(value = { @@ -216,12 +220,10 @@ public interface DeviceManagementService { " you can use this REST API to register an Android device with WSO2 EMM, without having to install" + " an Android Agent. This API can be mainly used to test the device enrollment process.", tags = "Android Device Management", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope(scope = "/device-mgt/devices/enroll/android", - description = "Enroll Device") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:enroll") + }) } ) @ApiResponses(value = { @@ -273,12 +275,10 @@ public interface DeviceManagementService { value = "Getting the Registration Status of an Android Device", notes = "Use this REST API to retrieve the registration status of an Android device.", tags = "Android Device Management", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope(scope = "/device-mgt/devices/enroll/android", - description = "Enroll Device") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:enroll") + }) } ) @ApiResponses(value = { @@ -328,12 +328,10 @@ public interface DeviceManagementService { value = "Updating the Registration Details of an Android Device", notes = "Use this REST API to update the registration details of an Android device.", tags = "Android Device Management", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope(scope = "/device-mgt/devices/enroll/android", - description = "Enroll Device") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:enroll") + }) } ) @ApiResponses( @@ -386,11 +384,10 @@ public interface DeviceManagementService { value = "Unregistering an Android Device", notes = "Use this REST API to unregister an Android device.", tags = "Android Device Management", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope(scope = "/device-mgt/devices/disenroll/android", description = "Disenroll Device") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:disenroll") + }) } ) @ApiResponses(value = { 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 3eab30e353..09a731df4d 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 @@ -24,16 +24,17 @@ import io.swagger.annotations.ExtensionProperty; import io.swagger.annotations.Extension; import io.swagger.annotations.Tag; import io.swagger.annotations.Api; -import io.swagger.annotations.AuthorizationScope; -import io.swagger.annotations.Authorization; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ResponseHeader; +import org.wso2.carbon.apimgt.annotations.api.Scope; +import org.wso2.carbon.apimgt.annotations.api.Scopes; 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; +import org.wso2.carbon.mdm.services.android.util.AndroidConstants; import javax.validation.Valid; import javax.ws.rs.*; @@ -61,6 +62,28 @@ import javax.ws.rs.core.Response; @Path("/configuration") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) +@Scopes( + scopes = { + @Scope( + name = "Enroll Device", + description = "Register an Android device", + key = "cdmf:android:enroll", + permissions = {"/device-mgt/devices/enroll/android"} + ), + @Scope( + name = "View Configurations", + description = "Getting Android Platform Configurations", + key = "cdmf:android:view-configuration", + permissions = {"/device-mgt/platform-configurations/view"} + ), + @Scope( + name = "Manage Configurations", + description = "Updating Android Platform Configurations", + key = "cdmf:android:manage-configuration", + permissions = {"/device-mgt/platform-configurations/manage"} + ) + } +) public interface DeviceTypeConfigurationService { @GET @@ -71,12 +94,10 @@ public interface DeviceTypeConfigurationService { notes = "Get the Android platform configuration details using this REST API.", response = PlatformConfiguration.class, tags = "Android Configuration Management", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope(scope = "/device-mgt/platform-configurations/view", - description = "View Configurations") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:view-configuration") + }) } ) @ApiResponses(value = { @@ -127,12 +148,10 @@ public interface DeviceTypeConfigurationService { value = "Updating Android Platform Configurations", notes = "Update the Android platform configurations using this REST API.", tags = "Android Configuration Management", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope(scope = "/device-mgt/platform-configurations/manage", - description = "Manage Configurations") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:manage-configuration") + }) } ) @ApiResponses(value = { @@ -184,12 +203,10 @@ public interface DeviceTypeConfigurationService { "registration process.", response = String.class, tags = "Android Configuration Management", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope(scope = "/device-mgt/devices/enroll/android", - description = "Enroll Device") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:enroll") + }) } ) @ApiResponses(value = { 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 744655768d..89e8dd44c9 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 @@ -24,15 +24,16 @@ import io.swagger.annotations.ExtensionProperty; import io.swagger.annotations.Extension; import io.swagger.annotations.Tag; import io.swagger.annotations.Api; -import io.swagger.annotations.AuthorizationScope; -import io.swagger.annotations.Authorization; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ResponseHeader; +import org.wso2.carbon.apimgt.annotations.api.Scope; +import org.wso2.carbon.apimgt.annotations.api.Scopes; import org.wso2.carbon.mdm.services.android.bean.DeviceState; import org.wso2.carbon.mdm.services.android.bean.wrapper.EventBeanWrapper; +import org.wso2.carbon.mdm.services.android.util.AndroidConstants; import javax.validation.Valid; import javax.validation.constraints.Size; @@ -61,6 +62,16 @@ import javax.ws.rs.core.Response; @Path("/events") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) +@Scopes( + scopes = { + @Scope( + name = "Enroll Device", + description = "Register an Android device", + key = "cdmf:android:enroll", + permissions = {"/device-mgt/devices/enroll/android"} + ) + } +) public interface EventReceiverService { @POST @@ -72,12 +83,10 @@ public interface EventReceiverService { value = "Publishing Events", notes = "Publish events received by the WSO2 EMM Android client to the WSO2 Data Analytics Server (DAS) using this API.", tags = "Event Receiver", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope(scope = "/device-mgt/devices/enroll/android", - description = "Publish Events to DAS") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:enroll") + }) } ) @ApiResponses( @@ -137,12 +146,10 @@ public interface EventReceiverService { response = DeviceState.class, responseContainer = "List", tags = "Event Receiver", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope(scope = "/device-mgt/devices/enroll/android", - description = "Publish Events to DAS") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:enroll") + }) } ) @ApiResponses( 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/AndroidConstants.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/AndroidConstants.java index 62ed8afe05..c1e09b4c06 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/AndroidConstants.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/AndroidConstants.java @@ -26,6 +26,7 @@ public final class AndroidConstants { public static final String DEVICE_TYPE_ANDROID = "android"; public static final String HEADER_CONTENT_TYPE = "Content-Type"; public static final String APPLICATION_JSON = "application/json"; + public static final String SCOPE = "scope"; public final class DeviceProperties { private DeviceProperties() { From 855162c028054d551b87d6aeae8ba71487f0e6eb Mon Sep 17 00:00:00 2001 From: Madawa Soysa Date: Sat, 17 Dec 2016 19:56:42 +0530 Subject: [PATCH 05/28] Improving scope annotations in windows plugin --- .../api/operations/util/Constants.java | 2 + .../api/services/ConfigurationMgtService.java | 59 +++++++---- .../DeviceManagementAdminService.java | 99 ++++++++++++------- .../api/services/authbst/BSTProvider.java | 25 +++-- 4 files changed, 120 insertions(+), 65 deletions(-) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/Constants.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/Constants.java index b68bca44c3..b20f31baa6 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/Constants.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/Constants.java @@ -79,6 +79,8 @@ public class Constants { public static final String META_FORMAT_INT = "int"; public static final String META_FORMAT_CHARACTER = "chr"; + public static final String SCOPE = "scope"; + /** * SynclML service related constants. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/ConfigurationMgtService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/ConfigurationMgtService.java index 1796a637cb..5b69ba25d7 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/ConfigurationMgtService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/ConfigurationMgtService.java @@ -32,9 +32,12 @@ import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ResponseHeader; +import org.wso2.carbon.apimgt.annotations.api.Scope; +import org.wso2.carbon.apimgt.annotations.api.Scopes; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsConfigurationException; import org.wso2.carbon.device.mgt.mobile.windows.api.common.util.Message; +import org.wso2.carbon.device.mgt.mobile.windows.api.operations.util.Constants; import javax.jws.WebService; import javax.ws.rs.*; @@ -66,8 +69,30 @@ import javax.ws.rs.core.Response; description = "This carries all the resources related to Windows configurations management functionalities") @WebService @Path("/configuration") -@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) -@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) +@Produces({"application/json", "application/xml"}) +@Consumes({"application/json", "application/xml"}) +@Scopes( + scopes = { + @Scope( + name = "Enroll Device", + description = "Register an Windows device", + key = "cdmf:windows:enroll", + permissions = {"/device-mgt/devices/enroll/windows"} + ), + @Scope( + name = "View Configurations", + description = "Getting Windows Platform Configurations", + key = "cdmf:windows:view-configuration", + permissions = {"/device-mgt/platform-configurations/view"} + ), + @Scope( + name = "Manage Configurations", + description = "Updating Windows Platform Configurations", + key = "cdmf:windows:manage-configuration", + permissions = {"/device-mgt/platform-configurations/manage"} + ) + } +) public interface ConfigurationMgtService { @GET @@ -78,12 +103,10 @@ public interface ConfigurationMgtService { notes = "Get the Windows platform configuration details using this REST API.", response = PlatformConfiguration.class, tags = "Windows Configuration Management", - authorizations = { - @Authorization( - value = "permission", - scopes = {@AuthorizationScope(scope = "/device-mgt/platform-configurations/view", - description = "View Configurations")} - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:view-configuration") + }) } ) @ApiResponses(value = { @@ -139,12 +162,10 @@ public interface ConfigurationMgtService { value = "Updating Windows Platform Configurations", notes = "Update the Windows platform configurations using this REST API.", tags = "Windows Configuration Management", - authorizations = { - @Authorization( - value = "permission", - scopes = {@AuthorizationScope(scope = "/device-mgt/configurations/manage", - description = "Manage Configurations")} - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:manage-configuration") + }) } ) @ApiResponses(value = { @@ -197,12 +218,10 @@ public interface ConfigurationMgtService { "registration process.", response = String.class, tags = "Windows Configuration Management", - authorizations = { - @Authorization( - value = "permission", - scopes = {@AuthorizationScope(scope = "/device-mgt/devices/enroll/windows", - description = "Enroll Device")} - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:enroll") + }) } ) @ApiResponses(value = { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java index c56d270c76..c054f821f8 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java @@ -19,8 +19,12 @@ package org.wso2.carbon.device.mgt.mobile.windows.api.services; import io.swagger.annotations.*; + +import org.wso2.carbon.apimgt.annotations.api.Scope; +import org.wso2.carbon.apimgt.annotations.api.Scopes; import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsDeviceEnrolmentException; +import org.wso2.carbon.device.mgt.mobile.windows.api.operations.util.Constants; import javax.jws.WebService; import javax.ws.rs.Consumes; @@ -57,9 +61,43 @@ import java.util.List; @Api(value = "Windows Device Management Administrative Service", description = "Device management related admin APIs.") @WebService -@Path("/operation/admin/devices") -@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) -@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) +@Path("/admin/devices") +@Consumes(MediaType.APPLICATION_JSON) +@Produces(MediaType.APPLICATION_JSON) +@Scopes( + scopes = { + @Scope( + name = "Lock Device", + description = "Adding a Device Lock on Windows devices.", + key = "cdmf:windows:lock-devices", + permissions = {"/device-mgt/devices/owning-device/operations/windows/lock"} + ), + @Scope( + name = "Un-enroll Device", + description = "Unregister an Windows device", + key = "cdmf:windows:disenroll", + permissions = {"/device-mgt/devices/disenroll/windows"} + ), + @Scope( + name = "Factory Reset", + description = "Factory Resetting Windows Devices", + key = "cdmf:windows:wipe", + permissions = {"/device-mgt/devices/owning-device/operations/windows/wipe"} + ), + @Scope( + name = "Ring Device", + description = "Ring Windows devices", + key = "cdmf:windows:ring", + permissions = {"/device-mgt/devices/owning-device/operations/windows/ring"} + ), + @Scope( + name = "Lock Reset", + description = "Lock reset on Windows devices", + key = "cdmf:windows:lock-reset", + permissions = {"/device-mgt/devices/owning-device/operations/windows/lock-reset"} + ) + } +) public interface DeviceManagementAdminService { @POST @@ -71,13 +109,10 @@ public interface DeviceManagementAdminService { notes = "Using this API you have the option of Device Windows device.", response = Activity.class, tags = "Windows Device Management Administrative Service", - authorizations = { - @Authorization( - value = "permission", - scopes = {@AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/windows/lock", - description = "Lock Device")} - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:lock-devices") + }) } ) @ApiResponses(value = { @@ -133,13 +168,10 @@ public interface DeviceManagementAdminService { notes = "Dis-enroll on Android devices", response = Activity.class, tags = "Windows Device Management Administrative Service.", - authorizations = { - @Authorization( - value = "permission", - scopes = {@AuthorizationScope( - scope = "/device-mgt/devices/disenroll/windows", - description = "Dis-enroll the windows devices ")} - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:disenroll") + }) } ) @ApiResponses(value = { @@ -197,13 +229,10 @@ public interface DeviceManagementAdminService { "to restore them back to the original system.", response = Activity.class, tags = "Windows Device Management Administrative Service", - authorizations = { - @Authorization( - value = "permission", - scopes = {@AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/windows/wipe", - description = "DeviceWipe")} - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:wipe") + }) } ) @ApiResponses(value = { @@ -258,13 +287,10 @@ public interface DeviceManagementAdminService { notes = "Ring Windows devices.", response = Activity.class, tags = "Windows Device Management Administrative Service", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/windows/ring", - description = "Ring Device") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:ring") + }) } ) @ApiResponses(value = { @@ -320,13 +346,10 @@ public interface DeviceManagementAdminService { notes = "Lock reset on Windows devices.Its use to reset the device pass code", response = Activity.class, tags = "Windows Device Management Administrative Service", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/windows/lock-reset", - description = "Lock reset") } - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:lock-reset") + }) } ) @ApiResponses(value = { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/authbst/BSTProvider.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/authbst/BSTProvider.java index b3272d703e..5b55a8ed07 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/authbst/BSTProvider.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/authbst/BSTProvider.java @@ -19,7 +19,11 @@ package org.wso2.carbon.device.mgt.mobile.windows.api.services.authbst; import io.swagger.annotations.*; + +import org.wso2.carbon.apimgt.annotations.api.Scope; +import org.wso2.carbon.apimgt.annotations.api.Scopes; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsDeviceEnrolmentException; +import org.wso2.carbon.device.mgt.mobile.windows.api.operations.util.Constants; import org.wso2.carbon.device.mgt.mobile.windows.api.services.authbst.beans.Credentials; import javax.jws.WebService; @@ -56,6 +60,16 @@ import javax.ws.rs.core.Response; @Path("/bst") @Produces({"application/json", "application/xml"}) @Consumes({"application/json", "application/xml"}) +@Scopes( + scopes = { + @Scope( + name = "Enroll Device", + description = "Register Windows device", + key = "cdmf:windows:enroll", + permissions = {"/device-mgt/devices/enroll/windows"} + ) + } +) public interface BSTProvider { @POST @@ -68,13 +82,10 @@ public interface BSTProvider { value = "Getting Binary security token.", notes = "Using this API to fetch Binary security token to call window enrollment and policy endpoints.", tags = "BST Provider", - authorizations = { - @Authorization( - value = "permission", - scopes = {@AuthorizationScope(scope = "/device-mgt/devices/enroll/windows", - description = "Getting Binary security token for Windows enrollment " + - "and policy endpoints.")} - ) + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:enroll") + }) } ) @ApiResponses( From 0c7f1adcbae758729935dca4f42156ac8f31850b Mon Sep 17 00:00:00 2001 From: Maninda Date: Thu, 5 Jan 2017 19:36:52 +0530 Subject: [PATCH 06/28] Fixed some issues reported with FindBugs while security plugin is enabled. --- .../communication/http/FireAlarmHTTPCommunicator.java | 2 +- .../pom.xml | 1 + .../plugin/config/VirtualFirealarmConfig.java | 2 ++ .../pom.xml | 1 + .../adapter/websocket/config/WebsocketConfig.java | 5 +++-- .../output/adapter/websocket/util/WebsocketUtils.java | 2 ++ .../android/bean/wrapper/AndroidDeviceInfo.java | 2 +- .../android/common/GsonMessageBodyHandler.java | 8 +------- .../org.wso2.carbon.device.mgt.mobile.android/pom.xml | 1 + .../android/impl/util/MobileDeviceManagementUtil.java | 2 ++ .../api/common/util/GsonMessageBodyHandler.java | 8 +------- .../windows/api/common/util/WindowsAPIUtils.java | 2 +- .../windows/api/operations/util/OperationHandler.java | 10 +++++----- .../enrollment/impl/EnrollmentServiceImpl.java | 4 +++- .../wstep/impl/CertificateEnrollmentServiceImpl.java | 2 +- .../org.wso2.carbon.device.mgt.mobile.windows/pom.xml | 1 + .../windows/impl/util/MobileDeviceManagementUtil.java | 2 ++ 17 files changed, 29 insertions(+), 26 deletions(-) diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/communication/http/FireAlarmHTTPCommunicator.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/communication/http/FireAlarmHTTPCommunicator.java index 98dbc6dc73..ead68c5285 100644 --- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/communication/http/FireAlarmHTTPCommunicator.java +++ b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/communication/http/FireAlarmHTTPCommunicator.java @@ -111,7 +111,7 @@ public class FireAlarmHTTPCommunicator extends HTTPTransportHandler { AgentManager agentManager = AgentManager.getInstance(); String pathContext = request.getPathInfo(); - String separator = File.separator; + String separator = File.separatorChar=='\\' ? "\\\\" : File.separator ; if (pathContext.toUpperCase().contains( separator + AgentConstants.TEMPERATURE_CONTROL)) { diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml index 40eba7c2ee..8a52af509d 100644 --- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml +++ b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml @@ -83,6 +83,7 @@ org.wso2.carbon.event.input.adapter.core, org.wso2.carbon.event.input.adapter.core.exception, org.jivesoftware.smack.*, + javax.xml, javax.xml.bind, javax.xml.bind.annotation, javax.xml.parsers; version="${javax.xml.parsers.import.pkg.version}", diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/VirtualFirealarmConfig.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/VirtualFirealarmConfig.java index a5a75611ea..9bb1380e52 100644 --- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/VirtualFirealarmConfig.java +++ b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/VirtualFirealarmConfig.java @@ -6,6 +6,7 @@ import org.w3c.dom.Document; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.config.exception.VirtualFirealarmConfigurationException; import org.wso2.carbon.utils.CarbonUtils; +import javax.xml.XMLConstants; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; @@ -50,6 +51,7 @@ public class VirtualFirealarmConfig { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); try { + factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); DocumentBuilder docBuilder = factory.newDocumentBuilder(); return docBuilder.parse(file); } catch (Exception e) { diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/pom.xml b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/pom.xml index 6400c6f34f..c72d27c77a 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/pom.xml +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/pom.xml @@ -134,6 +134,7 @@ org.wso2.carbon.event.output.adapter.core.*, + javax.xml, javax.xml.namespace; version=0.0.0, org.apache.axis2, org.apache.axis2.client, diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/config/WebsocketConfig.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/config/WebsocketConfig.java index 3499cd5e66..64efd5295e 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/config/WebsocketConfig.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/config/WebsocketConfig.java @@ -75,7 +75,8 @@ public class WebsocketConfig { return websocketValidationConfigs; } - public void setWebsocketValidationConfigs(WebsocketValidationConfigs websocketValidationConfigs) { - websocketValidationConfigs = websocketValidationConfigs; + public void setWebsocketValidationConfigs(WebsocketValidationConfigs websocketValidationConfigsTemp) { + websocketValidationConfigs = websocketValidationConfigsTemp; } + } diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/util/WebsocketUtils.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/util/WebsocketUtils.java index 162bc99559..86e30712f7 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/util/WebsocketUtils.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/util/WebsocketUtils.java @@ -21,6 +21,7 @@ package org.wso2.carbon.device.mgt.output.adapter.websocket.util; import org.w3c.dom.Document; import org.wso2.carbon.device.mgt.output.adapter.websocket.config.WebsocketValidationConfigurationFailedException; +import javax.xml.XMLConstants; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import java.io.File; @@ -34,6 +35,7 @@ public class WebsocketUtils { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); try { + factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); DocumentBuilder docBuilder = factory.newDocumentBuilder(); return docBuilder.parse(file); } catch (Exception e) { 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/AndroidDeviceInfo.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/AndroidDeviceInfo.java index bf775edfed..41fbb58570 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/AndroidDeviceInfo.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/AndroidDeviceInfo.java @@ -300,7 +300,7 @@ public class AndroidDeviceInfo extends DeviceInfo implements Serializable { } public Date getUpdatedTime() { - if(this.updatedTime.equals((Object)null)) { + if(this.updatedTime == null) { this.updatedTime = new Date(); } 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/common/GsonMessageBodyHandler.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/common/GsonMessageBodyHandler.java index a1ae89d151..2976300290 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/common/GsonMessageBodyHandler.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/common/GsonMessageBodyHandler.java @@ -83,13 +83,7 @@ public class GsonMessageBodyHandler implements MessageBodyWriter, Messag OutputStreamWriter writer = new OutputStreamWriter(entityStream, UTF_8); try { - Type jsonType; - if (type.equals(type)) { - jsonType = type; - } else { - jsonType = type; - } - getGson().toJson(object, jsonType, writer); + getGson().toJson(object, type, writer); } finally { writer.close(); } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/pom.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/pom.xml index bad6eab68c..e89d77a250 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/pom.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/pom.xml @@ -59,6 +59,7 @@ org.osgi.framework, org.osgi.service.component, org.apache.commons.logging, + javax.xml, javax.xml.bind.*, javax.sql, javax.xml.parsers; version=0.0.0, diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/MobileDeviceManagementUtil.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/MobileDeviceManagementUtil.java index 3e409653e8..210c73502b 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/MobileDeviceManagementUtil.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/MobileDeviceManagementUtil.java @@ -38,6 +38,7 @@ import org.wso2.carbon.registry.api.RegistryException; import org.wso2.carbon.registry.api.Resource; import org.wso2.carbon.registry.core.Registry; +import javax.xml.XMLConstants; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import java.io.File; @@ -66,6 +67,7 @@ public class MobileDeviceManagementUtil { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); try { + factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); DocumentBuilder docBuilder = factory.newDocumentBuilder(); return docBuilder.parse(file); } catch (Exception e) { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/util/GsonMessageBodyHandler.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/util/GsonMessageBodyHandler.java index ecb720866d..683d747cdb 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/util/GsonMessageBodyHandler.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/util/GsonMessageBodyHandler.java @@ -82,13 +82,7 @@ public class GsonMessageBodyHandler implements MessageBodyWriter, Messag OutputStreamWriter writer = new OutputStreamWriter(entityStream, UTF_8); try { - Type jsonType; - if (type.equals(type)) { - jsonType = type; - } else { - jsonType = type; - } - getGson().toJson(object, jsonType, writer); + getGson().toJson(object, type, writer); } finally { writer.close(); } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/util/WindowsAPIUtils.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/util/WindowsAPIUtils.java index 274c7ffaef..d77f2a5ab0 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/util/WindowsAPIUtils.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/util/WindowsAPIUtils.java @@ -187,10 +187,10 @@ public class WindowsAPIUtils { PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); AuthenticatorConfigService authenticatorConfigService = (AuthenticatorConfigService) ctx.getOSGiService(AuthenticatorConfigService.class, null); - AuthenticatorConfig authenticatorConfig = authenticatorConfigService.getAuthenticatorConfig("BST"); if (authenticatorConfigService == null) { throw new IllegalStateException("AuthenticatorConfiguration service has not initialized."); } + AuthenticatorConfig authenticatorConfig = authenticatorConfigService.getAuthenticatorConfig("BST"); if (authenticatorConfig == null) { throw new IllegalStateException("BST authenticatorConfig has not initialized."); } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/OperationHandler.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/OperationHandler.java index 8b0db02223..52ff4c4e20 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/OperationHandler.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/OperationHandler.java @@ -181,7 +181,7 @@ public class OperationHandler { if ((Constants.SyncMLResponseCodes.ACCEPTED.equals(status.getData()))) { pendingDataOperations = WindowsAPIUtils.getPendingOperations(deviceIdentifier); for (Operation operation : pendingDataOperations) { - if ((OperationCode.Command.DEVICE_RING.equals(operation.getCode())) && + if ((OperationCode.Command.DEVICE_RING.getCode().equals(operation.getCode())) && (operation.getId() == status.getCommandReference())) { operation.setStatus(Operation.Status.COMPLETED); updateStatus(syncmlDocument.getHeader().getSource().getLocURI(), @@ -213,7 +213,7 @@ public class OperationHandler { } for (Operation operation : pendingDataOperations) { - if ((OperationCode.Command.WIPE_DATA.equals(operation.getCode())) && + if ((OperationCode.Command.WIPE_DATA.getCode().equals(operation.getCode())) && (operation.getId() == status.getCommandReference())) { operation.setStatus(Operation.Status.COMPLETED); updateStatus(syncmlDocument.getHeader().getSource().getLocURI(), @@ -306,13 +306,13 @@ public class OperationHandler { if (status.getTargetReference() == null) { updateDeviceOperations(status, syncmlDocument, deviceIdentifier); } else { - if ((OperationCode.Command.DEVICE_LOCK.equals(status.getTargetReference()))) { + if ((OperationCode.Command.DEVICE_LOCK.getCode().equals(status.getTargetReference()))) { updateLockOperation(status, syncmlDocument, deviceIdentifier); } - if ((OperationCode.Command.DEVICE_RING.equals(status.getTargetReference()))) { + if ((OperationCode.Command.DEVICE_RING.getCode().equals(status.getTargetReference()))) { ring(status, syncmlDocument, deviceIdentifier); } - if (equals(OperationCode.Command.WIPE_DATA.equals(status.getTargetReference()))) { + if ((OperationCode.Command.WIPE_DATA.getCode().equals(status.getTargetReference()))) { dataWipe(status, syncmlDocument, deviceIdentifier); } } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/impl/EnrollmentServiceImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/impl/EnrollmentServiceImpl.java index 7cd57a495b..d59243549c 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/impl/EnrollmentServiceImpl.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/impl/EnrollmentServiceImpl.java @@ -51,6 +51,7 @@ import org.xml.sax.SAXException; import javax.annotation.Resource; import javax.jws.WebService; import javax.servlet.ServletContext; +import javax.xml.XMLConstants; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; @@ -102,7 +103,7 @@ public class EnrollmentServiceImpl implements EnrollmentService { String headerTo = null; String encodedWap; List
headers = getHeaders(); - for (Header headerElement : headers != null ? headers : null) { + for (Header headerElement : headers) { String nodeName = headerElement.getName().getLocalPart(); if (PluginConstants.SECURITY.equals(nodeName)) { Element element = (Element) headerElement.getObject(); @@ -231,6 +232,7 @@ public class EnrollmentServiceImpl implements EnrollmentService { signedCertEncodedString = base64Encoder.encodeAsString(signedCertificate.getEncoded()); DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); + domFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); DocumentBuilder builder; builder = domFactory.newDocumentBuilder(); diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/wstep/impl/CertificateEnrollmentServiceImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/wstep/impl/CertificateEnrollmentServiceImpl.java index 8e587bfc0f..a749214bac 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/wstep/impl/CertificateEnrollmentServiceImpl.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/wstep/impl/CertificateEnrollmentServiceImpl.java @@ -112,7 +112,7 @@ public class CertificateEnrollmentServiceImpl implements CertificateEnrollmentSe String headerTo = null; String encodedWap; List
headers = getHeaders(); - for (Header headerElement : headers != null ? headers : null) { + for (Header headerElement : headers) { String nodeName = headerElement.getName().getLocalPart(); if (PluginConstants.SECURITY.equals(nodeName)) { Element element = (Element) headerElement.getObject(); diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/pom.xml b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/pom.xml index 6890f755ac..3a74f23dec 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/pom.xml +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/pom.xml @@ -55,6 +55,7 @@ org.osgi.framework, org.osgi.service.component, org.apache.commons.logging, + javax.xml, javax.xml.bind.*, javax.sql, javax.naming, diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/util/MobileDeviceManagementUtil.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/util/MobileDeviceManagementUtil.java index c658eb6d09..72bf59ef2f 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/util/MobileDeviceManagementUtil.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/util/MobileDeviceManagementUtil.java @@ -38,6 +38,7 @@ import org.wso2.carbon.registry.api.RegistryException; import org.wso2.carbon.registry.api.Resource; import org.wso2.carbon.registry.core.Registry; +import javax.xml.XMLConstants; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import java.io.File; @@ -66,6 +67,7 @@ public class MobileDeviceManagementUtil { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); try { + factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); DocumentBuilder docBuilder = factory.newDocumentBuilder(); return docBuilder.parse(file); } catch (Exception e) { From 7dc5a2000dbffa30315256334cade7b9e507893d Mon Sep 17 00:00:00 2001 From: dunithd Date: Thu, 5 Jan 2017 21:23:34 +0530 Subject: [PATCH 07/28] Adding Geo Dashboard link to device view page --- .../device-view.hbs | 16 ++++++++++++++++ .../device-view.js | 5 ++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/components/device-types/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.hbs b/components/device-types/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.hbs index ba9322aca0..ce3f71d7c6 100644 --- a/components/device-types/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.hbs +++ b/components/device-types/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.hbs @@ -73,4 +73,20 @@ + {{/zone}} diff --git a/components/device-types/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/device-types/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 32d8c813e1..999d4ee64c 100644 --- a/components/device-types/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/device-types/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 @@ -28,10 +28,13 @@ function onRequest(context) { var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var device = deviceModule.viewDevice(deviceType, deviceId); if (device && device.status != "error") { + var anchor = { "device" : { "id" : device.content.deviceIdentifier, "type" : device.content.type}}; return { "device": device.content, "autoCompleteParams": autoCompleteParams, - "encodedFeaturePayloads": "" + "encodedFeaturePayloads": "", + "portalUrl" : devicemgtProps['portalURL'], + "anchor" : JSON.stringify(anchor) }; } else { response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!"); From d2d912fb6d9cda42fdf65f66db86f1199a1abf83 Mon Sep 17 00:00:00 2001 From: Milan Perera Date: Fri, 6 Jan 2017 10:10:45 +0530 Subject: [PATCH 08/28] Refactored scopes strings --- .../pom.xml | 4 + .../service/impl/AndroidSenseService.java | 89 ++++++++++++++-- .../impl/constants/AndroidSenseConstants.java | 2 + .../pom.xml | 4 + .../arduino/service/impl/ArduinoService.java | 77 ++++++++++++-- .../impl/constants/ArduinoConstants.java | 2 + .../pom.xml | 6 +- .../service/impl/RaspberryPiService.java | 60 +++++++++-- .../impl/constants/RaspberrypiConstants.java | 2 + .../pom.xml | 6 +- .../service/impl/VirtualFireAlarmService.java | 62 +++++++++-- .../DeviceManagementAdminService.java | 100 +++++++++--------- .../services/DeviceManagementService.java | 16 +-- .../DeviceTypeConfigurationService.java | 12 +-- .../services/EventReceiverService.java | 6 +- .../pom.xml | 9 ++ .../api/services/ConfigurationMgtService.java | 12 +-- .../DeviceManagementAdminService.java | 20 ++-- .../api/services/authbst/BSTProvider.java | 4 +- 19 files changed, 370 insertions(+), 123 deletions(-) diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/pom.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/pom.xml index 1cf3ce06ad..4a4a2f845c 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/pom.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/pom.xml @@ -153,6 +153,10 @@ org.wso2.carbon.device.mgt.extensions provided + + org.wso2.carbon.devicemgt + org.wso2.carbon.apimgt.annotations + diff --git a/components/device-types/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/device-types/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 6a215bf7c5..dab39be0a7 100644 --- a/components/device-types/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/device-types/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,14 +19,13 @@ package org.wso2.carbon.device.mgt.iot.androidsense.service.impl; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Info; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Extension; -import io.swagger.annotations.Tag; +import io.swagger.annotations.*; import org.wso2.carbon.apimgt.annotations.api.Scope; +import org.wso2.carbon.apimgt.annotations.api.Scopes; +import org.wso2.carbon.device.mgt.iot.androidsense.service.impl.constants.AndroidSenseConstants; import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @SwaggerDefinition( @@ -44,6 +43,16 @@ import javax.ws.rs.core.Response; @Tag(name = "android_sense", description = "") } ) +@Scopes( + scopes = { + @Scope( + name = "Enroll device", + description = "", + key = "perm:android-sense:enroll", + permissions = {"/device-mgt/devices/enroll/android-sense"} + ) + } +) public interface AndroidSenseService { /** @@ -54,7 +63,19 @@ public interface AndroidSenseService { */ @Path("device/{deviceId}/words") @POST - //@Scope(key = "device:android-sense:enroll", name = "", description = "") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Send the key words to the device", + notes = "", + response = Response.class, + tags = "android_sense", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidSenseConstants.SCOPE, value = "perm:android-sense:enroll") + }) + } + ) Response sendKeyWords(@PathParam("deviceId") String deviceId, @QueryParam("keywords") String keywords); /** @@ -65,12 +86,36 @@ public interface AndroidSenseService { */ @Path("device/{deviceId}/words/threshold") @POST - //@Scope(key = "device:android-sense:enroll", name = "", description = "") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Send threshold value to the device", + notes = "", + response = Response.class, + tags = "android_sense", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidSenseConstants.SCOPE, value = "perm:android-sense:enroll") + }) + } + ) Response sendThreshold(@PathParam("deviceId") String deviceId, @QueryParam("threshold") String threshold); @Path("device/{deviceId}/words") @DELETE - //@Scope(key = "device:android-sense:enroll", name = "", description = "") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "DELETE", + value = "Remove key words from the device", + notes = "", + response = Response.class, + tags = "android_sense", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidSenseConstants.SCOPE, value = "perm:android-sense:enroll") + }) + } + ) Response removeKeyWords(@PathParam("deviceId") String deviceId, @QueryParam("words") String words); /** @@ -79,8 +124,20 @@ public interface AndroidSenseService { @Path("stats/{deviceId}/sensors/{sensorName}") @GET @Consumes("application/json") - //@Scope(key = "device:android-sense:enroll", name = "", description = "") @Produces("application/json") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "GET", + value = "Retrieve Sensor data for the device type", + notes = "", + response = Response.class, + tags = "android_sense", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidSenseConstants.SCOPE, value = "perm:android-sense:enroll") + }) + } + ) Response getAndroidSenseDeviceStats(@PathParam("deviceId") String deviceId, @PathParam("sensorName") String sensor, @QueryParam("from") long from, @QueryParam("to") long to); @@ -89,7 +146,19 @@ public interface AndroidSenseService { */ @Path("device/{device_id}/register") @POST - //@Scope(key = "device:android-sense:enroll", name = "", description = "") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Enroll device", + notes = "", + response = Response.class, + tags = "android_sense", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = AndroidSenseConstants.SCOPE, value = "perm:android-sense:enroll") + }) + } + ) Response register(@PathParam("device_id") String deviceId, @QueryParam("deviceName") String deviceName); } diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/constants/AndroidSenseConstants.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/constants/AndroidSenseConstants.java index e1419844c7..68678d0006 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/constants/AndroidSenseConstants.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/constants/AndroidSenseConstants.java @@ -42,4 +42,6 @@ public class AndroidSenseConstants { public static final String CONFIG_TYPE = "general"; public static final String DEFAULT_ENDPOINT = "tcp://localhost:1886"; + public static final String SCOPE = "scope"; + } diff --git a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/pom.xml b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/pom.xml index 55154f46a7..9b2465e218 100644 --- a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/pom.xml +++ b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/pom.xml @@ -141,6 +141,10 @@ org.wso2.carbon.analytics.api provided + + org.wso2.carbon.devicemgt + org.wso2.carbon.apimgt.annotations + diff --git a/components/device-types/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/device-types/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 1dd0500134..3ed382479a 100644 --- a/components/device-types/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/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoService.java @@ -18,15 +18,14 @@ package org.wso2.carbon.device.mgt.iot.arduino.service.impl; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Info; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Extension; -import io.swagger.annotations.Tag; +import io.swagger.annotations.*; import org.wso2.carbon.apimgt.annotations.api.Scope; +import org.wso2.carbon.apimgt.annotations.api.Scopes; +import org.wso2.carbon.device.mgt.iot.arduino.service.impl.constants.ArduinoConstants; import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @SwaggerDefinition( @@ -44,26 +43,72 @@ import javax.ws.rs.core.Response; @Tag(name = "arduino", description = "") } ) +@Scopes( + scopes = { + @Scope( + name = "Enroll device", + description = "", + key = "perm:arduino:enroll", + permissions = {"/device-mgt/devices/enroll/arduino"} + ) + } +) public interface ArduinoService { @Path("device/{deviceId}/bulb") @POST - //@Scope(key = "device:arduino:enroll", name = "", description = "") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Switch bulb", + notes = "", + response = Response.class, + tags = "arduino", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = ArduinoConstants.SCOPE, value = "perm:arduino:enroll") + }) + } + ) Response switchBulb(@PathParam("deviceId") String deviceId, @QueryParam("state") String state); @Path("device/{deviceId}/controls") @GET - //@Scope(key = "device:arduino:enroll", name = "", description = "") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Read controls", + notes = "", + response = Response.class, + tags = "arduino", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = ArduinoConstants.SCOPE, value = "perm:arduino:enroll") + }) + } + ) Response readControls(@PathParam("deviceId") String deviceId); /** - * Retreive Sensor data for the device type + * Retrieve Sensor data for the device type */ @Path("device/stats/{deviceId}") @GET @Consumes("application/json") @Produces("application/json") - //@Scope(key = "device:arduino:enroll", name = "", description = "") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Retrieve Sensor data for the device type", + notes = "", + response = Response.class, + tags = "arduino", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = ArduinoConstants.SCOPE, value = "perm:arduino:enroll") + }) + } + ) Response getArduinoTemperatureStats(@PathParam("deviceId") String deviceId, @QueryParam("from") long from, @QueryParam("to") long to); @@ -73,7 +118,19 @@ public interface ArduinoService { @Path("device/download") @GET @Produces("application/octet-stream") - //@Scope(key = "device:arduino:enroll", name = "", description = "") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Download device agent", + notes = "", + response = Response.class, + tags = "arduino", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = ArduinoConstants.SCOPE, value = "perm:arduino:enroll") + }) + } + ) Response downloadSketch(@QueryParam("deviceName") String customDeviceName); } diff --git a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/constants/ArduinoConstants.java b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/constants/ArduinoConstants.java index ebf84d9ea9..4f3a042c9a 100644 --- a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/constants/ArduinoConstants.java +++ b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/constants/ArduinoConstants.java @@ -27,4 +27,6 @@ public class ArduinoConstants { public static final String APIM_APPLICATION_TOKEN_VALIDITY_PERIOD = "3600"; + public static final String SCOPE = "scope"; + } diff --git a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/pom.xml b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/pom.xml index 8df74b2f26..ddae87c220 100644 --- a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/pom.xml +++ b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/pom.xml @@ -121,7 +121,11 @@ org.wso2.carbon.device.mgt.extensions provided - + + org.wso2.carbon.devicemgt + org.wso2.carbon.apimgt.annotations + + diff --git a/components/device-types/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/device-types/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 816f3e6b9a..1f227e630e 100644 --- a/components/device-types/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/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiService.java @@ -18,12 +18,10 @@ package org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Info; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Extension; -import io.swagger.annotations.Tag; +import io.swagger.annotations.*; import org.wso2.carbon.apimgt.annotations.api.Scope; +import org.wso2.carbon.apimgt.annotations.api.Scopes; +import org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl.constants.RaspberrypiConstants; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; @@ -44,11 +42,33 @@ import javax.ws.rs.core.Response; @Tag(name = "raspberrypi", description = "") } ) +@Scopes( + scopes = { + @Scope( + name = "Enroll device", + description = "", + key = "perm:raspberrypi:enroll", + permissions = {"/device-mgt/devices/enroll/raspberrypi"} + ) + } +) public interface RaspberryPiService { @Path("device/{deviceId}/bulb") @POST - //@Scope(key = "device:raspberrypi:enroll", name = "", description = "") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Switch bulb", + notes = "", + response = Response.class, + tags = "raspberrypi", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = RaspberrypiConstants.SCOPE, value = "perm:raspberrypi:enroll") + }) + } + ) Response switchBulb(@PathParam("deviceId") String deviceId, @QueryParam("state") String state); /** @@ -58,7 +78,19 @@ public interface RaspberryPiService { @GET @Consumes("application/json") @Produces("application/json") - //@Scope(key = "device:raspberrypi:enroll", name = "", description = "") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Retreive Sensor data for the device type", + notes = "", + response = Response.class, + tags = "raspberrypi", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = RaspberrypiConstants.SCOPE, value = "perm:raspberrypi:enroll") + }) + } + ) Response getRaspberryPiTemperatureStats(@PathParam("deviceId") String deviceId, @QueryParam("from") long from, @QueryParam("to") long to); @@ -68,7 +100,19 @@ public interface RaspberryPiService { @Path("device/download") @GET @Produces(MediaType.APPLICATION_JSON) - //@Scope(key = "device:raspberrypi:enroll", name = "", description = "") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Download the agent.", + notes = "", + response = Response.class, + tags = "raspberrypi", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = RaspberrypiConstants.SCOPE, value = "perm:raspberrypi:enroll") + }) + } + ) Response downloadSketch(@QueryParam("deviceName") String deviceName, @QueryParam("sketch_type") String sketchType); } diff --git a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/constants/RaspberrypiConstants.java b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/constants/RaspberrypiConstants.java index 168cb7d6d3..00919d6f6b 100644 --- a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/constants/RaspberrypiConstants.java +++ b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/constants/RaspberrypiConstants.java @@ -33,4 +33,6 @@ public class RaspberrypiConstants { public static final String APIM_APPLICATION_TOKEN_VALIDITY_PERIOD = "3600"; + public static final String SCOPE = "scope"; + } diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/pom.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/pom.xml index 59ccc4a793..6c9cc0636a 100644 --- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/pom.xml +++ b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/pom.xml @@ -240,7 +240,11 @@ org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin provided - + + org.wso2.carbon.devicemgt + org.wso2.carbon.apimgt.annotations + + diff --git a/components/device-types/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/device-types/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 62be0f612f..6585280f0e 100644 --- a/components/device-types/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/device-types/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 @@ -18,14 +18,12 @@ package org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Info; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Extension; -import io.swagger.annotations.Tag; +import io.swagger.annotations.*; import org.wso2.carbon.apimgt.annotations.api.Scope; +import org.wso2.carbon.apimgt.annotations.api.Scopes; import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; /** @@ -50,8 +48,20 @@ import javax.ws.rs.core.Response; @Tag(name = "virtual_firealarm", description = "") } ) +@Scopes( + scopes = { + @Scope( + name = "Enroll device", + description = "", + key = "perm:firealarm:enroll", + permissions = {"/device-mgt/devices/enroll/firealarm"} + ) + } +) public interface VirtualFireAlarmService { + String SCOPE = "scope"; + /** * This is an API called/used from within the Server(Front-End) or by a device Owner. It sends a control command to * the VirtualFirealarm device to switch `ON` or `OFF` its buzzer. The method also takes in the protocol to be used @@ -63,7 +73,19 @@ public interface VirtualFireAlarmService { */ @POST @Path("device/{deviceId}/buzz") - //@Scope(key = "device:firealarm:enroll", name = "", description = "") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Switch Buzzer", + notes = "", + response = Response.class, + tags = "virtual_firealarm", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = SCOPE, value = "perm:firealarm:enroll") + }) + } + ) Response switchBuzzer(@PathParam("deviceId") String deviceId, @FormParam("state") String state); @@ -72,7 +94,19 @@ public interface VirtualFireAlarmService { */ @Path("device/stats/{deviceId}") @GET - //@Scope(key = "device:firealarm:enroll", name = "", description = "") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "GET", + value = "Retrieve Sensor data for the device type", + notes = "", + response = Response.class, + tags = "virtual_firealarm", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = SCOPE, value = "perm:firealarm:enroll") + }) + } + ) @Consumes("application/json") @Produces("application/json") Response getVirtualFirealarmStats(@PathParam("deviceId") String deviceId, @QueryParam("from") long from, @@ -81,7 +115,19 @@ public interface VirtualFireAlarmService { @Path("device/download") @GET @Produces("application/zip") - //@Scope(key = "device:firealarm:enroll", name = "", description = "") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "GET", + value = "Download agent", + notes = "", + response = Response.class, + tags = "virtual_firealarm", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = SCOPE, value = "perm:firealarm:enroll") + }) + } + ) Response downloadSketch(@QueryParam("deviceName") String deviceName, @QueryParam("sketchType") String sketchType); } 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 d752a30779..9094a28a25 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 @@ -70,151 +70,151 @@ import java.util.List; @Scope( name = "Lock Device", description = "Hard lock own device", - key = "cdmf:android:lock-devices", + key = "perm:android:lock-devices", permissions = {"/device-mgt/devices/owning-device/operations/android/lock"} ), @Scope( name = "Unlock Device", description = "Unlock permanently locked device", - key = "cdmf:android:unlock-devices", + key = "perm:android:unlock-devices", permissions = {"/device-mgt/devices/owning-device/operations/android/unlock"} ), @Scope( name = "Get Location", description = "Request device location coordinates", - key = "cdmf:android:location", + key = "perm:android:location", permissions = {"/device-mgt/devices/owning-device/operations/android/location"} ), @Scope( name = "Clear Password", description = "Clear the password on Android devices", - key = "cdmf:android:clear-password", + key = "perm:android:clear-password", permissions = {"/device-mgt/devices/owning-device/operations/android/clear-password"} ), @Scope( name = "Control Camera", description = "Enabling or Disabling the Camera on Android Devices", - key = "cdmf:android:control-camera", + key = "perm:android:control-camera", permissions = {"/device-mgt/devices/owning-device/operations/android/camera"} ), @Scope( name = "Get Info", description = "Requesting device information from Android Devices", - key = "cdmf:android:info", + key = "perm:android:info", permissions = {"/device-mgt/devices/owning-device/operations/android/info"} ), @Scope( name = "Get Logs", description = "Requesting Logcat Details from Android Devices", - key = "cdmf:android:logcat", + key = "perm:android:logcat", permissions = {"/device-mgt/devices/owning-device/operations/android/logcat"} ), @Scope( name = "Enterprise Wipe", description = "Enterprise Wiping Android Devices", - key = "cdmf:android:enterprise-wipe", + key = "perm:android:enterprise-wipe", permissions = {"/device-mgt/devices/owning-device/operations/android/enterprise-wipe"} ), @Scope( name = "Factory Reset", description = "Factory Resetting Android Devices", - key = "cdmf:android:wipe", + key = "perm:android:wipe", permissions = {"/device-mgt/devices/owning-device/operations/android/wipe"} ), @Scope( name = "Get Installed Applications", description = "Get list of installed applications", - key = "cdmf:android:applications", + key = "perm:android:applications", permissions = {"/device-mgt/devices/owning-device/operations/android/applications"} ), @Scope( name = "Ring Device", description = "Ring Android devices", - key = "cdmf:android:ring", + key = "perm:android:ring", permissions = {"/device-mgt/devices/owning-device/operations/android/ring"} ), @Scope( name = "Reboot Device", description = "Reboot Android devices", - key = "cdmf:android:reboot", + key = "perm:android:reboot", permissions = {"/device-mgt/devices/owning-device/operations/android/reboot"} ), @Scope( name = "Mute Device", description = "Mute Android devices", - key = "cdmf:android:mute", + key = "perm:android:mute", permissions = {"/device-mgt/devices/owning-device/operations/android/mute"} ), @Scope( name = "Install Applications", description = "Installing an Application on Android Devices", - key = "cdmf:android:install-application", + key = "perm:android:install-application", permissions = {"/device-mgt/devices/owning-device/operations/android/install-app"} ), @Scope( name = "Update Applications", description = "Updating an Application on Android Devices", - key = "cdmf:android:update-application", + key = "perm:android:update-application", permissions = {"/device-mgt/devices/owning-device/operations/android/update-app"} ), @Scope( name = "Uninstall Applications", description = "Uninstalling an Application on Android Devices", - key = "cdmf:android:uninstall-application", + key = "perm:android:uninstall-application", permissions = {"/device-mgt/devices/owning-device/operations/android/uninstall-app"} ), @Scope( name = "Blacklist Applications", description = "Blacklisting applications on Android Devices", - key = "cdmf:android:blacklist-applications", + key = "perm:android:blacklist-applications", permissions = {"/device-mgt/devices/owning-device/operations/android/blacklist-app"} ), @Scope( name = "Upgrade Firmware", description = "Upgrading Firmware of Android Devices", - key = "cdmf:android:upgrade-firmware", + key = "perm:android:upgrade-firmware", permissions = {"/device-mgt/devices/owning-device/operations/android/upgrade"} ), @Scope( name = "Configure VPN", description = "Configure VPN on Android Device", - key = "cdmf:android:configure-vpn", + key = "perm:android:configure-vpn", permissions = {"/device-mgt/devices/owning-device/operations/android/vpn"} ), @Scope( name = "Send Notification", description = "Sending a notification to Android Device", - key = "cdmf:android:send-notification", + key = "perm:android:send-notification", permissions = {"/device-mgt/devices/owning-device/operations/android/send-notification"} ), @Scope( name = "Configure Wi-Fi", description = "Configure Wi-Fi on Android Device", - key = "cdmf:android:configure-wifi", + key = "perm:android:configure-wifi", permissions = {"/device-mgt/devices/owning-device/operations/android/wifi"} ), @Scope( name = "Encrypt Storage", description = "Encrypting storage on Android Device", - key = "cdmf:android:encrypt-storage", + key = "perm:android:encrypt-storage", permissions = {"/device-mgt/devices/owning-device/operations/android/encrypt"} ), @Scope( name = "Change Password", description = "Changing the lock code of an Android Device", - key = "cdmf:android:change-lock-code", + key = "perm:android:change-lock-code", permissions = {"/device-mgt/devices/owning-device/operations/android/change-lock-code"} ), @Scope( name = "Password Policy", description = "Set password policy of an Android Device", - key = "cdmf:android:set-password-policy", + key = "perm:android:set-password-policy", permissions = {"/device-mgt/devices/owning-device/operations/android/password-policy"} ), @Scope( name = "Add Web clip", description = "Setting a Web Clip on Android Devices", - key = "cdmf:android:set-webclip", + key = "perm:android:set-webclip", permissions = {"/device-mgt/devices/owning-device/operations/android/webclip"} ) } @@ -233,7 +233,7 @@ public interface DeviceManagementAdminService { tags = "Android Device Management Administrative Service", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:lock-devices") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:lock-devices") }) } ) @@ -296,7 +296,7 @@ public interface DeviceManagementAdminService { tags = "Android Device Management Administrative Service", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:unlock-devices") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:unlock-devices") }) } ) @@ -359,7 +359,7 @@ public interface DeviceManagementAdminService { tags = "Android Device Management Administrative Service", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:location") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:location") }) } ) @@ -418,7 +418,7 @@ public interface DeviceManagementAdminService { tags = "Android Device Management Administrative Service.", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:clear-password") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:clear-password") }) } ) @@ -476,7 +476,7 @@ public interface DeviceManagementAdminService { tags = "Android Device Management Administrative Service", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:control-camera") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:control-camera") }) } ) @ApiResponses(value = { @@ -541,7 +541,7 @@ public interface DeviceManagementAdminService { tags = "Android Device Management Administrative Service", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:info") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:info") }) } ) @@ -604,7 +604,7 @@ public interface DeviceManagementAdminService { tags = "Android Device Management Administrative Service", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:logcat") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:logcat") }) } ) @@ -666,7 +666,7 @@ public interface DeviceManagementAdminService { tags = "Android Device Management Administrative Service", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:enterprise-wipe") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:enterprise-wipe") }) } ) @@ -726,7 +726,7 @@ public interface DeviceManagementAdminService { tags = "Android Device Management Administrative Service", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:wipe") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:wipe") }) } ) @@ -790,7 +790,7 @@ public interface DeviceManagementAdminService { tags = "Android Device Management Administrative Service", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:applications") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:applications") }) } ) @@ -850,7 +850,7 @@ public interface DeviceManagementAdminService { tags = "Android Device Management Administrative Service", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:ring") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:ring") }) } ) @@ -910,7 +910,7 @@ public interface DeviceManagementAdminService { tags = "Android Device Management Administrative Service", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:reboot") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:reboot") }) } ) @@ -970,7 +970,7 @@ public interface DeviceManagementAdminService { tags = "Android Device Management Administrative Service", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:mute") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:mute") }) } ) @@ -1032,7 +1032,7 @@ public interface DeviceManagementAdminService { tags = "Android Device Management Administrative Service", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:install-application") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:install-application") }) } ) @@ -1097,7 +1097,7 @@ public interface DeviceManagementAdminService { tags = "Android Device Management Administrative Service", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:update-application") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:update-application") }) } ) @@ -1159,7 +1159,7 @@ public interface DeviceManagementAdminService { tags = "Android Device Management Administrative Service", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:uninstall-application") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:uninstall-application") }) } ) @@ -1225,7 +1225,7 @@ public interface DeviceManagementAdminService { tags = "Android Device Management Administrative Service", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:blacklist-applications") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:blacklist-applications") }) } ) @@ -1287,7 +1287,7 @@ public interface DeviceManagementAdminService { tags = "Android Device Management Administrative Service", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:upgrade-firmware") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:upgrade-firmware") }) } ) @@ -1351,7 +1351,7 @@ public interface DeviceManagementAdminService { tags = "Android Device Management Administrative Service", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:configure-vpn") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:configure-vpn") }) } ) @@ -1411,7 +1411,7 @@ public interface DeviceManagementAdminService { tags = "Android Device Management Administrative Service", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:send-notification") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:send-notification") }) } ) @@ -1472,7 +1472,7 @@ public interface DeviceManagementAdminService { tags = "Android Device Management Administrative Service", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:configure-wifi") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:configure-wifi") }) } ) @@ -1534,7 +1534,7 @@ public interface DeviceManagementAdminService { tags = "Android Device Management Administrative Service", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:encrypt-storage") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:encrypt-storage") }) } ) @@ -1596,7 +1596,7 @@ public interface DeviceManagementAdminService { tags = "Android Device Management Administrative Service", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:change-lock-code") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:change-lock-code") }) } ) @@ -1658,7 +1658,7 @@ public interface DeviceManagementAdminService { tags = "Android Device Management Administrative Service", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:set-password-policy") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:set-password-policy") }) } ) @@ -1718,7 +1718,7 @@ public interface DeviceManagementAdminService { tags = "Android Device Management Administrative Service", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:set-webclip") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:set-webclip") }) } ) 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 777c9582bc..62194a1481 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 @@ -69,13 +69,13 @@ import java.util.List; @Scope( name = "Enroll Device", description = "Register an Android device", - key = "cdmf:android:enroll", + key = "perm:android:enroll", permissions = {"/device-mgt/devices/enroll/android"} ), @Scope( name = "Un-enroll Device", description = "Unregister an Android device", - key = "cdmf:android:disenroll", + key = "perm:android:disenroll", permissions = {"/device-mgt/devices/disenroll/android"} ) } @@ -93,7 +93,7 @@ public interface DeviceManagementService { tags = "Android Device Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:enroll") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:enroll") }) } ) @@ -158,7 +158,7 @@ public interface DeviceManagementService { tags = "Android Device Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:enroll") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:enroll") }) } ) @@ -222,7 +222,7 @@ public interface DeviceManagementService { tags = "Android Device Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:enroll") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:enroll") }) } ) @@ -277,7 +277,7 @@ public interface DeviceManagementService { tags = "Android Device Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:enroll") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:enroll") }) } ) @@ -330,7 +330,7 @@ public interface DeviceManagementService { tags = "Android Device Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:enroll") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:enroll") }) } ) @@ -386,7 +386,7 @@ public interface DeviceManagementService { tags = "Android Device Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:disenroll") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:disenroll") }) } ) 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 09a731df4d..de9ccb1808 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 @@ -67,19 +67,19 @@ import javax.ws.rs.core.Response; @Scope( name = "Enroll Device", description = "Register an Android device", - key = "cdmf:android:enroll", + key = "perm:android:enroll", permissions = {"/device-mgt/devices/enroll/android"} ), @Scope( name = "View Configurations", description = "Getting Android Platform Configurations", - key = "cdmf:android:view-configuration", + key = "perm:android:view-configuration", permissions = {"/device-mgt/platform-configurations/view"} ), @Scope( name = "Manage Configurations", description = "Updating Android Platform Configurations", - key = "cdmf:android:manage-configuration", + key = "perm:android:manage-configuration", permissions = {"/device-mgt/platform-configurations/manage"} ) } @@ -96,7 +96,7 @@ public interface DeviceTypeConfigurationService { tags = "Android Configuration Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:view-configuration") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:view-configuration") }) } ) @@ -150,7 +150,7 @@ public interface DeviceTypeConfigurationService { tags = "Android Configuration Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:manage-configuration") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:manage-configuration") }) } ) @@ -205,7 +205,7 @@ public interface DeviceTypeConfigurationService { tags = "Android Configuration Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:enroll") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:enroll") }) } ) 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 89e8dd44c9..d24b7afa73 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 @@ -67,7 +67,7 @@ import javax.ws.rs.core.Response; @Scope( name = "Enroll Device", description = "Register an Android device", - key = "cdmf:android:enroll", + key = "perm:android:enroll", permissions = {"/device-mgt/devices/enroll/android"} ) } @@ -85,7 +85,7 @@ public interface EventReceiverService { tags = "Event Receiver", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:enroll") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:enroll") }) } ) @@ -148,7 +148,7 @@ public interface EventReceiverService { tags = "Event Receiver", extensions = { @Extension(properties = { - @ExtensionProperty(name = AndroidConstants.SCOPE, value = "cdmf:android:enroll") + @ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:enroll") }) } ) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/pom.xml b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/pom.xml index 53533a75c6..e0ba6a441a 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/pom.xml +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/pom.xml @@ -372,5 +372,14 @@ + + org.wso2.carbon.devicemgt + org.wso2.carbon.apimgt.annotations + + + org.wso2.carbon.devicemgt + org.wso2.carbon.apimgt.annotations + 2.0.3-SNAPSHOT + diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/ConfigurationMgtService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/ConfigurationMgtService.java index 5b69ba25d7..8bb90b1958 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/ConfigurationMgtService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/ConfigurationMgtService.java @@ -76,19 +76,19 @@ import javax.ws.rs.core.Response; @Scope( name = "Enroll Device", description = "Register an Windows device", - key = "cdmf:windows:enroll", + key = "perm:windows:enroll", permissions = {"/device-mgt/devices/enroll/windows"} ), @Scope( name = "View Configurations", description = "Getting Windows Platform Configurations", - key = "cdmf:windows:view-configuration", + key = "perm:windows:view-configuration", permissions = {"/device-mgt/platform-configurations/view"} ), @Scope( name = "Manage Configurations", description = "Updating Windows Platform Configurations", - key = "cdmf:windows:manage-configuration", + key = "perm:windows:manage-configuration", permissions = {"/device-mgt/platform-configurations/manage"} ) } @@ -105,7 +105,7 @@ public interface ConfigurationMgtService { tags = "Windows Configuration Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:view-configuration") + @ExtensionProperty(name = Constants.SCOPE, value = "perm:windows:view-configuration") }) } ) @@ -164,7 +164,7 @@ public interface ConfigurationMgtService { tags = "Windows Configuration Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:manage-configuration") + @ExtensionProperty(name = Constants.SCOPE, value = "perm:windows:manage-configuration") }) } ) @@ -220,7 +220,7 @@ public interface ConfigurationMgtService { tags = "Windows Configuration Management", extensions = { @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:enroll") + @ExtensionProperty(name = Constants.SCOPE, value = "perm:windows:enroll") }) } ) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java index c054f821f8..288378dd92 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java @@ -69,31 +69,31 @@ import java.util.List; @Scope( name = "Lock Device", description = "Adding a Device Lock on Windows devices.", - key = "cdmf:windows:lock-devices", + key = "perm:windows:lock-devices", permissions = {"/device-mgt/devices/owning-device/operations/windows/lock"} ), @Scope( name = "Un-enroll Device", description = "Unregister an Windows device", - key = "cdmf:windows:disenroll", + key = "perm:windows:disenroll", permissions = {"/device-mgt/devices/disenroll/windows"} ), @Scope( name = "Factory Reset", description = "Factory Resetting Windows Devices", - key = "cdmf:windows:wipe", + key = "perm:windows:wipe", permissions = {"/device-mgt/devices/owning-device/operations/windows/wipe"} ), @Scope( name = "Ring Device", description = "Ring Windows devices", - key = "cdmf:windows:ring", + key = "perm:windows:ring", permissions = {"/device-mgt/devices/owning-device/operations/windows/ring"} ), @Scope( name = "Lock Reset", description = "Lock reset on Windows devices", - key = "cdmf:windows:lock-reset", + key = "perm:windows:lock-reset", permissions = {"/device-mgt/devices/owning-device/operations/windows/lock-reset"} ) } @@ -111,7 +111,7 @@ public interface DeviceManagementAdminService { tags = "Windows Device Management Administrative Service", extensions = { @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:lock-devices") + @ExtensionProperty(name = Constants.SCOPE, value = "perm:windows:lock-devices") }) } ) @@ -170,7 +170,7 @@ public interface DeviceManagementAdminService { tags = "Windows Device Management Administrative Service.", extensions = { @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:disenroll") + @ExtensionProperty(name = Constants.SCOPE, value = "perm:windows:disenroll") }) } ) @@ -231,7 +231,7 @@ public interface DeviceManagementAdminService { tags = "Windows Device Management Administrative Service", extensions = { @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:wipe") + @ExtensionProperty(name = Constants.SCOPE, value = "perm:windows:wipe") }) } ) @@ -289,7 +289,7 @@ public interface DeviceManagementAdminService { tags = "Windows Device Management Administrative Service", extensions = { @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:ring") + @ExtensionProperty(name = Constants.SCOPE, value = "perm:windows:ring") }) } ) @@ -348,7 +348,7 @@ public interface DeviceManagementAdminService { tags = "Windows Device Management Administrative Service", extensions = { @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:lock-reset") + @ExtensionProperty(name = Constants.SCOPE, value = "perm:windows:lock-reset") }) } ) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/authbst/BSTProvider.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/authbst/BSTProvider.java index 5b55a8ed07..7926260f22 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/authbst/BSTProvider.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/authbst/BSTProvider.java @@ -65,7 +65,7 @@ import javax.ws.rs.core.Response; @Scope( name = "Enroll Device", description = "Register Windows device", - key = "cdmf:windows:enroll", + key = "perm:windows:enroll", permissions = {"/device-mgt/devices/enroll/windows"} ) } @@ -84,7 +84,7 @@ public interface BSTProvider { tags = "BST Provider", extensions = { @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "cdmf:windows:enroll") + @ExtensionProperty(name = Constants.SCOPE, value = "perm:windows:enroll") }) } ) From cff23fe7aa383c6f019a9e1287e056392412d25c Mon Sep 17 00:00:00 2001 From: dunithd Date: Fri, 6 Jan 2017 11:11:22 +0530 Subject: [PATCH 09/28] Adding Geo Dashboard link for Arduino and RaspberryPi devices --- .../device-view.hbs | 16 ++++++++++++++++ .../device-view.js | 9 ++++++++- .../device-view.hbs | 16 ++++++++++++++++ .../device-view.js | 9 ++++++++- 4 files changed, 48 insertions(+), 2 deletions(-) diff --git a/components/device-types/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.hbs b/components/device-types/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.hbs index 182c043a13..8911ee7485 100644 --- a/components/device-types/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.hbs +++ b/components/device-types/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.hbs @@ -75,4 +75,20 @@ + {{/zone}} \ No newline at end of file diff --git a/components/device-types/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/device-types/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 c3863813b2..5da6f194bf 100644 --- a/components/device-types/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/device-types/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 @@ -28,7 +28,14 @@ function onRequest(context) { var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var device = deviceModule.viewDevice(deviceType, deviceId); if (device && device.status != "error") { - return {"device": device.content, "autoCompleteParams" : autoCompleteParams, "encodedFeaturePayloads": ""}; + var anchor = { "device" : { "id" : device.content.deviceIdentifier, "type" : device.content.type}}; + return { + "device": device.content, + "autoCompleteParams" : autoCompleteParams, + "encodedFeaturePayloads": "", + "portalUrl" : devicemgtProps['portalURL'], + "anchor" : JSON.stringify(anchor) + }; } else { response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!"); exit(); diff --git a/components/device-types/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.hbs b/components/device-types/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.hbs index 9c12567b1d..62d9e2d9db 100644 --- a/components/device-types/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.hbs +++ b/components/device-types/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.hbs @@ -75,4 +75,20 @@ + {{/zone}} \ No newline at end of file diff --git a/components/device-types/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/device-types/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 c3863813b2..5da6f194bf 100644 --- a/components/device-types/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/device-types/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 @@ -28,7 +28,14 @@ function onRequest(context) { var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var device = deviceModule.viewDevice(deviceType, deviceId); if (device && device.status != "error") { - return {"device": device.content, "autoCompleteParams" : autoCompleteParams, "encodedFeaturePayloads": ""}; + var anchor = { "device" : { "id" : device.content.deviceIdentifier, "type" : device.content.type}}; + return { + "device": device.content, + "autoCompleteParams" : autoCompleteParams, + "encodedFeaturePayloads": "", + "portalUrl" : devicemgtProps['portalURL'], + "anchor" : JSON.stringify(anchor) + }; } else { response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!"); exit(); From 22a58121d215c2a4974413679b2388fb68e72f89 Mon Sep 17 00:00:00 2001 From: inoshperera Date: Fri, 6 Jan 2017 11:38:09 +0530 Subject: [PATCH 10/28] changing the Andrid API tag to standerdise --- .../services/android/services/DeviceManagementAdminService.java | 2 +- .../mdm/services/android/services/DeviceManagementService.java | 2 +- .../android/services/DeviceTypeConfigurationService.java | 2 +- .../mdm/services/android/services/EventReceiverService.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) 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 e24f6fbfad..4386ca5cc4 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 @@ -57,7 +57,7 @@ import java.util.List; } ), tags = { - @Tag(name = "devicemgt_android", description = "") + @Tag(name = "android", description = "") } ) @Path("/admin/devices") 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 4bf71b564a..cf1ba24316 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 @@ -64,7 +64,7 @@ import java.util.List; } ), tags = { - @Tag(name = "devicemgt_android", description = "") + @Tag(name = "android", description = "") } ) @Api(value = "Android Device Management", 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 3eab30e353..9b005bab7f 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 @@ -54,7 +54,7 @@ import javax.ws.rs.core.Response; } ), tags = { - @Tag(name = "devicemgt_android", description = "") + @Tag(name = "android", description = "") } ) @Api(value = "Android Configuration Management", description = "This API carries all the resource used to mange the Android platform configurations.") 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 744655768d..c2278ffa58 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 @@ -52,7 +52,7 @@ import javax.ws.rs.core.Response; } ), tags = { - @Tag(name = "devicemgt_android", description = "") + @Tag(name = "android", description = "") } ) @Api(value = "Event Receiver", description = "Event publishing/retrieving related APIs. To enable event publishing/retrieving you need to" + From 223a973cda441fe23b9e3b51f47658b65e594abe Mon Sep 17 00:00:00 2001 From: Hasunie Date: Fri, 6 Jan 2017 14:12:14 +0530 Subject: [PATCH 11/28] adding Windows 10 location support --- .../windows/api/common/PluginConstants.java | 7 ++ .../api/common/util/WindowsAPIUtils.java | 13 ++++ .../api/operations/util/OperationCode.java | 9 ++- .../api/operations/util/OperationHandler.java | 76 +++++++++++++++++-- .../api/operations/util/OperationReply.java | 22 +++++- .../device-view.js | 67 ---------------- .../enrollments/windows/agent-controller.jag | 2 +- .../enrollments/windows/agent-enroll.jag | 2 +- .../main/resources/devicetypes/windows.xml | 50 +++++++++--- 9 files changed, 155 insertions(+), 93 deletions(-) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/PluginConstants.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/PluginConstants.java index 92573902d9..b44bee0374 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/PluginConstants.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/PluginConstants.java @@ -218,6 +218,8 @@ public final class PluginConstants { public static final String BATTERY_CHARGE_REMAINING = "BATTERY_CHARGE_REMAINING"; public static final String BATTERY_ESTIMATED_RUNTIME = "BATTERY_ESTIMATED_RUNTIME"; public static final String MOBILE_ID = "MOBILE_ID"; + public static final String LONGITUDE = "LONGITUDE"; + public static final String LATITUDE = "LATITUDE"; } @@ -267,6 +269,11 @@ public final class PluginConstants { public static final String DEVICE_PASSWORD_STATUS = "DEVICE_PASSWORD_STATUS"; public static final String DEVICE_PASSCODE_DELETE = "DEVICE_PASSCODE_DELETE"; public static final String DEVICE_INFO = "DEVICE_INFO"; + public static final String POLICY_REVOKE = "POLICY_REVOKE"; + public static final String DEVICE_LOCATION = "DEVICE_LOCATION"; + public static final String LONGITUDE = "LONGITUDE"; + public static final String LATITUDE = "LATITUDE"; + public static final String DEVICE_REBOOT = "DEVICE_REBOOT"; } /** diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/util/WindowsAPIUtils.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/util/WindowsAPIUtils.java index 274c7ffaef..dd5b435bac 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/util/WindowsAPIUtils.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/common/util/WindowsAPIUtils.java @@ -29,6 +29,7 @@ import org.wso2.carbon.device.mgt.common.InvalidDeviceException; import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo; +import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService; import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; @@ -239,4 +240,16 @@ public class WindowsAPIUtils { (DeviceInformationManager) ctx.getOSGiService(DeviceInformationManager.class, null); informationManager.addDeviceInfo(deviceId, deviceInfo); } + + /** + * This method is used to update device location. + * @param deviceLocation Device coordination related information. + * @throws DeviceDetailsMgtException Error occurs while updating Device location. + */ + public static void updateDeviceLocation(DeviceLocation deviceLocation) throws DeviceDetailsMgtException { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + DeviceInformationManager informationManager = + (DeviceInformationManager) ctx.getOSGiService(DeviceInformationManager.class, null); + informationManager.addDeviceLocation(deviceLocation); + } } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/OperationCode.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/OperationCode.java index 8ba4b44162..60547fa5e4 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/OperationCode.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/OperationCode.java @@ -43,8 +43,6 @@ public class OperationCode { ENCRYPT_STORAGE_STATUS("./Vendor/MSFT/PolicyManager/Device/Security/RequireDeviceEncryption"), DEVICE_PASSWORD_STATUS("./Vendor/MSFT/PolicyManager/Device/DeviceLock/DevicePasswordEnabled"), DEVICE_PASSCODE_DELETE("./Vendor/MSFT/PolicyManager/My/DeviceLock"), - LONGITUDE("./Vendor/MSFT/RemoteFind/Location/Longitude"), - LATITUDE("./Vendor/MSFT/RemoteFind/Location/Latitude"), // Windows10 operation codes TOTAL_RAM("./DevDetail/Ext/Microsoft/TotalRAM"), @@ -56,6 +54,8 @@ public class OperationCode { BATTERY_STATUS("./Vendor/MSFT/DeviceStatus/Battery/Status"), BATTERY_CHARGE_REMAINING("./Vendor/MSFT/DeviceStatus/Battery/EstimatedChargeRemaining"), BATTERY_ESTIMATED_RUNTIME("./Vendor/MSFT/DeviceStatus/Battery/EstimatedRuntime"), + LONGITUDE("./Vendor/MSFT/RemoteFind/Location/Longitude"), + LATITUDE("./Vendor/MSFT/RemoteFind/Location/Latitude"), TEST("./Vendor/MSFT/DiagnosticLog/EtwLog/Collectors"); private final String code; @@ -91,7 +91,10 @@ public class OperationCode { BATTERY_STATUS("./Vendor/MSFT/DeviceStatus/Battery/Status"), BATTERY_CHARGE_REMAINING("./Vendor/MSFT/DeviceStatus/Battery/EstimatedChargeRemaining"), BATTERY_ESTIMATED_RUNTIME("./Vendor/MSFT/DeviceStatus/Battery/EstimatedRuntime"), - TEST("./Vendor/MSFT/DiagnosticLog/EtwLog/Collectors"); + LONGITUDE("./Vendor/MSFT/RemoteFind/Location/Longitude"), + LATITUDE("./Vendor/MSFT/RemoteFind/Location/Latitude"), + TEST("./Vendor/MSFT/DiagnosticLog/EtwLog/Collectors"), + DEVICE_REBOOT("./Vendor/MSFT/Reboot/RebootNow"); private final String code; diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/OperationHandler.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/OperationHandler.java index 8b0db02223..fe07b720b1 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/OperationHandler.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/OperationHandler.java @@ -25,11 +25,13 @@ import org.json.JSONObject; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo; +import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation; import org.wso2.carbon.device.mgt.common.notification.mgt.Notification; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService; 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.device.details.mgt.DeviceDetailsMgtException; import org.wso2.carbon.device.mgt.mobile.windows.api.common.PluginConstants; import org.wso2.carbon.device.mgt.mobile.windows.api.common.util.WindowsAPIUtils; import org.wso2.carbon.device.mgt.mobile.windows.api.services.syncml.beans.Profile; @@ -239,6 +241,33 @@ public class OperationHandler { } } + public void updateDeviceLocationStatus(SyncmlDocument syncmlDocument) throws OperationManagementException { + List pendingDataOperations; + List statuses = syncmlDocument.getBody().getStatus(); + DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject( + syncmlDocument.getHeader().getSource().getLocURI()); + try { + pendingDataOperations = WindowsAPIUtils.getPendingOperations(deviceIdentifier); + } catch (DeviceManagementException e) { + throw new OperationManagementException("Error occurred in getting pending operation."); + } + for (Operation operation : pendingDataOperations) { + if (PluginConstants.OperationCodes.DEVICE_LOCATION.equals(operation.getCode())) { + for (StatusTag statusTag : statuses) { + if (Constants.GET.equals(statusTag.getCommand()) && statusTag.getTargetReference() != null + && OperationCode.Command.LATITUDE.getCode().equals(statusTag.getTargetReference())) { + if (Constants.SyncMLResponseCodes.ACCEPTED.equals(statusTag.getData())) { + operation.setStatus(Operation.Status.COMPLETED); + } else { + operation.setStatus(Operation.Status.ERROR); + } + } + } + updateStatus(syncmlDocument.getHeader().getSource().getLocURI(), + pendingDataOperations); + } + } + } /** * Get pending operations. @@ -253,12 +282,18 @@ public class OperationHandler { SyncmlBody syncmlBody = syncmlDocument.getBody(); List pendingOperations; DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject(syncmlHeader.getSource().getLocURI()); - int sessionId = syncmlHeader.getSessionId(); - int msgId = syncmlHeader.getMsgID(); - if (!(PluginConstants.SyncML.SYNCML_FIRST_MESSAGE_ID == msgId && - PluginConstants.SyncML.SYNCML_FIRST_SESSION_ID == sessionId)) { - if ((syncmlBody.getResults() != null)) { - updateDeviceInfo(syncmlDocument); + List statuses = syncmlBody.getStatus(); + for (StatusTag status : statuses ) { + if (OperationCode.Command.LATITUDE.getCode().equals(status.getTargetReference()) && + Constants.SyncMLResponseCodes.ACCEPTED.equals(status.getData())) { + updateLocation(syncmlDocument); + } + + if (OperationCode.Command.TOTAL_RAM.getCode().equals(status.getTargetReference()) && + Constants.SyncMLResponseCodes.ACCEPTED.equals(status.getData())) { + if ((syncmlBody.getResults() != null)) { + updateDeviceInfo(syncmlDocument); + } } } UpdateUriOperations(syncmlDocument); @@ -568,4 +603,33 @@ public class OperationHandler { throw new WindowsOperationException("Error occurred while updating Device info operation status."); } } + + private void updateLocation(SyncmlDocument syncmlDocument) throws WindowsOperationException { + List deviceInformations = syncmlDocument.getBody().getResults().getItem(); + DeviceIdentifier deviceIdentifier = convertToDeviceIdentifierObject( + syncmlDocument.getHeader().getSource().getLocURI()); + + DeviceLocation deviceLocation = new DeviceLocation(); + deviceLocation.setDeviceIdentifier(deviceIdentifier); + for (ItemTag item : deviceInformations) { + String source = item.getSource().getLocURI(); + if (OperationCode.Info.LONGITUDE.getCode().equals(source)) { + String longitude = item.getData(); + deviceLocation.setLongitude(Double.parseDouble(longitude)); + } + if (OperationCode.Info.LATITUDE.getCode().equals(source)) { + Double latitude = Double.parseDouble(item.getData()); + deviceLocation.setLatitude(latitude); + } + } + try { + WindowsAPIUtils.updateDeviceLocation(deviceLocation); + updateDeviceLocationStatus(syncmlDocument); + } catch (DeviceDetailsMgtException e) { + throw new WindowsOperationException("Error occurred while updating Device Location."); + } catch (OperationManagementException e) { + throw new WindowsOperationException("Error occurred while updating Device Location operation status."); + } + + } } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/OperationReply.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/OperationReply.java index 658e7dc133..c4f28cb402 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/OperationReply.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/operations/util/OperationReply.java @@ -240,7 +240,6 @@ public class OperationReply { List replaceItems = new ArrayList<>(); SequenceTag monitorSequence = new SequenceTag(); List deviceInfoOperations; - if (operations != null) { for (Operation operation : operations) { Operation.Type type = operation.getType(); @@ -293,6 +292,23 @@ public class OperationReply { SequenceTag sequence = buildSequence(operation, sequenceElement); syncmlBody.setSequence(sequence); } + if (PluginConstants.OperationCodes.DEVICE_LOCATION.equals(operation.getCode())) { + Operation longitudeOperation = new Operation(); + Operation latitudeOperation = new Operation(); + longitudeOperation.setCode(PluginConstants.OperationCodes.LONGITUDE); + latitudeOperation.setCode(PluginConstants.OperationCodes.LATITUDE); + List deviceLocationOperations = new ArrayList<>(); + deviceLocationOperations.add(latitudeOperation); + deviceLocationOperations.add(longitudeOperation); + for (Operation infoOperation : deviceLocationOperations) { + ItemTag deviceInfo = appendGetInfo(infoOperation); + getElements.add(deviceInfo); + } + } + if (PluginConstants.OperationCodes.DEVICE_REBOOT.equals(operation.getCode())) { + execElement = executeCommand(operation); + executeElements.add(execElement); + } if ((PluginConstants.OperationCodes.MONITOR.equals(operation.getCode()))) { GetTag monitorGetElement = new GetTag(); List monitorItems; @@ -561,8 +577,7 @@ public class OperationReply { return execElement; } - public SequenceTag buildSequence(Operation operation, SequenceTag sequenceElement) throws - JSONException, + public SequenceTag buildSequence(Operation operation, SequenceTag sequenceElement) throws JSONException, SyncmlOperationException { sequenceElement.setCommandId(operation.getId()); @@ -580,7 +595,6 @@ public class OperationReply { sequenceElement.setExec(execElement); sequenceElement.setGet(getElements); return sequenceElement; - } else if ((PluginConstants.OperationCodes.POLICY_BUNDLE.equals(operation.getCode()))) { List policyOperations; try { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.device-view/device-view.js b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.device-view/device-view.js index d1de7c9600..c5e0619f7a 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.device-view/device-view.js +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.device-view/device-view.js @@ -62,73 +62,6 @@ function onRequest(context) { viewModel["ownership"] = filteredDeviceData["enrolmentInfo"]["ownership"]; } } - if (filteredDeviceData["initialDeviceInfo"]) { - viewModel["deviceInfoAvailable"] = true; - if (filteredDeviceData["initialDeviceInfo"]["IMEI"]) { - viewModel["imei"] = filteredDeviceData["initialDeviceInfo"]["IMEI"]; - } - if (!filteredDeviceData["latestDeviceInfo"]) { - if (filteredDeviceData["initialDeviceInfo"]["OS_BUILD_DATE"]) { - if (filteredDeviceData["initialDeviceInfo"]["OS_BUILD_DATE"] != "0") { - viewModel["osBuildDate"] = new Date(filteredDeviceData["initialDeviceInfo"]["OS_BUILD_DATE"] * 1000); - } - } - if (filteredDeviceData["initialDeviceInfo"]["LATITUDE"] && filteredDeviceData["initialDeviceInfo"]["LONGITUDE"]) { - viewModel["location"] = {}; - viewModel["location"]["latitude"] = filteredDeviceData["initialDeviceInfo"]["LATITUDE"]; - viewModel["location"]["longitude"] = filteredDeviceData["initialDeviceInfo"]["LONGITUDE"]; - } - if (filteredDeviceData["initialDeviceInfo"]["VENDOR"] && filteredDeviceData["initialDeviceInfo"]["DEVICE_MODEL"]) { - viewModel["vendor"] = filteredDeviceData["initialDeviceInfo"]["VENDOR"]; - viewModel["model"] = filteredDeviceData["initialDeviceInfo"]["DEVICE_MODEL"]; - } - if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]) { - if (deviceType == "android") { - viewModel["BatteryLevel"] = {}; - viewModel["BatteryLevel"]["value"] = filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["BATTERY_LEVEL"]; - - viewModel["internalMemory"] = {}; - viewModel["internalMemory"]["total"] = Math. - round(filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] * 100) / 100; - if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] != 0) { - viewModel["internalMemory"]["usage"] = Math. - round((filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] - - filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_AVAILABLE_MEMORY"]) - / filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] * 10000) / 100; - } else { - viewModel["internalMemory"]["usage"] = 0; - } - - viewModel["externalMemory"] = {}; - viewModel["externalMemory"]["total"] = Math. - round(filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] * 100) / 100; - if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] != 0) { - viewModel["externalMemory"]["usage"] = Math. - round((filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] - - filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_AVAILABLE_MEMORY"]) - / filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] * 10000) / 100; - } else { - viewModel["externalMemory"]["usage"] = 0; - } - } else if (deviceType == "ios") { - viewModel["BatteryLevel"] = {}; - viewModel["BatteryLevel"]["value"] = Math. round(filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["BatteryLevel"] * 10000) / 100; - - viewModel["internalMemory"] = {}; - viewModel["internalMemory"]["total"] = Math. - round(filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] * 100) / 100; - if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] != 0) { - viewModel["internalMemory"]["usage"] = Math. - round((filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] - - filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["AvailableDeviceCapacity"]) - / filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] * 10000) / 100; - } else { - viewModel["internalMemory"]["usage"] = 0; - } - } - } - } - } if (filteredDeviceData["latestDeviceInfo"]) { viewModel["deviceInfoAvailable"] = true; if (filteredDeviceData["latestDeviceInfo"]["osBuildDate"]) { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/modules/enrollments/windows/agent-controller.jag b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/modules/enrollments/windows/agent-controller.jag index c5740cd403..1cf29bb0e2 100755 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/modules/enrollments/windows/agent-controller.jag +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/modules/enrollments/windows/agent-controller.jag @@ -32,7 +32,7 @@ parser.getResult(); var os = parser.getOS(); var platform = os.name; -if (platform != "Windows Phone") { +if (platform != "Windows Phone" && platform != "Windows") { response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request"); } else if (session.get("lastAccessedPage") != "login-agent") { response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request"); diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/modules/enrollments/windows/agent-enroll.jag b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/modules/enrollments/windows/agent-enroll.jag index 66a4eed09b..92687fcff4 100755 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/modules/enrollments/windows/agent-enroll.jag +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/windows-web-agent/app/modules/enrollments/windows/agent-enroll.jag @@ -27,7 +27,7 @@ parser.getResult(); var os = parser.getOS(); var platform = os.name; -if (platform != "Windows Phone") { +if (platform != "Windows Phone" && platform != "Windows") { response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request"); } else if (session.get("lastAccessedPage") != "license-agent") { response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request"); diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/devicetypes/windows.xml b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/devicetypes/windows.xml index 1313b68673..2872f0e7a4 100644 --- a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/devicetypes/windows.xml +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/devicetypes/windows.xml @@ -24,11 +24,27 @@ en_US 1.0.0 - This End User License Agreement ("Agreement") is a legal agreement between you ("You") and WSO2, Inc., regarding the enrollment of Your personal mobile device ("Device") in SoR's mobile device management program, and the loading to and removal from Your Device and Your use of certain applications and any associated software and user documentation, whether provided in "online" or electronic format, used in connection with the operation of or provision of services to WSO2, Inc., BY SELECTING "I ACCEPT" DURING INSTALLATION, YOU ARE ENROLLING YOUR DEVICE, AND THEREBY AUTHORIZING SOR OR ITS AGENTS TO INSTALL, UPDATE AND REMOVE THE APPS FROM YOUR DEVICE AS DESCRIBED IN THIS AGREEMENT. YOU ARE ALSO EXPLICITLY ACKNOWLEDGING AND AGREEING THAT (1) THIS IS A BINDING CONTRACT AND (2) YOU HAVE READ AND AGREE TO THE TERMS OF THIS AGREEMENT. + This End User License Agreement ("Agreement") is a legal agreement between you ("You") and WSO2, Inc., + regarding the enrollment of Your personal mobile device ("Device") in SoR's mobile device management + program, and the loading to and removal from Your Device and Your use of certain applications and any + associated software and user documentation, whether provided in "online" or electronic format, used in + connection with the operation of or provision of services to WSO2, Inc., + BY SELECTING "I ACCEPT" DURING INSTALLATION, YOU ARE ENROLLING YOUR DEVICE, + AND THEREBY AUTHORIZING SOR OR ITS AGENTS TO INSTALL, UPDATE AND REMOVE THE APPS FROM YOUR DEVICE AS + DESCRIBED IN THIS AGREEMENT. YOU ARE ALSO EXPLICITLY ACKNOWLEDGING AND AGREEING THAT (1) + THIS IS A BINDING CONTRACT AND (2) YOU HAVE READ AND AGREE TO THE TERMS OF THIS AGREEMENT. IF YOU DO NOT ACCEPT THESE TERMS, DO NOT ENROLL YOUR DEVICE AND DO NOT PROCEED ANY FURTHER. - You agree that: (1) You understand and agree to be bound by the terms and conditions contained in this Agreement, and (2) You are at least 21 years old and have the legal capacity to enter into this Agreement as defined by the laws of Your jurisdiction. SoR shall have the right, without prior notice, to terminate or suspend (i) this Agreement, (ii) the enrollment of Your Device, or (iii) the functioning of the Apps in the event of a violation of this Agreement or the cessation of Your relationship with SoR (including termination of Your employment if You are an employee or expiration or termination of Your applicable franchise or supply agreement if You are a franchisee of or supplier to the WSO2 WSO2, Inc., system). SoR expressly reserves all rights not expressly granted herein. + You agree that: (1) You understand and agree to be bound by the terms and conditions + contained in this Agreement, and (2) You are at least 21 years old and have the legal capacity to enter + into this Agreement as defined by the laws of Your jurisdiction. SoR shall have the right, + without prior notice, to terminate or suspend (i) this Agreement, (ii) the enrollment of + Your Device, or (iii) the functioning of the Apps in the event of a violation of this Agreement or + the cessation of Your relationship with SoR (including termination of Your employment + if You are an employee or expiration or termination of Your applicable franchise or supply agreement + if You are a franchisee of or supplier to the WSO2 WSO2, Inc., system). SoR expressly + reserves all rights not expressly granted herein. @@ -64,32 +80,44 @@ Disenroll - Lock the device - + Dis-enrol the device + Wipe Data - Lock the device - + Wipe the device + Ring - Lock the device - + Ring the device + Device Lock Lock the device - + Device Lock Reset - Lock the device - + Lock Reset the device + + + + + Location + Request coordinates of device location + From 0a5cafd6ef5605a92b0e244855bd035b3e3fdb30 Mon Sep 17 00:00:00 2001 From: Hasunie Date: Fri, 6 Jan 2017 14:14:25 +0530 Subject: [PATCH 12/28] fixing windows device view --- .../cdmf.unit.device.type.windows.device-view/device-view.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.device-view/device-view.hbs b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.device-view/device-view.hbs index 6030939efe..cb00b423a1 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.device-view/device-view.hbs +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.device-view/device-view.hbs @@ -1,6 +1,6 @@ {{unit "cdmf.unit.device.type.windows.leaflet"}} {{unit "cdmf.unit.lib.qrcode"}} -{{unit "cdmf.unit.device.type.windows.qr-modal"}} +{{unit "cdmf.unit.device.type.qr-modal"}} {{#if deviceFound}} {{#if isAuthorized}} From d7b94a7f0797cbd93c6de8311d92084e50bc82fa Mon Sep 17 00:00:00 2001 From: Hasunie Date: Fri, 6 Jan 2017 14:18:20 +0530 Subject: [PATCH 13/28] adding location,reboot operation icons --- .../public/js/operation-mod.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-mod/public/js/operation-mod.js b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-mod/public/js/operation-mod.js index 3d35bd67d6..b064ef186f 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-mod/public/js/operation-mod.js +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.operation-mod/public/js/operation-mod.js @@ -143,9 +143,10 @@ var windowsOperationModule = function () { "DISENROLL": "disenroll", "DEVICE_RING": "ring-device", "LOCK_RESET": "lock-reset", - "WIPE_DATA": "wipe-data" + "WIPE_DATA": "wipe-data", + "DEVICE_LOCATION": "location", + "DEVICE_REBOOT": "reboot" }; - //return "/mdm-windows-agent/services/windows/operation/" + featureMap[operationCode]; return "/api/device-mgt/windows/v1.0/operation/admin/devices/" + featureMap[operationCode]; }; @@ -160,7 +161,9 @@ var windowsOperationModule = function () { "DEVICE_RING": "fw-dial-up", "DISENROLL": "fw-export", "LOCK_RESET": "fw-key", - "WIPE_DATA": "fw-delete" + "WIPE_DATA": "fw-delete", + "DEVICE_LOCATION": "location", + "DEVICE_REBOOT": "fw-refresh" }; return featureMap[operationCode]; }; From 32d603c8f6e2de6bb57b6285e65aaed00e766a98 Mon Sep 17 00:00:00 2001 From: Hasunie Date: Fri, 6 Jan 2017 14:56:57 +0530 Subject: [PATCH 14/28] updating API context and publish names --- .../api/services/ConfigurationMgtService.java | 4 +- .../DeviceManagementAdminService.java | 649 +++++++++++------- .../api/services/DeviceManagementService.java | 12 +- .../api/services/authbst/BSTProvider.java | 6 +- .../services/discovery/DiscoveryService.java | 56 +- .../discovery/impl/DiscoveryServiceImpl.java | 15 - .../enrollment/EnrollmentService.java | 75 ++ .../enrollment/beans/ContextItem.java | 5 +- .../DeviceManagementAdminServiceImpl.java | 68 ++ .../api/services/syncml/SyncmlService.java | 8 +- .../syncml/impl/SyncmlServiceImpl.java | 1 - .../wstep/CertificateEnrollmentService.java | 4 +- .../CertificateEnrollmentPolicyService.java | 6 +- 13 files changed, 558 insertions(+), 351 deletions(-) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/ConfigurationMgtService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/ConfigurationMgtService.java index 1796a637cb..4d57e80a32 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/ConfigurationMgtService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/ConfigurationMgtService.java @@ -59,11 +59,11 @@ import javax.ws.rs.core.Response; } ), tags = { - @Tag(name = "devicemgt_windows", description = "") + @Tag(name = "windows", description = "") } ) @Api(value = "Windows Configuration Management", - description = "This carries all the resources related to Windows configurations management functionalities") + description = "This carries all the resources related to Windows configurations management functionality") @WebService @Path("/configuration") @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java index 0b1b0995c6..0652953f42 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java @@ -52,7 +52,7 @@ import java.util.List; } ), tags = { - @Tag(name = "devicemgt_windows", description = "") + @Tag(name = "windows", description = "") } ) @Api(value = "Windows Device Management Administrative Service", @@ -63,277 +63,407 @@ import java.util.List; @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public interface DeviceManagementAdminService { - @POST - @Path("/lock-devices") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Adding a Device Lock on Windows devices.", - notes = "Using this API you have the option of Device Windows device.", - response = Activity.class, - tags = "Windows Device Management Administrative Service", - authorizations = { - @Authorization( - value = "permission", - scopes = {@AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/windows/lock", - description = "Lock Device")} - ) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully scheduled the device lock operation.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified. \n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while locking the device.") - }) - Response lock(@HeaderParam("Accept") String headerParam, @ApiParam( - name = "deviceIDs", - value = "Provide the ID of the AWindows device. Multiple device IDs can be added by " + - "using comma separated values. ", - required = true) List deviceIds) throws WindowsDeviceEnrolmentException; + @POST + @Path("/lock-devices") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Adding a Device Lock on Windows devices.", + notes = "Using this API you have the option of Device Windows device.", + response = Activity.class, + tags = "Windows Device Management Administrative Service", + authorizations = { + @Authorization( + value = "permission", + scopes = {@AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/windows/lock", + description = "Lock Device")} + ) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 201, + message = "Created. \n Successfully scheduled the device lock operation.", + response = Activity.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "URL of the activity instance that refers to the scheduled operation."), + @ResponseHeader( + name = "Content-Type", + description = "Content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified. \n" + + "Used by caches, or in conditional requests.")}), + @ApiResponse( + code = 303, + message = "See Other. \n The source can be retrieved from the URL specified in the location header.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error."), + @ApiResponse( + code = 415, + message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while locking the device.") + }) + Response lock(@HeaderParam("Accept") String headerParam, @ApiParam( + name = "deviceIDs", + value = "Provide the ID of the AWindows device. Multiple device IDs can be added by " + + "using comma separated values. ", + required = true) List deviceIds) throws WindowsDeviceEnrolmentException; - @POST - @Path("/disenroll-devices") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Dis-enrol the windows Devices", - notes = "Dis-enroll on Android devices", - response = Activity.class, - tags = "Windows Device Management Administrative Service.", - authorizations = { - @Authorization( - value = "permission", - scopes = {@AuthorizationScope( - scope = "/device-mgt/devices/disenroll/windows", - description = "Dis-enroll the windows devices ")} - ) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully scheduled the Dis-enroll operation.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified the last time.\n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.\n", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while adding a Dis-enroll operation.") - }) - Response disenroll(@HeaderParam("Accept") String headerParam, @ApiParam( - name = "deviceIDs", - value = "Provide the ID of the A Windows device. Multiple device IDs can be added by " + - "using comma separated values. ", - required = true) List deviceIds) throws WindowsDeviceEnrolmentException; + @POST + @Path("/disenroll-devices") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Dis-enrol the windows Devices", + notes = "Dis-enroll on Android devices", + response = Activity.class, + tags = "Windows Device Management Administrative Service.", + authorizations = { + @Authorization( + value = "permission", + scopes = {@AuthorizationScope( + scope = "/device-mgt/devices/disenroll/windows", + description = "Dis-enroll the windows devices ")} + ) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 201, + message = "Created. \n Successfully scheduled the Dis-enroll operation.", + response = Activity.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "URL of the activity instance that refers to the scheduled operation."), + @ResponseHeader( + name = "Content-Type", + description = "Content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified the last time.\n" + + "Used by caches, or in conditional requests.")}), + @ApiResponse( + code = 303, + message = "See Other. \n The source can be retrieved from the URL specified in the location header.\n", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error."), + @ApiResponse( + code = 415, + message = "Unsupported media type. \n The format of the requested entity was not supported."), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while adding a Dis-enroll operation.") + }) + Response disenroll(@HeaderParam("Accept") String headerParam, @ApiParam( + name = "deviceIDs", + value = "Provide the ID of the A Windows device. Multiple device IDs can be added by " + + "using comma separated values. ", + required = true) List deviceIds) throws WindowsDeviceEnrolmentException; - @POST - @Path("/wipe-devices") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Factory Resetting an Windows Device", - notes = "Factory rest or erase all the data stored on the Windows devices" + - "to restore them back to the original system.", - response = Activity.class, - tags = "Windows Device Management Administrative Service", - authorizations = { - @Authorization( - value = "permission", - scopes = {@AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/windows/wipe", - description = "DeviceWipe")} - ) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully scheduled the Data wipe operation.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified." + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.\n", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while adding the Data wipe operation.")}) - Response wipe(@HeaderParam("Accept") String headerParam, @ApiParam( - name = "deviceIDs", - value = "Provide the ID of the A Windows device. Multiple device IDs can be added by " + - "using comma separated values. ", - required = true) List deviceIds) throws WindowsDeviceEnrolmentException; + @POST + @Path("/wipe-devices") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + produces = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Factory Resetting an Windows Device", + notes = "Factory rest or erase all the data stored on the Windows devices" + + "to restore them back to the original system.", + response = Activity.class, + tags = "Windows Device Management Administrative Service", + authorizations = { + @Authorization( + value = "permission", + scopes = {@AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/windows/wipe", + description = "DeviceWipe")} + ) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 201, + message = "Created. \n Successfully scheduled the Data wipe operation.", + response = Activity.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "URL of the activity instance that refers to the scheduled operation."), + @ResponseHeader( + name = "Content-Type", + description = "Content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified." + + "Used by caches, or in conditional requests.")}), + @ApiResponse( + code = 303, + message = "See Other. \n The source can be retrieved from the URL specified in the location header.\n", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error."), + @ApiResponse( + code = 415, + message = "Unsupported media type. \n The format of the requested entity was not supported."), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while adding the Data wipe operation.")}) + Response wipe(@HeaderParam("Accept") String headerParam, @ApiParam( + name = "deviceIDs", + value = "Provide the ID of the A Windows device. Multiple device IDs can be added by " + + "using comma separated values. ", + required = true) List deviceIds) throws WindowsDeviceEnrolmentException; - @POST - @Path("/ring-devices") - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - httpMethod = "POST", - value = "Ringing Windows Devices", - notes = "Ring Windows devices.", - response = Activity.class, - tags = "Windows Device Management Administrative Service", - authorizations = { - @Authorization( - value="permission", - scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/windows/ring", - description = "Ring Device") } - ) - } - ) - @ApiResponses(value = { - @ApiResponse( - code = 201, - message = "Created. \n Successfully scheduled the device ring operation.", - response = Activity.class, - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "URL of the activity instance that refers to the scheduled operation."), - @ResponseHeader( - name = "Content-Type", - description = "Content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests.")}), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified in the location header.", - responseHeaders = { - @ResponseHeader( - name = "Content-Location", - description = "The Source URL of the document.")}), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error."), - @ApiResponse( - code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while adding a new device ring operation.") - }) - Response ring(@HeaderParam("Accept") String headerParam, @ApiParam( - name = "deviceIDs", - value = "Provide the ID of the A Windows device. Multiple device IDs can be added by " + - "using comma separated values. ", - required = true) List deviceIds) throws WindowsDeviceEnrolmentException; + @POST + @Path("/ring-devices") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Ringing Windows Devices", + notes = "Ring Windows devices.", + response = Activity.class, + tags = "Windows Device Management Administrative Service", + authorizations = { + @Authorization( + value = "permission", + scopes = {@AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/windows/ring", + description = "Ring Device")} + ) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 201, + message = "Created. \n Successfully scheduled the device ring operation.", + response = Activity.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "URL of the activity instance that refers to the scheduled operation."), + @ResponseHeader( + name = "Content-Type", + description = "Content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified.\n" + + "Used by caches, or in conditional requests.")}), + @ApiResponse( + code = 303, + message = "See Other. \n The source can be retrieved from the URL specified in the location header.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error."), + @ApiResponse( + code = 415, + message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while adding a new device ring operation.") + }) + Response ring(@HeaderParam("Accept") String headerParam, @ApiParam( + name = "deviceIDs", + value = "Provide the ID of the A Windows device. Multiple device IDs can be added by " + + "using comma separated values. ", + required = true) List deviceIds) throws WindowsDeviceEnrolmentException; + + @POST + @Path("/lock-reset-devices") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Lock reset on Windows devices", + notes = "Lock reset on Windows devices.Its use to reset the device pass code", + response = Activity.class, + tags = "Windows Device Management Administrative Service", + authorizations = { + @Authorization( + value = "permission", + scopes = {@AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/windows/lock-reset", + description = "Lock reset")} + ) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 201, + message = "Created. \n Successfully scheduled the lock-reset operation.", + response = Activity.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "URL of the activity instance that refers to the scheduled operation."), + @ResponseHeader( + name = "Content-Type", + description = "Content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified.\n" + + "Used by caches, or in conditional requests.")}), + @ApiResponse( + code = 303, + message = "See Other. \n The source can be retrieved from the URL specified in the location header.\n", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error."), + @ApiResponse( + code = 415, + message = "Unsupported media type. \n The format of the requested entity was not supported."), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while adding adding a lock-reset operation.") + }) + Response lockReset(@HeaderParam("Accept") String acceptHeader, @ApiParam( + name = "deviceIDs", + value = "Provide the ID of the A Windows device. Multiple device IDs can be added by " + + "using comma separated values. ", + required = true) List deviceIds) throws WindowsDeviceEnrolmentException; + + @POST + @Path("/location") + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + httpMethod = "POST", + value = "Requesting Location Coordinates", + responseContainer = "List", + notes = "Request location coordinates of Windows devices. \n" + + "Example: In situations where you have lost your device and need to find out where it is, " + + "you can use this REST API to get the location of the device.", + response = Activity.class, + tags = "Windows Device Management Administrative Service", + authorizations = { + @Authorization( + value = "permission", + scopes = {@AuthorizationScope( + scope = "/device-mgt/devices/owning-device/operations/windows/location", + description = "Get Device Location")} + ) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 201, + message = "Created. \n Get-location operation has successfully been scheduled", + response = Activity.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "URL of the activity instance that refers to the " + + "scheduled operation."), + @ResponseHeader( + name = "Content-Type", + description = "Content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified.\n" + + "Used by caches, or in conditional requests.")}), + @ApiResponse( + code = 303, + message = "See Other. \n The source can be retrieved from the URL specified in the" + + " location header.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error."), + @ApiResponse( + code = 415, + message = "Unsupported media type. \n The format of the requested entity was not supported."), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while adding a new get-location operation.")}) + Response getDeviceLocation( + @ApiParam( + name = "deviceIDs", + value = "Provide the ID of the Windows device. Multiple device IDs can be added by " + + "using comma separated values. ", + required = true) + List deviceIDs); @POST - @Path("/lock-reset-devices") + @Path("/reboot") @ApiOperation( consumes = MediaType.APPLICATION_JSON, httpMethod = "POST", - value = "Lock reset on Windows devices", - notes = "Lock reset on Windows devices.Its use to reset the device pass code", + value = "Rebooting Windows Devices", + notes = "Reboot or restart your Windows devices.", response = Activity.class, tags = "Windows Device Management Administrative Service", authorizations = { @Authorization( value="permission", scopes = { @AuthorizationScope( - scope = "/device-mgt/devices/owning-device/operations/windows/lock-reset", - description = "Lock reset") } + scope = "/device-mgt/devices/owning-device/operations/windows/reboot", + description = "Reboot Device") } ) } ) @ApiResponses(value = { @ApiResponse( code = 201, - message = "Created. \n Successfully scheduled the lock-reset operation.", + message = "Created. \n Successfully scheduled the device reboot operation.", response = Activity.class, responseHeaders = { @ResponseHeader( @@ -362,15 +492,16 @@ public interface DeviceManagementAdminService { message = "Bad Request. \n Invalid request or validation error."), @ApiResponse( code = 415, - message = "Unsupported media type. \n The format of the requested entity was not supported."), + message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), @ApiResponse( code = 500, message = "Internal Server Error. \n " + - "Server error occurred while adding adding a lock-reset operation.") + "Server error occurred while adding the new device reboot operation.") }) - Response lockReset(@HeaderParam("Accept") String acceptHeader, @ApiParam( - name = "deviceIDs", - value = "Provide the ID of the A Windows device. Multiple device IDs can be added by " + - "using comma separated values. ", - required = true) List deviceIds) throws WindowsDeviceEnrolmentException; + Response rebootDevice( + @ApiParam( + name = "deviceIDs", + value = "Provide the ID of the Android device. Multiple device IDs can be added using comma separated values. ", + required = true) + List deviceIDs); } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java index 2b3dd6ae68..7a08827df3 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java @@ -36,7 +36,7 @@ import javax.ws.rs.core.Response; /** - * Interface for Syncml message flow. + * Interface for Windows 10 Device management phase. */ @SwaggerDefinition( info = @Info( @@ -44,18 +44,18 @@ import javax.ws.rs.core.Response; title = "", extensions = { @Extension(properties = { - @ExtensionProperty(name = "name", value = "Syncml Endpoint"), + @ExtensionProperty(name = "name", value = "Windows 10 Device management"), @ExtensionProperty(name = "context", - value = "/api/device-mgt/windows/v1.0/syncmlmgt"), + value = "/api/device-mgt/windows/v1.0/management"), }) } ), tags = { - @Tag(name = "devicemgt_windows", description = "") + @Tag(name = "windows", description = "") } ) -@Api(value = "Windows syncml service to initialize management session", - description = "This carries all the resources related to Windows syncml message flow.") +@Api(value = "Windows 10 Device management", + description = "This carries all the resources related to Windows 10 management session message flow.") @Path("/devicemgt") public interface DeviceManagementService { @Path("/pending-operations") diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/authbst/BSTProvider.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/authbst/BSTProvider.java index 1cea655c4f..fd24786681 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/authbst/BSTProvider.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/authbst/BSTProvider.java @@ -41,17 +41,17 @@ import javax.ws.rs.core.Response; title = "", extensions = { @Extension(properties = { - @ExtensionProperty(name = "name", value = "Windows Binary security token provider"), + @ExtensionProperty(name = "name", value = "Windows Binary Security Token Service"), @ExtensionProperty(name = "context", value = "/api/device-mgt/windows/v1.0/federated"), }) } ), tags = { - @Tag(name = "devicemgt_windows", description = "") + @Tag(name = "windows", description = "") } ) -@Api(value = "Windows BST Management", +@Api(value = "Windows Binary Security Token Service", description = "This carries all the resources related to Windows Binary security token management.") @WebService @Path("/bst") diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/DiscoveryService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/DiscoveryService.java index 460f11f405..db9a8125df 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/DiscoveryService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/DiscoveryService.java @@ -48,17 +48,17 @@ import javax.xml.ws.soap.SOAPBinding; title = "", extensions = { @Extension(properties = { - @ExtensionProperty(name = "name", value = "Windows Discovery service provider"), + @ExtensionProperty(name = "name", value = "Windows Discovery Service"), @ExtensionProperty(name = "context", value = "/api/device-mgt/windows/v1.0/discovery/post"), }) } ), tags = { - @Tag(name = "devicemgt_windows", description = "") + @Tag(name = "windows", description = "") } ) -@Api(value = "Windows Discovery service", +@Api(value = "Windows Discovery Service", description = "This carries all the resources related to Windows Discovery service.") @WebService(targetNamespace = PluginConstants.DISCOVERY_SERVICE_TARGET_NAMESPACE, name = "IDiscoveryService") @@ -133,54 +133,4 @@ public interface DiscoveryService { javax.xml.ws.Holder response ) throws WindowsDeviceEnrolmentException; - - @ApiOperation( - httpMethod = "GET", - value = "Device ping the server to check whether it is running or not.", - notes = ".", - tags = "Windows Discovery service.", - authorizations = { - @Authorization( - value = "permission", - scopes = {@AuthorizationScope(scope = "/device-mgt/devices/enroll/windows", - description = "Ping the Discovery service")} - ) - } - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Server is already running."), - @ApiResponse( - code = 303, - message = "See Other. \n The source can be retrieved from the URL specified " + - "in the location header.", - responseHeaders = { - @ResponseHeader(name = "Content-Location", - description = "Source URL of the document.") - }), - @ApiResponse( - code = 304, - message = "Not Modified. \n " + - "Empty body because the client already has the latest version of " + - "the requested resource."), - @ApiResponse( - code = 400, - message = "Bad Request. \n Invalid request or validation error. You must provide" + - " the device identifier. Additionally, the device identifier can be combined" + - " with either the device type" + - " OR the from and to date."), - @ApiResponse( - code = 404, - message = "Not Found. \n The specified resource does not exist."), - @ApiResponse( - code = 500, - message = "Error occurred while pinging the server.") - }) - @GET - @WebMethod - @WebResult() - Response discoverGet(); - } \ No newline at end of file diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/impl/DiscoveryServiceImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/impl/DiscoveryServiceImpl.java index 6b7d57fac6..08e69af07d 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/impl/DiscoveryServiceImpl.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/discovery/impl/DiscoveryServiceImpl.java @@ -101,21 +101,6 @@ public class DiscoveryServiceImpl implements DiscoveryService { } } - /** - * This is the first method called through device. The device checks the availability of the - * Service end point by calling this method. - * - * @return - HTTP 200OK message - */ - @Override - public Response discoverGet() { - - if (log.isDebugEnabled()) { - log.debug("Discovery service end point was triggered via GET method."); - } - return Response.ok().build(); - } - /** * Get authentication policy from the tenant configuration, otherwise set default value as Federated. * diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/EnrollmentService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/EnrollmentService.java index 74390a031b..42af805411 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/EnrollmentService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/EnrollmentService.java @@ -18,6 +18,7 @@ package org.wso2.carbon.device.mgt.mobile.windows.api.services.enrollment; +import io.swagger.annotations.*; import org.wso2.carbon.device.mgt.mobile.windows.api.common.PluginConstants; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WAPProvisioningException; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsDeviceEnrolmentException; @@ -27,12 +28,32 @@ import org.wso2.carbon.device.mgt.mobile.windows.api.services.enrollment.beans.R import javax.jws.WebMethod; import javax.jws.WebParam; import javax.jws.WebService; +import javax.ws.rs.POST; import javax.xml.ws.BindingType; import javax.xml.ws.RequestWrapper; import javax.xml.ws.ResponseWrapper; import javax.xml.ws.soap.SOAPBinding; import java.io.UnsupportedEncodingException; +@SwaggerDefinition( + info = @Info( + version = "1.0.0", + title = "", + extensions = { + @io.swagger.annotations.Extension(properties = { + @ExtensionProperty(name = "name", value = "Windows 10 Enrollment Service"), + @ExtensionProperty(name = "context", + value = "/api/device-mgt/windows/v1.0/deviceenrolment/enrollment"), + }) + } + ), + tags = { + @Tag(name = "windows", description = "") + } +) +@Api(value = "Windows 10 Enrollment Service", + description = "This carries all the resources related to Windows enrollment.") + @WebService(targetNamespace = PluginConstants.DEVICE_ENROLLMENT_SERVICE_TARGET_NAMESPACE, name = "enrollment") @BindingType(value = SOAPBinding.SOAP12HTTP_BINDING) public interface EnrollmentService { @@ -42,6 +63,60 @@ public interface EnrollmentService { @WebMethod(operationName = "RequestSecurityToken") @ResponseWrapper(localName = "RequestSecurityTokenResponseCollection", targetNamespace = PluginConstants.WS_TRUST_TARGET_NAMESPACE) + @POST + @ApiOperation( + httpMethod = "POST", + value = "Signing the certificate signing request(CSR) and provide request security token response.", + notes = "Using this API to fetching more information to enroll the Device and " + + "getting pending operations.", + tags = "Windows 10 Device Enrollment Service.", + authorizations = { + @Authorization( + value = "permission", + scopes = {@AuthorizationScope( + scope = "/device-mgt/devices/enroll/windows", + description = "Signing the certificate signing request(CSR) " + + "and provide request security token response")} + ) + } + ) + @ApiResponses(value = { + @ApiResponse( + code = 200, + message = "Ok.Successfully signed the CSR.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "URL of the activity instance that refers to the scheduled operation."), + @ResponseHeader( + name = "Content-Type", + description = "Content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified. \n" + + "Used by caches, or in conditional requests.")}), + @ApiResponse( + code = 303, + message = "See Other. \n The source can be retrieved from the URL specified in the location header.", + responseHeaders = { + @ResponseHeader( + name = "Content-Location", + description = "The Source URL of the document.")}), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error."), + @ApiResponse( + code = 415, + message = "Unsupported media type. \n The format of the requested entity was not supported.\n"), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while Signing the CSR.") + }) void requestSecurityToken( @WebParam(name = "TokenType", targetNamespace = PluginConstants.WS_TRUST_TARGET_NAMESPACE) String tokenType, diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/beans/ContextItem.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/beans/ContextItem.java index bbbdbd09c0..dbc690aa43 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/beans/ContextItem.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/enrollment/beans/ContextItem.java @@ -25,9 +25,8 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "ContextItem", namespace = PluginConstants.SOAP_AUTHORIZATION_TARGET_NAMESPACE, - propOrder = {"Name" , "Value"}) +@XmlAccessorType(XmlAccessType.PROPERTY) +@XmlType(name = "ContextItem", namespace = PluginConstants.SOAP_AUTHORIZATION_TARGET_NAMESPACE) public class ContextItem { @XmlElement(required = true, namespace = PluginConstants.SOAP_AUTHORIZATION_TARGET_NAMESPACE) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/impl/DeviceManagementAdminServiceImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/impl/DeviceManagementAdminServiceImpl.java index 1bcd6da0a9..56e9334962 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/impl/DeviceManagementAdminServiceImpl.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/impl/DeviceManagementAdminServiceImpl.java @@ -19,6 +19,7 @@ package org.wso2.carbon.device.mgt.mobile.windows.api.services.impl; import com.ibm.wsdl.OperationImpl; +import io.swagger.annotations.ApiParam; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.DeviceManagementException; @@ -29,6 +30,7 @@ import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation; import org.wso2.carbon.device.mgt.mobile.windows.api.common.PluginConstants; import org.wso2.carbon.device.mgt.mobile.windows.api.common.beans.ErrorResponse; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.BadRequestException; +import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.UnexpectedServerErrorException; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsDeviceEnrolmentException; import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsOperationsException; import org.wso2.carbon.device.mgt.mobile.windows.api.common.util.Message; @@ -268,4 +270,70 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); } } + + @POST + @Path("/location") + public Response getDeviceLocation(@ApiParam( + name = "deviceIDs", + value = "Provide the ID of the Windows device. Multiple device IDs can be added by " + + "using comma separated values. ", + required = true) List deviceIDs) { + if (log.isDebugEnabled()) { + log.debug("Invoking Windows device location operation."); + } + try { + CommandOperation operation = new CommandOperation(); + operation.setCode(PluginConstants.OperationCodes.DEVICE_LOCATION); + operation.setType(Operation.Type.COMMAND); + return WindowsAPIUtils.getOperationResponse(deviceIDs, operation); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException( + new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + throw new UnexpectedServerErrorException( + new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); + } catch (DeviceManagementException e) { + String errorMessage = "Issue in retrieving device management service instance"; + log.error(errorMessage, e); + throw new UnexpectedServerErrorException( + new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); + } + } + + @POST + @Path("/reboot") + public Response rebootDevice(@ApiParam( + name = "deviceIDs", + value = "Provide the ID of the Windows device. Multiple device IDs can be " + + "added using comma separated values.", + required = true) List deviceIDs) { + if (log.isDebugEnabled()) { + log.debug("Invoking Windows reboot-device device operation"); + } + try { + CommandOperation operation = new CommandOperation(); + operation.setCode(PluginConstants.OperationCodes.DEVICE_REBOOT); + operation.setType(Operation.Type.COMMAND); + return WindowsAPIUtils.getOperationResponse(deviceIDs, operation); + } catch (InvalidDeviceException e) { + String errorMessage = "Invalid Device Identifiers found."; + log.error(errorMessage, e); + throw new BadRequestException( + new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); + } catch (OperationManagementException e) { + String errorMessage = "Issue in retrieving operation management service instance"; + log.error(errorMessage, e); + throw new UnexpectedServerErrorException( + new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); + } catch (DeviceManagementException e) { + String errorMessage = "Issue in retrieving device management service instance"; + log.error(errorMessage, e); + throw new UnexpectedServerErrorException( + new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build()); + } + } } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/syncml/SyncmlService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/syncml/SyncmlService.java index 37194987b1..7ba8c570b7 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/syncml/SyncmlService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/syncml/SyncmlService.java @@ -35,7 +35,7 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; /** - * Interface for Syncml message flow. + * Interface for Windows 8.1 enrollment flow. */ @SwaggerDefinition( info = @Info( @@ -43,17 +43,17 @@ import javax.ws.rs.core.Response; title = "", extensions = { @Extension(properties = { - @ExtensionProperty(name = "name", value = "Syncml Endpoint"), + @ExtensionProperty(name = "name", value = "Windows 8.1 Device Management Service"), @ExtensionProperty(name = "context", value = "/api/device-mgt/windows/v1.0/syncml"), }) } ), tags = { - @Tag(name = "devicemgt_windows", description = "") + @Tag(name = "windows", description = "") } ) -@Api(value = "Windows syncml service", +@Api(value = "Windows 8.1 Device Management Service", description = "This carries all the resources related to Windows syncml message flow.") @Path("/devicemanagement") public interface SyncmlService { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/syncml/impl/SyncmlServiceImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/syncml/impl/SyncmlServiceImpl.java index 3dfcb44617..4cc2f0ac82 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/syncml/impl/SyncmlServiceImpl.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/syncml/impl/SyncmlServiceImpl.java @@ -235,7 +235,6 @@ public class SyncmlServiceImpl implements SyncmlService { String devLang; String vendor; String macAddress; - String resolution; String modVersion; boolean status = false; String user; diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/wstep/CertificateEnrollmentService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/wstep/CertificateEnrollmentService.java index 2bdf781285..eb6f7001a6 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/wstep/CertificateEnrollmentService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/wstep/CertificateEnrollmentService.java @@ -47,14 +47,14 @@ import java.io.UnsupportedEncodingException; title = "", extensions = { @Extension(properties = { - @ExtensionProperty(name = "name", value = "Windows enrollment service provider"), + @ExtensionProperty(name = "name", value = "Windows 8.1 Enrollment Service"), @ExtensionProperty(name = "context", value = "/api/device-mgt/windows/v1.0/deviceenrolment/wstep"), }) } ), tags = { - @Tag(name = "devicemgt_windows", description = "") + @Tag(name = "windows", description = "") } ) @Api(value = "Windows Enrollment service Management", diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/xcep/CertificateEnrollmentPolicyService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/xcep/CertificateEnrollmentPolicyService.java index 70d6cbb212..0934824c95 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/xcep/CertificateEnrollmentPolicyService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/xcep/CertificateEnrollmentPolicyService.java @@ -47,17 +47,17 @@ import javax.xml.ws.soap.SOAPBinding; title = "", extensions = { @io.swagger.annotations.Extension(properties = { - @ExtensionProperty(name = "name", value = "Windows Enrollment policy service"), + @ExtensionProperty(name = "name", value = "Windows Enrollment policy Service"), @ExtensionProperty(name = "context", value = "/api/device-mgt/windows/v1.0/certificatepolicy/xcep"), }) } ), tags = { - @Tag(name = "devicemgt_windows", description = "") + @Tag(name = "windows", description = "") } ) -@Api(value = "Windows enrollment policy Management", +@Api(value = "Windows Enrollment policy Service", description = "This carries all the resources related to Windows enrollment policy.") @WebService(targetNamespace = PluginConstants.CERTIFICATE_ENROLLMENT_POLICY_SERVICE_TARGET_NAMESPACE, name = "IPolicy") From 41095da20c04a97805847935cfe6540c8e02b304 Mon Sep 17 00:00:00 2001 From: dunithd Date: Fri, 6 Jan 2017 15:40:13 +0530 Subject: [PATCH 15/28] Fixing the geo dashboard link for Android sense, Raspberry and Arduino devices --- .../device-view.hbs | 2 ++ .../cdmf.unit.device.type.arduino.device-view/device-view.hbs | 2 ++ .../device-view.hbs | 2 ++ 3 files changed, 6 insertions(+) diff --git a/components/device-types/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.hbs b/components/device-types/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.hbs index ce3f71d7c6..952d78878e 100644 --- a/components/device-types/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.hbs +++ b/components/device-types/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.hbs @@ -43,6 +43,8 @@
  • Operations Log
  • +
  • Map
  • {{/zone}} {{#zone "device-view-tab-contents"}} diff --git a/components/device-types/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.hbs b/components/device-types/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.hbs index 8911ee7485..23aaa135e4 100644 --- a/components/device-types/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.hbs +++ b/components/device-types/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.hbs @@ -44,6 +44,8 @@
  • Operations Log
  • +
  • Map
  • {{/zone}} {{#zone "device-view-tab-contents"}} diff --git a/components/device-types/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.hbs b/components/device-types/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.hbs index 62d9e2d9db..42ad0d173f 100644 --- a/components/device-types/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.hbs +++ b/components/device-types/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.hbs @@ -44,6 +44,8 @@
  • Operations Log
  • +
  • Map
  • {{/zone}} {{#zone "device-view-tab-contents"}} From 2c9c02dc00b392205460a42fe2bf95c1a90825e7 Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Fri, 6 Jan 2017 16:26:59 +0530 Subject: [PATCH 16/28] Replaced [EMM] with [IoT Server] --- .../download-agent.hbs | 4 ++-- .../configuration.hbs | 4 ++-- .../public/templates/android-policy-edit.hbs | 2 +- .../public/templates/android-policy-view.hbs | 2 +- .../public/templates/android-policy-operations.hbs | 2 +- .../configuration.hbs | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/android-web-agent/app/pages/mdm.page.enrollments.android.download-agent/download-agent.hbs b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/android-web-agent/app/pages/mdm.page.enrollments.android.download-agent/download-agent.hbs index 26f32fefb6..8173c413a7 100755 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/android-web-agent/app/pages/mdm.page.enrollments.android.download-agent/download-agent.hbs +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/android-web-agent/app/pages/mdm.page.enrollments.android.download-agent/download-agent.hbs @@ -38,9 +38,9 @@ under the License. --}}
    If you have not already enrolled this device with {{companyName}}, - Download and install following EMM Agent to continue. + Download and install following IoT Server Agent to continue.
    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.platform.configuration/configuration.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.platform.configuration/configuration.hbs index 7e3708ed9d..5ace32cb31 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.platform.configuration/configuration.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.platform.configuration/configuration.hbs @@ -28,7 +28,7 @@
    @@ -42,7 +42,7 @@