@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(java.io.PrintStream standardOutput,
java.io.PrintStream standardError)
Creates a new instance of this password file reader.
|
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(java.io.PrintStream standardOutput, 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
.public char[] readPassword(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.public char[] readPassword(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.public java.util.List<char[]> getCachedEncryptionPasswords()
public void addToEncryptionPasswordCache(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(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.