class FilePasswordProvider extends java.lang.Object implements PasswordProvider
This is a relatively secure way to handle passwords:
getPassword()
method and the password file is read until the moment that the caller
completes authentication and overwrites the password char[] array.
Less secure implementations are MemoryPasswordProvider
and EnvironmentPasswordProvider
.
Modifier and Type | Field and Description |
---|---|
private java.nio.file.Path |
passwordPath |
Constructor and Description |
---|
FilePasswordProvider(java.lang.String passwordFile)
Constructs a new FilePasswordProvider with the specified path.
|
Modifier and Type | Method and Description |
---|---|
char[] |
getPassword()
Returns a new char[] array with the password characters.
|
public FilePasswordProvider(java.lang.String passwordFile) throws java.nio.file.NoSuchFileException
passwordFile
- the path to the password filejava.nio.file.NoSuchFileException
- if the password file does not exist when this FilePasswordProvider is constructedpublic char[] getPassword()
PasswordProvider
It is the responsibility of the caller to erase this data by calling
Arrays.fill(char[], char)
immediately when authentication is complete and the password data
is no longer needed.
getPassword
in interface PasswordProvider