public abstract class AbstractReloadingMetadataResolver extends AbstractBatchMetadataResolver implements ExtendedRefreshableMetadataResolver
getMaxRefreshDelay() value is used. Otherwise, the earliest refresh interval of the metadata file is checked
by looking for the earliest of all the validUntil attributes and cacheDuration attributes. If that refresh interval
is larger than the max refresh delay then getMaxRefreshDelay() is used. If that number is smaller than the
min refresh delay then getMinRefreshDelay() is used. Otherwise the calculated refresh delay multiplied by
getRefreshDelayFactor() is used. By using this factor, the provider will attempt to be refresh before the
cache actually expires, allowing a some room for error and recovery. Assuming the factor is not exceedingly close to
1.0 and a min refresh delay that is not overly large, this refresh will likely occur a few times before the cache
expires.| Modifier and Type | Class and Description |
|---|---|
private class |
AbstractReloadingMetadataResolver.RefreshMetadataTask
Background task that refreshes metadata.
|
AbstractBatchMetadataResolver.BatchEntityBackingStoreAbstractMetadataResolver.EntityBackingStore| Modifier and Type | Field and Description |
|---|---|
private boolean |
createdOwnTaskTimer
Whether we created our own task timer during object construction.
|
private org.joda.time.DateTime |
expirationTime
Time when the currently cached metadata file expires.
|
private long |
expirationWarningThreshold
Impending expiration warning threshold for metadata refresh, in milliseconds.
|
private org.joda.time.DateTime |
lastRefresh
Last time a refresh cycle occurred.
|
private org.joda.time.DateTime |
lastSuccessfulRefresh
Last time a successful refresh cycle occurred.
|
private org.joda.time.DateTime |
lastUpdate
Last time the metadata was updated.
|
private org.slf4j.Logger |
log
Class logger.
|
private long |
maxRefreshDelay
Refresh interval used when metadata does not contain any validUntil or cacheDuration information.
|
private long |
minRefreshDelay
Floor, in milliseconds, for the refresh interval.
|
private org.joda.time.DateTime |
nextRefresh
Next time a refresh cycle will occur.
|
private float |
refreshDelayFactor
Factor used to compute when the next refresh interval will occur.
|
private AbstractReloadingMetadataResolver.RefreshMetadataTask |
refreshMetadataTask
Current task to refresh metadata.
|
private Timer |
taskTimer
Timer used to schedule background metadata update tasks.
|
private boolean |
trackRefreshSuccess
Internal flag for tracking success during the refresh operation.
|
private Boolean |
wasLastRefreshSuccess
Flag indicating whether last refresh cycle was successful.
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractReloadingMetadataResolver()
Constructor.
|
protected |
AbstractReloadingMetadataResolver(Timer backgroundTaskTimer)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected long |
computeNextRefreshDelay(org.joda.time.DateTime expectedExpiration)
Computes the delay until the next refresh time based on the current metadata's expiration time and the refresh
interval floor.
|
protected void |
doDestroy() |
protected abstract byte[] |
fetchMetadata()
Fetches metadata from a source.
|
org.joda.time.DateTime |
getExpirationTime()
Gets the time when the currently cached metadata expires.
|
long |
getExpirationWarningThreshold()
Gets the impending expiration warning threshold used at refresh time.
|
org.joda.time.DateTime |
getLastRefresh() |
org.joda.time.DateTime |
getLastSuccessfulRefresh() |
org.joda.time.DateTime |
getLastUpdate() |
long |
getMaxRefreshDelay()
Gets the maximum amount of time, in milliseconds, between refresh intervals.
|
protected abstract String |
getMetadataIdentifier()
Gets an identifier which may be used to distinguish this metadata in logging statements.
|
long |
getMinRefreshDelay()
Gets the minimum amount of time, in milliseconds, between refreshes.
|
org.joda.time.DateTime |
getNextRefresh()
Gets the time when the next refresh cycle will occur.
|
float |
getRefreshDelayFactor()
Gets the delay factor used to compute the next refresh time.
|
protected void |
initMetadataResolver()
Subclasses should override this method to perform any initialization logic necessary.
|
protected byte[] |
inputstreamToByteArray(InputStream ins)
Converts an InputStream into a byte array.
|
private void |
logCachedMetadataExpiration(org.joda.time.DateTime now)
Check cached metadata for expiration or pending expiration and log appropriately.
|
protected void |
postProcessMetadata(byte[] metadataBytes,
Document metadataDom,
org.opensaml.core.xml.XMLObject originalMetadata,
org.opensaml.core.xml.XMLObject filteredMetadata)
Post-processing hook called after new metadata has been unmarshalled, filtered, and the DOM released (from the
XMLObject) but before the metadata is saved off. |
protected void |
processCachedMetadata(String metadataIdentifier,
org.joda.time.DateTime refreshStart)
Processes a cached metadata document in order to determine, and schedule, the next time it should be refreshed.
|
protected void |
processNewMetadata(String metadataIdentifier,
org.joda.time.DateTime refreshStart,
byte[] metadataBytes)
Process a new metadata document.
|
protected void |
processNonExpiredMetadata(String metadataIdentifier,
org.joda.time.DateTime refreshStart,
byte[] metadataBytes,
org.opensaml.core.xml.XMLObject metadata)
Processes metadata that has been determined to be valid at the time it was fetched.
|
protected void |
processPreExpiredMetadata(String metadataIdentifier,
org.joda.time.DateTime refreshStart,
byte[] metadataBytes,
org.opensaml.core.xml.XMLObject metadata)
Processes metadata that has been determined to be invalid (usually because it's already expired) at the time it
was fetched.
|
void |
refresh()
Refreshes the metadata from its source.
|
protected void |
setCacheSourceMetadata(boolean flag)
Set whether to cache the original source metadata document.
|
void |
setExpirationWarningThreshold(long threshold)
Sets the impending expiration warning threshold used at refresh time.
|
void |
setMaxRefreshDelay(long delay)
Sets the maximum amount of time, in milliseconds, between refresh intervals.
|
void |
setMinRefreshDelay(long delay)
Sets the minimum amount of time, in milliseconds, between refreshes.
|
void |
setRefreshDelayFactor(float factor)
Sets the delay factor used to compute the next refresh time.
|
protected org.opensaml.core.xml.XMLObject |
unmarshallMetadata(byte[] metadataBytes)
Unmarshalls the given metadata bytes.
|
Boolean |
wasLastRefreshSuccess() |
createNewBackingStore, getBackingStore, getCachedFilteredMetadata, getCachedOriginalMetadata, getIndexes, getRootValidUntil, indexEntityDescriptor, isCacheSourceMetadata, isResolveViaPredicatesOnly, isRootValid, iterator, lookupByIndexes, preProcessNewMetadata, resolve, setIndexes, setResolveViaPredicatesOnlydoInitialize, filterMetadata, getCriterionPredicateRegistry, getLogPrefix, getMetadataFilter, getParserPool, getUnmarshallerFactory, isFailFastInitialization, isRequireValidMetadata, isSatisfyAnyPredicates, isUseDefaultPredicateRegistry, isValid, lookupEntityID, lookupIndexedEntityID, predicateFilterCandidates, preProcessEntitiesDescriptor, preProcessEntityDescriptor, releaseMetadataDOM, removeByEntityID, resolveSingle, setBackingStore, setCriterionPredicateRegistry, setFailFastInitialization, setMetadataFilter, setParserPool, setRequireValidMetadata, setSatisfyAnyPredicates, setUseDefaultPredicateRegistry, unmarshallMetadatasetIdgetIddestroy, initialize, isDestroyed, isInitializedclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetMetadataFilter, isRequireValidMetadata, setMetadataFilter, setRequireValidMetadataresolve, resolveSinglegetIdforEach, spliteratorprivate final org.slf4j.Logger log
private Timer taskTimer
private boolean createdOwnTaskTimer
private AbstractReloadingMetadataResolver.RefreshMetadataTask refreshMetadataTask
private float refreshDelayFactor
@Duration @Positive private long maxRefreshDelay
@Duration @Positive private long minRefreshDelay
private org.joda.time.DateTime expirationTime
@Duration @Positive private long expirationWarningThreshold
private org.joda.time.DateTime lastUpdate
private org.joda.time.DateTime lastRefresh
private org.joda.time.DateTime nextRefresh
private org.joda.time.DateTime lastSuccessfulRefresh
private Boolean wasLastRefreshSuccess
private boolean trackRefreshSuccess
protected AbstractReloadingMetadataResolver()
protected void setCacheSourceMetadata(boolean flag)
setCacheSourceMetadata in class AbstractBatchMetadataResolverflag - true if source should be cached, false otherwisepublic org.joda.time.DateTime getExpirationTime()
@Nullable public org.joda.time.DateTime getLastUpdate()
getLastUpdate in interface RefreshableMetadataResolver@Nullable public org.joda.time.DateTime getLastRefresh()
getLastRefresh in interface RefreshableMetadataResolver@Nullable public org.joda.time.DateTime getLastSuccessfulRefresh()
getLastSuccessfulRefresh in interface ExtendedRefreshableMetadataResolver@Nullable public Boolean wasLastRefreshSuccess()
wasLastRefreshSuccess in interface ExtendedRefreshableMetadataResolverpublic org.joda.time.DateTime getNextRefresh()
@Duration public long getExpirationWarningThreshold()
@Duration public void setExpirationWarningThreshold(@Duration @Positive long threshold)
threshold - the threshold for logging a warning if live metadata will soon expire@Duration public long getMaxRefreshDelay()
@Duration public void setMaxRefreshDelay(@Duration @Positive long delay)
delay - maximum amount of time, in milliseconds, between refresh intervalspublic float getRefreshDelayFactor()
public void setRefreshDelayFactor(float factor)
factor - delay factor used to compute the next refresh time@Duration public long getMinRefreshDelay()
@Duration public void setMinRefreshDelay(@Duration @Positive long delay)
delay - minimum amount of time, in milliseconds, between refreshesprotected void doDestroy()
doDestroy in class AbstractMetadataResolverprotected void initMetadataResolver()
throws ComponentInitializationException
initMetadataResolver in class AbstractBatchMetadataResolverComponentInitializationException - thrown if there is a problem initializing the providerpublic void refresh()
throws ResolverException
refresh in interface RefreshableMetadataResolverResolverException - thrown is there is a problem retrieving and processing the metadataprivate void logCachedMetadataExpiration(@Nonnull org.joda.time.DateTime now)
now - the current date/timeprotected abstract String getMetadataIdentifier()
protected abstract byte[] fetchMetadata()
throws ResolverException
ResolverException - thrown if there is a problem fetching the metadataprotected org.opensaml.core.xml.XMLObject unmarshallMetadata(byte[] metadataBytes)
throws ResolverException
metadataBytes - raw metadata bytesResolverException - thrown if the metadata can not be unmarshalledprotected void processCachedMetadata(String metadataIdentifier, org.joda.time.DateTime refreshStart) throws ResolverException
metadataIdentifier - identifier of the metadata sourcerefreshStart - when the current refresh cycle startedResolverException - throw is there is a problem process the cached metadataprotected void processNewMetadata(String metadataIdentifier, org.joda.time.DateTime refreshStart, byte[] metadataBytes) throws ResolverException
metadataIdentifier - identifier of the metadata sourcerefreshStart - when the current refresh cycle startedmetadataBytes - raw bytes of the new metadata documentResolverException - thrown if there is a problem unmarshalling or filtering the new metadataprotected void processPreExpiredMetadata(String metadataIdentifier, org.joda.time.DateTime refreshStart, byte[] metadataBytes, org.opensaml.core.xml.XMLObject metadata)
AbstractMetadataResolver.isValid(XMLObject) method.metadataIdentifier - identifier of the metadata sourcerefreshStart - when the current refresh cycle startedmetadataBytes - raw bytes of the new metadata documentmetadata - new metadata document unmarshalledprotected void processNonExpiredMetadata(String metadataIdentifier, org.joda.time.DateTime refreshStart, byte[] metadataBytes, org.opensaml.core.xml.XMLObject metadata) throws ResolverException
AbstractMetadataResolver.isValid(XMLObject) method.metadataIdentifier - identifier of the metadata sourcerefreshStart - when the current refresh cycle startedmetadataBytes - raw bytes of the new metadata documentmetadata - new metadata document unmarshalledResolverException - thrown if there s a problem processing the metadataprotected void postProcessMetadata(byte[] metadataBytes,
Document metadataDom,
org.opensaml.core.xml.XMLObject originalMetadata,
org.opensaml.core.xml.XMLObject filteredMetadata)
throws ResolverException
XMLObject) but before the metadata is saved off. Any exception thrown by this hook will cause the
retrieved metadata to be discarded.
The default implementation of this method is a no-opmetadataBytes - original raw metadata bytes retrieved via fetchMetadata()metadataDom - original metadata after it has been parsed in to a DOM documentoriginalMetadata - original metadata prior to being filtered, with its DOM releasedfilteredMetadata - metadata after it has been run through all registered filters and its DOM releasedResolverException - thrown if there is a problem with the provided dataprotected long computeNextRefreshDelay(org.joda.time.DateTime expectedExpiration)
expectedExpiration - the time when the metadata is expected to expire and need refreshingprotected byte[] inputstreamToByteArray(InputStream ins) throws ResolverException
ins - input stream to convertResolverException - thrown if there is a problem reading the resultant byte arrayCopyright © 1999–2019 Shibboleth Consortium. All rights reserved.