forked from community/device-mgt-plugins
parent
a61433d35a
commit
f5ae0e7cc3
@ -0,0 +1,174 @@
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<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/maven-v4_0_0.xsd">
|
||||
|
||||
<parent>
|
||||
<artifactId>device-mgt-mdm-android</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.mobile.android.api</artifactId>
|
||||
<name>Android JAX-RS API</name>
|
||||
<description>Android JAX-RS API</description>
|
||||
<packaging>war</packaging>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.5</source>
|
||||
<target>1.5</target>
|
||||
</configuration>
|
||||
<version>2.3.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
<configuration>
|
||||
<packagingExcludes>WEB-INF/lib/*cxf*.jar</packagingExcludes>
|
||||
<warName>${project.artifactId}</warName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>deploy</id>
|
||||
<build>
|
||||
<defaultGoal>compile</defaultGoal>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<version>1.7</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<copy todir="${basedir}/../../../repository/deployment/server/webapps" overwrite="true">
|
||||
<fileset dir="${basedir}/target">
|
||||
<include name="${project.artifactId}.war" />
|
||||
</fileset>
|
||||
</copy>
|
||||
</tasks>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>client</id>
|
||||
<build>
|
||||
<defaultGoal>test</defaultGoal>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>java</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-frontend-jaxws</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-transports-http</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>jsr311-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.utils</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.logging</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!--CDM Dependencies-->
|
||||
<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>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.policy.mgt.common</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.policy.mgt.core</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-httpclient.wso2</groupId>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,161 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.services.android;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
|
||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration;
|
||||
import org.wso2.carbon.device.mgt.common.license.mgt.License;
|
||||
import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
|
||||
import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils;
|
||||
import org.wso2.carbon.mdm.services.android.util.AndroidConstants;
|
||||
import org.wso2.carbon.mdm.services.android.util.Message;
|
||||
|
||||
import javax.jws.WebService;
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Android Platform Configuration REST-API implementation.
|
||||
* All end points supports JSON, XMl with content negotiation.
|
||||
*/
|
||||
@WebService
|
||||
@Produces({ "application/json", "application/xml" })
|
||||
@Consumes({ "application/json", "application/xml" })
|
||||
public class ConfigurationMgtService {
|
||||
|
||||
private static Log log = LogFactory.getLog(ConfigurationMgtService.class);
|
||||
|
||||
@POST
|
||||
public Message configureSettings(TenantConfiguration configuration)
|
||||
throws AndroidAgentException {
|
||||
|
||||
Message responseMsg = new Message();
|
||||
String msg;
|
||||
ConfigurationEntry licenseEntry = null;
|
||||
try {
|
||||
configuration.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||
List<ConfigurationEntry> configs = configuration.getConfiguration();
|
||||
for(ConfigurationEntry entry : configs){
|
||||
if(AndroidConstants.TenantConfigProperties.LICENSE_KEY.equals(entry.getName())){
|
||||
License license = new License();
|
||||
license.setName(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||
license.setLanguage(AndroidConstants.TenantConfigProperties.LANGUAGE_US);
|
||||
license.setVersion("1.0.0");
|
||||
license.setText(entry.getValue().toString());
|
||||
AndroidAPIUtils.getDeviceManagementService().addLicense(DeviceManagementConstants.
|
||||
MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, license);
|
||||
licenseEntry = entry;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(licenseEntry != null) {
|
||||
configs.remove(licenseEntry);
|
||||
}
|
||||
configuration.setConfiguration(configs);
|
||||
AndroidAPIUtils.getDeviceManagementService().saveConfiguration(configuration);
|
||||
Response.status(Response.Status.CREATED);
|
||||
responseMsg.setResponseMessage("Android platform configuration saved successfully.");
|
||||
responseMsg.setResponseCode(Response.Status.CREATED.toString());
|
||||
} catch (DeviceManagementException e) {
|
||||
msg = "Error occurred while configuring the android platform";
|
||||
log.error(msg, e);
|
||||
throw new AndroidAgentException(msg, e);
|
||||
}
|
||||
return responseMsg;
|
||||
}
|
||||
|
||||
@GET
|
||||
public TenantConfiguration getConfiguration() throws AndroidAgentException {
|
||||
String msg;
|
||||
TenantConfiguration tenantConfiguration;
|
||||
List<ConfigurationEntry> configs;
|
||||
try {
|
||||
tenantConfiguration = AndroidAPIUtils.getDeviceManagementService().
|
||||
getConfiguration(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||
if(tenantConfiguration != null) {
|
||||
configs = tenantConfiguration.getConfiguration();
|
||||
} else {
|
||||
tenantConfiguration = new TenantConfiguration();
|
||||
configs = new ArrayList<ConfigurationEntry>();
|
||||
}
|
||||
|
||||
ConfigurationEntry entry = new ConfigurationEntry();
|
||||
License license = AndroidAPIUtils.getDeviceManagementService().getLicense(
|
||||
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, AndroidConstants.
|
||||
TenantConfigProperties.LANGUAGE_US);
|
||||
|
||||
if(license != null && configs != null) {
|
||||
entry.setContentType(AndroidConstants.TenantConfigProperties.CONTENT_TYPE_TEXT);
|
||||
entry.setName(AndroidConstants.TenantConfigProperties.LICENSE_KEY);
|
||||
entry.setValue(license.getText());
|
||||
configs.add(entry);
|
||||
tenantConfiguration.setConfiguration(configs);
|
||||
}
|
||||
} catch (DeviceManagementException e) {
|
||||
msg = "Error occurred while retrieving the Android tenant configuration";
|
||||
log.error(msg, e);
|
||||
throw new AndroidAgentException(msg, e);
|
||||
}
|
||||
return tenantConfiguration;
|
||||
}
|
||||
|
||||
@PUT
|
||||
public Message updateConfiguration(TenantConfiguration configuration) throws AndroidAgentException {
|
||||
String msg;
|
||||
Message responseMsg = new Message();
|
||||
ConfigurationEntry licenseEntry = null;
|
||||
try {
|
||||
configuration.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||
List<ConfigurationEntry> configs = configuration.getConfiguration();
|
||||
for(ConfigurationEntry entry : configs){
|
||||
if(AndroidConstants.TenantConfigProperties.LICENSE_KEY.equals(entry.getName())){
|
||||
License license = new License();
|
||||
license.setName(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||
license.setLanguage(AndroidConstants.TenantConfigProperties.LANGUAGE_US);
|
||||
license.setVersion("1.0.0");
|
||||
license.setText(entry.getValue().toString());
|
||||
AndroidAPIUtils.getDeviceManagementService().addLicense(DeviceManagementConstants.
|
||||
MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, license);
|
||||
licenseEntry = entry;
|
||||
}
|
||||
}
|
||||
|
||||
if(licenseEntry != null) {
|
||||
configs.remove(licenseEntry);
|
||||
}
|
||||
configuration.setConfiguration(configs);
|
||||
AndroidAPIUtils.getDeviceManagementService().saveConfiguration(configuration);
|
||||
Response.status(Response.Status.ACCEPTED);
|
||||
responseMsg.setResponseMessage("Android platform configuration has updated successfully.");
|
||||
responseMsg.setResponseCode(Response.Status.ACCEPTED.toString());
|
||||
} catch (DeviceManagementException e) {
|
||||
msg = "Error occurred while modifying configuration settings of Android platform";
|
||||
log.error(msg, e);
|
||||
throw new AndroidAgentException(msg, e);
|
||||
}
|
||||
return responseMsg;
|
||||
}
|
||||
}
|
@ -0,0 +1,183 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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.
|
||||
*/
|
||||
package org.wso2.carbon.mdm.services.android;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
|
||||
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.license.mgt.License;
|
||||
import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
|
||||
import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils;
|
||||
import org.wso2.carbon.mdm.services.android.util.Message;
|
||||
|
||||
import javax.jws.WebService;
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Android Device Management REST-API implementation.
|
||||
* All end points supports JSON, XMl with content negotiation.
|
||||
*/
|
||||
@WebService
|
||||
@Produces({ "application/json", "application/xml" })
|
||||
@Consumes({ "application/json", "application/xml" })
|
||||
public class DeviceManagementService {
|
||||
|
||||
private static Log log = LogFactory.getLog(DeviceManagementService.class);
|
||||
|
||||
/**
|
||||
* Get all devices.Returns list of Android devices registered in MDM.
|
||||
*
|
||||
* @return Device List
|
||||
* @throws org.wso2.carbon.mdm.services.android.exception.AndroidAgentException
|
||||
*/
|
||||
@GET
|
||||
public List<org.wso2.carbon.device.mgt.common.Device> getAllDevices()
|
||||
throws AndroidAgentException {
|
||||
String msg;
|
||||
List<org.wso2.carbon.device.mgt.common.Device> devices;
|
||||
|
||||
try {
|
||||
devices = AndroidAPIUtils.getDeviceManagementService().
|
||||
getAllDevices(DeviceManagementConstants.MobileDeviceTypes.
|
||||
MOBILE_DEVICE_TYPE_ANDROID);
|
||||
} catch (DeviceManagementException e) {
|
||||
msg = "Error occurred while fetching the device list.";
|
||||
log.error(msg, e);
|
||||
throw new AndroidAgentException(msg, e);
|
||||
}
|
||||
return devices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch Android device details of a given device Id.
|
||||
*
|
||||
* @param id Device Id
|
||||
* @return Device
|
||||
* @throws org.wso2.carbon.mdm.services.android.exception.AndroidAgentException
|
||||
*/
|
||||
@GET
|
||||
@Path("{id}")
|
||||
public org.wso2.carbon.device.mgt.common.Device getDevice(@PathParam("id") String id)
|
||||
throws AndroidAgentException {
|
||||
|
||||
String msg;
|
||||
org.wso2.carbon.device.mgt.common.Device device;
|
||||
|
||||
try {
|
||||
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
|
||||
device = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier);
|
||||
if (device == null) {
|
||||
Response.status(Response.Status.NOT_FOUND);
|
||||
}
|
||||
} catch (DeviceManagementException deviceMgtEx) {
|
||||
msg = "Error occurred while fetching the device information.";
|
||||
log.error(msg, deviceMgtEx);
|
||||
throw new AndroidAgentException(msg, deviceMgtEx);
|
||||
}
|
||||
return device;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Android device details of given device id.
|
||||
*
|
||||
* @param id Device Id
|
||||
* @param device Device Details
|
||||
* @return Message
|
||||
* @throws AndroidAgentException
|
||||
*/
|
||||
@PUT
|
||||
@Path("{id}")
|
||||
public Message updateDevice(@PathParam("id") String id, Device device)
|
||||
throws AndroidAgentException {
|
||||
String msg;
|
||||
Message responseMessage = new Message();
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||
deviceIdentifier.setId(id);
|
||||
deviceIdentifier
|
||||
.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||
boolean result;
|
||||
try {
|
||||
device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||
result = AndroidAPIUtils.getDeviceManagementService()
|
||||
.updateDeviceInfo(deviceIdentifier, device);
|
||||
if (result) {
|
||||
Response.status(Response.Status.ACCEPTED);
|
||||
responseMessage.setResponseMessage("Device information has modified successfully.");
|
||||
} else {
|
||||
Response.status(Response.Status.NOT_MODIFIED);
|
||||
responseMessage.setResponseMessage("Device not found for the update.");
|
||||
}
|
||||
} catch (DeviceManagementException e) {
|
||||
msg = "Error occurred while modifying the device information.";
|
||||
log.error(msg, e);
|
||||
throw new AndroidAgentException(msg, e);
|
||||
}
|
||||
return responseMessage;
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("appList/{id}")
|
||||
public Message updateApplicationList(@PathParam("id") String id, List<Application> applications)
|
||||
throws
|
||||
AndroidAgentException {
|
||||
|
||||
Message responseMessage = new Message();
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||
deviceIdentifier.setId(id);
|
||||
deviceIdentifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||
try {
|
||||
AndroidAPIUtils.getApplicationManagerService().
|
||||
updateApplicationListInstalledInDevice(deviceIdentifier, applications);
|
||||
Response.status(Response.Status.ACCEPTED);
|
||||
responseMessage.setResponseMessage("Device information has modified successfully.");
|
||||
|
||||
} catch (ApplicationManagementException e) {
|
||||
String msg = "Error occurred while modifying the application list.";
|
||||
log.error(msg, e);
|
||||
throw new AndroidAgentException(msg, e);
|
||||
}
|
||||
return responseMessage;
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("license")
|
||||
@Produces("text/html")
|
||||
public String getLicense() throws AndroidAgentException {
|
||||
License license;
|
||||
|
||||
try {
|
||||
license =
|
||||
AndroidAPIUtils.getDeviceManagementService().getLicense(
|
||||
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID,
|
||||
DeviceManagementConstants.LanguageCodes.LANGUAGE_CODE_ENGLISH_US);
|
||||
} catch (DeviceManagementException e) {
|
||||
String msg = "Error occurred while retrieving the license configured for Android device enrolment";
|
||||
log.error(msg, e);
|
||||
throw new AndroidAgentException(msg, e);
|
||||
}
|
||||
return (license == null) ? null : license.getText();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.services.android;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
|
||||
import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils;
|
||||
import org.wso2.carbon.mdm.services.android.util.Message;
|
||||
|
||||
import javax.jws.WebService;
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
/**
|
||||
* Android Device Enrollment REST-API implementation.
|
||||
* All end points supports JSON, XMl with content negotiation.
|
||||
*/
|
||||
@WebService
|
||||
@Produces({ "application/json", "application/xml" })
|
||||
@Consumes({ "application/json", "application/xml" })
|
||||
public class EnrollmentService {
|
||||
|
||||
private static Log log = LogFactory.getLog(EnrollmentService.class);
|
||||
|
||||
@POST
|
||||
public Message enrollDevice(org.wso2.carbon.device.mgt.common.Device device)
|
||||
throws AndroidAgentException {
|
||||
|
||||
Message responseMsg = new Message();
|
||||
String msg;
|
||||
try {
|
||||
device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||
AndroidAPIUtils.getDeviceManagementService().enrollDevice(device);
|
||||
Response.status(Response.Status.CREATED);
|
||||
responseMsg.setResponseMessage("Device enrollment succeeded");
|
||||
responseMsg.setResponseCode(Response.Status.CREATED.toString());
|
||||
} catch (DeviceManagementException e) {
|
||||
msg = "Error occurred while enrolling the device";
|
||||
log.error(msg, e);
|
||||
throw new AndroidAgentException(msg, e);
|
||||
}
|
||||
return responseMsg;
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{deviceId}")
|
||||
public Message isEnrolled(@PathParam("deviceId") String id) throws AndroidAgentException {
|
||||
String msg;
|
||||
boolean result;
|
||||
Message responseMsg = new Message();
|
||||
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
|
||||
|
||||
try {
|
||||
result = AndroidAPIUtils.getDeviceManagementService().isEnrolled(deviceIdentifier);
|
||||
if (result) {
|
||||
responseMsg.setResponseMessage("Device has already enrolled");
|
||||
responseMsg.setResponseCode(Response.Status.ACCEPTED.toString());
|
||||
Response.status(Response.Status.ACCEPTED);
|
||||
} else {
|
||||
responseMsg.setResponseMessage("Device not found");
|
||||
responseMsg.setResponseCode(Response.Status.NOT_FOUND.toString());
|
||||
Response.status(Response.Status.NOT_FOUND);
|
||||
}
|
||||
} catch (DeviceManagementException e) {
|
||||
msg = "Error occurred while enrollment of the device.";
|
||||
log.error(msg, e);
|
||||
throw new AndroidAgentException(msg, e);
|
||||
}
|
||||
return responseMsg;
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("{deviceId}")
|
||||
public Message modifyEnrollment(@PathParam("deviceId") String id,
|
||||
org.wso2.carbon.device.mgt.common.Device device)
|
||||
throws AndroidAgentException {
|
||||
String msg;
|
||||
boolean result;
|
||||
Message responseMsg = new Message();
|
||||
try {
|
||||
device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||
result = AndroidAPIUtils.getDeviceManagementService().modifyEnrollment(device);
|
||||
if (result) {
|
||||
responseMsg.setResponseMessage("Device enrollment has updated successfully");
|
||||
responseMsg.setResponseCode(Response.Status.ACCEPTED.toString());
|
||||
Response.status(Response.Status.ACCEPTED);
|
||||
} else {
|
||||
responseMsg.setResponseMessage("Device not found for enrollment");
|
||||
responseMsg.setResponseCode(Response.Status.NOT_MODIFIED.toString());
|
||||
Response.status(Response.Status.NOT_MODIFIED);
|
||||
}
|
||||
} catch (DeviceManagementException e) {
|
||||
msg = "Error occurred while modifying enrollment of the device";
|
||||
log.error(msg, e);
|
||||
throw new AndroidAgentException(msg, e);
|
||||
}
|
||||
return responseMsg;
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("{deviceId}")
|
||||
public Message disEnrollDevice(@PathParam("deviceId") String id) throws AndroidAgentException {
|
||||
Message responseMsg = new Message();
|
||||
boolean result;
|
||||
String msg;
|
||||
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
|
||||
|
||||
try {
|
||||
result = AndroidAPIUtils.getDeviceManagementService().disenrollDevice(deviceIdentifier);
|
||||
if (result) {
|
||||
responseMsg.setResponseMessage("Device has removed successfully");
|
||||
responseMsg.setResponseCode(Response.Status.ACCEPTED.toString());
|
||||
Response.status(Response.Status.ACCEPTED);
|
||||
} else {
|
||||
responseMsg.setResponseMessage("Device not found");
|
||||
responseMsg.setResponseCode(Response.Status.NOT_FOUND.toString());
|
||||
Response.status(Response.Status.NOT_FOUND);
|
||||
}
|
||||
} catch (DeviceManagementException e) {
|
||||
msg = "Error occurred while dis enrolling the device";
|
||||
log.error(msg, e);
|
||||
throw new AndroidAgentException(msg, e);
|
||||
}
|
||||
return responseMsg;
|
||||
}
|
||||
}
|
@ -0,0 +1,931 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.services.android;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.notification.mgt.*;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
||||
import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation;
|
||||
import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation;
|
||||
import org.wso2.carbon.mdm.services.android.bean.*;
|
||||
import org.wso2.carbon.mdm.services.android.bean.Notification;
|
||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.*;
|
||||
import org.wso2.carbon.mdm.services.android.exception.AndroidOperationException;
|
||||
import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils;
|
||||
import org.wso2.carbon.mdm.services.android.util.AndroidConstants;
|
||||
import org.wso2.carbon.mdm.services.android.util.AndroidDeviceUtils;
|
||||
import org.wso2.carbon.mdm.services.android.util.Message;
|
||||
import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException;
|
||||
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Android Device Operation REST-API implementation.
|
||||
*/
|
||||
public class OperationMgtService {
|
||||
|
||||
private static Log log = LogFactory.getLog(OperationMgtService.class);
|
||||
private static final String ACCEPT = "Accept";
|
||||
private static final String OPERATION_ERROR_STATUS = "ERROR";
|
||||
private static final String DEVICE_TYPE_ANDROID = "android";
|
||||
|
||||
@PUT
|
||||
@Path("{id}")
|
||||
public List<? extends Operation> getPendingOperations
|
||||
(@HeaderParam(ACCEPT) String acceptHeader, @PathParam("id") String id,
|
||||
List<? extends Operation> resultOperations) {
|
||||
Message message;
|
||||
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
|
||||
|
||||
if (id == null || id.isEmpty()) {
|
||||
String errorMessage = "Device identifier is null or empty, hence returning device not found";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.BAD_REQUEST.toString()).build();
|
||||
log.error(errorMessage);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
}
|
||||
|
||||
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
|
||||
try {
|
||||
if (!AndroidDeviceUtils.isValidDeviceIdentifier(deviceIdentifier)) {
|
||||
String errorMessage = "Device not found for identifier '" + id + "'";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.BAD_REQUEST.toString()).build();
|
||||
log.error(errorMessage);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
}
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invoking Android pending operations:" + id);
|
||||
}
|
||||
if (resultOperations != null && !resultOperations.isEmpty()) {
|
||||
updateOperations(id, resultOperations);
|
||||
}
|
||||
} catch (OperationManagementException e) {
|
||||
log.error("Issue in retrieving operation management service instance", e);
|
||||
} catch (PolicyComplianceException e) {
|
||||
log.error("Issue in updating Monitoring operation");
|
||||
} catch (DeviceManagementException e) {
|
||||
log.error("Issue in retrieving device management service instance", e);
|
||||
} catch (ApplicationManagementException e) {
|
||||
log.error("Issue in retrieving application management service instance", e);
|
||||
} catch (NotificationManagementException e) {
|
||||
log.error("Issue in retrieving Notification management service instance", e);
|
||||
}
|
||||
|
||||
List<? extends Operation> pendingOperations;
|
||||
try {
|
||||
pendingOperations = AndroidAPIUtils.getPendingOperations(deviceIdentifier);
|
||||
} catch (OperationManagementException e) {
|
||||
String errorMessage = "Issue in retrieving operation management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
}
|
||||
return pendingOperations;
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("lock")
|
||||
public Response configureDeviceLock(@HeaderParam(ACCEPT) String acceptHeader, List<String> deviceIDs) {
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invoking Android device lock operation");
|
||||
}
|
||||
|
||||
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
|
||||
Message message = new Message();
|
||||
Response response;
|
||||
|
||||
try {
|
||||
CommandOperation operation = new CommandOperation();
|
||||
operation.setCode(AndroidConstants.OperationCodes.DEVICE_LOCK);
|
||||
operation.setType(Operation.Type.COMMAND);
|
||||
operation.setEnabled(true);
|
||||
response = AndroidAPIUtils.getOperationResponse(deviceIDs, operation, message, responseMediaType);
|
||||
} catch (OperationManagementException e) {
|
||||
String errorMessage = "Issue in retrieving operation management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
} catch (DeviceManagementException e) {
|
||||
String errorMessage = "Issue in retrieving device management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("location")
|
||||
public Response getDeviceLocation(@HeaderParam(ACCEPT) String acceptHeader,
|
||||
List<String> deviceIDs) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invoking Android device location operation");
|
||||
}
|
||||
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
|
||||
Message message = new Message();
|
||||
|
||||
try {
|
||||
CommandOperation operation = new CommandOperation();
|
||||
operation.setCode(AndroidConstants.OperationCodes.DEVICE_LOCATION);
|
||||
operation.setType(Operation.Type.COMMAND);
|
||||
return AndroidAPIUtils.getOperationResponse(deviceIDs, operation,
|
||||
message, responseMediaType);
|
||||
} catch (OperationManagementException e) {
|
||||
String errorMessage = "Issue in retrieving operation management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
} catch (DeviceManagementException e) {
|
||||
String errorMessage = "Issue in retrieving device management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("clear-password")
|
||||
public Response removePassword(@HeaderParam(ACCEPT) String acceptHeader,
|
||||
List<String> deviceIDs) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invoking Android clear password operation");
|
||||
}
|
||||
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
|
||||
Message message = new Message();
|
||||
|
||||
try {
|
||||
CommandOperation operation = new CommandOperation();
|
||||
operation.setCode(AndroidConstants.OperationCodes.CLEAR_PASSWORD);
|
||||
operation.setType(Operation.Type.COMMAND);
|
||||
|
||||
return AndroidAPIUtils.getOperationResponse(deviceIDs, operation,
|
||||
message, responseMediaType);
|
||||
|
||||
} catch (OperationManagementException e) {
|
||||
String errorMessage = "Issue in retrieving operation management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
} catch (DeviceManagementException e) {
|
||||
String errorMessage = "Issue in retrieving device management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("camera")
|
||||
public Response configureCamera(@HeaderParam(ACCEPT) String acceptHeader,
|
||||
CameraBeanWrapper cameraBeanWrapper) {
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invoking Android Camera operation");
|
||||
}
|
||||
|
||||
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
|
||||
Message message = new Message();
|
||||
|
||||
try {
|
||||
Camera camera = cameraBeanWrapper.getOperation();
|
||||
|
||||
if (camera == null) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("The payload of the configure camera operation is incorrect");
|
||||
}
|
||||
throw new OperationManagementException("Issue in creating a new camera instance");
|
||||
}
|
||||
|
||||
CommandOperation operation = new CommandOperation();
|
||||
operation.setCode(AndroidConstants.OperationCodes.CAMERA);
|
||||
operation.setType(Operation.Type.COMMAND);
|
||||
operation.setEnabled(camera.isEnabled());
|
||||
|
||||
return AndroidAPIUtils.getOperationResponse(cameraBeanWrapper.getDeviceIDs(), operation, message,
|
||||
responseMediaType);
|
||||
|
||||
} catch (OperationManagementException e) {
|
||||
String errorMessage = "Issue in retrieving operation management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
} catch (DeviceManagementException e) {
|
||||
String errorMessage = "Issue in retrieving device management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("device-info")
|
||||
public Response getDeviceInformation(@HeaderParam(ACCEPT) String acceptHeader,
|
||||
List<String> deviceIDs) {
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invoking get Android device information operation");
|
||||
}
|
||||
|
||||
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
|
||||
Message message = new Message();
|
||||
|
||||
try {
|
||||
CommandOperation operation = new CommandOperation();
|
||||
operation.setCode(AndroidConstants.OperationCodes.DEVICE_INFO);
|
||||
operation.setType(Operation.Type.COMMAND);
|
||||
getApplications(acceptHeader, deviceIDs);
|
||||
return AndroidAPIUtils.getOperationResponse(deviceIDs, operation, message,
|
||||
responseMediaType);
|
||||
} catch (OperationManagementException e) {
|
||||
String errorMessage = "Issue in retrieving operation management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
} catch (DeviceManagementException e) {
|
||||
String errorMessage = "Issue in retrieving device management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("enterprise-wipe")
|
||||
public Response wipeDevice(@HeaderParam(ACCEPT) String acceptHeader,
|
||||
List<String> deviceIDs) {
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invoking enterprise-wipe device operation");
|
||||
}
|
||||
|
||||
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
|
||||
Message message = new Message();
|
||||
|
||||
try {
|
||||
CommandOperation operation = new CommandOperation();
|
||||
operation.setCode(AndroidConstants.OperationCodes.ENTERPRISE_WIPE);
|
||||
operation.setType(Operation.Type.COMMAND);
|
||||
|
||||
return AndroidAPIUtils.getOperationResponse(deviceIDs, operation, message,
|
||||
responseMediaType);
|
||||
} catch (OperationManagementException e) {
|
||||
String errorMessage = "Issue in retrieving operation management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
} catch (DeviceManagementException e) {
|
||||
String errorMessage = "Issue in retrieving device management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("wipe-data")
|
||||
public Response wipeData(@HeaderParam(ACCEPT) String acceptHeader,
|
||||
WipeDataBeanWrapper wipeDataBeanWrapper) {
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invoking Android wipe-data device operation");
|
||||
}
|
||||
|
||||
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
|
||||
Message message = new Message();
|
||||
|
||||
try {
|
||||
WipeData wipeData = wipeDataBeanWrapper.getOperation();
|
||||
|
||||
if (wipeData == null) {
|
||||
throw new OperationManagementException("WipeData bean is empty");
|
||||
}
|
||||
|
||||
ProfileOperation operation = new ProfileOperation();
|
||||
operation.setCode(AndroidConstants.OperationCodes.WIPE_DATA);
|
||||
operation.setType(Operation.Type.PROFILE);
|
||||
operation.setPayLoad(wipeData.toJSON());
|
||||
|
||||
return AndroidAPIUtils.getOperationResponse(wipeDataBeanWrapper.getDeviceIDs(), operation, message,
|
||||
responseMediaType);
|
||||
|
||||
} catch (OperationManagementException e) {
|
||||
String errorMessage = "Issue in retrieving operation management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
} catch (DeviceManagementException e) {
|
||||
String errorMessage = "Issue in retrieving device management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("application-list")
|
||||
public Response getApplications(@HeaderParam(ACCEPT) String acceptHeader,
|
||||
List<String> deviceIDs) {
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invoking Android getApplicationList device operation");
|
||||
}
|
||||
|
||||
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
|
||||
Message message = new Message();
|
||||
|
||||
try {
|
||||
CommandOperation operation = new CommandOperation();
|
||||
operation.setCode(AndroidConstants.OperationCodes.APPLICATION_LIST);
|
||||
operation.setType(Operation.Type.COMMAND);
|
||||
|
||||
return AndroidAPIUtils.getOperationResponse(deviceIDs, operation, message,
|
||||
responseMediaType);
|
||||
} catch (OperationManagementException e) {
|
||||
String errorMessage = "Issue in retrieving operation management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
} catch (DeviceManagementException e) {
|
||||
String errorMessage = "Issue in retrieving device management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("ring-device")
|
||||
public Response ringDevice(@HeaderParam(ACCEPT) String acceptHeader,
|
||||
List<String> deviceIDs) {
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invoking Android ring-device device operation");
|
||||
}
|
||||
|
||||
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
|
||||
Message message = new Message();
|
||||
|
||||
try {
|
||||
CommandOperation operation = new CommandOperation();
|
||||
operation.setCode(AndroidConstants.OperationCodes.DEVICE_RING);
|
||||
operation.setType(Operation.Type.COMMAND);
|
||||
return AndroidAPIUtils.getOperationResponse(deviceIDs, operation, message,
|
||||
responseMediaType);
|
||||
} catch (OperationManagementException e) {
|
||||
String errorMessage = "Issue in retrieving operation management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
} catch (DeviceManagementException e) {
|
||||
String errorMessage = "Issue in retrieving device management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("mute")
|
||||
public Response muteDevice(@HeaderParam(ACCEPT) String acceptHeader,
|
||||
List<String> deviceIDs) {
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invoking mute device operation");
|
||||
}
|
||||
|
||||
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
|
||||
Message message = new Message();
|
||||
|
||||
try {
|
||||
CommandOperation operation = new CommandOperation();
|
||||
operation.setCode(AndroidConstants.OperationCodes.DEVICE_MUTE);
|
||||
operation.setType(Operation.Type.COMMAND);
|
||||
operation.setEnabled(true);
|
||||
return AndroidAPIUtils.getOperationResponse(deviceIDs, operation, message,
|
||||
responseMediaType);
|
||||
} catch (OperationManagementException e) {
|
||||
String errorMessage = "Issue in retrieving operation management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
} catch (DeviceManagementException e) {
|
||||
String errorMessage = "Issue in retrieving device management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("install-application")
|
||||
public Response installApplication(@HeaderParam(ACCEPT) String acceptHeader,
|
||||
ApplicationInstallationBeanWrapper applicationInstallationBeanWrapper) {
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invoking 'InstallApplication' operation");
|
||||
}
|
||||
|
||||
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
|
||||
Message message = new Message();
|
||||
|
||||
try {
|
||||
ApplicationInstallation applicationInstallation = applicationInstallationBeanWrapper.getOperation();
|
||||
|
||||
if (applicationInstallation == null) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("The payload of the application installing operation is incorrect");
|
||||
}
|
||||
throw new OperationManagementException("Issue in creating a new application installation instance");
|
||||
}
|
||||
|
||||
ProfileOperation operation = new ProfileOperation();
|
||||
operation.setCode(AndroidConstants.OperationCodes.INSTALL_APPLICATION);
|
||||
operation.setType(Operation.Type.PROFILE);
|
||||
operation.setPayLoad(applicationInstallation.toJSON());
|
||||
|
||||
return AndroidAPIUtils.getOperationResponse(applicationInstallationBeanWrapper.getDeviceIDs(),
|
||||
operation, message, responseMediaType);
|
||||
} catch (OperationManagementException e) {
|
||||
String errorMessage = "Issue in retrieving operation management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
} catch (DeviceManagementException e) {
|
||||
String errorMessage = "Issue in retrieving device management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("uninstall-application")
|
||||
public Response uninstallApplication(@HeaderParam(ACCEPT) String acceptHeader,
|
||||
ApplicationUninstallationBeanWrapper applicationUninstallationBeanWrapper) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invoking 'UninstallApplication' operation");
|
||||
}
|
||||
|
||||
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
|
||||
Message message = new Message();
|
||||
|
||||
try {
|
||||
ApplicationUninstallation applicationUninstallation = applicationUninstallationBeanWrapper.getOperation();
|
||||
|
||||
if (applicationUninstallation == null) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("The payload of the application uninstalling operation is incorrect");
|
||||
}
|
||||
throw new OperationManagementException("Issue in creating a new application uninstallation instance");
|
||||
}
|
||||
|
||||
ProfileOperation operation = new ProfileOperation();
|
||||
operation.setCode(AndroidConstants.OperationCodes.UNINSTALL_APPLICATION);
|
||||
operation.setType(Operation.Type.PROFILE);
|
||||
operation.setPayLoad(applicationUninstallation.toJSON());
|
||||
|
||||
return AndroidAPIUtils.getOperationResponse(applicationUninstallationBeanWrapper.getDeviceIDs(),
|
||||
operation, message, responseMediaType);
|
||||
} catch (OperationManagementException e) {
|
||||
String errorMessage = "Issue in retrieving operation management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
} catch (DeviceManagementException e) {
|
||||
String errorMessage = "Issue in retrieving device management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("blacklist-applications")
|
||||
public Response blacklistApplications(@HeaderParam(ACCEPT) String acceptHeader,
|
||||
BlacklistApplicationsBeanWrapper blacklistApplicationsBeanWrapper) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invoking 'Blacklist-Applications' operation");
|
||||
}
|
||||
|
||||
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
|
||||
Message message = new Message();
|
||||
|
||||
try {
|
||||
BlacklistApplications blacklistApplications = blacklistApplicationsBeanWrapper.getOperation();
|
||||
|
||||
if (blacklistApplications == null) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("The payload of the blacklisting apps operation is incorrect");
|
||||
}
|
||||
throw new OperationManagementException("Issue in creating a new blacklist applications instance");
|
||||
}
|
||||
|
||||
ProfileOperation operation = new ProfileOperation();
|
||||
operation.setCode(AndroidConstants.OperationCodes.BLACKLIST_APPLICATIONS);
|
||||
operation.setType(Operation.Type.PROFILE);
|
||||
operation.setPayLoad(blacklistApplications.toJSON());
|
||||
|
||||
return AndroidAPIUtils.getOperationResponse(blacklistApplicationsBeanWrapper.getDeviceIDs(),
|
||||
operation, message, responseMediaType);
|
||||
|
||||
} catch (OperationManagementException e) {
|
||||
String errorMessage = "Issue in retrieving operation management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
} catch (DeviceManagementException e) {
|
||||
String errorMessage = "Issue in retrieving device management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("notification")
|
||||
public Response sendNotification(@HeaderParam(ACCEPT) String acceptHeader,
|
||||
NotificationBeanWrapper notificationBeanWrapper) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invoking 'notification' operation");
|
||||
}
|
||||
|
||||
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
|
||||
Message message = new Message();
|
||||
|
||||
try {
|
||||
Notification notification = notificationBeanWrapper.getOperation();
|
||||
|
||||
if (notification == null) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("The payload of the notification operation is incorrect");
|
||||
}
|
||||
throw new OperationManagementException("Issue in creating a new notification instance");
|
||||
}
|
||||
|
||||
ProfileOperation operation = new ProfileOperation();
|
||||
operation.setCode(AndroidConstants.OperationCodes.NOTIFICATION);
|
||||
operation.setType(Operation.Type.PROFILE);
|
||||
operation.setPayLoad(notification.toJSON());
|
||||
|
||||
return AndroidAPIUtils.getOperationResponse(notificationBeanWrapper.getDeviceIDs(),
|
||||
operation, message, responseMediaType);
|
||||
|
||||
} catch (OperationManagementException e) {
|
||||
String errorMessage = "Issue in retrieving operation management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
} catch (DeviceManagementException e) {
|
||||
String errorMessage = "Issue in retrieving device management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("wifi")
|
||||
public Response configureWifi(@HeaderParam(ACCEPT) String acceptHeader,
|
||||
WifiBeanWrapper wifiBeanWrapper) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invoking 'configure wifi' operation");
|
||||
}
|
||||
|
||||
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
|
||||
Message message = new Message();
|
||||
|
||||
try {
|
||||
Wifi wifi = wifiBeanWrapper.getOperation();
|
||||
|
||||
if (wifi == null) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("The payload of the wifi operation is incorrect");
|
||||
}
|
||||
throw new OperationManagementException("Issue in creating a new Wifi instance");
|
||||
}
|
||||
|
||||
ProfileOperation operation = new ProfileOperation();
|
||||
operation.setCode(AndroidConstants.OperationCodes.WIFI);
|
||||
operation.setType(Operation.Type.PROFILE);
|
||||
operation.setPayLoad(wifi.toJSON());
|
||||
|
||||
return AndroidAPIUtils.getOperationResponse(wifiBeanWrapper.getDeviceIDs(),
|
||||
operation, message, responseMediaType);
|
||||
|
||||
} catch (OperationManagementException e) {
|
||||
String errorMessage = "Issue in retrieving operation management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
} catch (DeviceManagementException e) {
|
||||
String errorMessage = "Issue in retrieving device management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("encrypt")
|
||||
public Response encryptStorage(@HeaderParam(ACCEPT) String acceptHeader,
|
||||
EncryptionBeanWrapper encryptionBeanWrapper) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invoking 'encrypt' operation");
|
||||
}
|
||||
|
||||
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
|
||||
Message message = new Message();
|
||||
|
||||
try {
|
||||
DeviceEncryption deviceEncryption = encryptionBeanWrapper.getOperation();
|
||||
|
||||
if (deviceEncryption == null) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("The payload of the device encryption operation is incorrect");
|
||||
}
|
||||
throw new OperationManagementException("Issue in creating a new encryption instance");
|
||||
}
|
||||
|
||||
CommandOperation operation = new CommandOperation();
|
||||
operation.setCode(AndroidConstants.OperationCodes.ENCRYPT_STORAGE);
|
||||
operation.setType(Operation.Type.COMMAND);
|
||||
operation.setEnabled(deviceEncryption.isEncrypted());
|
||||
|
||||
return AndroidAPIUtils.getOperationResponse(encryptionBeanWrapper.getDeviceIDs(),
|
||||
operation, message, responseMediaType);
|
||||
|
||||
} catch (OperationManagementException e) {
|
||||
String errorMessage = "Issue in retrieving operation management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
} catch (DeviceManagementException e) {
|
||||
String errorMessage = "Issue in retrieving device management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("change-lock-code")
|
||||
public Response changeLockCode(@HeaderParam(ACCEPT) String acceptHeader,
|
||||
LockCodeBeanWrapper lockCodeBeanWrapper) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invoking 'change lock code' operation");
|
||||
}
|
||||
|
||||
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
|
||||
Message message = new Message();
|
||||
|
||||
try {
|
||||
LockCode lockCode = lockCodeBeanWrapper.getOperation();
|
||||
|
||||
if (lockCode == null) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("The payload of the change lock code operation is incorrect");
|
||||
}
|
||||
throw new OperationManagementException("Issue in retrieving a new lock-code instance");
|
||||
}
|
||||
|
||||
ProfileOperation operation = new ProfileOperation();
|
||||
operation.setCode(AndroidConstants.OperationCodes.CHANGE_LOCK_CODE);
|
||||
operation.setType(Operation.Type.PROFILE);
|
||||
operation.setPayLoad(lockCode.toJSON());
|
||||
|
||||
return AndroidAPIUtils.getOperationResponse(lockCodeBeanWrapper.getDeviceIDs(),
|
||||
operation, message, responseMediaType);
|
||||
|
||||
} catch (OperationManagementException e) {
|
||||
String errorMessage = "Issue in retrieving operation management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
} catch (DeviceManagementException e) {
|
||||
String errorMessage = "Issue in retrieving device management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("password-policy")
|
||||
public Response setPasswordPolicy(@HeaderParam(ACCEPT) String acceptHeader,
|
||||
PasswordPolicyBeanWrapper passwordPolicyBeanWrapper) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invoking 'password policy' operation");
|
||||
}
|
||||
|
||||
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
|
||||
Message message = new Message();
|
||||
|
||||
try {
|
||||
PasscodePolicy passcodePolicy = passwordPolicyBeanWrapper.getOperation();
|
||||
|
||||
if (passcodePolicy == null) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("The payload of the change password policy operation is incorrect");
|
||||
}
|
||||
throw new OperationManagementException("Issue in creating a new Password policy instance");
|
||||
}
|
||||
|
||||
ProfileOperation operation = new ProfileOperation();
|
||||
operation.setCode(AndroidConstants.OperationCodes.PASSCODE_POLICY);
|
||||
operation.setType(Operation.Type.PROFILE);
|
||||
operation.setPayLoad(passcodePolicy.toJSON());
|
||||
|
||||
return AndroidAPIUtils.getOperationResponse(passwordPolicyBeanWrapper.getDeviceIDs(),
|
||||
operation, message, responseMediaType);
|
||||
|
||||
} catch (OperationManagementException e) {
|
||||
String errorMessage = "Issue in retrieving operation management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
} catch (DeviceManagementException e) {
|
||||
String errorMessage = "Issue in retrieving device management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("webclip")
|
||||
public Response setWebClip(@HeaderParam(ACCEPT) String acceptHeader,
|
||||
WebClipBeanWrapper webClipBeanWrapper) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invoking 'webclip' operation");
|
||||
}
|
||||
|
||||
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
|
||||
Message message = new Message();
|
||||
|
||||
try {
|
||||
WebClip webClip = webClipBeanWrapper.getOperation();
|
||||
|
||||
if (webClip == null) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("The payload of the add webclip operation is incorrect");
|
||||
}
|
||||
throw new OperationManagementException("Issue in creating a new web clip instance");
|
||||
}
|
||||
|
||||
ProfileOperation operation = new ProfileOperation();
|
||||
operation.setCode(AndroidConstants.OperationCodes.WEBCLIP);
|
||||
operation.setType(Operation.Type.PROFILE);
|
||||
operation.setPayLoad(webClip.toJSON());
|
||||
|
||||
return AndroidAPIUtils.getOperationResponse(webClipBeanWrapper.getDeviceIDs(),
|
||||
operation, message, responseMediaType);
|
||||
|
||||
} catch (OperationManagementException e) {
|
||||
String errorMessage = "Issue in retrieving operation management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
} catch (DeviceManagementException e) {
|
||||
String errorMessage = "Issue in retrieving device management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("disenroll")
|
||||
public Response setDisenrollment(@HeaderParam(ACCEPT) String acceptHeader,
|
||||
DisenrollmentBeanWrapper disenrollmentBeanWrapper) {
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invoking Android device disenrollment operation");
|
||||
}
|
||||
|
||||
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
|
||||
Message message = new Message();
|
||||
|
||||
try {
|
||||
Disenrollment disenrollment = disenrollmentBeanWrapper.getOperation();
|
||||
|
||||
if (disenrollment == null) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("The payload of the device disenrollment operation is incorrect");
|
||||
}
|
||||
throw new OperationManagementException("Issue in creating a new disenrollment instance");
|
||||
}
|
||||
|
||||
CommandOperation operation = new CommandOperation();
|
||||
operation.setCode(AndroidConstants.OperationCodes.DISENROLL);
|
||||
operation.setType(Operation.Type.COMMAND);
|
||||
operation.setEnabled(disenrollment.isEnabled());
|
||||
|
||||
return AndroidAPIUtils.getOperationResponse(disenrollmentBeanWrapper.getDeviceIDs(), operation,
|
||||
message, responseMediaType);
|
||||
|
||||
} catch (OperationManagementException e) {
|
||||
String errorMessage = "Issue in retrieving operation management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
} catch (DeviceManagementException e) {
|
||||
String errorMessage = "Issue in retrieving device management service instance";
|
||||
message = Message.responseMessage(errorMessage).
|
||||
responseCode(Response.Status.INTERNAL_SERVER_ERROR.toString()).build();
|
||||
log.error(errorMessage, e);
|
||||
throw new AndroidOperationException(message, responseMediaType);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateOperations(String deviceId, List<? extends Operation> operations)
|
||||
throws OperationManagementException, PolicyComplianceException,
|
||||
ApplicationManagementException, NotificationManagementException, DeviceManagementException {
|
||||
for (org.wso2.carbon.device.mgt.common.operation.mgt.Operation operation : operations) {
|
||||
AndroidAPIUtils.updateOperation(deviceId, operation);
|
||||
if(operation.getStatus().equals(OPERATION_ERROR_STATUS)){
|
||||
org.wso2.carbon.device.mgt.common.notification.mgt.Notification notification = new
|
||||
org.wso2.carbon.device.mgt.common.notification.mgt.Notification();
|
||||
DeviceIdentifier id = new DeviceIdentifier();
|
||||
id.setId(deviceId);
|
||||
id.setType(DEVICE_TYPE_ANDROID);
|
||||
String deviceName = AndroidAPIUtils.getDeviceManagementService().getDevice(id).getName();
|
||||
notification.setOperationId(operation.getId());
|
||||
notification.setStatus(org.wso2.carbon.device.mgt.common.notification.mgt.Notification.
|
||||
Status.NEW.toString());
|
||||
notification.setDeviceIdentifier(id);
|
||||
notification.setDescription("Operation " + operation.getCode() + " failed to execute on device "+
|
||||
deviceName+". Device ID : " + deviceId);
|
||||
AndroidAPIUtils.getNotificationManagementService().addNotification(notification);
|
||||
}
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Updating operation '" + operation.toString() + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package org.wso2.carbon.mdm.services.android;
|
||||
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
|
||||
import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils;
|
||||
import org.wso2.carbon.mdm.services.android.util.Message;
|
||||
import org.wso2.carbon.policy.mgt.common.FeatureManagementException;
|
||||
import org.wso2.carbon.policy.mgt.common.Policy;
|
||||
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
||||
import org.wso2.carbon.policy.mgt.common.ProfileFeature;
|
||||
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
||||
|
||||
import javax.jws.WebService;
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.List;
|
||||
|
||||
@WebService
|
||||
@Produces({"application/json", "application/xml"})
|
||||
@Consumes({"application/json", "application/xml"})
|
||||
public class PolicyMgtService {
|
||||
|
||||
private static Log log = LogFactory.getLog(PolicyMgtService.class);
|
||||
|
||||
@GET
|
||||
@Path("{deviceId}")
|
||||
public Message getEffectivePolicy(@HeaderParam("Accept") String acceptHeader,
|
||||
@PathParam("deviceId") String id) throws AndroidAgentException {
|
||||
|
||||
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
|
||||
Message responseMessage = new Message();
|
||||
Policy policy;
|
||||
try {
|
||||
PolicyManagerService policyManagerService = AndroidAPIUtils.getPolicyManagerService();
|
||||
policy = policyManagerService.getEffectivePolicy(deviceIdentifier);
|
||||
if (policy == null) {
|
||||
responseMessage = Message.responseMessage("No effective policy found").
|
||||
responseCode(Response.Status.NO_CONTENT.toString()).build();
|
||||
} else {
|
||||
responseMessage = Message.responseMessage("Effective policy added to operation").
|
||||
responseCode(Response.Status.OK.toString()).build();
|
||||
}
|
||||
} catch (PolicyManagementException e) {
|
||||
String msg = "Error occurred while getting the policy.";
|
||||
log.error(msg, e);
|
||||
throw new AndroidAgentException(msg, e);
|
||||
}
|
||||
return responseMessage;
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/features/{deviceId}")
|
||||
public List<ProfileFeature> getEffectiveFeatures(@HeaderParam("Accept") String acceptHeader,
|
||||
@PathParam("deviceId") String id) throws AndroidAgentException {
|
||||
List<ProfileFeature> profileFeatures;
|
||||
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
|
||||
try {
|
||||
PolicyManagerService policyManagerService = AndroidAPIUtils.getPolicyManagerService();
|
||||
profileFeatures = policyManagerService.getEffectiveFeatures(deviceIdentifier);
|
||||
if (profileFeatures == null) {
|
||||
Response.status(Response.Status.NOT_FOUND);
|
||||
}
|
||||
} catch (FeatureManagementException e) {
|
||||
String msg = "Error occurred while getting the features.";
|
||||
log.error(msg, e);
|
||||
throw new AndroidAgentException(msg, e);
|
||||
}
|
||||
return profileFeatures;
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.services.android.bean;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
/*
|
||||
* This abstract class is used for extending generic functions with regard to operation.
|
||||
*/
|
||||
public abstract class AndroidOperation {
|
||||
|
||||
/*
|
||||
* This method is used to convert operation object to a json format.
|
||||
*
|
||||
* @return json formatted String.
|
||||
*/
|
||||
public String toJSON() {
|
||||
Gson gson = new Gson();
|
||||
return gson.toJson(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.services.android.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the information of install application operation.
|
||||
*/
|
||||
public class ApplicationInstallation extends AndroidOperation implements Serializable {
|
||||
|
||||
private String appIdentifier;
|
||||
private String type;
|
||||
private String url;
|
||||
|
||||
public String getAppIdentifier() {
|
||||
return appIdentifier;
|
||||
}
|
||||
|
||||
public void setAppIdentifier(String appIdentifier) {
|
||||
this.appIdentifier = appIdentifier;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.services.android.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the information of uninstall application operation.
|
||||
*/
|
||||
public class ApplicationUninstallation extends AndroidOperation implements Serializable {
|
||||
|
||||
private String appIdentifier;
|
||||
private String type;
|
||||
private String url;
|
||||
private String name;
|
||||
|
||||
public String getAppIdentifier() {
|
||||
return appIdentifier;
|
||||
}
|
||||
|
||||
public void setAppIdentifier(String appIdentifier) {
|
||||
this.appIdentifier = appIdentifier;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.services.android.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class represents the blacklist applications information.
|
||||
*/
|
||||
public class BlacklistApplications extends AndroidOperation implements Serializable {
|
||||
|
||||
private List<String> appIdentifiers;
|
||||
|
||||
public List<String> getAppIdentifier() {
|
||||
return appIdentifiers;
|
||||
}
|
||||
|
||||
public void setAppIdentifier(List<String> appIdentifiers) {
|
||||
this.appIdentifiers = appIdentifiers;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.services.android.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the information of camera operation.
|
||||
*/
|
||||
public class Camera extends AndroidOperation implements Serializable {
|
||||
|
||||
private boolean enabled;
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.services.android.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the information of encrypt operation.
|
||||
*/
|
||||
public class DeviceEncryption extends AndroidOperation implements Serializable {
|
||||
|
||||
private boolean encrypted;
|
||||
|
||||
public boolean isEncrypted() {
|
||||
return encrypted;
|
||||
}
|
||||
|
||||
public void setEncrypted(boolean encrypted) {
|
||||
this.encrypted = encrypted;
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.services.android.bean;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Disenrollment extends AndroidOperation implements Serializable {
|
||||
|
||||
private boolean enabled;
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.services.android.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the information of changing lock code operation.
|
||||
*/
|
||||
public class LockCode extends AndroidOperation implements Serializable {
|
||||
|
||||
private String lockCode;
|
||||
|
||||
public String getLockCode() {
|
||||
return lockCode;
|
||||
}
|
||||
|
||||
public void setLockCode(String lockCode) {
|
||||
this.lockCode = lockCode;
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.services.android.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the information of sending notification operation.
|
||||
*/
|
||||
public class Notification extends AndroidOperation implements Serializable {
|
||||
|
||||
private String message;
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.services.android.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the information of setting up password policy.
|
||||
*/
|
||||
public class PasscodePolicy extends AndroidOperation implements Serializable {
|
||||
|
||||
private int maxFailedAttempts;
|
||||
private int minLength;
|
||||
private int pinHistory;
|
||||
private int minComplexChars;
|
||||
private int maxPINAgeInDays;
|
||||
private boolean requireAlphanumeric;
|
||||
private boolean allowSimple;
|
||||
|
||||
public int getMaxFailedAttempts() {
|
||||
return maxFailedAttempts;
|
||||
}
|
||||
|
||||
public void setMaxFailedAttempts(int maxFailedAttempts) {
|
||||
this.maxFailedAttempts = maxFailedAttempts;
|
||||
}
|
||||
|
||||
public int getMinLength() {
|
||||
return minLength;
|
||||
}
|
||||
|
||||
public void setMinLength(int minLength) {
|
||||
this.minLength = minLength;
|
||||
}
|
||||
|
||||
public int getPinHistory() {
|
||||
return pinHistory;
|
||||
}
|
||||
|
||||
public void setPinHistory(int pinHistory) {
|
||||
this.pinHistory = pinHistory;
|
||||
}
|
||||
|
||||
public int getMinComplexChars() {
|
||||
return minComplexChars;
|
||||
}
|
||||
|
||||
public void setMinComplexChars(int minComplexChars) {
|
||||
this.minComplexChars = minComplexChars;
|
||||
}
|
||||
|
||||
public int getMaxPINAgeInDays() {
|
||||
return maxPINAgeInDays;
|
||||
}
|
||||
|
||||
public void setMaxPINAgeInDays(int maxPINAgeInDays) {
|
||||
this.maxPINAgeInDays = maxPINAgeInDays;
|
||||
}
|
||||
|
||||
public boolean isRequireAlphanumeric() {
|
||||
return requireAlphanumeric;
|
||||
}
|
||||
|
||||
public void setRequireAlphanumeric(boolean requireAlphanumeric) {
|
||||
this.requireAlphanumeric = requireAlphanumeric;
|
||||
}
|
||||
|
||||
public boolean isAllowSimple() {
|
||||
return allowSimple;
|
||||
}
|
||||
|
||||
public void setAllowSimple(boolean allowSimple) {
|
||||
this.allowSimple = allowSimple;
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.services.android.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the information of setting up webclip.
|
||||
*/
|
||||
public class WebClip extends AndroidOperation implements Serializable {
|
||||
|
||||
private String identity;
|
||||
private String title;
|
||||
private String type;
|
||||
|
||||
public String getIdentity() {
|
||||
return identity;
|
||||
}
|
||||
|
||||
public void setIdentity(String identity) {
|
||||
this.identity = identity;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.services.android.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the information of configuring wifi operation.
|
||||
*/
|
||||
public class Wifi extends AndroidOperation implements Serializable {
|
||||
|
||||
private String ssid;
|
||||
private String password;
|
||||
|
||||
public String getSsid() {
|
||||
return ssid;
|
||||
}
|
||||
|
||||
public void setSsid(String ssid) {
|
||||
this.ssid = ssid;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.services.android.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the information of wipedata operation.
|
||||
*/
|
||||
public class WipeData extends AndroidOperation implements Serializable {
|
||||
|
||||
private String pin;
|
||||
|
||||
public String getPin() {
|
||||
return pin;
|
||||
}
|
||||
|
||||
public void setPin(String pin) {
|
||||
this.pin = pin;
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.wso2.carbon.mdm.services.android.bean.wrapper;
|
||||
|
||||
import org.wso2.carbon.mdm.services.android.bean.ApplicationInstallation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the InstallApplication bean with devices.
|
||||
*/
|
||||
public class ApplicationInstallationBeanWrapper {
|
||||
|
||||
private List<String> deviceIDs;
|
||||
private ApplicationInstallation operation;
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
|
||||
public ApplicationInstallation getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(ApplicationInstallation operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.wso2.carbon.mdm.services.android.bean.wrapper;
|
||||
|
||||
import org.wso2.carbon.mdm.services.android.bean.ApplicationUninstallation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the UninstallApplication bean with devices.
|
||||
*/
|
||||
public class ApplicationUninstallationBeanWrapper {
|
||||
|
||||
private List<String> deviceIDs;
|
||||
private ApplicationUninstallation operation;
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
|
||||
public ApplicationUninstallation getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(ApplicationUninstallation operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.wso2.carbon.mdm.services.android.bean.wrapper;
|
||||
|
||||
import org.wso2.carbon.mdm.services.android.bean.BlacklistApplications;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the BlacklistApplications bean with devices.
|
||||
*/
|
||||
public class BlacklistApplicationsBeanWrapper {
|
||||
|
||||
private BlacklistApplications operation;
|
||||
private List<String> deviceIDs;
|
||||
|
||||
public BlacklistApplications getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(BlacklistApplications operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.wso2.carbon.mdm.services.android.bean.wrapper;
|
||||
|
||||
import org.wso2.carbon.mdm.services.android.bean.Camera;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the Camera bean with devices.
|
||||
*/
|
||||
public class CameraBeanWrapper {
|
||||
|
||||
private Camera operation;
|
||||
private List<String> deviceIDs;
|
||||
|
||||
public Camera getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(Camera operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.wso2.carbon.mdm.services.android.bean.wrapper;
|
||||
|
||||
import org.wso2.carbon.mdm.services.android.bean.Disenrollment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DisenrollmentBeanWrapper {
|
||||
|
||||
private Disenrollment operation;
|
||||
private List<String> deviceIDs;
|
||||
|
||||
public Disenrollment getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(Disenrollment operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.wso2.carbon.mdm.services.android.bean.wrapper;
|
||||
|
||||
import org.wso2.carbon.mdm.services.android.bean.DeviceEncryption;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the Encrypt bean with devices.
|
||||
*/
|
||||
public class EncryptionBeanWrapper {
|
||||
|
||||
private DeviceEncryption operation;
|
||||
private List<String> deviceIDs;
|
||||
|
||||
public DeviceEncryption getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(DeviceEncryption operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.wso2.carbon.mdm.services.android.bean.wrapper;
|
||||
|
||||
import org.wso2.carbon.mdm.services.android.bean.LockCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the LockCode bean with devices.
|
||||
*/
|
||||
public class LockCodeBeanWrapper {
|
||||
|
||||
private LockCode operation;
|
||||
private List<String> deviceIDs;
|
||||
|
||||
public LockCode getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(LockCode operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.wso2.carbon.mdm.services.android.bean.wrapper;
|
||||
|
||||
import org.wso2.carbon.mdm.services.android.bean.Notification;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the Notification bean with devices.
|
||||
*/
|
||||
public class NotificationBeanWrapper {
|
||||
|
||||
private List<String> deviceIDs;
|
||||
private Notification operation;
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
|
||||
public Notification getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(Notification operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.wso2.carbon.mdm.services.android.bean.wrapper;
|
||||
|
||||
import org.wso2.carbon.mdm.services.android.bean.PasscodePolicy;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the PasswordPolicy bean with devices.
|
||||
*/
|
||||
public class PasswordPolicyBeanWrapper {
|
||||
|
||||
private PasscodePolicy operation;
|
||||
private List<String> deviceIDs;
|
||||
|
||||
public PasscodePolicy getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(PasscodePolicy operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.wso2.carbon.mdm.services.android.bean.wrapper;
|
||||
|
||||
import org.wso2.carbon.mdm.services.android.bean.WebClip;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the WebClip bean with devices.
|
||||
*/
|
||||
public class WebClipBeanWrapper {
|
||||
|
||||
private WebClip operation;
|
||||
private List<String> deviceIDs;
|
||||
|
||||
public WebClip getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(WebClip operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.wso2.carbon.mdm.services.android.bean.wrapper;
|
||||
|
||||
import org.wso2.carbon.mdm.services.android.bean.Wifi;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the Wifi bean with devices.
|
||||
*/
|
||||
public class WifiBeanWrapper {
|
||||
|
||||
private Wifi operation;
|
||||
private List<String> deviceIDs;
|
||||
|
||||
public Wifi getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(Wifi operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.wso2.carbon.mdm.services.android.bean.wrapper;
|
||||
|
||||
import org.wso2.carbon.mdm.services.android.bean.WipeData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the WipeData bean with devices.
|
||||
*/
|
||||
public class WipeDataBeanWrapper {
|
||||
|
||||
private WipeData operation;
|
||||
private List<String> deviceIDs;
|
||||
|
||||
public WipeData getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(WipeData operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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.
|
||||
*/
|
||||
package org.wso2.carbon.mdm.services.android.common;
|
||||
|
||||
import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
|
||||
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.ext.ExceptionMapper;
|
||||
|
||||
|
||||
@Produces({ "application/json", "application/xml" })
|
||||
public class ErrorHandler implements ExceptionMapper<AndroidAgentException> {
|
||||
|
||||
public Response toResponse(AndroidAgentException exception) {
|
||||
ErrorMessage errorMessage = new ErrorMessage();
|
||||
errorMessage.setErrorMessage(exception.getErrorMessage());
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build();
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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.
|
||||
*/
|
||||
package org.wso2.carbon.mdm.services.android.common;
|
||||
|
||||
|
||||
public class ErrorMessage {
|
||||
|
||||
private String errorMessage;
|
||||
private String errorCode;
|
||||
|
||||
public String getErrorMessage() {
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
public void setErrorMessage(String errorMessage) {
|
||||
this.errorMessage = errorMessage;
|
||||
}
|
||||
|
||||
public String getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
public void setErrorCode(String errorCode) {
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.services.android.common;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.ext.MessageBodyReader;
|
||||
import javax.ws.rs.ext.MessageBodyWriter;
|
||||
import javax.ws.rs.ext.Provider;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
||||
|
||||
@Provider
|
||||
@Produces(APPLICATION_JSON)
|
||||
@Consumes(APPLICATION_JSON)
|
||||
public class GsonMessageBodyHandler implements MessageBodyWriter<Object>, MessageBodyReader<Object> {
|
||||
|
||||
private Gson gson;
|
||||
private static final String UTF_8 = "UTF-8";
|
||||
|
||||
public boolean isReadable(Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private Gson getGson() {
|
||||
if (gson == null) {
|
||||
final GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
gson = gsonBuilder.create();
|
||||
}
|
||||
return gson;
|
||||
}
|
||||
|
||||
public Object readFrom(Class<Object> objectClass, Type type, Annotation[] annotations, MediaType mediaType,
|
||||
MultivaluedMap<String, String> stringStringMultivaluedMap, InputStream entityStream)
|
||||
throws IOException, WebApplicationException {
|
||||
|
||||
InputStreamReader reader = new InputStreamReader(entityStream, "UTF-8");
|
||||
|
||||
try {
|
||||
return getGson().fromJson(reader, type);
|
||||
} finally {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isWriteable(Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public long getSize(Object o, Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void writeTo(Object object, Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType,
|
||||
MultivaluedMap<String, Object> stringObjectMultivaluedMap, OutputStream entityStream)
|
||||
throws IOException, WebApplicationException {
|
||||
|
||||
OutputStreamWriter writer = new OutputStreamWriter(entityStream, UTF_8);
|
||||
try {
|
||||
Type jsonType;
|
||||
if (type.equals(type)) {
|
||||
jsonType = type;
|
||||
} else {
|
||||
jsonType = type;
|
||||
}
|
||||
getGson().toJson(object, jsonType, writer);
|
||||
} finally {
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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.
|
||||
*/
|
||||
package org.wso2.carbon.mdm.services.android.exception;
|
||||
|
||||
/**
|
||||
*
|
||||
* Custom exception class for Android API related exceptions.
|
||||
*
|
||||
*/
|
||||
public class AndroidAgentException extends Exception{
|
||||
|
||||
private static final long serialVersionUID = 7950151650447893900L;
|
||||
private String errorMessage;
|
||||
|
||||
public String getErrorMessage() {
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
public void setErrorMessage(String errorMessage) {
|
||||
this.errorMessage = errorMessage;
|
||||
}
|
||||
|
||||
public AndroidAgentException(String msg, Exception nestedEx) {
|
||||
super(msg, nestedEx);
|
||||
setErrorMessage(msg);
|
||||
}
|
||||
|
||||
public AndroidAgentException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
setErrorMessage(message);
|
||||
}
|
||||
|
||||
public AndroidAgentException(String msg) {
|
||||
super(msg);
|
||||
setErrorMessage(msg);
|
||||
}
|
||||
|
||||
public AndroidAgentException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public AndroidAgentException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.services.android.exception;
|
||||
|
||||
import org.wso2.carbon.mdm.services.android.util.Message;
|
||||
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
/**
|
||||
* Custom exception class for wrapping Android Operation related exceptions.
|
||||
*/
|
||||
public class AndroidOperationException extends WebApplicationException {
|
||||
|
||||
public AndroidOperationException(Message message, MediaType mediaType) {
|
||||
super(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).
|
||||
type(mediaType).build());
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.services.android.exception;
|
||||
|
||||
import org.wso2.carbon.mdm.services.android.util.Message;
|
||||
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
/**
|
||||
* Custom exception class for wrapping BadRequest related exceptions.
|
||||
*/
|
||||
public class BadRequestException extends WebApplicationException {
|
||||
|
||||
public BadRequestException(Message message, MediaType mediaType) {
|
||||
super(Response.status(Response.Status.BAD_REQUEST).entity(message).
|
||||
type(mediaType).build());
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.services.android.exception;
|
||||
|
||||
/**
|
||||
*
|
||||
* Custom exception class for operation configuration related exceptions.
|
||||
*
|
||||
*/
|
||||
public class OperationConfigurationException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 7435543643747623629L;
|
||||
|
||||
public OperationConfigurationException(String errorMessage) {
|
||||
super(errorMessage);
|
||||
}
|
||||
|
||||
public OperationConfigurationException(String errorMessage, Throwable throwable) {
|
||||
super(errorMessage, throwable);
|
||||
}
|
||||
}
|
@ -0,0 +1,186 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.services.android.util;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
|
||||
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
||||
import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService;
|
||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||
import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException;
|
||||
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* AndroidAPIUtil class provides utility functions used by Android REST-API classes.
|
||||
*/
|
||||
public class AndroidAPIUtils {
|
||||
|
||||
private static Log log = LogFactory.getLog(AndroidAPIUtils.class);
|
||||
|
||||
public static DeviceIdentifier convertToDeviceIdentifierObject(String deviceId) {
|
||||
DeviceIdentifier identifier = new DeviceIdentifier();
|
||||
identifier.setId(deviceId);
|
||||
identifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public static void endTenantFlow() {
|
||||
PrivilegedCarbonContext.endTenantFlow();
|
||||
}
|
||||
|
||||
public static DeviceManagementProviderService getDeviceManagementService() {
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
DeviceManagementProviderService deviceManagementProviderService =
|
||||
(DeviceManagementProviderService) ctx.getOSGiService(DeviceManagementProviderService.class, null);
|
||||
if (deviceManagementProviderService == null) {
|
||||
String msg = "Device Management service has not initialized.";
|
||||
log.error(msg);
|
||||
throw new IllegalStateException(msg);
|
||||
}
|
||||
return deviceManagementProviderService;
|
||||
}
|
||||
|
||||
public static MediaType getResponseMediaType(String acceptHeader) {
|
||||
MediaType responseMediaType;
|
||||
if (MediaType.WILDCARD.equals(acceptHeader)) {
|
||||
responseMediaType = MediaType.APPLICATION_JSON_TYPE;
|
||||
} else {
|
||||
responseMediaType = MediaType.valueOf(acceptHeader);
|
||||
}
|
||||
return responseMediaType;
|
||||
}
|
||||
|
||||
public static Response getOperationResponse(List<String> deviceIDs, Operation operation,
|
||||
Message message, MediaType responseMediaType)
|
||||
throws DeviceManagementException, OperationManagementException {
|
||||
|
||||
AndroidDeviceUtils deviceUtils = new AndroidDeviceUtils();
|
||||
DeviceIDHolder deviceIDHolder = deviceUtils.validateDeviceIdentifiers(deviceIDs,
|
||||
message, responseMediaType);
|
||||
getDeviceManagementService().addOperation(operation, deviceIDHolder.getValidDeviceIDList());
|
||||
if (!deviceIDHolder.getErrorDeviceIdList().isEmpty()) {
|
||||
return javax.ws.rs.core.Response.status(AndroidConstants.StatusCodes.
|
||||
MULTI_STATUS_HTTP_CODE).type(
|
||||
responseMediaType).entity(deviceUtils.
|
||||
convertErrorMapIntoErrorMessage(deviceIDHolder.getErrorDeviceIdList())).build();
|
||||
}
|
||||
return javax.ws.rs.core.Response.status(javax.ws.rs.core.Response.Status.CREATED).
|
||||
type(responseMediaType).build();
|
||||
}
|
||||
|
||||
|
||||
public static PolicyManagerService getPolicyManagerService() {
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
PolicyManagerService policyManagerService = (PolicyManagerService) ctx.getOSGiService(
|
||||
PolicyManagerService.class, null);
|
||||
if (policyManagerService == null) {
|
||||
String msg = "Policy Manager service has not initialized";
|
||||
log.error(msg);
|
||||
throw new IllegalStateException(msg);
|
||||
}
|
||||
return policyManagerService;
|
||||
}
|
||||
|
||||
public static ApplicationManagementProviderService getApplicationManagerService() {
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
ApplicationManagementProviderService applicationManagementProviderService =
|
||||
(ApplicationManagementProviderService) ctx.getOSGiService(ApplicationManagementProviderService.class, null);
|
||||
if (applicationManagementProviderService == null) {
|
||||
String msg = "Application Management provder service has not initialized";
|
||||
log.error(msg);
|
||||
throw new IllegalStateException(msg);
|
||||
}
|
||||
return applicationManagementProviderService;
|
||||
}
|
||||
|
||||
public static NotificationManagementService getNotificationManagementService() {
|
||||
NotificationManagementService notificationManagementService;
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
notificationManagementService = (NotificationManagementService) ctx.getOSGiService(
|
||||
NotificationManagementService.class, null);
|
||||
if (notificationManagementService == null) {
|
||||
String msg = "Notification Management service not initialized.";
|
||||
log.error(msg);
|
||||
throw new IllegalStateException(msg);
|
||||
}
|
||||
return notificationManagementService;
|
||||
}
|
||||
|
||||
public static void updateOperation(String deviceId, Operation operation)
|
||||
throws OperationManagementException, PolicyComplianceException, ApplicationManagementException {
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||
deviceIdentifier.setId(deviceId);
|
||||
deviceIdentifier.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||
if (AndroidConstants.OperationCodes.MONITOR.equals(operation.getCode())) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.info("Received compliance status from MONITOR operation ID: " + operation.getId());
|
||||
}
|
||||
getPolicyManagerService().checkPolicyCompliance(deviceIdentifier, operation.getOperationResponse());
|
||||
} else if (AndroidConstants.OperationCodes.APPLICATION_LIST.equals(operation.getCode())) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.info("Received applications list from device '" + deviceId + "'");
|
||||
}
|
||||
updateApplicationList(operation, deviceIdentifier);
|
||||
}
|
||||
getDeviceManagementService().updateOperation(deviceIdentifier, operation);
|
||||
}
|
||||
|
||||
public static List<? extends org.wso2.carbon.device.mgt.common.operation.mgt.Operation> getPendingOperations
|
||||
(DeviceIdentifier deviceIdentifier) throws OperationManagementException {
|
||||
|
||||
List<? extends org.wso2.carbon.device.mgt.common.operation.mgt.Operation> operations;
|
||||
operations = getDeviceManagementService().getPendingOperations(deviceIdentifier);
|
||||
return operations;
|
||||
}
|
||||
|
||||
private static void updateApplicationList(Operation operation, DeviceIdentifier deviceIdentifier)
|
||||
throws ApplicationManagementException {
|
||||
List<Application> applications = new ArrayList<Application>();
|
||||
// Parsing json string to get applications list.
|
||||
JsonElement jsonElement = new JsonParser().parse(operation.getOperationResponse());
|
||||
JsonArray jsonArray = jsonElement.getAsJsonArray();
|
||||
Application app;
|
||||
for (JsonElement element : jsonArray) {
|
||||
app = new Application();
|
||||
app.setName(element.getAsJsonObject().
|
||||
get(AndroidConstants.ApplicationProperties.NAME).getAsString());
|
||||
app.setApplicationIdentifier(element.getAsJsonObject().
|
||||
get(AndroidConstants.ApplicationProperties.IDENTIFIER).getAsString());
|
||||
app.setPlatform(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||
applications.add(app);
|
||||
}
|
||||
getApplicationManagerService().updateApplicationListInstalledInDevice(deviceIdentifier, applications);
|
||||
}
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.services.android.util;
|
||||
|
||||
/**
|
||||
* Defines constants used in Android-REST API bundle.
|
||||
*/
|
||||
public final class AndroidConstants {
|
||||
|
||||
public final class DeviceProperties{
|
||||
private DeviceProperties() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
public static final String PROPERTY_USER_KEY = "username";
|
||||
public static final String PROPERTY_DEVICE_KEY = "device";
|
||||
}
|
||||
|
||||
public final class DeviceFeatures{
|
||||
private DeviceFeatures() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
||||
public final class DeviceConstants{
|
||||
private DeviceConstants() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
public static final String DEVICE_MAC_KEY = "mac";
|
||||
public static final String DEVICE_DESCRIPTION_KEY = "description";
|
||||
public static final String DEVICE_OWNERSHIP_KEY = "ownership";
|
||||
public static final String DEVICE_PROPERTIES_KEY = "properties";
|
||||
public static final String DEVICE_FEATURES_KEY = "features";
|
||||
public static final String DEVICE_DATA = "data";
|
||||
public static final String DEVICE_ID_NOT_FOUND = "Device Id not found for device found at %s";
|
||||
public static final String DEVICE_ID_SERVICE_NOT_FOUND =
|
||||
"Issue in retrieving device management service instance for device found at %s";
|
||||
}
|
||||
|
||||
public final class Messages{
|
||||
private Messages(){
|
||||
throw new AssertionError();
|
||||
}
|
||||
public static final String DEVICE_MANAGER_SERVICE_NOT_AVAILABLE =
|
||||
"Device Manager service not available";
|
||||
}
|
||||
|
||||
public final class OperationCodes{
|
||||
private OperationCodes(){
|
||||
throw new AssertionError();
|
||||
}
|
||||
public static final String DEVICE_LOCK = "DEVICE_LOCK";
|
||||
public static final String DEVICE_LOCATION = "DEVICE_LOCATION";
|
||||
public static final String WIFI = "WIFI";
|
||||
public static final String CAMERA = "CAMERA";
|
||||
public static final String DEVICE_MUTE = "DEVICE_MUTE";
|
||||
public static final String PASSCODE_POLICY = "PASSCODE_POLICY";
|
||||
public static final String DEVICE_INFO = "DEVICE_INFO";
|
||||
public static final String ENTERPRISE_WIPE = "ENTERPRISE_WIPE";
|
||||
public static final String CLEAR_PASSWORD = "CLEAR_PASSWORD";
|
||||
public static final String WIPE_DATA = "WIPE_DATA";
|
||||
public static final String APPLICATION_LIST = "APPLICATION_LIST";
|
||||
public static final String CHANGE_LOCK_CODE = "CHANGE_LOCK_CODE";
|
||||
public static final String INSTALL_APPLICATION = "INSTALL_APPLICATION";
|
||||
public static final String UNINSTALL_APPLICATION = "UNINSTALL_APPLICATION";
|
||||
public static final String BLACKLIST_APPLICATIONS = "BLACKLIST_APPLICATIONS";
|
||||
public static final String ENCRYPT_STORAGE = "ENCRYPT_STORAGE";
|
||||
public static final String DEVICE_RING = "DEVICE_RING";
|
||||
public static final String NOTIFICATION = "NOTIFICATION";
|
||||
public static final String WEBCLIP = "WEBCLIP";
|
||||
public static final String DISENROLL = "DISENROLL";
|
||||
public static final String MONITOR = "MONITOR";
|
||||
}
|
||||
|
||||
public final class StatusCodes{
|
||||
private StatusCodes(){
|
||||
throw new AssertionError();
|
||||
}
|
||||
public static final int MULTI_STATUS_HTTP_CODE = 207;
|
||||
}
|
||||
|
||||
public final class TenantConfigProperties{
|
||||
private TenantConfigProperties(){
|
||||
throw new AssertionError();
|
||||
}
|
||||
public static final String LICENSE_KEY = "androidEula";
|
||||
public static final String LANGUAGE_US = "en_US";
|
||||
public static final String CONTENT_TYPE_TEXT = "text";
|
||||
}
|
||||
|
||||
public final class ApplicationProperties {
|
||||
private ApplicationProperties(){
|
||||
throw new AssertionError();
|
||||
}
|
||||
public static final String NAME = "name";
|
||||
public static final String IDENTIFIER = "package";
|
||||
public static final String ICON = "icon";
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.services.android.util;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.wso2.carbon.device.mgt.common.*;
|
||||
import org.wso2.carbon.mdm.services.android.exception.BadRequestException;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Util class for holding Android device related util methods.
|
||||
*/
|
||||
public class AndroidDeviceUtils {
|
||||
|
||||
private static final String COMMA_SEPARATION_PATTERN = ", ";
|
||||
|
||||
public DeviceIDHolder validateDeviceIdentifiers(List<String> deviceIDs,
|
||||
Message message, MediaType responseMediaType) {
|
||||
|
||||
if (deviceIDs == null || deviceIDs.isEmpty()) {
|
||||
message.setResponseMessage("Device identifier list is empty");
|
||||
throw new BadRequestException(message, responseMediaType);
|
||||
}
|
||||
|
||||
List<String> errorDeviceIdList = new ArrayList<String>();
|
||||
List<DeviceIdentifier> validDeviceIDList = new ArrayList<DeviceIdentifier>();
|
||||
|
||||
int deviceIDCounter = 0;
|
||||
for (String deviceID : deviceIDs) {
|
||||
|
||||
deviceIDCounter++;
|
||||
|
||||
if (deviceID == null || deviceID.isEmpty()) {
|
||||
errorDeviceIdList.add(String.format(AndroidConstants.DeviceConstants.DEVICE_ID_NOT_FOUND,
|
||||
deviceIDCounter));
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||
deviceIdentifier.setId(deviceID);
|
||||
deviceIdentifier.setType(DeviceManagementConstants.MobileDeviceTypes.
|
||||
MOBILE_DEVICE_TYPE_ANDROID);
|
||||
|
||||
if (isValidDeviceIdentifier(deviceIdentifier)) {
|
||||
validDeviceIDList.add(deviceIdentifier);
|
||||
} else {
|
||||
errorDeviceIdList.add(String.format(AndroidConstants.DeviceConstants.DEVICE_ID_NOT_FOUND,
|
||||
deviceIDCounter));
|
||||
}
|
||||
} catch (DeviceManagementException e) {
|
||||
errorDeviceIdList.add(String.format(AndroidConstants.DeviceConstants.DEVICE_ID_SERVICE_NOT_FOUND,
|
||||
deviceIDCounter));
|
||||
}
|
||||
}
|
||||
|
||||
DeviceIDHolder deviceIDHolder = new DeviceIDHolder();
|
||||
deviceIDHolder.setValidDeviceIDList(validDeviceIDList);
|
||||
deviceIDHolder.setErrorDeviceIdList(errorDeviceIdList);
|
||||
|
||||
return deviceIDHolder;
|
||||
}
|
||||
|
||||
public String convertErrorMapIntoErrorMessage(List<String> errorDeviceIdList) {
|
||||
return StringUtils.join(errorDeviceIdList.iterator(), COMMA_SEPARATION_PATTERN);
|
||||
}
|
||||
|
||||
public static boolean isValidDeviceIdentifier(DeviceIdentifier deviceIdentifier) throws DeviceManagementException {
|
||||
Device device = AndroidAPIUtils.getDeviceManagementService().
|
||||
getDevice(deviceIdentifier);
|
||||
if (device == null || device.getDeviceIdentifier() == null ||
|
||||
device.getDeviceIdentifier().isEmpty() || device.getEnrolmentInfo() == null) {
|
||||
return false;
|
||||
} else if (EnrolmentInfo.Status.REMOVED.equals(device.getEnrolmentInfo().getStatus())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.services.android.util;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Holder class for storing valid & invalid device-ids.
|
||||
*/
|
||||
public class DeviceIDHolder {
|
||||
|
||||
private List<String> errorDeviceIdList;
|
||||
private List<DeviceIdentifier> validDeviceIDList;
|
||||
|
||||
public List<String> getErrorDeviceIdList() {
|
||||
return errorDeviceIdList;
|
||||
}
|
||||
|
||||
public void setErrorDeviceIdList(List<String> errorDeviceIdList) {
|
||||
this.errorDeviceIdList = errorDeviceIdList;
|
||||
}
|
||||
|
||||
public List<DeviceIdentifier> getValidDeviceIDList() {
|
||||
return validDeviceIDList;
|
||||
}
|
||||
|
||||
public void setValidDeviceIDList(List<DeviceIdentifier> validDeviceIDList) {
|
||||
this.validDeviceIDList = validDeviceIDList;
|
||||
}
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.mdm.services.android.util;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
* This class contains the information of response message.
|
||||
*/
|
||||
@XmlRootElement
|
||||
public class Message {
|
||||
|
||||
private String responseCode;
|
||||
private String responseMessage;
|
||||
|
||||
@XmlElement
|
||||
public String getResponseMessage() {
|
||||
return responseMessage;
|
||||
}
|
||||
|
||||
public void setResponseMessage(String responseMessage) {
|
||||
this.responseMessage = responseMessage;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getResponseCode() {
|
||||
return responseCode;
|
||||
}
|
||||
|
||||
public void setResponseCode(String responseCode) {
|
||||
this.responseCode = responseCode;
|
||||
}
|
||||
|
||||
private MessageBuilder getBuilder() {
|
||||
return new MessageBuilder();
|
||||
}
|
||||
|
||||
public static MessageBuilder responseCode(String responseCode) {
|
||||
Message message = new Message();
|
||||
return message.getBuilder().responseCode(responseCode);
|
||||
}
|
||||
|
||||
public static MessageBuilder responseMessage(String responseMessage) {
|
||||
Message message = new Message();
|
||||
return message.getBuilder().responseMessage(responseMessage);
|
||||
}
|
||||
|
||||
public class MessageBuilder {
|
||||
|
||||
private String responseCode;
|
||||
private String responseMessage;
|
||||
|
||||
public MessageBuilder responseCode(String responseCode) {
|
||||
this.responseCode = responseCode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MessageBuilder responseMessage(String responseMessage) {
|
||||
this.responseMessage = responseMessage;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Message build() {
|
||||
Message message = new Message();
|
||||
message.setResponseCode(responseCode);
|
||||
message.setResponseMessage(responseMessage);
|
||||
return message;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,315 @@
|
||||
<?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 authorization scope (OAuth2).
|
||||
When defining dynamic paths for APIs, path variables are denoted by '*' notation.
|
||||
For ex:
|
||||
Actual API endpoint: mdm-android-agent/1.0.0/operation/{device-id}
|
||||
URL to be represented here: /operation/*
|
||||
NOTE: All the endpoints of the web app should be available in this file. Otherwise
|
||||
it will result 403 error at the runtime.
|
||||
-->
|
||||
<PermissionConfiguration>
|
||||
<APIVersion></APIVersion>
|
||||
<!-- Operations management related permissions for admin -->
|
||||
<Permission>
|
||||
<name>Get Pending Operation</name>
|
||||
<path>/device-mgt/android/operations/poll</path>
|
||||
<url>/operation/*</url>
|
||||
<method>PUT</method>
|
||||
<scope>emm_android_agent</scope>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Lock</name>
|
||||
<path>/device-mgt/android/operations/lock</path>
|
||||
<url>/operation/lock</url>
|
||||
<method>POST</method>
|
||||
<scope>emm_admin,emm_user</scope>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Mute</name>
|
||||
<path>/device-mgt/android/operations/mute</path>
|
||||
<url>/operation/mute</url>
|
||||
<method>POST</method>
|
||||
<scope>emm_admin,emm_user</scope>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Location</name>
|
||||
<path>/device-mgt/android/operations/location</path>
|
||||
<url>/operation/location</url>
|
||||
<method>POST</method>
|
||||
<scope>emm_admin,emm_user</scope>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Clear Passcode</name>
|
||||
<url>/operation/clear-password/</url>
|
||||
<method>POST</method>
|
||||
<scope>emm_admin</scope>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Camera</name>
|
||||
<path>/device-mgt/android/operations/camera</path>
|
||||
<url>/operation/camera</url>
|
||||
<method>POST</method>
|
||||
<scope>emm_admin,emm_user</scope>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Device Info</name>
|
||||
<path>/device-mgt/android/operations/device-info</path>
|
||||
<url>/operation/device-info</url>
|
||||
<method>POST</method>
|
||||
<scope>emm_admin,emm_user</scope>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Enterprise Wipe</name>
|
||||
<path>/device-mgt/android/operations/enterprise-wipe</path>
|
||||
<url>/operation/enterprise-wipe</url>
|
||||
<method>POST</method>
|
||||
<scope>emm_admin</scope>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Wipe Data</name>
|
||||
<path>/device-mgt/android/operations/wipe-data</path>
|
||||
<url>/operation/wipe-data</url>
|
||||
<method>POST</method>
|
||||
<scope>emm_admin</scope>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Application List</name>
|
||||
<path>/device-mgt/android/operations/application-list</path>
|
||||
<url>/operation/application-list</url>
|
||||
<method>POST</method>
|
||||
<scope>emm_admin,emm_user</scope>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Ring</name>
|
||||
<path>/device-mgt/android/operations/ring-device</path>
|
||||
<url>/operation/ring-device</url>
|
||||
<method>POST</method>
|
||||
<scope>emm_admin,emm_user</scope>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Install Application</name>
|
||||
<path>/device-mgt/android/operations/install-application</path>
|
||||
<url>/operation/install-application</url>
|
||||
<method>POST</method>
|
||||
<scope>emm_admin,emm_user</scope>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Uninstall Application</name>
|
||||
<path>/device-mgt/android/operations/uninstall-application</path>
|
||||
<url>/operation/uninstall-application</url>
|
||||
<method>POST</method>
|
||||
<scope>emm_admin,emm_user</scope>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Blacklist Applications</name>
|
||||
<path>/device-mgt/android/operations/blacklist-applications</path>
|
||||
<url>/operation/blacklist-applications</url>
|
||||
<method>POST</method>
|
||||
<scope>emm_admin</scope>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Notification</name>
|
||||
<path>/device-mgt/android/operations/notification</path>
|
||||
<url>/operation/notification</url>
|
||||
<method>POST</method>
|
||||
<scope>emm_admin,emm_user</scope>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Wifi</name>
|
||||
<path>/device-mgt/android/operations/wifi</path>
|
||||
<url>/operation/wifi</url>
|
||||
<method>POST</method>
|
||||
<scope>emm_admin</scope>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Encryption</name>
|
||||
<path>/device-mgt/android/operations/encrypt</path>
|
||||
<url>/operation/encrypt</url>
|
||||
<method>POST</method>
|
||||
<scope>emm_admin</scope>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Change lock code</name>
|
||||
<path>/device-mgt/android/operations/change-lock-code</path>
|
||||
<url>/operation/change-lock-code</url>
|
||||
<method>POST</method>
|
||||
<scope>emm_admin</scope>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Password Policy</name>
|
||||
<path>/device-mgt/android/operations/password-policy</path>
|
||||
<url>/operation/password-policy</url>
|
||||
<method>POST</method>
|
||||
<scope>emm_admin</scope>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Webclip</name>
|
||||
<path>/device-mgt/android/operations/webclip</path>
|
||||
<url>/operation/webclip</url>
|
||||
<method>POST</method>
|
||||
<scope>emm_admin</scope>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Disenroll</name>
|
||||
<path>/device-mgt/android/operations/disenroll</path>
|
||||
<url>/operation/disenroll</url>
|
||||
<method>POST</method>
|
||||
<scope>emm_android_agent</scope>
|
||||
</Permission>
|
||||
|
||||
<!-- Device management related permissions -->
|
||||
<Permission>
|
||||
<name>View devices</name>
|
||||
<path>/device-mgt/android/devices/list</path>
|
||||
<url>/device</url>
|
||||
<method>GET</method>
|
||||
<scope>emm_admin</scope>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>View device</name>
|
||||
<path>/device-mgt/android/devices/view</path>
|
||||
<url>/device/*</url>
|
||||
<method>GET</method>
|
||||
<scope>emm_admin,emm_user</scope>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Update device</name>
|
||||
<path>/device-mgt/android/devices/update</path>
|
||||
<url>/device/*</url>
|
||||
<method>PUT</method>
|
||||
<scope>emm_admin,emm_user</scope>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Update application list</name>
|
||||
<path>/device-mgt/android/devices/update-app</path>
|
||||
<url>/device/appList/*</url>
|
||||
<method>POST</method>
|
||||
<scope>emm_admin</scope>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>View license</name>
|
||||
<path>/device-mgt/android/license/view</path>
|
||||
<url>/device/license</url>
|
||||
<method>GET</method>
|
||||
<scope>emm_android_agent</scope>
|
||||
</Permission>
|
||||
|
||||
<!-- Enrollment related permissions -->
|
||||
<Permission>
|
||||
<name>Enroll device</name>
|
||||
<path>/device-mgt/android/devices/enroll</path>
|
||||
<url>/enrollment</url>
|
||||
<method>POST</method>
|
||||
<scope>emm_android_agent</scope>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Get Enrollment Status</name>
|
||||
<path>/device-mgt/android/devices/enroll</path>
|
||||
<url>/enrollment/*</url>
|
||||
<method>GET</method>
|
||||
<scope>emm_android_agent</scope>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Update Enrollment</name>
|
||||
<path>/device-mgt/android/devices/enroll</path>
|
||||
<url>/enrollment/*</url>
|
||||
<method>PUT</method>
|
||||
<scope>emm_user,emm_admin</scope>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Disenroll device</name>
|
||||
<path>/device-mgt/android/devices/enroll</path>
|
||||
<url>/enrollment/*</url>
|
||||
<method>DELETE</method>
|
||||
<scope>emm_user,emm_admin</scope>
|
||||
</Permission>
|
||||
|
||||
<!-- Policy related permissions -->
|
||||
<Permission>
|
||||
<name>View Policies</name>
|
||||
<path>/device-mgt/android/policies/view</path>
|
||||
<url>/policy/*</url>
|
||||
<method>GET</method>
|
||||
<scope>emm_admin</scope>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>View Policy Features</name>
|
||||
<path>/device-mgt/android/policies/view</path>
|
||||
<url>/policy/features/*</url>
|
||||
<method>GET</method>
|
||||
<scope>emm_admin</scope>
|
||||
</Permission>
|
||||
|
||||
<!-- Configuration related permissions -->
|
||||
<Permission>
|
||||
<name>View Tenant configuration</name>
|
||||
<path>/device-mgt/android/tenant/configuration</path>
|
||||
<url>/configuration</url>
|
||||
<method>GET</method>
|
||||
<scope>emm_admin</scope>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Add Tenant configuration</name>
|
||||
<path>/device-mgt/android/tenant/configuration</path>
|
||||
<url>/configuration</url>
|
||||
<method>POST</method>
|
||||
<scope>emm_admin</scope>
|
||||
</Permission>
|
||||
|
||||
<Permission>
|
||||
<name>Update Tenant configuration</name>
|
||||
<path>/device-mgt/android/tenant/configuration</path>
|
||||
<url>/configuration</url>
|
||||
<method>PUT</method>
|
||||
<scope>emm_admin</scope>
|
||||
</Permission>
|
||||
</PermissionConfiguration>
|
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
|
||||
<!--
|
||||
~ Copyright (c) 2014, 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 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,80 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2014, 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.
|
||||
-->
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
|
||||
|
||||
<jaxrs:server id="operationService" address="/operation">
|
||||
<jaxrs:serviceBeans>
|
||||
<ref bean="operationServiceBean"/>
|
||||
</jaxrs:serviceBeans>
|
||||
<jaxrs:providers>
|
||||
<ref bean="jsonProvider"/>
|
||||
<ref bean="errorHandler"/>
|
||||
</jaxrs:providers>
|
||||
</jaxrs:server>
|
||||
<jaxrs:server id="deviceManagementService" address="/device">
|
||||
<jaxrs:serviceBeans>
|
||||
<ref bean="deviceMgtServiceBean"/>
|
||||
</jaxrs:serviceBeans>
|
||||
<jaxrs:providers>
|
||||
<ref bean="jsonProvider"/>
|
||||
<ref bean="errorHandler"/>
|
||||
</jaxrs:providers>
|
||||
</jaxrs:server>
|
||||
<jaxrs:server id="enrollmentService" address="/enrollment">
|
||||
<jaxrs:serviceBeans>
|
||||
<ref bean="enrollmentServiceBean"/>
|
||||
</jaxrs:serviceBeans>
|
||||
<jaxrs:providers>
|
||||
<ref bean="jsonProvider"/>
|
||||
<ref bean="errorHandler"/>
|
||||
</jaxrs:providers>
|
||||
</jaxrs:server>
|
||||
<jaxrs:server id="policyService" address="/policy">
|
||||
<jaxrs:serviceBeans>
|
||||
<ref bean="policyServiceBean"/>
|
||||
</jaxrs:serviceBeans>
|
||||
<jaxrs:providers>
|
||||
<ref bean="jsonProvider"/>
|
||||
<ref bean="errorHandler"/>
|
||||
</jaxrs:providers>
|
||||
</jaxrs:server>
|
||||
<jaxrs:server id="configurationService" address="/configuration">
|
||||
<jaxrs:serviceBeans>
|
||||
<ref bean="configurationServiceBean"/>
|
||||
</jaxrs:serviceBeans>
|
||||
<jaxrs:providers>
|
||||
<ref bean="jsonProvider"/>
|
||||
<ref bean="errorHandler"/>
|
||||
</jaxrs:providers>
|
||||
</jaxrs:server>
|
||||
|
||||
<bean id="deviceMgtServiceBean" class="org.wso2.carbon.mdm.services.android.DeviceManagementService"/>
|
||||
<bean id="enrollmentServiceBean" class="org.wso2.carbon.mdm.services.android.EnrollmentService"/>
|
||||
<bean id="operationServiceBean" class="org.wso2.carbon.mdm.services.android.OperationMgtService"/>
|
||||
<bean id="policyServiceBean" class="org.wso2.carbon.mdm.services.android.PolicyMgtService"/>
|
||||
<bean id="configurationServiceBean" class="org.wso2.carbon.mdm.services.android.ConfigurationMgtService"/>
|
||||
<bean id="jsonProvider" class="org.wso2.carbon.mdm.services.android.common.GsonMessageBodyHandler"/>
|
||||
<bean id="errorHandler" class="org.wso2.carbon.mdm.services.android.common.ErrorHandler"/>
|
||||
</beans>
|
||||
|
@ -0,0 +1,71 @@
|
||||
<?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.
|
||||
-->
|
||||
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
|
||||
<display-name>Admin-Webapp</display-name>
|
||||
<servlet>
|
||||
<description>JAX-WS/JAX-RS MDM Endpoint</description>
|
||||
<display-name>JAX-WS/JAX-RS Servlet</display-name>
|
||||
<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>
|
||||
<session-config>
|
||||
<session-timeout>60</session-timeout>
|
||||
</session-config>
|
||||
|
||||
<context-param>
|
||||
<param-name>isAdminService</param-name>
|
||||
<param-value>false</param-value>
|
||||
</context-param>
|
||||
<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>doAuthentication</param-name>
|
||||
<param-value>true</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-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>MDM-Admin</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>
|
@ -0,0 +1,117 @@
|
||||
@CHARSET "ISO-8859-1";
|
||||
|
||||
/* http://meyerweb.com/eric/tools/css/reset/
|
||||
v2.0 | 20110126
|
||||
License: none (public domain)
|
||||
*/
|
||||
|
||||
html, body, div, span, applet, object, iframe,
|
||||
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
||||
a, abbr, acronym, address, big, cite, code,
|
||||
del, dfn, em, img, ins, kbd, q, s, samp,
|
||||
small, strike, strong, sub, sup, tt, var,
|
||||
b, u, i, center,
|
||||
dl, dt, dd, ol, ul, li,
|
||||
fieldset, form, label, legend,
|
||||
table, caption, tbody, tfoot, thead, tr, th, td,
|
||||
article, aside, canvas, details, embed,
|
||||
figure, figcaption, footer, header, hgroup,
|
||||
menu, nav, output, ruby, section, summary,
|
||||
time, mark, audio, video {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
font-size: 100%;
|
||||
font: inherit;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
/* HTML5 display-role reset for older browsers */
|
||||
article, aside, details, figcaption, figure,
|
||||
footer, header, hgroup, menu, nav, section {
|
||||
display: block;
|
||||
}
|
||||
|
||||
html {
|
||||
background: #efefef;
|
||||
}
|
||||
|
||||
body {
|
||||
line-height: 1;
|
||||
width:960px;
|
||||
margin:auto;
|
||||
background:white;
|
||||
padding:10px;
|
||||
box-shadow:0px 0px 5px #CCC;
|
||||
font-family:"Lucida Grande","Lucida Sans","Microsoft Sans Serif", "Lucida Sans Unicode","Verdana","Sans-serif","trebuchet ms" !important;
|
||||
|
||||
}
|
||||
ol, ul {
|
||||
list-style: none;
|
||||
}
|
||||
blockquote, q {
|
||||
quotes: none;
|
||||
}
|
||||
blockquote:before, blockquote:after,
|
||||
q:before, q:after {
|
||||
content: '';
|
||||
content: none;
|
||||
}
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
width:960px;
|
||||
border:solid 1px #ccc;
|
||||
}
|
||||
|
||||
table a {
|
||||
font-size:12px;
|
||||
color:#1e90ff;
|
||||
padding:7px;
|
||||
float:left;
|
||||
;
|
||||
}
|
||||
|
||||
.heading {
|
||||
font-size: 18px;
|
||||
margin-top: 20px;
|
||||
float:left;
|
||||
color:#0067B1;
|
||||
margin-bottom:20px;
|
||||
padding-top:20px;
|
||||
}
|
||||
|
||||
.field {
|
||||
font-weight: normal;
|
||||
width:120px;
|
||||
font-size:12px;
|
||||
float:left;
|
||||
padding:7px;
|
||||
clear:left;
|
||||
}
|
||||
.value {
|
||||
font-weight: bold;
|
||||
font-size:12px;
|
||||
float:left;
|
||||
padding:7px;
|
||||
clear:right;
|
||||
}
|
||||
.porttypename {
|
||||
font-weight: bold;
|
||||
font-size:14px;
|
||||
}
|
||||
UL {
|
||||
margin-top: 0;
|
||||
}
|
||||
LI {
|
||||
font-weight: normal;
|
||||
font-size:12px;
|
||||
margin-top:10px;
|
||||
}
|
||||
|
||||
TD {
|
||||
border:1px solid #ccc;
|
||||
vertical-align: text-top;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
instructions.configure = \
|
||||
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,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);\
|
||||
|
Loading…
Reference in new issue