Top Description Inners Fields Constructors Methods
org.apache.commons.jexl2.introspection

public final Class Sandbox

extends Object
Class Inheritance
Imports
java.util.HashMap, .HashSet, .Map, .Set

A sandbox describes permissions on a class by explicitly allowing or forbidding access to methods and properties through "whitelists" and "blacklists".

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":

Since
2.1

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
Sandbox.BlackSet

A black set of names.

public abstract static class
Sandbox.Names

A base set of names.

public static class
Sandbox.Permissions

Contains the white or black lists for properties and methods for a given class.

public static class
Sandbox.WhiteSet

A white set of names.

Field Summary

Modifier and TypeField and Description
private static final Sandbox.Permissions
ALL_WHITE

The pass-thru permissions.

private final Map<String, Sandbox.Permissions>
sandbox

The map from class names to permissions.

private static final Sandbox.Names
WHITE_NAMES

The pass-thru name set.

Constructor Summary

AccessConstructor and Description
public
Sandbox()

Creates a new default sandbox.

protected
Sandbox(Map<String, Sandbox.Permissions>
the permissions map
map
)

Creates a sandbox based on an existing permissions map.

Method Summary

Modifier and TypeMethod and Description
public Sandbox.Permissions

Returns:

the permissions instance
black
(String
the blackened class name
clazz
)

Creates a new set of permissions based on black lists for methods and properties for a given class.

public String

Returns:

null if not allowed, the name of the method to use otherwise
execute
(Class<?>
the class
clazz
,
String
the method name
name
)

Gets the execute permission value for a given method of a class.

public String

Returns:

null if not allowed, the name of the method to use otherwise
execute
(String
the class name
clazz
,
String
the method name
name
)

Gets the execute permission value for a given method of a class.

public Sandbox.Permissions

Returns:

the defined permissions or an all-white permission instance if none were defined
get
(String
the class name
clazz
)

Gets the set of permissions associated to a class.

public Sandbox.Permissions

Returns:

the set of permissions
permissions
(String
the class for which these permissions apply
clazz
,
boolean
whether the readable property list is white - true - or black - false -
readFlag
,
boolean
whether the writeable property list is white - true - or black - false -
writeFlag
,
boolean
whether the executable method list is white white - true - or black - false -
executeFlag
)

Creates the set of permissions for a given class.

public String

Returns:

null if not allowed, the name of the property to use otherwise
read
(Class<?>
the class
clazz
,
String
the property name
name
)

Gets the read permission value for a given property of a class.

public String

Returns:

null if not allowed, the name of the property to use otherwise
read
(String
the class name
clazz
,
String
the property name
name
)

Gets the read permission value for a given property of a class.

public Sandbox.Permissions

Returns:

the permissions instance
white
(String
the whitened class name
clazz
)

Creates a new set of permissions based on white lists for methods and properties for a given class.

public String

Returns:

null if not allowed, the name of the property to use otherwise
write
(Class<?>
the class
clazz
,
String
the property name
name
)

Gets the write permission value for a given property of a class.

public String

Returns:

null if not allowed, the name of the property to use otherwise
write
(String
the class name
clazz
,
String
the property name
name
)

Gets the write permission value for a given property of a class.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ALL_WHITEback to summary
private static final Sandbox.Permissions ALL_WHITE

The pass-thru permissions.

sandboxback to summary
private final Map<String, Sandbox.Permissions> sandbox

The map from class names to permissions.

WHITE_NAMESback to summary
private static final Sandbox.Names WHITE_NAMES

The pass-thru name set.

Constructor Detail

Sandboxback to summary
public Sandbox()

Creates a new default sandbox.

Sandboxback to summary
protected Sandbox(Map<String, Sandbox.Permissions> map)

Creates a sandbox based on an existing permissions map.

Parameters
map:Map<String, Sandbox.Permissions>

the permissions map

Method Detail

blackback to summary
public Sandbox.Permissions black(String clazz)

Creates a new set of permissions based on black lists for methods and properties for a given class.

Parameters
clazz:String

the blackened class name

Returns:Sandbox.Permissions

the permissions instance

executeback to summary
public String execute(Class<?> clazz, String name)

Gets the execute permission value for a given method of a class.

Parameters
clazz:Class<?>

the class

name:String

the method name

Returns:String

null if not allowed, the name of the method to use otherwise

executeback to summary
public String execute(String clazz, String name)

Gets the execute permission value for a given method of a class.

Parameters
clazz:String

the class name

name:String

the method name

Returns:String

null if not allowed, the name of the method to use otherwise

getback to summary
public Sandbox.Permissions get(String clazz)

Gets the set of permissions associated to a class.

Parameters
clazz:String

the class name

Returns:Sandbox.Permissions

the defined permissions or an all-white permission instance if none were defined

permissionsback to summary
public Sandbox.Permissions permissions(String clazz, boolean readFlag, boolean writeFlag, boolean executeFlag)

Creates the set of permissions for a given class.

Parameters
clazz:String

the class for which these permissions apply

readFlag:boolean

whether the readable property list is white - true - or black - false -

writeFlag:boolean

whether the writeable property list is white - true - or black - false -

executeFlag:boolean

whether the executable method list is white white - true - or black - false -

Returns:Sandbox.Permissions

the set of permissions

readback to summary
public String read(Class<?> clazz, String name)

Gets the read permission value for a given property of a class.

Parameters
clazz:Class<?>

the class

name:String

the property name

Returns:String

null if not allowed, the name of the property to use otherwise

readback to summary
public String read(String clazz, String name)

Gets the read permission value for a given property of a class.

Parameters
clazz:String

the class name

name:String

the property name

Returns:String

null if not allowed, the name of the property to use otherwise

whiteback to summary
public Sandbox.Permissions white(String clazz)

Creates a new set of permissions based on white lists for methods and properties for a given class.

Parameters
clazz:String

the whitened class name

Returns:Sandbox.Permissions

the permissions instance

writeback to summary
public String write(Class<?> clazz, String name)

Gets the write permission value for a given property of a class.

Parameters
clazz:Class<?>

the class

name:String

the property name

Returns:String

null if not allowed, the name of the property to use otherwise

writeback to summary
public String write(String clazz, String name)

Gets the write permission value for a given property of a class.

Parameters
clazz:String

the class name

name:String

the property name

Returns:String

null if not allowed, the name of the property to use otherwise

org.apache.commons.jexl2.introspection back to summary

public final Class Sandbox.BlackSet

extends Names
Class Inheritance

A black set of names.

Field Summary

Modifier and TypeField and Description
private Set<String>
names

The set of controlled names.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
add(String
the name to add
name
)

Implements abstract org.apache.commons.jexl2.introspection.Sandbox.Names.add.

Adds a name to this set.
public String
get(String
the method/property name to check
name
)

Overrides org.apache.commons.jexl2.introspection.Sandbox.Names.get.

Whether a given name is allowed or not.
Inherited from org.apache.commons.jexl2.introspection.Sandbox.Names:
alias

Field Detail

namesback to summary
private Set<String> names

The set of controlled names.

Constructor Detail

BlackSetback to summary
public BlackSet()

Method Detail

addback to summary
public boolean add(String name)

Implements abstract org.apache.commons.jexl2.introspection.Sandbox.Names.add.

Doc from org.apache.commons.jexl2.introspection.Sandbox.Names.add.

Adds a name to this set.

Parameters
name:String

the name to add

Returns:boolean

true if the name was really added, false if not

Annotations
@Override
getback to summary
public String get(String name)

Overrides org.apache.commons.jexl2.introspection.Sandbox.Names.get.

Doc from org.apache.commons.jexl2.introspection.Sandbox.Names.get.

Whether a given name is allowed or not.

Parameters
name:String

the method/property name to check

Returns:String

null if not allowed, the actual name to use otherwise

Annotations
@Override
org.apache.commons.jexl2.introspection back to summary

public abstract Class Sandbox.Names

extends Object
Class Inheritance
Known Direct Subclasses
org.apache.commons.jexl2.introspection.Sandbox.WhiteSet, org.apache.commons.jexl2.introspection.Sandbox.BlackSet

A base set of names.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract boolean

Returns:

true if the name was really added, false if not
add
(String
the name to add
name
)

Adds a name to this set.

public boolean

Returns:

true if the alias was added, false if it was already present
alias
(String
the name to alias
name
,
String
the alias
alias
)

Adds an alias to a name to this set.

public String

Returns:

null if not allowed, the actual name to use otherwise
get
(String
the method/property name to check
name
)

Whether a given name is allowed or not.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Namesback to summary
public Names()

Method Detail

addback to summary
public abstract boolean add(String name)

Adds a name to this set.

Parameters
name:String

the name to add

Returns:boolean

true if the name was really added, false if not

aliasback to summary
public boolean alias(String name, String alias)

Adds an alias to a name to this set.

This only has an effect on white lists.

Parameters
name:String

the name to alias

alias:String

the alias

Returns:boolean

true if the alias was added, false if it was already present

getback to summary
public String get(String name)

Whether a given name is allowed or not.

Parameters
name:String

the method/property name to check

Returns:String

null if not allowed, the actual name to use otherwise

org.apache.commons.jexl2.introspection back to summary

public final Class Sandbox.Permissions

extends Object
Class Inheritance

Contains the white or black lists for properties and methods for a given class.

Field Summary

Modifier and TypeField and Description
private final Sandbox.Names
execute

The controlled methods.

private final Sandbox.Names
read

The controlled readable properties.

private final Sandbox.Names
write

The controlled writeable properties.

Constructor Summary

AccessConstructor and Description
pack-priv
Permissions(boolean
whether the read property list is white or black
readFlag
,
boolean
whether the write property list is white or black
writeFlag
,
boolean
whether the method list is white of black
executeFlag
)

Creates a new permissions instance.

pack-priv
Permissions(Sandbox.Names
the read set
nread
,
Sandbox.Names
the write set
nwrite
,
Sandbox.Names
the method set
nexecute
)

Creates a new permissions instance.

Method Summary

Modifier and TypeMethod and Description
public Sandbox.Permissions

Returns:

this instance of permissions
execute
(String...
the method names
mnames
)

Adds a list of executable methods names to these permissions.

public Sandbox.Names

Returns:

the set of method names
execute
()

Gets the set of method names in these permissions.

public Sandbox.Permissions

Returns:

this instance of permissions
read
(String...
the property names
pnames
)

Adds a list of readable property names to these permissions.

public Sandbox.Names

Returns:

the set of property names
read
()

Gets the set of readable property names in these permissions.

public Sandbox.Permissions

Returns:

this instance of permissions
write
(String...
the property names
pnames
)

Adds a list of writeable property names to these permissions.

public Sandbox.Names

Returns:

the set of property names
write
()

Gets the set of writeable property names in these permissions.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

executeback to summary
private final Sandbox.Names execute

The controlled methods.

readback to summary
private final Sandbox.Names read

The controlled readable properties.

writeback to summary
private final Sandbox.Names write

The controlled writeable properties.

Constructor Detail

Permissionsback to summary
pack-priv Permissions(boolean readFlag, boolean writeFlag, boolean executeFlag)

Creates a new permissions instance.

Parameters
readFlag:boolean

whether the read property list is white or black

writeFlag:boolean

whether the write property list is white or black

executeFlag:boolean

whether the method list is white of black

Permissionsback to summary
pack-priv Permissions(Sandbox.Names nread, Sandbox.Names nwrite, Sandbox.Names nexecute)

Creates a new permissions instance.

Parameters
nread:Sandbox.Names

the read set

nwrite:Sandbox.Names

the write set

nexecute:Sandbox.Names

the method set

Method Detail

executeback to summary
public Sandbox.Permissions execute(String... mnames)

Adds a list of executable methods names to these permissions.

The constructor is denoted as the empty-string, all other methods by their names.

Parameters
mnames:String[]

the method names

Returns:Sandbox.Permissions

this instance of permissions

executeback to summary
public Sandbox.Names execute()

Gets the set of method names in these permissions.

Returns:Sandbox.Names

the set of method names

readback to summary
public Sandbox.Permissions read(String... pnames)

Adds a list of readable property names to these permissions.

Parameters
pnames:String[]

the property names

Returns:Sandbox.Permissions

this instance of permissions

readback to summary
public Sandbox.Names read()

Gets the set of readable property names in these permissions.

Returns:Sandbox.Names

the set of property names

writeback to summary
public Sandbox.Permissions write(String... pnames)

Adds a list of writeable property names to these permissions.

Parameters
pnames:String[]

the property names

Returns:Sandbox.Permissions

this instance of permissions

writeback to summary
public Sandbox.Names write()

Gets the set of writeable property names in these permissions.

Returns:Sandbox.Names

the set of property names

org.apache.commons.jexl2.introspection back to summary

public final Class Sandbox.WhiteSet

extends Names
Class Inheritance

A white set of names.

Field Summary

Modifier and TypeField and Description
private Map<String, String>
names

The map of controlled names and aliases.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
add(String
the name to add
name
)

Implements abstract org.apache.commons.jexl2.introspection.Sandbox.Names.add.

Adds a name to this set.
public boolean
alias(String
the name to alias
name
,
String
the alias
alias
)

Overrides org.apache.commons.jexl2.introspection.Sandbox.Names.alias.

Adds an alias to a name to this set.
public String
get(String
the method/property name to check
name
)

Overrides org.apache.commons.jexl2.introspection.Sandbox.Names.get.

Whether a given name is allowed or not.

Field Detail

namesback to summary
private Map<String, String> names

The map of controlled names and aliases.

Constructor Detail

WhiteSetback to summary
public WhiteSet()

Method Detail

addback to summary
public boolean add(String name)

Implements abstract org.apache.commons.jexl2.introspection.Sandbox.Names.add.

Doc from org.apache.commons.jexl2.introspection.Sandbox.Names.add.

Adds a name to this set.

Parameters
name:String

the name to add

Returns:boolean

true if the name was really added, false if not

Annotations
@Override
aliasback to summary
public boolean alias(String name, String alias)

Overrides org.apache.commons.jexl2.introspection.Sandbox.Names.alias.

Doc from org.apache.commons.jexl2.introspection.Sandbox.Names.alias.

Adds an alias to a name to this set.

This only has an effect on white lists.

Parameters
name:String

the name to alias

alias:String

the alias

Returns:boolean

true if the alias was added, false if it was already present

Annotations
@Override
getback to summary
public String get(String name)

Overrides org.apache.commons.jexl2.introspection.Sandbox.Names.get.

Doc from org.apache.commons.jexl2.introspection.Sandbox.Names.get.

Whether a given name is allowed or not.

Parameters
name:String

the method/property name to check

Returns:String

null if not allowed, the actual name to use otherwise

Annotations
@Override