Package com.globalmentor.net
Class DefaultPasswordAuthenticable
- java.lang.Object
-
- com.globalmentor.net.AbstractAuthenticable
-
- com.globalmentor.net.DefaultPasswordAuthenticable
-
- All Implemented Interfaces:
Authenticable
public final class DefaultPasswordAuthenticable extends AbstractAuthenticable
A default class for providing a username and password. A singlePasswordAuthentication
instance is stored and provided when requested.- Author:
- Garret Wilson
-
-
Constructor Summary
Constructors Constructor Description DefaultPasswordAuthenticable(java.lang.String username, char[] password)
Username and password constructor.DefaultPasswordAuthenticable(java.net.PasswordAuthentication passwordAuthentication)
Password authentication constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.net.PasswordAuthentication
getPasswordAuthentication()
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.-
Methods inherited from class com.globalmentor.net.AbstractAuthenticable
getPasswordAuthentication, getPasswordAuthentication
-
-
-
-
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 isnull
.
-
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 isnull
.
-
-
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 storedPasswordAuthentication
instance.- Parameters:
uri
- The URI for which authentication is requested, ornull
if there is no relevant URI.prompt
- A description of the authentication.username
- The user for which password information should be gathered, ornull
if the username is not restricted.- Returns:
- The password authentication collected from the user, or
null
if none is provided.
-
-