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.LocalDateTimegetCreationDate()Returns the date and time the Account was initially created.java.time.LocalDateTimegetPasswordExpirationDate()Returns the expiration date of the current password.java.util.Collection<java.lang.String>getRoles()Returns the Account's assigned roles.java.lang.StringgetUsername()Returns the username.booleanhasPasswordExpiration()Returnstrueif a password expiration date is set.booleanisLocked()Returnstrueif this Account is locked and thus cannot be used to login.booleanisPasswordExpired()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:
getUsernamein interfaceAuthenticationInfo- Returns:
- the username
-
getRoles
public java.util.Collection<java.lang.String> getRoles()
Returns the Account's assigned roles.- Specified by:
getRolesin interfaceAuthorizationInfo- Returns:
- the Account's assigned roles
-
isLocked
public boolean isLocked()
Returnstrueif this Account is locked and thus cannot be used to login.- Specified by:
isLockedin interfaceAuthenticationInfo- Returns:
trueif 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:
isPasswordExpiredin 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:
getCreationDatein 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:
getPasswordExpirationDatein interfaceAuthenticationInfo- Returns:
- the expiration date of the current password
- Since:
- 1.5.0
-
hasPasswordExpiration
public boolean hasPasswordExpiration()
Returnstrueif a password expiration date is set.- Specified by:
hasPasswordExpirationin interfaceAuthenticationInfo- Returns:
trueif a password expiration date is set.- Since:
- 1.5.0
-
-