Class OwnerOnlyFilePermissions
java.lang.Object
com.shaft.capture.storage.OwnerOnlyFilePermissions
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 Summary
Modifier and TypeMethodDescriptionstatic voidrestrictDirectoryToOwner(Path directory) Sets owner-only permissions on a directory, keeping it traversable by its owner.static voidrestrictToOwner(Path path) Sets owner-only permissions on a file.
-
Method Details
-
restrictToOwner
Sets owner-only permissions on a file. On POSIX systems, usesPosixFilePermission(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
Sets owner-only permissions on a directory, keeping it traversable by its owner. UnlikerestrictToOwner(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
-