Package com.jgcomptech.tools.authc
Class UserAccount
- java.lang.Object
-
- com.jgcomptech.tools.authc.UserAccount
-
- All Implemented Interfaces:
Account
,AuthenticationInfo
,AuthorizationInfo
,java.io.Serializable
public class UserAccount extends java.lang.Object implements Account
An object representing a user account.- Since:
- 1.4.0, 1.5.0 made class immutable
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description UserAccount(java.lang.String username, java.time.LocalDateTime creationDate, boolean locked, boolean hasPasswordExpiration, java.time.LocalDateTime passwordExpirationDate)
Maps a user in the database to a object.UserAccount(java.lang.String username, java.time.LocalDateTime creationDate, boolean locked, boolean hasPasswordExpiration, java.time.LocalDateTime passwordExpirationDate, java.util.Set<java.lang.String> roles)
Maps a user in the database to a object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.time.LocalDateTime
getCreationDate()
Returns the date and time the Account was initially created.java.time.LocalDateTime
getPasswordExpirationDate()
Returns the expiration date of the current password.java.util.Collection<java.lang.String>
getRoles()
Returns the Account's assigned roles.java.lang.String
getUsername()
Returns the username.boolean
hasPasswordExpiration()
Returnstrue
if a password expiration date is set.boolean
isLocked()
Returnstrue
if this Account is locked and thus cannot be used to login.boolean
isPasswordExpired()
Returns whether or not the Account's password is expired.
-
-
-
Constructor Detail
-
UserAccount
public UserAccount(java.lang.String username, java.time.LocalDateTime creationDate, boolean locked, boolean hasPasswordExpiration, java.time.LocalDateTime passwordExpirationDate)
Maps a user in the database to a object.- Parameters:
username
- the usernamecreationDate
- the date and time that the user was createdlocked
- if the account is lockedhasPasswordExpiration
- if the password is set to expirepasswordExpirationDate
- the date the password is set to expire
-
UserAccount
public UserAccount(java.lang.String username, java.time.LocalDateTime creationDate, boolean locked, boolean hasPasswordExpiration, java.time.LocalDateTime passwordExpirationDate, java.util.Set<java.lang.String> roles)
Maps a user in the database to a object.- Parameters:
username
- the usernamecreationDate
- the date and time that the user was createdlocked
- specifies if the account is lockedhasPasswordExpiration
- specifies if the password has an expiration datepasswordExpirationDate
- the password expiration dateroles
- the user roles to add
-
-
Method Detail
-
getUsername
public java.lang.String getUsername()
Returns the username.- Specified by:
getUsername
in interfaceAuthenticationInfo
- Returns:
- the username
-
getRoles
public java.util.Collection<java.lang.String> getRoles()
Returns the Account's assigned roles.- Specified by:
getRoles
in interfaceAuthorizationInfo
- Returns:
- the Account's assigned roles
-
isLocked
public boolean isLocked()
Returnstrue
if this Account is locked and thus cannot be used to login.- Specified by:
isLocked
in interfaceAuthenticationInfo
- Returns:
true
if this Account is locked and thus cannot be used to login
-
isPasswordExpired
public boolean isPasswordExpired()
Returns whether or not the Account's password is expired. This usually indicates that the password would need to changed before the account could be used.- Specified by:
isPasswordExpired
in interfaceAuthenticationInfo
- Returns:
- whether or not the Account's credentials are expired
- Since:
- 1.5.0 changed implementation
-
getCreationDate
public java.time.LocalDateTime getCreationDate()
Returns the date and time the Account was initially created.- Specified by:
getCreationDate
in interfaceAuthenticationInfo
- Returns:
- the date and time the Account was initially created
- Since:
- 1.5.0
-
getPasswordExpirationDate
public java.time.LocalDateTime getPasswordExpirationDate()
Returns the expiration date of the current password.- Specified by:
getPasswordExpirationDate
in interfaceAuthenticationInfo
- Returns:
- the expiration date of the current password
- Since:
- 1.5.0
-
hasPasswordExpiration
public boolean hasPasswordExpiration()
Returnstrue
if a password expiration date is set.- Specified by:
hasPasswordExpiration
in interfaceAuthenticationInfo
- Returns:
true
if a password expiration date is set.- Since:
- 1.5.0
-
-