Some logs added and 404 not found status support added
This commit is contained in:
parent
9335a80b5a
commit
41ffb26bcd
|
@ -2,6 +2,7 @@ package org.gcube.oidc.rest;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
@ -195,7 +196,8 @@ public class OpenIdConnectRESTHelper {
|
||||||
params.put("client_id", Arrays.asList(URLEncoder.encode(clientId, "UTF-8")));
|
params.put("client_id", Arrays.asList(URLEncoder.encode(clientId, "UTF-8")));
|
||||||
params.put("refresh_token", Arrays.asList(token.getRefreshTokenString()));
|
params.put("refresh_token", Arrays.asList(token.getRefreshTokenString()));
|
||||||
logger.info("Performing logut from OIDC server with URL: " + logoutUrl);
|
logger.info("Performing logut from OIDC server with URL: " + logoutUrl);
|
||||||
HttpURLConnection httpURLConnection = performURLEncodedPOSTSendData(logoutUrl, params, token.getAccessTokenAsBearer());
|
HttpURLConnection httpURLConnection = performURLEncodedPOSTSendData(logoutUrl, params,
|
||||||
|
token.getAccessTokenAsBearer());
|
||||||
int responseCode = httpURLConnection.getResponseCode();
|
int responseCode = httpURLConnection.getResponseCode();
|
||||||
if (responseCode == 204) {
|
if (responseCode == 204) {
|
||||||
logger.info("Logout performed correctly");
|
logger.info("Logout performed correctly");
|
||||||
|
@ -223,7 +225,11 @@ public class OpenIdConnectRESTHelper {
|
||||||
logger.debug("Adding authorization header as: {}", authorization);
|
logger.debug("Adding authorization header as: {}", authorization);
|
||||||
conn.setRequestProperty("Authorization", authorization);
|
conn.setRequestProperty("Authorization", authorization);
|
||||||
}
|
}
|
||||||
logger.debug("Getting the resource opening the stream");
|
String contentType = conn.getContentType();
|
||||||
|
int contentLenght = conn.getContentLength();
|
||||||
|
|
||||||
|
logger.debug("Getting the stream to a %d bytes lenght resource with MIME: %s", contentLenght, contentType);
|
||||||
|
|
||||||
InputStream is = conn.getInputStream();
|
InputStream is = conn.getInputStream();
|
||||||
buffer = new ByteArrayOutputStream();
|
buffer = new ByteArrayOutputStream();
|
||||||
int nRead;
|
int nRead;
|
||||||
|
@ -234,8 +240,10 @@ public class OpenIdConnectRESTHelper {
|
||||||
|
|
||||||
buffer.flush();
|
buffer.flush();
|
||||||
return buffer.toByteArray();
|
return buffer.toByteArray();
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
logger.debug("User's avatar not found");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.debug("Can't download avatar", e);
|
logger.warn("Downloading user's avatar", e);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue