sameera910409 8 years ago
parent 2049e44319
commit d907f1bc51

@ -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(

Loading…
Cancel
Save