forked from community/device-mgt-plugins
parent
a47654e1f2
commit
3cdb490908
@ -1,161 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016, 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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,183 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016, 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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,153 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2016, 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);
|
|
||||||
device.getEnrolmentInfo().setOwner(AndroidAPIUtils.getAuthenticatedUser());
|
|
||||||
boolean status = AndroidAPIUtils.getDeviceManagementService().enrollDevice(device);
|
|
||||||
if (status) {
|
|
||||||
Response.status(Response.Status.CREATED);
|
|
||||||
responseMsg.setResponseMessage("Device enrollment succeeded.");
|
|
||||||
responseMsg.setResponseCode(Response.Status.CREATED.toString());
|
|
||||||
} else {
|
|
||||||
Response.status(Response.Status.INTERNAL_SERVER_ERROR);
|
|
||||||
responseMsg.setResponseMessage("Device enrollment failed.");
|
|
||||||
responseMsg.setResponseCode(Response.Status.INTERNAL_SERVER_ERROR.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,81 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.services.configuration;
|
||||||
|
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration;
|
||||||
|
import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
|
||||||
|
import org.wso2.carbon.mdm.services.android.util.Message;
|
||||||
|
|
||||||
|
import javax.jws.WebService;
|
||||||
|
import javax.ws.rs.*;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Android Platform Configuration REST-API implementation.
|
||||||
|
* All end points supports JSON, XMl with content negotiation.
|
||||||
|
*/
|
||||||
|
@Api(value = "ConfigurationMgtService")
|
||||||
|
@WebService
|
||||||
|
@Produces({"application/json", "application/xml"})
|
||||||
|
@Consumes({"application/json", "application/xml"})
|
||||||
|
public interface ConfigurationMgtService {
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@ApiOperation(
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Configuring Android Platform Settings",
|
||||||
|
notes = "Configure the Android platform settings using this REST API"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 201, message = "Android platform configuration saved successfully"),
|
||||||
|
@ApiResponse(code = 500, message = "Internal Server Error")
|
||||||
|
})
|
||||||
|
Message configureSettings(@ApiParam(name = "configuration", value = "AndroidPlatformConfiguration")
|
||||||
|
TenantConfiguration configuration) throws AndroidAgentException;
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@ApiOperation(
|
||||||
|
httpMethod = "GET",
|
||||||
|
value = "Getting Android Platform Configurations",
|
||||||
|
notes = "Get the Android platform configuration details using this REST API",
|
||||||
|
response = TenantConfiguration.class
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 200, message = "Get Android Configurations"),
|
||||||
|
@ApiResponse(code = 500, message = "Server Error")
|
||||||
|
})
|
||||||
|
TenantConfiguration getConfiguration() throws AndroidAgentException;
|
||||||
|
|
||||||
|
@PUT
|
||||||
|
@ApiOperation(
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "PUT",
|
||||||
|
value = "Updating Android Platform Configurations",
|
||||||
|
notes = "Update the Android platform configurations using this REST API"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 201, message = "Created"),
|
||||||
|
@ApiResponse(code = 500, message = "Error occurred while modifying configuration settings of " +
|
||||||
|
"Android platform")
|
||||||
|
})
|
||||||
|
Message updateConfiguration(TenantConfiguration configuration) throws AndroidAgentException;
|
||||||
|
}
|
@ -0,0 +1,162 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.services.configuration.impl;
|
||||||
|
|
||||||
|
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.services.configuration.ConfigurationMgtService;
|
||||||
|
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 ConfigurationMgtServiceImpl implements ConfigurationMgtService {
|
||||||
|
private static Log log = LogFactory.getLog(ConfigurationMgtServiceImpl.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,147 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.services.devicemgt;
|
||||||
|
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import org.wso2.carbon.device.mgt.common.Device;
|
||||||
|
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
|
||||||
|
import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
|
||||||
|
import org.wso2.carbon.mdm.services.android.util.Message;
|
||||||
|
|
||||||
|
import javax.jws.WebService;
|
||||||
|
import javax.ws.rs.*;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Android Device Management REST-API implementation.
|
||||||
|
* All end points supports JSON, XMl with content negotiation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Api(value = "DeviceManagementService")
|
||||||
|
@WebService
|
||||||
|
@Produces({"application/json", "application/xml"})
|
||||||
|
@Consumes({"application/json", "application/xml"})
|
||||||
|
public interface DeviceManagementService {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all devices.Returns list of Android devices registered in MDM.
|
||||||
|
*
|
||||||
|
* @return Device List
|
||||||
|
* @throws org.wso2.carbon.mdm.services.android.exception.AndroidAgentException
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@ApiOperation(
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "GET",
|
||||||
|
value = "Getting Details of All Android Devices",
|
||||||
|
notes = "Use this REST API to retrieve the details " +
|
||||||
|
"(e.g., the Android device type, serial number, International Mobile Station Equipment Identity " +
|
||||||
|
"(IMEI), owner, version, model etc.) of all Android devices that are registered with WSO2 EMM.",
|
||||||
|
response = Device.class,
|
||||||
|
responseContainer = "List"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 200, message = "List of Devices"),
|
||||||
|
@ApiResponse(code = 500, message = "Error occurred while fetching the device list")
|
||||||
|
})
|
||||||
|
List<org.wso2.carbon.device.mgt.common.Device> getAllDevices() throws AndroidAgentException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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}")
|
||||||
|
@ApiOperation(
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "GET",
|
||||||
|
value = "Getting Details of an Android Device",
|
||||||
|
notes = "Use this REST API to retrieve the details " +
|
||||||
|
"(e.g., the Android device type, serial number, International Mobile Station Equipment Identity " +
|
||||||
|
"(IMEI), owner, version, model etc.) of a specific Android device that is registered with WSO2 EMM",
|
||||||
|
response = Device.class
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 200, message = "Information of the given device"),
|
||||||
|
@ApiResponse(code = 500, message = "Error occurred while fetching the device information")
|
||||||
|
})
|
||||||
|
org.wso2.carbon.device.mgt.common.Device getDevice(@ApiParam(name = "id", value = "deviceIdentifier")
|
||||||
|
@PathParam("id") String id) throws AndroidAgentException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update Android device details of given device id.
|
||||||
|
*
|
||||||
|
* @param id Device Id
|
||||||
|
* @param device Device Details
|
||||||
|
* @return Message
|
||||||
|
* @throws AndroidAgentException
|
||||||
|
*/
|
||||||
|
@PUT
|
||||||
|
@ApiOperation(
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "PUT",
|
||||||
|
value = "Updating the Details of an Android Device",
|
||||||
|
notes = "Use this REST API to update the details of an Android device"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 202, message = "The device enrollment details has been updated successfully"),
|
||||||
|
@ApiResponse(code = 500, message = "Error occurred while modifying the device information"),
|
||||||
|
@ApiResponse(code = 304, message = "Device not found for the update")
|
||||||
|
})
|
||||||
|
@Path("{id}")
|
||||||
|
Message updateDevice(@ApiParam(name = "id", value = "deviceIdentifier")
|
||||||
|
@PathParam("id") String id, @ApiParam(name = "device", value = "deviceIdentifier")
|
||||||
|
Device device) throws AndroidAgentException;
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@ApiOperation(
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Updating an ApplicationList",
|
||||||
|
notes = "Update application list in server side."
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 202, message = "Device information has modified successfully"),
|
||||||
|
@ApiResponse(code = 500, message = "Error occurred while modifying the application list")
|
||||||
|
})
|
||||||
|
Message updateApplicationList(@ApiParam(name = "id", value = "deviceIdentifier") @PathParam("id") String id,
|
||||||
|
@ApiParam(name = "applications", value = "updatable applications")
|
||||||
|
List<Application> applications);
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("license")
|
||||||
|
@Produces("text/html")
|
||||||
|
@ApiOperation(
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "GET",
|
||||||
|
value = "Getting the License Agreement for Android Device Registration",
|
||||||
|
notes = "Use this REST API to retrieve the license agreement that is used for the Android device " +
|
||||||
|
"registration process",
|
||||||
|
response = String.class)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 200, message = "Licence agreement"),
|
||||||
|
@ApiResponse(code = 500, message = "Error occurred while retrieving the license configured for Android " +
|
||||||
|
"device enrolment")})
|
||||||
|
String getLicense() throws AndroidAgentException;
|
||||||
|
}
|
@ -0,0 +1,184 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.services.devicemgt.impl;
|
||||||
|
|
||||||
|
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 DeviceManagementServiceImpl {
|
||||||
|
|
||||||
|
private static Log log = LogFactory.getLog(DeviceManagementServiceImpl.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all devices.Returns list of Android devices registered in MDM.
|
||||||
|
*
|
||||||
|
* @return Device List
|
||||||
|
* @throws AndroidAgentException
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
public List<Device> getAllDevices()
|
||||||
|
throws AndroidAgentException {
|
||||||
|
String msg;
|
||||||
|
List<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 AndroidAgentException
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Path("{id}")
|
||||||
|
public Device getDevice(@PathParam("id") String id)
|
||||||
|
throws AndroidAgentException {
|
||||||
|
|
||||||
|
String msg;
|
||||||
|
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,99 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.services.enrollment;
|
||||||
|
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
|
||||||
|
import org.wso2.carbon.mdm.services.android.util.Message;
|
||||||
|
|
||||||
|
import javax.jws.WebService;
|
||||||
|
import javax.ws.rs.*;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Android Device Enrollment REST-API implementation.
|
||||||
|
* All end points supports JSON, XMl with content negotiation.
|
||||||
|
*/
|
||||||
|
@Api(value = "EnrollmentService")
|
||||||
|
@WebService
|
||||||
|
@Produces({"application/json", "application/xml"})
|
||||||
|
@Consumes({"application/json", "application/xml"})
|
||||||
|
public interface EnrollmentService {
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@ApiOperation(
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Registering an Android Device",
|
||||||
|
notes = "When carrying out device registration via an Android device, you need to initially install" +
|
||||||
|
" an Android Agent on the device, before being able to register the device with WSO2 EMM. Instead," +
|
||||||
|
" you can use this REST API to register an Android device with WSO2 EMM, without having to install" +
|
||||||
|
" an Android Agent on the respective device"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 201, message = "Device enrollment succeeded"),
|
||||||
|
@ApiResponse(code = 500, message = "Device enrollment failed"),
|
||||||
|
})
|
||||||
|
Message enrollDevice(@ApiParam(name = "device", value = "Device Information to be enroll")
|
||||||
|
org.wso2.carbon.device.mgt.common.Device device) throws AndroidAgentException;
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("{deviceId}")
|
||||||
|
@ApiOperation(
|
||||||
|
httpMethod = "GET",
|
||||||
|
value = "Getting the Registration Status of an Android Device",
|
||||||
|
notes = "Use this REST API to retrieve the registration status of an Android device"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 202, message = "Device has already enrolled"),
|
||||||
|
@ApiResponse(code = 404, message = "Device not found")
|
||||||
|
})
|
||||||
|
Message isEnrolled(@ApiParam(name = "deviceId", value = "DeviceIdentifier") @PathParam("deviceId") String id)
|
||||||
|
throws AndroidAgentException;
|
||||||
|
|
||||||
|
@PUT
|
||||||
|
@Path("{deviceId}")
|
||||||
|
@ApiOperation(
|
||||||
|
httpMethod = "PUT",
|
||||||
|
value = "Updating the Registration Details of an Android Device",
|
||||||
|
notes = "Use this REST API to update the registration details of an Android device"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 202, message = "Device enrollment has updated successfully"),
|
||||||
|
@ApiResponse(code = 404, message = "Device not found for enrollment")
|
||||||
|
})
|
||||||
|
Message modifyEnrollment(@ApiParam(name = "deviceId", value = "DeviceIdentifier") @PathParam("deviceId") String id,
|
||||||
|
@ApiParam(name = "device", value = "Device information to be modify")
|
||||||
|
org.wso2.carbon.device.mgt.common.Device device)
|
||||||
|
throws AndroidAgentException;
|
||||||
|
|
||||||
|
@DELETE
|
||||||
|
@ApiOperation(
|
||||||
|
httpMethod = "DELETE",
|
||||||
|
value = "Un-registering an Android Device",
|
||||||
|
notes = "Use this REST API to unregister a specific Android device"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 202, message = "Device has removed successfully"),
|
||||||
|
@ApiResponse(code = 404, message = "Device not found")
|
||||||
|
})
|
||||||
|
@Path("{deviceId}")
|
||||||
|
Message disEnrollDevice(@ApiParam(name = "deviceId", value = "DeviceIdentifier") @PathParam("deviceId") String id)
|
||||||
|
throws AndroidAgentException;
|
||||||
|
}
|
@ -0,0 +1,158 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.services.enrollment.impl;
|
||||||
|
|
||||||
|
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.services.enrollment.EnrollmentService;
|
||||||
|
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 EnrollmentServiceImpl implements 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);
|
||||||
|
device.getEnrolmentInfo().setOwner(AndroidAPIUtils.getAuthenticatedUser());
|
||||||
|
boolean status = AndroidAPIUtils.getDeviceManagementService().enrollDevice(device);
|
||||||
|
if (status) {
|
||||||
|
Response.status(Response.Status.CREATED);
|
||||||
|
responseMsg.setResponseMessage("Device enrollment succeeded.");
|
||||||
|
responseMsg.setResponseCode(Response.Status.CREATED.toString());
|
||||||
|
} else {
|
||||||
|
Response.status(Response.Status.INTERNAL_SERVER_ERROR);
|
||||||
|
responseMsg.setResponseMessage("Device enrollment failed.");
|
||||||
|
responseMsg.setResponseCode(Response.Status.INTERNAL_SERVER_ERROR.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 checking enrollment status of the device.";
|
||||||
|
responseMsg.setResponseMessage(msg);
|
||||||
|
responseMsg.setResponseCode(Response.Status.INTERNAL_SERVER_ERROR.toString());
|
||||||
|
Response.status(Response.Status.INTERNAL_SERVER_ERROR);
|
||||||
|
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,414 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.services.operationmgt;
|
||||||
|
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||||
|
import org.wso2.carbon.mdm.services.android.bean.wrapper.*;
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Api("OperationMgtService")
|
||||||
|
public interface OperationMgtService {
|
||||||
|
String ACCEPT = "Accept";
|
||||||
|
|
||||||
|
@PUT
|
||||||
|
@Path("{id}")
|
||||||
|
@ApiOperation(
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "PUT",
|
||||||
|
value = "Getting Pending Android Device Operations",
|
||||||
|
responseContainer = "List",
|
||||||
|
notes = "The Android agent communicates with the server to get the operations that are queued up " +
|
||||||
|
"at the server end for a given device using this REST API",
|
||||||
|
response = Operation.class)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 200, message = "List of pending operations"),
|
||||||
|
@ApiResponse(code = 500, message = "Issue in retrieving operation management service instance")
|
||||||
|
})
|
||||||
|
List<? extends Operation> getPendingOperations(
|
||||||
|
@ApiParam(name = "acceptHeader", value = "Accept Header") @HeaderParam(ACCEPT) String acceptHeader,
|
||||||
|
@ApiParam(name = "id", value = "DeviceIdentifier") @PathParam("id") String id,
|
||||||
|
@ApiParam(name = "resultOperations", value = "Device Operation Status")
|
||||||
|
List<? extends Operation> resultOperations);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("lock")
|
||||||
|
@ApiOperation(
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Adding a Device Lock on Android Devices",
|
||||||
|
responseContainer = "List",
|
||||||
|
notes = "Using this API you have the option of hard locking an Android device, where the Administrator " +
|
||||||
|
"permanently locks the device or screen locking an Android device",
|
||||||
|
response = String.class)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 201, message = "created"),
|
||||||
|
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
||||||
|
})
|
||||||
|
Response configureDeviceLock(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
||||||
|
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "deviceIDs", value =
|
||||||
|
"DeviceIds to be enable device lock operation")
|
||||||
|
List<String> deviceIDs);
|
||||||
|
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("location")
|
||||||
|
@ApiOperation(
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Requesting Location Coordinates of Android Devices",
|
||||||
|
responseContainer = "List",
|
||||||
|
notes = "Request location coordinates of Android devices",
|
||||||
|
response = String.class)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 201, message = "Requested Device Coordinates"),
|
||||||
|
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")})
|
||||||
|
Response getDeviceLocation(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
||||||
|
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "deviceIDs",
|
||||||
|
value = "DeviceIDs to be requested to get device location")
|
||||||
|
List<String> deviceIDs);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("clear-password")
|
||||||
|
@ApiOperation(
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Clearing the Password on Android Devices",
|
||||||
|
notes = "Clear the password on Android devices"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 201, message = "Created"),
|
||||||
|
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
||||||
|
})
|
||||||
|
Response removePassword(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
||||||
|
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "deviceIDs",
|
||||||
|
value = "DeviceIds to be requested to remove password")
|
||||||
|
List<String> deviceIDs);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("camera")
|
||||||
|
@ApiOperation(
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Enabling or Disabling the Camera on Android Devices",
|
||||||
|
notes = "Enable or disable the camera on Android devices"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 201, message = "Created"),
|
||||||
|
@ApiResponse(code = 500, message = "Issue in creating a new camera instance")
|
||||||
|
})
|
||||||
|
Response configureCamera(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
||||||
|
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "cameraBeanWrapper",
|
||||||
|
value = "Camera enable/disable configurations with device IDs") CameraBeanWrapper cameraBeanWrapper);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("device-info")
|
||||||
|
@ApiOperation(
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Requesting Information from Android Devices",
|
||||||
|
notes = "Using this REST API you are able to request for Android device details. Once this REST API is" +
|
||||||
|
" executed it will be in the Android operation queue until the device calls the server to retrieve " +
|
||||||
|
"the list of operations that needs to be executed on the device"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 200, message = "Device Information"),
|
||||||
|
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
||||||
|
})
|
||||||
|
Response getDeviceInformation(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
||||||
|
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "deviceIds",
|
||||||
|
value = "Device IDs to be requested to get device information")
|
||||||
|
List<String> deviceIDs);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("enterprise-wipe")
|
||||||
|
@ApiOperation(
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Enterprise Wiping Android Devices",
|
||||||
|
notes = "Enterprise wipe is the process of deleting enterprise related data on a device while keeping the " +
|
||||||
|
"personal data intact. You are able to enterprise wipe Android devices using this REST API"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 201, message = "Created"),
|
||||||
|
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance"
|
||||||
|
)})
|
||||||
|
Response wipeDevice(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
||||||
|
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "deviceIDs",
|
||||||
|
value = "Device IDs to be requested to done enterprise-wipe")
|
||||||
|
List<String> deviceIDs);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("wipe-data")
|
||||||
|
@ApiOperation(
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Factory Resetting an Android Device",
|
||||||
|
notes = "Factory rest or erases all the data stored in the Android devices " +
|
||||||
|
"to restore them back to the original system"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 201, message = "Created"),
|
||||||
|
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")})
|
||||||
|
Response wipeData(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
||||||
|
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "wipeDataBeanWrapper",
|
||||||
|
value = "Configurations and DeviceIds to be need to done wipe-data")
|
||||||
|
WipeDataBeanWrapper wipeDataBeanWrapper);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("application-list")
|
||||||
|
@ApiOperation(
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Requesting the List of Installed Applications on Android Devices",
|
||||||
|
notes = "Using this REST API the server requests for the list of applications that are installed on" +
|
||||||
|
" the Android devices. Once this REST API is executed it will be in the Android operation queue " +
|
||||||
|
"until the device calls the server to retrieve the list of operations that needs to be executed " +
|
||||||
|
"on the device"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 200, message = "List of applications for specific deviceIdentifier"),
|
||||||
|
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
||||||
|
})
|
||||||
|
Response getApplications(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
||||||
|
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "deviceIDs",
|
||||||
|
value = "Device Ids to be need to get applications which already installed")
|
||||||
|
List<String> deviceIDs);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("ring-device")
|
||||||
|
@ApiOperation(
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Ringing Android Devices",
|
||||||
|
notes = "Ring Android devices"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 201, message = "Created"),
|
||||||
|
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
||||||
|
})
|
||||||
|
Response ringDevice(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
||||||
|
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "deviceIDs",
|
||||||
|
value = "Device Ids needs to be ring") List<String> deviceIDs);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@ApiOperation(
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Muting Android Devices",
|
||||||
|
notes = "Mute Android devices"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 201, message = "Created"),
|
||||||
|
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
||||||
|
})
|
||||||
|
@Path("mute")
|
||||||
|
Response muteDevice(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
||||||
|
@HeaderParam(ACCEPT) String acceptHeader,
|
||||||
|
@ApiParam(name = "deviceIDs", value = "DeviceIDs need to be muted") List<String> deviceIDs);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("install-application")
|
||||||
|
@ApiOperation(
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Installing an Application on Android Devices",
|
||||||
|
notes = "Install an application on an Android device. If the device you are installing the application" +
|
||||||
|
" on has the WSO2 system service installed, the application installation will happen in silent " +
|
||||||
|
"mode, else the device user's consent will be required"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 201, message = "Created"),
|
||||||
|
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
||||||
|
})
|
||||||
|
Response installApplication(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
||||||
|
@HeaderParam(ACCEPT) String acceptHeader,
|
||||||
|
@ApiParam(name = "applicationInstallationBeanWrapper",
|
||||||
|
value = "Properties of installed apps and device IDs")
|
||||||
|
ApplicationInstallationBeanWrapper applicationInstallationBeanWrapper);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("uninstall-application")
|
||||||
|
@ApiOperation(
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Uninstalling an Application from Android Devices",
|
||||||
|
notes = "Uninstall an application from Android devices"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 201, message = "Created"),
|
||||||
|
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
||||||
|
})
|
||||||
|
Response uninstallApplication(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
||||||
|
@HeaderParam(ACCEPT) String acceptHeader,
|
||||||
|
@ApiParam(name = "applicationUninstallationBeanWrapper",
|
||||||
|
value = "applicationUninstallationConfigs and Device Ids")
|
||||||
|
ApplicationUninstallationBeanWrapper applicationUninstallationBeanWrapper);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("blacklist-applications")
|
||||||
|
@ApiOperation(
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Get BlackListed Applications",
|
||||||
|
notes = "Getting BlackListed Applications"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 201, message = "Created"),
|
||||||
|
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
||||||
|
})
|
||||||
|
Response blacklistApplications(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
||||||
|
@HeaderParam(ACCEPT) String acceptHeader,
|
||||||
|
@ApiParam(name = "blacklistApplicationsBeanWrapper",
|
||||||
|
value = "BlacklistApplications Configuration and DeviceIds")
|
||||||
|
BlacklistApplicationsBeanWrapper blacklistApplicationsBeanWrapper);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("notification")
|
||||||
|
@ApiOperation(
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Sending a Notification to Android Devices",
|
||||||
|
notes = "Send a notification to Android devices"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 201, message = "Created"),
|
||||||
|
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
||||||
|
})
|
||||||
|
Response sendNotification(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
||||||
|
@HeaderParam(ACCEPT) String acceptHeader,
|
||||||
|
@ApiParam(name = "notificationBeanWrapper",
|
||||||
|
value = "Notification Configurations and device Ids")
|
||||||
|
NotificationBeanWrapper notificationBeanWrapper);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("wifi")
|
||||||
|
@ApiOperation(
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Configuring Wi-Fi on Android Devices",
|
||||||
|
notes = "Configure Wi-Fi on Android devices"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 201, message = "Created"),
|
||||||
|
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
||||||
|
})
|
||||||
|
Response configureWifi(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
||||||
|
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "wifiBeanWrapper",
|
||||||
|
value = "WifiConfigurations and Device Ids") WifiBeanWrapper wifiBeanWrapper);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("encrypt")
|
||||||
|
@ApiOperation(
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Encrypting Storage on Android Devices",
|
||||||
|
notes = "Encrypt the data stored on Android devices"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 201, message = "Created"),
|
||||||
|
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
||||||
|
})
|
||||||
|
Response encryptStorage(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
||||||
|
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "encryptionBeanWrapper",
|
||||||
|
value = "Configurations and deviceIds need to be done data encryption")
|
||||||
|
EncryptionBeanWrapper encryptionBeanWrapper);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("change-lock-code")
|
||||||
|
@ApiOperation(
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Changing the Lock Code on Android Devices",
|
||||||
|
notes = "Change the lock code on Android devices"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 201, message = "Created"),
|
||||||
|
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
||||||
|
})
|
||||||
|
Response changeLockCode(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
||||||
|
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "lockCodeBeanWrapper",
|
||||||
|
value = "Configurations and device Ids need to be done change lock code")
|
||||||
|
LockCodeBeanWrapper lockCodeBeanWrapper);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("password-policy")
|
||||||
|
@ApiOperation(
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Setting a Passcode Policy on Android Devices",
|
||||||
|
notes = "Set a password policy on Android devices"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 201, message = "created"),
|
||||||
|
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
||||||
|
})
|
||||||
|
Response setPasswordPolicy(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
||||||
|
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "passwordPolicyBeanWrapper",
|
||||||
|
value = "Password Policy Configurations and Device Ids")
|
||||||
|
PasswordPolicyBeanWrapper passwordPolicyBeanWrapper);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("webclip")
|
||||||
|
@ApiOperation(
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Setting a Web Clip on Android Devices",
|
||||||
|
notes = "Set a web clip on Android devices. A web clip is used to add a bookmark to a web application"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 201, message = "Accepted"),
|
||||||
|
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
||||||
|
})
|
||||||
|
Response setWebClip(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
||||||
|
@HeaderParam(ACCEPT) String acceptHeader, @ApiParam(name = "webClipBeanWrapper",
|
||||||
|
value = "Configurations to need set web clip on device and device Ids")
|
||||||
|
WebClipBeanWrapper webClipBeanWrapper);
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("disenroll")
|
||||||
|
@ApiOperation(
|
||||||
|
consumes = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "POST",
|
||||||
|
value = "Un-Register The Device from the EMM server",
|
||||||
|
notes = "unregister the given device"
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 201, message = "Accepted"),
|
||||||
|
@ApiResponse(code = 500, message = "Issue in retrieving device management service instance")
|
||||||
|
})
|
||||||
|
Response setDisenrollment(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
||||||
|
@HeaderParam(ACCEPT) String acceptHeader,
|
||||||
|
@ApiParam(name = "disenrollmentBeanWrapper", value = "Dis-enrollment configurations")
|
||||||
|
DisenrollmentBeanWrapper disenrollmentBeanWrapper);
|
||||||
|
}
|
49
components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/OperationMgtService.java → components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/operationmgt/impl/OperationMgtServiceImpl.java
49
components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/OperationMgtService.java → components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/operationmgt/impl/OperationMgtServiceImpl.java
@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, 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.services.policymgt;
|
||||||
|
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
|
||||||
|
import org.wso2.carbon.mdm.services.android.util.Message;
|
||||||
|
import org.wso2.carbon.policy.mgt.common.ProfileFeature;
|
||||||
|
|
||||||
|
import javax.jws.WebService;
|
||||||
|
import javax.ws.rs.*;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Api("PolicyMgtService")
|
||||||
|
@WebService
|
||||||
|
@Produces({"application/json", "application/xml"})
|
||||||
|
@Consumes({"application/json", "application/xml"})
|
||||||
|
public interface PolicyMgtService {
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("{deviceId}")
|
||||||
|
@ApiOperation(
|
||||||
|
httpMethod = "GET",
|
||||||
|
value = "Identifying whether a Policy is Enforced on an Android Device",
|
||||||
|
notes = "When a device registers with WSO2 EMM, a policy is enforced on the device based on the policy " +
|
||||||
|
"enforcement criteria. Using this API you are able to identify if a specific device has a policy " +
|
||||||
|
"enforced or if no policy is enforced on the device."
|
||||||
|
)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 200, message = "Effective policy added to operation"),
|
||||||
|
@ApiResponse(code = 204, message = "No effective policy found")
|
||||||
|
})
|
||||||
|
Message getEffectivePolicy(@ApiParam(name = "acceptHeader", value = "Accept Header") @HeaderParam("Accept")
|
||||||
|
String acceptHeader,
|
||||||
|
@ApiParam(name = "deviceId", value = "DeviceIdentifier") @PathParam("deviceId")
|
||||||
|
String id) throws AndroidAgentException;
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/features/{deviceId}")
|
||||||
|
@ApiOperation(
|
||||||
|
produces = MediaType.APPLICATION_JSON,
|
||||||
|
httpMethod = "GET",
|
||||||
|
value = "Get Effective Features",
|
||||||
|
responseContainer = "List",
|
||||||
|
notes = "Get already applied features for given device Identifier",
|
||||||
|
response = ProfileFeature.class)
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@ApiResponse(code = 200, message = "Effective Feature List"),
|
||||||
|
@ApiResponse(code = 404, message = "Not Found"),
|
||||||
|
@ApiResponse(code = 500, message = "Error occurred while getting the features")
|
||||||
|
})
|
||||||
|
List<ProfileFeature> getEffectiveFeatures(@ApiParam(name = "acceptHeader", value = "Accept Header")
|
||||||
|
@HeaderParam("Accept") String acceptHeader,
|
||||||
|
@ApiParam(name = "deviceId", value = "DeviceIdentifier")
|
||||||
|
@PathParam("deviceId") String id) throws AndroidAgentException;
|
||||||
|
}
|
17
components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/PolicyMgtService.java → components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/policymgt/impl/PolicyMgtServiceImpl.java
17
components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/PolicyMgtService.java → components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/policymgt/impl/PolicyMgtServiceImpl.java
Loading…
Reference in new issue