public class ScriptedPredicate extends Object implements Predicate<ProfileRequestContext>
Predicate which calls out to a supplied script.| Modifier and Type | Field and Description |
|---|---|
private Object |
customObject
A custom object to inject into the script.
|
static String |
DEFAULT_ENGINE
The default language is Javascript.
|
private boolean |
hideExceptions
Whether to raise runtime exceptions if a script fails.
|
private org.slf4j.Logger |
log
log.
|
private String |
logPrefix
Debugging info.
|
private boolean |
returnOnError
Value to return from predicate when an error occurs.
|
private EvaluableScript |
script
The script we care about.
|
| Constructor and Description |
|---|
ScriptedPredicate(EvaluableScript theScript)
Constructor.
|
ScriptedPredicate(EvaluableScript theScript,
String extraInfo)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
apply(ProfileRequestContext profileContext) |
Object |
getCustomObject()
Return the custom (externally provided) object.
|
(package private) static ScriptedPredicate |
inlineScript(String scriptSource)
Factory to create
ScriptedPredicate from inline data. |
(package private) static ScriptedPredicate |
inlineScript(String engineName,
String scriptSource)
Factory to create
ScriptedPredicate from inline data. |
(package private) static ScriptedPredicate |
resourceScript(Resource resource)
Factory to create
ScriptedPredicate from a Resource. |
(package private) static ScriptedPredicate |
resourceScript(String engineName,
Resource resource)
Factory to create
ScriptedPredicate 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).
|
void |
setReturnOnError(boolean flag)
Set value to return if an error occurs (default is false).
|
public static final String DEFAULT_ENGINE
private final org.slf4j.Logger log
@Nonnull private final EvaluableScript script
private boolean hideExceptions
private boolean returnOnError
public ScriptedPredicate(@Nonnull@NotEmpty@ParameterName(name="theScript") EvaluableScript theScript, @Nullable@NotEmpty@ParameterName(name="extraInfo") String extraInfo)
theScript - the script we will evaluate.extraInfo - debugging information.public ScriptedPredicate(@Nonnull@NotEmpty@ParameterName(name="theScript") EvaluableScript theScript)
theScript - the script we will evaluate.@Nullable public Object getCustomObject()
public void setCustomObject(Object object)
object - the custom objectpublic void setHideExceptions(boolean flag)
flag - flag to setpublic void setReturnOnError(boolean flag)
flag - flag to setpublic boolean apply(@Nullable ProfileRequestContext profileContext)
apply in interface Predicate<ProfileRequestContext>static ScriptedPredicate resourceScript(@Nonnull@NotEmpty String engineName, @Nonnull Resource resource) throws ScriptException, IOException
ScriptedPredicate from a Resource.resource - the resource to look atengineName - the languageScriptException - if the compile failsIOException - if the file doesn't exist.static ScriptedPredicate resourceScript(Resource resource) throws ScriptException, IOException
ScriptedPredicate from a Resource.resource - the resource to look atScriptException - if the compile failsIOException - if the file doesn't exist.static ScriptedPredicate inlineScript(@Nonnull@NotEmpty String engineName, @Nonnull@NotEmpty String scriptSource) throws ScriptException
ScriptedPredicate from inline data.scriptSource - the script, as a stringengineName - the languageScriptException - if the compile failsstatic ScriptedPredicate inlineScript(@Nonnull@NotEmpty String scriptSource) throws ScriptException
ScriptedPredicate from inline data.scriptSource - the script, as a stringScriptException - if the compile failsCopyright © 1999–2017 Shibboleth Consortium. All rights reserved.