public class HttpsJwks extends Object
setDefaultCacheDuration(long).
The keys are cached per HttpsJwks instance so your application will need to keep using
the same instance, however is appropriate for that application, to get the benefit of the caching.
This class, when used with HttpsJwksVerificationKeyResolver, can help facilitate the consuming side of
a key publication and rotation model like that which is described
in OpenID Connect, section 10.HttpsJwksVerificationKeyResolver| Constructor and Description |
|---|
HttpsJwks(String location)
Create a new HttpsJwks that cab be used to retrieve JWKs from the given location.
|
| Modifier and Type | Method and Description |
|---|---|
List<JsonWebKey> |
getJsonWebKeys()
Gets the JSON Web Keys from the JWKS endpoint location or from local cache, if appropriate.
|
String |
getLocation()
Gets the location of the JWKS endpoint/URL.
|
void |
refresh()
Forces a refresh of the cached JWKs from the JWKS endpoint.
|
void |
setDefaultCacheDuration(long defaultCacheDuration)
The time period to cache the JWKs from the endpoint, if the cache directive
headers of the response are not present or indicate that the content should not be cached.
|
void |
setRefreshReprieveThreshold(long refreshReprieveThreshold)
Sets the period of time as a threshold for which a subsequent
refresh() calls will use the cache and
not actually refresh from the JWKS endpoint/URL. |
void |
setRetainCacheOnErrorDuration(long retainCacheOnErrorDuration)
Sets the length of time, before trying again, to keep using the cache when an error occurs making the request to
the JWKS URI or parsing the response.
|
void |
setSimpleHttpGet(SimpleGet simpleHttpGet)
Sets the SimpleGet instance to use when making the HTTP GET request to the JWKS location.
|
public HttpsJwks(String location)
location - the HTTPS URI of the JSON Web Key Setpublic void setDefaultCacheDuration(long defaultCacheDuration)
defaultCacheDuration - the length in seconds of the default cache durationpublic void setRetainCacheOnErrorDuration(long retainCacheOnErrorDuration)
getJsonWebKeys()
when an error occurs. When larger than zero, the previously established cached list of keys (if it exists) will be used/returned
and another attempt to fetch the keys from the JWKS URI will not be made for the given duration.
The default value is 0.retainCacheOnErrorDuration - the length in seconds to keep using the cache when an error occurs before trying againpublic void setSimpleHttpGet(SimpleGet simpleHttpGet)
Get is used. This method should be used
right after construction, if a different implementation of SimpleGet
or non-default configured instance of Get is needed.simpleHttpGet - the instance of the implementation of SimpleGet to usepublic String getLocation()
public void setRefreshReprieveThreshold(long refreshReprieveThreshold)
refresh() calls will use the cache and
not actually refresh from the JWKS endpoint/URL.refreshReprieveThreshold - the threshold time in milliseconds (probably should be a relatevily small value).
The default value, if unset is 300.public List<JsonWebKey> getJsonWebKeys() throws JoseException, IOException
JoseException - if a problem is encountered parsing the JSON content into JSON Web Keys.IOException - if a problem is encountered making the HTTP request.public void refresh()
throws JoseException,
IOException
refreshReprieveThreshold it will not actually force a refresh but use the cache instead.JoseException - if an problem is encountered parsing the JSON content into JSON Web Keys.IOException - if a problem is encountered making the HTTP request.Copyright © 2022. All rights reserved.