Class AbstractReloadingOIDCEntityResolver<Key extends Identifier,Value>

Type Parameters:
Key - The identifier type in the backing store
Value - The entity type in the backing store
All Implemented Interfaces:
Component, DestructableComponent, IdentifiableComponent, IdentifiedComponent, InitializableComponent
Direct Known Subclasses:
AbstractFileOIDCEntityResolver

public abstract class AbstractReloadingOIDCEntityResolver<Key extends Identifier,Value> extends AbstractOIDCEntityResolver<Key,Value>
Base class for metadata providers that cache and periodically refresh their entities. Based on AbstractReloadingMetadataResolver.
  • Field Details

    • log

      @Nonnull private final org.slf4j.Logger log
      Class logger.
    • taskTimer

      @Nonnull private final Timer taskTimer
      Timer used to schedule background metadata update tasks.
    • createdOwnTaskTimer

      private final boolean createdOwnTaskTimer
      Whether we created our own task timer during object construction.
    • refreshMetadataTask

      @Nullable private AbstractReloadingOIDCEntityResolver<Key extends Identifier,Value>.RefreshMetadataTask refreshMetadataTask
      Current task to refresh metadata.
    • maxRefreshDelay

      @Nonnull @Positive private Duration maxRefreshDelay
      Refresh interval used when metadata does not contain any validUntil or cacheDuration information. Default value: 4 hours
    • minRefreshDelay

      @Nonnull @Positive private Duration minRefreshDelay
      Floor, in milliseconds, for the refresh interval. Default value: 5 minutes
    • lastUpdate

      @Nullable private Instant lastUpdate
      Last time the metadata was updated.
    • lastRefresh

      @Nullable private Instant lastRefresh
      Last time a refresh cycle occurred.
    • nextRefresh

      @Nullable private Instant nextRefresh
      Next time a refresh cycle will occur.
  • Constructor Details

    • AbstractReloadingOIDCEntityResolver

      protected AbstractReloadingOIDCEntityResolver()
      Constructor.
    • AbstractReloadingOIDCEntityResolver

      protected AbstractReloadingOIDCEntityResolver(@Nullable Timer backgroundTaskTimer)
      Constructor.
      Parameters:
      backgroundTaskTimer - time used to schedule background refresh tasks
  • Method Details

    • initOIDCResolver

      protected void initOIDCResolver() throws ComponentInitializationException
      Description copied from class: AbstractOIDCEntityResolver
      Initializes this resolver by creating a new backing store.
      Overrides:
      initOIDCResolver in class AbstractOIDCEntityResolver<Key extends Identifier,Value>
      Throws:
      ComponentInitializationException - If the initialization fails.
    • getLastUpdate

      @Nullable public Instant getLastUpdate()
      Get last update of resolver.
      Returns:
      last update
    • getLastRefresh

      @Nullable public Instant getLastRefresh()
      Get last refresh of resolver.
      Returns:
      last refresh
    • setMinRefreshDelay

      public void setMinRefreshDelay(@Positive @Nonnull Duration delay)
      Sets the minimum amount of time between refreshes.
      Parameters:
      delay - minimum amount of time between refreshes
    • setMaxRefreshDelay

      public void setMaxRefreshDelay(@Positive @Nonnull Duration delay)
      Sets the maximum amount of time between refresh intervals.
      Parameters:
      delay - maximum amount of time, in milliseconds, between refresh intervals
    • refresh

      public void refresh() throws ResolverException
      Refreshes the metadata from its source.
      Throws:
      ResolverException - thrown is there is a problem retrieving and processing the metadata
    • scheduleNextRefresh

      protected void scheduleNextRefresh(@Nullable Duration delay)
      Schedules the next refresh. If the given delay is 0 or null, then maxRefreshDelay is used.
      Parameters:
      delay - The delay before the next refresh.
    • parse

      @Nonnull protected abstract List<Value> parse(@Nonnull byte[] bytes) throws ParseException
      Parses an entity from the byte array.
      Parameters:
      bytes - The encoded entity
      Returns:
      The parsed entity
      Throws:
      ParseException - if parse fails
    • getKey

      @Nonnull protected abstract Key getKey(@Nonnull Value value)
      Gets the identifier for the given entity.
      Parameters:
      value - The entity whose identifier will be returned.
      Returns:
      The identifier for the given entity.
    • getMetadataIdentifier

      @Nonnull protected abstract String getMetadataIdentifier()
      Gets an identifier which may be used to distinguish this metadata in logging statements.
      Returns:
      identifier which may be used to distinguish this metadata in logging statements
    • fetchMetadata

      @Nullable protected abstract byte[] fetchMetadata() throws ResolverException
      Fetches metadata from a source.
      Returns:
      the fetched metadata, or null if the metadata is known not to have changed since the last retrieval
      Throws:
      ResolverException - thrown if there is a problem fetching the metadata