Package org.opensaml.saml.metadata.resolver.impl

# Class FilesystemMetadataResolver

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent
org.opensaml.saml.metadata.resolver.impl.AbstractMetadataResolver
org.opensaml.saml.metadata.resolver.impl.AbstractBatchMetadataResolver
org.opensaml.saml.metadata.resolver.impl.AbstractReloadingMetadataResolver
org.opensaml.saml.metadata.resolver.impl.FilesystemMetadataResolver

All Implemented Interfaces:
  `Iterable<EntityDescriptor>`, `Component`, `DestructableComponent`, `IdentifiableComponent`, `IdentifiedComponent`, `InitializableComponent`, `Resolver<EntityDescriptor,CriteriaSet>`, `IterableMetadataSource`, `BatchMetadataResolver`, `MetadataResolver`, `RefreshableMetadataResolver`

public class FilesystemMetadataResolver extends AbstractReloadingMetadataResolver
A metadata provider that pulls metadata from a file on the local filesystem. This metadata provider periodically checks to see if the read metadata file has changed. The delay between each refresh interval is calculated as follows. If no validUntil or cacheDuration is present then the `AbstractReloadingMetadataResolver.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 `AbstractReloadingMetadataResolver.getMaxRefreshDelay()` is used. If that number is smaller than the min refresh delay then `AbstractReloadingMetadataResolver.getMinRefreshDelay()` is used. Otherwise the calculated refresh delay multiplied by `AbstractReloadingMetadataResolver.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.

## Nested Class Summary

## Nested classes/interfaces inherited from class org.opensaml.saml.metadata.resolver.impl.AbstractBatchMetadataResolver

`AbstractBatchMetadataResolver.BatchEntityBackingStore`

## Nested classes/interfaces inherited from class org.opensaml.saml.metadata.resolver.impl.AbstractMetadataResolver

`AbstractMetadataResolver.EntityBackingStore`

## Field Summary

Fields
Modifier and Type
Field
Description
`private final org.slf4j.Logger`
`log`
Class logger.
`private File`
`metadataFile`
The metadata file.

### Fields inherited from class org.opensaml.saml.metadata.resolver.impl.AbstractReloadingMetadataResolver

`METRIC_TIMER_REFRESH`

## Constructor Summary

Constructors
Constructor
Description
`FilesystemMetadataResolver(File file)`
Constructor.
`FilesystemMetadataResolver(Timer backgroundTaskTimer, File file)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`protected void`
`doDestroy()`
`protected byte[]`
`fetchMetadata()`
Fetches metadata from a source.
`protected String`
`getMetadataIdentifier()`
Gets an identifier which may be used to distinguish this metadata in logging statements.
`protected void`
`setMetadataFile(File file)`
Sets the file from which metadata is read.
`protected void`
`validateMetadataFile(File file)`
Validate the basic properties of the specified metadata file, for example that it exists; that it is a file; and that it is readable.

### Methods inherited from class org.opensaml.saml.metadata.resolver.impl.AbstractReloadingMetadataResolver

`computeNextRefreshDelay, getExpirationTime, getExpirationWarningThreshold, getLastFailureCause, getLastRefresh, getLastSuccessfulRefresh, getLastUpdate, getMaxRefreshDelay, getMinRefreshDelay, getNextRefresh, getRefreshDelayFactor, initMetadataResolver, inputstreamToByteArray, postProcessMetadata, processCachedMetadata, processNewMetadata, processNonExpiredMetadata, processPreExpiredMetadata, refresh, setCacheSourceMetadata, setExpirationWarningThreshold, setMaxRefreshDelay, setMinRefreshDelay, setRefreshDelayFactor, unmarshallMetadata, wasLastRefreshSuccess`

### Methods inherited from class org.opensaml.saml.metadata.resolver.impl.AbstractBatchMetadataResolver

`createNewBackingStore, doResolve, ensureBackingStore, getCachedFilteredMetadata, getCachedOriginalMetadata, getIndexes, getRootValidUntil, indexEntityDescriptor, isCacheSourceMetadata, isResolveViaPredicatesOnly, isRootValid, iterator, lookupByIndexes, preProcessNewMetadata, setIndexes, setResolveViaPredicatesOnly`

### Methods inherited from class org.opensaml.saml.metadata.resolver.impl.AbstractMetadataResolver

`doInitialize, filterMetadata, getActivationCondition, getBackingStore, getCriterionPredicateRegistry, getLogPrefix, getMetadataFilter, getMetricsBaseName, getParserPool, getType, getUnmarshallerFactory, isFailFastInitialization, isRequireValidMetadata, isSatisfyAnyPredicates, isUseDefaultPredicateRegistry, isValid, lookupEntityID, lookupIndexedEntityID, newFilterContext, predicateFilterCandidates, preProcessEntitiesDescriptor, preProcessEntityDescriptor, releaseMetadataDOM, removeByEntityID, resolve, resolveSingle, setActivationCondition, setBackingStore, setCriterionPredicateRegistry, setFailFastInitialization, setMetadataFilter, setMetricsBaseName, setParserPool, setRequireValidMetadata, setSatisfyAnyPredicates, setType, setUseDefaultPredicateRegistry, unmarshallMetadata`

### Methods inherited from class net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent

`setId`

### Methods inherited from class net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent

`ensureId, getId, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException`

### Methods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent

`checkComponentActive, checkSetterPreconditions, destroy, 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.shared.component.IdentifiedComponent

`getId`

### Methods inherited from interface java.lang.Iterable

`forEach, spliterator`

### Methods inherited from interface org.opensaml.saml.metadata.resolver.MetadataResolver

`getMetadataFilter, getType, isRequireValidMetadata, setMetadataFilter, setRequireValidMetadata`

### Methods inherited from interface net.shibboleth.shared.resolver.Resolver

`resolve, resolveSingle`

## Field Details

### log

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

### metadataFile

@NonnullAfterInit private File metadataFile
The metadata file.

## Constructor Details

### FilesystemMetadataResolver

public FilesystemMetadataResolver(@Nonnull File file) throws ResolverException
Constructor.

Parameters:
  `file` - the metadata file
Throws:
  `ResolverException` - this exception is no longer thrown

### FilesystemMetadataResolver

public FilesystemMetadataResolver(@Nullable Timer backgroundTaskTimer, @Nonnull File file) throws ResolverException
Constructor.

Parameters:
  `file` - the metadata file
  `backgroundTaskTimer` - timer used to refresh metadata in the background
Throws:
  `ResolverException` - this exception is no longer thrown

## Method Details

### setMetadataFile

protected void setMetadataFile(@Nonnull File file) throws ResolverException
Sets the file from which metadata is read.

Parameters:
  `file` - path to the metadata file
Throws:
  `ResolverException` - this exception is no longer thrown

### doDestroy

protected void doDestroy()

Overrides:
  `doDestroy` in class `AbstractReloadingMetadataResolver`

### getMetadataIdentifier

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

Specified by:
  `getMetadataIdentifier` in class `AbstractReloadingMetadataResolver`
Returns:
  identifier which may be used to distinguish this metadata in logging statements

### fetchMetadata

@Nullable protected byte[] fetchMetadata() throws ResolverException
Fetches metadata from a source.

Specified by:
  `fetchMetadata` in class `AbstractReloadingMetadataResolver`
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

### validateMetadataFile

protected void validateMetadataFile(@Nonnull File file) throws ResolverException
Validate the basic properties of the specified metadata file, for example that it exists; that it is a file; and that it is readable.

Parameters:
  `file` - the file to evaluate
Throws:
  `ResolverException` - if file does not pass basic properties required of a metadata file