adapted keyfetcher to be more general

pull/263/head
Justin Richer 2013-01-15 11:58:30 -05:00
parent abd64eccd6
commit c946a84b09
2 changed files with 6 additions and 6 deletions

View File

@ -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());

View File

@ -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++) {