Package com.alpaca.entity
Class User
java.lang.Object
com.alpaca.entity.User
Represents a User entity in the system. This entity is mapped to the "users" table in the
database and stores authentication and authorization details. It includes information about
roles, entity status, and authentication settings.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
Indicates whether the User's entity is not expired.private boolean
Indicates whether the User's entity is not locked.private Advertiser
The Advertiser entity associated with the User.private boolean
Indicates whether the User's credentials are not expired.private String
The User's email address.private boolean
Indicates whether the User's email has been verified.private boolean
Indicates whether the User's entity is enabled.private boolean
Indicates whether the User has connected their account to Google.private UUID
Unique identifier for the User.private String
The User's encrypted password.private Profile
The Profile entity associated with the User.Indicates the set of Role has the User. -
Constructor Summary
ConstructorsConstructorDescriptionUser
(String email, String password, boolean enabled, boolean accountNoExpired, boolean accountNoLocked, boolean credentialNoExpired, boolean emailVerified, boolean googleConnected, Set<Role> roles) Constructs an instance of a new User object with the specified attributes.Constructs an instance of a new User object with the specified attributes. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Set
<org.springframework.security.core.authority.SimpleGrantedAuthority> Retrieves the authorities granted to the User based on their assigned roles.getRoles()
Retrieves the list of roles assigned to the User.int
hashCode()
boolean
Determines whether the user account is allowed to be used based on its status.rolesToUserRoles
(Collection<Role> roles) void
setUserRoles
(Collection<Role> roles)
-
Field Details
-
id
Unique identifier for the User. This value is automatically generated using a UUID strategy. -
email
The User's email address. This field is unique and cannot be null. -
password
The User's encrypted password. This field cannot be null. -
enabled
private boolean enabledIndicates whether the User's entity is enabled. Defaults totrue
. -
accountNoExpired
private boolean accountNoExpiredIndicates whether the User's entity is not expired. Defaults totrue
. -
accountNoLocked
private boolean accountNoLockedIndicates whether the User's entity is not locked. Defaults totrue
. -
credentialNoExpired
private boolean credentialNoExpiredIndicates whether the User's credentials are not expired. Defaults totrue
. -
emailVerified
private boolean emailVerifiedIndicates whether the User's email has been verified. Defaults tofalse
. -
googleConnected
private boolean googleConnectedIndicates whether the User has connected their account to Google. Defaults tofalse
. -
userRoles
-
profile
The Profile entity associated with the User.A User has a one-to-one relationship with a
Profile
. -
advertiser
The Advertiser entity associated with the User.A User has a one-to-one relationship with an
Advertiser
.
-
-
Constructor Details
-
User
Constructs an instance of a new User object with the specified attributes. The generated object is ready to be used by default.- Parameters:
email
- the User's email - must not be nullpassword
- the User's encrypted password - must not be nullroles
- Set of Roles assigned to the User
-
User
public User(String email, String password, boolean enabled, boolean accountNoExpired, boolean accountNoLocked, boolean credentialNoExpired, boolean emailVerified, boolean googleConnected, Set<Role> roles) Constructs an instance of a new User object with the specified attributes. The generated object is ready to be used and stored in the database.- Parameters:
email
- the User's email - must not be nullpassword
- the User's encrypted password - must not be nullenabled
- indicates whether the entity is enabledaccountNoExpired
- indicates whether the entity is not expiredaccountNoLocked
- indicates whether the entity is not lockedcredentialNoExpired
- indicates whether the credentials are not expiredemailVerified
- indicates whether the email has been verifiedgoogleConnected
- indicates whether the User has connected with Googleroles
- Set of Roles assigned to the User
-
-
Method Details
-
setUserRoles
-
rolesToUserRoles
-
getRoles
Retrieves the list of roles assigned to the User.- Returns:
- a List of
Role
objects representing the User's roles.
-
getAuthorities
Retrieves the authorities granted to the User based on their assigned roles. Each role is prefixed with "ROLE_" as per Spring Security conventions.- Returns:
- Set of
SimpleGrantedAuthority
representing the User's permissions.
-
isAllowUser
public boolean isAllowUser()Determines whether the user account is allowed to be used based on its status.This method checks multiple conditions to determine if the account is active and can be used for authentication. A user account is considered allowed if:
- The account is enabled.
- The account is not expired.
- The account is not locked.
- The credentials are not expired.
- Returns:
true
if the account meets all the conditions to be considered active;false
otherwise.
-
equals
-
hashCode
public int hashCode()
-