Package net.shibboleth.shared.logic
Class ScriptedPredicate<T>
java.lang.Object
net.shibboleth.shared.scripting.AbstractScriptEvaluator
net.shibboleth.shared.logic.ScriptedPredicate<T>
- Type Parameters:
T- input type
- All Implemented Interfaces:
Predicate<T>
A
Predicate which calls out to a supplied script.- Since:
- 7.4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionInput type.private final org.slf4j.LoggerClass logger.Fields inherited from class net.shibboleth.shared.scripting.AbstractScriptEvaluator
DEFAULT_ENGINE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedScriptedPredicate(EvaluableScript theScript) Constructor.protectedScriptedPredicate(EvaluableScript theScript, String extraInfo) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionGet the input type to be enforced.static <T> ScriptedPredicate<T>inlineScript(String scriptSource) Factory to createScriptedPredicatefrom inline data.static <T> ScriptedPredicate<T>inlineScript(String engineName, String scriptSource) Factory to createScriptedPredicatefrom inline data.protected voidprepareContext(ScriptContext scriptContext, Object... input) Pre-process the script context before execution.static <T> ScriptedPredicate<T>resourceScript(String engineName, Resource resource) Factory to createScriptedPredicatefrom aResource.static <T> ScriptedPredicate<T>resourceScript(Resource resource) Factory to createScriptedPredicatefrom aResource.private booleanHelper function to sanity check return-on-error object.voidsetInputType(Class<T> type) Set the input type to be enforced.voidsetReturnOnError(boolean flag) Set value to return if an error occurs.booleanMethods inherited from class net.shibboleth.shared.scripting.AbstractScriptEvaluator
evaluate, finalizeContext, getCustomObject, getHideExceptions, getLogPrefix, getOutputType, getReturnOnError, setContextExtenders, setCustomObject, setHideExceptions, setLogPrefix, setOutputType, setReturnOnError
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
inputTypeClass
Input type.
-
-
Constructor Details
-
Method Details
-
getInputType
Get the input type to be enforced.- Returns:
- input type
- Since:
- 8.2.0
-
setInputType
Set the input type to be enforced.- Parameters:
type- input type- Since:
- 8.2.0
-
setReturnOnError
public void setReturnOnError(boolean flag) Set value to return if an error occurs.- Parameters:
flag- value to return
-
test
-
returnError
Helper function to sanity check return-on-error object.- Returns:
- a boolean-valued error fallback
- Throws:
ClassCastException- if the installed fallback is null or non-Boolean
-
prepareContext
Pre-process the script context before execution.- Specified by:
prepareContextin classAbstractScriptEvaluator- Parameters:
scriptContext- the script contextinput- the input
-
inlineScript
@Nonnull public static <T> ScriptedPredicate<T> inlineScript(@Nonnull @NotEmpty @ParameterName(name="engineName") String engineName, @Nonnull @NotEmpty @ParameterName(name="scriptSource") String scriptSource) throws ScriptException, ComponentInitializationException Factory to createScriptedPredicatefrom inline data.- Type Parameters:
T- input type- Parameters:
scriptSource- the script, as a stringengineName- the language- Returns:
- the predicate
- Throws:
ScriptException- if the compile failsComponentInitializationException- if the scripting initialization fails
-
inlineScript
@Nonnull public static <T> ScriptedPredicate<T> inlineScript(@Nonnull @NotEmpty @ParameterName(name="scriptSource") String scriptSource) throws ScriptException, ComponentInitializationException Factory to createScriptedPredicatefrom inline data.- Type Parameters:
T- input type- Parameters:
scriptSource- the script, as a string- Returns:
- the predicate
- Throws:
ScriptException- if the compile failsComponentInitializationException- if the scripting initialization fails
-