Class FileBasedEventHandlerConfiguration.FilePermissions

java.lang.Object
org.forgerock.audit.events.handlers.FileBasedEventHandlerConfiguration.FilePermissions
Enclosing class:
FileBasedEventHandlerConfiguration

public static final class FileBasedEventHandlerConfiguration.FilePermissions extends Object
This class provides a mechanism for setting file permissions in a more abstract manner than is provided by the underlying operating system and/or filesystem. It uses a traditional UNIX-style rwx/ugo representation for the permissions and converts them as necessary to the scheme used by the underlying platform. It does not provide any mechanism for getting file permissions, nor does it provide any way of dealing with file ownership or ACLs.
  • Method Details

    • applyFilePermissions

      public static boolean applyFilePermissions(Path filePath, FileBasedEventHandlerConfiguration.FilePermissions filePermissions) throws FileNotFoundException, AuditException
      Attempts to set the given permissions on the specified file. If the underlying platform does not allow the full level of granularity specified in the permissions, then an attempt will be made to set them as closely as possible to the provided permissions, erring on the side of security.
      Parameters:
      filePath - The file to which the permissions should be applied.
      filePermissions - The permissions to apply to the file.
      Returns:
      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.
      Throws:
      FileNotFoundException - If the specified file does not exist.
      AuditException - If a problem occurs while trying to set the file permissions.
    • decodeUnixMode

      public static FileBasedEventHandlerConfiguration.FilePermissions decodeUnixMode(String modeString) throws AuditException
      Decodes the provided string as a UNIX mode and retrieves the corresponding file permissions. The mode string must contain three digits between zero and seven.
      Parameters:
      modeString - The string representation of the UNIX mode to decode.
      Returns:
      The file permissions that is equivalent to the given UNIX mode.
      Throws:
      AuditException - If the provided string is not a valid three-digit UNIX mode.
    • toPosixPermissions

      public Set<PosixFilePermission> toPosixPermissions()
      Returns the corresponding set of POSIX file permissions.
      Returns:
      the corresponding set of POSIX file permissions
    • toString

      public String toString()
      Overrides:
      toString in class Object