forked from community/device-mgt-plugins
parent
8106b42c0f
commit
18b8f0c41d
@ -0,0 +1,206 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>device-mgt-iot-androidsense</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<version>1.9.2-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.wso2.carbon.device.mgt.iot.androidsense.controller.api</artifactId>
|
||||
<version>1.9.2-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
<name>WSO2 Carbon - Android Sense Controller API</name>
|
||||
<description>WSO2 Carbon - Android Sense Service Controller API Implementation</description>
|
||||
<url>http://wso2.org</url>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<!-- CDM -->
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache.axis2.wso2</groupId>
|
||||
<artifactId>axis2-client</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!--CXF -->
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-frontend-jaxws</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-transports-http</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--MQTT -->
|
||||
<dependency>
|
||||
<groupId>org.eclipse.paho</groupId>
|
||||
<artifactId>mqtt-client</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--IOT -->
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpasyncclient</artifactId>
|
||||
<version>4.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.iot</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.iot.androidsense</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--JAX-RS -->
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-core-asl</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-jaxrs</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax</groupId>
|
||||
<artifactId>javaee-web-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>jsr311-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.analytics</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-httpclient.wso2</groupId>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.utils</artifactId>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bouncycastle.wso2</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.user.api</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.queuing</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.base</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.axis2.wso2</groupId>
|
||||
<artifactId>axis2</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.igniterealtime.smack.wso2</groupId>
|
||||
<artifactId>smack</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.igniterealtime.smack.wso2</groupId>
|
||||
<artifactId>smackx</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>jaxen</groupId>
|
||||
<artifactId>jaxen</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>commons-fileupload.wso2</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.ant.wso2</groupId>
|
||||
<artifactId>ant</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.ant.wso2</groupId>
|
||||
<artifactId>ant</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>commons-httpclient.wso2</groupId>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.equinox</groupId>
|
||||
<artifactId>javax.servlet</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.registry.api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.apimgt.webapp.publisher</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
<source>${wso2.maven.compiler.source}</source>
|
||||
<target>${wso2.maven.compiler.target}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<configuration>
|
||||
<warName>android_sense</warName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
170
components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseService.java → components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.controller.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/controller/service/impl/AndroidSenseService.java
170
components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseService.java → components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.controller.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/controller/service/impl/AndroidSenseService.java
2
components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/DeviceJSON.java → components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.controller.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/controller/service/impl/util/DeviceJSON.java
2
components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/DeviceJSON.java → components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.controller.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/controller/service/impl/util/DeviceJSON.java
@ -1,4 +1,4 @@
|
||||
package org.wso2.carbon.device.mgt.iot.androidsense.service.impl.util;
|
||||
package org.wso2.carbon.device.mgt.iot.androidsense.controller.service.impl.util;
|
||||
|
||||
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
|
||||
|
2
components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/SensorJSON.java → components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.controller.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/controller/service/impl/util/SensorJSON.java
2
components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/SensorJSON.java → components/device-mgt-iot-androidsense/org.wso2.carbon.device.mgt.iot.androidsense.controller.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/controller/service/impl/util/SensorJSON.java
@ -1,4 +1,4 @@
|
||||
package org.wso2.carbon.device.mgt.iot.androidsense.service.impl.util;
|
||||
package org.wso2.carbon.device.mgt.iot.androidsense.controller.service.impl.util;
|
||||
|
||||
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
|
||||
|
@ -0,0 +1,223 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.iot.androidsense.mgt.service.impl;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.apimgt.annotations.api.API;
|
||||
import org.wso2.carbon.apimgt.webapp.publisher.KeyGenerationUtil;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
|
||||
import org.wso2.carbon.device.mgt.iot.DeviceManagement;
|
||||
import org.wso2.carbon.device.mgt.iot.androidsense.plugin.constants.AndroidSenseConstants;
|
||||
import org.wso2.carbon.device.mgt.iot.apimgt.AccessTokenInfo;
|
||||
import org.wso2.carbon.device.mgt.iot.apimgt.TokenClient;
|
||||
import org.wso2.carbon.device.mgt.iot.exception.AccessTokenException;
|
||||
import org.wso2.carbon.utils.CarbonUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.io.File;
|
||||
import java.util.Date;
|
||||
|
||||
@API( name="android_sense", version="1.0.0", context="/android_sense")
|
||||
public class AndroidSenseService {
|
||||
|
||||
private static Log log = LogFactory.getLog(AndroidSenseService.class);
|
||||
|
||||
//TODO; replace this tenant domain
|
||||
private final String SUPER_TENANT = "carbon.super";
|
||||
|
||||
@Context //injected response proxy supporting multiple thread
|
||||
private HttpServletResponse response;
|
||||
|
||||
@Path("manager/device")
|
||||
@PUT
|
||||
public boolean register(@FormParam("deviceId") String deviceId,
|
||||
@FormParam("owner") String owner) {
|
||||
|
||||
DeviceManagement deviceManagement = new DeviceManagement(SUPER_TENANT);
|
||||
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||
deviceIdentifier.setId(deviceId);
|
||||
deviceIdentifier.setType(AndroidSenseConstants.DEVICE_TYPE);
|
||||
try {
|
||||
if (deviceManagement.getDeviceManagementService().isEnrolled(deviceIdentifier)) {
|
||||
response.setStatus(Response.Status.CONFLICT.getStatusCode());
|
||||
return true;
|
||||
}
|
||||
Device device = new Device();
|
||||
device.setDeviceIdentifier(deviceId);
|
||||
EnrolmentInfo enrolmentInfo = new EnrolmentInfo();
|
||||
|
||||
// KeyGenerationUtil.createApplicationKeys("android_sense");
|
||||
//
|
||||
// TokenClient accessTokenClient = new TokenClient(AndroidSenseConstants.DEVICE_TYPE);
|
||||
// AccessTokenInfo accessTokenInfo = accessTokenClient.getAccessToken(owner, deviceId);
|
||||
//
|
||||
// //create token
|
||||
// String accessToken = accessTokenInfo.getAccess_token();
|
||||
// String refreshToken = accessTokenInfo.getRefresh_token();
|
||||
|
||||
enrolmentInfo.setDateOfEnrolment(new Date().getTime());
|
||||
enrolmentInfo.setDateOfLastUpdate(new Date().getTime());
|
||||
enrolmentInfo.setStatus(EnrolmentInfo.Status.ACTIVE);
|
||||
enrolmentInfo.setOwnership(EnrolmentInfo.OwnerShip.BYOD);
|
||||
String name = owner + " android " + deviceId;
|
||||
device.setName(name);
|
||||
device.setType(AndroidSenseConstants.DEVICE_TYPE);
|
||||
enrolmentInfo.setOwner(owner);
|
||||
device.setEnrolmentInfo(enrolmentInfo);
|
||||
boolean added = deviceManagement.getDeviceManagementService().enrollDevice(device);
|
||||
|
||||
if (added) {
|
||||
response.setStatus(Response.Status.OK.getStatusCode());
|
||||
// response.addHeader("access", accessToken);
|
||||
// response.addHeader("refresh", refreshToken);
|
||||
} else {
|
||||
response.setStatus(Response.Status.NOT_ACCEPTABLE.getStatusCode());
|
||||
}
|
||||
|
||||
return added;
|
||||
} catch (DeviceManagementException e) {
|
||||
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
|
||||
return false;
|
||||
} finally {
|
||||
deviceManagement.endTenantFlow();
|
||||
}
|
||||
}
|
||||
|
||||
@Path("manager/device/remove/{device_id}")
|
||||
@DELETE
|
||||
public void removeDevice(@PathParam("device_id") String deviceId,
|
||||
@Context HttpServletResponse response) {
|
||||
|
||||
DeviceManagement deviceManagement = new DeviceManagement(SUPER_TENANT);
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||
deviceIdentifier.setId(deviceId);
|
||||
deviceIdentifier.setType(AndroidSenseConstants.DEVICE_TYPE);
|
||||
try {
|
||||
boolean removed = deviceManagement.getDeviceManagementService().disenrollDevice(deviceIdentifier);
|
||||
if (removed) {
|
||||
response.setStatus(Response.Status.OK.getStatusCode());
|
||||
|
||||
} else {
|
||||
response.setStatus(Response.Status.NOT_ACCEPTABLE.getStatusCode());
|
||||
|
||||
}
|
||||
} catch (DeviceManagementException e) {
|
||||
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
|
||||
} finally {
|
||||
deviceManagement.endTenantFlow();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Path("manager/device/update/{device_id}")
|
||||
@POST
|
||||
public boolean updateDevice(
|
||||
@PathParam("device_id") String deviceId, @QueryParam("name") String name,
|
||||
@Context HttpServletResponse response) {
|
||||
|
||||
DeviceManagement deviceManagement = new DeviceManagement(SUPER_TENANT);
|
||||
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||
deviceIdentifier.setId(deviceId);
|
||||
deviceIdentifier.setType(AndroidSenseConstants.DEVICE_TYPE);
|
||||
try {
|
||||
Device device = deviceManagement.getDeviceManagementService().getDevice(deviceIdentifier);
|
||||
device.setDeviceIdentifier(deviceId);
|
||||
|
||||
// device.setDeviceTypeId(deviceTypeId);
|
||||
device.getEnrolmentInfo().setDateOfLastUpdate(new Date().getTime());
|
||||
|
||||
device.setName(name);
|
||||
device.setType(AndroidSenseConstants.DEVICE_TYPE);
|
||||
|
||||
boolean updated = deviceManagement.getDeviceManagementService().modifyEnrollment(device);
|
||||
|
||||
if (updated) {
|
||||
response.setStatus(Response.Status.OK.getStatusCode());
|
||||
|
||||
} else {
|
||||
response.setStatus(Response.Status.NOT_ACCEPTABLE.getStatusCode());
|
||||
|
||||
}
|
||||
return updated;
|
||||
} catch (DeviceManagementException e) {
|
||||
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
|
||||
return false;
|
||||
} finally {
|
||||
deviceManagement.endTenantFlow();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Path("manager/device/{device_id}")
|
||||
@GET
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public Device getDevice(
|
||||
@PathParam("device_id") String deviceId) {
|
||||
|
||||
DeviceManagement deviceManagement = new DeviceManagement(SUPER_TENANT);
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||
deviceIdentifier.setId(deviceId);
|
||||
deviceIdentifier.setType(AndroidSenseConstants.DEVICE_TYPE);
|
||||
|
||||
try {
|
||||
return deviceManagement.getDeviceManagementService().getDevice(deviceIdentifier);
|
||||
|
||||
} catch (DeviceManagementException e) {
|
||||
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
|
||||
return null;
|
||||
} finally {
|
||||
deviceManagement.endTenantFlow();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Path("manager/device/{sketch_type}/download")
|
||||
@GET
|
||||
@Produces("application/octet-stream")
|
||||
public Response downloadSketch(@PathParam("sketch_type") String sketchType) {
|
||||
//TODO:: null check customDeviceName at UI level
|
||||
try {
|
||||
|
||||
String sep = File.separator;
|
||||
String sketchFolder = "repository" + sep + "resources" + sep + "sketches" + sep + "android_sense" + sep;
|
||||
String archivesPath = CarbonUtils.getCarbonHome() + sep + sketchFolder;
|
||||
|
||||
Response.ResponseBuilder rb = Response.ok(new File(archivesPath+sep+"androidsense.apk"));
|
||||
rb.header("Content-Disposition",
|
||||
"attachment; filename=\"" + "androidsense.apk" + "\"");
|
||||
return rb.build();
|
||||
} catch (IllegalArgumentException ex) {
|
||||
return Response.status(400).entity(ex.getMessage()).build();//bad request
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ you may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<!-- This file contains the list of permissions that are associated with URL end points
|
||||
of the web app. Each permission should contain the name, permission path ,API path
|
||||
(URL) , HTTP method and OAUTH2 authorization scope (not-required).
|
||||
When defining dynamic paths for APIs, path variables are denoted by '*' notation.
|
||||
For ex:
|
||||
Actual API endpoint: mdm-admin/1.0.0/devices/{device-id}
|
||||
URL to be represented here: /devices/*
|
||||
NOTE: All the endpoints of the web app should be available in this file. Otherwise
|
||||
it will result 403 error at the runtime.
|
||||
-->
|
||||
|
||||
<ResourceConfiguration>
|
||||
<!-- Device related APIs -->
|
||||
<Resource>
|
||||
<AuthType>Any</AuthType>
|
||||
<HttpVerb>PUT</HttpVerb>
|
||||
<Uri>http://localhost:9763/android_sense/manager/device/register</Uri>
|
||||
<UriTemplate>/manager/device/register/*</UriTemplate>
|
||||
</Resource>
|
||||
<Resource>
|
||||
<AuthType>Any</AuthType>
|
||||
<HttpVerb>DELETE</HttpVerb>
|
||||
<Uri>http://localhost:9763/android_sense/manager/device/remove</Uri>
|
||||
<UriTemplate>/manager/device/remove/*</UriTemplate>
|
||||
</Resource>
|
||||
<Resource>
|
||||
<AuthType>Any</AuthType>
|
||||
<HttpVerb>POST</HttpVerb>
|
||||
<Uri>http://localhost:9763/android_sense/manager/device/update</Uri>
|
||||
<UriTemplate>/manager/device/update/*</UriTemplate>
|
||||
</Resource>
|
||||
<Resource>
|
||||
<AuthType>Any</AuthType>
|
||||
<HttpVerb>GET</HttpVerb>
|
||||
<Uri>http://localhost:9763/android_sense/manager/device/{device_id}</Uri>
|
||||
<UriTemplate>/manager/device/{device_id}</UriTemplate>
|
||||
</Resource>
|
||||
<Resource>
|
||||
<AuthType>Any</AuthType>
|
||||
<HttpVerb>GET</HttpVerb>
|
||||
<Uri>http://localhost:9763/android_sense/controller/sensordata</Uri>
|
||||
<UriTemplate>/controller/sensordata</UriTemplate>
|
||||
</Resource>
|
||||
<Resource>
|
||||
<AuthType>Any</AuthType>
|
||||
<HttpVerb>GET</HttpVerb>
|
||||
<Uri>http://localhost:9763/android_sense/controller/readbattery</Uri>
|
||||
<UriTemplate>/controller/readbattery</UriTemplate>
|
||||
</Resource>
|
||||
<Resource>
|
||||
<AuthType>Any</AuthType>
|
||||
<HttpVerb>GET</HttpVerb>
|
||||
<Uri>http://localhost:9763/android_sense/controller/readlight</Uri>
|
||||
<UriTemplate>/controller/readlight</UriTemplate>
|
||||
</Resource>
|
||||
<Resource>
|
||||
<AuthType>Any</AuthType>
|
||||
<HttpVerb>GET</HttpVerb>
|
||||
<Uri>http://localhost:9763/android_sense/controller/readgps</Uri>
|
||||
<UriTemplate>/controller/readgps</UriTemplate>
|
||||
</Resource>
|
||||
<Resource>
|
||||
<AuthType>Any</AuthType>
|
||||
<HttpVerb>GET</HttpVerb>
|
||||
<Uri>http://localhost:9763/android_sense/controller/readmagnetic</Uri>
|
||||
<UriTemplate>/controller/readmagnetic</UriTemplate>
|
||||
</Resource>
|
||||
<Resource>
|
||||
<AuthType>Any</AuthType>
|
||||
<HttpVerb>GET</HttpVerb>
|
||||
<Uri>http://localhost:9763/android_sense/controller/readgravity</Uri>
|
||||
<UriTemplate>/controller/readgravity</UriTemplate>
|
||||
</Resource>
|
||||
<Resource>
|
||||
<AuthType>Any</AuthType>
|
||||
<HttpVerb>GET</HttpVerb>
|
||||
<Uri>http://localhost:9763/android_sense/controller/readpressure</Uri>
|
||||
<UriTemplate>/controller/readpressure</UriTemplate>
|
||||
</Resource>
|
||||
<Resource>
|
||||
<AuthType>Any</AuthType>
|
||||
<HttpVerb>GET</HttpVerb>
|
||||
<Uri>http://localhost:9763/android_sense/controller/readproximity</Uri>
|
||||
<UriTemplate>/controller/readproximity</UriTemplate>
|
||||
</Resource>
|
||||
<Resource>
|
||||
<AuthType>Any</AuthType>
|
||||
<HttpVerb>GET</HttpVerb>
|
||||
<Uri>http://localhost:9763/android_sense/controller/readgyroscope</Uri>
|
||||
<UriTemplate>/controller/readgyroscope</UriTemplate>
|
||||
</Resource>
|
||||
<Resource>
|
||||
<AuthType>Any</AuthType>
|
||||
<HttpVerb>GET</HttpVerb>
|
||||
<Uri>http://localhost:9763/android_sense/controller/readrotation</Uri>
|
||||
<UriTemplate>/controller/readrotation</UriTemplate>
|
||||
</Resource>
|
||||
<Resource>
|
||||
<AuthType>Any</AuthType>
|
||||
<HttpVerb>GET</HttpVerb>
|
||||
<Uri>http://localhost:9763/android_sense/controller/readaccelerometer</Uri>
|
||||
<UriTemplate>/controller/readaccelerometer</UriTemplate>
|
||||
</Resource>
|
||||
</ResourceConfiguration>
|
@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
|
||||
<!--
|
||||
~ Copyright 2005-2013 WSO2, Inc. (http://wso2.com)
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<!--
|
||||
This file defines class loading policy of the whole container. But this behaviour can be overridden by individual webapps by putting this file into the META-INF/ directory.
|
||||
-->
|
||||
<Classloading xmlns="http://wso2.org/projects/as/classloading">
|
||||
|
||||
<!-- Parent-first or child-first. Default behaviour is child-first.-->
|
||||
<ParentFirst>false</ParentFirst>
|
||||
|
||||
<!--
|
||||
Default environments that contains provides to all the webapps. This can be overridden by individual webapps by specifing required environments
|
||||
Tomcat environment is the default and every webapps gets it even if they didn't specify it.
|
||||
e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
|
||||
-->
|
||||
<Environments>CXF,Carbon</Environments>
|
||||
</Classloading>
|
@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
~ Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:cxf="http://cxf.apache.org/core"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
|
||||
|
||||
|
||||
|
||||
<jaxrs:server id="AndroidSense" address="/">
|
||||
<jaxrs:features>
|
||||
<cxf:logging/>
|
||||
</jaxrs:features>
|
||||
<jaxrs:serviceBeans>
|
||||
<bean id="AndroidSenseMgtService"
|
||||
class="org.wso2.carbon.device.mgt.iot.androidsense.mgt.service.impl.AndroidSenseService"/>
|
||||
</jaxrs:serviceBeans>
|
||||
<jaxrs:providers>
|
||||
<bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider" />
|
||||
</jaxrs:providers>
|
||||
</jaxrs:server>
|
||||
|
||||
</beans>
|
||||
|
@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<web-app version="2.5"
|
||||
xmlns="http://java.sun.com/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
|
||||
metadata-complete="true">
|
||||
<display-name>Android Sense</display-name>
|
||||
<description>Android Sense</description>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>CXFServlet</servlet-name>
|
||||
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>CXFServlet</servlet-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<!--<context-param>-->
|
||||
<!--<param-name>isAdminService</param-name>-->
|
||||
<!--<param-value>false</param-value>-->
|
||||
<!--</context-param>-->
|
||||
<!--<context-param>-->
|
||||
<!--<param-name>doAuthentication</param-name>-->
|
||||
<!--<param-value>false</param-value>-->
|
||||
<!--</context-param>-->
|
||||
|
||||
<!--publish to apim-->
|
||||
<context-param>
|
||||
<param-name>managed-api-enabled</param-name>
|
||||
<param-value>false</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>managed-api-owner</param-name>
|
||||
<param-value>admin</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>managed-api-name</param-name>
|
||||
<param-value>android_sense</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>managed-api-endpoint</param-name>
|
||||
<param-value>https://localhost:9443/android_sense</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>managed-api-version</param-name>
|
||||
<param-value>1.0.0</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>managed-api-context</param-name>
|
||||
<param-value>/android_sense</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>managed-api-isSecured</param-name>
|
||||
<param-value>true</param-value>
|
||||
</context-param>
|
||||
|
||||
<!-- Below configuration is used to redirect http requests to https -->
|
||||
<!--<security-constraint>-->
|
||||
<!--<web-resource-collection>-->
|
||||
<!--<web-resource-name>IoT</web-resource-name>-->
|
||||
<!--<url-pattern>/*</url-pattern>-->
|
||||
<!--</web-resource-collection>-->
|
||||
<!--<user-data-constraint>-->
|
||||
<!--<transport-guarantee>CONFIDENTIAL</transport-guarantee>-->
|
||||
<!--</user-data-constraint>-->
|
||||
<!--</security-constraint>-->
|
||||
|
||||
|
||||
</web-app>
|
Loading…
Reference in new issue