|
JSecurity | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jsecurity.authc.UsernamePasswordToken
public class UsernamePasswordToken
A simple username/password authentication token to support the most widely-used authentication mechanism. This
class also implements the RememberMeAuthenticationToken interface to support
"Remember Me" services across user sessions as well as the
InetAuthenticationToken interface to retain the IP address location from where the
authentication attempt is occuring.
"Remember Me" authentications are disabled by default, but if the application developer wishes to allow
it for a login attempt, all that is necessary is to call setRememberMe(true). If the underlying
SecurityManager implementation also supports RememberMe services, the user's identity will be
remembered across sessions.
Note that this class stores a password as a char[] instead of a String (which may seem more logical). This is because Strings are immutable and their internal value cannot be overwritten - meaning even a nulled String instance might be accessible in memory at a later time (e.g. memory dump). This is not good for sensitive information such as passwords. For more information, see the Java Cryptography Extension Reference Guide.
To avoid this possibility of later memory access, the application developer should always call
clear() after using the token to perform a login attempt.
| Constructor Summary | |
|---|---|
UsernamePasswordToken()
JavaBeans compatible no-arg constructor. |
|
UsernamePasswordToken(String username,
char[] password)
Constructs a new UsernamePasswordToken encapsulating the username and password submitted during an authentication attempt, with a null inetAddress and a
rememberMe default of false. |
|
UsernamePasswordToken(String username,
char[] password,
boolean rememberMe)
Constructs a new UsernamePasswordToken encapsulating the username and password submitted, as well as if the user wishes their identity to be remembered across sessions. |
|
UsernamePasswordToken(String username,
char[] password,
boolean rememberMe,
InetAddress inetAddress)
Constructs a new UsernamePasswordToken encapsulating the username and password submitted, if the user wishes their identity to be remembered across sessions, and the inetAddress from where the attempt is ocurring. |
|
UsernamePasswordToken(String username,
char[] password,
InetAddress inetAddress)
Constructs a new UsernamePasswordToken encapsulating the username and password submitted, the inetAddress from where the attempt is occurring, and a default rememberMe value of false |
|
UsernamePasswordToken(String username,
String password)
Constructs a new UsernamePasswordToken encapsulating the username and password submitted during an authentication attempt, with a null inetAddress and
a rememberMe default of false
This is a convience constructor and maintains the password internally via a character
array, i.e. |
|
UsernamePasswordToken(String username,
String password,
boolean rememberMe)
Constructs a new UsernamePasswordToken encapsulating the username and password submitted, as well as if the user wishes their identity to be remembered across sessions. |
|
UsernamePasswordToken(String username,
String password,
boolean rememberMe,
InetAddress inetAddress)
Constructs a new UsernamePasswordToken encapsulating the username and password submitted, if the user wishes their identity to be remembered across sessions, and the inetAddress from where the attempt is ocurring. |
|
UsernamePasswordToken(String username,
String password,
InetAddress inetAddress)
Constructs a new UsernamePasswordToken encapsulating the username and password submitted, the inetAddress from where the attempt is occurring, and a default rememberMe value of false This is a convience constructor and maintains the password internally via a character array, i.e. |
|
| Method Summary | |
|---|---|
void |
clear()
Clears out (nulls) the username, password, rememberMe, and inetAddress. |
Object |
getCredentials()
Returns the password char array. |
InetAddress |
getInetAddress()
Returns the inetAddress from where the authentication attempt occurs. |
char[] |
getPassword()
Returns the password submitted during an authentication attempt as a character array. |
Object |
getPrincipal()
Simply returns getUsername(). |
String |
getUsername()
Returns the username submitted during an authentication attempt. |
boolean |
isRememberMe()
Returns true if the submitting user wishes their identity (principal(s)) to be remembered across sessions, false otherwise. |
void |
setInetAddress(InetAddress inetAddress)
Sets the inetAddress from where the authentication attempt occurs. |
void |
setPassword(char[] password)
Sets the password for submission during an authentication attempt. |
void |
setRememberMe(boolean rememberMe)
Sets if the submitting user wishes their identity (pricipal(s)) to be remembered across sessions. |
void |
setUsername(String username)
Sets the username for submission during an authentication attempt. |
String |
toString()
Returns the String representation. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public UsernamePasswordToken()
public UsernamePasswordToken(String username,
char[] password)
inetAddress and a
rememberMe default of false.
username - the username submitted for authenticationpassword - the password character array submitted for authentication
public UsernamePasswordToken(String username,
String password)
inetAddress and
a rememberMe default of false
This is a convience constructor and maintains the password internally via a character array, i.e. password.toCharArray();. Note that storing a password as a String in your code could have possible security implications as noted in the class JavaDoc.
username - the username submitted for authenticationpassword - the password string submitted for authentication
public UsernamePasswordToken(String username,
char[] password,
InetAddress inetAddress)
username - the username submitted for authenticationpassword - the password string submitted for authenticationinetAddress - the inetAddress from where the attempt is occuring
public UsernamePasswordToken(String username,
String password,
InetAddress inetAddress)
This is a convience constructor and maintains the password internally via a character array, i.e. password.toCharArray();. Note that storing a password as a String in your code could have possible security implications as noted in the class JavaDoc.
username - the username submitted for authenticationpassword - the password string submitted for authenticationinetAddress - the inetAddress from where the attempt is occuring
public UsernamePasswordToken(String username,
char[] password,
boolean rememberMe)
username - the username submitted for authenticationpassword - the password string submitted for authenticationrememberMe - if the user wishes their identity to be remembered across sessions
public UsernamePasswordToken(String username,
String password,
boolean rememberMe)
This is a convience constructor and maintains the password internally via a character array, i.e. password.toCharArray();. Note that storing a password as a String in your code could have possible security implications as noted in the class JavaDoc.
username - the username submitted for authenticationpassword - the password string submitted for authenticationrememberMe - if the user wishes their identity to be remembered across sessions
public UsernamePasswordToken(String username,
char[] password,
boolean rememberMe,
InetAddress inetAddress)
username - the username submitted for authenticationpassword - the password character array submitted for authenticationrememberMe - if the user wishes their identity to be remembered across sessionsinetAddress - the inetAddress from where the attempt is occuring
public UsernamePasswordToken(String username,
String password,
boolean rememberMe,
InetAddress inetAddress)
This is a convience constructor and maintains the password internally via a character array, i.e. password.toCharArray();. Note that storing a password as a String in your code could have possible security implications as noted in the class JavaDoc.
username - the username submitted for authenticationpassword - the password string submitted for authenticationrememberMe - if the user wishes their identity to be remembered across sessionsinetAddress - the inetAddress from where the attempt is occuring| Method Detail |
|---|
public String getUsername()
public void setUsername(String username)
username - the username to be used for submission during an authentication attempt.public char[] getPassword()
public void setPassword(char[] password)
password - the password to be used for submission during an authentication attemp.public Object getPrincipal()
getUsername().
getPrincipal in interface AuthenticationTokenusername.AuthenticationToken.getPrincipal()public Object getCredentials()
password char array.
getCredentials in interface AuthenticationTokenpassword char array.AuthenticationToken.getCredentials()public InetAddress getInetAddress()
(JSecurity's default Authenticator allows null IPs to support localhost and proxy server environments).
getInetAddress in interface InetAuthenticationTokenpublic void setInetAddress(InetAddress inetAddress)
(JSecurity's default Authenticator allows null IPs to allow localhost and proxy server environments).
inetAddress - the inetAddress from where the authentication attempt occurs.public boolean isRememberMe()
isRememberMe in interface RememberMeAuthenticationTokenpublic void setRememberMe(boolean rememberMe)
rememberMe - value inidicating if the user wishes their identity (principal(s)) to be remembered across
sessions.public void clear()
public String toString()
toString in class Object
|
JSecurity | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||