public final class Sandbox
extends java.lang.Object
A whitelist explicitly allows methods/properties for a class;
A blacklist explicitly forbids methods/properties for a class;
Permissions are composed of three lists, read, write, execute, each being "white" or "black":
Modifier and Type | Class and Description |
---|---|
static class |
Sandbox.BlackSet
A black set of names.
|
static class |
Sandbox.Names
A base set of names.
|
static class |
Sandbox.Permissions
Contains the white or black lists for properties and methods for a given class.
|
static class |
Sandbox.WhiteSet
A white set of names.
|
Modifier and Type | Field and Description |
---|---|
private static Sandbox.Permissions |
ALL_WHITE
The pass-thru permissions.
|
private java.util.Map<java.lang.String,Sandbox.Permissions> |
sandbox
The map from class names to permissions.
|
private static Sandbox.Names |
WHITE_NAMES
The pass-thru name set.
|
Modifier | Constructor and Description |
---|---|
|
Sandbox()
Creates a new default sandbox.
|
protected |
Sandbox(java.util.Map<java.lang.String,Sandbox.Permissions> map)
Creates a sandbox based on an existing permissions map.
|
Modifier and Type | Method and Description |
---|---|
Sandbox.Permissions |
black(java.lang.String clazz)
Creates a new set of permissions based on black lists for methods and properties for a given class.
|
java.lang.String |
execute(java.lang.Class<?> clazz,
java.lang.String name)
Gets the execute permission value for a given method of a class.
|
java.lang.String |
execute(java.lang.String clazz,
java.lang.String name)
Gets the execute permission value for a given method of a class.
|
Sandbox.Permissions |
get(java.lang.String clazz)
Gets the set of permissions associated to a class.
|
Sandbox.Permissions |
permissions(java.lang.String clazz,
boolean readFlag,
boolean writeFlag,
boolean executeFlag)
Creates the set of permissions for a given class.
|
java.lang.String |
read(java.lang.Class<?> clazz,
java.lang.String name)
Gets the read permission value for a given property of a class.
|
java.lang.String |
read(java.lang.String clazz,
java.lang.String name)
Gets the read permission value for a given property of a class.
|
Sandbox.Permissions |
white(java.lang.String clazz)
Creates a new set of permissions based on white lists for methods and properties for a given class.
|
java.lang.String |
write(java.lang.Class<?> clazz,
java.lang.String name)
Gets the write permission value for a given property of a class.
|
java.lang.String |
write(java.lang.String clazz,
java.lang.String name)
Gets the write permission value for a given property of a class.
|
private final java.util.Map<java.lang.String,Sandbox.Permissions> sandbox
private static final Sandbox.Names WHITE_NAMES
private static final Sandbox.Permissions ALL_WHITE
public Sandbox()
protected Sandbox(java.util.Map<java.lang.String,Sandbox.Permissions> map)
map
- the permissions mappublic java.lang.String read(java.lang.Class<?> clazz, java.lang.String name)
clazz
- the classname
- the property namepublic java.lang.String read(java.lang.String clazz, java.lang.String name)
clazz
- the class namename
- the property namepublic java.lang.String write(java.lang.Class<?> clazz, java.lang.String name)
clazz
- the classname
- the property namepublic java.lang.String write(java.lang.String clazz, java.lang.String name)
clazz
- the class namename
- the property namepublic java.lang.String execute(java.lang.Class<?> clazz, java.lang.String name)
clazz
- the classname
- the method namepublic java.lang.String execute(java.lang.String clazz, java.lang.String name)
clazz
- the class namename
- the method namepublic Sandbox.Permissions permissions(java.lang.String clazz, boolean readFlag, boolean writeFlag, boolean executeFlag)
clazz
- the class for which these permissions applyreadFlag
- whether the readable property list is white - true - or black - false -writeFlag
- whether the writeable property list is white - true - or black - false -executeFlag
- whether the executable method list is white white - true - or black - false -public Sandbox.Permissions white(java.lang.String clazz)
clazz
- the whitened class namepublic Sandbox.Permissions black(java.lang.String clazz)
clazz
- the blackened class namepublic Sandbox.Permissions get(java.lang.String clazz)
clazz
- the class name