java.lang.Object
java.io.File
net.i2p.util.SecureDirectory
net.i2p.util.SecureFile
- All Implemented Interfaces:
Serializable, Comparable<File>
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:
Field Summary
Fields inherited from class SecureDirectory
isNotWindowsModifier and TypeFieldDescriptionprotected static final booleanWhether the OS is not Windows.Fields inherited from class File
pathSeparator, pathSeparatorChar, separator, separatorCharConstructor Summary
ConstructorsConstructorDescriptionSecureFile(File parent, String child) Wraps a parent directory and file name with restricted permissions.SecureFile(String pathname) Wraps a path so the file is created with restricted permissions.SecureFile(String parent, String child) Wraps a parent path and file name with restricted permissions.Method Summary
Modifier and TypeMethodDescriptionbooleanTries to set file to mode 600 if the file is created.static FilecreateTempFile(String prefix, String suffix) Tries to set file to mode 600 when the file is created.static FilecreateTempFile(String prefix, String suffix, File directory) Tries to set file to mode 600 when the file is created.protected voidsetPerms()Tries to set the permissions to 600, ignores errors.Methods inherited from class SecureDirectory
mkdir, mkdirsMethods inherited from class File
canExecute, canRead, canWrite, compareTo, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getFreeSpace, getName, getParent, getParentFile, getPath, getTotalSpace, getUsableSpace, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listFiles, listRoots, renameTo, setExecutable, setExecutable, setLastModified, setReadable, setReadable, setReadOnly, setWritable, setWritable, toPath, toString, toURI
Constructor Details
SecureFile
Wraps a path so the file is created with restricted permissions.- Parameters:
pathname- the path of the file to wrap
SecureFile
SecureFile
Method Details
createNewFile
Tries to set file to mode 600 if the file is created.- Overrides:
createNewFilein classFile- Throws:
IOException
createTempFile
Tries to set file to mode 600 when the file is created.- Parameters:
prefix- the prefix of the generated file namesuffix- 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
Tries to set file to mode 600 when the file is created.- Parameters:
prefix- the prefix of the generated file namesuffix- the suffix of the generated file namedirectory- 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:
setPermsin classSecureDirectory