Use proxy authenticator on Keycloak Settings retrieval;

7.20.x
Max Shaposhnik 2020-07-10 13:55:51 +03:00 committed by GitHub
parent 3ceb16245f
commit 5d51b28d83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -44,6 +44,7 @@ import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.eclipse.che.commons.annotation.Nullable;
import org.eclipse.che.commons.proxy.ProxyAuthenticator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -90,11 +91,9 @@ public class KeycloakSettings {
LOG.info("Retrieving OpenId configuration from endpoint: {}", wellKnownEndpoint);
URL url;
Map<String, Object> openIdConfiguration;
try {
url = new URL(wellKnownEndpoint);
final InputStream inputStream = url.openStream();
ProxyAuthenticator.initAuthenticator(wellKnownEndpoint);
try (InputStream inputStream = new URL(wellKnownEndpoint).openStream()) {
final JsonFactory factory = new JsonFactory();
final JsonParser parser = factory.createParser(inputStream);
final TypeReference<Map<String, Object>> typeReference =
@ -103,6 +102,8 @@ public class KeycloakSettings {
} catch (IOException e) {
throw new RuntimeException(
"Exception while retrieving OpenId configuration from endpoint: " + wellKnownEndpoint, e);
} finally {
ProxyAuthenticator.resetAuthenticator();
}
LOG.info("openid configuration = {}", openIdConfiguration);