explicitly try to initialize the JWK set if it's null by the time the getter is called
parent
6a9650d2a7
commit
da915d8b35
|
@ -19,7 +19,9 @@
|
|||
*/
|
||||
package org.mitre.jose.keystore;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
@ -50,18 +52,23 @@ public class JWKSetKeyStore {
|
|||
}
|
||||
|
||||
@PostConstruct
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
private void initializeJwkSet() {
|
||||
|
||||
if (jwkSet == null) {
|
||||
if (location != null) {
|
||||
|
||||
if (location.exists() && location.isReadable()) {
|
||||
|
||||
// read in the file from disk
|
||||
String s = CharStreams.toString(new InputStreamReader(location.getInputStream(), Charsets.UTF_8));
|
||||
try {
|
||||
// read in the file from disk
|
||||
String s = CharStreams.toString(new InputStreamReader(location.getInputStream(), Charsets.UTF_8));
|
||||
|
||||
// parse it into a jwkSet object
|
||||
jwkSet = JWKSet.parse(s);
|
||||
// parse it into a jwkSet object
|
||||
jwkSet = JWKSet.parse(s);
|
||||
} catch (IOException e) {
|
||||
throw new IllegalArgumentException("Key Set resource could not be read: " + location);
|
||||
} catch (ParseException e) {
|
||||
throw new IllegalArgumentException("Key Set resource could not be parsed: " + location); }
|
||||
|
||||
} else {
|
||||
throw new IllegalArgumentException("Key Set resource could not be read: " + location);
|
||||
|
@ -105,6 +112,9 @@ public class JWKSetKeyStore {
|
|||
* Get the list of keys in this keystore. This is a passthrough to the underlying JWK Set
|
||||
*/
|
||||
public List<JWK> getKeys() {
|
||||
if (jwkSet == null) {
|
||||
initializeJwkSet();
|
||||
}
|
||||
return jwkSet.getKeys();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue