From 07c7f2b6ff44ab6d707eaa1451b30550368301a8 Mon Sep 17 00:00:00 2001 From: charitha Date: Wed, 7 Sep 2016 08:10:35 +0530 Subject: [PATCH] Add validation to APK type (cherry picked from commit 9da85ad) --- .../impl/DeviceManagementAdminServiceImpl.java | 16 ++++++++++++++++ 1 file changed, 16 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/DeviceManagementAdminServiceImpl.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/DeviceManagementAdminServiceImpl.java index c383304a52..8442d44c7d 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/DeviceManagementAdminServiceImpl.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/DeviceManagementAdminServiceImpl.java @@ -558,6 +558,22 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe throw new BadRequestException( new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); } + if (payload.has("type")) { + String type = payload.getString("type"); + if (!"enterprise".equalsIgnoreCase(type) + && !"public".equalsIgnoreCase(type) + && !"webapp".equalsIgnoreCase(type)) { + String errorMessage = "Invalid application type."; + log.error(errorMessage); + throw new BadRequestException( + new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); + } + } else { + String errorMessage = "Application type is missing."; + log.error(errorMessage); + throw new BadRequestException( + new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); + } } catch (MalformedURLException e) { String errorMessage = "Malformed application url."; log.error(errorMessage);