Class DefaultPasswordAuthenticable

  • All Implemented Interfaces:
    Authenticable

    public final class DefaultPasswordAuthenticable
    extends AbstractAuthenticable
    A default class for providing a username and password. A single PasswordAuthentication instance is stored and provided when requested.
    Author:
    Garret Wilson
    • Constructor Detail

      • DefaultPasswordAuthenticable

        public DefaultPasswordAuthenticable​(java.lang.String username,
                                            char[] password)
        Username and password constructor.

        The given password is cloned before it is stored in a new PasswordAuthentication object.

        Parameters:
        username - The user's username.
        password - the user's password.
        Throws:
        java.lang.NullPointerException - if the given username and/or password is null.
      • DefaultPasswordAuthenticable

        public DefaultPasswordAuthenticable​(java.net.PasswordAuthentication passwordAuthentication)
        Password authentication constructor.
        Parameters:
        passwordAuthentication - The password authentication to provide.
        Throws:
        java.lang.NullPointerException - if the given password authentication is null.
    • Method Detail

      • getPasswordAuthentication

        public java.net.PasswordAuthentication getPasswordAuthentication()
        Returns:
        The password authentication to provide.
      • getPasswordAuthentication

        public java.net.PasswordAuthentication getPasswordAuthentication​(java.net.URI uri,
                                                                         java.lang.String prompt,
                                                                         java.lang.String username)
        Determines password information for a given user in relation to a given URI and description. The user must not be allowed to change the username, if one is provided. This implementation returns the stored PasswordAuthentication instance.
        Parameters:
        uri - The URI for which authentication is requested, or null if there is no relevant URI.
        prompt - A description of the authentication.
        username - The user for which password information should be gathered, or null if the username is not restricted.
        Returns:
        The password authentication collected from the user, or null if none is provided.