public class DefaultUser extends java.lang.Object implements User, java.io.Serializable
User,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
private static int |
ABSOLUTE_TIMEOUT_LENGTH
The absolute timeout length specified in the ESAPI config file.
|
(package private) long |
accountId
This user's account id.
|
private java.lang.String |
accountName
This user's account name.
|
private java.lang.String |
csrfToken
This user's CSRF token.
|
private boolean |
enabled
Whether this user's account is enabled.
|
private java.util.HashMap |
eventMap
The event map for this User
|
private java.util.Date |
expirationTime
The expiration date/time for this user's account.
|
private int |
failedLoginCount
The failed login count for this user's account.
|
private static int |
IDLE_TIMEOUT_LENGTH
The idle timeout length specified in the ESAPI config file.
|
private java.util.Date |
lastFailedLoginTime
The last failed login time for this user.
|
private java.lang.String |
lastHostAddress
The last host address used by this user.
|
private java.util.Date |
lastLoginTime
The last login time for this user.
|
private java.util.Date |
lastPasswordChangeTime
The last password change time for this user.
|
private java.util.Locale |
locale
This user's Locale.
|
private boolean |
locked
Whether this user's account is locked.
|
private boolean |
loggedIn
Whether this user is logged in.
|
private Logger |
logger
The logger used by the class.
|
private static int |
MAX_ROLE_LENGTH |
private java.util.Set<java.lang.String> |
roles
This user's assigned roles.
|
private java.lang.String |
screenName
This user's screen name (account name alias).
|
private static long |
serialVersionUID
The Constant serialVersionUID.
|
private java.util.Set<javax.servlet.http.HttpSession> |
sessions
The sessions this user is associated with
|
| Constructor and Description |
|---|
DefaultUser(java.lang.String accountName)
Instantiates a new user.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addRole(java.lang.String role)
Adds a role to this user's account.
|
void |
addRoles(java.util.Set<java.lang.String> newRoles)
Adds a set of roles to this user's account.
|
void |
addSession(javax.servlet.http.HttpSession s)
Adds a session for this User.
|
void |
changePassword(java.lang.String oldPassword,
java.lang.String newPassword1,
java.lang.String newPassword2)
Sets the user's password, performing a verification of the user's old password, the equality of the two new
passwords, and the strength of the new password.
|
java.lang.Object |
clone()
Override clone and make final to prevent duplicate user objects.
|
void |
disable()
Disable this user's account.
|
void |
enable()
Enable this user's account.
|
long |
getAccountId()
Gets this user's account id number.
|
java.lang.String |
getAccountName()
Gets this user's account name.
|
java.lang.String |
getCSRFToken()
Gets the CSRF token for this user's current sessions.
|
java.util.HashMap |
getEventMap()
Returns the hashmap used to store security events for this user.
|
java.util.Date |
getExpirationTime()
Returns the date that this user's account will expire.
|
int |
getFailedLoginCount()
Returns the number of failed login attempts since the last successful login for an account.
|
java.util.Date |
getLastFailedLoginTime()
Returns the date of the last failed login time for a user.
|
java.lang.String |
getLastHostAddress()
Returns the last host address used by the user.
|
java.util.Date |
getLastLoginTime()
Returns the date of the last successful login time for a user.
|
java.util.Date |
getLastPasswordChangeTime()
Gets the date of user's last password change.
|
java.util.Locale |
getLocale() |
java.lang.String |
getName() |
java.util.Set<java.lang.String> |
getRoles()
Gets the roles assigned to a particular account.
|
java.lang.String |
getScreenName()
Gets the screen name (alias) for the current user.
|
java.util.Set |
getSessions()
Returns the list of sessions associated with this User.
|
void |
incrementFailedLoginCount()
Increment failed login count.
|
boolean |
isAnonymous()
Checks if user is anonymous.
|
boolean |
isEnabled()
Checks if this user's account is currently enabled.
|
boolean |
isExpired()
Checks if this user's account is expired.
|
boolean |
isInRole(java.lang.String role)
Checks if this user's account is assigned a particular role.
|
boolean |
isLocked()
Checks if this user's account is locked.
|
boolean |
isLoggedIn()
Tests to see if the user is currently logged in.
|
boolean |
isSessionAbsoluteTimeout()
Tests to see if this user's session has exceeded the absolute time out based
on ESAPI's configuration settings.
|
boolean |
isSessionTimeout()
Tests to see if the user's session has timed out from inactivity based
on ESAPI's configuration settings.
|
void |
lock()
Lock this user's account.
|
void |
loginWithPassword(java.lang.String password)
Login with password.
|
void |
logout()
Logout this user.
|
void |
removeRole(java.lang.String role)
Removes a role from this user's account.
|
void |
removeSession(javax.servlet.http.HttpSession s)
Removes a session for this User.
|
java.lang.String |
resetCSRFToken()
Returns a token to be used as a prevention against CSRF attacks.
|
private void |
setAccountId(long accountId)
Sets the account id for this user's account.
|
void |
setAccountName(java.lang.String accountName)
Sets this user's account name.
|
void |
setExpirationTime(java.util.Date expirationTime)
Sets the date and time when this user's account will expire.
|
(package private) void |
setFailedLoginCount(int count)
Set the failed login count
|
void |
setLastFailedLoginTime(java.util.Date lastFailedLoginTime)
Set the time of the last failed login for this user.
|
void |
setLastHostAddress(java.lang.String remoteHost)
Set the last remote host address used by this user.
|
void |
setLastLoginTime(java.util.Date lastLoginTime)
Set the time of the last successful login for this user.
|
void |
setLastPasswordChangeTime(java.util.Date lastPasswordChangeTime)
Set the time of the last password change for this user.
|
void |
setLocale(java.util.Locale locale) |
void |
setRoles(java.util.Set<java.lang.String> roles)
Sets the roles for this account.
|
void |
setScreenName(java.lang.String screenName)
Sets the screen name (username alias) for this user.
|
java.lang.String |
toString() |
void |
unlock()
Unlock this user's account.
|
boolean |
verifyPassword(java.lang.String password)
Verify that the supplied password matches the password for this user.
|
private static final long serialVersionUID
private static final int IDLE_TIMEOUT_LENGTH
private static final int ABSOLUTE_TIMEOUT_LENGTH
private final transient Logger logger
long accountId
private java.lang.String accountName
private java.lang.String screenName
private java.lang.String csrfToken
private java.util.Set<java.lang.String> roles
private boolean locked
private boolean loggedIn
private boolean enabled
private java.lang.String lastHostAddress
private java.util.Date lastPasswordChangeTime
private java.util.Date lastLoginTime
private java.util.Date lastFailedLoginTime
private java.util.Date expirationTime
private transient java.util.Set<javax.servlet.http.HttpSession> sessions
private transient java.util.HashMap eventMap
private int failedLoginCount
private java.util.Locale locale
private static final int MAX_ROLE_LENGTH
public DefaultUser(java.lang.String accountName)
accountName - The name of this user's account.public void addRole(java.lang.String role)
throws AuthenticationException
addRole in interface Userrole - the role to addAuthenticationException - the authentication exceptionpublic void addRoles(java.util.Set<java.lang.String> newRoles)
throws AuthenticationException
addRoles in interface UsernewRoles - the new roles to addAuthenticationException - the authentication exceptionpublic void changePassword(java.lang.String oldPassword,
java.lang.String newPassword1,
java.lang.String newPassword2)
throws AuthenticationException,
EncryptionException
changePassword in interface UseroldPassword - the old passwordnewPassword1 - the new passwordnewPassword2 - the new password - used to verify that the new password was typed correctlyAuthenticationException - if newPassword1 does not match newPassword2, if oldPassword does not match the stored old password, or if the new password does not meet complexity requirementsEncryptionExceptionpublic long getAccountId()
getAccountId in interface Userpublic java.lang.String getAccountName()
getAccountName in interface Userpublic java.lang.String getCSRFToken()
getCSRFToken in interface Userpublic java.util.Date getExpirationTime()
getExpirationTime in interface Userpublic int getFailedLoginCount()
getFailedLoginCount in interface Uservoid setFailedLoginCount(int count)
count - the number of failed loginspublic java.util.Date getLastFailedLoginTime()
getLastFailedLoginTime in interface Userpublic java.lang.String getLastHostAddress()
getLastHostAddress in interface Userpublic java.util.Date getLastLoginTime()
getLastLoginTime in interface Userpublic java.util.Date getLastPasswordChangeTime()
getLastPasswordChangeTime in interface Userpublic java.lang.String getName()
getName in interface java.security.Principalpublic java.util.Set<java.lang.String> getRoles()
public java.lang.String getScreenName()
getScreenName in interface Userpublic void addSession(javax.servlet.http.HttpSession s)
addSession in interface Users - The session to associate with this user.public void removeSession(javax.servlet.http.HttpSession s)
removeSession in interface Users - The session to remove from being associated with this user.public java.util.Set getSessions()
getSessions in interface Userpublic void incrementFailedLoginCount()
incrementFailedLoginCount in interface Userpublic boolean isAnonymous()
isAnonymous in interface Userpublic boolean isEnabled()
public boolean isExpired()
public boolean isInRole(java.lang.String role)
public boolean isLocked()
public boolean isLoggedIn()
isLoggedIn in interface Userpublic boolean isSessionAbsoluteTimeout()
isSessionAbsoluteTimeout in interface Userpublic boolean isSessionTimeout()
isSessionTimeout in interface Userpublic void loginWithPassword(java.lang.String password)
throws AuthenticationException
loginWithPassword in interface Userpassword - the passwordAuthenticationException - if login failspublic void removeRole(java.lang.String role)
removeRole in interface Userrole - the role to removepublic java.lang.String resetCSRFToken()
resetCSRFToken in interface Userprivate void setAccountId(long accountId)
public void setAccountName(java.lang.String accountName)
setAccountName in interface UseraccountName - the new account namepublic void setExpirationTime(java.util.Date expirationTime)
setExpirationTime in interface UserexpirationTime - the new expiration timepublic void setLastFailedLoginTime(java.util.Date lastFailedLoginTime)
setLastFailedLoginTime in interface UserlastFailedLoginTime - the date and time when the user just failed to login correctly.public void setLastHostAddress(java.lang.String remoteHost)
throws AuthenticationHostException
setLastHostAddress in interface UserremoteHost - The address of the user's current source host.AuthenticationHostExceptionpublic void setLastLoginTime(java.util.Date lastLoginTime)
setLastLoginTime in interface UserlastLoginTime - the date and time when the user just successfully logged in.public void setLastPasswordChangeTime(java.util.Date lastPasswordChangeTime)
setLastPasswordChangeTime in interface UserlastPasswordChangeTime - the date and time when the user just successfully changed his/her password.public void setRoles(java.util.Set<java.lang.String> roles)
throws AuthenticationException
setRoles in interface Userroles - the new rolesAuthenticationException - the authentication exceptionpublic void setScreenName(java.lang.String screenName)
setScreenName in interface UserscreenName - the new screen namepublic java.lang.String toString()
toString in interface java.security.PrincipaltoString in class java.lang.Objectpublic boolean verifyPassword(java.lang.String password)
verifyPassword in interface Userpassword - the password that the user enteredpublic final java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in class java.lang.Objectjava.lang.CloneNotSupportedExceptionpublic java.util.Locale getLocale()
public void setLocale(java.util.Locale locale)
public java.util.HashMap getEventMap()
UsergetEventMap in interface User