Class ScriptableFilter
- java.lang.Object
-
- org.forgerock.openig.script.AbstractScriptableHeapObject<Response>
-
- org.forgerock.openig.filter.ScriptableFilter
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Filter
public class ScriptableFilter extends AbstractScriptableHeapObject<Response> implements Filter
A scriptable filter. This filter acts as a simple wrapper around the scripting engine. Scripts are provided with the bindings provided byAbstractScriptableHeapObject
plus :context
- the associated request contextrequest
- the HTTP requestnext
- the next handler in the filter chain.
Contains also easy access to
attributes
from theAttributesContext
, e.g:attributes.user = "jackson"
, instead ofcontexts.attributes.attributes.user = "jackson"
.In the same way, it gives access to
session
from theSessionContext
, for example, you can use:session.put(...)
, instead ofcontexts.session.session.put(...)
.Like Java based filters, scripts are free to choose whether or not they forward the request to the next handler or, instead, return a response immediately.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ScriptableFilter.Heaplet
Creates and initializes a scriptable filter in a heap environment.-
Nested classes/interfaces inherited from class org.forgerock.openig.script.AbstractScriptableHeapObject
AbstractScriptableHeapObject.AbstractScriptableHeaplet<V>
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Promise<Response,NeverThrowsException>
filter(Context context, Request request, Handler next)
Filters the request and/or response of an exchange.-
Methods inherited from class org.forgerock.openig.script.AbstractScriptableHeapObject
close, runScript, runScriptAsync, setArgs, setClientHandler
-
-
-
-
Method Detail
-
filter
public Promise<Response,NeverThrowsException> filter(Context context, Request request, Handler next)
Description copied from interface:Filter
Filters the request and/or response of an exchange. To pass the request to the next filter or handler in the chain, the filter callsnext.handle(context, request)
.This method may elect not to pass the request to the next filter or handler, and instead handle the request itself. It can achieve this by merely avoiding a call to
next.handle(context, request)
and creating its own response object. The filter is also at liberty to replace a response with another of its own by intercepting the response returned by the next handler.
-
-