From db882bd0bf115966634e1f370dc19487a9c747aa Mon Sep 17 00:00:00 2001 From: Mauro Mugnaini Date: Fri, 26 Jun 2020 18:09:36 +0200 Subject: [PATCH] Request method declaration fixed and some logs added --- .../org/gcube/oidc/rest/OpenIdConnectRESTHelper.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/gcube/oidc/rest/OpenIdConnectRESTHelper.java b/src/main/java/org/gcube/oidc/rest/OpenIdConnectRESTHelper.java index 274666c..0220c28 100644 --- a/src/main/java/org/gcube/oidc/rest/OpenIdConnectRESTHelper.java +++ b/src/main/java/org/gcube/oidc/rest/OpenIdConnectRESTHelper.java @@ -73,15 +73,21 @@ public class OpenIdConnectRESTHelper { logger.debug("Querying access token from OIDC server with URL: " + tokenURL); } HttpURLConnection con = (HttpURLConnection) tokenURL.openConnection(); + con.setRequestMethod("POST"); con.setDoOutput(true); con.setDoInput(true); con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); con.setRequestProperty("Accept", "application/json"); - con.setRequestProperty("Method", "POST"); if (authorization != null) { + if (logger.isDebugEnabled()) { + logger.debug("Adding auhotization header as: " + authorization); + } con.setRequestProperty("Authorization", authorization); } OutputStream os = con.getOutputStream(); + if (logger.isDebugEnabled()) { + logger.debug("Sending parameters: " + params); + } os.write(mapToQueryString(params).getBytes("UTF-8")); os.close(); @@ -134,11 +140,11 @@ public class OpenIdConnectRESTHelper { params.put("refresh_token", Arrays.asList(token.getRefreshTokenString())); logger.info("Performing logut from OIDC server with URL: " + logoutUrl); HttpURLConnection con = (HttpURLConnection) logoutUrl.openConnection(); + con.setRequestMethod("POST"); con.setDoOutput(true); con.setDoInput(true); con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); con.setRequestProperty("Accept", "application/json"); - con.setRequestProperty("Method", "POST"); con.setRequestProperty("Authorization", token.getAsBearer()); OutputStream os = con.getOutputStream(); os.write(mapToQueryString(params).getBytes("UTF-8"));