Class AttributeResolverImpl
java.lang.Object
net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent
net.shibboleth.ext.spring.service.AbstractServiceableComponent<AttributeResolver>
net.shibboleth.idp.attribute.resolver.impl.AttributeResolverImpl
- All Implemented Interfaces:
AttributeResolver,Component,DestructableComponent,IdentifiableComponent,IdentifiedComponent,InitializableComponent,ServiceableComponent<AttributeResolver>,Aware,ApplicationContextAware
@ThreadSafe
public class AttributeResolverImpl
extends AbstractServiceableComponent<AttributeResolver>
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
Criterions. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Map<String,AttributeDefinition> Attribute definitions defined for this resolver.private Map<String,DataConnector> Data connectors defined for this resolver.private final org.slf4j.LoggerClass logger.private StringCache for the log prefix - to save multiple recalculations.PreRequestedAttributes, resolved first and made available for late-comers.Strategy to get theProfileRequestContext.private booleanWhether to strip null attribute values.private booleanWhether to attach DisplayInfo to attributes. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckPlugInDependencies(String circularCheckPluginId, ResolverPlugin<?> plugin, Set<String> checkedPlugins) Checks to ensure that there are no circular dependencies or dependencies on non-existent plugins.private voidcollectExportingDataConnectors(Map<String, IdPAttribute> resolvedAttributes, AttributeResolutionContext resolutionContext, AttributeResolverWorkContext workContext) Helper function to collect attributes and their data & metadata from suitable data connectors.private voidcollectResolvedAttributes(Map<String, IdPAttribute> resolvedAttributes, AttributeResolverWorkContext workContext, boolean includeDependencyOnly) Helper function to collect suitably resolved attributes.protected voidprivate List<IdPAttributeValue>filterAttributeValues(String attributeId, List<IdPAttributeValue> input) Helper method for exporting attributes.protected voidfinalizePreResolvedAttributes(AttributeResolutionContext resolutionContext) Collects the set of pre resolved attributes and places them in anAttributeContextwhich inserted as a child of theAttributeResolutionContextand also returned.protected voidfinalizeResolvedAttributes(AttributeResolutionContext resolutionContext) Finalizes the set of resolved attributes and places them in theAttributeResolutionContext.Gets the collection of attribute definitions for this resolver.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.booleanDo we strip nulls from attribute values.booleanDo we allow addition of Display Information?protected voidresolveAttributeDefinition(String attributeId, AttributeResolutionContext resolutionContext) Resolve theAttributeDefinitionwhich has the specified ID.voidresolveAttributes(AttributeResolutionContext resolutionContext) Resolves the attribute for the given request.protected voidresolveDataConnector(String connectorId, AttributeResolutionContext resolutionContext) Resolve theDataConnectorwhich has the specified ID.protected voidresolveDependencies(ResolverPlugin<?> plugin, AttributeResolutionContext resolutionContext) Resolves all the dependencies for a given plugin.voidsetAttributeDefinitions(Collection<AttributeDefinition> definitions) Sets the attribute definitions for this resolver.voidsetDataConnectors(Collection<DataConnector> connectors) Sets the data connectors for this resolver.voidsetProfileContextLookupStrategy(Function<AttributeResolutionContext, ProfileRequestContext> strategy) Set the mechanism to obtain theProfileRequestContext.voidsetStripNulls(Boolean doStripNulls) Sets whether to strip nulls from attribute values.voidsetSuppressDisplayInformation(boolean what) Deprecated, for removal: This API element is subject to removal in a future version.Display Information should be consulted at point of useprivate booleanstartTimer(AttributeResolutionContext resolutionContext) Conditionally start a timer at the beginning of the resolution process.private voidstopTimer(AttributeResolutionContext resolutionContext) Conditionally stop a timer at the end of the resolution process.Methods inherited from class net.shibboleth.ext.spring.service.AbstractServiceableComponent
doDestroy, getApplicationContext, pinComponent, setApplicationContext, unloadComponent, unpinComponentMethods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent
setIdMethods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
getIdMethods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, initialize, isDestroyed, isInitializedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.shibboleth.utilities.java.support.component.IdentifiedComponent
getId
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
attributeDefinitions
Attribute definitions defined for this resolver. -
dataConnectors
Data connectors defined for this resolver. -
logPrefix
Cache for the log prefix - to save multiple recalculations. -
preRequestedAttributes
PreRequestedAttributes, resolved first and made available for late-comers. -
stripNulls
private boolean stripNullsWhether to strip null attribute values. -
suppressDisplayInformation
private boolean suppressDisplayInformationWhether to attach DisplayInfo to attributes. -
profileContextStrategy
Strategy to get theProfileRequestContext.
-
-
Constructor Details
-
AttributeResolverImpl
public AttributeResolverImpl()Constructor.
-
-
Method Details
-
setAttributeDefinitions
public void setAttributeDefinitions(@Nonnull @NonnullElements Collection<AttributeDefinition> definitions) Sets the attribute definitions for this resolver.- Parameters:
definitions- attribute definitions loaded in to this resolver
-
getAttributeDefinitions
@Nonnull @NonnullElements @Unmodifiable public Map<String,AttributeDefinition> getAttributeDefinitions()Gets the collection of attribute definitions for this resolver.- Returns:
- attribute definitions loaded in to this resolver
-
setDataConnectors
Sets the data connectors for this resolver.- Parameters:
connectors- data connectors loaded in to this resolver
-
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
Sets whether to strip nulls from attribute values.- Parameters:
doStripNulls- what to set
-
isSuppressDisplayInformation
public boolean isSuppressDisplayInformation()Do we allow addition of Display Information?- Returns:
- whether we are suppressing
-
setSuppressDisplayInformation
Deprecated, for removal: This API element is subject to removal in a future version.Display Information should be consulted at point of useSet whether we suppress addition of Display Information.- Parameters:
what- true if we suppress the addition.
-
setProfileContextLookupStrategy
public void setProfileContextLookupStrategy(@Nonnull Function<AttributeResolutionContext, ProfileRequestContext> strategy) Set the mechanism to obtain theProfileRequestContext.- Parameters:
strategy- lookup strategy
-
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:
resolveAttributesin interfaceAttributeResolver- 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
-
getToBeResolvedAttributeIds
@Nonnull @NonnullElements protected Collection<String> getToBeResolvedAttributeIds(@Nonnull AttributeResolutionContext resolutionContext) Gets the list of attributes, identified by IDs, that should be resolved. If theAttributeResolutionContext.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
-
resolveAttributeDefinition
protected void resolveAttributeDefinition(@Nonnull String attributeId, @Nonnull AttributeResolutionContext resolutionContext) throws ResolutionException Resolve theAttributeDefinitionwhich has the specified ID. The results of the resolution are stored in the givenAttributeResolutionContext.- Parameters:
attributeId- id of the attribute definition to resolveresolutionContext- 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 theDataConnectorwhich has the specified ID. The results of the resolution are stored in the givenAttributeResolutionContext.- Parameters:
connectorId- id of the data connector to resolveresolutionContext- 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 resolvedresolutionContext- current resolution context- Throws:
ResolutionException- thrown if there is a problem resolving a dependency
-
filterAttributeValues
@Nullable @NonnullElements private List<IdPAttributeValue> filterAttributeValues(String attributeId, 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(Map<String, IdPAttribute> resolvedAttributes, AttributeResolverWorkContext workContext, boolean includeDependencyOnly) Helper function to collect suitably resolved attributes.- Parameters:
resolvedAttributes- bucket to collect attributes intoworkContext- context to extract attributes fromincludeDependencyOnly- whether we include dependencyOnly attributes
-
collectExportingDataConnectors
private void collectExportingDataConnectors(Map<String, IdPAttribute> resolvedAttributes, AttributeResolutionContext resolutionContext, AttributeResolverWorkContext workContext) Helper function to collect attributes and their data & metadata from suitable data connectors.- Parameters:
resolvedAttributes- bucket to collect attributes intoresolutionContext- the context we are working inworkContext- context to extract attributes from
-
finalizeResolvedAttributes
Finalizes the set of resolved attributes and places them in theAttributeResolutionContext. The result of eachAttributeDefinitionresolution 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
Collects the set of pre resolved attributes and places them in anAttributeContextwhich inserted as a child of theAttributeResolutionContextand also returned.Values are also de-duplicated here.
- Parameters:
resolutionContext- current resolution context
-
doInitialize
- Overrides:
doInitializein classAbstractServiceableComponent<AttributeResolver>- Throws:
ComponentInitializationException
-
checkPlugInDependencies
protected void checkPlugInDependencies(String circularCheckPluginId, ResolverPlugin<?> plugin, 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 dependenciesplugin- current plugin, in the dependency tree of the plugin being checked, that we're currently looking atcheckedPlugins- IDs of plugins that have already been checked and known to be good- Throws:
ComponentInitializationException- thrown if there is a dependency loop
-
getComponent
- Specified by:
getComponentin interfaceServiceableComponent<AttributeResolver>- Specified by:
getComponentin classAbstractServiceableComponent<AttributeResolver>
-
startTimer
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
Conditionally stop a timer at the end of the resolution process.- Parameters:
resolutionContext- attribute resolution context
-