Package net.shibboleth.idp.profile

# Class ScriptedAction

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
org.opensaml.profile.action.AbstractProfileAction
org.opensaml.profile.action.AbstractConditionalProfileAction
net.shibboleth.idp.profile.AbstractProfileAction
net.shibboleth.idp.profile.ScriptedAction

All Implemented Interfaces:
  `Component`, `DestructableComponent`, `InitializableComponent`, `ProfileAction`, `Aware`, `MessageSource`, `MessageSourceAware`, `Action`

public class ScriptedAction extends AbstractProfileAction
An action which calls out to a supplied script.

The return value must be an event ID to signal. As this is a generic wrapper, the action may return any event depending on the context of the activity, and may manipulate the profile context tree as required.

Event:
  `EventIds.INVALID_PROFILE_CTX`

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`private class`
`ScriptedAction.ActionScriptEvaluator`
Evaluator bound to the Action semantic.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`DEFAULT_ENGINE`
The default language is Javascript.
`private final org.slf4j.Logger`
`log`
Class logger.
`private final ScriptedAction.ActionScriptEvaluator`
`scriptEvaluator`
Evaluator.

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`ScriptedAction(EvaluableScript theScript)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`void`
`doExecute(ProfileRequestContext profileContext)`
`protected void`
`doInitialize()`
`Object`
`getCustomObject()`
Return the custom (externally provided) object.
`static ScriptedAction`
`inlineScript(String scriptSource)`
Factory to create `ScriptedAction` from inline data.
`static ScriptedAction`
`inlineScript(String engineName, String scriptSource)`
Factory to create `ScriptedAction` from inline data.
`static ScriptedAction`
`resourceScript(String engineName, Resource resource)`
Factory to create `ScriptedAction` from a `Resource`.
`static ScriptedAction`
`resourceScript(Resource resource)`
Factory to create `ScriptedAction` from a `Resource`.
`void`
`setCustomObject(Object object)`
Set the custom (externally provided) object.
`void`
`setHideExceptions(boolean flag)`
Set whether to hide exceptions in script execution (default is false).

### Methods inherited from class net.shibboleth.idp.profile.AbstractProfileAction

`doExecute, execute, getBean, getBean, getMessage, getMessage, getMessage, getParameter, getParameter, getProfileContextLookupStrategy, getRequestContext, getResult, setMessageSource, setProfileContextLookupStrategy`

### Methods inherited from class org.opensaml.profile.action.AbstractConditionalProfileAction

`doPreExecute, getActivationCondition, setActivationCondition`

### Methods inherited from class org.opensaml.profile.action.AbstractProfileAction

`doPostExecute, doPostExecute, ensureHttpServletRequest, ensureHttpServletResponse, execute, getHttpServletRequest, getHttpServletRequestSupplier, getHttpServletResponse, getHttpServletResponseSupplier, getLogPrefix, isPreExecuteCalled, setHttpServletRequestSupplier, setHttpServletResponseSupplier`

### 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 net.shibboleth.shared.component.InitializableComponent

`initialize, isInitialized`

## Field Details

### DEFAULT_ENGINE

@Nonnull @NotEmpty public static final String DEFAULT_ENGINE
The default language is Javascript.

See Also:
  - Constant Field Values

### log

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

### scriptEvaluator

@Nonnull private final ScriptedAction.ActionScriptEvaluator scriptEvaluator
Evaluator.

## Constructor Details

### ScriptedAction

protected ScriptedAction(@Nonnull EvaluableScript theScript)
Constructor.

Parameters:
  `theScript` - the script we will evaluate

## 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

### setHideExceptions

public void setHideExceptions(boolean flag)
Set whether to hide exceptions in script execution (default is false).

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

### doInitialize

protected void doInitialize() throws ComponentInitializationException

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

### doExecute

public void doExecute(@Nonnull ProfileRequestContext profileContext)

Overrides:
  `doExecute` in class `AbstractProfileAction`

### resourceScript

@Nonnull public static ScriptedAction resourceScript(@Nonnull @NotEmpty @ParameterName(name="engineName") String engineName, @Nonnull @ParameterName(name="resource") Resource resource) throws ScriptException, IOException, ComponentInitializationException
Factory to create `ScriptedAction` from a `Resource`.

Parameters:
  `resource` - the resource to look at
  `engineName` - the language
Returns:
  the predicate
Throws:
  `ScriptException` - if the compile fails
  `IOException` - if the file doesn't exist.
  `ComponentInitializationException` - if the scripting initialization fails

### resourceScript

@Nonnull public static ScriptedAction resourceScript(@Nonnull @ParameterName(name="resource") Resource resource) throws ScriptException, IOException, ComponentInitializationException
Factory to create `ScriptedAction` from a `Resource`.

Parameters:
  `resource` - the resource to look at
Returns:
  the predicate
Throws:
  `ScriptException` - if the compile fails
  `IOException` - if the file doesn't exist.
  `ComponentInitializationException` - if the scripting initialization fails

### inlineScript

@Nonnull public static ScriptedAction inlineScript(@Nonnull @NotEmpty @ParameterName(name="engineName") String engineName, @Nonnull @NotEmpty @ParameterName(name="scriptSource") String scriptSource) throws ScriptException, ComponentInitializationException
Factory to create `ScriptedAction` from inline data.

Parameters:
  `scriptSource` - the script, as a string
  `engineName` - the language
Returns:
  the predicate
Throws:
  `ScriptException` - if the compile fails
  `ComponentInitializationException` - if the scripting initialization fails

### inlineScript

@Nonnull public static ScriptedAction inlineScript(@Nonnull @NotEmpty @ParameterName(name="scriptSource") String scriptSource) throws ScriptException, ComponentInitializationException
Factory to create `ScriptedAction` from inline data.

Parameters:
  `scriptSource` - the script, as a string
Returns:
  the predicate
Throws:
  `ScriptException` - if the compile fails
  `ComponentInitializationException` - if the scripting initialization fails