@PublicAPI(stability=VOLATILE, mayInstantiate=true, mayExtend=false, mayInvoke=true) public class FilePermission extends Object
Modifier and Type | Field and Description |
---|---|
static int |
GROUP_EXECUTABLE
The bitmask that should be used for indicating whether a file is
executable by members of its group.
|
static int |
GROUP_READABLE
The bitmask that should be used for indicating whether a file is
readable by members of its group.
|
static int |
GROUP_WRITABLE
The bitmask that should be used for indicating whether a file is
writable by members of its group.
|
static int |
OTHER_EXECUTABLE
The bitmask that should be used for indicating whether a file is
executable by users other than the owner or group members.
|
static int |
OTHER_READABLE
The bitmask that should be used for indicating whether a file is
readable by users other than the owner or group members.
|
static int |
OTHER_WRITABLE
The bitmask that should be used for indicating whether a file is
writable by users other than the owner or group members.
|
static int |
OWNER_EXECUTABLE
The bitmask that should be used for indicating whether a file is
executable by its owner.
|
static int |
OWNER_READABLE
The bitmask that should be used for indicating whether a file is
readable by its owner.
|
static int |
OWNER_WRITABLE
The bitmask that should be used for indicating whether a file is
writable by its owner.
|
Constructor and Description |
---|
FilePermission(boolean ownerReadable,
boolean ownerWritable,
boolean ownerExecutable)
Creates a new file permission with the specified rights for the
file owner.
|
FilePermission(boolean ownerReadable,
boolean ownerWritable,
boolean ownerExecutable,
boolean groupReadable,
boolean groupWritable,
boolean groupExecutable,
boolean otherReadable,
boolean otherWritable,
boolean otherExecutable)
Creates a new file permission with the specified rights for the
file owner, group members, and other users.
|
FilePermission(int encodedPermission)
Creates a new file permission object with the provided encoded
representation.
|
Modifier and Type | Method and Description |
---|---|
static FilePermission |
decodeUNIXMode(String modeString)
Decodes the provided string as a UNIX mode and retrieves the
corresponding file permission.
|
boolean |
isGroupExecutable()
Indicates whether this file permission includes the group execute
permission.
|
boolean |
isGroupReadable()
Indicates whether this file permission includes the group read
permission.
|
boolean |
isGroupWritable()
Indicates whether this file permission includes the group write
permission.
|
boolean |
isOtherExecutable()
Indicates whether this file permission includes the other execute
permission.
|
boolean |
isOtherReadable()
Indicates whether this file permission includes the other read
permission.
|
boolean |
isOtherWritable()
Indicates whether this file permission includes the other write
permission.
|
boolean |
isOwnerExecutable()
Indicates whether this file permission includes the owner execute
permission.
|
boolean |
isOwnerReadable()
Indicates whether this file permission includes the owner read
permission.
|
boolean |
isOwnerWritable()
Indicates whether this file permission includes the owner write
permission.
|
static boolean |
setPermissions(File f,
FilePermission p)
Attempts to set the given permissions on the specified file.
|
String |
toString()
Retrieves a string representation of this file permission.
|
void |
toString(StringBuilder buffer)
Appends a string representation of this file permission to the
given buffer.
|
static String |
toUNIXMode(FilePermission p)
Retrieves a three-character string that is the UNIX mode for the
provided file permission.
|
static void |
toUNIXMode(StringBuilder buffer,
FilePermission p)
Appends a three-character string that is the UNIX mode for the
provided file permission to the given buffer.
|
public static final int OWNER_READABLE
public static final int OWNER_WRITABLE
public static final int OWNER_EXECUTABLE
public static final int GROUP_READABLE
public static final int GROUP_WRITABLE
public static final int GROUP_EXECUTABLE
public static final int OTHER_READABLE
public static final int OTHER_WRITABLE
public static final int OTHER_EXECUTABLE
public FilePermission(int encodedPermission)
encodedPermission
- The encoded representation for this
file permission.public FilePermission(boolean ownerReadable, boolean ownerWritable, boolean ownerExecutable)
ownerReadable
- Indicates whether the owner should have
the read permission.ownerWritable
- Indicates whether the owner should have
the write permission.ownerExecutable
- Indicates whether the owner should have
the execute permission.public FilePermission(boolean ownerReadable, boolean ownerWritable, boolean ownerExecutable, boolean groupReadable, boolean groupWritable, boolean groupExecutable, boolean otherReadable, boolean otherWritable, boolean otherExecutable)
ownerReadable
- Indicates whether the owner should have
the read permission.ownerWritable
- Indicates whether the owner should have
the write permission.ownerExecutable
- Indicates whether the owner should have
the execute permission.groupReadable
- Indicates whether members of the file's
group should have the read permission.groupWritable
- Indicates whether members of the file's
group should have the write permission.groupExecutable
- Indicates whether members of the file's
group should have the execute
permission.otherReadable
- Indicates whether other users should
have the read permission.otherWritable
- Indicates whether other users should
have the write permission.otherExecutable
- Indicates whether other users should
have the execute permission.public boolean isOwnerReadable()
true
if this file permission includes the
owner read permission, or false
if not.public boolean isOwnerWritable()
true
if this file permission includes the
owner write permission, or false
if not.public boolean isOwnerExecutable()
true
if this file permission includes the
owner execute permission, or false
if not.public boolean isGroupReadable()
true
if this file permission includes the
group read permission, or false
if not.public boolean isGroupWritable()
true
if this file permission includes the
group write permission, or false
if not.public boolean isGroupExecutable()
true
if this file permission includes the
group execute permission, or false
if not.public boolean isOtherReadable()
true
if this file permission includes the
other read permission, or false
if not.public boolean isOtherWritable()
true
if this file permission includes the
other write permission, or false
if not.public boolean isOtherExecutable()
true
if this file permission includes the
other execute permission, or false
if not.public static boolean setPermissions(File f, FilePermission p) throws FileNotFoundException, DirectoryException
f
- The file to which the permissions should be applied.p
- The permissions to apply to the file.true
if the permissions (or the nearest
equivalent) were successfully applied to the specified
file, or false
if was not possible to set
the permissions on the current platform.FileNotFoundException
- If the specified file does not
exist.DirectoryException
- If a problem occurs while trying to
set the file permissions.public static String toUNIXMode(FilePermission p)
p
- The permission to retrieve as a UNIX mode string.public static void toUNIXMode(StringBuilder buffer, FilePermission p)
buffer
- The buffer to which the mode string should be
appended.p
- The permission to retrieve as a UNIX mode string.public static FilePermission decodeUNIXMode(String modeString) throws DirectoryException
modeString
- The string representation of the UNIX mode to
decode.DirectoryException
- If the provided string is not a
valid three-digit UNIX mode.public void toString(StringBuilder buffer)
buffer
- The buffer to which the data should be appended.Copyright © 2010-2015 ForgeRock AS. All Rights Reserved.