Package com.nimbusds.jose.jwk.source
Class OutageTolerantJWKSetSource<C extends SecurityContext>
- java.lang.Object
-
- com.nimbusds.jose.jwk.source.JWKSetSourceWrapper<C>
-
- com.nimbusds.jose.jwk.source.OutageTolerantJWKSetSource<C>
-
- All Implemented Interfaces:
JWKSetSource<C>
,Closeable
,AutoCloseable
@ThreadSafe public class OutageTolerantJWKSetSource<C extends SecurityContext> extends JWKSetSourceWrapper<C>
JWKSetSource with outage tolerance to handle temporary network issues and endpoint downtime, potentially running into minutes or hours. Transparently caches the JWK set provided by the wrapped JWKSetSource, returning it in case the underlying source throws a JWKSetUnavailableException.- Version:
- 2022-11-22
- Author:
- Thomas Rørvik Skjølberg, Vladimir Dzhuvinov
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
OutageTolerantJWKSetSource.OutageEvent<C extends SecurityContext>
JWK set source outage event.
-
Constructor Summary
Constructors Constructor Description OutageTolerantJWKSetSource(JWKSetSource<C> source, long timeToLive, EventListener<OutageTolerantJWKSetSource<C>,C> eventListener)
Creates a new outage tolerant JWK set source.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JWKSet
getJWKSet(JWKSetCacheRefreshEvaluator refreshEvaluator, long currentTime, C context)
Gets the JWK set.long
getTimeToLive()
Returns the time to live of the cached JWK set.-
Methods inherited from class com.nimbusds.jose.jwk.source.JWKSetSourceWrapper
close, getSource
-
-
-
-
Constructor Detail
-
OutageTolerantJWKSetSource
public OutageTolerantJWKSetSource(JWKSetSource<C> source, long timeToLive, EventListener<OutageTolerantJWKSetSource<C>,C> eventListener)
Creates a new outage tolerant JWK set source.- Parameters:
source
- The JWK set source to decorate. Must not benull
.timeToLive
- The time to live of the cached JWK set to cover outages, in milliseconds.eventListener
- The event listener,null
if not specified.
-
-
Method Detail
-
getJWKSet
public JWKSet getJWKSet(JWKSetCacheRefreshEvaluator refreshEvaluator, long currentTime, C context) throws KeySourceException
Description copied from interface:JWKSetSource
Gets 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,null
if not required.- Returns:
- The JWK set.
- Throws:
KeySourceException
- If JWK set retrieval failed.
-
getTimeToLive
public long getTimeToLive()
Returns the time to live of the cached JWK set.- Returns:
- The time to live, in milliseconds.
-
-