[java-idp-oidc] 02/02: JOIDC-168 - CheckRedirectURIs HTTP resource leak
Henri Mikkonen
henri.mikkonen at iki.fi
Tue Aug 29 12:26:23 UTC 2023
This is an automated email from the git hooks/post-receive script.
hjmikkon pushed a commit to branch main
in repository java-idp-oidc.
View the commit online:
http://git.shibboleth.net/view/?p=java-idp-oidc.git;a=commit;h=392ee011f14f330039ffd59742a48cfbce65a1e5
commit 392ee011f14f330039ffd59742a48cfbce65a1e5
Author: Henri Mikkonen <henri.mikkonen at iki.fi>
AuthorDate: Tue Aug 29 15:22:47 2023 +0300
JOIDC-168 - CheckRedirectURIs HTTP resource leak
https://shibboleth.atlassian.net/browse/JOIDC-168
---
.../oidc/op/profile/impl/CheckRedirectURIs.java | 36 ++++++++++------------
1 file changed, 17 insertions(+), 19 deletions(-)
diff --git a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/CheckRedirectURIs.java b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/CheckRedirectURIs.java
index d9f3f398..4e66a1e8 100644
--- a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/CheckRedirectURIs.java
+++ b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/profile/impl/CheckRedirectURIs.java
@@ -16,7 +16,9 @@ package net.shibboleth.idp.plugin.oidc.op.profile.impl;
import java.io.IOException;
import java.net.URI;
+import java.net.URISyntaxException;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import java.util.Set;
@@ -237,35 +239,31 @@ public class CheckRedirectURIs extends AbstractProfileAction {
* fetched.
*/
protected boolean verifySectorIdUri(final URI sectorIdUri, final Set<URI> redirectURIs) {
- final ClassicHttpResponse response;
- try {
- final ClassicHttpRequest get = ClassicRequestBuilder.get().setUri(sectorIdUri).build();
- final HttpClientContext clientContext = HttpClientContext.create();
- HttpClientSecuritySupport.marshalSecurityParameters(clientContext, httpClientSecurityParameters, true);
- HttpClientSecuritySupport.addDefaultTLSTrustEngineCriteria(clientContext, get);
- response = httpClient.executeOpen(null, get, clientContext);
+ final ClassicHttpRequest get = ClassicRequestBuilder.get().setUri(sectorIdUri).build();
+ final HttpClientContext clientContext = HttpClientContext.create();
+ HttpClientSecuritySupport.marshalSecurityParameters(clientContext, httpClientSecurityParameters, true);
+ HttpClientSecuritySupport.addDefaultTLSTrustEngineCriteria(clientContext, get);
+
+ final String output;
+ try (final ClassicHttpResponse response = httpClient.executeOpen(null, get, clientContext)) {
HttpClientSecuritySupport.checkTLSCredentialEvaluated(clientContext, get.getUri().getScheme());
- } catch (final Exception e) {
+ if (response == null) {
+ log.error("{} Could not get the sector_identifier_uri contents from {}", getLogPrefix(), sectorIdUri);
+ return false;
+ }
+ output = EntityUtils.toString(response.getEntity(), "UTF-8");
+ } catch (final URISyntaxException e) {
log.error("{} Could not get the sector_identifier_uri contents from {}", getLogPrefix(), sectorIdUri, e);
return false;
- }
- if (response == null) {
- log.error("{} Could not get the sector_identifier_uri contents from {}", getLogPrefix(), sectorIdUri);
- return false;
- }
- final String output;
- try {
- output = EntityUtils.toString(response.getEntity(), "UTF-8");
} catch (final ParseException | IOException e) {
log.error("{} Could not parse the sector_identifier_uri contents from {}", getLogPrefix(), sectorIdUri);
return false;
- } finally {
- EntityUtils.consumeQuietly(response.getEntity());
}
log.trace("{} Fetched the following response body: {}", getLogPrefix(), output);
final List<URI> parsedUris;
try {
- parsedUris = Arrays.asList(objectMapper.readValue(output, URI[].class));
+ parsedUris = output == null ? Collections.emptyList() : Arrays.asList(objectMapper.readValue(output,
+ URI[].class));
} catch (final JsonProcessingException e) {
log.error("{} Could not parse the sector_identifier_uri contents from {}", getLogPrefix(), sectorIdUri, e);
return false;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list