oracle.kv

## Class PasswordCredentials

- java.lang.Object
- - oracle.kv.PasswordCredentials

- All Implemented Interfaces:
    Serializable, LoginCredentials

      public class PasswordCredentials
      extends Object
      implements LoginCredentials, Serializable

  Username/password credentials. This class provides the standard mechanism for an application to authenticate as a particular user when accessing a KVStore instance. The object contains sensitive information and should be kept private. When no longer needed the user should call clear() to erase the internal password information.
  Since:
    3.0
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PasswordCredentials(String username, char[] password)` Creates a username/password credential set.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clear()` Wipes out the password storage to ensure it does not hang around in in the Java VM memory space.
    `char[]` | `getPassword()` Gets the password.
    `String` | `getUsername()` Identifies the user owning the credentials.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### PasswordCredentials

          public PasswordCredentials(String username,
                             char[] password)
                              throws IllegalArgumentException

      Creates a username/password credential set. The password passed in is copied internal to the object. For maximum security, it is recommended that you call the `clear()` method when you are done with the object to avoid have the password being present in the Java memory heap.
      Parameters:
        `username` - the name of the user
        `password` - the password of the user
      Throws:
        `IllegalArgumentException` - if either username or password have null values.

  - ### Method Detail

    - #### getUsername

          public String getUsername()

      Description copied from interface: `LoginCredentials`
      Identifies the user owning the credentials.
      Specified by:
        `getUsername` in interface `LoginCredentials`
      Returns:
        the name of the user for which the credentials belong.
      See Also:
        `LoginCredentials.getUsername()`

    - #### getPassword

          public char[] getPassword()

      Gets the password. This returns a copy of the password. The caller should clear the returned memory when the value is no longer needed.
      Returns:
        The password for the user.

    - #### clear

          public void clear()

      Wipes out the password storage to ensure it does not hang around in in the Java VM memory space.

Copyright (c) 2011, 2014 Oracle and/or its affiliates. All rights reserved.