Class ScriptedContextLookupFunction<T extends BaseContext>
- java.lang.Object
-
- net.shibboleth.utilities.java.support.scripting.AbstractScriptEvaluator
-
- net.shibboleth.idp.profile.context.navigate.ScriptedContextLookupFunction<T>
-
- Type Parameters:
T- the specific type of context
- All Implemented Interfaces:
Function<T,Object>,ContextDataLookupFunction<T,Object>
public class ScriptedContextLookupFunction<T extends BaseContext> extends AbstractScriptEvaluator implements ContextDataLookupFunction<T,Object>
AFunctionover aBaseContextwhich calls out to a supplied script.
-
-
Field Summary
Fields Modifier and Type Field Description private Class<T>inputClassWhat class we want the input to test against.-
Fields inherited from class net.shibboleth.utilities.java.support.scripting.AbstractScriptEvaluator
DEFAULT_ENGINE
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedScriptedContextLookupFunction(Class<T> inClass, EvaluableScript theScript)Constructor.protectedScriptedContextLookupFunction(Class<T> inClass, EvaluableScript theScript, String extraInfo)Constructor.protectedScriptedContextLookupFunction(Class<T> inClass, EvaluableScript theScript, String extraInfo, Class<?> outputType)Constructor.
-
Method Summary
-
Methods inherited from class net.shibboleth.utilities.java.support.scripting.AbstractScriptEvaluator
evaluate, finalizeContext, getHideExceptions, getLogPrefix, getOutputType, getReturnOnError, setCustomObject, setHideExceptions, setLogPrefix, setOutputType, setReturnOnError
-
-
-
-
Field Detail
-
inputClass
@Nonnull private final Class<T extends BaseContext> inputClass
What class we want the input to test against.
-
-
Constructor Detail
-
ScriptedContextLookupFunction
protected ScriptedContextLookupFunction(@Nonnull Class<T> inClass, @Nonnull EvaluableScript theScript, @Nullable String extraInfo)Constructor.- Parameters:
inClass- the class we accept as input.theScript- the script we will evaluate.extraInfo- debugging information.
-
ScriptedContextLookupFunction
protected ScriptedContextLookupFunction(@Nonnull Class<T> inClass, @Nonnull EvaluableScript theScript)Constructor.- Parameters:
inClass- the class we accept as input.theScript- the script we will evaluate.
-
ScriptedContextLookupFunction
protected ScriptedContextLookupFunction(@Nonnull Class<T> inClass, @Nonnull EvaluableScript theScript, @Nullable String extraInfo, @Nullable Class<?> outputType)Constructor.- Parameters:
inClass- the class we accept as input.theScript- the script we will evaluate.extraInfo- debugging information.outputType- the type to test against.
-
-
Method Detail
-
getCustomObject
@Nullable public Object getCustomObject()
- Overrides:
getCustomObjectin classAbstractScriptEvaluator
-
apply
public Object apply(@Nullable T context)
- Specified by:
applyin interfaceFunction<T extends BaseContext,Object>
-
prepareContext
protected void prepareContext(@Nonnull ScriptContext scriptContext, @Nullable Object... input)- Specified by:
prepareContextin classAbstractScriptEvaluator
-
resourceScript
@Nonnull public static ScriptedContextLookupFunction<ProfileRequestContext> resourceScript(@Nonnull @NotEmpty String engineName, @Nonnull Resource resource) throws ScriptException, IOException
- Parameters:
resource- the resource to look atengineName- the language- Returns:
- the function
- Throws:
ScriptException- if the compile failsIOException- if the file doesn't exist.
-
resourceScript
@Nonnull public static ScriptedContextLookupFunction<ProfileRequestContext> resourceScript(@Nonnull @NotEmpty String engineName, @Nonnull Resource resource, @Nullable Class<?> outputType) throws ScriptException, IOException
- Parameters:
resource- the resource to look atengineName- the languageoutputType- the type to test against.- Returns:
- the function
- Throws:
ScriptException- if the compile failsIOException- if the file doesn't exist.
-
resourceScript
@Nonnull public static ScriptedContextLookupFunction<ProfileRequestContext> resourceScript(Resource resource) throws ScriptException, IOException
Factory to createScriptedContextLookupFunctionfrom aResource.- Parameters:
resource- the resource to look at- Returns:
- the function
- Throws:
ScriptException- if the compile failsIOException- if the file doesn't exist.
-
resourceScript
@Nonnull public static ScriptedContextLookupFunction<ProfileRequestContext> resourceScript(Resource resource, @Nullable Class<?> outputType) throws ScriptException, IOException
- Parameters:
resource- the resource to look atoutputType- the type to test against.- Returns:
- the function
- Throws:
ScriptException- if the compile failsIOException- if the file doesn't exist.
-
inlineScript
@Nonnull public static ScriptedContextLookupFunction<ProfileRequestContext> inlineScript(@Nonnull @NotEmpty String engineName, @Nonnull @NotEmpty String scriptSource) throws ScriptException
Factory to createScriptedContextLookupFunctionforProfileRequestContexts from inline data.- Parameters:
scriptSource- the script, as a stringengineName- the language- Returns:
- the function
- Throws:
ScriptException- if the compile fails
-
inlineScript
@Nonnull public static ScriptedContextLookupFunction<ProfileRequestContext> inlineScript(@Nonnull @NotEmpty String engineName, @Nonnull @NotEmpty String scriptSource, @Nullable Class<?> outputType) throws ScriptException
Factory to createScriptedContextLookupFunctionforProfileRequestContexts from inline data.- Parameters:
scriptSource- the script, as a stringengineName- the languageoutputType- the type to test against.- Returns:
- the function
- Throws:
ScriptException- if the compile fails
-
inlineScript
@Nonnull public static ScriptedContextLookupFunction<ProfileRequestContext> inlineScript(@Nonnull @NotEmpty String scriptSource) throws ScriptException
Factory to createScriptedContextLookupFunctionforProfileRequestContexts from inline data.- Parameters:
scriptSource- the script, as a string- Returns:
- the function
- Throws:
ScriptException- if the compile fails
-
inlineScript
@Nonnull public static ScriptedContextLookupFunction<ProfileRequestContext> inlineScript(@Nonnull @NotEmpty String scriptSource, @Nullable Class<?> outputType) throws ScriptException
Factory to createScriptedContextLookupFunctionforProfileRequestContexts from inline data.- Parameters:
scriptSource- the script, as a stringoutputType- the type to test against.- Returns:
- the function
- Throws:
ScriptException- if the compile fails
-
resourceMessageContextScript
@Nonnull public static ScriptedContextLookupFunction<MessageContext> resourceMessageContextScript(@Nonnull @NotEmpty String engineName, @Nonnull Resource resource) throws ScriptException, IOException
- Parameters:
resource- the resource to look atengineName- the language- Returns:
- the function
- Throws:
ScriptException- if the compile failsIOException- if the file doesn't exist.
-
resourceMessageContextScript
@Nonnull public static ScriptedContextLookupFunction<MessageContext> resourceMessageContextScript(@Nonnull @NotEmpty String engineName, @Nonnull Resource resource, @Nullable Class<?> outputType) throws ScriptException, IOException
- Parameters:
resource- the resource to look atengineName- the languageoutputType- the type to test against.- Returns:
- the function
- Throws:
ScriptException- if the compile failsIOException- if the file doesn't exist.
-
resourceMessageContextScript
@Nonnull public static ScriptedContextLookupFunction<MessageContext> resourceMessageContextScript(Resource resource) throws ScriptException, IOException
- Parameters:
resource- the resource to look at- Returns:
- the function
- Throws:
ScriptException- if the compile failsIOException- if the file doesn't exist.
-
resourceMessageContextScript
@Nonnull public static ScriptedContextLookupFunction<MessageContext> resourceMessageContextScript(Resource resource, @Nullable Class<?> outputType) throws ScriptException, IOException
- Parameters:
resource- the resource to look atoutputType- the type to test against.- Returns:
- the function
- Throws:
ScriptException- if the compile failsIOException- if the file doesn't exist.
-
inlineMessageContextScript
@Nonnull public static ScriptedContextLookupFunction<MessageContext> inlineMessageContextScript(@Nonnull @NotEmpty String engineName, @Nonnull @NotEmpty String scriptSource) throws ScriptException
Factory to createScriptedContextLookupFunctionforMessageContexts from inline data.- Parameters:
scriptSource- the script, as a stringengineName- the language- Returns:
- the function
- Throws:
ScriptException- if the compile fails
-
inlineMessageContextScript
@Nonnull public static ScriptedContextLookupFunction<MessageContext> inlineMessageContextScript(@Nonnull @NotEmpty String engineName, @Nonnull @NotEmpty String scriptSource, @Nullable Class<?> outputType) throws ScriptException
Factory to createScriptedContextLookupFunctionforMessageContexts from inline data.- Parameters:
scriptSource- the script, as a stringengineName- the languageoutputType- the type to test against.- Returns:
- the function
- Throws:
ScriptException- if the compile fails
-
inlineMessageContextScript
@Nonnull public static ScriptedContextLookupFunction<MessageContext> inlineMessageContextScript(@Nonnull @NotEmpty String scriptSource) throws ScriptException
Factory to createScriptedContextLookupFunctionforMessageContexts from inline data.- Parameters:
scriptSource- the script, aMessageContexts a string- Returns:
- the function
- Throws:
ScriptException- if the compile fails
-
inlineMessageContextScript
@Nonnull public static ScriptedContextLookupFunction<MessageContext> inlineMessageContextScript(@Nonnull @NotEmpty String scriptSource, @Nullable Class<?> outputType) throws ScriptException
Factory to createScriptedContextLookupFunctionforMessageContexts from inline data.- Parameters:
scriptSource- the script, as a stringoutputType- the type to test against.- Returns:
- the function
- Throws:
ScriptException- if the compile fails
-
-