public class GroovyValueFilter extends GroovyInterceptor
GroovyInterceptor that looks at individual values that are coming into/out of a call,
without regard to any context.
One of the common strategies for filtering is to ensure that the sandboxed script don't acquire a reference to objects that they are not supposed to. This implementation works as a convenient base class for such interceptor by providing a smaller number of methods that can be overridden.
GroovyInterceptor.Invoker| Constructor and Description |
|---|
GroovyValueFilter() |
| Modifier and Type | Method and Description |
|---|---|
Object |
filter(Object o)
All the specific
filterXXX() methods delegate to this method. |
Object |
filterArgument(Object arg)
Called for every argument to method/constructor calls.
|
Object |
filterIndex(Object index)
Called for every index of the array get/set access.
|
Object |
filterReceiver(Object receiver)
Called for every receiver.
|
Object |
filterReturnValue(Object returnValue)
Called for a return value of a method call, newly created object, retrieve property/attribute values.
|
Object |
onGetArray(GroovyInterceptor.Invoker invoker,
Object receiver,
Object index)
Intercepts an array access, like "z=foo[bar]"
|
Object |
onGetAttribute(GroovyInterceptor.Invoker invoker,
Object receiver,
String attribute)
Intercepts an attribute access, like "z=foo.@bar"
|
Object |
onGetProperty(GroovyInterceptor.Invoker invoker,
Object receiver,
String property)
Intercepts a property access, like "z=foo.bar"
|
Object |
onMethodCall(GroovyInterceptor.Invoker invoker,
Object receiver,
String method,
Object... args)
Intercepts an instance method call on some object of the form "foo.bar(...)"
|
Object |
onNewInstance(GroovyInterceptor.Invoker invoker,
Class receiver,
Object... args)
Intercepts an object instantiation, like "new Receiver(...)"
|
Object |
onSetArray(GroovyInterceptor.Invoker invoker,
Object receiver,
Object index,
Object value)
Intercepts an attribute assignment like "foo[bar]=z"
|
Object |
onSetAttribute(GroovyInterceptor.Invoker invoker,
Object receiver,
String attribute,
Object value)
Intercepts an attribute assignment like "foo.@bar=z"
|
Object |
onSetProperty(GroovyInterceptor.Invoker invoker,
Object receiver,
String property,
Object value)
Intercepts a property assignment like "foo.bar=z"
|
Object |
onStaticCall(GroovyInterceptor.Invoker invoker,
Class receiver,
String method,
Object... args)
Intercepts a static method call on some class, like "Class.forName(...)".
|
getApplicableInterceptors, register, unregisterpublic Object filterReturnValue(Object returnValue)
public Object filterArgument(Object arg)
public Object filterIndex(Object index)
public Object onMethodCall(GroovyInterceptor.Invoker invoker, Object receiver, String method, Object... args) throws Throwable
GroovyInterceptoronMethodCall in class GroovyInterceptorThrowablepublic Object onStaticCall(GroovyInterceptor.Invoker invoker, Class receiver, String method, Object... args) throws Throwable
GroovyInterceptorClass can invoke static methods, too
(that is, x=Integer.class;x.valueOf(5) results in onMethodCall(invoker,Integer.class,"valueOf",5)onStaticCall in class GroovyInterceptorThrowablepublic Object onNewInstance(GroovyInterceptor.Invoker invoker, Class receiver, Object... args) throws Throwable
GroovyInterceptoronNewInstance in class GroovyInterceptorThrowablepublic Object onGetProperty(GroovyInterceptor.Invoker invoker, Object receiver, String property) throws Throwable
GroovyInterceptoronGetProperty in class GroovyInterceptorreceiver - 'foo' in the above example, the object whose property is accessed.property - 'bar' in the above example, the name of the propertyThrowablepublic Object onSetProperty(GroovyInterceptor.Invoker invoker, Object receiver, String property, Object value) throws Throwable
GroovyInterceptoronSetProperty in class GroovyInterceptorreceiver - 'foo' in the above example, the object whose property is accessed.property - 'bar' in the above example, the name of the propertyvalue - The value to be assigned.value.Throwablepublic Object onGetAttribute(GroovyInterceptor.Invoker invoker, Object receiver, String attribute) throws Throwable
GroovyInterceptoronGetAttribute in class GroovyInterceptorreceiver - 'foo' in the above example, the object whose attribute is accessed.attribute - 'bar' in the above example, the name of the attributeThrowablepublic Object onSetAttribute(GroovyInterceptor.Invoker invoker, Object receiver, String attribute, Object value) throws Throwable
GroovyInterceptoronSetAttribute in class GroovyInterceptorreceiver - 'foo' in the above example, the object whose attribute is accessed.attribute - 'bar' in the above example, the name of the attributevalue - The value to be assigned.value.Throwablepublic Object onGetArray(GroovyInterceptor.Invoker invoker, Object receiver, Object index) throws Throwable
GroovyInterceptoronGetArray in class GroovyInterceptorreceiver - 'foo' in the above example, the array-like object.index - 'bar' in the above example, the object that acts as an index.Throwablepublic Object onSetArray(GroovyInterceptor.Invoker invoker, Object receiver, Object index, Object value) throws Throwable
GroovyInterceptoronSetArray in class GroovyInterceptorreceiver - 'foo' in the above example, the array-like object.index - 'bar' in the above example, the object that acts as an index.value - The value to be assigned.value.ThrowableCopyright © 2012. All Rights Reserved.