Package com.nimbusds.jose.jwk.source
Class CachingJWKSetSource<C extends SecurityContext>
- java.lang.Object
-
- com.nimbusds.jose.jwk.source.JWKSetSourceWrapper<C>
-
- com.nimbusds.jose.jwk.source.CachingJWKSetSource<C>
-
- All Implemented Interfaces:
JWKSetSource<C>,Closeable,AutoCloseable
- Direct Known Subclasses:
RefreshAheadCachingJWKSetSource
@ThreadSafe public class CachingJWKSetSource<C extends SecurityContext> extends JWKSetSourceWrapper<C>
Caching JWKSetSource. Blocks during cache updates.- Version:
- 2022-11-08
- Author:
- Thomas Rørvik Skjølberg, Vladimir Dzhuvinov
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCachingJWKSetSource.RefreshCompletedEvent<C extends SecurityContext>JWK set cache refresh completed event.static classCachingJWKSetSource.RefreshInitiatedEvent<C extends SecurityContext>JWK set cache refresh initiated event.static classCachingJWKSetSource.RefreshTimedOutEvent<C extends SecurityContext>JWK set cache refresh timed out event.static classCachingJWKSetSource.UnableToRefreshEvent<C extends SecurityContext>Unable to refresh the JWK set cache event.static classCachingJWKSetSource.WaitingForRefreshEvent<C extends SecurityContext>Waiting for a JWK set cache refresh to complete on another thread event.
-
Constructor Summary
Constructors Constructor Description CachingJWKSetSource(JWKSetSource<C> source, long timeToLive, long cacheRefreshTimeout, EventListener<CachingJWKSetSource<C>,C> eventListener)Creates a new caching JWK set source.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetCacheRefreshTimeout()Returns the cache refresh timeout.JWKSetgetJWKSet(JWKSetCacheRefreshEvaluator refreshEvaluator, long currentTime, C context)Gets the JWK set.longgetTimeToLive()Returns the time to live of the cached JWK set.-
Methods inherited from class com.nimbusds.jose.jwk.source.JWKSetSourceWrapper
close, getSource
-
-
-
-
Constructor Detail
-
CachingJWKSetSource
public CachingJWKSetSource(JWKSetSource<C> source, long timeToLive, long cacheRefreshTimeout, EventListener<CachingJWKSetSource<C>,C> eventListener)
Creates a new caching JWK set source.- Parameters:
source- The JWK set source to decorate. Must not benull.timeToLive- The time to live of the cached JWK set, in milliseconds.cacheRefreshTimeout- The cache refresh timeout, in milliseconds.eventListener- The event listener,nullif not specified.
-
-
Method Detail
-
getJWKSet
public JWKSet getJWKSet(JWKSetCacheRefreshEvaluator refreshEvaluator, long currentTime, C context) throws KeySourceException
Description copied from interface:JWKSetSourceGets the JWK set.- Parameters:
refreshEvaluator- Controls whether refresh of the JWK set cache (if utilised by the source) is required.currentTime- The current time, in milliseconds since the Unix epoch.context- Optional context,nullif not required.- Returns:
- The JWK set.
- Throws:
KeySourceException- If JWK set retrieval failed.
-
getCacheRefreshTimeout
public long getCacheRefreshTimeout()
Returns the cache refresh timeout.- Returns:
- The cache refresh timeout, in milliseconds.
-
getTimeToLive
public long getTimeToLive()
Returns the time to live of the cached JWK set.- Returns:
- The time to live, in milliseconds.
-
-