From d907f1bc512d3c94c6191419ec6c0753172f1421 Mon Sep 17 00:00:00 2001 From: sameera910409 Date: Wed, 22 Mar 2017 19:00:51 +0530 Subject: [PATCH] fix https://wso2.org/jira/browse/EMM-1880 --- .../impl/DeviceManagementAdminServiceImpl.java | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) 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 2349aa3ef..22182b5b1 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 @@ -72,6 +72,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.io.IOException; +import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; @@ -1018,22 +1019,11 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe } } - private static boolean hasValidAPKContentType(String contentType){ - if (contentType != null){ - switch (contentType) { - case MediaType.APPLICATION_OCTET_STREAM: - case "application/android": - return true; - } - } - return false; - } - private static void validateApplicationUrl(String apkUrl) { try { URL url = new URL(apkUrl); URLConnection conn = url.openConnection(); - if (!hasValidAPKContentType(conn.getContentType())) { + if(((HttpURLConnection) conn).getResponseCode() != HttpURLConnection.HTTP_OK) { String errorMessage = "URL is not pointed to a downloadable file."; log.error(errorMessage); throw new BadRequestException(