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