KEYCLOAK-8008 Ensure InputStream are closed

This commit is contained in:
mposolda 2018-09-25 21:59:24 +02:00 committed by Hynek Mlnařík
parent e1ecf94428
commit 4b9b189016
2 changed files with 8 additions and 6 deletions

View file

@ -68,11 +68,12 @@ public class AuthorizationEndpointRequestParserProcessor {
if (requestParam != null) { if (requestParam != null) {
new AuthzEndpointRequestObjectParser(session, requestParam, client).parseRequest(request); new AuthzEndpointRequestObjectParser(session, requestParam, client).parseRequest(request);
} else if (requestUriParam != null) { } else if (requestUriParam != null) {
InputStream is = session.getProvider(HttpClientProvider.class).get(requestUriParam); try (InputStream is = session.getProvider(HttpClientProvider.class).get(requestUriParam)) {
String retrievedRequest = StreamUtil.readString(is); String retrievedRequest = StreamUtil.readString(is);
new AuthzEndpointRequestObjectParser(session, retrievedRequest, client).parseRequest(request); new AuthzEndpointRequestObjectParser(session, retrievedRequest, client).parseRequest(request);
} }
}
return request; return request;

View file

@ -36,8 +36,9 @@ import java.security.PublicKey;
public class JWKSHttpUtils { public class JWKSHttpUtils {
public static JSONWebKeySet sendJwksRequest(KeycloakSession session, String jwksURI) throws IOException { public static JSONWebKeySet sendJwksRequest(KeycloakSession session, String jwksURI) throws IOException {
InputStream is = session.getProvider(HttpClientProvider.class).get(jwksURI); try (InputStream is = session.getProvider(HttpClientProvider.class).get(jwksURI)){
String keySetString = StreamUtil.readString(is); String keySetString = StreamUtil.readString(is);
return JsonSerialization.readValue(keySetString, JSONWebKeySet.class); return JsonSerialization.readValue(keySetString, JSONWebKeySet.class);
} }
}
} }