From d99765401145bbba1ac88ac17b06fa7976afe26a Mon Sep 17 00:00:00 2001 From: Ace Date: Wed, 10 Aug 2016 12:47:02 +0530 Subject: [PATCH] Adding date validations when updating device enrollment --- .../services/impl/DeviceManagementServiceImpl.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java index 69c0c5def..4dd924859 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/impl/DeviceManagementServiceImpl.java @@ -260,7 +260,16 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { @Override public Response modifyEnrollment(@PathParam("id") String id, @Valid AndroidDevice androidDevice) { Device device = new Device(); + String msg = ""; device.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID); + if(androidDevice.getEnrolmentInfo().getDateOfEnrolment() <= 0){ + msg = "Invalid Enrollment date."; + return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); + } + if(androidDevice.getEnrolmentInfo().getDateOfLastUpdate() <= 0){ + msg = "Invalid Last Updated date."; + return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); + } device.setEnrolmentInfo(androidDevice.getEnrolmentInfo()); device.getEnrolmentInfo().setOwner(AndroidAPIUtils.getAuthenticatedUser()); device.setDeviceInfo(androidDevice.getDeviceInfo());