JWK display support for key maps, still no key ids
parent
d5e7000365
commit
6c01134095
|
@ -2,17 +2,18 @@ package org.mitre.jwt.signer.service;
|
|||
|
||||
import java.security.PublicKey;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.mitre.jwt.model.Jwt;
|
||||
|
||||
public interface JwtSigningAndValidationService {
|
||||
|
||||
/**
|
||||
* Returns all public keys this service is configured with.
|
||||
* Returns all public keys this service is configured with, indexed by key id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<PublicKey> getAllPublicKeys();
|
||||
public Map<String, PublicKey> getAllPublicKeys();
|
||||
|
||||
/**
|
||||
* Check to see if this JWT has expired or not
|
||||
|
|
|
@ -68,7 +68,7 @@ public class JwtSigningAndValidationServiceDefault implements
|
|||
* ()
|
||||
*/
|
||||
@Override
|
||||
public List<PublicKey> getAllPublicKeys() {
|
||||
public Map<String, PublicKey> getAllPublicKeys() {
|
||||
|
||||
Map<String, PublicKey> map = new HashMap<String, PublicKey>();
|
||||
|
||||
|
@ -80,11 +80,13 @@ public class JwtSigningAndValidationServiceDefault implements
|
|||
|
||||
publicKey = ((RsaSigner) signer).getPublicKey();
|
||||
|
||||
if (publicKey != null)
|
||||
if (publicKey != null) {
|
||||
// what's the index of this map for?
|
||||
map.put(((RSAPublicKey) publicKey).getModulus()
|
||||
.toString(16).toUpperCase()
|
||||
+ ((RSAPublicKey) publicKey).getPublicExponent()
|
||||
.toString(16).toUpperCase(), publicKey);
|
||||
}
|
||||
|
||||
} else if (signer instanceof EcdsaSigner) {
|
||||
|
||||
|
@ -92,8 +94,7 @@ public class JwtSigningAndValidationServiceDefault implements
|
|||
}
|
||||
}
|
||||
|
||||
return new ArrayList<PublicKey>(map.values());
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -76,7 +76,7 @@ public class JwkKeyListView extends AbstractView {
|
|||
o.addProperty("alg", "RSA");
|
||||
o.addProperty("mod", m64);
|
||||
o.addProperty("exp", e64);
|
||||
|
||||
// TODO: get the key ID from the map
|
||||
return o;
|
||||
} else if (src instanceof ECPublicKey) {
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.mitre.openid.connect.web;
|
||||
|
||||
import java.security.PublicKey;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -20,7 +21,7 @@ public class JsonWebKeyEndpoint {
|
|||
@RequestMapping("/jwk")
|
||||
public ModelAndView getJwk() {
|
||||
|
||||
List<PublicKey> keys = jwtService.getAllPublicKeys();
|
||||
Collection<PublicKey> keys = jwtService.getAllPublicKeys().values();
|
||||
|
||||
// TODO: check if keys are empty, return a 404 here or just an empty list?
|
||||
|
||||
|
|
Loading…
Reference in New Issue