Request method declaration fixed and some logs added

This commit is contained in:
Mauro Mugnaini 2020-06-26 18:09:36 +02:00
parent 35cf56a086
commit db882bd0bf
1 changed files with 8 additions and 2 deletions

View File

@ -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"));