Class PosixAcl
The permissions of one file or folder of a POSIX-style source (a Unix
file system, SFTP, ADLS Gen2, HDFS): its owner, group and mode bits, and
any extended entries (named users and groups, and the mask), turned into
the standard AclLevel for one right.
POSIX checks the classes in order and stops at the first that matches: the owner, then named users, then the groups (any group the person is in that grants the right), then everyone else. The standard has no order, only "a deny wins", so a class without the right is written as a deny whenever a later class could otherwise let the same person in: an owner who may not read is denied when a group or everyone may. The translation never lets in anyone POSIX keeps out. It can keep out a person POSIX lets in, in one rare case: an owner (or named user) with the right who is also in a group that is denied.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordAn entry beside the mode bits that allows or denies rights directly, the way macOS ACL entries do (they are checked before the mode bits).static final recordA user or group, by the most stable id the source gives, and a readable name when the source gives one besides. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPosixAcl(String dir, PosixAcl.Principal owner, PosixAcl.Principal group, int mode) -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanadmitsEverybody(AclLevel level) Whether a level lets everybody in: it allows everyone and denies nobody.direct(PosixAcl.Direct direct) Adds an entry that allows or denies rights directly (macOS).group(PosixAcl.Principal grp, int perms) Adds a named group entry of an extended ACL.groupPerms(int perms) Sets the owning group's rights, as given by an extended ACL's owngroup::entry (when a file has an extended ACL, the group bits of its mode hold the mask instead).booleanWho has one right, as a level.mask(int perms) Sets the mask, which limits the rights of named users, named groups and the owning group.static intmode(Set<PosixFilePermission> perms) The mode bits of a set of Java POSIX permissions.The source's own entries, in thegetfaclway of writing them when none were kept as given.nativeEntry(String entry) Keeps one of the source's own entries, as it gave it, for thenativepart of the ACL.otherPerms(int perms) Sets everyone else's rights, as given by an extended ACL'sother::entry.ownerPerms(int perms) Sets the owner's rights, as given by an extended ACL's ownuser::entry.owners()static intReads a mode written in octal (755,1777), or therwxr-x---way.static intparsePerms(String text) Reads rights written therwxway (r-x, for example), any other letter thanr,wandxignored.user(PosixAcl.Principal user, int perms) Adds a named user entry of an extended ACL.
-
Field Details
-
READ
public static final int READThe read right (r).- See Also:
-
WRITE
public static final int WRITEThe write right (w).- See Also:
-
EXECUTE
public static final int EXECUTEThe execute right (x), which on a folder is the right to go in.- See Also:
-
-
Constructor Details
-
PosixAcl
- Parameters:
dir- the directory users and groups belong to, as<system>:<name>(for exampleunix:host.example.com)owner- the owning user, ornullif unknowngroup- the owning group, ornullif unknownmode- the mode bits (0640, for example); only the lowest nine are used
-
-
Method Details
-
ownerPerms
Sets the owner's rights, as given by an extended ACL's ownuser::entry. -
groupPerms
Sets the owning group's rights, as given by an extended ACL's owngroup::entry (when a file has an extended ACL, the group bits of its mode hold the mask instead).- Parameters:
perms- the rights- Returns:
- this
-
otherPerms
Sets everyone else's rights, as given by an extended ACL'sother::entry.- Parameters:
perms- the rights- Returns:
- this
-
mask
Sets the mask, which limits the rights of named users, named groups and the owning group.- Parameters:
perms- the rights the mask lets through- Returns:
- this
-
user
Adds a named user entry of an extended ACL.- Parameters:
user- the userperms- the rights, before the mask- Returns:
- this
-
group
Adds a named group entry of an extended ACL.- Parameters:
grp- the groupperms- the rights, before the mask- Returns:
- this
-
direct
Adds an entry that allows or denies rights directly (macOS).- Parameters:
direct- the entry- Returns:
- this
-
nativeEntry
Keeps one of the source's own entries, as it gave it, for thenativepart of the ACL.- Parameters:
entry- the entry, as text- Returns:
- this
-
hasExtendedEntries
public boolean hasExtendedEntries()- Returns:
- whether named users or groups were added
-
level
Who has one right, as a level. -
owners
- Returns:
- the owner, as the ACL's owners
-
nativeData
The source's own entries, in thegetfaclway of writing them when none were kept as given.- Returns:
- the native part of the ACL
-
admitsEverybody
Whether a level lets everybody in: it allows everyone and denies nobody. Such a level can be left out, as it changes nothing.- Parameters:
level- the level- Returns:
trueif it lets everybody in
-
parsePerms
Reads rights written therwxway (r-x, for example), any other letter thanr,wandxignored. -
parseMode
Reads a mode written in octal (755,1777), or therwxr-x---way.- Parameters:
text- the mode- Returns:
- the mode bits
- Throws:
IllegalArgumentException- if the mode is not readable
-
mode
The mode bits of a set of Java POSIX permissions.- Parameters:
perms- the permissions- Returns:
- the mode bits
-