From f675468e4489dfa64b50a3d2f19a9f50dad44dc6 Mon Sep 17 00:00:00 2001 From: mharindu Date: Mon, 4 Jul 2016 18:03:20 +0530 Subject: [PATCH 1/6] Added scopes to APIS --- .../service/impl/AndroidSenseService.java | 10 +++---- .../arduino/service/impl/ArduinoService.java | 8 ++--- .../service/impl/RaspberryPiService.java | 6 ++-- .../service/impl/VirtualFireAlarmService.java | 6 ++-- .../pom.xml | 4 +-- .../DeviceManagementAdminService.java | 30 +++++++++++++++++++ .../services/DeviceManagementService.java | 12 ++++++++ .../DeviceTypeConfigurationService.java | 9 ++++++ .../services/EventReceiverService.java | 8 +++++ .../pom.xml | 2 +- .../src/main/resources/p2.inf | 2 +- 11 files changed, 78 insertions(+), 19 deletions(-) diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseService.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseService.java index 8ba820d18..323afc19d 100644 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseService.java +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseService.java @@ -45,7 +45,7 @@ public interface AndroidSenseService { @Path("device/{deviceId}/words") @POST @Feature(code = "keywords", name = "Add Keywords", description = "Send keywords to the device") - @Permission(scope = "android_sense_user", permissions = {"/permission/admin/device-mgt/user/operations"}) + @Permission(scope = "android_sense_user", roles = {"/permission/admin/device-mgt/user/operations"}) Response sendKeyWords(@PathParam("deviceId") String deviceId, @QueryParam("keywords") String keywords); /** @@ -57,13 +57,13 @@ public interface AndroidSenseService { @Path("device/{deviceId}/words/threshold") @POST @Feature(code = "threshold", name = "Add a Threshold", description = "Set a threshold for word in the device") - @Permission(scope = "android_sense_user", permissions = {"/permission/admin/device-mgt/user/operations"}) + @Permission(scope = "android_sense_user", roles = {"emm-user"}) Response sendThreshold(@PathParam("deviceId") String deviceId, @QueryParam("threshold") String threshold); @Path("device/{deviceId}/words") @DELETE @Feature(code = "remove", name = "Remove Keywords", description = "Remove the keywords") - @Permission(scope = "android_sense_user", permissions = {"/permission/admin/device-mgt/user/operations"}) + @Permission(scope = "android_sense_user", roles = {"emm-user"}) Response removeKeyWords(@PathParam("deviceId") String deviceId, @QueryParam("words") String words); /** @@ -72,7 +72,7 @@ public interface AndroidSenseService { @Path("stats/{deviceId}/sensors/{sensorName}") @GET @Consumes("application/json") - @Permission(scope = "android_sense_user", permissions = {"/permission/admin/device-mgt/user/stats"}) + @Permission(scope = "android_sense_user", roles = {"emm-user"}) @Produces("application/json") Response getAndroidSenseDeviceStats(@PathParam("deviceId") String deviceId, @PathParam("sensorName") String sensor, @QueryParam("from") long from, @QueryParam("to") long to); @@ -82,7 +82,7 @@ public interface AndroidSenseService { */ @Path("device/{device_id}/register") @POST - @Permission(scope = "android_sense_user", permissions = {"/permission/admin/device-mgt/user/devices"}) + @Permission(scope = "android_sense_user", roles = {"emm-user"}) Response register(@PathParam("device_id") String deviceId, @QueryParam("deviceName") String deviceName); } diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoService.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoService.java index afe0c89b1..6f7480f37 100644 --- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoService.java +++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoService.java @@ -38,12 +38,12 @@ public interface ArduinoService { @Path("device/{deviceId}/bulb") @POST @Feature(code = "bulb", name = "Control Bulb", description = "Control Bulb on Arduino Uno") - @Permission(scope = "arduino_user", permissions = {"/permission/admin/device-mgt/user/operations"}) + @Permission(scope = "arduino_user", roles = {"emm-user"}) Response switchBulb(@PathParam("deviceId") String deviceId, @QueryParam("state") String state); @Path("device/{deviceId}/controls") @GET - @Permission(scope = "arduino_device", permissions = {"/permission/admin/device-mgt/user/operations"}) + @Permission(scope = "arduino_device", roles = {"emm-user"}) Response readControls(@PathParam("deviceId") String deviceId); /** @@ -53,7 +53,7 @@ public interface ArduinoService { @GET @Consumes("application/json") @Produces("application/json") - @Permission(scope = "arduino_user", permissions = {"/permission/admin/device-mgt/user/stats"}) + @Permission(scope = "arduino_user", roles = {"emm-user"}) Response getArduinoTemperatureStats(@PathParam("deviceId") String deviceId, @QueryParam("from") long from, @QueryParam("to") long to); @@ -63,7 +63,7 @@ public interface ArduinoService { @Path("device/download") @GET @Produces("application/octet-stream") - @Permission(scope = "arduino_user", permissions = {"/permission/admin/device-mgt/user/devices"}) + @Permission(scope = "arduino_user", roles = {"emm-user"}) Response downloadSketch(@QueryParam("deviceName") String customDeviceName); } diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiService.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiService.java index 299f7be26..1fc893ca2 100644 --- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiService.java +++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiService.java @@ -39,7 +39,7 @@ public interface RaspberryPiService { @Path("device/{deviceId}/bulb") @POST @Feature(code = "bulb", name = "Bulb On / Off", description = "Switch on/off Raspberry Pi agent's bulb. (On / Off)") - @Permission(scope = "raspberrypi_user", permissions = {"/permission/admin/device-mgt/user/operations"}) + @Permission(scope = "raspberrypi_user", roles = {"emm-user"}) Response switchBulb(@PathParam("deviceId") String deviceId, @QueryParam("state") String state); /** @@ -49,7 +49,7 @@ public interface RaspberryPiService { @GET @Consumes("application/json") @Produces("application/json") - @Permission(scope = "raspberrypi_user", permissions = {"/permission/admin/device-mgt/user/stats"}) + @Permission(scope = "raspberrypi_user", roles = {"emm-user"}) Response getRaspberryPiTemperatureStats(@PathParam("deviceId") String deviceId, @QueryParam("from") long from, @QueryParam("to") long to); @@ -59,7 +59,7 @@ public interface RaspberryPiService { @Path("device/download") @GET @Produces(MediaType.APPLICATION_JSON) - @Permission(scope = "raspberrypi_user", permissions = {"/permission/admin/device-mgt/user/devices"}) + @Permission(scope = "raspberrypi_user", roles = {"emm-user"}) Response downloadSketch(@QueryParam("deviceName") String deviceName, @QueryParam("sketch_type") String sketchType); } diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmService.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmService.java index 9f380dcde..1be685927 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmService.java +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmService.java @@ -48,7 +48,7 @@ public interface VirtualFireAlarmService { */ @POST @Path("device/{deviceId}/buzz") - @Permission(scope = "virtual_firealarm_user", permissions = {"/permission/admin/device-mgt/user/operations"}) + @Permission(scope = "virtual_firealarm_user", roles = {"emm-user"}) @Feature(code = "buzz", name = "Buzzer On / Off", description = "Switch on/off Virtual Fire Alarm Buzzer. (On / Off)") Response switchBuzzer(@PathParam("deviceId") String deviceId, @FormParam("state") String state); @@ -58,7 +58,7 @@ public interface VirtualFireAlarmService { */ @Path("device/stats/{deviceId}") @GET - @Permission(scope = "virtual_firealarm_user", permissions = {"/permission/admin/device-mgt/user/stats"}) + @Permission(scope = "virtual_firealarm_user", roles = {"emm-user"}) @Consumes("application/json") @Produces("application/json") Response getVirtualFirealarmStats(@PathParam("deviceId") String deviceId, @QueryParam("from") long from, @@ -67,7 +67,7 @@ public interface VirtualFireAlarmService { @Path("device/download") @GET @Produces("application/zip") - @Permission(scope = "virtual_firealarm_user", permissions = {"/permission/admin/device-mgt/user/devices"}) + @Permission(scope = "virtual_firealarm_user", roles = {"emm-user"}) 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/pom.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml index 1258094d9..46a66ae9b 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 @@ -46,7 +46,7 @@ 2.2 WEB-INF/lib/*cxf*.jar - api#device-mgt#android#v1.0 + api-device-mgt-android-v1.0 @@ -72,7 +72,7 @@ - + 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 3e504e52c..8291a1056 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementAdminService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementAdminService.java @@ -19,6 +19,8 @@ package org.wso2.carbon.mdm.services.android.services; import io.swagger.annotations.*; +import org.wso2.carbon.apimgt.annotations.api.API; +import org.wso2.carbon.apimgt.annotations.api.Permission; import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; import org.wso2.carbon.mdm.services.android.bean.wrapper.*; @@ -30,6 +32,10 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; +@API(name = "Android Device Management Administrative Service", version = "1.0.0", + context = "api-device-mgt-android-v1.0/admin/devices", + tags = {"devicemgt_android"}) + @Path("/admin/devices") @Api(value = "Android Device Management Administrative Service", description = "Device management related admin APIs.") @Produces(MediaType.APPLICATION_JSON) @@ -85,6 +91,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new lock operation.") }) + @Permission(scope = "device:android:lock", roles = {"admin"}) Response configureDeviceLock( @ApiParam(name = "deviceLockBeanWrapper", value = "Device lock configurations with device IDs") DeviceLockBeanWrapper deviceLockBeanWrapper); @@ -138,6 +145,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new un-lock operation.") }) + @Permission(scope = "device:android:unlock", roles = {"admin"}) Response configureDeviceUnlock( @ApiParam(name = "deviceIDs", value = "DeviceIds to be enable device unlock operation") List deviceIDs); @@ -190,6 +198,7 @@ public interface DeviceManagementAdminService { code = 500, message = "Internal Server Error. \n " + "Server error occurred while adding a new get-location operation.")}) + @Permission(scope = "device:android:location", roles = {"admin"}) Response getDeviceLocation( @ApiParam(name = "deviceIDs", value = "DeviceIDs to be requested to get device location") List deviceIDs); @@ -242,6 +251,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new clear password operation.") }) + @Permission(scope = "device:android:clear-password", roles = {"admin"}) Response removePassword( @ApiParam(name = "deviceIDs", value = "DeviceIds to be requested to remove password") List deviceIDs); @@ -294,6 +304,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new control camera operation.") }) + @Permission(scope = "device:android:camera", roles = {"admin"}) Response configureCamera( @ApiParam(name = "cameraBeanWrapper", value = "Camera enable/disable configurations with device IDs") CameraBeanWrapper cameraBeanWrapper); @@ -349,6 +360,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new device info operation.") }) + @Permission(scope = "device:android:info", roles = {"admin"}) Response getDeviceInformation( @ApiParam(name = "deviceIds", value = "Device IDs to be requested to get device information") List deviceIDs); @@ -402,6 +414,7 @@ public interface DeviceManagementAdminService { code = 500, message = "Internal Server Error. \n " + "Server error occurred while adding a enterprise wipe operation.")}) + @Permission(scope = "device:android:enterprise-wipe", roles = {"admin"}) Response wipeDevice(@ApiParam(name = "deviceIDs", value = "Device IDs to be requested to do enterprise-wipe") List deviceIDs); @@ -453,6 +466,7 @@ public interface DeviceManagementAdminService { code = 500, message = "Internal Server Error. \n " + "Server error occurred while adding a device wipe operation.")}) + @Permission(scope = "device:android:wipe", roles = {"admin"}) Response wipeData( @ApiParam(name = "wipeDataBeanWrapper", value = "Configurations and DeviceIds needed to do wipe-data") WipeDataBeanWrapper wipeDataBeanWrapper); @@ -509,6 +523,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new get-applications operation.") }) + @Permission(scope = "device:android:get-applications", roles = {"admin"}) Response getApplications( @ApiParam(name = "deviceIDs", value = "Device Ids needed to get applications that are already installed") List deviceIDs); @@ -561,6 +576,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new device ring operation.") }) + @Permission(scope = "device:android:ring", roles = {"admin"}) Response ringDevice( @ApiParam(name = "deviceIDs", value = "Device Ids needed for ring") List deviceIDs); @@ -612,6 +628,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new device reboot operation.") }) + @Permission(scope = "device:android:reboot", roles = {"admin"}) Response rebootDevice( @ApiParam(name = "deviceIDs", value = "Device Ids needed for reboot.") List deviceIDs); @@ -663,6 +680,7 @@ public interface DeviceManagementAdminService { "Server error occurred while adding a new device mute operation.") }) @Path("/mute") + @Permission(scope = "device:android:mute", roles = {"admin"}) Response muteDevice( @ApiParam(name = "deviceIDs", value = "DeviceIDs need to be muted") List deviceIDs); @@ -717,6 +735,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new install-application operation.") }) + @Permission(scope = "device:android:install-application", roles = {"admin"}) Response installApplication( @ApiParam(name = "applicationInstallationBeanWrapper", value = "Properties of installed apps and device IDs") ApplicationInstallationBeanWrapper applicationInstallationBeanWrapper); @@ -772,6 +791,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new update-application operation.") }) + @Permission(scope = "device:android:update-application", roles = {"admin"}) Response updateApplication( @ApiParam(name = "applicationUpdateBeanWrapper", value = "Properties of updated apps and device IDs") ApplicationUpdateBeanWrapper applicationUpdateBeanWrapper); @@ -824,6 +844,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new uninstall-application operation.") }) + @Permission(scope = "device:android:uninstall-application", roles = {"admin"}) Response uninstallApplication( @ApiParam(name = "applicationUninstallationBeanWrapper", value = "applicationUninstallationConfigs and Device Ids") @@ -878,6 +899,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new blacklist-applications operation.") }) + @Permission(scope = "device:android:blacklist-application", roles = {"admin"}) Response blacklistApplications( @ApiParam(name = "blacklistApplicationsBeanWrapper", value = "BlacklistApplications " + "Configuration and DeviceIds") @@ -932,6 +954,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new upgrade firmware operation.") }) + @Permission(scope = "device:android:upgrade-firmware", roles = {"admin"}) Response upgradeFirmware( @ApiParam(name = "upgradeFirmwareBeanWrapper", value = "Firmware upgrade configuration and DeviceIds") @@ -986,6 +1009,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new configure VPN operation.") }) + @Permission(scope = "device:android:vpn", roles = {"admin"}) Response configureVPN( @ApiParam(name = "vpnBeanWrapper", value = "VPN configuration and DeviceIds") @@ -1039,6 +1063,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new send notification operation.") }) + @Permission(scope = "device:android:send-notification", roles = {"admin"}) Response sendNotification( @ApiParam(name = "notificationBeanWrapper", value = "Notification Configurations and device Ids") @@ -1092,6 +1117,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new configure wifi operation.") }) + @Permission(scope = "device:android:wifi", roles = {"admin"}) Response configureWifi( @ApiParam(name = "wifiBeanWrapper", value = "WifiConfigurations and Device Ids") WifiBeanWrapper wifiBeanWrapper); @@ -1144,6 +1170,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new encrypt storage operation.") }) + @Permission(scope = "device:android:encrypt", roles = {"admin"}) Response encryptStorage( @ApiParam(name = "encryptionBeanWrapper", value = "Configurations and deviceIds need to be done data encryption") @@ -1197,6 +1224,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new change lock code operation.") }) + @Permission(scope = "device:android:change-lock-code", roles = {"admin"}) Response changeLockCode( @ApiParam(name = "lockCodeBeanWrapper", value = "Configurations and device Ids need to be done change lock code") @@ -1250,6 +1278,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new set password policy operation.") }) + @Permission(scope = "device:android:set-password-policy", roles = {"admin"}) Response setPasswordPolicy( @ApiParam(name = "passwordPolicyBeanWrapper", value = "Password Policy Configurations and Device Ids") @@ -1303,6 +1332,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new set webclip operation.") }) + @Permission(scope = "device:android:webclip", roles = {"admin"}) Response setWebClip( @ApiParam(name = "webClipBeanWrapper", value = "Configurations to need set web clip on device and device Ids") diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java index 4464d6c73..f787cd5b5 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java @@ -19,6 +19,8 @@ package org.wso2.carbon.mdm.services.android.services; import io.swagger.annotations.*; +import org.wso2.carbon.apimgt.annotations.api.API; +import org.wso2.carbon.apimgt.annotations.api.Permission; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.app.mgt.Application; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; @@ -28,6 +30,10 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; +@API(name = "Android Device Management", version = "1.0.0", + context = "api-device-mgt-android-v1.0/devices", + tags = {"devicemgt_android"}) + @Api(value = "Android Device Management", description = "This carries all the resources related to Android device management functionalities") @Path("/devices") @@ -77,6 +83,7 @@ public interface DeviceManagementService { message = "Internal Server Error. \n " + "Server error occurred while updating the application list.") }) + @Permission(scope = "device:android:enroll", roles = {"admin"}) Response updateApplicationList( @ApiParam( name = "id", @@ -127,6 +134,7 @@ public interface DeviceManagementService { code = 500, message = "Internal Server Error. \n Server error occurred while fetching policies.") }) + @Permission(scope = "device:android:enroll", roles = {"admin"}) Response getPendingOperations( @ApiParam( name = "id", @@ -191,6 +199,7 @@ public interface DeviceManagementService { message = "Internal Server Error. \n " + "Server error occurred while adding a new policy.") }) + @Permission(scope = "device:android:enroll", roles = {"admin"}) Response enrollDevice(@ApiParam(name = "device", value = "Device Information to be enroll") Device device); @GET @@ -228,6 +237,7 @@ public interface DeviceManagementService { code = 500, message = "Internal Server Error. \n Server error occurred while fetching the enrollment status of the Android device.") }) + @Permission(scope = "device:android:enroll", roles = {"admin"}) Response isEnrolled( @ApiParam( name = "id", @@ -281,6 +291,7 @@ public interface DeviceManagementService { message = "Internal Server Error. \n " + "Server error occurred while updating the device enrollment.") }) + @Permission(scope = "device:android:enroll", roles = {"admin"}) Response modifyEnrollment( @ApiParam( name = "id", @@ -310,6 +321,7 @@ public interface DeviceManagementService { message = "Internal Server Error. \n " + "Server error occurred while dis-enrolling the device.") }) + @Permission(scope = "device:android:enroll", roles = {"admin"}) Response disEnrollDevice( @ApiParam( name = "id", diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java index 7d74b700d..d3b9156d0 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java @@ -19,6 +19,8 @@ package org.wso2.carbon.mdm.services.android.services; import io.swagger.annotations.*; +import org.wso2.carbon.apimgt.annotations.api.API; +import org.wso2.carbon.apimgt.annotations.api.Permission; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException; @@ -26,6 +28,10 @@ import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +@API(name = "Android Configuration Management", version = "1.0.0", + context = "api-device-mgt-android-v1.0/configuration", + tags = {"devicemgt_android"}) + @Api(value = "Android Configuration Management", description = "This API carries all resource associated with " + "manipulating the general configurations of Android platform") @Path("/configuration") @@ -73,6 +79,7 @@ public interface DeviceTypeConfigurationService { code = 500, message = "Internal Server Error. \n Server error occurred while fetching Android platform configuration.") }) + @Permission(scope = "configuration:view", roles = {"admin"}) Response getConfiguration( @ApiParam( name = "If-Modified-Since", @@ -122,6 +129,7 @@ public interface DeviceTypeConfigurationService { message = "Internal Server Error. \n " + "Server error occurred while modifying Android platform configuration.") }) + @Permission(scope = "configuration:modify", roles = {"admin"}) Response updateConfiguration( @ApiParam(name = "configuration", value = "AndroidPlatformConfiguration") @@ -169,6 +177,7 @@ public interface DeviceTypeConfigurationService { code = 500, message = "Internal Server Error. \n Server error occurred while fetching Android license configuration.") }) + @Permission(scope = "device:android:enroll", roles = {"admin"}) Response getLicense( @ApiParam( name = "If-Modified-Since", diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/EventReceiverService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/EventReceiverService.java index c48844090..24c4fbe54 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/EventReceiverService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/EventReceiverService.java @@ -19,6 +19,8 @@ package org.wso2.carbon.mdm.services.android.services; import io.swagger.annotations.*; +import org.wso2.carbon.apimgt.annotations.api.API; +import org.wso2.carbon.apimgt.annotations.api.Permission; import org.wso2.carbon.mdm.services.android.bean.DeviceState; import org.wso2.carbon.mdm.services.android.bean.wrapper.EventBeanWrapper; @@ -26,6 +28,10 @@ import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +@API(name = "Android Event Receiver", version = "1.0.0", + context = "api-device-mgt-android-v1.0/configuration", + tags = {"devicemgt_android"}) + @Api(value = "Event Receiver", description = "Event publishing/retrieving related APIs.To enable Eventing need to" + " configure as ref-https://docs.wso2.com/display/EMM210/Managing+Event+Publishing+with+WSO2+Data+Analytics+Server, " + "https://docs.wso2.com/display/EMM210/Creating+a+New+Event+Stream+and+Receiver") @@ -82,6 +88,7 @@ public interface EventReceiverService { message = "Internal Server Error. \n " + "Server error occurred while publishing events.") }) + @Permission(scope = "device:android:event:publish", roles = {"admin"}) Response publishEvents( @ApiParam( name = "eventBeanWrapper", @@ -130,6 +137,7 @@ public interface EventReceiverService { code = 500, message = "Error occurred while getting published events for specific device.") }) + @Permission(scope = "device:android:event:view", roles = {"admin"}) Response retrieveAlerts( @ApiParam( name = "id", diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml index 581ca9d10..ce76f7e12 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml @@ -118,7 +118,7 @@ true ${project.build.directory}/maven-shared-archive-resources/webapps/ - api#device-mgt#android#v1.0.war + api-device-mgt-android-v1.0.war diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf index 3b9d91aec..86e299d01 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf @@ -1,5 +1,5 @@ instructions.configure = \ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/webapps/api#device-mgt#android#v1.0.war,target:${installFolder}/../../deployment/server/webapps/api#device-mgt#android#v1.0.war,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/webapps/api-device-mgt-android-v1.0.war,target:${installFolder}/../../deployment/server/webapps/api-device-mgt-android-v1.0.war,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/jaggeryapps/,target:${installFolder}/../../deployment/server/jaggeryapps/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/conf/mobile-config.xml,target:${installFolder}/../../conf/mobile-config.xml,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/dbscripts/plugins/,target:${installFolder}/../../../dbscripts/cdm/plugins/android,overwrite:true);\ From 48613018ab8bf90bf961a65b52c21fa7af950bba Mon Sep 17 00:00:00 2001 From: mharindu Date: Mon, 4 Jul 2016 19:27:46 +0530 Subject: [PATCH 2/6] Fixed issues in scope based autorization implementation --- .../services/android/services/DeviceManagementAdminService.java | 2 +- .../mdm/services/android/services/EventReceiverService.java | 2 +- .../src/main/webapp/WEB-INF/web.xml | 2 +- 3 files changed, 3 insertions(+), 3 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 8291a1056..369b87517 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 @@ -899,7 +899,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new blacklist-applications operation.") }) - @Permission(scope = "device:android:blacklist-application", roles = {"admin"}) + @Permission(scope = "device:android:blacklist-applications", roles = {"admin"}) Response blacklistApplications( @ApiParam(name = "blacklistApplicationsBeanWrapper", value = "BlacklistApplications " + "Configuration and DeviceIds") 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 24c4fbe54..a9f0e249e 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 @@ -29,7 +29,7 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @API(name = "Android Event Receiver", version = "1.0.0", - context = "api-device-mgt-android-v1.0/configuration", + context = "api-device-mgt-android-v1.0/events", tags = {"devicemgt_android"}) @Api(value = "Event Receiver", description = "Event publishing/retrieving related APIs.To enable Eventing need to" + diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/web.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/web.xml index 48eeb393e..b39cda673 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/web.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/web.xml @@ -49,7 +49,7 @@ managed-api-enabled - false + true managed-api-owner From 6b939714d8b842952c5c1a34c968986d3d520bd1 Mon Sep 17 00:00:00 2001 From: mharindu Date: Tue, 12 Jul 2016 01:32:15 +0530 Subject: [PATCH 3/6] Changed context paths --- .../src/main/webapp/WEB-INF/cxf-servlet.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/cxf-servlet.xml index f6095bd02..5423cba71 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -51,7 +51,7 @@ - + From 302f71b6d197457906b2f8bd747952c38162e949 Mon Sep 17 00:00:00 2001 From: mharindu Date: Mon, 18 Jul 2016 20:17:31 +0530 Subject: [PATCH 4/6] Fixed webapp name resolving issue and changed API context --- .../org.wso2.carbon.device.mgt.mobile.android.api/pom.xml | 4 ++-- .../android/services/DeviceManagementAdminService.java | 2 +- .../services/android/services/DeviceManagementService.java | 2 +- .../android/services/DeviceTypeConfigurationService.java | 2 +- .../mdm/services/android/services/EventReceiverService.java | 2 +- .../org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml | 2 +- .../src/main/resources/p2.inf | 2 +- 7 files changed, 8 insertions(+), 8 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 dbd947212..fa45d4c24 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 @@ -46,7 +46,7 @@ 2.2 WEB-INF/lib/*cxf*.jar - api-device-mgt-android-v1.0 + api#device-mgt#android#v1.0 @@ -72,7 +72,7 @@ - + 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 e7e8fdc8b..6f3884a8a 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 @@ -33,7 +33,7 @@ import javax.ws.rs.core.Response; import java.util.List; @API(name = "Android Device Management Administrative Service", version = "1.0.0", - context = "api-device-mgt-android-v1.0/admin/devices", + context = "api/device-mgt/android/v1.0/admin/devices", tags = {"devicemgt_android"}) @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 f627e5f0f..2aaaee1c7 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 @@ -35,7 +35,7 @@ import javax.ws.rs.core.Response; import java.util.List; @API(name = "Android Device Management", version = "1.0.0", - context = "api-device-mgt-android-v1.0/devices", + context = "api/device-mgt/android/v1.0/devices", tags = {"devicemgt_android"}) @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 d5af40fe1..9a9012bb1 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 @@ -31,7 +31,7 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @API(name = "Android Configuration Management", version = "1.0.0", - context = "api-device-mgt-android-v1.0/configuration", + context = "api/device-mgt/android/v1.0/configuration", tags = {"devicemgt_android"}) @Api(value = "Android Configuration Management", description = "This API carries all resource associated with " + 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 fdfa38799..eb6e270ed 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 @@ -32,7 +32,7 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @API(name = "Android Event Receiver", version = "1.0.0", - context = "api-device-mgt-android-v1.0/events", + context = "api/device-mgt/android/v1.0/events", tags = {"devicemgt_android"}) @Api(value = "Event Receiver", description = "Event publishing/retrieving related APIs.To enable Eventing need to" + diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml index 6419ef571..a86fa94ae 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml @@ -118,7 +118,7 @@ true ${project.build.directory}/maven-shared-archive-resources/webapps/ - api-device-mgt-android-v1.0.war + api#device-mgt#android#v1.0.war diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf index 86e299d01..3b9d91aec 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf @@ -1,5 +1,5 @@ instructions.configure = \ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/webapps/api-device-mgt-android-v1.0.war,target:${installFolder}/../../deployment/server/webapps/api-device-mgt-android-v1.0.war,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/webapps/api#device-mgt#android#v1.0.war,target:${installFolder}/../../deployment/server/webapps/api#device-mgt#android#v1.0.war,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/jaggeryapps/,target:${installFolder}/../../deployment/server/jaggeryapps/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/conf/mobile-config.xml,target:${installFolder}/../../conf/mobile-config.xml,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/dbscripts/plugins/,target:${installFolder}/../../../dbscripts/cdm/plugins/android,overwrite:true);\ From 8ddee3b2170be2e23e25f7d474791f029c87f46f Mon Sep 17 00:00:00 2001 From: mharindu Date: Thu, 4 Aug 2016 17:47:26 +0530 Subject: [PATCH 5/6] Refactored scopes --- .../service/impl/AndroidSenseService.java | 22 +++----- .../arduino/service/impl/ArduinoService.java | 19 +++---- .../service/impl/RaspberryPiService.java | 17 +++---- .../service/impl/VirtualFireAlarmService.java | 8 +-- .../DeviceManagementAdminService.java | 50 +++++++++---------- .../services/DeviceManagementService.java | 12 ++--- .../DeviceTypeConfigurationService.java | 8 +-- .../services/EventReceiverService.java | 6 +-- 8 files changed, 63 insertions(+), 79 deletions(-) diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseService.java b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseService.java index 323afc19d..348a9008d 100644 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseService.java +++ b/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseService.java @@ -19,17 +19,11 @@ package org.wso2.carbon.device.mgt.iot.androidsense.service.impl; import org.wso2.carbon.apimgt.annotations.api.API; -import org.wso2.carbon.apimgt.annotations.api.Permission; +import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.DeviceType; import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.Feature; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; + +import javax.ws.rs.*; import javax.ws.rs.core.Response; @DeviceType(value = "android_sense") @@ -45,7 +39,7 @@ public interface AndroidSenseService { @Path("device/{deviceId}/words") @POST @Feature(code = "keywords", name = "Add Keywords", description = "Send keywords to the device") - @Permission(scope = "android_sense_user", roles = {"/permission/admin/device-mgt/user/operations"}) + @Scope(key = "device:android-sense:enroll", name = "", description = "") Response sendKeyWords(@PathParam("deviceId") String deviceId, @QueryParam("keywords") String keywords); /** @@ -57,13 +51,13 @@ public interface AndroidSenseService { @Path("device/{deviceId}/words/threshold") @POST @Feature(code = "threshold", name = "Add a Threshold", description = "Set a threshold for word in the device") - @Permission(scope = "android_sense_user", roles = {"emm-user"}) + @Scope(key = "device:android-sense:enroll", name = "", description = "") Response sendThreshold(@PathParam("deviceId") String deviceId, @QueryParam("threshold") String threshold); @Path("device/{deviceId}/words") @DELETE @Feature(code = "remove", name = "Remove Keywords", description = "Remove the keywords") - @Permission(scope = "android_sense_user", roles = {"emm-user"}) + @Scope(key = "device:android-sense:enroll", name = "", description = "") Response removeKeyWords(@PathParam("deviceId") String deviceId, @QueryParam("words") String words); /** @@ -72,7 +66,7 @@ public interface AndroidSenseService { @Path("stats/{deviceId}/sensors/{sensorName}") @GET @Consumes("application/json") - @Permission(scope = "android_sense_user", roles = {"emm-user"}) + @Scope(key = "device:android-sense:enroll", name = "", description = "") @Produces("application/json") Response getAndroidSenseDeviceStats(@PathParam("deviceId") String deviceId, @PathParam("sensorName") String sensor, @QueryParam("from") long from, @QueryParam("to") long to); @@ -82,7 +76,7 @@ public interface AndroidSenseService { */ @Path("device/{device_id}/register") @POST - @Permission(scope = "android_sense_user", roles = {"emm-user"}) + @Scope(key = "device:android-sense:enroll", name = "", description = "") Response register(@PathParam("device_id") String deviceId, @QueryParam("deviceName") String deviceName); } diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoService.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoService.java index 6f7480f37..9e0c97ec3 100644 --- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoService.java +++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoService.java @@ -19,16 +19,11 @@ package org.wso2.carbon.device.mgt.iot.arduino.service.impl; import org.wso2.carbon.apimgt.annotations.api.API; -import org.wso2.carbon.apimgt.annotations.api.Permission; +import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.DeviceType; import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.Feature; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; + +import javax.ws.rs.*; import javax.ws.rs.core.Response; @API(name = "arduino", version = "1.0.0", context = "/arduino", tags = {"arduino"}) @@ -38,12 +33,12 @@ public interface ArduinoService { @Path("device/{deviceId}/bulb") @POST @Feature(code = "bulb", name = "Control Bulb", description = "Control Bulb on Arduino Uno") - @Permission(scope = "arduino_user", roles = {"emm-user"}) + @Scope(key = "device:arduino:enroll", name = "", description = "") Response switchBulb(@PathParam("deviceId") String deviceId, @QueryParam("state") String state); @Path("device/{deviceId}/controls") @GET - @Permission(scope = "arduino_device", roles = {"emm-user"}) + @Scope(key = "device:arduino:enroll", name = "", description = "") Response readControls(@PathParam("deviceId") String deviceId); /** @@ -53,7 +48,7 @@ public interface ArduinoService { @GET @Consumes("application/json") @Produces("application/json") - @Permission(scope = "arduino_user", roles = {"emm-user"}) + @Scope(key = "device:arduino:enroll", name = "", description = "") Response getArduinoTemperatureStats(@PathParam("deviceId") String deviceId, @QueryParam("from") long from, @QueryParam("to") long to); @@ -63,7 +58,7 @@ public interface ArduinoService { @Path("device/download") @GET @Produces("application/octet-stream") - @Permission(scope = "arduino_user", roles = {"emm-user"}) + @Scope(key = "device:arduino:enroll", name = "", description = "") Response downloadSketch(@QueryParam("deviceName") String customDeviceName); } diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiService.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiService.java index 1fc893ca2..00236ddbe 100644 --- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiService.java +++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiService.java @@ -19,16 +19,11 @@ package org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl; import org.wso2.carbon.apimgt.annotations.api.API; -import org.wso2.carbon.apimgt.annotations.api.Permission; +import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.DeviceType; import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.Feature; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; + +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @@ -39,7 +34,7 @@ public interface RaspberryPiService { @Path("device/{deviceId}/bulb") @POST @Feature(code = "bulb", name = "Bulb On / Off", description = "Switch on/off Raspberry Pi agent's bulb. (On / Off)") - @Permission(scope = "raspberrypi_user", roles = {"emm-user"}) + @Scope(key = "device:raspberrypi:enroll", name = "", description = "") Response switchBulb(@PathParam("deviceId") String deviceId, @QueryParam("state") String state); /** @@ -49,7 +44,7 @@ public interface RaspberryPiService { @GET @Consumes("application/json") @Produces("application/json") - @Permission(scope = "raspberrypi_user", roles = {"emm-user"}) + @Scope(key = "device:raspberrypi:enroll", name = "", description = "") Response getRaspberryPiTemperatureStats(@PathParam("deviceId") String deviceId, @QueryParam("from") long from, @QueryParam("to") long to); @@ -59,7 +54,7 @@ public interface RaspberryPiService { @Path("device/download") @GET @Produces(MediaType.APPLICATION_JSON) - @Permission(scope = "raspberrypi_user", roles = {"emm-user"}) + @Scope(key = "device:raspberrypi:enroll", name = "", description = "") Response downloadSketch(@QueryParam("deviceName") String deviceName, @QueryParam("sketch_type") String sketchType); } diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmService.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmService.java index 1be685927..9d89050fb 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmService.java +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmService.java @@ -19,7 +19,7 @@ package org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl; import org.wso2.carbon.apimgt.annotations.api.API; -import org.wso2.carbon.apimgt.annotations.api.Permission; +import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.DeviceType; import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.Feature; @@ -48,7 +48,7 @@ public interface VirtualFireAlarmService { */ @POST @Path("device/{deviceId}/buzz") - @Permission(scope = "virtual_firealarm_user", roles = {"emm-user"}) + @Scope(key = "device:firealarm:enroll", name = "", description = "") @Feature(code = "buzz", name = "Buzzer On / Off", description = "Switch on/off Virtual Fire Alarm Buzzer. (On / Off)") Response switchBuzzer(@PathParam("deviceId") String deviceId, @FormParam("state") String state); @@ -58,7 +58,7 @@ public interface VirtualFireAlarmService { */ @Path("device/stats/{deviceId}") @GET - @Permission(scope = "virtual_firealarm_user", roles = {"emm-user"}) + @Scope(key = "device:firealarm:enroll", name = "", description = "") @Consumes("application/json") @Produces("application/json") Response getVirtualFirealarmStats(@PathParam("deviceId") String deviceId, @QueryParam("from") long from, @@ -67,7 +67,7 @@ public interface VirtualFireAlarmService { @Path("device/download") @GET @Produces("application/zip") - @Permission(scope = "virtual_firealarm_user", roles = {"emm-user"}) + @Scope(key = "device:firealarm:enroll", name = "", description = "") 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 6f3884a8a..a23eedb33 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementAdminService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementAdminService.java @@ -20,7 +20,7 @@ package org.wso2.carbon.mdm.services.android.services; import io.swagger.annotations.*; import org.wso2.carbon.apimgt.annotations.api.API; -import org.wso2.carbon.apimgt.annotations.api.Permission; +import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; import org.wso2.carbon.mdm.services.android.bean.wrapper.*; @@ -91,7 +91,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new lock operation.") }) - @Permission(scope = "device:android:lock", roles = {"admin"}) + @Scope(key = "device:android:operation:lock", name = "Lock device", description = "") Response configureDeviceLock( @ApiParam(name = "deviceLockBeanWrapper", value = "Device lock configurations with device IDs") DeviceLockBeanWrapper deviceLockBeanWrapper); @@ -145,7 +145,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new un-lock operation.") }) - @Permission(scope = "device:android:unlock", roles = {"admin"}) + @Scope(key = "device:android:operation:unlock", name = "Unlock device", description = "") Response configureDeviceUnlock( @ApiParam(name = "deviceIDs", value = "DeviceIds to be enable device unlock operation") List deviceIDs); @@ -198,7 +198,7 @@ public interface DeviceManagementAdminService { code = 500, message = "Internal Server Error. \n " + "Server error occurred while adding a new get-location operation.")}) - @Permission(scope = "device:android:location", roles = {"admin"}) + @Scope(key = "device:android:operation:location", name = "Get device location", description = "") Response getDeviceLocation( @ApiParam(name = "deviceIDs", value = "DeviceIDs to be requested to get device location") List deviceIDs); @@ -251,7 +251,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new clear password operation.") }) - @Permission(scope = "device:android:clear-password", roles = {"admin"}) + @Scope(key = "device:android:operation:clear-password", name = "Clear password of device", description = "") Response removePassword( @ApiParam(name = "deviceIDs", value = "DeviceIds to be requested to remove password") List deviceIDs); @@ -304,7 +304,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new control camera operation.") }) - @Permission(scope = "device:android:camera", roles = {"admin"}) + @Scope(key = "device:android:operation:camera", name = "Enable/Disable camera", description = "") Response configureCamera( @ApiParam(name = "cameraBeanWrapper", value = "Camera enable/disable configurations with device IDs") CameraBeanWrapper cameraBeanWrapper); @@ -360,7 +360,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new device info operation.") }) - @Permission(scope = "device:android:info", roles = {"admin"}) + @Scope(key = "device:android:operation:info", name = "Get device information", description = "") Response getDeviceInformation( @ApiParam(name = "deviceIds", value = "Device IDs to be requested to get device information") List deviceIDs); @@ -469,7 +469,7 @@ public interface DeviceManagementAdminService { code = 500, message = "Internal Server Error. \n " + "Server error occurred while adding a enterprise wipe operation.")}) - @Permission(scope = "device:android:enterprise-wipe", roles = {"admin"}) + @Scope(key = "device:android:operation:enterprise-wipe", name = "Enterprise wipe", description = "") Response wipeDevice(@ApiParam(name = "deviceIDs", value = "Device IDs to be requested to do enterprise-wipe") List deviceIDs); @@ -521,7 +521,7 @@ public interface DeviceManagementAdminService { code = 500, message = "Internal Server Error. \n " + "Server error occurred while adding a device wipe operation.")}) - @Permission(scope = "device:android:wipe", roles = {"admin"}) + @Scope(key = "device:android:operation:wipe", name = "Factory reset device", description = "") Response wipeData( @ApiParam(name = "wipeDataBeanWrapper", value = "Configurations and DeviceIds needed to do wipe-data") WipeDataBeanWrapper wipeDataBeanWrapper); @@ -578,7 +578,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new get-applications operation.") }) - @Permission(scope = "device:android:get-applications", roles = {"admin"}) + @Scope(key = "device:android:operation:applications", name = "Get installed applications", description = "") Response getApplications( @ApiParam(name = "deviceIDs", value = "Device Ids needed to get applications that are already installed") List deviceIDs); @@ -631,7 +631,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new device ring operation.") }) - @Permission(scope = "device:android:ring", roles = {"admin"}) + @Scope(key = "device:android:operation:ring", name = "Ring device", description = "") Response ringDevice( @ApiParam(name = "deviceIDs", value = "Device Ids needed for ring") List deviceIDs); @@ -684,7 +684,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new device reboot operation.") }) - @Permission(scope = "device:android:reboot", roles = {"admin"}) + @Scope(key = "device:android:operation:reboot", name = "Reboot device", description = "") Response rebootDevice( @ApiParam(name = "deviceIDs", value = "Device Ids needed for reboot.") List deviceIDs); @@ -737,7 +737,7 @@ public interface DeviceManagementAdminService { "Server error occurred while adding a new device mute operation.") }) @Path("/mute") - @Permission(scope = "device:android:mute", roles = {"admin"}) + @Scope(key = "device:android:operation:mute", name = "Mute device", description = "") Response muteDevice( @ApiParam(name = "deviceIDs", value = "DeviceIDs need to be muted") List deviceIDs); @@ -793,7 +793,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new install-application operation.") }) - @Permission(scope = "device:android:install-application", roles = {"admin"}) + @Scope(key = "device:android:operation:install-app", name = "Install applications", description = "") Response installApplication( @ApiParam(name = "applicationInstallationBeanWrapper", value = "Properties of installed apps and device IDs") ApplicationInstallationBeanWrapper applicationInstallationBeanWrapper); @@ -849,7 +849,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new update-application operation.") }) - @Permission(scope = "device:android:update-application", roles = {"admin"}) + @Scope(key = "device:android:operation:update-app", name = "Update installed applications", description = "") Response updateApplication( @ApiParam(name = "applicationUpdateBeanWrapper", value = "Properties of updated apps and device IDs") ApplicationUpdateBeanWrapper applicationUpdateBeanWrapper); @@ -902,7 +902,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new uninstall-application operation.") }) - @Permission(scope = "device:android:uninstall-application", roles = {"admin"}) + @Scope(key = "device:android:operation:uninstall-app", name = "Uninstall applications", description = "") Response uninstallApplication( @ApiParam(name = "applicationUninstallationBeanWrapper", value = "applicationUninstallationConfigs and Device Ids") @@ -957,7 +957,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new blacklist-applications operation.") }) - @Permission(scope = "device:android:blacklist-applications", roles = {"admin"}) + @Scope(key = "device:android:operation:blacklist-app", name = "Blacklist applications", description = "") Response blacklistApplications( @ApiParam(name = "blacklistApplicationsBeanWrapper", value = "BlacklistApplications " + "Configuration and DeviceIds") @@ -1012,7 +1012,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new upgrade firmware operation.") }) - @Permission(scope = "device:android:upgrade-firmware", roles = {"admin"}) + @Scope(key = "device:android:operation:upgrade", name = "Upgrade firmware", description = "") Response upgradeFirmware( @ApiParam(name = "upgradeFirmwareBeanWrapper", value = "Firmware upgrade configuration and DeviceIds") @@ -1067,7 +1067,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new configure VPN operation.") }) - @Permission(scope = "device:android:vpn", roles = {"admin"}) + @Scope(key = "device:android:operation:vpn", name = "Add VPN profiles", description = "") Response configureVPN( @ApiParam(name = "vpnBeanWrapper", value = "VPN configuration and DeviceIds") @@ -1121,7 +1121,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new send notification operation.") }) - @Permission(scope = "device:android:send-notification", roles = {"admin"}) + @Scope(key = "device:android:operation:notification", name = "Send notifications", description = "") Response sendNotification( @ApiParam(name = "notificationBeanWrapper", value = "Notification Configurations and device Ids") @@ -1175,7 +1175,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new configure wifi operation.") }) - @Permission(scope = "device:android:wifi", roles = {"admin"}) + @Scope(key = "device:android:operation:wifi", name = "Add WiFi configurations", description = "") Response configureWifi( @ApiParam(name = "wifiBeanWrapper", value = "WifiConfigurations and Device Ids") WifiBeanWrapper wifiBeanWrapper); @@ -1228,7 +1228,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new encrypt storage operation.") }) - @Permission(scope = "device:android:encrypt", roles = {"admin"}) + @Scope(key = "device:android:operation:encrypt", name = "Encrypt device", description = "") Response encryptStorage( @ApiParam(name = "encryptionBeanWrapper", value = "Configurations and deviceIds need to be done data encryption") @@ -1282,7 +1282,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new change lock code operation.") }) - @Permission(scope = "device:android:change-lock-code", roles = {"admin"}) + @Scope(key = "device:android:operation:change-lock", name = "Change password of device", description = "") Response changeLockCode( @ApiParam(name = "lockCodeBeanWrapper", value = "Configurations and device Ids need to be done change lock code") @@ -1336,7 +1336,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new set password policy operation.") }) - @Permission(scope = "device:android:set-password-policy", roles = {"admin"}) + @Scope(key = "device:android:operation:password-policy", name = "Set password policy", description = "") Response setPasswordPolicy( @ApiParam(name = "passwordPolicyBeanWrapper", value = "Password Policy Configurations and Device Ids") @@ -1390,7 +1390,7 @@ public interface DeviceManagementAdminService { message = "Internal Server Error. \n " + "Server error occurred while adding a new set webclip operation.") }) - @Permission(scope = "device:android:webclip", roles = {"admin"}) + @Scope(key = "device:android:operation:webclip", name = "Add webclips", description = "") Response setWebClip( @ApiParam(name = "webClipBeanWrapper", value = "Configurations to need set web clip on device and device Ids") diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java index 2aaaee1c7..b3fd5a35e 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 @@ -20,7 +20,7 @@ package org.wso2.carbon.mdm.services.android.services; import io.swagger.annotations.*; import org.wso2.carbon.apimgt.annotations.api.API; -import org.wso2.carbon.apimgt.annotations.api.Permission; +import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidApplication; import org.wso2.carbon.mdm.services.android.bean.wrapper.AndroidDevice; @@ -87,7 +87,7 @@ public interface DeviceManagementService { message = "Internal Server Error. \n " + "Server error occurred while updating the application list.") }) - @Permission(scope = "device:android:enroll", roles = {"admin"}) + @Scope(key = "device:android:enroll", name = "Enroll Android device", description = "") Response updateApplicationList( @ApiParam( name = "id", @@ -141,7 +141,7 @@ public interface DeviceManagementService { code = 500, message = "Internal Server Error. \n Server error occurred while fetching policies.") }) - @Permission(scope = "device:android:enroll", roles = {"admin"}) + @Scope(key = "device:android:enroll", name = "Enroll Android device", description = "") Response getPendingOperations( @ApiParam( name = "id", @@ -245,7 +245,7 @@ public interface DeviceManagementService { code = 500, message = "Internal Server Error. \n Server error occurred while fetching the enrollment status of the Android device.") }) - @Permission(scope = "device:android:enroll", roles = {"admin"}) + @Scope(key = "device:android:enroll", name = "Enroll Android device", description = "") Response isEnrolled( @ApiParam( name = "id", @@ -299,7 +299,7 @@ public interface DeviceManagementService { message = "Internal Server Error. \n " + "Server error occurred while updating the device enrollment.") }) - @Permission(scope = "device:android:enroll", roles = {"admin"}) + @Scope(key = "device:android:enroll", name = "Enroll Android device", description = "") Response modifyEnrollment( @ApiParam( name = "id", @@ -329,7 +329,7 @@ public interface DeviceManagementService { message = "Internal Server Error. \n " + "Server error occurred while dis-enrolling the device.") }) - @Permission(scope = "device:android:enroll", roles = {"admin"}) + @Scope(key = "device:android:enroll", name = "Enroll Android device", description = "") Response disEnrollDevice( @ApiParam( name = "id", diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java index 9a9012bb1..48737c083 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 @@ -20,7 +20,7 @@ package org.wso2.carbon.mdm.services.android.services; import io.swagger.annotations.*; import org.wso2.carbon.apimgt.annotations.api.API; -import org.wso2.carbon.apimgt.annotations.api.Permission; +import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.mdm.services.android.bean.AndroidPlatformConfiguration; import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException; @@ -81,7 +81,7 @@ public interface DeviceTypeConfigurationService { code = 500, message = "Internal Server Error. \n Server error occurred while fetching Android platform configuration.") }) - @Permission(scope = "configuration:view", roles = {"admin"}) + @Scope(key = "configuration:read", name = "View configurations", description = "") Response getConfiguration( @ApiParam( name = "If-Modified-Since", @@ -131,7 +131,7 @@ public interface DeviceTypeConfigurationService { message = "Internal Server Error. \n " + "Server error occurred while modifying Android platform configuration.") }) - @Permission(scope = "configuration:modify", roles = {"admin"}) + @Scope(key = "configuration:write", name = "Add configurations", description = "") Response updateConfiguration( @ApiParam(name = "configuration", value = "AndroidPlatformConfiguration") @@ -179,7 +179,7 @@ public interface DeviceTypeConfigurationService { code = 500, message = "Internal Server Error. \n Server error occurred while fetching Android license configuration.") }) - @Permission(scope = "device:android:enroll", roles = {"admin"}) + @Scope(key = "device:android:enroll", name = "Enroll Android device", description = "") Response getLicense( @ApiParam( name = "If-Modified-Since", diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/EventReceiverService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/EventReceiverService.java index eb6e270ed..ab9008e73 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 @@ -20,7 +20,7 @@ package org.wso2.carbon.mdm.services.android.services; import io.swagger.annotations.*; import org.wso2.carbon.apimgt.annotations.api.API; -import org.wso2.carbon.apimgt.annotations.api.Permission; +import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.mdm.services.android.bean.DeviceState; import org.wso2.carbon.mdm.services.android.bean.wrapper.EventBeanWrapper; @@ -91,7 +91,7 @@ public interface EventReceiverService { message = "Internal Server Error. \n " + "Server error occurred while publishing events.") }) - @Permission(scope = "device:android:event:publish", roles = {"admin"}) + @Scope(key = "device:android:event:write", name = "Publish events to DAS", description = "") Response publishEvents( @ApiParam( name = "eventBeanWrapper", @@ -141,7 +141,7 @@ public interface EventReceiverService { code = 500, message = "Error occurred while getting published events for specific device.") }) - @Permission(scope = "device:android:event:view", roles = {"admin"}) + @Scope(key = "device:android:event:read", name = "View events", description = "") Response retrieveAlerts( @ApiParam( name = "id", From 6e8f3f5db231c34033fd970f63ef5134e20c2927 Mon Sep 17 00:00:00 2001 From: mharindu Date: Mon, 8 Aug 2016 18:25:00 +0530 Subject: [PATCH 6/6] Modified scopes --- .../services/android/services/DeviceManagementService.java | 2 +- .../android/services/DeviceTypeConfigurationService.java | 4 ++-- 2 files changed, 3 insertions(+), 3 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/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 b3fd5a35e..71fcdba84 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java @@ -329,7 +329,7 @@ public interface DeviceManagementService { message = "Internal Server Error. \n " + "Server error occurred while dis-enrolling the device.") }) - @Scope(key = "device:android:enroll", name = "Enroll Android device", description = "") + @Scope(key = "device:android:disenroll", name = "Enroll Android device", description = "") Response disEnrollDevice( @ApiParam( name = "id", diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java index 48737c083..44d915028 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java @@ -81,7 +81,7 @@ public interface DeviceTypeConfigurationService { code = 500, message = "Internal Server Error. \n Server error occurred while fetching Android platform configuration.") }) - @Scope(key = "configuration:read", name = "View configurations", description = "") + @Scope(key = "configuration:view", name = "View configurations", description = "") Response getConfiguration( @ApiParam( name = "If-Modified-Since", @@ -131,7 +131,7 @@ public interface DeviceTypeConfigurationService { message = "Internal Server Error. \n " + "Server error occurred while modifying Android platform configuration.") }) - @Scope(key = "configuration:write", name = "Add configurations", description = "") + @Scope(key = "configuration:manage", name = "Add configurations", description = "") Response updateConfiguration( @ApiParam(name = "configuration", value = "AndroidPlatformConfiguration")