public class JwksStore extends Object
Constructor and Description |
---|
JwksStore(Duration cacheTimeout,
Duration cacheMissCacheTime,
URL jwkUrl,
JWKSetParser jwkSetParser,
Clock clock)
Create a new JWKs store.
|
Modifier and Type | Method and Description |
---|---|
JWK |
findJwk(Algorithm algorithm,
KeyUse keyUse)
Search for a JWK that matches the algorithm and the key usage.
|
JWK |
findJwk(String kid)
Search for a JWK that matches the kid.
|
Duration |
getCacheMissCacheTime()
Get the cache time before reload the cache in case of cache miss.
|
Duration |
getCacheTimeout()
Get the cache timeout.
|
URL |
getJwkUrl()
The JWKs URI.
|
Pair<JWKSet,Instant> |
getLastLoadedJwkSet()
Returns the last successfully loaded JWK Set together with the time at which it was last fetched.
|
void |
reloadJwks()
Communicates with the configured server, attempting to download the latest JWKs for use.
|
void |
setCacheMissCacheTime(Duration cacheMissCacheTime)
Update the cache time before reload the cache in case of cache miss.
|
void |
setCacheTimeout(Duration cacheTimeout)
Update the cache timeout.
|
void |
setJwkUrl(URL jwkUrl)
Update the JWKs URI.
|
public JwksStore(Duration cacheTimeout, Duration cacheMissCacheTime, URL jwkUrl, JWKSetParser jwkSetParser, Clock clock) throws FailedToLoadJWKException
cacheTimeout
- a cache timeout to avoid reloading the cache all the time when doing encryptioncacheMissCacheTime
- the cache time before reload the cache in case of a cache miss.
This avoid polling the client application too often.jwkUrl
- the jwk url of the JWKs hosted by the client applicationjwkSetParser
- the jwks set parserclock
- the clock to use for determining when to reload the jwk set.FailedToLoadJWKException
- if the jwks can't be reloaded.public void reloadJwks() throws FailedToLoadJWKException
FailedToLoadJWKException
- if there were issues parsing the supplied URLpublic JWK findJwk(Algorithm algorithm, KeyUse keyUse) throws FailedToLoadJWKException
algorithm
- the algorithm neededkeyUse
- the key usage. If null, only the algorithm will be used as a search criteria.FailedToLoadJWKException
- if the jwks can't be reloaded.public JWK findJwk(String kid) throws FailedToLoadJWKException
kid
- Key IDFailedToLoadJWKException
- if the jwks can't be reloaded.public Pair<JWKSet,Instant> getLastLoadedJwkSet()
public Duration getCacheTimeout()
public Duration getCacheMissCacheTime()
public URL getJwkUrl()
public void setCacheTimeout(Duration cacheTimeout)
cacheTimeout
- the cache timeout.public void setCacheMissCacheTime(Duration cacheMissCacheTime)
cacheMissCacheTime
- the cache miss cache time.public void setJwkUrl(URL jwkUrl) throws FailedToLoadJWKException
jwkUrl
- the jwks uri.FailedToLoadJWKException
- If the URI has changed and the JWK set cannot be loaded.Copyright 2010-2018 ForgeRock AS.