public class PermissionUtils
extends java.lang.Object
PosixFilePermission or the traditional Unix mode representation of
permissions.| Modifier and Type | Class and Description |
|---|---|
static class |
PermissionUtils.FileType
The supported types of files, maps to the
isFoo methods
in BasicFileAttributes. |
| Modifier and Type | Method and Description |
|---|---|
static java.util.Set<java.nio.file.attribute.PosixFilePermission> |
getPermissions(Resource r,
java.util.function.Function<java.nio.file.Path,java.util.Set<java.nio.file.attribute.PosixFilePermission>> posixNotSupportedFallback)
Sets permissions of a
Resource - returns an empty set
for unsupported resource types or file systems that don't
support PosixFilePermissions and no fallback has been
provided.. |
static int |
modeFromPermissions(java.util.Set<java.nio.file.attribute.PosixFilePermission> permissions,
PermissionUtils.FileType type)
Translates a set of permissions into a Unix stat(2)
st_mode result. |
static java.util.Set<java.nio.file.attribute.PosixFilePermission> |
permissionsFromMode(int mode)
Translates a Unix stat(2)
st_mode compatible value into
a set of permissions. |
static void |
setPermissions(Resource r,
java.util.Set<java.nio.file.attribute.PosixFilePermission> permissions,
java.util.function.Consumer<java.nio.file.Path> posixNotSupportedCallback)
Sets permissions on a
Resource - doesn't do anything
for unsupported resource types. |
public static int modeFromPermissions(java.util.Set<java.nio.file.attribute.PosixFilePermission> permissions,
PermissionUtils.FileType type)
st_mode result.permissions - the permissionstype - the file typepublic static java.util.Set<java.nio.file.attribute.PosixFilePermission> permissionsFromMode(int mode)
st_mode compatible value into
a set of permissions.mode - the "mode"public static void setPermissions(Resource r, java.util.Set<java.nio.file.attribute.PosixFilePermission> permissions, java.util.function.Consumer<java.nio.file.Path> posixNotSupportedCallback) throws java.io.IOException
Resource - doesn't do anything
for unsupported resource types.
Supported types are:
r - the resource to set permissions forpermissions - the permissionsposixNotSupportedCallback - optional callback that is
invoked for a file provider resource if the file-system holding
the file doesn't support PosixFilePermissions. The Path
corresponding to the file is passed to the callback.java.io.IOException - if something goes wrongpublic static java.util.Set<java.nio.file.attribute.PosixFilePermission> getPermissions(Resource r, java.util.function.Function<java.nio.file.Path,java.util.Set<java.nio.file.attribute.PosixFilePermission>> posixNotSupportedFallback) throws java.io.IOException
Resource - returns an empty set
for unsupported resource types or file systems that don't
support PosixFilePermissions and no fallback has been
provided..
Supported types are:
r - the resource to read permissions fromposixNotSupportedFallback - optional fallback function to provide
permissions for file system that don't support
PosixFilePermissions. The Path corresponding to the file is
passed to the callback.java.io.IOException - if something goes wrong