Class AbstractReloadingOIDCEntityResolver<Key extends com.nimbusds.oauth2.sdk.id.Identifier,​Value>

    • Field Detail

      • log

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

        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.
      • 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 Detail

      • AbstractReloadingOIDCEntityResolver

        protected AbstractReloadingOIDCEntityResolver()
        Constructor.
      • AbstractReloadingOIDCEntityResolver

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

      • 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

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

        protected abstract Key getKey​(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

        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

        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