org.opensaml.saml2.metadata.provider
Class FileBackedHTTPMetadataProvider
java.lang.Object
org.opensaml.saml2.metadata.provider.BaseMetadataProvider
org.opensaml.saml2.metadata.provider.AbstractMetadataProvider
org.opensaml.saml2.metadata.provider.AbstractObservableMetadataProvider
org.opensaml.saml2.metadata.provider.AbstractReloadingMetadataProvider
org.opensaml.saml2.metadata.provider.HTTPMetadataProvider
org.opensaml.saml2.metadata.provider.FileBackedHTTPMetadataProvider
- All Implemented Interfaces:
- MetadataProvider, ObservableMetadataProvider
public class FileBackedHTTPMetadataProvider
- extends HTTPMetadataProvider
A URL metadata provider that caches a copy of the retrieved metadata to disk so that, in the event that the metadata
may not be pulled from the URL it may be pulled from disk using the last fetched data. If the backing file does not
already exist it will be created.
It is the responsibility of the caller to re-initialize, via AbstractMetadataProvider.initialize()
, if any properties of this
provider are changed.
Method Summary |
protected byte[] |
fetchMetadata()
Gets the metadata document from the remote server. |
protected void |
postProcessMetadata(byte[] metadataBytes,
Document metadataDom,
org.opensaml.xml.XMLObject metadata)
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 |
setBackupFile(String backupFilePath)
Sets the file used to backup metadata. |
Methods inherited from class org.opensaml.saml2.metadata.provider.HTTPMetadataProvider |
buildGetMethod, getMaxCacheDuration, getMetadataBytesFromResponse, getMetadataIdentifier, getMetadataURI, getRequestTimeout, maintainExpiredMetadata, processConditionalRetrievalHeaders, setBasicCredentials, setMaintainExpiredMetadata, setMaxCacheDuration, setSocketFactory |
Methods inherited from class org.opensaml.saml2.metadata.provider.AbstractReloadingMetadataProvider |
computeNextRefreshDelay, doGetMetadata, doInitialization, getExpirationTime, getLastRefresh, getLastUpdate, getMaxRefreshDelay, getMinRefreshDelay, getNextRefresh, getRefreshDelayFactor, inputstreamToByteArray, processCachedMetadata, processNewMetadata, processNonExpiredMetadata, processPreExpiredMetadata, refresh, setMaxRefreshDelay, setMinRefreshDelay, setRefreshDelayFactor, unmarshallMetadata |
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FileBackedHTTPMetadataProvider
@Deprecated
public FileBackedHTTPMetadataProvider(String metadataURL,
int requestTimeout,
String backupFilePath)
throws MetadataProviderException
- Deprecated.
- Constructor.
- Parameters:
metadataURL
- the URL to fetch the metadatarequestTimeout
- the time, in milliseconds, to wait for the metadata server to respondbackupFilePath
- the file that will keep a backup copy of the metadata,
- Throws:
MetadataProviderException
- thrown if the URL is not a valid URL, the metadata can not be retrieved from
the URL, the given file can not be created or written to
FileBackedHTTPMetadataProvider
public FileBackedHTTPMetadataProvider(Timer backgroundTaskTimer,
org.apache.commons.httpclient.HttpClient client,
String metadataURL,
String backupFilePath)
throws MetadataProviderException
- Constructor.
- Parameters:
client
- HTTP client used to fetch remove metadatabackgroundTaskTimer
- timer used to schedule background metadata refresh tasksmetadataURL
- the URL to fetch the metadatabackupFilePath
- the file that will keep a backup copy of the metadata,
- Throws:
MetadataProviderException
- thrown if the URL is not a valid URL, the metadata can not be retrieved from
the URL, the given file can not be created or written to
setBackupFile
protected void setBackupFile(String backupFilePath)
throws MetadataProviderException
- Sets the file used to backup metadata. The given file path is checked to see if it is a read/writable file if it
exists or if can be created if it does not exist.
- Parameters:
backupFilePath
- path to the backup file
- Throws:
MetadataProviderException
- thrown if the backup file is not read/writable or creatable
fetchMetadata
protected byte[] fetchMetadata()
throws MetadataProviderException
- Gets the metadata document from the remote server.
- Overrides:
fetchMetadata
in class HTTPMetadataProvider
- Returns:
- the metadata from remote server, or null if the metadata document has not changed since the last
retrieval
- Throws:
MetadataProviderException
- thrown if there is a problem retrieving the metadata from the remote server
postProcessMetadata
protected void postProcessMetadata(byte[] metadataBytes,
Document metadataDom,
org.opensaml.xml.XMLObject metadata)
throws MetadataProviderException
- 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. Any exception thrown by this hook will cause the
retrieved metadata to be discarded.
The default implementation of this method is a no-op
- Overrides:
postProcessMetadata
in class AbstractReloadingMetadataProvider
- Parameters:
metadataBytes
- raw metadata bytes retrieved via AbstractReloadingMetadataProvider.fetchMetadata()
metadataDom
- metadata after it has been parsed in to a DOM documentmetadata
- metadata after it has been run through all registered filters and its DOM released
- Throws:
MetadataProviderException
- thrown if there is a problem with the provided data
Copyright © 2006-2012 Internet2. All Rights Reserved.