|
|
|
@ -42,11 +42,11 @@ public class Enrollment {
|
|
|
|
|
private static Log log = LogFactory.getLog(Enrollment.class);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Request Format : {"deviceIdentifier":"macid","description":"ww","ownership":"ww",
|
|
|
|
|
* "properties":[{"name":"username","value":"ww"},{"name":"device","value":"ww"},
|
|
|
|
|
* {"name":"imei","value":"imei"},{"name":"imsi","value":"imsi"},{"name":"model","value":"mi3"},
|
|
|
|
|
* {"name":"regId","value":"regid"},{"name":"vendor","value":"vendor"},
|
|
|
|
|
* {"name":"osVersion","value":"Lolipop"}]}
|
|
|
|
|
* Request Format : {"deviceIdentifier":"macid","description":"description","ownership":"BYOD",
|
|
|
|
|
* "properties":[{"name":"username","value":"harshan"},{"name":"device","value":"Harshan S5"},
|
|
|
|
|
* {"name":"imei","value":"356938035643809"},{"name":"imsi","value":"404685505601234"},{"name":"model","value":"Galaxy S5"},
|
|
|
|
|
* {"name":"regId","value":"02fab24b2242"},{"name":"vendor","value":"Samsung"},
|
|
|
|
|
* {"name":"osVersion","value":"5.0.0"}]}
|
|
|
|
|
*
|
|
|
|
|
**/
|
|
|
|
|
@POST
|
|
|
|
@ -66,14 +66,16 @@ public class Enrollment {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
if (dmService != null) {
|
|
|
|
|
device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
|
|
|
|
device.setType(
|
|
|
|
|
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
|
|
|
|
result = dmService.enrollDevice(device);
|
|
|
|
|
Response.status(HttpStatus.SC_CREATED);
|
|
|
|
|
responseMsg.setResponseMessage("Device enrollment has succeeded");
|
|
|
|
|
return responseMsg;
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
responseMsg.setResponseMessage(AndroidConstants.Messages.DEVICE_MANAGER_SERVICE_NOT_AVAILABLE);
|
|
|
|
|
responseMsg.setResponseMessage(
|
|
|
|
|
AndroidConstants.Messages.DEVICE_MANAGER_SERVICE_NOT_AVAILABLE);
|
|
|
|
|
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
|
|
|
|
return responseMsg;
|
|
|
|
|
}
|
|
|
|
@ -106,20 +108,20 @@ public class Enrollment {
|
|
|
|
|
result = dmService.isEnrolled(deviceIdentifier);
|
|
|
|
|
if (result) {
|
|
|
|
|
Response.status(HttpStatus.SC_OK);
|
|
|
|
|
responseMsg.setResponseMessage("Device already enroll");
|
|
|
|
|
responseMsg.setResponseMessage("Device has already enrolled");
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
Response.status(HttpStatus.SC_NOT_FOUND);
|
|
|
|
|
responseMsg.setResponseMessage("Device not enroll");
|
|
|
|
|
responseMsg.setResponseMessage("Device has not enrolled");
|
|
|
|
|
}
|
|
|
|
|
return responseMsg;
|
|
|
|
|
} else {
|
|
|
|
|
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
|
|
|
|
responseMsg.setResponseMessage(AndroidConstants.Messages.DEVICE_MANAGER_SERVICE_NOT_AVAILABLE);
|
|
|
|
|
responseMsg.setResponseMessage(
|
|
|
|
|
AndroidConstants.Messages.DEVICE_MANAGER_SERVICE_NOT_AVAILABLE);
|
|
|
|
|
return responseMsg;
|
|
|
|
|
}
|
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
msg = "Error occurred while checking enrollment of the device";
|
|
|
|
|
msg = "Error occurred while checking the enrollment of the device.";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
responseMsg.setResponseMessage(msg);
|
|
|
|
|
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
|
|
|
@ -128,6 +130,14 @@ public class Enrollment {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Request Format : {"deviceIdentifier":"macid","description":"description","ownership":"BYOD",
|
|
|
|
|
* "properties":[{"name":"username","value":"harshan"},{"name":"device","value":"Harshan S5"},
|
|
|
|
|
* {"name":"imei","value":"356938035643809"},{"name":"imsi","value":"404685505601234"},{"name":"model","value":"Galaxy S5"},
|
|
|
|
|
* {"name":"regId","value":"02fab24b2242"},{"name":"vendor","value":"Samsung"},
|
|
|
|
|
* {"name":"osVersion","value":"5.0.0"}]}
|
|
|
|
|
*
|
|
|
|
|
**/
|
|
|
|
|
@PUT
|
|
|
|
|
@Path("{id}")
|
|
|
|
|
public Message modifyEnrollment(@PathParam("id") String id, Device device) {
|
|
|
|
@ -144,10 +154,12 @@ public class Enrollment {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
if (dmService != null) {
|
|
|
|
|
device.setType(
|
|
|
|
|
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
|
|
|
|
result = dmService.modifyEnrollment(device);
|
|
|
|
|
|
|
|
|
|
if (result) {
|
|
|
|
|
responseMsg.setResponseMessage("update device");
|
|
|
|
|
responseMsg.setResponseMessage("Device enrollment has updated successfully");
|
|
|
|
|
Response.status(HttpStatus.SC_OK);
|
|
|
|
|
} else {
|
|
|
|
|
responseMsg.setResponseMessage("Update enrollment has failed");
|
|
|
|
@ -178,7 +190,6 @@ public class Enrollment {
|
|
|
|
|
DeviceManagementService dmService;
|
|
|
|
|
Message responseMsg = new Message();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
dmService = AndroidAPIUtils.getDeviceManagementService();
|
|
|
|
|
} finally {
|
|
|
|
@ -189,7 +200,7 @@ public class Enrollment {
|
|
|
|
|
if (dmService != null) {
|
|
|
|
|
result = dmService.disenrollDevice(deviceIdentifier);
|
|
|
|
|
if (result) {
|
|
|
|
|
responseMsg.setResponseMessage("Dis enrolled device");
|
|
|
|
|
responseMsg.setResponseMessage("Device has disenrolled successfully");
|
|
|
|
|
Response.status(HttpStatus.SC_OK);
|
|
|
|
|
} else {
|
|
|
|
|
responseMsg.setResponseMessage("Device not found");
|
|
|
|
|