public class DefaultJWKSetCache extends Object implements JWKSetCache
| Modifier and Type | Field and Description |
|---|---|
static long |
DEFAULT_LIFESPAN_MINUTES
The default lifespan for cached JWK sets (15 minutes).
|
static long |
DEFAULT_REFRESH_TIME_MINUTES
The default refresh time for cached JWK sets (5 minutes).
|
| Constructor and Description |
|---|
DefaultJWKSetCache()
Creates a new JWK set, the default lifespan of the cached JWK set is
set to 15 minutes, the refresh time to 5 minutes.
|
DefaultJWKSetCache(long lifespan,
long refreshTime,
TimeUnit timeUnit)
Creates a new JWK set cache.
|
| Modifier and Type | Method and Description |
|---|---|
JWKSet |
get()
Gets the cached JWK set.
|
long |
getLifespan(TimeUnit timeUnit)
Returns the configured lifespan of the cached JWK.
|
long |
getPutTimestamp()
Returns the cache put timestamp.
|
long |
getRefreshTime(TimeUnit timeUnit)
Returns the configured refresh time of the cached JWK.
|
boolean |
isExpired()
Returns
true if the cached JWK set is expired. |
void |
put(JWKSet jwkSet)
Puts the specified JWK set into the cache or clears the cache.
|
boolean |
requiresRefresh()
Returns
true if the cached JWK set requires a refresh. |
public static final long DEFAULT_LIFESPAN_MINUTES
public static final long DEFAULT_REFRESH_TIME_MINUTES
public DefaultJWKSetCache()
public DefaultJWKSetCache(long lifespan, long refreshTime, TimeUnit timeUnit)
lifespan - The lifespan of the cached JWK set before it
expires, negative means no expiration.refreshTime - The time after which the cached JWK set is marked
for refresh, negative if not specified. Should be
shorter or equal to the lifespan.timeUnit - The lifespan time unit, may be null if no
expiration or refresh time.public void put(JWKSet jwkSet)
JWKSetCacheput in interface JWKSetCachejwkSet - The JWK set to cache, null to clear the cache.public JWKSet get()
JWKSetCacheget in interface JWKSetCachenull if none or expired.public boolean requiresRefresh()
JWKSetCachetrue if the cached JWK set requires a refresh. This
should typically occur some time before the cache has expired, to
allow for transient retrieval exceptions before expiration.requiresRefresh in interface JWKSetCachetrue if the cached JWK set requires a refresh.public long getPutTimestamp()
public boolean isExpired()
true if the cached JWK set is expired.true if expired.public long getLifespan(TimeUnit timeUnit)
timeUnit - The time unit to use.public long getRefreshTime(TimeUnit timeUnit)
timeUnit - The time unit to use.Copyright © 2020 Connect2id Ltd.. All rights reserved.