public class SecureIOUtils
extends java.lang.Object
| Modifier and Type | Class | Description |
|---|---|---|
static class |
SecureIOUtils.AlreadyExistsException |
Signals that an attempt to create a file at a given pathname has failed
because another file already existed at that path.
|
| Constructor | Description |
|---|---|
SecureIOUtils() |
| Modifier and Type | Method | Description |
|---|---|---|
static java.io.FileOutputStream |
createForWrite(java.io.File f,
int permissions) |
Open the specified File for write access, ensuring that it does not exist.
|
protected static java.io.RandomAccessFile |
forceSecureOpenForRandomRead(java.io.File f,
java.lang.String mode,
java.lang.String expectedOwner,
java.lang.String expectedGroup) |
|
protected static java.io.FileInputStream |
forceSecureOpenForRead(java.io.File f,
java.lang.String expectedOwner,
java.lang.String expectedGroup) |
|
protected static FSDataInputStream |
forceSecureOpenFSDataInputStream(java.io.File file,
java.lang.String expectedOwner,
java.lang.String expectedGroup) |
Same as openFSDataInputStream except that it will run even if security is
off.
|
static java.io.RandomAccessFile |
openForRandomRead(java.io.File f,
java.lang.String mode,
java.lang.String expectedOwner,
java.lang.String expectedGroup) |
|
static java.io.FileInputStream |
openForRead(java.io.File f,
java.lang.String expectedOwner,
java.lang.String expectedGroup) |
Open the given File for read access, verifying the expected user/group
constraints if security is enabled.
|
static FSDataInputStream |
openFSDataInputStream(java.io.File file,
java.lang.String expectedOwner,
java.lang.String expectedGroup) |
Opens the
FSDataInputStream on the requested file on local file
system, verifying the expected user/group constraints if security is
enabled. |
public static java.io.RandomAccessFile openForRandomRead(java.io.File f,
java.lang.String mode,
java.lang.String expectedOwner,
java.lang.String expectedGroup)
throws java.io.IOException
f - file that we are trying to openmode - mode in which we want to open the random access fileexpectedOwner - the expected user owner for the fileexpectedGroup - the expected group owner for the filejava.io.IOException - if an IO error occurred or if the user/group does
not match when security is enabled.@VisibleForTesting
protected static java.io.RandomAccessFile forceSecureOpenForRandomRead(java.io.File f,
java.lang.String mode,
java.lang.String expectedOwner,
java.lang.String expectedGroup)
throws java.io.IOException
f - input f.mode - input mode.expectedOwner - input expectedOwner.expectedGroup - input expectedGroup.java.io.IOException - raised on errors performing I/O.public static FSDataInputStream openFSDataInputStream(java.io.File file, java.lang.String expectedOwner, java.lang.String expectedGroup) throws java.io.IOException
FSDataInputStream on the requested file on local file
system, verifying the expected user/group constraints if security is
enabled.file - absolute path of the fileexpectedOwner - the expected user owner for the fileexpectedGroup - the expected group owner for the filejava.io.IOException - if an IO Error occurred or the user/group does not
match if security is enabled@VisibleForTesting protected static FSDataInputStream forceSecureOpenFSDataInputStream(java.io.File file, java.lang.String expectedOwner, java.lang.String expectedGroup) throws java.io.IOException
file - input file.expectedOwner - input expectedOwner.expectedGroup - input expectedGroup.java.io.IOException - raised on errors performing I/O.public static java.io.FileInputStream openForRead(java.io.File f,
java.lang.String expectedOwner,
java.lang.String expectedGroup)
throws java.io.IOException
f - the file that we are trying to openexpectedOwner - the expected user owner for the fileexpectedGroup - the expected group owner for the filejava.io.IOException - if an IO Error occurred, or security is enabled and
the user/group does not match@VisibleForTesting
protected static java.io.FileInputStream forceSecureOpenForRead(java.io.File f,
java.lang.String expectedOwner,
java.lang.String expectedGroup)
throws java.io.IOException
f - input f.expectedOwner - input expectedOwner.expectedGroup - input expectedGroup.java.io.IOException - raised on errors performing I/O.public static java.io.FileOutputStream createForWrite(java.io.File f,
int permissions)
throws java.io.IOException
f - the file that we want to createpermissions - we want to have on the file (if security is enabled)SecureIOUtils.AlreadyExistsException - if the file already existsjava.io.IOException - if any other error occurredCopyright © 2008–2025 Apache Software Foundation. All rights reserved.