org.opensaml.saml2.metadata.provider
Class FilesystemMetadataProvider

java.lang.Object
  extended by org.opensaml.saml2.metadata.provider.BaseMetadataProvider
      extended by org.opensaml.saml2.metadata.provider.AbstractMetadataProvider
          extended by org.opensaml.saml2.metadata.provider.AbstractObservableMetadataProvider
              extended by org.opensaml.saml2.metadata.provider.AbstractReloadingMetadataProvider
                  extended by org.opensaml.saml2.metadata.provider.FilesystemMetadataProvider
All Implemented Interfaces:
MetadataProvider, ObservableMetadataProvider

public class FilesystemMetadataProvider
extends AbstractReloadingMetadataProvider

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 AbstractReloadingMetadataProvider.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 AbstractReloadingMetadataProvider.getMaxRefreshDelay() is used. If that number is smaller than the min refresh delay then AbstractReloadingMetadataProvider.getMinRefreshDelay() is used. Otherwise the calculated refresh delay multiplied by AbstractReloadingMetadataProvider.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 interface org.opensaml.saml2.metadata.provider.ObservableMetadataProvider
ObservableMetadataProvider.Observer
 
Field Summary
private  org.slf4j.Logger log
          Class logger.
private  File metadataFile
          The metadata file.
 
Fields inherited from class org.opensaml.saml2.metadata.provider.BaseMetadataProvider
unmarshallerFactory
 
Constructor Summary
FilesystemMetadataProvider(File metadata)
          Constructor.
FilesystemMetadataProvider(Timer backgroundTaskTimer, File metadata)
          Constructor.
 
Method Summary
 void destroy()
          Destroys the metadata provider and frees any resources current held by it.
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.
 boolean maintainExpiredMetadata()
          Deprecated. use BaseMetadataProvider.requireValidMetadata() instead
 void setMaintainExpiredMetadata(boolean maintain)
          Deprecated. use BaseMetadataProvider.setRequireValidMetadata(boolean) instead
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.saml2.metadata.provider.AbstractReloadingMetadataProvider
computeNextRefreshDelay, doGetMetadata, doInitialization, getExpirationTime, getLastRefresh, getLastUpdate, getMaxRefreshDelay, getMinRefreshDelay, getNextRefresh, getRefreshDelayFactor, inputstreamToByteArray, postProcessMetadata, processCachedMetadata, processNewMetadata, processNonExpiredMetadata, processPreExpiredMetadata, refresh, setMaxRefreshDelay, setMinRefreshDelay, setRefreshDelayFactor, unmarshallMetadata
 
Methods inherited from class org.opensaml.saml2.metadata.provider.AbstractObservableMetadataProvider
emitChangeEvent, getObservers
 
Methods inherited from class org.opensaml.saml2.metadata.provider.AbstractMetadataProvider
clearDescriptorIndex, doGetEntitiesDescriptor, doGetEntityDescriptor, doGetRole, doGetRole, filterMetadata, getEntitiesDescriptor, getEntitiesDescriptorByName, getEntityDescriptor, getEntityDescriptorById, getEntityDescriptorById, getMetadata, getParserPool, getRole, getRole, initialize, isFailFastInitialization, isInitialized, isValid, releaseMetadataDOM, setFailFastInitialization, setInitialized, setParserPool, unmarshallMetadata
 
Methods inherited from class org.opensaml.saml2.metadata.provider.BaseMetadataProvider
getMetadataFilter, requireValidMetadata, setMetadataFilter, setRequireValidMetadata
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.opensaml.saml2.metadata.provider.MetadataProvider
getEntitiesDescriptor, getEntityDescriptor, getMetadata, getMetadataFilter, getRole, getRole, requireValidMetadata, setMetadataFilter, setRequireValidMetadata
 

Field Detail

log

private final org.slf4j.Logger log
Class logger.


metadataFile

private File metadataFile
The metadata file.

Constructor Detail

FilesystemMetadataProvider

public FilesystemMetadataProvider(File metadata)
                           throws MetadataProviderException
Constructor.

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

FilesystemMetadataProvider

public FilesystemMetadataProvider(Timer backgroundTaskTimer,
                                  File metadata)
                           throws MetadataProviderException
Constructor.

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

setMetadataFile

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

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

maintainExpiredMetadata

public boolean maintainExpiredMetadata()
Deprecated. use BaseMetadataProvider.requireValidMetadata() instead

Gets whether cached metadata should be discarded if it expires and can not be refreshed.

Returns:
whether cached metadata should be discarded if it expires and can not be refreshed.

setMaintainExpiredMetadata

public void setMaintainExpiredMetadata(boolean maintain)
Deprecated. use BaseMetadataProvider.setRequireValidMetadata(boolean) instead

Sets whether cached metadata should be discarded if it expires and can not be refreshed.

Parameters:
maintain - whether cached metadata should be discarded if it expires and can not be refreshed.

destroy

public void destroy()
Destroys the metadata provider and frees any resources current held by it. Default method is a no-op.

Overrides:
destroy in class AbstractReloadingMetadataProvider

getMetadataIdentifier

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

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

fetchMetadata

protected byte[] fetchMetadata()
                        throws MetadataProviderException
Fetches metadata from a source.

Specified by:
fetchMetadata in class AbstractReloadingMetadataProvider
Returns:
the fetched metadata, or null if the metadata is known not to have changed since the last retrieval
Throws:
MetadataProviderException - thrown if there is a problem fetching the metadata

validateMetadataFile

protected void validateMetadataFile(File file)
                             throws MetadataProviderException
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:
MetadataProviderException - if file does not pass basic properties required of a metadata file


Copyright © 1999-2013. All Rights Reserved.