Package org.forgerock.openig.script
Class AbstractScriptableHeapObject<V>
- java.lang.Object
-
- org.forgerock.openig.script.AbstractScriptableHeapObject<V>
-
- Type Parameters:
V- The expected result type of thePromise. As a convenience, this class supports non-Promise type to be returned from the script, and will wrap it into aPromise.
- Direct Known Subclasses:
ScriptableAccessTokenResolver,ScriptableFilter,ScriptableHandler,ScriptableThrottlingPolicy
public class AbstractScriptableHeapObject<V> extends Object
A scriptable heap object acts as a simple wrapper around the scripting engine.This class is a base class for implementing any interface that we want to make pluggable through scripting support.
Scripts are provided with the following variables bindings:
logger- The logger for this scriptglobals- the Map of global variables which persist across successive invocations of the scriptcontext- the associated request contextcontexts- the visible contexts, keyed by context's namehttp- an HTTP client which may be used for performing outbound HTTP requestsldap- an OpenIG LDAP client which may be used for performing LDAP requests such as LDAP authentication
The provided
argsparameters supports config-time expressions evaluation with the special addition of aheapvariable that allows the script to get references to other objects available in the heap.{ "args": { "ref": "heap['object-name']" } }NOTE : at the moment only Groovy is supported.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classAbstractScriptableHeapObject.AbstractScriptableHeapletCreates and initializes a capture filter in a heap environment.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractScriptableHeapObject(Script compiledScript, Heap heap, String name)Creates a new scriptable heap object using the provided compiled script.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.forgerock.util.promise.Promise<V,ScriptException>runScript(Bindings bindings, org.forgerock.services.context.Context context, Class<V> clazz)Runs the compiled script using the provided bindings.voidsetArgs(Map<String,Object> args)Sets the parameters which should be made available to scripts.voidsetClientHandler(org.forgerock.http.Handler clientHandler)Sets the HTTP client handler which should be made available to scripts.
-
-
-
Constructor Detail
-
AbstractScriptableHeapObject
protected AbstractScriptableHeapObject(Script compiledScript, Heap heap, String name)
Creates a new scriptable heap object using the provided compiled script.- Parameters:
compiledScript- The compiled script.heap- The heap to look for bindingsname- The name of this scriptable heap object.
-
-
Method Detail
-
setClientHandler
public void setClientHandler(org.forgerock.http.Handler clientHandler)
Sets the HTTP client handler which should be made available to scripts.- Parameters:
clientHandler- The HTTP client handler which should be made available to scripts.
-
setArgs
public void setArgs(Map<String,Object> args)
Sets the parameters which should be made available to scripts.- Parameters:
args- The parameters which should be made available to scripts.
-
runScript
protected final org.forgerock.util.promise.Promise<V,ScriptException> runScript(Bindings bindings, org.forgerock.services.context.Context context, Class<V> clazz)
Runs the compiled script using the provided bindings.- Parameters:
bindings- Base bindings available to the script (will be enriched).context- request processing contextclazz- the class representing the expected result type of thePromise- Returns:
- the Promise of a Response produced by the script
-
-