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(