public abstract class AbstractReloadingMetadataResolver extends AbstractBatchMetadataResolver implements RefreshableMetadataResolver
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.AbstractBatchMetadataResolver.BatchEntityBackingStore
AbstractMetadataResolver.EntityBackingStore
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.
|
org.joda.time.DateTime |
getLastRefresh()
Gets the time the last refresh cycle occurred.
|
org.joda.time.DateTime |
getLastUpdate()
Get the time that the currently available metadata was last updated.
|
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.
|
protected void |
postProcessMetadata(byte[] metadataBytes,
Document metadataDom,
XMLObject originalMetadata,
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,
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,
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 |
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 XMLObject |
unmarshallMetadata(byte[] metadataBytes)
Unmarshalls the given metadata bytes.
|
createNewBackingStore, getBackingStore, getCachedFilteredMetadata, getCachedOriginalMetadata, isCacheSourceMetadata, iterator, preProcessNewMetadata, resolve
doInitialize, filterMetadata, getMetadataFilter, getParserPool, getUnmarshallerFactory, indexEntityDescriptor, isFailFastInitialization, isRequireValidMetadata, isValid, lookupEntityID, lookupIndexedEntityID, preProcessEntitiesDescriptor, preProcessEntityDescriptor, releaseMetadataDOM, removeByEntityID, resolveSingle, setBackingStore, setFailFastInitialization, setMetadataFilter, setParserPool, setRequireValidMetadata, unmarshallMetadata
setId
getId
destroy, initialize, isDestroyed, isInitialized
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getMetadataFilter, isRequireValidMetadata, setMetadataFilter, setRequireValidMetadata
resolve, resolveSingle
getId
forEach, spliterator
protected AbstractReloadingMetadataResolver()
protected void setCacheSourceMetadata(boolean flag)
setCacheSourceMetadata
in class AbstractBatchMetadataResolver
flag
- true if source should be cached, false otherwisepublic org.joda.time.DateTime getExpirationTime()
@Nullable public org.joda.time.DateTime getLastUpdate()
RefreshableMetadataResolver.getLastRefresh()
is the metadata was known not to have changed during the last refresh
cycle.getLastUpdate
in interface RefreshableMetadataResolver
@Nullable public org.joda.time.DateTime getLastRefresh()
getLastRefresh
in interface RefreshableMetadataResolver
public org.joda.time.DateTime getNextRefresh()
public long getMaxRefreshDelay()
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 timepublic long getMinRefreshDelay()
public void setMinRefreshDelay(@Duration @Positive long delay)
delay
- minimum amount of time, in milliseconds, between refreshesprotected void doDestroy()
doDestroy
in class AbstractMetadataResolver
protected void initMetadataResolver() throws net.shibboleth.utilities.java.support.component.ComponentInitializationException
initMetadataResolver
in class AbstractBatchMetadataResolver
net.shibboleth.utilities.java.support.component.ComponentInitializationException
- thrown if there is a problem initializing the providerpublic void refresh() throws net.shibboleth.utilities.java.support.resolver.ResolverException
refresh
in interface RefreshableMetadataResolver
net.shibboleth.utilities.java.support.resolver.ResolverException
- thrown is there is a problem retrieving and processing the metadataprotected abstract String getMetadataIdentifier()
protected abstract byte[] fetchMetadata() throws net.shibboleth.utilities.java.support.resolver.ResolverException
net.shibboleth.utilities.java.support.resolver.ResolverException
- thrown if there is a problem fetching the metadataprotected XMLObject unmarshallMetadata(byte[] metadataBytes) throws net.shibboleth.utilities.java.support.resolver.ResolverException
metadataBytes
- raw metadata bytesnet.shibboleth.utilities.java.support.resolver.ResolverException
- thrown if the metadata can not be unmarshalledprotected void processCachedMetadata(String metadataIdentifier, org.joda.time.DateTime refreshStart) throws net.shibboleth.utilities.java.support.resolver.ResolverException
metadataIdentifier
- identifier of the metadata sourcerefreshStart
- when the current refresh cycle startednet.shibboleth.utilities.java.support.resolver.ResolverException
- throw is there is a problem process the cached metadataprotected void processNewMetadata(String metadataIdentifier, org.joda.time.DateTime refreshStart, byte[] metadataBytes) throws net.shibboleth.utilities.java.support.resolver.ResolverException
metadataIdentifier
- identifier of the metadata sourcerefreshStart
- when the current refresh cycle startedmetadataBytes
- raw bytes of the new metadata documentnet.shibboleth.utilities.java.support.resolver.ResolverException
- thrown if there is a problem unmarshalling or filtering the new metadataprotected void processPreExpiredMetadata(String metadataIdentifier, org.joda.time.DateTime refreshStart, byte[] metadataBytes, 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, XMLObject metadata) throws net.shibboleth.utilities.java.support.resolver.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 unmarshallednet.shibboleth.utilities.java.support.resolver.ResolverException
- thrown if there s a problem processing the metadataprotected void postProcessMetadata(byte[] metadataBytes, Document metadataDom, XMLObject originalMetadata, XMLObject filteredMetadata) throws net.shibboleth.utilities.java.support.resolver.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 releasednet.shibboleth.utilities.java.support.resolver.ResolverException
- 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 net.shibboleth.utilities.java.support.resolver.ResolverException
ins
- input stream to convertnet.shibboleth.utilities.java.support.resolver.ResolverException
- thrown if there is a problem reading the resultant byte arrayCopyright © 2019. All rights reserved.