Added permissions to firealarm API

revert-dabc3590
mharindu 9 years ago
parent ac407a6a1a
commit f6d75bb880

@ -19,23 +19,16 @@
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 org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.Feature; import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.Feature;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl.dto.DeviceData; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl.dto.DeviceData;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes; import javax.ws.rs.*;
import javax.ws.rs.FormParam;
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.core.Context; import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.io.InputStream;
/** /**
* This class consists the functions/APIs specific to the "actions" of the VirtualFirealarm device-type. These APIs * This class consists the functions/APIs specific to the "actions" of the VirtualFirealarm device-type. These APIs
@ -44,7 +37,7 @@ import java.io.InputStream;
* the transport 'Connectors' [XMPP & MQTT] specific to the VirtualFirealarm device-type in order to communicate with * the transport 'Connectors' [XMPP & MQTT] specific to the VirtualFirealarm device-type in order to communicate with
* such devices and to receive messages form it. * such devices and to receive messages form it.
*/ */
@API(name = "virtual_firealarm", version = "1.0.0", context = "/virtual_firealarm", tags = "virtual_firealarm") @API(name = "virtual_firealarm", version = "1.0.0", context = "/virtual_firealarm", tags = {"virtual_firealarm"})
@DeviceType(value = "virtual_firealarm") @DeviceType(value = "virtual_firealarm")
public interface VirtualFireAlarmControllerService { public interface VirtualFireAlarmControllerService {
@ -64,6 +57,7 @@ public interface VirtualFireAlarmControllerService {
*/ */
@POST @POST
@Path("device/register/{deviceId}/{ip}/{port}") @Path("device/register/{deviceId}/{ip}/{port}")
@Permission(scope = "virtual_firealarm_admin", permissions = {"device-mgt/virtual_firealarm/admin"})
Response registerDeviceIP(@PathParam("deviceId") String deviceId, @PathParam("ip") String deviceIP, Response registerDeviceIP(@PathParam("deviceId") String deviceId, @PathParam("ip") String deviceIP,
@PathParam("port") String devicePort, @Context HttpServletRequest request); @PathParam("port") String devicePort, @Context HttpServletRequest request);
@ -80,6 +74,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"})
@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,
@ -94,6 +89,7 @@ public interface VirtualFireAlarmControllerService {
*/ */
@POST @POST
@Path("device/temperature") @Path("device/temperature")
@Permission(scope = "virtual_firealarm_admin", permissions = {"device-mgt/virtual_firealarm/admin"})
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
Response pushTemperatureData(final DeviceData dataMsg); Response pushTemperatureData(final DeviceData dataMsg);
@ -103,6 +99,7 @@ public interface VirtualFireAlarmControllerService {
*/ */
@Path("device/stats/{deviceId}/sensors/{sensorName}") @Path("device/stats/{deviceId}/sensors/{sensorName}")
@GET @GET
@Permission(scope = "virtual_firealarm_user", permissions = {"device-mgt/virtual_firealarm/user"})
@Consumes("application/json") @Consumes("application/json")
@Produces("application/json") @Produces("application/json")
Response getVirtualFirealarmStats(@PathParam("deviceId") String deviceId, Response getVirtualFirealarmStats(@PathParam("deviceId") String deviceId,

@ -23,6 +23,7 @@ import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.analytics.dataservice.commons.SORT; import org.wso2.carbon.analytics.dataservice.commons.SORT;
import org.wso2.carbon.analytics.dataservice.commons.SortByField; import org.wso2.carbon.analytics.dataservice.commons.SortByField;
import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException; import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException;
import org.wso2.carbon.apimgt.annotations.api.Permission;
import org.wso2.carbon.certificate.mgt.core.dto.SCEPResponse; import org.wso2.carbon.certificate.mgt.core.dto.SCEPResponse;
import org.wso2.carbon.certificate.mgt.core.exception.KeystoreException; import org.wso2.carbon.certificate.mgt.core.exception.KeystoreException;
import org.wso2.carbon.certificate.mgt.core.service.CertificateManagementService; import org.wso2.carbon.certificate.mgt.core.service.CertificateManagementService;
@ -78,6 +79,7 @@ public class VirtualFireAlarmControllerServiceImpl implements VirtualFireAlarmCo
// holds a mapping of the IP addresses to Device-IDs for HTTP communication // holds a mapping of the IP addresses to Device-IDs for HTTP communication
private ConcurrentHashMap<String, String> deviceToIpMap = new ConcurrentHashMap<>(); private ConcurrentHashMap<String, String> deviceToIpMap = new ConcurrentHashMap<>();
@Permission(scope = "virtual_firealarm_user", permissions = {"device-mgt/virtual_firealarm/user"})
@POST @POST
@Path("device/register/{deviceId}/{ip}/{port}") @Path("device/register/{deviceId}/{ip}/{port}")
public Response registerDeviceIP(@PathParam("deviceId") String deviceId, @PathParam("ip") String deviceIP, public Response registerDeviceIP(@PathParam("deviceId") String deviceId, @PathParam("ip") String deviceIP,

@ -33,7 +33,7 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
@Path("enrollment") @Path("enrollment")
@API(name = "virtual_firealarm_mgt", version = "1.0.0", context = "/virtual_firealarm_mgt", tags = "virtual_firealarm") @API(name = "virtual_firealarm_mgt", version = "1.0.0", context = "/virtual_firealarm_mgt", tags = {"virtual_firealarm"})
public interface VirtualFireAlarmManagerService { public interface VirtualFireAlarmManagerService {
@Path("/devices/{device_id}") @Path("/devices/{device_id}")

Loading…
Cancel
Save