6.1.2 Credentials

The credentials that are passed must implement the empty marker interface Credentials.

The implementer may either provide its own custom implementation or use the provided SimpleCredentials class. This class provides a minimal standard method for authenticating against a repository (i.e., using a user ID and password). Additional attributes may be used by the repository, for example, to set a token that can then be passed back and forth once authentication has been completed (thus enabling later authorization without re-authentication).



SimpleCredentials(String userID, char[] password)

Create a new SimpleCredentials object, given a user ID and password. Note that the given password is cloned before it is stored in the new SimpleCredentials object. This should avoid the risk of having unnecessary references to password data lying around in memory.



Gets the user ID.



Returns the password. Note that this method returns a reference to the password. It is the caller's responsibility to zero out the password information after it is no longer needed.


setAttribute(String name, Object value)

Stores an attribute in this credentials instance.


removeAttribute(String name)

Removes an attribute from this credentials instance.


getAttribute(String name)

Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.



Returns the names of the attributes available to this credentials instance. This method returns an empty array if the credentials instance has no attributes available to it.