org.opensaml.saml2.metadata.provider
Class HTTPMetadataProvider

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.HTTPMetadataProvider
All Implemented Interfaces:
MetadataProvider, ObservableMetadataProvider
Direct Known Subclasses:
FileBackedHTTPMetadataProvider

public class HTTPMetadataProvider
extends AbstractObservableMetadataProvider

A metadata provider that pulls metadata using an HTTP GET. Metadata is cached until one of these criteria is met:

Metadata is filtered prior to determining the cache expiration data. This allows a filter to remove XMLObjects that may effect the cache duration but for which the user of this provider does not care about. It is the responsibility of the caller to re-initialize, via initialize(), if any properties of this provider are changed.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.opensaml.saml2.metadata.provider.ObservableMetadataProvider
ObservableMetadataProvider.Observer
 
Field Summary
 
Fields inherited from class org.opensaml.saml2.metadata.provider.BaseMetadataProvider
unmarshallerFactory
 
Constructor Summary
HTTPMetadataProvider(java.lang.String metadataURL, int requestTimeout)
          Constructor.
 
Method Summary
protected  void cacheMetadata(org.opensaml.xml.XMLObject metadata)
          Caches the metadata.
protected  org.opensaml.xml.XMLObject fetchMetadata()
          Fetches the metadata from the remote server and unmarshalls it.
 int getMaxCacheDuration()
          Gets the maximum amount of time, in seconds, metadata will be cached for.
 org.opensaml.xml.XMLObject getMetadata()
          Gets the entire metadata tree, after the registered filter has been applied.
 java.lang.String getMetadataURI()
          Gets the URL to fetch the metadata.
 int getRequestTimeout()
          Gets the length of time in milliseconds to wait for the server to respond.
 void initialize()
          Initializes the provider and prepares it for use.
 boolean maintainExpiredMetadata()
          Gets whether cached metadata should be discarded if it expires and can not be refreshed.
protected  void refreshMetadata()
          Refreshes the metadata cache.
 void setBasicCredentials(java.lang.String username, java.lang.String password)
          Sets the username and password used to access the metadata URL.
 void setMaintainExpiredMetadata(boolean maintain)
          Sets whether cached metadata should be discarded if it expires and can not be refreshed.
 void setMaxCacheDuration(int newDuration)
          Sets the maximum amount of time, in seconds, metadata will be cached for.
 void setSocketFactory(org.apache.commons.httpclient.protocol.ProtocolSocketFactory newSocketFactory)
          Sets the socket factory used to create sockets to the HTTP server.
 
Methods inherited from class org.opensaml.saml2.metadata.provider.AbstractObservableMetadataProvider
emitChangeEvent, getObservers
 
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 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, getMetadataFilter, getRole, getRole, requireValidMetadata, setMetadataFilter, setRequireValidMetadata
 

Constructor Detail

HTTPMetadataProvider

public HTTPMetadataProvider(java.lang.String metadataURL,
                            int requestTimeout)
                     throws MetadataProviderException
Constructor.

Parameters:
metadataURL - the URL to fetch the metadata
requestTimeout - the time, in milliseconds, to wait for the metadata server to respond
Throws:
MetadataProviderException - thrown if the URL is not a valid URL or the metadata can not be retrieved from the URL
Method Detail

initialize

public void initialize()
                throws MetadataProviderException
Initializes the provider and prepares it for use.

Throws:
MetadataProviderException - thrown if there is a problem fetching, parsing, or processing the metadata

getMetadataURI

public java.lang.String getMetadataURI()
Gets the URL to fetch the metadata.

Returns:
the URL to fetch the metadata

maintainExpiredMetadata

public boolean maintainExpiredMetadata()
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)
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

setBasicCredentials

public void setBasicCredentials(java.lang.String username,
                                java.lang.String password)
Sets the username and password used to access the metadata URL. To disable BASIC authentication set the username and password to null;

Parameters:
username - the username
password - the password

getRequestTimeout

public int getRequestTimeout()
Gets the length of time in milliseconds to wait for the server to respond.

Returns:
length of time in milliseconds to wait for the server to respond

setSocketFactory

public void setSocketFactory(org.apache.commons.httpclient.protocol.ProtocolSocketFactory newSocketFactory)
Sets the socket factory used to create sockets to the HTTP server.

Parameters:
newSocketFactory - the socket factory used to produce sockets used to connect to the server
See Also:
HTTPClient SSL guide

getMaxCacheDuration

public int getMaxCacheDuration()
Gets the maximum amount of time, in seconds, metadata will be cached for.

Returns:
the maximum amount of time metadata will be cached for

setMaxCacheDuration

public void setMaxCacheDuration(int newDuration)
Sets the maximum amount of time, in seconds, metadata will be cached for.

Parameters:
newDuration - the maximum amount of time metadata will be cached for

getMetadata

public org.opensaml.xml.XMLObject getMetadata()
                                       throws MetadataProviderException
Gets the entire metadata tree, after the registered filter has been applied.

Returns:
the entire metadata tree
Throws:
MetadataProviderException - thrown if the provider can not fetch the metadata

cacheMetadata

protected void cacheMetadata(org.opensaml.xml.XMLObject metadata)
Caches the metadata.

Parameters:
metadata - metadata to cache

refreshMetadata

protected void refreshMetadata()
                        throws MetadataProviderException
Refreshes the metadata cache. Metadata is fetched from the URL through an HTTP get, unmarshalled, and then filtered. This method also clears out the entity ID to entity descriptor cache.

Throws:
MetadataProviderException - thrown if the metadata can not be read, unmarshalled, and filtered

fetchMetadata

protected org.opensaml.xml.XMLObject fetchMetadata()
                                            throws java.io.IOException,
                                                   org.opensaml.xml.io.UnmarshallingException
Fetches the metadata from the remote server and unmarshalls it.

Returns:
the unmarshalled metadata
Throws:
java.io.IOException - thrown if the metadata can not be fetched from the remote server
org.opensaml.xml.io.UnmarshallingException - thrown if the metadata can not be unmarshalled


Copyright © 2006-2009 Internet2. All Rights Reserved.