All Implemented Interfaces:
Serializable, Comparable<File>

public class SecureFileextends SecureDirectory
Same as SecureDirectory but sets the file mode after createNewFile() and createTempFile(String, String) also. So just use this instead. Probably should have just made this class in the beginning and not had two.
See Also:
  • Constructor Details

    • SecureFile

      public SecureFile(String pathname)
      Wraps a path so the file is created with restricted permissions.
      Parameters:
      pathname - the path of the file to wrap
    • SecureFile

      public SecureFile(String parent, String child)
      Wraps a parent path and file name with restricted permissions.
      Parameters:
      parent - the path of the containing directory
      child - the name of the file within parent
    • SecureFile

      public SecureFile(File parent, String child)
      Wraps a parent directory and file name with restricted permissions.
      Parameters:
      parent - the containing directory
      child - the name of the file within parent
  • Method Details

    • createNewFile

      public boolean createNewFile() throws IOException
      Tries to set file to mode 600 if the file is created.
      Overrides:
      createNewFile in class File
      Throws:
      IOException
    • createTempFile

      public static File createTempFile(String prefix, String suffix) throws IOException
      Tries to set file to mode 600 when the file is created.
      Parameters:
      prefix - the prefix of the generated file name
      suffix - the suffix of the generated file name
      Returns:
      the new file, already set to mode 600
      Throws:
      IOException - if the file could not be created
    • createTempFile

      public static File createTempFile(String prefix, String suffix, File directory) throws IOException
      Tries to set file to mode 600 when the file is created.
      Parameters:
      prefix - the prefix of the generated file name
      suffix - the suffix of the generated file name
      directory - the directory to create the file in, or null for the default temp directory
      Returns:
      the new file, already set to mode 600
      Throws:
      IOException - if the file could not be created
    • setPerms

      protected void setPerms()
      Tries to set the permissions to 600, ignores errors.
      Overrides:
      setPerms in class SecureDirectory