edu.internet2.middleware.shibboleth.common.attribute.resolver.provider
Class ShibbolethAttributeResolver

java.lang.Object
  extended by edu.internet2.middleware.shibboleth.common.config.BaseService
      extended by edu.internet2.middleware.shibboleth.common.config.BaseReloadableService
          extended by edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.ShibbolethAttributeResolver
All Implemented Interfaces:
AttributeResolver<SAMLProfileRequestContext>, ReloadableService, Service, org.springframework.beans.factory.BeanNameAware, org.springframework.context.ApplicationContextAware

public class ShibbolethAttributeResolver
extends BaseReloadableService
implements AttributeResolver<SAMLProfileRequestContext>

Primary implementation of AttributeResolver. "Raw" attributes are gathered by the registered DataConnectors while the AttributeDefinitions refine the raw attributes or create attributes of their own. Connectors and definitions may depend on each other so implementations must use a directed dependency graph when performing the resolution.


Nested Class Summary
 
Nested classes/interfaces inherited from class edu.internet2.middleware.shibboleth.common.config.BaseReloadableService
BaseReloadableService.ConfigurationResourceListener
 
Field Summary
private  Map<String,DataConnector> dataConnectors
          Data connectors defined for this resolver.
private  Map<String,AttributeDefinition> definitions
          Attribute definitions defined for this resolver.
private  org.slf4j.Logger log
          Class logger.
static Collection<Class> PLUGIN_TYPES
          Resolution plug-in types.
private  Map<String,PrincipalConnector> principalConnectors
          Principal connectors defined for this resolver.
 
Constructor Summary
ShibbolethAttributeResolver()
          Constructor.
 
Method Summary
protected  void addVertex(org.jgrapht.DirectedGraph<ResolutionPlugIn,org.jgrapht.graph.DefaultEdge> graph, ResolutionPlugIn<?> plugin)
          Add a resolution plug-in and dependencies to a directed graph.
protected  void cleanResolvedAttributes(Map<String,BaseAttribute> resolvedAttributes, ShibbolethResolutionContext resolutionContext)
          Removes attributes that contain no values or those which are dependency only.
 Map<String,AttributeDefinition> getAttributeDefinitions()
          Gets the attribute definitions registered with this resolver.
 Map<String,DataConnector> getDataConnectors()
          Gets the data connectors registered with this provider.
protected  String getNameIdentifierFormat(org.opensaml.common.SAMLObject nameIdentifier)
          Gets the format of the name identifier used to identify the subject.
 Map<String,PrincipalConnector> getPrincipalConnectors()
          Gets the principal connectors registered with this resolver.
protected  void onNewContextCreated(org.springframework.context.ApplicationContext newServiceContext)
          Called after a new context has been created but before it set as the service's context.
protected  BaseAttribute resolveAttribute(String attributeID, ShibbolethResolutionContext resolutionContext)
          Resolve the AttributeDefinition which has the specified ID.
 Map<String,BaseAttribute> resolveAttributes(SAMLProfileRequestContext attributeRequestContext)
          Gets all the attributes for a given subject.
protected  Map<String,BaseAttribute> resolveAttributes(ShibbolethResolutionContext resolutionContext)
          Resolves the attributes requested in the resolution context or all attributes if no specific attributes were requested.
protected  void resolveDataConnector(String connectorID, ShibbolethResolutionContext resolutionContext)
          Resolve the DataConnector which has the specified ID and add it to the resolution context.
protected  void resolveDependencies(ResolutionPlugIn<?> plugin, ShibbolethResolutionContext resolutionContext)
          Resolves all the dependencies for a given plugin.
 String resolvePrincipalName(SAMLProfileRequestContext requestContext)
          Resolves the principal name for the subject of the request.
 void validate()
          Check that the Attribute Resolver is in a valid state and ready to begin receiving resolution requests.
protected  void validateDataConnector(DataConnector connector)
          Validates that a data connector is valid, per ResolutionPlugIn.validate() and, if invalid, fails over to a connector's failover connector, if present.
 
Methods inherited from class edu.internet2.middleware.shibboleth.common.config.BaseReloadableService
destroy, getPollingFrequency, getPollingRetryAttempts, getPollingTimer, initialize, reload, setPollingFrequency, setPollingRetryAttempts, setPollingTimer
 
Methods inherited from class edu.internet2.middleware.shibboleth.common.config.BaseService
getApplicationContext, getId, getReadWriteLock, getServiceConfigurations, getServiceContext, isDestroyed, isInitialized, loadContext, setApplicationContext, setBeanName, setInitialized, setServiceConfigurations, setServiceContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.internet2.middleware.shibboleth.common.service.Service
getId, isDestroyed, isInitialized
 

Field Detail

PLUGIN_TYPES

public static final Collection<Class> PLUGIN_TYPES
Resolution plug-in types.


log

private final org.slf4j.Logger log
Class logger.


dataConnectors

private Map<String,DataConnector> dataConnectors
Data connectors defined for this resolver.


definitions

private Map<String,AttributeDefinition> definitions
Attribute definitions defined for this resolver.


principalConnectors

private Map<String,PrincipalConnector> principalConnectors
Principal connectors defined for this resolver.

Constructor Detail

ShibbolethAttributeResolver

public ShibbolethAttributeResolver()
Constructor.

Method Detail

getAttributeDefinitions

public Map<String,AttributeDefinition> getAttributeDefinitions()
Gets the attribute definitions registered with this resolver.

Returns:
attribute definitions registered with this resolver

getDataConnectors

public Map<String,DataConnector> getDataConnectors()
Gets the data connectors registered with this provider.

Returns:
data connectors registered with this provider

getPrincipalConnectors

public Map<String,PrincipalConnector> getPrincipalConnectors()
Gets the principal connectors registered with this resolver.

Returns:
principal connectors registered with this resolver

resolveAttributes

public Map<String,BaseAttribute> resolveAttributes(SAMLProfileRequestContext attributeRequestContext)
                                            throws AttributeResolutionException
Gets all the attributes for a given subject. While an initial attribute producer is given this does not mean every returned attribute is from that producer. The producer may return information that can be used by data connectors to contact other producers and retrieve attributes from them.

Specified by:
resolveAttributes in interface AttributeResolver<SAMLProfileRequestContext>
Parameters:
attributeRequestContext - the attribute resolution context to use to resolve attributes
Returns:
the attributes describing the subject
Throws:
AttributeResolutionException - thrown if there is a problem resolving the attributes for the subject

validate

public void validate()
              throws AttributeResolutionException
Check that the Attribute Resolver is in a valid state and ready to begin receiving resolution requests.

Specified by:
validate in interface AttributeResolver<SAMLProfileRequestContext>
Throws:
AttributeResolutionException - if resolver is in an invalid state

validateDataConnector

protected void validateDataConnector(DataConnector connector)
                              throws AttributeResolutionException
Validates that a data connector is valid, per ResolutionPlugIn.validate() and, if invalid, fails over to a connector's failover connector, if present.

Parameters:
connector - connector to validate
Throws:
AttributeResolutionException - thrown if the connector is invalid and does not define a failover connector or, if a failover connector is defined, if that connector is invalid

resolvePrincipalName

public String resolvePrincipalName(SAMLProfileRequestContext requestContext)
                            throws AttributeResolutionException
Resolves the principal name for the subject of the request.

Parameters:
requestContext - current request context
Returns:
principal name for the subject of the request
Throws:
AttributeResolutionException - thrown if the subject identifier information can not be resolved into a principal name

getNameIdentifierFormat

protected String getNameIdentifierFormat(org.opensaml.common.SAMLObject nameIdentifier)
Gets the format of the name identifier used to identify the subject.

Parameters:
nameIdentifier - name identifier used to identify the subject
Returns:
format of the name identifier used to identify the subject

resolveAttributes

protected Map<String,BaseAttribute> resolveAttributes(ShibbolethResolutionContext resolutionContext)
                                               throws AttributeResolutionException
Resolves the attributes requested in the resolution context or all attributes if no specific attributes were requested. This method does not remove dependency only attributes or attributes that do not contain values.

Parameters:
resolutionContext - current resolution context
Returns:
resolved attributes
Throws:
AttributeResolutionException - thrown if the attributes could not be resolved

resolveAttribute

protected BaseAttribute resolveAttribute(String attributeID,
                                         ShibbolethResolutionContext resolutionContext)
                                  throws AttributeResolutionException
Resolve the AttributeDefinition which has the specified ID. The definition is then added to the ShibbolethResolutionContext for use by other ResolutionPlugIns and the resolution of the specified definition is added to resolvedAttributes to be returned by the resolver.

Parameters:
attributeID - id of the attribute definition to resolve
resolutionContext - resolution context that we are working in
Returns:
resolution of the specified attribute definition
Throws:
AttributeResolutionException - if unable to resolve the requested attribute definition

resolveDataConnector

protected void resolveDataConnector(String connectorID,
                                    ShibbolethResolutionContext resolutionContext)
                             throws AttributeResolutionException
Resolve the DataConnector which has the specified ID and add it to the resolution context.

Parameters:
connectorID - id of the data connector to resolve
resolutionContext - resolution context that we are working in
Throws:
AttributeResolutionException - if unable to resolve the requested connector

resolveDependencies

protected void resolveDependencies(ResolutionPlugIn<?> plugin,
                                   ShibbolethResolutionContext resolutionContext)
                            throws AttributeResolutionException
Resolves all the dependencies for a given plugin.

Parameters:
plugin - plugin whose dependencies should be resolved
resolutionContext - current resolution context
Throws:
AttributeResolutionException - thrown if there is a problem resolving a dependency

cleanResolvedAttributes

protected void cleanResolvedAttributes(Map<String,BaseAttribute> resolvedAttributes,
                                       ShibbolethResolutionContext resolutionContext)
Removes attributes that contain no values or those which are dependency only.

Parameters:
resolvedAttributes - attribute set to clean up
resolutionContext - current resolution context

addVertex

protected void addVertex(org.jgrapht.DirectedGraph<ResolutionPlugIn,org.jgrapht.graph.DefaultEdge> graph,
                         ResolutionPlugIn<?> plugin)
Add a resolution plug-in and dependencies to a directed graph.

Parameters:
graph - directed graph
plugin - plug-in to add

onNewContextCreated

protected void onNewContextCreated(org.springframework.context.ApplicationContext newServiceContext)
                            throws ServiceException
Called after a new context has been created but before it set as the service's context. If an exception is thrown the new context will not be set as the service's context and the current service context will be retained.

Specified by:
onNewContextCreated in class BaseService
Parameters:
newServiceContext - the newly created context for the service
Throws:
ServiceException - thrown if there is a problem with the given service context


Copyright © 1999-2012. All Rights Reserved.