Class SandboxClosure<V>
- All Implemented Interfaces:
SandboxCode,groovy.lang.GroovyCallable<V>,groovy.lang.GroovyObject,Serializable,Cloneable,Runnable,Callable<V>
- Direct Known Subclasses:
SandboxClosureWrapper,SandboxMethodPointer
GroovyScriptSupport.
Inside a closure, a call or property access without an explicit receiver is resolved on the
closure's owner and delegate, which the receiver checks never see. A closure whose delegate (or
owner) is a class the policy denies would therefore give access to it, for example its static
methods and properties (c.delegate = System then getenv()).
This class ensures that a sandboxed closure never holds such a delegate or owner: they can
only be changed through setDelegate(Object) (used by with, c.delegate =
..., c['delegate'] = ..., etc.) and rehydrate(Object, Object, Object), which
validate them against the policy. A collection or an array is validated with its elements, also
when a property is resolved on it, as its elements can be changed later.
The closures Groovy builds from a sandboxed closure (curry, >>,
memoize, trampoline...) are sandboxed too, see SandboxClosureWrapper.
The compiled closures are made to extend this class by SandboxClosureProcessor, as the
Groovy compiler always generates closures extending Closure.
- See Also:
-
Field Summary
Fields inherited from class groovy.lang.Closure
DELEGATE_FIRST, DELEGATE_ONLY, DONE, IDENTITY, maximumNumberOfParameters, OWNER_FIRST, OWNER_ONLY, parameterTypes, SKIP, TO_SELF -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSandboxClosure(Object owner) protectedSandboxClosure(Object owner, Object thisObject) -
Method Summary
Modifier and TypeMethodDescription<W> groovy.lang.Closure<W> andThen(groovy.lang.Closure<W> other) groovy.lang.Closure<V> groovy.lang.Closure<V> andThenSelf(int times) groovy.lang.Closure<V> compose(groovy.lang.Closure other) groovy.lang.Closure<V> groovy.lang.Closure<V> composeSelf(int times) groovy.lang.Closure<V> groovy.lang.Closure<V> getProperty(String property) groovy.lang.Closure<V> leftShift(groovy.lang.Closure other) groovy.lang.Closure<V> memoize()groovy.lang.Closure<V> memoizeAtLeast(int protectedCacheSize) groovy.lang.Closure<V> memoizeAtMost(int maxCacheSize) groovy.lang.Closure<V> memoizeBetween(int protectedCacheSize, int maxCacheSize) groovy.lang.Closure<V> groovy.lang.Closure<V> groovy.lang.Closure<V> groovy.lang.Closure<V> groovy.lang.Closure<V> <W> groovy.lang.Closure<W> rightShift(groovy.lang.Closure<W> other) voidsetDelegate(Object delegate) groovy.lang.Closure<V> groovy.lang.Closure<V> trampoline(Object... arguments) Methods inherited from class groovy.lang.Closure
asWritable, call, call, call, clone, dehydrate, getDelegate, getDirective, getMaximumNumberOfParameters, getOwner, getParameterTypes, getResolveStrategy, getThisObject, isCase, leftShift, run, setDirective, setProperty, setResolveStrategy, throwRuntimeExceptionMethods inherited from class groovy.lang.GroovyObjectSupport
getMetaClass, setMetaClassMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface groovy.lang.GroovyObject
invokeMethod
-
Constructor Details
-
SandboxClosure
-
SandboxClosure
-
-
Method Details
-
setDelegate
- Overrides:
setDelegatein classgroovy.lang.Closure<V>
-
rehydrate
- Overrides:
rehydratein classgroovy.lang.Closure<V>
-
curry
- Overrides:
curryin classgroovy.lang.Closure<V>
-
curry
- Overrides:
curryin classgroovy.lang.Closure<V>
-
rcurry
- Overrides:
rcurryin classgroovy.lang.Closure<V>
-
rcurry
- Overrides:
rcurryin classgroovy.lang.Closure<V>
-
ncurry
- Overrides:
ncurryin classgroovy.lang.Closure<V>
-
ncurry
- Overrides:
ncurryin classgroovy.lang.Closure<V>
-
rightShift
public <W> groovy.lang.Closure<W> rightShift(groovy.lang.Closure<W> other) - Overrides:
rightShiftin classgroovy.lang.Closure<V>
-
leftShift
- Overrides:
leftShiftin classgroovy.lang.Closure<V>
-
andThen
public <W> groovy.lang.Closure<W> andThen(groovy.lang.Closure<W> other) - Overrides:
andThenin classgroovy.lang.Closure<V>
-
andThenSelf
- Overrides:
andThenSelfin classgroovy.lang.Closure<V>
-
andThenSelf
- Overrides:
andThenSelfin classgroovy.lang.Closure<V>
-
compose
- Overrides:
composein classgroovy.lang.Closure<V>
-
composeSelf
- Overrides:
composeSelfin classgroovy.lang.Closure<V>
-
composeSelf
- Overrides:
composeSelfin classgroovy.lang.Closure<V>
-
memoize
- Overrides:
memoizein classgroovy.lang.Closure<V>
-
memoizeAtMost
- Overrides:
memoizeAtMostin classgroovy.lang.Closure<V>
-
memoizeAtLeast
- Overrides:
memoizeAtLeastin classgroovy.lang.Closure<V>
-
memoizeBetween
- Overrides:
memoizeBetweenin classgroovy.lang.Closure<V>
-
trampoline
- Overrides:
trampolinein classgroovy.lang.Closure<V>
-
trampoline
- Overrides:
trampolinein classgroovy.lang.Closure<V>
-
getProperty
- Specified by:
getPropertyin interfacegroovy.lang.GroovyObject- Overrides:
getPropertyin classgroovy.lang.Closure<V>
-