Class ScriptedAttributeDefinition
- 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.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
AnAttributeDefinitionthat 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
contextand whose value is the currentAttributeResolutionContext - 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
IdPAttributeand its value is theListofIdPAttributeValuefor the attribute.
The evaluated script should populate the values of the newly constructed
IdPAttributementioned above. No other information from the script will be taken in to account.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classScriptedAttributeDefinition.AttributeDefinitionScriptEvaluatorEvaluator bound to the AttributeDefinition semantic.
-
Field Summary
Fields Modifier and Type Field Description private ObjectcustomObjectThe custom object we inject into all scripts.private org.slf4j.LoggerlogClass logger.private Function<AttributeResolutionContext,ProfileRequestContext>prcLookupStrategyStrategy used to locate theProfileRequestContextto use.private Function<ProfileRequestContext,SubjectContext>scLookupStrategyStrategy used to locate theSubjectContextto use.private EvaluableScriptscriptScript to be evaluated.private ScriptedAttributeDefinition.AttributeDefinitionScriptEvaluatorscriptEvaluatorEvaluator.
-
Constructor Summary
Constructors Constructor Description ScriptedAttributeDefinition()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected IdPAttributedoAttributeDefinitionResolve(AttributeResolutionContext resolutionContext, AttributeResolverWorkContext workContext)protected voiddoInitialize()ObjectgetCustomObject()Return the custom (externally provided) object.EvaluableScriptgetScript()Gets the script to be evaluated.voidsetCustomObject(Object object)Set the custom (externally provided) object.voidsetProfileRequestContextLookupStrategy(Function<AttributeResolutionContext,ProfileRequestContext> strategy)Set the strategy used to locate theProfileRequestContextassociated with a givenAttributeResolutionContext.voidsetScript(EvaluableScript definitionScript)Sets the script to be evaluated.voidsetSubjectContextLookupStrategy(Function<ProfileRequestContext,SubjectContext> strategy)Set the strategy used to locate theSubjectContextassociated with a givenAttributeResolutionContext.-
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
addDisplayInformation, doDestroy, equals, getActivationCondition, getAttributeDependencies, getDataConnectorDependencies, getProfileContextStrategy, hashCode, isPropagateResolutionExceptions, isSuppressDisplayInformation, resolve, setActivationCondition, setAttributeDependencies, setDataConnectorDependencies, setProfileContextStrategy, setPropagateResolutionExceptions, setSuppressDisplayInformation
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent
setId
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
getId
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
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.utilities.java.support.component.DestructableComponent
destroy, isDestroyed
-
Methods inherited from interface org.springframework.beans.factory.DisposableBean
destroy
-
Methods inherited from interface net.shibboleth.utilities.java.support.component.IdentifiedComponent
getId
-
Methods inherited from interface net.shibboleth.utilities.java.support.component.InitializableComponent
initialize, isInitialized
-
Methods inherited from interface net.shibboleth.idp.attribute.resolver.ResolverPlugin
getActivationCondition, getAttributeDependencies, getDataConnectorDependencies, isPropagateResolutionExceptions, resolve
-
-
-
-
Field Detail
-
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.
-
prcLookupStrategy
@Nonnull private Function<AttributeResolutionContext,ProfileRequestContext> prcLookupStrategy
Strategy used to locate theProfileRequestContextto use.
-
scLookupStrategy
@Nonnull private Function<ProfileRequestContext,SubjectContext> scLookupStrategy
Strategy used to locate theSubjectContextto use.
-
customObject
@Nullable private Object customObject
The custom object we inject into all scripts.
-
-
Method Detail
-
getCustomObject
@Nullable public Object getCustomObject()
Return the custom (externally provided) object.- Returns:
- the custom object
-
setCustomObject
@Nullable public void setCustomObject(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
-
setProfileRequestContextLookupStrategy
public void setProfileRequestContextLookupStrategy(@Nonnull Function<AttributeResolutionContext,ProfileRequestContext> strategy)Set the strategy used to locate theProfileRequestContextassociated with a givenAttributeResolutionContext.- Parameters:
strategy- strategy used to locate theProfileRequestContextassociated with a givenAttributeResolutionContext
-
setSubjectContextLookupStrategy
public void setSubjectContextLookupStrategy(@Nonnull Function<ProfileRequestContext,SubjectContext> strategy)Set the strategy used to locate theSubjectContextassociated with a givenAttributeResolutionContext.- Parameters:
strategy- strategy used to locate theSubjectContextassociated with a givenAttributeResolutionContext
-
doInitialize
protected void doInitialize() throws ComponentInitializationException- Overrides:
doInitializein classAbstractAttributeDefinition- Throws:
ComponentInitializationException
-
doAttributeDefinitionResolve
@Nullable protected IdPAttribute doAttributeDefinitionResolve(@Nonnull AttributeResolutionContext resolutionContext, @Nonnull AttributeResolverWorkContext workContext) throws ResolutionException
- Specified by:
doAttributeDefinitionResolvein classAbstractAttributeDefinition- Throws:
ResolutionException
-
-