Package net.shibboleth.idp.attribute.resolver.impl

# Class AttributeResolverImpl

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent
net.shibboleth.idp.attribute.resolver.impl.AttributeResolverImpl

All Implemented Interfaces:
  `AttributeResolver`, `Component`, `DestructableComponent`, `IdentifiableComponent`, `IdentifiedComponent`, `InitializableComponent`

@ThreadSafe public class AttributeResolverImpl extends AbstractIdentifiableInitializableComponent implements AttributeResolver
A component that resolves the attributes for a particular subject. Note WellThis class is about attribute resolution, that is to say the summoning up of attributes in response to the exigies of the provided context. It does not implement `Resolver` which in about summoning up bits of generic data from the configuration (usually the metadata) in response to specific `Criterion`s.

## Field Summary

Fields
Modifier and Type
Field
Description
`private Map<String,AttributeDefinition>`
`attributeDefinitions`
Attribute definitions defined for this resolver.
`private Map<String,DataConnector>`
`dataConnectors`
Data connectors defined for this resolver.
`private final org.slf4j.Logger`
`log`
Class logger.
`private String`
`logPrefix`
Cache for the log prefix - to save multiple recalculations.
`private List<String>`
`preRequestedAttributes`
PreRequestedAttributes, resolved first and made available for late-comers.
`private boolean`
`stripNulls`
Whether to strip null attribute values.

## Constructor Summary

Constructors
Constructor
Description
`AttributeResolverImpl()`

## Method Summary

Modifier and Type
Method
Description
`protected void`
`checkPlugInDependencies(String circularCheckPluginId, ResolverPlugin<?> plugin, Set<String> checkedPlugins)`
Checks to ensure that there are no circular dependencies or dependencies on non-existent plugins.
`private void`
`collectExportingDataConnectors(Map<String,IdPAttribute> resolvedAttributes, AttributeResolutionContext resolutionContext, AttributeResolverWorkContext workContext)`
Helper function to collect attributes and their data & metadata from suitable data connectors.
`private void`
`collectResolvedAttributes(Map<String,IdPAttribute> resolvedAttributes, AttributeResolverWorkContext workContext, boolean includeDependencyOnly)`
Helper function to collect suitably resolved attributes.
`protected void`
`doInitialize()`
`private List<IdPAttributeValue>`
`filterAttributeValues(String attributeId, List<IdPAttributeValue> input)`
Helper method for exporting attributes.
`protected void`
`finalizePreResolvedAttributes(AttributeResolutionContext resolutionContext)`
Collects the set of pre resolved attributes and places them in an `AttributeContext` which inserted as a child of the `AttributeResolutionContext` and also returned.
`protected void`
`finalizeResolvedAttributes(AttributeResolutionContext resolutionContext)`
Finalizes the set of resolved attributes and places them in the `AttributeResolutionContext`.
`Map<String,AttributeDefinition>`
`getAttributeDefinitions()`
Gets the collection of attribute definitions for this resolver.
`Map<String,DataConnector>`
`getDataConnectors()`
Gets the unmodifiable collection of data connectors for this resolver.
`protected Collection<String>`
`getToBeResolvedAttributeIds(AttributeResolutionContext resolutionContext)`
Gets the list of attributes, identified by IDs, that should be resolved.
`boolean`
`isStripNulls()`
Do we strip nulls from attribute values.
`private void`
`logContext(AttributeResolutionContext resolutionContext)`
Before we start log all we know about the resolver and context (at `Logger.debug(String)`).
`protected boolean`
`noAttributesRequested(AttributeResolutionContext resolutionContext)`
Were attributes requested or is thisa get everything situation?
`private String`
`notProvidedOr(String input)`
Code to replace (null) with <Not Supplied> in the log
`protected void`
`resolveAttributeDefinition(String attributeId, AttributeResolutionContext resolutionContext)`
Resolve the `AttributeDefinition` which has the specified ID.
`void`
`resolveAttributes(AttributeResolutionContext resolutionContext)`
Resolves the attribute for the given request.
`protected void`
`resolveDataConnector(String connectorId, AttributeResolutionContext resolutionContext)`
Resolve the `DataConnector` which has the specified ID.
`protected void`
`resolveDependencies(ResolverPlugin<?> plugin, AttributeResolutionContext resolutionContext)`
Resolves all the dependencies for a given plugin.
`void`
`setAttributeDefinitions(Collection<AttributeDefinition> definitions)`
Sets the attribute definitions for this resolver.
`void`
`setDataConnectors(Collection<DataConnector> connectors)`
Sets the data connectors for this resolver.
`void`
`setStripNulls(Boolean doStripNulls)`
Sets whether to strip nulls from attribute values.
`private boolean`
`startTimer(AttributeResolutionContext resolutionContext)`
Conditionally start a timer at the beginning of the resolution process.
`private void`
`stopTimer(AttributeResolutionContext resolutionContext)`
Conditionally stop a timer at the end of the resolution process.

### Methods inherited from class net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent

`setId`

### Methods inherited from class net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent

`ensureId, getId, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException`

### Methods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent

`checkComponentActive, checkSetterPreconditions, destroy, doDestroy, initialize, isDestroyed, isInitialized`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface net.shibboleth.shared.component.IdentifiedComponent

`getId`

## Field Details

### log

@Nonnull private final org.slf4j.Logger log
Class logger.

### attributeDefinitions

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

### dataConnectors

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

### logPrefix

@NonnullAfterInit private String logPrefix
Cache for the log prefix - to save multiple recalculations.

### preRequestedAttributes

@NonnullAfterInit private List<String> preRequestedAttributes
PreRequestedAttributes, resolved first and made available for late-comers.

### stripNulls

private boolean stripNulls
Whether to strip null attribute values.

## Constructor Details

### AttributeResolverImpl

public AttributeResolverImpl()

## Method Details

### setAttributeDefinitions

public void setAttributeDefinitions(@Nonnull Collection<AttributeDefinition> definitions)
Sets the attribute definitions for this resolver.

Parameters:
  `definitions` - attribute definitions loaded in to this resolver

### getAttributeDefinitions

@NonnullAfterInit @Unmodifiable @NotLive public Map<String,AttributeDefinition> getAttributeDefinitions()
Gets the collection of attribute definitions for this resolver.

Returns:
  attribute definitions loaded in to this resolver

### setDataConnectors

public void setDataConnectors(@Nonnull Collection<DataConnector> connectors)
Sets the data connectors for this resolver.

Parameters:
  `connectors` - data connectors loaded in to this resolver

### getDataConnectors

@NonnullAfterInit @Unmodifiable @NotLive public Map<String,DataConnector> getDataConnectors()
Gets the unmodifiable collection of data connectors for this resolver.

Returns:
  data connectors loaded in to this resolver

### isStripNulls

public boolean isStripNulls()
Do we strip nulls from attribute values.

Returns:
  Returns whether to strip nulls from attribute values

### setStripNulls

public void setStripNulls(Boolean doStripNulls)
Sets whether to strip nulls from attribute values.

Parameters:
  `doStripNulls` - what to set

### resolveAttributes

public void resolveAttributes(@Nonnull AttributeResolutionContext resolutionContext) throws ResolutionException
Resolves the attribute for the given request. Note, if attributes are requested, `AttributeResolutionContext.getRequestedIdPAttributeNames()`, the resolver will not fail if they can not be resolved. This information serves only as a hint to the resolver to, potentially, optimize the resolution of attributes.

Specified by:
  `resolveAttributes` in interface `AttributeResolver`
Parameters:
  `resolutionContext` - the attribute resolution context that identifies the request subject and accumulates the resolved attributes
Throws:
  `ResolutionException` - thrown if there is a problem resolving the attributes for the subject

### notProvidedOr

@Nonnull private String notProvidedOr(@Nullable String input)
Code to replace (null) with <Not Supplied> in the log

Parameters:
  `input` - an input
Returns:
  the input or a fixed string

### logContext

private void logContext(@Nonnull AttributeResolutionContext resolutionContext)
Before we start log all we know about the resolver and context (at `Logger.debug(String)`).

Parameters:
  `resolutionContext` - the context

### getToBeResolvedAttributeIds

@Nonnull @Live protected Collection<String> getToBeResolvedAttributeIds(@Nonnull AttributeResolutionContext resolutionContext)
Gets the list of attributes, identified by IDs, that should be resolved. If the `AttributeResolutionContext.getRequestedIdPAttributeNames()` is not empty then those attributes are the ones to be resolved, otherwise all registered attribute definitions are to be resolved.

Parameters:
  `resolutionContext` - current resolution context
Returns:
  list of attributes, identified by IDs, that should be resolved

### noAttributesRequested

protected boolean noAttributesRequested(@Nonnull AttributeResolutionContext resolutionContext)
Were attributes requested or is thisa get everything situation?

Parameters:
  `resolutionContext` - current resolution context
Returns:
  whether some attiibutes were explictly requested

### resolveAttributeDefinition

protected void resolveAttributeDefinition(@Nonnull String attributeId, @Nonnull AttributeResolutionContext resolutionContext) throws ResolutionException
Resolve the `AttributeDefinition` which has the specified ID. The results of the resolution are stored in the given `AttributeResolutionContext`.

Parameters:
  `attributeId` - id of the attribute definition to resolve
  `resolutionContext` - resolution context that we are working in
Throws:
  `ResolutionException` - if unable to resolve the requested attribute definition

### resolveDataConnector

protected void resolveDataConnector(@Nonnull String connectorId, @Nonnull AttributeResolutionContext resolutionContext) throws ResolutionException
Resolve the `DataConnector` which has the specified ID. The results of the resolution are stored in the given `AttributeResolutionContext`.

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

### resolveDependencies

protected void resolveDependencies(@Nonnull ResolverPlugin<?> plugin, @Nonnull AttributeResolutionContext resolutionContext) throws ResolutionException
Resolves all the dependencies for a given plugin.

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

### filterAttributeValues

@Nullable @Live private List<IdPAttributeValue> filterAttributeValues(@Nonnull String attributeId, @Nonnull List<IdPAttributeValue> input)
Helper method for exporting attributes.

Parameters:
  `attributeId` - the if (for logging)
  `input` - the inout list
Returns:
  a null stripped, or null list of values

### collectResolvedAttributes

private void collectResolvedAttributes(@Nonnull Map<String,IdPAttribute> resolvedAttributes, @Nonnull AttributeResolverWorkContext workContext, boolean includeDependencyOnly)
Helper function to collect suitably resolved attributes.

Parameters:
  `resolvedAttributes` - bucket to collect attributes into
  `workContext` - context to extract attributes from
  `includeDependencyOnly` - whether we include dependencyOnly attributes

### collectExportingDataConnectors

private void collectExportingDataConnectors(@Nonnull Map<String,IdPAttribute> resolvedAttributes, @Nonnull AttributeResolutionContext resolutionContext, @Nonnull AttributeResolverWorkContext workContext)
Helper function to collect attributes and their data & metadata from suitable data connectors.

Parameters:
  `resolvedAttributes` - bucket to collect attributes into
  `resolutionContext` - the context we are working in
  `workContext` - context to extract attributes from

### finalizeResolvedAttributes

protected void finalizeResolvedAttributes(@Nonnull AttributeResolutionContext resolutionContext)
Finalizes the set of resolved attributes and places them in the `AttributeResolutionContext`. The result of each `AttributeDefinition` resolution is inspected. If the result is not null, a dependency-only attribute, or an attribute that contains no values then it becomes part of the final set of resolved attributes.

Then we handle attribute exports from DataConnectors.

Values are also de-duplicated here, so that all the intermediate operations maintain the coherency of multi-valued result sets produced by data connectors.

Parameters:
  `resolutionContext` - current resolution context

### finalizePreResolvedAttributes

protected void finalizePreResolvedAttributes(@Nonnull AttributeResolutionContext resolutionContext)
Collects the set of pre resolved attributes and places them in an `AttributeContext` which inserted as a child of the `AttributeResolutionContext` and also returned.

Values are also de-duplicated here.

Parameters:
  `resolutionContext` - current resolution context

### doInitialize

protected void doInitialize() throws ComponentInitializationException

Overrides:
  `doInitialize` in class `AbstractIdentifiedInitializableComponent`
Throws:
  `ComponentInitializationException`

### checkPlugInDependencies

protected void checkPlugInDependencies(@Nullable String circularCheckPluginId, @Nonnull ResolverPlugin<?> plugin, @Nonnull Set<String> checkedPlugins) throws ComponentInitializationException
Checks to ensure that there are no circular dependencies or dependencies on non-existent plugins.

Parameters:
  `circularCheckPluginId` - the ID of the plugin currently being checked for circular dependencies
  `plugin` - current plugin, in the dependency tree of the plugin being checked, that we're currently looking at
  `checkedPlugins` - IDs of plugins that have already been checked and known to be good
Throws:
  `ComponentInitializationException` - thrown if there is a dependency loop

### startTimer

private boolean startTimer(@Nonnull AttributeResolutionContext resolutionContext)
Conditionally start a timer at the beginning of the resolution process.

Parameters:
  `resolutionContext` - attribute resolution context
Returns:
  true iff the `stopTimer(AttributeResolutionContext)` method needs to be called

### stopTimer

private void stopTimer(@Nonnull AttributeResolutionContext resolutionContext)
Conditionally stop a timer at the end of the resolution process.

Parameters:
  `resolutionContext` - attribute resolution context