The Shibboleth IdP V4 software has reached its End of Life and is no longer supported. This documentation is available for historical purposes only. See the IDP5 wiki space for current documentation on the supported version.

ScriptedContextFunction

The bean named shibboleth.ContextFunctions.Scripted executes a JSR-223 scriptlet to implement a Function operating against either a ProfileRequestContext or MessageContext, which are the two most common "roots" of important state information during a request.

Configuration

A Scripted ContextFunction is instantiated using one of a large number of static factory methods (rather than created directly by invoking a Java constructor), so they have a different syntax in Spring. You can refer to the javadoc for complete details.

These factory methods are used to construct functions over a ProfileRequestContext or MessageContext respectively. Various variants exist to control the scripting engine and output type, but all of them rely on a String parameter to supply the script itself.

<bean id="MyPRCFunction" parent="shibboleth.ContextFunctions.Scripted" factory-method="inlineScript" c:outputType="java.lang.String" p:hideExceptions="true"> <constructor-arg name="scriptSource"> <value> <![CDATA[ input.getLoggingId(); ]]> </value> </constructor-arg> </bean>

resourceScript, resourceMessageContextScript

These factory methods are used to construct functions over a ProfileRequestContext or MessageContext respectively. Various variants exist to control the scripting engine and output type, but all of them rely on a String parameter to supply the location of a resource (file) containing the script.

<bean id="MyPRCFunction" parent="shibboleth.ContextFunctions.Scripted" factory-method="resourceScript" c:_0="%{idp.home}/conf/script.js" />

Reference

Properties

The following additional bean properties are available:

PropertyName

Type

Default

Description

PropertyName

Type

Default

Description

customObject

Bean/Reference



An object to make available to the script via a variable named custom

returnOnError

Object

null

What to return if the script fails

hideExceptions

boolean

false

If true, then the returnOnError value is returned if the script raises an exception, otherwise the exception is passed out

outputType

Class<?>



Adds type checking against the output of the function to enforce type safety

Script Context

The script environment will have two variables populated:

  • input - the function input

  • custom - the object set via the customObject property, if any