Package net.shibboleth.idp.authn.impl

# Class AttributeSourcedSubjectCanonicalization

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent
net.shibboleth.idp.authn.SubjectCanonicalizationFlowDescriptor
net.shibboleth.idp.authn.AbstractSubjectCanonicalizer
net.shibboleth.idp.authn.impl.AttributeSourcedSubjectCanonicalization

All Implemented Interfaces:
  `Function<SubjectCanonicalizationContext,String>`, `Predicate<ProfileRequestContext>`, `SubjectCanonicalizer`, `FlowDescriptor`, `Component`, `DestructableComponent`, `IdentifiableComponent`, `IdentifiedComponent`, `InitializableComponent`

public class AttributeSourcedSubjectCanonicalization extends AbstractSubjectCanonicalizer
A `SubjectCanonicalizer` that resolves attributes and then extracts a resolved `IdPAttribute` value from an `AttributeContext` child obtained via lookup function (by default a child of the `SubjectCanonicalizationContext`), and uses it as the result of subject canonicalization.

String and scoped attribute values are supported.

Since:
  5.2.0

## Field Summary

Fields
Modifier and Type
Field
Description
`private List<String>`
`attributeSourceIds`
Ordered list of attributes to look for and read from.
`private Collection<String>`
`attributesToResolve`
Attributes to resolve if explicit.
`private char`
`delimiter`
Delimiter to use for scoped attribute serialization.
`private Function<ProfileRequestContext,String>`
`issuerLookupStrategy`
Strategy used to locate the identity of the issuer associated with the attribute resolution.
`private final org.slf4j.Logger`
`log`
Class logger.
`private Function<ProfileRequestContext,String>`
`principalNameLookupStrategy`
Strategy used to locate the principal name associated with the attribute resolution.
`private Function<ProfileRequestContext,String>`
`recipientLookupStrategy`
Strategy used to locate the identity of the recipient associated with the attribute resolution.
`private Predicate<ProfileRequestContext>`
`resolutionCondition`
Condition controlling whether to run the attribute resolver.
`private boolean`
`resolveFromSubject`
Whether to also (or instead) check the original Subject for `IdPAttributePrincipal`s.
`private ReloadableService<AttributeResolver>`
`resolverService`
Attribute resolver service.

## Constructor Summary

Constructors
Constructor
Description
`AttributeSourcedSubjectCanonicalization()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`protected String`
`doApply(SubjectCanonicalizationContext c14nContext)`
Performs c14n if possible.
`protected void`
`doInitialize()`
`private Map<String,IdPAttribute>`
`extractSubjectSourcedAttributes(SubjectCanonicalizationContext c14nContext)`
Extract and populate a map of any attributes found in the Subject.
`private String`
`findValue(IdPAttribute attribute)`
Check for a compatible value in the input attribute.
`private Map<String,IdPAttribute>`
`resolveAttributes(ProfileRequestContext profileRequestContext, SubjectCanonicalizationContext c14nContext)`
Perform attribute resolution inline.
`void`
`setAttributeResolver(ReloadableService<AttributeResolver> service)`
Set the `AttributeResolver` service instance to use.
`void`
`setAttributeSourceIds(List<String> ids)`
Set the attribute IDs to read from in order of preference.
`void`
`setAttributesToResolve(Collection<String> ids)`
Set the attribute IDs to resolve.
`void`
`setIssuerLookupStrategy(Function<ProfileRequestContext,String> strategy)`
Set the strategy used to lookup the issuer for this attribute resolution.
`void`
`setPrincipalNameLookupStrategy(Function<ProfileRequestContext,String> strategy)`
Set the strategy used to locate the principal name for this attribute resolution.
`void`
`setRecipientLookupStrategy(Function<ProfileRequestContext,String> strategy)`
Set the strategy used to lookup the recipient for this attribute resolution.
`void`
`setResolutionCondition(Predicate<ProfileRequestContext> condition)`
Set a condition to evaluate to decide whether to resolve attributes.
`void`
`setResolveFromSubject(boolean flag)`
Whether to include any `IdPAttributePrincipal` objects found in the input `Subject` when searching for a matching attribute ID.
`void`
`setScopedDelimiter(char ch)`
Set the delimiter to use for serializing scoped attribute values.

### Methods inherited from class net.shibboleth.idp.authn.AbstractSubjectCanonicalizer

`apply, applyTransforms, getLogPrefix, setLowercase, setTransforms, setTrim, setUppercase`

### Methods inherited from class net.shibboleth.idp.authn.SubjectCanonicalizationFlowDescriptor

`equals, getFlowId, hashCode, setActivationCondition, setFlowId, test, toString`

### 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, finalize, getClass, notify, notifyAll, wait, wait, wait`

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

`destroy, isDestroyed`

### Methods inherited from interface java.util.function.Function

`andThen, compose`

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

`setId`

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

`getId`

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

`initialize, isInitialized`

### Methods inherited from interface java.util.function.Predicate

`and, negate, or`

## Field Details

### log

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

### resolverService

@NonnullAfterInit private ReloadableService<AttributeResolver> resolverService
Attribute resolver service.

### resolutionCondition

@Nonnull private Predicate<ProfileRequestContext> resolutionCondition
Condition controlling whether to run the attribute resolver.

### delimiter

private char delimiter
Delimiter to use for scoped attribute serialization.

### resolveFromSubject

private boolean resolveFromSubject
Whether to also (or instead) check the original Subject for `IdPAttributePrincipal`s.

### attributesToResolve

@Nonnull private Collection<String> attributesToResolve
Attributes to resolve if explicit.

### attributeSourceIds

@Nonnull private List<String> attributeSourceIds
Ordered list of attributes to look for and read from.

### issuerLookupStrategy

@Nullable private Function<ProfileRequestContext,String> issuerLookupStrategy
Strategy used to locate the identity of the issuer associated with the attribute resolution.

### recipientLookupStrategy

@Nullable private Function<ProfileRequestContext,String> recipientLookupStrategy
Strategy used to locate the identity of the recipient associated with the attribute resolution.

### principalNameLookupStrategy

@Nullable private Function<ProfileRequestContext,String> principalNameLookupStrategy
Strategy used to locate the principal name associated with the attribute resolution.

## Constructor Details

### AttributeSourcedSubjectCanonicalization

public AttributeSourcedSubjectCanonicalization()
Constructor.

## Method Details

### setAttributeResolver

public void setAttributeResolver(@Nonnull ReloadableService<AttributeResolver> service)
Set the `AttributeResolver` service instance to use.

Parameters:
  `service` - service to use

### setResolutionCondition

public void setResolutionCondition(@Nonnull Predicate<ProfileRequestContext> condition)
Set a condition to evaluate to decide whether to resolve attributes.

Defaults to true.

Parameters:
  `condition` - condition to set

### setScopedDelimiter

public void setScopedDelimiter(char ch)
Set the delimiter to use for serializing scoped attribute values.

Defaults to '@'.

Parameters:
  `ch` - delimiter to use

### setResolveFromSubject

public void setResolveFromSubject(boolean flag)
Whether to include any `IdPAttributePrincipal` objects found in the input `Subject` when searching for a matching attribute ID.

Defaults to false.

Parameters:
  `flag` - flag to set

### setAttributesToResolve

public void setAttributesToResolve(@Nonnull Collection<String> ids)
Set the attribute IDs to resolve.

Parameters:
  `ids` - attribute IDs to resolve

### setAttributeSourceIds

public void setAttributeSourceIds(@Nonnull List<String> ids)
Set the attribute IDs to read from in order of preference.

Parameters:
  `ids` - attribute IDs to read from

### setIssuerLookupStrategy

public void setIssuerLookupStrategy(@Nullable Function<ProfileRequestContext,String> strategy)
Set the strategy used to lookup the issuer for this attribute resolution.

Parameters:
  `strategy` - lookup strategy

### setRecipientLookupStrategy

public void setRecipientLookupStrategy(@Nullable Function<ProfileRequestContext,String> strategy)
Set the strategy used to lookup the recipient for this attribute resolution.

Parameters:
  `strategy` - lookup strategy

### setPrincipalNameLookupStrategy

public void setPrincipalNameLookupStrategy(@Nullable Function<ProfileRequestContext,String> strategy)
Set the strategy used to locate the principal name for this attribute resolution.

Parameters:
  `strategy` - lookup strategy

### doInitialize

protected void doInitialize() throws ComponentInitializationException

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

### doApply

@Nullable protected String doApply(@Nonnull SubjectCanonicalizationContext c14nContext)
Performs c14n if possible.

Specified by:
  `doApply` in class `AbstractSubjectCanonicalizer`
Parameters:
  `c14nContext` - the current subject canonicalization context
Returns:
  event indicating result of function

### extractSubjectSourcedAttributes

@Nonnull private Map<String,IdPAttribute> extractSubjectSourcedAttributes(@Nonnull SubjectCanonicalizationContext c14nContext)
Extract and populate a map of any attributes found in the Subject.

Parameters:
  `c14nContext` - source of Subject
Returns:
  possibly empty map

### resolveAttributes

private Map<String,IdPAttribute> resolveAttributes(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull SubjectCanonicalizationContext c14nContext)
Perform attribute resolution inline.

Parameters:
  `profileRequestContext` - profile request context
  `c14nContext` - subject c14n context
Returns:
  the resolved map of attributes

### findValue

@Nullable private String findValue(@Nonnull IdPAttribute attribute)
Check for a compatible value in the input attribute.

Parameters:
  `attribute` - input attribute
Returns:
  value to use for result, or null