Additional top-level class in compilation unit: FilePermissionCollection.
Pathname is the pathname of the file or directory granted the specified
actions. A pathname that ends in "/*" (where "/" is
the file separator character, File.separatorChar
) 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. Such a pathname is called
a wildcard pathname. Otherwise, it's a simple pathname.
A pathname consisting of the special token "<<ALL FILES>>" matches any file.
Note
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.
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 "read", "write", "execute", "delete", and "readlink". Their meaning is defined as follows:
Runtime.exec
to
be called. Corresponds to SecurityManager.checkExec
.
File.delete
to
be called. Corresponds to SecurityManager.checkDelete
.
readSymbolicLink
method.
The actions string is converted to lowercase before processing.
Be careful when granting FilePermissions. Think about the implications of granting read and especially write access to various files and directories. The "<<ALL FILES>>" 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.
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.
java.security.Permission
, java.security.Permissions
, java.security.PermissionCollection
Modifier and Type | Field and Description |
---|---|
private String | actions
the actions string. |
private static final int | ALL
All actions (read,write,execute,delete,readlink) |
private transient boolean | |
private static final FileSystem | builtInFS
Use the platform's default file system to avoid recursive initialization issues when the VM is configured to use a custom file system provider. |
private transient String | |
private static final Path | |
private static final int | DELETE
Delete action. |
private transient boolean | |
private static final Path | |
private static final Path | |
private static final int | EXECUTE
Execute action. |
private static final Path | |
private transient boolean | |
private transient int | |
private static final int | NONE
No actions. |
private transient Path | |
private transient Path | |
private static final int | READ
Read action. |
private static final int | READLINK
Read link action. |
private transient boolean | |
private static final char | |
private static final long | |
private static final char | |
private static final int | WRITE
Write action. |
Access | Constructor and Description |
---|---|
private | FilePermission(String name, FilePermission input, Path npath, Path npath2, int mask, String actions)
A private constructor that clones some and updates some, always with a different name. |
public | FilePermission(String
the pathname of the file/directory. path, String the action string. actions)Creates a new FilePermission object with the specified actions. |
pack-priv | FilePermission(String
the pathname of the file/directory. path, int the action mask to use. mask)Creates a new FilePermission object using an action mask. |
Modifier and Type | Method and Description |
---|---|
private static Path | |
private static int | Returns: the depth in betweenthe expected outer path, normalized p1, Path the expected inner path, normalized p2)Returns the depth between an outer path p1 and an inner path p2. |
public boolean | Returns: true if obj is a FilePermission, and has the same
pathname and actions as this FilePermission object,
false otherwise.the object we are testing for equality with this object. obj)Implements abstract java. Checks two FilePermission objects for equality. |
private static String | Returns: the canonical string representation of the actions.Return the canonical string representation of the actions. |
public String | Returns: the canonical string representation of the actions.Implements abstract java. Returns the "canonical string representation" of the actions. |
private static int | |
pack-priv int | |
public int | Returns: a hash code value for this object.Implements abstract java. Returns the hash code value for this object. |
public boolean | Returns: true if the specified permission is not
null and is implied by this object,
false otherwise.the permission to check against. p)Implements abstract java. Checks if this FilePermission object "implies" the specified permission. |
pack-priv boolean | Returns: the effective maskthe FilePermission to check against. that)Checks if the Permission's actions are a proper subset of the this object's actions. |
private void | |
public PermissionCollection | Returns: a new PermissionCollection object suitable for storing FilePermissions.Overrides java. Returns a new PermissionCollection object for storing FilePermission objects. |
private void | readObject(ObjectInputStream s)
readObject is called to restore the state of the FilePermission from a stream. |
pack-priv FilePermission | Returns: a new objectthe new actions effective)Create a cloned FilePermission with a different actions. |
private void | writeObject(ObjectOutputStream s)
WriteObject is called to save the state of the FilePermission to a stream. |
actions | back to summary |
---|---|
private String actions the actions string. |
ALL | back to summary |
---|---|
private static final int ALL All actions (read,write,execute,delete,readlink) |
allFiles | back to summary |
---|---|
private transient boolean allFiles |
builtInFS | back to summary |
---|---|
private static final FileSystem builtInFS Use the platform's default file system to avoid recursive initialization issues when the VM is configured to use a custom file system provider. |
cpath | back to summary |
---|---|
private transient String cpath |
DASH_PATH | back to summary |
---|---|
private static final Path DASH_PATH |
DELETE | back to summary |
---|---|
private static final int DELETE Delete action. |
directory | back to summary |
---|---|
private transient boolean directory |
DOTDOT_PATH | back to summary |
---|---|
private static final Path DOTDOT_PATH |
EMPTY_PATH | back to summary |
---|---|
private static final Path EMPTY_PATH |
EXECUTE | back to summary |
---|---|
private static final int EXECUTE Execute action. |
here | back to summary |
---|---|
private static final Path here |
invalid | back to summary |
---|---|
private transient boolean invalid |
mask | back to summary |
---|---|
private transient int mask |
NONE | back to summary |
---|---|
private static final int NONE No actions. |
npath | back to summary |
---|---|
private transient Path npath |
npath2 | back to summary |
---|---|
private transient Path npath2 |
READ | back to summary |
---|---|
private static final int READ Read action. |
READLINK | back to summary |
---|---|
private static final int READLINK Read link action. |
recursive | back to summary |
---|---|
private transient boolean recursive |
RECURSIVE_CHAR | back to summary |
---|---|
private static final char RECURSIVE_CHAR |
serialVersionUID | back to summary |
---|---|
private static final long serialVersionUID Hides java. |
WILD_CHAR | back to summary |
---|---|
private static final char WILD_CHAR |
WRITE | back to summary |
---|---|
private static final int WRITE Write action. |
FilePermission | back to summary |
---|---|
private FilePermission(String name, FilePermission input, Path npath, Path npath2, int mask, String actions) A private constructor that clones some and updates some, always with a different name. |
FilePermission | back to summary |
---|---|
public FilePermission(String path, String actions) Creates a new FilePermission object with the specified actions. path is the pathname of a file or directory, and actions contains a comma-separated list of the desired actions granted on the file or directory. Possible actions are "read", "write", "execute", "delete", and "readlink". A pathname that ends in "/*" (where "/" is
the file separator character, 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. Implementation Note In this implementation, the
If the value of the system property is set to
If the value of the system property is set to
In either case, the "*" or "-" character at the end of a wildcard
The default value of the The value can also be set with a security property using the same name, but setting a system property will override the security property value.
|
FilePermission | back to summary |
---|---|
pack-priv FilePermission(String path, int mask) Creates a new FilePermission object using an action mask.
More efficient than the FilePermission(String, String) constructor.
Can be used from within
code that needs to create a FilePermission object to pass into the
|
altPath | back to summary |
---|---|
private static Path altPath(Path in) Returns the alternative path as a Path object, i.e. absolute path for a relative one, or vice versa. |
containsPath | back to summary |
---|---|
private static int containsPath(Path p1, Path p2) Returns the depth between an outer path p1 and an inner path p2. -1 is returned if - p1 does not contains p2. - this is not decidable. For example, p1="../x", p2="y". - the depth is not decidable. For example, p1="/", p2="x". This method can return 2 if the depth is greater than 2. |
equals | back to summary |
---|---|
public boolean equals(Object obj) Implements abstract java. Checks two FilePermission objects for equality. Checks that obj is a FilePermission, and has the same pathname and actions as this object. Implementation Note More specifically, two pathnames are the same if and only if
they have the same wildcard flag and their
When |
getActions | back to summary |
---|---|
private static String getActions(int mask) Return the canonical string representation of the actions. Always returns present actions in the following order: read, write, execute, delete, readlink.
|
getActions | back to summary |
---|---|
public String getActions() Implements abstract java. Returns the "canonical string representation" of the actions.
That is, this method always returns present actions in the following order:
read, write, execute, delete, readlink. For example, if this FilePermission
object allows both write and read actions, a call to |
getMask | back to summary |
---|---|
private static int getMask(String actions) Converts an actions String to an actions mask.
|
getMask | back to summary |
---|---|
pack-priv int getMask() Return the current action mask. Used by the FilePermissionCollection.
|
hashCode | back to summary |
---|---|
public int hashCode() Implements abstract java. Returns the hash code value for this object.
|
implies | back to summary |
---|---|
public boolean implies(Permission p) Implements abstract java. Checks if this FilePermission object "implies" the specified permission. More specifically, this method returns true if:
Precisely, a simple pathname implies another simple pathname if and only if they are equal. A simple pathname never implies a wildcard pathname. A wildcard pathname implies another wildcard pathname if and only if all simple pathnames implied by the latter are implied by the former. A wildcard pathname implies a simple pathname if and only if
"<<ALL FILES>>" implies every other pathname. No pathname, except for "<<ALL FILES>>" itself, implies "<<ALL FILES>>". Implementation Note If
If
An invalid
|
impliesIgnoreMask | back to summary |
---|---|
pack-priv boolean impliesIgnoreMask(FilePermission that) Checks if the Permission's actions are a proper subset of the this object's actions. Returns the effective mask iff the this FilePermission's path also implies that FilePermission's path.
|
init | back to summary |
---|---|
private void init(int mask) initialize a FilePermission object. Common to all constructors. Also called during de-serialization.
|
newPermissionCollection | back to summary |
---|---|
public PermissionCollection newPermissionCollection() Overrides java. Returns a new PermissionCollection object for storing FilePermission objects.
FilePermission 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 For example, if you have two FilePermissions:
and you are calling the "/tmp/scratch/foo", "read,write",then the implies function must
take into account both the "/tmp/-" and "/tmp/scratch/foo"
permissions, so the effective permission is "read,write",
and implies returns true. The "implies" semantics for
FilePermissions are handled properly by the PermissionCollection object
returned by this newPermissionCollection method.
|
readObject | back to summary |
---|---|
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException readObject is called to restore the state of the FilePermission from a stream.
|
withNewActions | back to summary |
---|---|
pack-priv FilePermission withNewActions(int effective) Create a cloned FilePermission with a different actions.
|
writeObject | back to summary |
---|---|
private void writeObject(ObjectOutputStream s) throws IOException WriteObject is called to save the state of the FilePermission to a stream. The actions are serialized, and the superclass takes care of the name.
|