Class OwnerOnlyFilePermissions

java.lang.Object
com.shaft.capture.storage.OwnerOnlyFilePermissions

public final class OwnerOnlyFilePermissions extends Object
Restricts a file or directory to owner-only access on any filesystem. Extracted from com.shaft.capture.network.SecretHeaderReplacer so every locally-stored secret -- captured header secrets, and the mobile capture proxy's CA private key -- goes through the same single, tested implementation of this security-sensitive operation rather than duplicating it.
  • Method Details

    • restrictToOwner

      public static void restrictToOwner(Path path)
      Sets owner-only permissions on a file. On POSIX systems, uses PosixFilePermission (0600 = owner read+write only). On Windows (or any non-POSIX filesystem that supports ACLs), replaces the ACL with a single ALLOW entry for the owner, denying access to every other principal.
      Parameters:
      path - file path
    • restrictDirectoryToOwner

      public static void restrictDirectoryToOwner(Path directory)
      Sets owner-only permissions on a directory, keeping it traversable by its owner. Unlike restrictToOwner(Path), this also grants the owner execute (search) permission -- on POSIX systems, a directory without its own execute bit cannot be traversed into by anyone, including its owner, so a plain owner-read/write-only directory would block every subsequent read or write of files inside it.
      Parameters:
      directory - directory path