com.unboundid.ldap.sdk
Class ReadFromFilePasswordProvider

java.lang.Object
  extended by com.unboundid.ldap.sdk.PasswordProvider
      extended by com.unboundid.ldap.sdk.ReadFromFilePasswordProvider
All Implemented Interfaces:
java.io.Serializable

@ThreadSafety(level=COMPLETELY_THREADSAFE)
public final class ReadFromFilePasswordProvider
extends PasswordProvider
implements java.io.Serializable

This class provides an implementation of a password provider that will obtain the password from a specified file. All bytes up to (but not including) the first end-of-line character (or to the end of the file if it does not contain an end-of-line character) will be considered part of the password.

See Also:
Serialized Form

Constructor Summary
ReadFromFilePasswordProvider(java.io.File passwordFile)
          Creates a new instance of this password provider that will read passwords from the specified file.
ReadFromFilePasswordProvider(java.lang.String passwordFile)
          Creates a new instance of this password provider that will read passwords from the specified file.
 
Method Summary
 byte[] getPasswordBytes()
          Retrieves a password in a newly-created byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReadFromFilePasswordProvider

public ReadFromFilePasswordProvider(java.lang.String passwordFile)
Creates a new instance of this password provider that will read passwords from the specified file.

Parameters:
passwordFile - The path to the file containing the password to use. It must not be null.

ReadFromFilePasswordProvider

public ReadFromFilePasswordProvider(java.io.File passwordFile)
Creates a new instance of this password provider that will read passwords from the specified file.

Parameters:
passwordFile - The file containing the password to use. It must not be null.
Method Detail

getPasswordBytes

public byte[] getPasswordBytes()
                        throws LDAPException
Retrieves a password in a newly-created byte array. Once the password is no longer required, the contents of the array will be overwritten so that the password is no longer contained in memory.

Specified by:
getPasswordBytes in class PasswordProvider
Returns:
A byte array containing the password that should be used.
Throws:
LDAPException - If a problem is encountered while attempting to obtain the password.