Package java.net
Class PasswordAuthentication
- java.lang.Object
-
- java.net.PasswordAuthentication
-
public final class PasswordAuthentication extends Object
This immutable class is a data structure that encapsulates username and password which is used by theAuthenticatorclass.- See Also:
Authenticator
-
-
Constructor Summary
Constructors Constructor Description PasswordAuthentication(String userName, char[] password)Creates an instance of a password authentication with a specified username and password.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description char[]getPassword()Gets a clone of the password stored by this instance.StringgetUserName()Gets the username stored by this instance.
-
-
-
Constructor Detail
-
PasswordAuthentication
public PasswordAuthentication(String userName, char[] password)
Creates an instance of a password authentication with a specified username and password.- Parameters:
userName- the username to store.password- the associated password to store.
-
-
Method Detail
-
getPassword
public char[] getPassword()
Gets a clone of the password stored by this instance. The user is responsible to finalize the returned array if the password clone is no longer needed.- Returns:
- the copied password.
-
getUserName
public String getUserName()
Gets the username stored by this instance.- Returns:
- the stored username.
-
-