...
A Scripted Function is instantiated using one of two 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 (Function, BiFunction) for complete details.
Localtabgroup |
---|
Localtab live |
---|
active | true Expand |
---|
|
If provided with one parameter, this is the script to be executed. If two parameters are the provided, then the first is the name of the (installed) JSR-223 lanuage and the second is the script. Code Block |
---|
<bean id="MyFunction" parent="shibboleth.Functions.Scripted" factory-method="inlineScript"
p:inputType="java.lang.Integer" p:outputType="java.lang.Integer"
p:hideExceptions="true">
<constructor-arg>
<value>
<![CDATA[
input + 42;
]]>
</value>
</constructor-arg>
</bean> | localtab-live |
Expand |
---|
|
If provided with one parameter this is the location (usually the file name) of the resource (file) containing the script. If two parameters are provided, the the first is the name of the (installed) JSR-223 lanuage and the second is the location. Code Block |
---|
<bean id="MyFunction" parent="shibboleth.Functions.Scripted" factory-method="resourceScript"
c:_0="javascript" c:_1="%{idp.home}/conf/script.js" /> |
|
Reference
Localtabgroup |
---|
Localtab live |
---|
active | true Expand |
---|
|
The following additional bean properties are available: 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 | inputType (Function variant) | Class<?> | | Adds type checking against the input to the function to enforce type safety | inputTypes (BiFunction variant) | Pair<Class<?>,Class<?>> | | Adds type checking against the input to the function to enforce type safety | outputType | Class<?> | | Adds type checking against the output of the function to enforce type safety |
localtab-live |
Expand |
---|
|
For the Function variant, the script environment will have these variables populated: For the BiFunction variant, the script environment will have these variables populated: input1 - the first function input
input2 - the second function input
custom - the object set via the customObject property, if any
|
...