From 24e353698f0714894ef4e37eb175091b424fb911 Mon Sep 17 00:00:00 2001 From: mharindu Date: Mon, 16 May 2016 12:12:47 +0530 Subject: [PATCH] Added permission annotations to virtual fire alarm API --- .../impl/AndroidSenseControllerService.java | 5 +++++ .../impl/AndroidSenseManagerService.java | 5 +++++ .../VirtualFireAlarmControllerService.java | 4 ++-- .../impl/VirtualFireAlarmManagerService.java | 6 ++++++ .../src/main/webapp/META-INF/permissions.xml | 20 +++---------------- 5 files changed, 21 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/AndroidSenseControllerService.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/AndroidSenseControllerService.java index 43792b859b..bbd8358a8d 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/AndroidSenseControllerService.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/AndroidSenseControllerService.java @@ -19,6 +19,7 @@ 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.device.mgt.extensions.feature.mgt.annotations.DeviceType; import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.Feature; import javax.ws.rs.Consumes; @@ -44,6 +45,7 @@ public interface AndroidSenseControllerService { @Path("device/{deviceId}/words") @POST @Feature(code = "keywords", name = "Add Keywords", description = "Send keywords to the device", type = "operation") + @Permission(scope = "android_sense_user", permissions = {"/permission/admin/device-mgt/user/operations"}) Response sendKeyWords(@PathParam("deviceId") String deviceId, @QueryParam("keywords") String keywords); /** @@ -56,12 +58,14 @@ public interface AndroidSenseControllerService { @POST @Feature(code = "threshold", name = "Add a Threshold", description = "Set a threshold for word in the device", type = "operation") + @Permission(scope = "android_sense_user", permissions = {"/permission/admin/device-mgt/user/operations"}) 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", type = "operation") + @Permission(scope = "android_sense_user", permissions = {"/permission/admin/device-mgt/user/operations"}) Response removeKeyWords(@PathParam("deviceId") String deviceId, @QueryParam("words") String words); /** @@ -71,6 +75,7 @@ public interface AndroidSenseControllerService { @GET @Consumes("application/json") @Produces("application/json") + @Permission(scope = "android_sense_device", permissions = {"/permission/admin/device-mgt/user/stats"}) Response getAndroidSenseDeviceStats(@PathParam("deviceId") String deviceId, @PathParam("sensorName") String sensor, @QueryParam("from") long from, @QueryParam("to") long to); 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/AndroidSenseManagerService.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/AndroidSenseManagerService.java index 68e48074ac..1e03db16ea 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/AndroidSenseManagerService.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/AndroidSenseManagerService.java @@ -19,6 +19,7 @@ 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.device.mgt.extensions.feature.mgt.annotations.DeviceType; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -36,20 +37,24 @@ public interface AndroidSenseManagerService { @Path("/devices/{device_id}") @POST + @Permission(scope = "android_sense_user", permissions = {"/permission/admin/device-mgt/user/devices"}) Response register(@PathParam("device_id") String deviceId, @QueryParam("deviceName") String deviceName); @Path("/devices/{device_id}") @DELETE + @Permission(scope = "android_sense_user", permissions = {"/permission/admin/device-mgt/user/devices/remove"}) Response removeDevice(@PathParam("device_id") String deviceId); @Path("/devices/{device_id}") @PUT + @Permission(scope = "android_sense_user", permissions = {"/permission/admin/device-mgt/user/devices/update"}) Response updateDevice(@PathParam("device_id") String deviceId, @QueryParam("name") String name); @Path("/devices/{device_id}") @GET @Consumes("application/json") @Produces("application/json") + @Permission(scope = "android_sense_user", permissions = {"/permission/admin/device-mgt/user/devices/list"}) Response getDevice(@PathParam("device_id") String deviceId); } 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/VirtualFireAlarmControllerService.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/VirtualFireAlarmControllerService.java index 3bbbe3ad49..30523c4444 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/VirtualFireAlarmControllerService.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/VirtualFireAlarmControllerService.java @@ -49,7 +49,7 @@ public interface VirtualFireAlarmControllerService { */ @POST @Path("device/{deviceId}/buzz") - @Permission(scope = "virtual_firealarm_user", permissions = {"device-mgt/virtual_firealarm/user"}) + @Permission(scope = "virtual_firealarm_user", permissions = {"/permission/admin/device-mgt/user/operation"}) @Feature(code = "buzz", name = "Buzzer On / Off", type = "operation", description = "Switch on/off Virtual Fire Alarm Buzzer. (On / Off)") Response switchBuzzer(@PathParam("deviceId") String deviceId, @QueryParam("protocol") String protocol, @@ -61,7 +61,7 @@ public interface VirtualFireAlarmControllerService { */ @Path("device/stats/{deviceId}") @GET - @Permission(scope = "virtual_firealarm_user", permissions = {"device-mgt/virtual_firealarm/user"}) + @Permission(scope = "virtual_firealarm_user", permissions = {"/permission/admin/device-mgt/user/stats"}) @Consumes("application/json") @Produces("application/json") Response getVirtualFirealarmStats(@PathParam("deviceId") String deviceId, @QueryParam("from") long from, 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/VirtualFireAlarmManagerService.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/VirtualFireAlarmManagerService.java index 7b5bdaf097..4b0f3c13fd 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/VirtualFireAlarmManagerService.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/VirtualFireAlarmManagerService.java @@ -19,6 +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.device.mgt.extensions.feature.mgt.annotations.DeviceType; import javax.ws.rs.Consumes; @@ -38,28 +39,33 @@ public interface VirtualFireAlarmManagerService { @Path("/devices/{device_id}") @DELETE + @Permission(scope = "virtual_firealarm_user", permissions = {"/permission/admin/device-mgt/user/devices/remove"}) Response removeDevice(@PathParam("device_id") String deviceId); @Path("/devices/{device_id}") @PUT + @Permission(scope = "virtual_firealarm_user", permissions = {"/permission/admin/device-mgt/user/devices/update"}) Response updateDevice(@PathParam("device_id") String deviceId, @QueryParam("name") String name); @Path("/devices/{device_id}") @GET @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) + @Permission(scope = "virtual_firealarm_user", permissions = {"/permission/admin/device-mgt/user/devices/list"}) Response getDevice(@PathParam("device_id") String deviceId); @Path("/devices") @GET @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) + @Permission(scope = "virtual_firealarm_user", permissions = {"/device-mgt/user/devices/list"}) Response getFirealarmDevices(); @Path("/devices/download") @GET @Produces("application/zip") + @Permission(scope = "virtual_firealarm_user", permissions = {"/permission/admin/device-mgt/user"}) Response downloadSketch(@QueryParam("deviceName") String deviceName, @QueryParam("sketchType") String sketchType); } \ No newline at end of file diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/META-INF/permissions.xml b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/META-INF/permissions.xml index 8b8957385b..072cd1e74a 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/META-INF/permissions.xml +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/META-INF/permissions.xml @@ -44,7 +44,7 @@ Download device - /device-mgt/virtual_firealarm/user + /device-mgt/user /enrollment/devices/download GET virtual_firealarm_user @@ -63,32 +63,18 @@ GET virtual_firealarm_user - - Register Device - /device-mgt/user/operations - /device/register/*/*/* - POST - virtual_firealarm_device - Control Buzz - /device-mgt/user/operations + /device-mgt/user/operation /device/*/buzz POST virtual_firealarm_user - - Push Temperature - /device-mgt/user/stats - /device/temperature - POST - virtual_firealarm_device - Get Stats /device-mgt/user/stats /device/stats/* GET - virtual_firealarm_device + virtual_firealarm_user \ No newline at end of file