Fixed url creation for jdk8

This commit is contained in:
Giancarlo Panichi 2024-10-28 10:58:06 +01:00
parent 231f741513
commit 7518881a75
1 changed files with 29 additions and 17 deletions

View File

@ -77,7 +77,7 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
StringBuilder callUrl = new StringBuilder(getInternalEnpoint(infrastructureHash)).append(methodPath); StringBuilder callUrl = new StringBuilder(getInternalEnpoint(infrastructureHash)).append(methodPath);
URL url = new URL(callUrl.toString()); URL url = new URL(null, callUrl.toString(), new sun.net.www.protocol.https.Handler());
HttpURLConnection connection = makeRequest(url, "PUT", true); HttpURLConnection connection = makeRequest(url, "PUT", true);
connection.setDoOutput(true); connection.setDoOutput(true);
connection.setDoInput(true); connection.setDoInput(true);
@ -118,7 +118,7 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
List<String> realTokens = containerTokens.stream().map(t -> Utils.getRealToken(t)).collect(Collectors.toList()); List<String> realTokens = containerTokens.stream().map(t -> Utils.getRealToken(t)).collect(Collectors.toList());
URL url = new URL(callUrl.toString()); URL url = new URL(null, callUrl.toString(), new sun.net.www.protocol.https.Handler());
HttpURLConnection connection = makeRequest(url, "PUT", true); HttpURLConnection connection = makeRequest(url, "PUT", true);
connection.setDoOutput(true); connection.setDoOutput(true);
connection.setDoInput(true); connection.setDoInput(true);
@ -153,7 +153,8 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
StringBuilder callUrl = new StringBuilder(getInternalEnpoint(infrastructureHash)).append(methodPath).append(serviceId); StringBuilder callUrl = new StringBuilder(getInternalEnpoint(infrastructureHash)).append(methodPath).append(serviceId);
URL url = new URL(callUrl.toString()); URL url = new URL(null, callUrl.toString(), new sun.net.www.protocol.https.Handler());
HttpURLConnection connection = makeRequest(url, "PUT", true); HttpURLConnection connection = makeRequest(url, "PUT", true);
connection.setDoInput(true); connection.setDoInput(true);
connection.setRequestProperty("Content-type", "application/xml"); connection.setRequestProperty("Content-type", "application/xml");
@ -182,7 +183,6 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
StringBuilder callUrl = new StringBuilder(getInternalEnpoint(infrastructureHash)).append(methodPath).append(user).append("?context=").append(context); StringBuilder callUrl = new StringBuilder(getInternalEnpoint(infrastructureHash)).append(methodPath).append(user).append("?context=").append(context);
//URL url = new URL(callUrl.toString());
URL url = new URL(null, callUrl.toString(), new sun.net.www.protocol.https.Handler()); URL url = new URL(null, callUrl.toString(), new sun.net.www.protocol.https.Handler());
HttpURLConnection connection = makeRequest(url, "GET", false); HttpURLConnection connection = makeRequest(url, "GET", false);
@ -214,7 +214,8 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
StringBuilder callUrl = new StringBuilder(getInternalEnpoint(infrastructureHash)).append(methodPath).append("?") StringBuilder callUrl = new StringBuilder(getInternalEnpoint(infrastructureHash)).append(methodPath).append("?")
.append(CONTEXT_PARAM).append("=").append(context); .append(CONTEXT_PARAM).append("=").append(context);
URL url = new URL(callUrl.toString()); URL url = new URL(null, callUrl.toString(), new sun.net.www.protocol.https.Handler());
HttpURLConnection connection = makeRequest(url, "PUT", false); HttpURLConnection connection = makeRequest(url, "PUT", false);
connection.setDoOutput(true); connection.setDoOutput(true);
connection.setDoInput(true); connection.setDoInput(true);
@ -275,7 +276,8 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
StringBuilder callUrl = new StringBuilder(getInternalEnpoint(infrastructureHash)).append(methodPath).append("?") StringBuilder callUrl = new StringBuilder(getInternalEnpoint(infrastructureHash)).append(methodPath).append("?")
.append(CONTEXT_PARAM).append("=").append(context).append("&").append(CLIENT_ID_PARAM).append("=").append(clientId); .append(CONTEXT_PARAM).append("=").append(context).append("&").append(CLIENT_ID_PARAM).append("=").append(clientId);
URL url = new URL(callUrl.toString()); URL url = new URL(null, callUrl.toString(), new sun.net.www.protocol.https.Handler());
HttpURLConnection connection = makeRequest(url, "DELETE", false); HttpURLConnection connection = makeRequest(url, "DELETE", false);
//connection.setDoOutput(false); //connection.setDoOutput(false);
connection.setDoInput(true); connection.setDoInput(true);
@ -297,7 +299,8 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
StringBuilder callUrl = new StringBuilder(getInternalEnpoint(infrastructureHash)).append(methodPath); StringBuilder callUrl = new StringBuilder(getInternalEnpoint(infrastructureHash)).append(methodPath);
URL url = new URL(callUrl.toString()); URL url = new URL(null, callUrl.toString(), new sun.net.www.protocol.https.Handler());
HttpURLConnection connection = makeRequest(url, "PUT", true); HttpURLConnection connection = makeRequest(url, "PUT", true);
connection.setDoInput(true); connection.setDoInput(true);
connection.setDoOutput(true); connection.setDoOutput(true);
@ -332,7 +335,8 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
StringBuilder callUrl = new StringBuilder(getInternalEnpoint(infrastructureHash)).append(methodPath); StringBuilder callUrl = new StringBuilder(getInternalEnpoint(infrastructureHash)).append(methodPath);
URL url = new URL(callUrl.toString()); URL url = new URL(null, callUrl.toString(), new sun.net.www.protocol.https.Handler());
HttpURLConnection connection = makeRequest(url, "GET", true); HttpURLConnection connection = makeRequest(url, "GET", true);
connection.setDoInput(true); connection.setDoInput(true);
connection.setDoOutput(true); connection.setDoOutput(true);
@ -367,7 +371,8 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
StringBuilder callUrl = new StringBuilder(getInternalEnpoint(infrastructureHash)).append(methodPath); StringBuilder callUrl = new StringBuilder(getInternalEnpoint(infrastructureHash)).append(methodPath);
URL url = new URL(callUrl.toString()); URL url = new URL(null, callUrl.toString(), new sun.net.www.protocol.https.Handler());
HttpURLConnection connection = makeRequest(url, "GET", true); HttpURLConnection connection = makeRequest(url, "GET", true);
connection.setDoInput(true); connection.setDoInput(true);
connection.setDoOutput(true); connection.setDoOutput(true);
@ -401,7 +406,8 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
callUrl = new StringBuilder(getInternalEnpoint(infrastructureHash)).append(methodPath).append("?context=").append(context); callUrl = new StringBuilder(getInternalEnpoint(infrastructureHash)).append(methodPath).append("?context=").append(context);
URL url = new URL(callUrl.toString()); URL url = new URL(null, callUrl.toString(), new sun.net.www.protocol.https.Handler());
HttpURLConnection connection = makeRequest(url, "PUT", false); HttpURLConnection connection = makeRequest(url, "PUT", false);
connection.setDoOutput(true); connection.setDoOutput(true);
connection.setDoInput(true); connection.setDoInput(true);
@ -437,7 +443,8 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
callUrl = new StringBuilder(getInternalEnpoint(infrastructureHash)).append(methodPath); callUrl = new StringBuilder(getInternalEnpoint(infrastructureHash)).append(methodPath);
URL url = new URL(callUrl.toString()); URL url = new URL(null, callUrl.toString(), new sun.net.www.protocol.https.Handler());
HttpURLConnection connection = makeRequest(url, "PUT", true); HttpURLConnection connection = makeRequest(url, "PUT", true);
connection.setDoOutput(true); connection.setDoOutput(true);
connection.setDoInput(true); connection.setDoInput(true);
@ -479,7 +486,8 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
StringBuilder callUrl = new StringBuilder(getInternalEnpoint(infrastructureHashFromToken)) StringBuilder callUrl = new StringBuilder(getInternalEnpoint(infrastructureHashFromToken))
.append(methodPath).append(realToken); .append(methodPath).append(realToken);
URL url = new URL(callUrl.toString()); URL url = new URL(null, callUrl.toString(), new sun.net.www.protocol.https.Handler());
HttpURLConnection connection = makeRequest(url, "GET", false); HttpURLConnection connection = makeRequest(url, "GET", false);
connection.setDoInput(true); connection.setDoInput(true);
@ -530,7 +538,8 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
} }
URL url = new URL(callUrl.toString()); URL url = new URL(null, callUrl.toString(), new sun.net.www.protocol.https.Handler());
HttpURLConnection connection = makeRequest(url, "GET", false); HttpURLConnection connection = makeRequest(url, "GET", false);
connection.setDoInput(true); connection.setDoInput(true);
@ -551,7 +560,8 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
StringBuilder callUrl = new StringBuilder(getInternalEnpoint(Utils.getInfrastructureHashFromToken(SecurityTokenProvider.instance.get(), endpoints.getDefaultInfrastructure()))).append(methodPath); StringBuilder callUrl = new StringBuilder(getInternalEnpoint(Utils.getInfrastructureHashFromToken(SecurityTokenProvider.instance.get(), endpoints.getDefaultInfrastructure()))).append(methodPath);
URL url = new URL(callUrl.toString()); URL url = new URL(null, callUrl.toString(), new sun.net.www.protocol.https.Handler());
HttpURLConnection connection = makeRequest(url, "POST", true); HttpURLConnection connection = makeRequest(url, "POST", true);
connection.setDoOutput(true); connection.setDoOutput(true);
connection.setRequestProperty("Content-type", "application/xml"); connection.setRequestProperty("Content-type", "application/xml");
@ -570,7 +580,7 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
StringBuilder callUrl = new StringBuilder(getInternalEnpoint(Utils.getInfrastructureHashFromToken(SecurityTokenProvider.instance.get(), endpoints.getDefaultInfrastructure()))).append(methodPath); StringBuilder callUrl = new StringBuilder(getInternalEnpoint(Utils.getInfrastructureHashFromToken(SecurityTokenProvider.instance.get(), endpoints.getDefaultInfrastructure()))).append(methodPath);
List<Long> errorIds = new ArrayList<Long>(); List<Long> errorIds = new ArrayList<Long>();
for (long id: ids){ for (long id: ids){
URL url = new URL(callUrl.toString()+id); URL url = new URL(null, callUrl.toString()+id, new sun.net.www.protocol.https.Handler());
HttpURLConnection connection = makeRequest(url, "DELETE", true); HttpURLConnection connection = makeRequest(url, "DELETE", true);
if (connection.getResponseCode()!=200) errorIds.add(id); if (connection.getResponseCode()!=200) errorIds.add(id);
} }
@ -584,7 +594,8 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
StringBuilder callUrl = new StringBuilder(getInternalEnpoint(Utils.getInfrastructureHashfromContext(context))).append(methodPath).append("?").append(CONTEXT_PARAM).append("=").append(context); StringBuilder callUrl = new StringBuilder(getInternalEnpoint(Utils.getInfrastructureHashfromContext(context))).append(methodPath).append("?").append(CONTEXT_PARAM).append("=").append(context);
URL url = new URL(callUrl.toString()); URL url = new URL(null, callUrl.toString(), new sun.net.www.protocol.https.Handler());
HttpURLConnection connection = makeRequest(url, "GET", true); HttpURLConnection connection = makeRequest(url, "GET", true);
connection.setDoInput(true); connection.setDoInput(true);
if (connection.getResponseCode()!=200){ if (connection.getResponseCode()!=200){
@ -608,7 +619,8 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
StringBuilder callUrl = new StringBuilder(getInternalEnpoint(Utils.getInfrastructureHashFromToken(SecurityTokenProvider.instance.get(), endpoints.getDefaultInfrastructure()))) StringBuilder callUrl = new StringBuilder(getInternalEnpoint(Utils.getInfrastructureHashFromToken(SecurityTokenProvider.instance.get(), endpoints.getDefaultInfrastructure())))
.append(methodPath); .append(methodPath);
URL url = new URL(callUrl.toString()); URL url = new URL(null, callUrl.toString(), new sun.net.www.protocol.https.Handler());
HttpURLConnection connection = makeRequest(url, "GET", true); HttpURLConnection connection = makeRequest(url, "GET", true);
connection.setDoInput(true); connection.setDoInput(true);
if (connection.getResponseCode()!=200) throw new Exception("error retrieving key"); if (connection.getResponseCode()!=200) throw new Exception("error retrieving key");