Added permission annotations to virtual fire alarm API

revert-dabc3590
mharindu 9 years ago
parent 34d4da7e66
commit 24e353698f

@ -19,6 +19,7 @@
package org.wso2.carbon.device.mgt.iot.androidsense.service.impl; 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.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.DeviceType;
import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.Feature; import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.Feature;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
@ -44,6 +45,7 @@ public interface AndroidSenseControllerService {
@Path("device/{deviceId}/words") @Path("device/{deviceId}/words")
@POST @POST
@Feature(code = "keywords", name = "Add Keywords", description = "Send keywords to the device", type = "operation") @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); Response sendKeyWords(@PathParam("deviceId") String deviceId, @QueryParam("keywords") String keywords);
/** /**
@ -56,12 +58,14 @@ public interface AndroidSenseControllerService {
@POST @POST
@Feature(code = "threshold", name = "Add a Threshold", description = "Set a threshold for word in the device", @Feature(code = "threshold", name = "Add a Threshold", description = "Set a threshold for word in the device",
type = "operation") type = "operation")
@Permission(scope = "android_sense_user", permissions = {"/permission/admin/device-mgt/user/operations"})
Response sendThreshold(@PathParam("deviceId") String deviceId, @QueryParam("threshold") String threshold); Response sendThreshold(@PathParam("deviceId") String deviceId, @QueryParam("threshold") String threshold);
@Path("device/{deviceId}/words") @Path("device/{deviceId}/words")
@DELETE @DELETE
@Feature(code = "remove", name = "Remove Keywords", description = "Remove the keywords", @Feature(code = "remove", name = "Remove Keywords", description = "Remove the keywords",
type = "operation") type = "operation")
@Permission(scope = "android_sense_user", permissions = {"/permission/admin/device-mgt/user/operations"})
Response removeKeyWords(@PathParam("deviceId") String deviceId, @QueryParam("words") String words); Response removeKeyWords(@PathParam("deviceId") String deviceId, @QueryParam("words") String words);
/** /**
@ -71,6 +75,7 @@ public interface AndroidSenseControllerService {
@GET @GET
@Consumes("application/json") @Consumes("application/json")
@Produces("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, Response getAndroidSenseDeviceStats(@PathParam("deviceId") String deviceId, @PathParam("sensorName") String sensor,
@QueryParam("from") long from, @QueryParam("to") long to); @QueryParam("from") long from, @QueryParam("to") long to);

@ -19,6 +19,7 @@
package org.wso2.carbon.device.mgt.iot.androidsense.service.impl; 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.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.DeviceType;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE; import javax.ws.rs.DELETE;
@ -36,20 +37,24 @@ public interface AndroidSenseManagerService {
@Path("/devices/{device_id}") @Path("/devices/{device_id}")
@POST @POST
@Permission(scope = "android_sense_user", permissions = {"/permission/admin/device-mgt/user/devices"})
Response register(@PathParam("device_id") String deviceId, @QueryParam("deviceName") String deviceName); Response register(@PathParam("device_id") String deviceId, @QueryParam("deviceName") String deviceName);
@Path("/devices/{device_id}") @Path("/devices/{device_id}")
@DELETE @DELETE
@Permission(scope = "android_sense_user", permissions = {"/permission/admin/device-mgt/user/devices/remove"})
Response removeDevice(@PathParam("device_id") String deviceId); Response removeDevice(@PathParam("device_id") String deviceId);
@Path("/devices/{device_id}") @Path("/devices/{device_id}")
@PUT @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); Response updateDevice(@PathParam("device_id") String deviceId, @QueryParam("name") String name);
@Path("/devices/{device_id}") @Path("/devices/{device_id}")
@GET @GET
@Consumes("application/json") @Consumes("application/json")
@Produces("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); Response getDevice(@PathParam("device_id") String deviceId);
} }

@ -49,7 +49,7 @@ public interface VirtualFireAlarmControllerService {
*/ */
@POST @POST
@Path("device/{deviceId}/buzz") @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", @Feature(code = "buzz", name = "Buzzer On / Off", type = "operation",
description = "Switch on/off Virtual Fire Alarm Buzzer. (On / Off)") description = "Switch on/off Virtual Fire Alarm Buzzer. (On / Off)")
Response switchBuzzer(@PathParam("deviceId") String deviceId, @QueryParam("protocol") String protocol, Response switchBuzzer(@PathParam("deviceId") String deviceId, @QueryParam("protocol") String protocol,
@ -61,7 +61,7 @@ public interface VirtualFireAlarmControllerService {
*/ */
@Path("device/stats/{deviceId}") @Path("device/stats/{deviceId}")
@GET @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") @Consumes("application/json")
@Produces("application/json") @Produces("application/json")
Response getVirtualFirealarmStats(@PathParam("deviceId") String deviceId, @QueryParam("from") long from, Response getVirtualFirealarmStats(@PathParam("deviceId") String deviceId, @QueryParam("from") long from,

@ -19,6 +19,7 @@
package org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl; 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.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.DeviceType;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
@ -38,28 +39,33 @@ public interface VirtualFireAlarmManagerService {
@Path("/devices/{device_id}") @Path("/devices/{device_id}")
@DELETE @DELETE
@Permission(scope = "virtual_firealarm_user", permissions = {"/permission/admin/device-mgt/user/devices/remove"})
Response removeDevice(@PathParam("device_id") String deviceId); Response removeDevice(@PathParam("device_id") String deviceId);
@Path("/devices/{device_id}") @Path("/devices/{device_id}")
@PUT @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); Response updateDevice(@PathParam("device_id") String deviceId, @QueryParam("name") String name);
@Path("/devices/{device_id}") @Path("/devices/{device_id}")
@GET @GET
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Produces(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); Response getDevice(@PathParam("device_id") String deviceId);
@Path("/devices") @Path("/devices")
@GET @GET
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Permission(scope = "virtual_firealarm_user", permissions = {"/device-mgt/user/devices/list"})
Response getFirealarmDevices(); Response getFirealarmDevices();
@Path("/devices/download") @Path("/devices/download")
@GET @GET
@Produces("application/zip") @Produces("application/zip")
@Permission(scope = "virtual_firealarm_user", permissions = {"/permission/admin/device-mgt/user"})
Response downloadSketch(@QueryParam("deviceName") String deviceName, @QueryParam("sketchType") String sketchType); Response downloadSketch(@QueryParam("deviceName") String deviceName, @QueryParam("sketchType") String sketchType);
} }

@ -44,7 +44,7 @@
</Permission> </Permission>
<Permission> <Permission>
<name>Download device</name> <name>Download device</name>
<path>/device-mgt/virtual_firealarm/user</path> <path>/device-mgt/user</path>
<url>/enrollment/devices/download</url> <url>/enrollment/devices/download</url>
<method>GET</method> <method>GET</method>
<scope>virtual_firealarm_user</scope> <scope>virtual_firealarm_user</scope>
@ -63,32 +63,18 @@
<method>GET</method> <method>GET</method>
<scope>virtual_firealarm_user</scope> <scope>virtual_firealarm_user</scope>
</Permission> </Permission>
<Permission>
<name>Register Device</name>
<path>/device-mgt/user/operations</path>
<url>/device/register/*/*/*</url>
<method>POST</method>
<scope>virtual_firealarm_device</scope>
</Permission>
<Permission> <Permission>
<name>Control Buzz</name> <name>Control Buzz</name>
<path>/device-mgt/user/operations</path> <path>/device-mgt/user/operation</path>
<url>/device/*/buzz</url> <url>/device/*/buzz</url>
<method>POST</method> <method>POST</method>
<scope>virtual_firealarm_user</scope> <scope>virtual_firealarm_user</scope>
</Permission> </Permission>
<Permission>
<name>Push Temperature</name>
<path>/device-mgt/user/stats</path>
<url>/device/temperature</url>
<method>POST</method>
<scope>virtual_firealarm_device</scope>
</Permission>
<Permission> <Permission>
<name>Get Stats</name> <name>Get Stats</name>
<path>/device-mgt/user/stats</path> <path>/device-mgt/user/stats</path>
<url>/device/stats/*</url> <url>/device/stats/*</url>
<method>GET</method> <method>GET</method>
<scope>virtual_firealarm_device</scope> <scope>virtual_firealarm_user</scope>
</Permission> </Permission>
</PermissionConfiguration> </PermissionConfiguration>
Loading…
Cancel
Save