OpenSAML-J 2.4.1-redhat-3

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(String name)
          Gets a valid named EntitiesDescriptor from the metadata.
 EntityDescriptor getEntityDescriptor(String entityID)
          Gets the valid metadata for a given entity.
 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.
 List<ObservableMetadataProvider.Observer> getObservers()
          Gets the list of observers for the provider.
 List<MetadataProvider> getProviders()
          Gets an immutable the list of currently registered providers.
 List<RoleDescriptor> getRole(String entityID, QName roleName)
          Gets the valid role descriptors of a given type for a given entity.
 RoleDescriptor getRole(String entityID, QName roleName, String supportedProtocol)
          Gets the valid role descriptors of a given type for a given entity that support the given protocol.
 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(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 List<MetadataProvider> getProviders()
Gets an immutable the list of currently registered providers.

Returns:
list of currently registered providers

setProviders

public void setProviders(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 valid 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, must not be thrown simply if there is no metadata to fetch

getEntitiesDescriptor

public EntitiesDescriptor getEntitiesDescriptor(String name)
                                         throws MetadataProviderException
Gets a valid 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, must not be thrown if there is simply no EntitiesDescriptor with the given name

getEntityDescriptor

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

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, must not be thrown if there is simply no EntityDescriptor with the given ID

getRole

public List<RoleDescriptor> getRole(String entityID,
                                    QName roleName)
                             throws MetadataProviderException
Gets the valid role descriptors of a given type for a given entity.

Specified by:
getRole in interface MetadataProvider
Parameters:
entityID - the ID of the entity
roleName - the role type
Returns:
the modifiable list of role descriptors
Throws:
MetadataProviderException - thrown if the provider can not fetch the metadata, must not be thrown if there is simply no such entity with the given roles

getRole

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

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 descriptor
Throws:
MetadataProviderException - thrown if the provider can not fetch the metadata, must not be thrown if there is simply no such entity with the given role supporting the given protocol

getObservers

public 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.


OpenSAML-J 2.4.1-redhat-3

Copyright © 2006-2012 Internet2. All Rights Reserved.