org.opensaml.saml2.metadata.provider
Class ChainingMetadataProvider

java.lang.Object
  extended by org.opensaml.saml2.metadata.provider.BaseMetadataProvider
      extended by org.opensaml.saml2.metadata.provider.ChainingMetadataProvider
All Implemented Interfaces:
MetadataProvider, ObservableMetadataProvider

public class ChainingMetadataProvider
extends BaseMetadataProvider
implements ObservableMetadataProvider

A metadata provider that uses registered providers, in turn, to answer queries. When searching for entity specific information (entity metadata, roles, etc.) the entity descriptor used is the first non-null descriptor found while iterating over the registered providers in insertion order. This chaining provider implements observation by registering an observer with each contained provider. When the contained provider emits a change this provider will also emit a change to observers registered with it. As such, developers should be careful not to register a the same observer with both container providers and this provider. Doing so will result in an observer being notified twice for each change.


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
ChainingMetadataProvider()
          Constructor.
 
Method Summary
 void addMetadataProvider(MetadataProvider newProvider)
          Adds a metadata provider to the list of registered providers.
protected  void emitChangeEvent()
          Convenience method for calling ObservableMetadataProvider.Observer.onEvent(MetadataProvider) on every registered Observer passing in this provider.
 EntitiesDescriptor getEntitiesDescriptor(java.lang.String name)
          Gets a named EntitiesDescriptor from the metadata.
 EntityDescriptor getEntityDescriptor(java.lang.String entityID)
          Gets the metadata for a given entity if the metadata is valid.
 org.opensaml.xml.XMLObject getMetadata()
          Gets the metadata from every registered provider and places each within a newly created EntitiesDescriptor.
 MetadataFilter getMetadataFilter()
          Gets the metadata filter applied to the metadata.
 java.util.List<ObservableMetadataProvider.Observer> getObservers()
          Gets the list of observers for the provider.
 java.util.List<MetadataProvider> getProviders()
          Gets an immutable the list of currently registered providers.
 java.util.List<RoleDescriptor> getRole(java.lang.String entityID, javax.xml.namespace.QName roleName)
          Gets the role descriptors of a given type for a given entity from valid metadata.
 RoleDescriptor getRole(java.lang.String entityID, javax.xml.namespace.QName roleName, java.lang.String supportedProtocol)
          Gets the role descriptors of a given type for a given entity that support the given protocol from valid metadata.
 void removeMetadataProvider(MetadataProvider provider)
          Removes a metadata provider from the list of registered providers.
 void setMetadataFilter(MetadataFilter newFilter)
          Sets the metadata filter applied to the metadata.
 void setProviders(java.util.List<MetadataProvider> newProviders)
          Replaces the current set of metadata providers with give collection.
 void setRequireValidMetadata(boolean requireValidMetadata)
          Sets whether the metadata returned by queries must be valid.
 
Methods inherited from class org.opensaml.saml2.metadata.provider.BaseMetadataProvider
requireValidMetadata
 
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
requireValidMetadata
 

Constructor Detail

ChainingMetadataProvider

public ChainingMetadataProvider()
Constructor.

Method Detail

getProviders

public java.util.List<MetadataProvider> getProviders()
Gets an immutable the list of currently registered providers.

Returns:
list of currently registered providers

setProviders

public void setProviders(java.util.List<MetadataProvider> newProviders)
                  throws MetadataProviderException
Replaces the current set of metadata providers with give collection.

Parameters:
newProviders - the metadata providers to replace the current providers with
Throws:
MetadataProviderException - thrown if there is a problem adding the metadata provider

addMetadataProvider

public void addMetadataProvider(MetadataProvider newProvider)
                         throws MetadataProviderException
Adds a metadata provider to the list of registered providers.

Parameters:
newProvider - the provider to be added
Throws:
MetadataProviderException - thrown if there is a problem adding the metadata provider

removeMetadataProvider

public void removeMetadataProvider(MetadataProvider provider)
Removes a metadata provider from the list of registered providers.

Parameters:
provider - provider to be removed

setRequireValidMetadata

public void setRequireValidMetadata(boolean requireValidMetadata)
Sets whether the metadata returned by queries must be valid.

Specified by:
setRequireValidMetadata in interface MetadataProvider
Overrides:
setRequireValidMetadata in class BaseMetadataProvider
Parameters:
requireValidMetadata - whether the metadata returned by queries must be valid

getMetadataFilter

public MetadataFilter getMetadataFilter()
Gets the metadata filter applied to the metadata.

Specified by:
getMetadataFilter in interface MetadataProvider
Overrides:
getMetadataFilter in class BaseMetadataProvider
Returns:
the metadata filter applied to the metadata

setMetadataFilter

public void setMetadataFilter(MetadataFilter newFilter)
                       throws MetadataProviderException
Sets the metadata filter applied to the metadata.

Specified by:
setMetadataFilter in interface MetadataProvider
Overrides:
setMetadataFilter in class BaseMetadataProvider
Parameters:
newFilter - the metadata filter applied to the metadata
Throws:
MetadataProviderException - thrown if the provider can not apply the filter to the metadata

getMetadata

public org.opensaml.xml.XMLObject getMetadata()
                                       throws MetadataProviderException
Gets the metadata from every registered provider and places each within a newly created EntitiesDescriptor. Gets the entire metadata tree, after the registered filter has been applied.

Specified by:
getMetadata in interface MetadataProvider
Returns:
the entire metadata tree
Throws:
MetadataProviderException - thrown if the provider can not fetch the metadata

getEntitiesDescriptor

public EntitiesDescriptor getEntitiesDescriptor(java.lang.String name)
                                         throws MetadataProviderException
Gets a named EntitiesDescriptor from the metadata.

Specified by:
getEntitiesDescriptor in interface MetadataProvider
Parameters:
name - the name of the EntitiesDescriptor
Returns:
the EntitiesDescriptor or null
Throws:
MetadataProviderException - thrown if the provider can not fetch the metadata

getEntityDescriptor

public EntityDescriptor getEntityDescriptor(java.lang.String entityID)
                                     throws MetadataProviderException
Gets the metadata for a given entity if the metadata is valid.

Specified by:
getEntityDescriptor in interface MetadataProvider
Parameters:
entityID - the ID of the entity
Returns:
the entity's metadata or null if there is no metadata or no valid metadata
Throws:
MetadataProviderException - thrown if the provider can not fetch the metadata

getRole

public java.util.List<RoleDescriptor> getRole(java.lang.String entityID,
                                              javax.xml.namespace.QName roleName)
                                       throws MetadataProviderException
Gets the role descriptors of a given type for a given entity from valid metadata.

Specified by:
getRole in interface MetadataProvider
Parameters:
entityID - the ID of the entity
roleName - the role type
Returns:
the role descriptors
Throws:
MetadataProviderException - thrown if the provider can not fetch the metadata

getRole

public RoleDescriptor getRole(java.lang.String entityID,
                              javax.xml.namespace.QName roleName,
                              java.lang.String supportedProtocol)
                       throws MetadataProviderException
Gets the role descriptors of a given type for a given entity that support the given protocol from valid metadata.

Specified by:
getRole in interface MetadataProvider
Parameters:
entityID - the ID of the entity
roleName - the role type
supportedProtocol - the protocol supported by the role
Returns:
the role descriptors
Throws:
MetadataProviderException - thrown if the provider can not fetch the metadata

getObservers

public java.util.List<ObservableMetadataProvider.Observer> getObservers()
Gets the list of observers for the provider. New observers may be added to the list or old ones removed.

Specified by:
getObservers in interface ObservableMetadataProvider
Returns:
the list of observers

emitChangeEvent

protected void emitChangeEvent()
Convenience method for calling ObservableMetadataProvider.Observer.onEvent(MetadataProvider) on every registered Observer passing in this provider.



Copyright © 2006-2009 Internet2. All Rights Reserved.