Class RefreshAheadCachingJWKSetSource<C extends SecurityContext>

All Implemented Interfaces:
JWKSetSource<C>, Closeable, AutoCloseable

@ThreadSafe public class RefreshAheadCachingJWKSetSource<C extends SecurityContext> extends CachingJWKSetSource<C>
Caching JWKSetSource that refreshes the JWK set prior to its expiration. The updates run on a separate, dedicated thread. Updates can be repeatedly scheduled, or (lazily) triggered by incoming requests for the JWK set.

This class is intended for uninterrupted operation under high-load, to avoid a potentially large number of threads blocking when the cache expires (and must be refreshed).

Version:
2022-11-22
Author:
Thomas Rørvik Skjølberg, Vladimir Dzhuvinov
  • Constructor Details

    • RefreshAheadCachingJWKSetSource

      public RefreshAheadCachingJWKSetSource(JWKSetSource<C> source, long timeToLive, long cacheRefreshTimeout, long refreshAheadTime, boolean scheduled, EventListener<CachingJWKSetSource<C>,C> eventListener)
      Creates a new refresh-ahead caching JWK set source.
      Parameters:
      source - The JWK set source to decorate. Must not be null.
      timeToLive - The time to live of the cached JWK set, in milliseconds.
      cacheRefreshTimeout - The cache refresh timeout, in milliseconds.
      refreshAheadTime - The refresh ahead time, in milliseconds.
      scheduled - true to refresh in a scheduled manner, regardless of requests.
      eventListener - The event listener, null if not specified.
    • RefreshAheadCachingJWKSetSource

      public RefreshAheadCachingJWKSetSource(JWKSetSource<C> source, long timeToLive, long cacheRefreshTimeout, long refreshAheadTime, boolean scheduled, ExecutorService executorService, boolean shutdownExecutorOnClose, EventListener<CachingJWKSetSource<C>,C> eventListener)
      Creates a new refresh-ahead caching JWK set source with the specified executor service to run the updates in the background.
      Parameters:
      source - The JWK set source to decorate. Must not be null.
      timeToLive - The time to live of the cached JWK set, in milliseconds.
      cacheRefreshTimeout - The cache refresh timeout, in milliseconds.
      refreshAheadTime - The refresh ahead time, in milliseconds.
      scheduled - true to refresh in a scheduled manner, regardless of requests.
      executorService - The executor service to run the updates in the background.
      shutdownExecutorOnClose - If true the executor service will be shut down upon closing the source.
      eventListener - The event listener, null if not specified.
  • Method Details