Class FilesystemMetadataResolver

  • All Implemented Interfaces:
    Iterable<org.opensaml.saml.saml2.metadata.EntityDescriptor>, net.shibboleth.utilities.java.support.component.Component, net.shibboleth.utilities.java.support.component.DestructableComponent, net.shibboleth.utilities.java.support.component.IdentifiableComponent, net.shibboleth.utilities.java.support.component.IdentifiedComponent, net.shibboleth.utilities.java.support.component.InitializableComponent, net.shibboleth.utilities.java.support.resolver.Resolver<org.opensaml.saml.saml2.metadata.EntityDescriptor,​net.shibboleth.utilities.java.support.resolver.CriteriaSet>, org.opensaml.saml.metadata.IterableMetadataSource, org.opensaml.saml.metadata.resolver.BatchMetadataResolver, org.opensaml.saml.metadata.resolver.MetadataResolver, org.opensaml.saml.metadata.resolver.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.
    • Field Detail

      • log

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

        @Nonnull
        private File metadataFile
        The metadata file.
    • Constructor Detail

      • FilesystemMetadataResolver

        public FilesystemMetadataResolver​(@Nonnull
                                          File metadata)
                                   throws net.shibboleth.utilities.java.support.resolver.ResolverException
        Constructor.
        Parameters:
        metadata - the metadata file
        Throws:
        net.shibboleth.utilities.java.support.resolver.ResolverException - this exception is no longer thrown
      • FilesystemMetadataResolver

        public FilesystemMetadataResolver​(@Nullable
                                          Timer backgroundTaskTimer,
                                          @Nonnull
                                          File metadata)
                                   throws net.shibboleth.utilities.java.support.resolver.ResolverException
        Constructor.
        Parameters:
        metadata - the metadata file
        backgroundTaskTimer - timer used to refresh metadata in the background
        Throws:
        net.shibboleth.utilities.java.support.resolver.ResolverException - this exception is no longer thrown
    • Method Detail

      • setMetadataFile

        protected void setMetadataFile​(@Nonnull
                                       File file)
                                throws net.shibboleth.utilities.java.support.resolver.ResolverException
        Sets the file from which metadata is read.
        Parameters:
        file - path to the metadata file
        Throws:
        net.shibboleth.utilities.java.support.resolver.ResolverException - this exception is no longer thrown
      • getMetadataIdentifier

        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

        protected byte[] fetchMetadata()
                                throws net.shibboleth.utilities.java.support.resolver.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:
        net.shibboleth.utilities.java.support.resolver.ResolverException - thrown if there is a problem fetching the metadata
      • validateMetadataFile

        protected void validateMetadataFile​(@Nonnull
                                            File file)
                                     throws net.shibboleth.utilities.java.support.resolver.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:
        net.shibboleth.utilities.java.support.resolver.ResolverException - if file does not pass basic properties required of a metadata file