Class AbstractReloadingOIDCEntityResolver<Key extends com.nimbusds.oauth2.sdk.id.Identifier,Value>
- java.lang.Object
-
- net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
-
- net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
-
- net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent
-
- net.shibboleth.oidc.metadata.impl.AbstractOIDCEntityResolver<Key,Value>
-
- net.shibboleth.oidc.metadata.impl.AbstractReloadingOIDCEntityResolver<Key,Value>
-
- Type Parameters:
Key- The identifier type in the backing storeValue- 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 com.nimbusds.oauth2.sdk.id.Identifier,Value> extends AbstractOIDCEntityResolver<Key,Value>
Based onAbstractReloadingMetadataResolver.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classAbstractReloadingOIDCEntityResolver.RefreshMetadataTaskBackground task that refreshes metadata.-
Nested classes/interfaces inherited from class net.shibboleth.oidc.metadata.impl.AbstractOIDCEntityResolver
AbstractOIDCEntityResolver.JsonBackingStore
-
-
Field Summary
Fields Modifier and Type Field Description private booleancreatedOwnTaskTimerWhether we created our own task timer during object construction.private InstantlastRefreshLast time a refresh cycle occurred.private InstantlastUpdateLast time the metadata was updated.private org.slf4j.LoggerlogClass logger.private DurationmaxRefreshDelayRefresh interval used when metadata does not contain any validUntil or cacheDuration information.private DurationminRefreshDelayFloor, in milliseconds, for the refresh interval.private InstantnextRefreshNext time a refresh cycle will occur.private AbstractReloadingOIDCEntityResolver.RefreshMetadataTaskrefreshMetadataTaskCurrent task to refresh metadata.private TimertaskTimerTimer used to schedule background metadata update tasks.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractReloadingOIDCEntityResolver()Constructor.protectedAbstractReloadingOIDCEntityResolver(Timer backgroundTaskTimer)Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract byte[]fetchMetadata()Fetches metadata from a source.protected abstract KeygetKey(Value value)Gets the identifier for the given entity.InstantgetLastRefresh()Get last refresh of resolver.InstantgetLastUpdate()Get last update of resolver.protected abstract StringgetMetadataIdentifier()Gets an identifier which may be used to distinguish this metadata in logging statements.protected voidinitOIDCResolver()Initializes this resolver by creating a new backing store.protected abstract List<Value>parse(byte[] bytes)Parses an entity from the byte array.voidrefresh()Refreshes the metadata from its source.protected voidscheduleNextRefresh(Duration delay)Schedules the next refresh.voidsetMaxRefreshDelay(Duration delay)Sets the maximum amount of time between refresh intervals.voidsetMinRefreshDelay(Duration delay)Sets the minimum amount of time between refreshes.-
Methods inherited from class net.shibboleth.oidc.metadata.impl.AbstractOIDCEntityResolver
createNewBackingStore, doInitialize, getBackingStore, getLogPrefix, indexEntityDescriptor, isFailFastInitialization, lookupIdentifier, lookupIndexedIdentifier, preProcessEntityDescriptor, removeByIdentifier, setBackingStore, setFailFastInitialization
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent
setId
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
getId
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, doDestroy, initialize, isDestroyed, isInitialized
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.shibboleth.utilities.java.support.component.IdentifiedComponent
getId
-
-
-
-
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.
-
refreshMetadataTask
private AbstractReloadingOIDCEntityResolver.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 Detail
-
AbstractReloadingOIDCEntityResolver
protected AbstractReloadingOIDCEntityResolver()
Constructor.
-
AbstractReloadingOIDCEntityResolver
protected AbstractReloadingOIDCEntityResolver(@Nullable Timer backgroundTaskTimer)Constructor.- Parameters:
backgroundTaskTimer- time used to schedule background refresh tasks
-
-
Method Detail
-
initOIDCResolver
protected void initOIDCResolver() throws ComponentInitializationExceptionDescription copied from class:AbstractOIDCEntityResolverInitializes this resolver by creating a new backing store.- Overrides:
initOIDCResolverin classAbstractOIDCEntityResolver<Key extends com.nimbusds.oauth2.sdk.id.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 ResolverExceptionRefreshes 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, thenmaxRefreshDelayis 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 ResolverExceptionFetches 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
-
-