@ThreadSafety(level=NOT_THREADSAFE) public final class PasswordFileReader extends java.lang.Object
PassphraseEncryptedOutputStream
, and may have optionally been
compressed with the GZIPOutputStream
. If the data is both compressed
and encrypted, then it must have been compressed before it was encrypted, so
that it is necessary to decrypt the data before it can be decompressed.
Constructor and Description |
---|
PasswordFileReader()
Creates a new instance of this password file reader.
|
PasswordFileReader(boolean allowPromptingForPassphrase)
Creates a new instance of this password file reader.
|
PasswordFileReader(java.io.PrintStream standardOutput,
java.io.PrintStream standardError)
Creates a new instance of this password file reader using the specified
output and error streams if it is necessary to interactively prompt the
user for an encryption passphrase.
|
Modifier and Type | Method and Description |
---|---|
void |
addToEncryptionPasswordCache(char[] encryptionPassword)
Adds the provided password to the cache of passwords that will be tried as
potential encryption keys if an encrypted password file is encountered.
|
void |
addToEncryptionPasswordCache(java.lang.String encryptionPassword)
Adds the provided password to the cache of passwords that will be tried as
potential encryption keys if an encrypted password file is encountered.
|
void |
clearEncryptionPasswordCache(boolean zeroArrays)
Clears the cache of passwords that will be tried as potential encryption
keys if an encrypted password file is encountered.
|
java.util.List<char[]> |
getCachedEncryptionPasswords()
Retrieves a list of the encryption passwords currently held in the cache.
|
char[] |
readPassword(java.io.File file)
Attempts to read a password from the specified file.
|
char[] |
readPassword(java.lang.String path)
Attempts to read a password from the specified file.
|
public PasswordFileReader()
public PasswordFileReader(boolean allowPromptingForPassphrase)
allowPromptingForPassphrase
- Indicates whether to allow interactively prompting the end
user for the encryption passphrase if the file is encrypted
and the key cannot be automatically obtained (for example,
from a Ping Identity server's encryption settings database).public PasswordFileReader(@NotNull java.io.PrintStream standardOutput, @NotNull java.io.PrintStream standardError)
standardOutput
- The print stream that should be used as standard
output if an encrypted password file is encountered
and it is necessary to prompt for the password
used as the encryption key. This must not be
null
.standardError
- The print stream that should be used as standard
error if an encrypted password file is encountered
and it is necessary to prompt for the password
used as the encryption key. This must not be
null
.@NotNull public char[] readPassword(@NotNull java.lang.String path) throws java.io.IOException, LDAPException
path
- The path to the file from which the password should be read.
It must not be null
, and the file must exist.java.io.IOException
- If a problem is encountered while trying to read the
password from the file.LDAPException
- If the file does not exist, if it does not contain
exactly one line, or if that line is empty.@NotNull public char[] readPassword(@NotNull java.io.File file) throws java.io.IOException, LDAPException
file
- The path file from which the password should be read. It
must not be null
, and the file must exist.java.io.IOException
- If a problem is encountered while trying to read the
password from the file.LDAPException
- If the file does not exist, if it does not contain
exactly one line, or if that line is empty.@NotNull public java.util.List<char[]> getCachedEncryptionPasswords()
public void addToEncryptionPasswordCache(@NotNull java.lang.String encryptionPassword)
encryptionPassword
- A password to add to the cache of passwords
that will be tried as potential encryption keys
if an encrypted password file is encountered.
It must not be null
or empty.public void addToEncryptionPasswordCache(@NotNull char[] encryptionPassword)
encryptionPassword
- A password to add to the cache of passwords
that will be tried as potential encryption keys
if an encrypted password file is encountered.
It must not be null
or empty.public void clearEncryptionPasswordCache(boolean zeroArrays)
zeroArrays
- Indicates whether to zero out the contents of the
cached passwords before clearing them. If this is
true
, then all of the backing arrays for the
cached passwords will be overwritten with all null
characters to erase the original passwords from memory.