2424import java .util .Map ;
2525import java .util .Set ;
2626
27- import javax .annotation .PostConstruct ;
28-
2927import org .mitre .jose .keystore .JWKSetKeyStore ;
3028import org .mitre .jwt .signer .service .JwtSigningAndValidationService ;
3129import org .slf4j .Logger ;
@@ -62,7 +60,7 @@ public class DefaultJwtSigningAndValidationService implements JwtSigningAndValid
6260
6361// map of identifier to key
6462private Map <String , JWK > keys = new HashMap <String , JWK >();
65-
63+
6664/**
6765 * Build this service based on the keys given. All public keys will be used
6866 * to make verifiers, all private keys will be used to make signers.
@@ -77,7 +75,7 @@ public class DefaultJwtSigningAndValidationService implements JwtSigningAndValid
7775 */
7876public DefaultJwtSigningAndValidationService (Map <String , JWK > keys ) throws NoSuchAlgorithmException , InvalidKeySpecException {
7977this .keys = keys ;
80- // buildSignersAndVerifiers();
78+ buildSignersAndVerifiers ();
8179}
8280
8381/**
@@ -95,29 +93,18 @@ public DefaultJwtSigningAndValidationService(Map<String, JWK> keys) throws NoSuc
9593public DefaultJwtSigningAndValidationService (JWKSetKeyStore keyStore ) throws NoSuchAlgorithmException , InvalidKeySpecException {
9694// convert all keys in the keystore to a map based on key id
9795if (keyStore != null && keyStore .getJwkSet () != null ) {
98- for (JWK key : keyStore .getKeys ()) {
99- if (!Strings .isNullOrEmpty (key .getKeyID ())) {
100- this .keys .put (key .getKeyID (), key );
101- } else {
102- throw new IllegalArgumentException ("Tried to load a key from a keystore without a 'kid' field: " + key );
96+ for (JWK key : keyStore .getKeys ()) {
97+ if (!Strings .isNullOrEmpty (key .getKeyID ())) {
98+ this .keys .put (key .getKeyID (), key );
99+ } else {
100+ throw new IllegalArgumentException ("Tried to load a key from a keystore without a 'kid' field: " + key );
101+ }
103102}
104103}
105- }
106- //buildSignersAndVerifiers();
107- }
108-
109- @ PostConstruct
110- public void afterPropertiesSet () throws NoSuchAlgorithmException , InvalidKeySpecException {
111-
112- if (keys == null ) {
113- throw new IllegalArgumentException ("Signing and validation service must have at least one key configured." );
114- }
115-
116104buildSignersAndVerifiers ();
117-
118- logger .info ("DefaultJwtSigningAndValidationService is ready: " + this .toString ());
119105}
120106
107+
121108/**
122109 * @return the defaultSignerKeyId
123110 */
0 commit comments