Added some log message to better debug and remove the exception raise
This commit is contained in:
parent
da8ed52808
commit
bb3728c421
|
@ -206,7 +206,10 @@ public class OpenIdConnectRESTHelper {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] getUserAvatar(URL avatarURL, JWTToken token) throws Exception {
|
public static byte[] getUserAvatar(URL avatarURL, JWTToken token) {
|
||||||
|
logger.debug("Getting user avatar from URL: {}", avatarURL);
|
||||||
|
ByteArrayOutputStream buffer;
|
||||||
|
try {
|
||||||
HttpURLConnection conn = (HttpURLConnection) avatarURL.openConnection();
|
HttpURLConnection conn = (HttpURLConnection) avatarURL.openConnection();
|
||||||
conn.setRequestMethod("GET");
|
conn.setRequestMethod("GET");
|
||||||
conn.setDoOutput(false);
|
conn.setDoOutput(false);
|
||||||
|
@ -217,8 +220,9 @@ 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");
|
||||||
InputStream is = conn.getInputStream();
|
InputStream is = conn.getInputStream();
|
||||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
buffer = new ByteArrayOutputStream();
|
||||||
int nRead;
|
int nRead;
|
||||||
byte[] data = new byte[1024];
|
byte[] data = new byte[1024];
|
||||||
while ((nRead = is.read(data, 0, data.length)) != -1) {
|
while ((nRead = is.read(data, 0, data.length)) != -1) {
|
||||||
|
@ -227,5 +231,9 @@ public class OpenIdConnectRESTHelper {
|
||||||
|
|
||||||
buffer.flush();
|
buffer.flush();
|
||||||
return buffer.toByteArray();
|
return buffer.toByteArray();
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.debug("Can't download avatar", e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue