org.opensaml.saml2.metadata.provider
Class FileBackedURLMetadataProvider
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.URLMetadataProvider
org.opensaml.saml2.metadata.provider.FileBackedURLMetadataProvider
- All Implemented Interfaces:
- MetadataProvider, ObservableMetadataProvider
public class FileBackedURLMetadataProvider
- extends URLMetadataProvider
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.
Constructor Summary |
FileBackedURLMetadataProvider(java.lang.String metadataURL,
int requestTimeout,
java.lang.String backingFilePath)
Constructor. |
Methods inherited from class org.opensaml.saml2.metadata.provider.URLMetadataProvider |
cacheMetadata, getMaxCacheDuration, getMetadata, getMetadataURI, getRequestTimeout, initialize, maintainExpiredMetadata, refreshMetadata, setBasicCredentials, setMaintainExpiredMetadata, setMaxCacheDuration, setMetadataFilter, setSocketFactory |
Methods inherited from class org.opensaml.saml2.metadata.provider.AbstractMetadataProvider |
clearDescriptorIndex, filterMetadata, getEntitiesDescriptor, getEntitiesDescriptorByName, getEntityDescriptor, getEntityDescriptorById, getEntityDescriptorById, getParserPool, getRole, getRole, isValid, releaseMetadataDOM, setParserPool, unmarshallMetadata |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FileBackedURLMetadataProvider
public FileBackedURLMetadataProvider(java.lang.String metadataURL,
int requestTimeout,
java.lang.String backingFilePath)
throws MetadataProviderException
- Constructor.
- Parameters:
metadataURL
- the URL to fetch the metadatarequestTimeout
- the time, in milliseconds, to wait for the metadata server to respondbackingFilePath
- 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
fetchMetadata
protected XMLObject fetchMetadata()
throws java.io.IOException,
UnmarshallingException
- Fetches the metadata from the remote server or from the local filesystem if it can not be retrieved remotely.
- Overrides:
fetchMetadata
in class URLMetadataProvider
- Returns:
- the unmarshalled metadata
- Throws:
java.io.IOException
- thrown if the metadata can not be fetched from the remote server or local filesystems
UnmarshallingException
- thrown if the metadata can not be unmarshalled
getLocalMetadata
protected XMLObject getLocalMetadata()
throws java.io.IOException,
UnmarshallingException
- Reads filtered metadata from the backup file.
- Returns:
- cached copy of the metadata read from disk
- Throws:
java.io.IOException
- thrown if the metadata can not be read from disk
UnmarshallingException
- thrown if the metadata, read from disk, can not be unmarshalled
writeMetadataToFile
protected void writeMetadataToFile(XMLObject metadata)
throws MetadataProviderException
- Writes the currently cached metadata to file.
- Parameters:
metadata
- metadata to write to disk
- Throws:
MetadataProviderException
- thrown if metadata can not be written to disk