Skip to content

Commit 85d9e07

Browse files
committed
Removed @PostConstruct; placed buildSignersAndVerifiers() calls inside both constructors.
1 parent c22cd62 commit 85d9e07

File tree

1 file changed

+9
-22
lines changed

1 file changed

+9
-22
lines changed

openid-connect-common/src/main/java/org/mitre/jwt/signer/service/impl/DefaultJwtSigningAndValidationService.java

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
import java.util.Map;
2525
import java.util.Set;
2626

27-
import javax.annotation.PostConstruct;
28-
2927
import org.mitre.jose.keystore.JWKSetKeyStore;
3028
import org.mitre.jwt.signer.service.JwtSigningAndValidationService;
3129
import org.slf4j.Logger;
@@ -62,7 +60,7 @@ public class DefaultJwtSigningAndValidationService implements JwtSigningAndValid
6260

6361
// map of identifier to key
6462
private 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
*/
7876
public DefaultJwtSigningAndValidationService(Map<String, JWK> keys) throws NoSuchAlgorithmException, InvalidKeySpecException {
7977
this.keys = keys;
80-
//buildSignersAndVerifiers();
78+
buildSignersAndVerifiers();
8179
}
8280

8381
/**
@@ -95,29 +93,18 @@ public DefaultJwtSigningAndValidationService(Map<String, JWK> keys) throws NoSuc
9593
public DefaultJwtSigningAndValidationService(JWKSetKeyStore keyStore) throws NoSuchAlgorithmException, InvalidKeySpecException {
9694
// convert all keys in the keystore to a map based on key id
9795
if (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-
116104
buildSignersAndVerifiers();
117-
118-
logger.info("DefaultJwtSigningAndValidationService is ready: " + this.toString());
119105
}
120106

107+
121108
/**
122109
* @return the defaultSignerKeyId
123110
*/

0 commit comments

Comments
 (0)