public final class JndiPermission
extends java.security.Permission
implements java.io.Serializable
Pathname is the pathname of the file or directory granted the specified actions. A pathname that ends in "/*" indicates all the files and directories contained in that directory. A pathname that ends with "/-" indicates (recursively) all files and subdirectories contained in that directory. A pathname consisting of the special token "<<ALL BINDINGS>>" matches any file.
The actions to be granted are passed to the constructor in a string containing a list of one or more comma-separated keywords. The possible keywords are "bind", "rebind", "unbind", "lookup", "list", "listBindings", and "createSubcontext". Their meaning is defined as follows:
The actions string is converted to lowercase before processing.
Be careful when granting JndiPermissions. Think about the implications of granting read and especially write access to various files and directories. The "<<ALL BINDINGS>>" permission with write action is especially dangerous. This grants permission to write to the entire file system. One thing this effectively allows is replacement of the system binary, including the JVM runtime environment.
Please note: Code can always read a file from the same directory it's in (or a subdirectory of that directory); it does not need explicit permission to do so.
Permission,
Permissions,
PermissionCollection| Modifier and Type | Field and Description |
|---|---|
private static int |
ACTION_COUNT |
private static java.util.HashMap<java.lang.String,java.lang.Integer> |
actionMap |
private java.lang.String |
actions
the actions string.
|
static int |
ALL
All actions (bind, rebind, unbind, lookup, list, listBindings, createSubcontext)
|
static java.lang.String |
ALL_ACTION |
private static java.lang.String[] |
ALL_ACTIONS |
static int |
BIND
bind action.
|
static java.lang.String |
BIND_ACTION |
private java.lang.String |
cpath |
static int |
CREATE_SUBCONTEXT |
static java.lang.String |
CREATE_SUBCONTEXT_ACTION |
private boolean |
directory |
static int |
LIST
list action.
|
static java.lang.String |
LIST_ACTION |
static int |
LIST_BINDINGS |
static java.lang.String |
LIST_BINDINGS_ACTION |
static int |
LOOKUP
lookup action.
|
static java.lang.String |
LOOKUP_ACTION |
private int |
mask |
static int |
NONE
No actions.
|
static int |
REBIND
rebind action.
|
static java.lang.String |
REBIND_ACTION |
private boolean |
recursive |
private static char |
RECURSIVE_CHAR |
private static long |
serialVersionUID |
static int |
UNBIND
unbind action.
|
static java.lang.String |
UNBIND_ACTION |
private static char |
WILD_CHAR |
| Constructor and Description |
|---|
JndiPermission(javax.naming.Name path,
int mask) |
JndiPermission(javax.naming.Name path,
java.lang.String actions) |
JndiPermission(java.lang.String path,
int mask)
Creates a new JndiPermission object using an action mask.
|
JndiPermission(java.lang.String path,
java.lang.String actions)
Creates a new JndiPermission object with the specified actions.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object obj)
Checks two JndiPermission objects for equality.
|
java.lang.String |
getActions()
Returns the "canonical string representation" of the actions.
|
private static java.lang.String |
getActions(int mask)
Return the canonical string representation of the actions.
|
(package private) int |
getMask()
Return the current action mask.
|
private static int |
getMask(java.lang.String actions)
Converts an actions String to an actions mask.
|
int |
hashCode()
Returns the hash code value for this object.
|
boolean |
implies(java.security.Permission p)
Checks if this JndiPermission object "implies" the specified permission.
|
(package private) boolean |
impliesIgnoreMask(JndiPermission that)
Checks if the Permission's actions are a proper subset of the this
object's actions.
|
private void |
init(int mask)
initialize a JndiPermission object.
|
java.security.PermissionCollection |
newPermissionCollection()
Returns a new PermissionCollection object for storing JndiPermission
objects.
|
private void |
readObject(java.io.ObjectInputStream s)
readObject is called to restore the state of the JndiPermission from a
stream.
|
private void |
writeObject(java.io.ObjectOutputStream s)
WriteObject is called to save the state of the JndiPermission to a stream.
|
private static final long serialVersionUID
public static final int BIND
public static final int REBIND
public static final int UNBIND
public static final int LOOKUP
public static final int LIST
public static final int LIST_BINDINGS
public static final int CREATE_SUBCONTEXT
private static final int ACTION_COUNT
public static final int ALL
public static final int NONE
public static final java.lang.String BIND_ACTION
public static final java.lang.String REBIND_ACTION
public static final java.lang.String UNBIND_ACTION
public static final java.lang.String LOOKUP_ACTION
public static final java.lang.String LIST_ACTION
public static final java.lang.String LIST_BINDINGS_ACTION
public static final java.lang.String ALL_ACTION
public static final java.lang.String CREATE_SUBCONTEXT_ACTION
private static final java.lang.String[] ALL_ACTIONS
private static final java.util.HashMap<java.lang.String,java.lang.Integer> actionMap
private transient int mask
private transient boolean directory
private transient boolean recursive
private java.lang.String actions
private transient java.lang.String cpath
private static final char RECURSIVE_CHAR
private static final char WILD_CHAR
public JndiPermission(java.lang.String path,
java.lang.String actions)
A pathname that ends in "/*" (where "/" is the file separator character,
'/') indicates all the files and directories contained in
that directory. A pathname that ends with "/-" indicates (recursively) all
files and subdirectories contained in that directory. The special pathname
"<<ALL BINDINGS>>" matches any file.
A pathname consisting of a single "*" indicates all the files in the current directory, while a pathname consisting of a single "-" indicates all the files in the current directory and (recursively) all files and subdirectories contained in the current directory.
A pathname containing an empty string represents an empty path.
path - the pathname of the file/directory.actions - the action string.java.lang.IllegalArgumentException - If actions is null, empty or contains an action
other than the specified possible actions.public JndiPermission(javax.naming.Name path,
java.lang.String actions)
JndiPermission(java.lang.String path,
int mask)
implies method.path - the pathname of the file/directory.mask - the action mask to use.public JndiPermission(javax.naming.Name path,
int mask)
private void init(int mask)
mask - the actions mask to use.public boolean implies(java.security.Permission p)
More specifically, this method returns true if:
implies in class java.security.Permissionp - the permission to check against.true if the specified permission is not
null and is implied by this object,
false otherwise.boolean impliesIgnoreMask(JndiPermission that)
that - the JndiPermission to check against.exact - return immediately if the masks are not equalpublic boolean equals(java.lang.Object obj)
equals in class java.security.Permissionobj - the object we are testing for equality with this object.true if obj is a JndiPermission, and has the same
pathname and actions as this JndiPermission object,
false otherwise.public int hashCode()
hashCode in class java.security.Permissionprivate static int getMask(java.lang.String actions)
action - - the comma separated list of actions.int getMask()
private static java.lang.String getActions(int mask)
public java.lang.String getActions()
getActions will
return the string "bind,unbind".getActions in class java.security.Permissionpublic java.security.PermissionCollection newPermissionCollection()
JndiPermission objects must be stored in a manner that allows them to be
inserted into the collection in any order, but that also enables the
PermissionCollection implies method to be implemented in an
efficient (and consistent) manner.
For example, if you have two JndiPermissions:
"/tmp/-", "bind"
"/tmp/scratch/foo", "unbind"
and you are calling the implies method with the
JndiPermission:
"/tmp/scratch/foo", "bind,unbind",then the
implies function must take into account both the
"/tmp/-" and "/tmp/scratch/foo" permissions, so the effective permission
is "bind,unbind", and implies returns true. The "implies"
semantics for JndiPermissions are handled properly by the
PermissionCollection object returned by this
newPermissionCollection method.newPermissionCollection in class java.security.Permissionprivate void writeObject(java.io.ObjectOutputStream s)
throws java.io.IOException
java.io.IOExceptionprivate void readObject(java.io.ObjectInputStream s)
throws java.io.IOException,
java.lang.ClassNotFoundException
java.io.IOExceptionjava.lang.ClassNotFoundException