From c946a84b09cdf502f42b330b00a4c4146fca5098 Mon Sep 17 00:00:00 2001 From: Justin Richer Date: Tue, 15 Jan 2013 11:58:30 -0500 Subject: [PATCH] adapted keyfetcher to be more general --- .../connect/client/AbstractOIDCAuthenticationFilter.java | 4 ++-- .../src/main/java/org/mitre/key/fetch/KeyFetcher.java | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/openid-connect-client/src/main/java/org/mitre/openid/connect/client/AbstractOIDCAuthenticationFilter.java b/openid-connect-client/src/main/java/org/mitre/openid/connect/client/AbstractOIDCAuthenticationFilter.java index 076a75864..cb4d75ce7 100644 --- a/openid-connect-client/src/main/java/org/mitre/openid/connect/client/AbstractOIDCAuthenticationFilter.java +++ b/openid-connect-client/src/main/java/org/mitre/openid/connect/client/AbstractOIDCAuthenticationFilter.java @@ -608,10 +608,10 @@ public class AbstractOIDCAuthenticationFilter extends if (serverConfig.getJwkSigningUrl() != null) { // prefer the JWK - signingKey = keyFetch.retrieveJwkKey(serverConfig); + signingKey = keyFetch.retrieveJwkKey(serverConfig.getJwkSigningUrl()); } else if (serverConfig.getX509SigningUrl() != null) { // use the x509 only if JWK isn't configured - signingKey = keyFetch.retrieveX509Key(serverConfig); + signingKey = keyFetch.retrieveX509Key(serverConfig.getX509SigningUrl()); } else { // no keys configured logger.warn("No server key URLs configured for " + serverConfig.getIssuer()); diff --git a/openid-connect-common/src/main/java/org/mitre/key/fetch/KeyFetcher.java b/openid-connect-common/src/main/java/org/mitre/key/fetch/KeyFetcher.java index 45cf39d15..62d65037e 100644 --- a/openid-connect-common/src/main/java/org/mitre/key/fetch/KeyFetcher.java +++ b/openid-connect-common/src/main/java/org/mitre/key/fetch/KeyFetcher.java @@ -54,13 +54,13 @@ public class KeyFetcher { return getArray; } - public PublicKey retrieveX509Key(OIDCServerConfiguration serverConfig) { + public PublicKey retrieveX509Key(String x509url) { PublicKey key = null; try { - InputStream x509Stream = restTemplate.getForObject(serverConfig.getX509SigningUrl(), InputStream.class); + InputStream x509Stream = restTemplate.getForObject(x509url, InputStream.class); CertificateFactory factory = CertificateFactory.getInstance("X.509"); X509Certificate cert = (X509Certificate) factory.generateCertificate(x509Stream); key = cert.getPublicKey(); @@ -73,11 +73,11 @@ public class KeyFetcher { return key; } - public PublicKey retrieveJwkKey(OIDCServerConfiguration serverConfig) { + public PublicKey retrieveJwkKey(String jwkUrl) { RSAPublicKey pub = null; try { - String jwkString = restTemplate.getForObject(serverConfig.getJwkSigningUrl(), String.class); + String jwkString = restTemplate.getForObject(jwkUrl, String.class); JsonObject json = (JsonObject) new JsonParser().parse(jwkString); JsonArray getArray = json.getAsJsonArray("keys"); for(int i = 0; i < getArray.size(); i++) {