Package net.shibboleth.idp.attribute.config

# Class AbstractMetadataDrivenConfigurationLookupStrategy<T>

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.idp.attribute.config.AbstractMetadataDrivenConfigurationLookupStrategy<T>

Type Parameters:
  `T` - type of property being returned

All Implemented Interfaces:
  `Function<BaseContext,T>`, `Component`, `DestructableComponent`, `InitializableComponent`

Direct Known Subclasses:
  `AbstractCollectionConfigurationLookupStrategy`, `BeanConfigurationLookupStrategy`, `BooleanConfigurationLookupStrategy`, `DoubleConfigurationLookupStrategy`, `DurationConfigurationLookupStrategy`, `IntegerConfigurationLookupStrategy`, `LongConfigurationLookupStrategy`, `StringConfigurationLookupStrategy`

public abstract class AbstractMetadataDrivenConfigurationLookupStrategy<T> extends AbstractInitializableComponent implements Function<BaseContext,T>
A strategy function that examines SAML metadata associated with a relying party and derives configuration settings based on EntityAttribute extension tags.

The function is tailored with properties that determine what tag it looks for, with subclasses handling the specific type conversion logic.

If a specific property is unavailable, then null is returned.

Since:
  5.0.0

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static final class`
`AbstractMetadataDrivenConfigurationLookupStrategy.CachedConfigurationContext`
A child context that caches derived configuration properties.

## Field Summary

Fields
Modifier and Type
Field
Description
`private static final Function<MessageContext,String>`
`DEFAULT_MC_PROFILE_ID_LOOKUP`
Default profile ID lookup for MC-based usage.
`private static final Function<ProfileRequestContext,String>`
`DEFAULT_PRC_PROFILE_ID_LOOKUP`
Default profile ID lookup for PRC-based usage.
`private Function<BaseContext,T>`
`defaultValueStrategy`
Default to return in the absence of a property.
`private boolean`
`enableCaching`
Cache the lookup in the context tree.
`private boolean`
`explicitPropertyName`
Prevents prefixing of property name by profile/aliases.
`private boolean`
`ignoreUnmappedEntityAttributes`
Examine only decoded/mapped tags in object metadata.
`private Collection<String>`
`legacyPropertyAliases`
Legacy "full" property identifiers to support.
`private String`
`legacyPropertyName`
Legacy name of property to check for (will warn).
`private static final org.slf4j.Logger`
`LOG`
Class logger.
`private Function<MessageContext,EntityDescriptor>`
`messageMetadataLookupStrategy`
Strategy for obtaining metadata via MessageContext.
`private Function<BaseContext,String>`
`profileIdLookupStrategy`
Strategy for obtaining profile ID for property naming.
`private Function<ProfileRequestContext,EntityDescriptor>`
`profileMetadataLookupStrategy`
Strategy for obtaining metadata via ProfileRequestContext.
`private Collection<String>`
`propertyAliases`
The "full" property identifiers to support.
`private String`
`propertyName`
Base name of property to check for.
`private boolean`
`strictNameFormat`
Require use of URI attribute name format.

## Constructor Summary

Constructors
Constructor
Description
`AbstractMetadataDrivenConfigurationLookupStrategy()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`T`
`apply(BaseContext input)`
`protected void`
`doInitialize()`
`protected abstract T`
`doTranslate(IdPAttribute tag)`
Translate the value(s) into a setting of the appropriate type.
`protected abstract T`
`doTranslate(Attribute tag)`
Translate the value(s) into a setting of the appropriate type.
`private String`
`ensurePropertyName()`
Gets the "base" name of the property/setting to derive.
`private IdPAttribute`
`findMatchingMappedTag(LockableClassToInstanceMultiMap<?> input, String name)`
Find first matching attribute in the input object's node metadata.
`private IdPAttribute`
`findMatchingMappedTag(EntityDescriptor entity, String name)`
Find first matching attribute in the input object's node metadata.
`private Attribute`
`findMatchingTag(EntityAttributes entityAttributes, String name)`
Find a matching entity attribute in the input metadata.
`private Attribute`
`findMatchingTag(EntityDescriptor entity, String name)`
Find a matching entity attribute in the input metadata.
`private Optional<T>`
`processMappedTag(IdPAttribute tag, AbstractMetadataDrivenConfigurationLookupStrategy.CachedConfigurationContext cacheContext)`
Process a mapped tag by returning any value found and caching if necessary.
`private Optional<T>`
`processTag(Attribute tag, AbstractMetadataDrivenConfigurationLookupStrategy.CachedConfigurationContext cacheContext)`
Process a tag by returning any value found and caching if necessary.
`void`
`setDefaultValue(T value)`
Sets a default value to return as the function result in the absence of an explicit property.
`void`
`setDefaultValueStrategy(Function<BaseContext,T> strategy)`
Sets a default value function to apply in the absence of an explicit property.
`void`
`setEnableCaching(boolean flag)`
Sets whether property lookup should be cached in the profile context tree.
`void`
`setExplicitPropertyName(boolean flag)`
Sets whether to treat the property name as absolute instead of auto-prefixed by profile or alias values.
`void`
`setIgnoreUnmappedEntityAttributes(boolean flag)`
Sets whether property lookup should be based solely on mapped/decoded objects and not on underlying SAML Attributes.
`void`
`setLegacyPropertyName(String name)`
Sets a legacy "base" name of the property/setting to derive.
`void`
`setMessageMetadataLookupStrategy(Function<MessageContext,EntityDescriptor> strategy)`
Sets lookup strategy for metadata to examine by way of `MessageContext`.
`void`
`setProfileAliases(Collection<String> aliases)`
Sets profile ID aliases to include when checking for metadata tags (the property name is suffixed to the aliases).
`void`
`setProfileIdLookupStrategy(Function<BaseContext,String> strategy)`
Sets lookup strategy for profile ID to base property names on.
`void`
`setProfileMetadataLookupStrategy(Function<ProfileRequestContext,EntityDescriptor> strategy)`
Sets lookup strategy for metadata to examine by way of `ProfileRequestContext`.
`void`
`setPropertyName(String name)`
Sets the "base" name of the property/setting to derive.
`void`
`setStrictNameFormat(boolean flag)`
Sets whether tag matching should examine and require an Attribute NameFormat of the URI type.
`private T`
`translate(IdPAttribute tag)`
Translate the value(s) into a setting of the appropriate type.
`private T`
`translate(Attribute tag)`
Translate the value(s) into a setting of the appropriate type.

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

`checkComponentActive, checkSetterPreconditions, destroy, doDestroy, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException, 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 java.util.function.Function

`andThen, compose`

## Field Details

### DEFAULT_PRC_PROFILE_ID_LOOKUP

@Nonnull private static final Function<ProfileRequestContext,String> DEFAULT_PRC_PROFILE_ID_LOOKUP
Default profile ID lookup for PRC-based usage.

### DEFAULT_MC_PROFILE_ID_LOOKUP

@Nonnull private static final Function<MessageContext,String> DEFAULT_MC_PROFILE_ID_LOOKUP
Default profile ID lookup for MC-based usage.

### LOG

@Nonnull private static final org.slf4j.Logger LOG
Class logger.

### strictNameFormat

private boolean strictNameFormat
Require use of URI attribute name format.

### enableCaching

private boolean enableCaching
Cache the lookup in the context tree.

### ignoreUnmappedEntityAttributes

private boolean ignoreUnmappedEntityAttributes
Examine only decoded/mapped tags in object metadata.

### explicitPropertyName

private boolean explicitPropertyName
Prevents prefixing of property name by profile/aliases.

### propertyName

@NonnullAfterInit @NotEmpty private String propertyName
Base name of property to check for.

### legacyPropertyName

@Nullable @NotEmpty private String legacyPropertyName
Legacy name of property to check for (will warn).

### propertyAliases

@NonnullAfterInit private Collection<String> propertyAliases
The "full" property identifiers to support.

### legacyPropertyAliases

@Nullable private Collection<String> legacyPropertyAliases
Legacy "full" property identifiers to support.

### defaultValueStrategy

@Nonnull private Function<BaseContext,T> defaultValueStrategy
Default to return in the absence of a property.

### profileMetadataLookupStrategy

@Nullable private Function<ProfileRequestContext,EntityDescriptor> profileMetadataLookupStrategy
Strategy for obtaining metadata via ProfileRequestContext.

### messageMetadataLookupStrategy

@Nullable private Function<MessageContext,EntityDescriptor> messageMetadataLookupStrategy
Strategy for obtaining metadata via MessageContext.

### profileIdLookupStrategy

@Nullable private Function<BaseContext,String> profileIdLookupStrategy
Strategy for obtaining profile ID for property naming.

## Constructor Details

### AbstractMetadataDrivenConfigurationLookupStrategy

public AbstractMetadataDrivenConfigurationLookupStrategy()
Constructor.

## Method Details

### setStrictNameFormat

public void setStrictNameFormat(boolean flag)
Sets whether tag matching should examine and require an Attribute NameFormat of the URI type.

Default is false.

Parameters:
  `flag` - flag to set

### setEnableCaching

public void setEnableCaching(boolean flag)
Sets whether property lookup should be cached in the profile context tree.

Default is true.

Parameters:
  `flag` - flag to set

### setIgnoreUnmappedEntityAttributes

public void setIgnoreUnmappedEntityAttributes(boolean flag)
Sets whether property lookup should be based solely on mapped/decoded objects and not on underlying SAML Attributes.

Default is false.

Parameters:
  `flag` - flag to set

### setExplicitPropertyName

public void setExplicitPropertyName(boolean flag)
Sets whether to treat the property name as absolute instead of auto-prefixed by profile or alias values.

Used to allow for direct lookup of a specific tag instead implicitly prefixing the tag name based on configuration "context".

Parameters:
  `flag` - flag to set
Since:
  4.3.0

### ensurePropertyName

@Nonnull private String ensurePropertyName()
Gets the "base" name of the property/setting to derive.

Callable only after init.

Returns:
  property name

### setPropertyName

public void setPropertyName(@Nonnull @NotEmpty String name)
Sets the "base" name of the property/setting to derive.

Parameters:
  `name` - base property name

### setLegacyPropertyName

public void setLegacyPropertyName(@Nullable @NotEmpty String name)
Sets a legacy "base" name of the property/setting to derive.

Use of this name will trigger a deprecation warning.

Parameters:
  `name` - base property name

### setProfileAliases

public void setProfileAliases(@Nonnull Collection<String> aliases)
Sets profile ID aliases to include when checking for metadata tags (the property name is suffixed to the aliases).

This allows alternatively-prefixed tag names to be checked.

Parameters:
  `aliases` - alternative profile IDs

### setDefaultValue

public void setDefaultValue(@Nullable T value)
Sets a default value to return as the function result in the absence of an explicit property.

Parameters:
  `value` - default value to return

### setDefaultValueStrategy

public void setDefaultValueStrategy(@Nonnull Function<BaseContext,T> strategy)
Sets a default value function to apply in the absence of an explicit property.

Parameters:
  `strategy` - default function to apply
Since:
  4.0.0

### setProfileMetadataLookupStrategy

public void setProfileMetadataLookupStrategy(@Nonnull Function<ProfileRequestContext,EntityDescriptor> strategy)
Sets lookup strategy for metadata to examine by way of `ProfileRequestContext`.

Parameters:
  `strategy` - lookup strategy

### setMessageMetadataLookupStrategy

public void setMessageMetadataLookupStrategy(@Nonnull Function<MessageContext,EntityDescriptor> strategy)
Sets lookup strategy for metadata to examine by way of `MessageContext`.

Parameters:
  `strategy` - lookup strategy

### setProfileIdLookupStrategy

public void setProfileIdLookupStrategy(@Nonnull Function<BaseContext,String> strategy)
Sets lookup strategy for profile ID to base property names on.

Parameters:
  `strategy` - lookup strategy

### doInitialize

protected void doInitialize() throws ComponentInitializationException

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

### apply

@Nullable public T apply(@Nullable BaseContext input)

Specified by:
  `apply` in interface `Function<BaseContext,T>`

### translate

@Nullable private T translate(@Nonnull Attribute tag)
Translate the value(s) into a setting of the appropriate type.

Parameters:
  `tag` - tag to translate
Returns:
  the setting derived from the tag's value(s)

### translate

@Nullable private T translate(@Nonnull IdPAttribute tag)
Translate the value(s) into a setting of the appropriate type.

Parameters:
  `tag` - tag to translate
Returns:
  the setting derived from the tag's value(s)

### doTranslate

@Nullable protected abstract T doTranslate(@Nonnull Attribute tag)
Translate the value(s) into a setting of the appropriate type.

Overrides of this function can assume a non-zero collection of values.

Parameters:
  `tag` - tag to translate
Returns:
  the setting derived from the tag's value(s)

### doTranslate

@Nullable protected abstract T doTranslate(@Nonnull IdPAttribute tag)
Translate the value(s) into a setting of the appropriate type.

Overrides of this function can assume a non-zero collection of values.

Parameters:
  `tag` - tag to translate
Returns:
  the setting derived from the tag's value(s)

### processMappedTag

@Nullable private Optional<T> processMappedTag(@Nullable IdPAttribute tag, @Nullable AbstractMetadataDrivenConfigurationLookupStrategy.CachedConfigurationContext cacheContext)
Process a mapped tag by returning any value found and caching if necessary.

Parameters:
  `tag` - the mapped tag object
  `cacheContext` - cache context
Returns:
  a possibly empty `Optional` containing the value if any, or null

### processTag

@Nullable private Optional<T> processTag(@Nullable Attribute tag, @Nullable AbstractMetadataDrivenConfigurationLookupStrategy.CachedConfigurationContext cacheContext)
Process a tag by returning any value found and caching if necessary.

Parameters:
  `tag` - the tag object
  `cacheContext` - cache context
Returns:
  a possibly empty `Optional` containing the value if any, or null

### findMatchingMappedTag

@Nullable private IdPAttribute findMatchingMappedTag(@Nonnull EntityDescriptor entity, @Nonnull @NotEmpty String name)
Find first matching attribute in the input object's node metadata.

Parameters:
  `entity` - the metadata to examine
  `name` - the tag name to search for
Returns:
  matching attribute, or null

### findMatchingTag

@Nullable private Attribute findMatchingTag(@Nonnull EntityDescriptor entity, @Nonnull @NotEmpty String name)
Find a matching entity attribute in the input metadata.

Parameters:
  `entity` - the metadata to examine
  `name` - the tag name to search for
Returns:
  matching attribute or null

### findMatchingMappedTag

@Nullable private IdPAttribute findMatchingMappedTag(@Nonnull LockableClassToInstanceMultiMap<?> input, @Nonnull @NotEmpty String name)
Find first matching attribute in the input object's node metadata.

Parameters:
  `input` - the metadata to examine
  `name` - the tag name to search for
Returns:
  matching attribute, or null

### findMatchingTag

@Nullable private Attribute findMatchingTag(@Nonnull EntityAttributes entityAttributes, @Nonnull @NotEmpty String name)
Find a matching entity attribute in the input metadata.

Parameters:
  `entityAttributes` - the metadata to examine
  `name` - the tag name to search for
Returns:
  matching attribute or null