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

# Class ScriptedAttributeDefinition

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent
net.shibboleth.idp.attribute.resolver.AbstractResolverPlugin<IdPAttribute>
net.shibboleth.idp.attribute.resolver.AbstractAttributeDefinition
net.shibboleth.idp.attribute.resolver.ad.impl.ScriptedAttributeDefinition

All Implemented Interfaces:
  `AttributeDefinition`, `ResolverPlugin<IdPAttribute>`, `Component`, `DestructableComponent`, `IdentifiableComponent`, `IdentifiedComponent`, `InitializableComponent`, `UnmodifiableComponent`, `DisposableBean`

@ThreadSafe public class ScriptedAttributeDefinition extends AbstractAttributeDefinition
An `AttributeDefinition` that executes a script in order to populate the values of the generated attribute.

The evaluated script has access to the following information:

- A script attribute whose name is the ID of this attribute definition and whose value is a newly constructed `IdPAttribute`.
- A script attribute whose name is `context` and whose value is the current `AttributeResolutionContext`
- A script attribute for every attribute produced by the dependencies of this attribute definition. The name of the script attribute is the ID of the `IdPAttribute` and its value is the `List` of `IdPAttributeValue` for the attribute.

The evaluated script should populate the values of the newly constructed `IdPAttribute` mentioned above. No other information from the script will be taken in to account.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`private class`
`ScriptedAttributeDefinition.AttributeDefinitionScriptEvaluator`
Evaluator bound to the AttributeDefinition semantic.

## Field Summary

Fields
Modifier and Type
Field
Description
`private Collection<ResolverScriptContextExtender>`
`contextExtenders`
Extenders for script context.
`private Object`
`customObject`
The custom object we inject into all scripts.
`private final org.slf4j.Logger`
`log`
Class logger.
`private EvaluableScript`
`script`
Script to be evaluated.
`private ScriptedAttributeDefinition.AttributeDefinitionScriptEvaluator`
`scriptEvaluator`
Evaluator.

## Constructor Summary

Constructors
Constructor
Description
`ScriptedAttributeDefinition()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`protected IdPAttribute`
`doAttributeDefinitionResolve(AttributeResolutionContext resolutionContext, AttributeResolverWorkContext workContext)`
Creates and populates the values for the resolved attribute.
`protected void`
`doInitialize()`
`Object`
`getCustomObject()`
Return the custom (externally provided) object.
`EvaluableScript`
`getScript()`
Gets the script to be evaluated.
`void`
`setCustomObject(Object object)`
Set the custom (externally provided) object.
`void`
`setScript(EvaluableScript definitionScript)`
Sets the script to be evaluated.
`void`
`setScriptContextExtenders(Collection<ResolverScriptContextExtender> extenders)`
Set any script context extenders to apply.

### Methods inherited from class net.shibboleth.idp.attribute.resolver.AbstractAttributeDefinition

`doResolve, getLogPrefix, isDependencyOnly, isPreRequested, setDependencyOnly, setPreRequested`

### Methods inherited from class net.shibboleth.idp.attribute.resolver.AbstractResolverPlugin

`doDestroy, equals, getActivationCondition, getAttributeDependencies, getDataConnectorDependencies, hashCode, isPropagateResolutionExceptions, resolve, setActivationCondition, setAttributeDependencies, setDataConnectorDependencies, setPropagateResolutionExceptions`

### 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, initialize, isDestroyed, isInitialized`

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

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

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

`destroy, isDestroyed`

### Methods inherited from interface org.springframework.beans.factory.DisposableBean

`destroy`

### 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 net.shibboleth.idp.attribute.resolver.ResolverPlugin

`getActivationCondition, getAttributeDependencies, getDataConnectorDependencies, isPropagateResolutionExceptions, resolve`

## Field Details

### log

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

### script

@NonnullAfterInit private EvaluableScript script
Script to be evaluated.

### scriptEvaluator

@NonnullAfterInit private ScriptedAttributeDefinition.AttributeDefinitionScriptEvaluator scriptEvaluator
Evaluator.

### contextExtenders

@Nonnull private Collection<ResolverScriptContextExtender> contextExtenders
Extenders for script context.

### customObject

@Nullable private Object customObject
The custom object we inject into all scripts.

## Constructor Details

### ScriptedAttributeDefinition

public ScriptedAttributeDefinition()
Constructor.

## Method Details

### getCustomObject

@Nullable public Object getCustomObject()
Return the custom (externally provided) object.

Returns:
  the custom object

### setCustomObject

public void setCustomObject(@Nullable Object object)
Set the custom (externally provided) object.

Parameters:
  `object` - the custom object

### getScript

@NonnullAfterInit public EvaluableScript getScript()
Gets the script to be evaluated.

Returns:
  the script to be evaluated

### setScript

public void setScript(@Nonnull EvaluableScript definitionScript)
Sets the script to be evaluated.

Parameters:
  `definitionScript` - the script to be evaluated

### setScriptContextExtenders

public void setScriptContextExtenders(@Nullable Collection<ResolverScriptContextExtender> extenders)
Set any script context extenders to apply.

Parameters:
  `extenders` - script extenders
Since:
  5.0.0

### doInitialize

protected void doInitialize() throws ComponentInitializationException

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

### doAttributeDefinitionResolve

@Nullable protected IdPAttribute doAttributeDefinitionResolve(@Nonnull AttributeResolutionContext resolutionContext, @Nonnull AttributeResolverWorkContext workContext) throws ResolutionException
Creates and populates the values for the resolved attribute. Implementations should not set, or otherwise manage, the resolved attribute's display name, description or encoders. Nor should the resultant attribute be recorded in the given resolution context.

Specified by:
  `doAttributeDefinitionResolve` in class `AbstractAttributeDefinition`
Parameters:
  `resolutionContext` - current attribute resolution context
  `workContext` - current resolver work context
Returns:
  resolved attribute or null if nothing to resolve.
Throws:
  `ResolutionException` - thrown if there is a problem resolving and creating the attribute