Class User
java.lang.Object
com.fiap.tech_challenge.parte1.ms_users.entities.User
- All Implemented Interfaces:
Serializable
,org.springframework.security.core.userdetails.UserDetails
public class User
extends Object
implements org.springframework.security.core.userdetails.UserDetails
Represents a user entity with authentication and authorization details.
Implements
UserDetails
to integrate with Spring Security.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns whether the user is currently active.Returns the list of addresses associated with the user.Collection<? extends org.springframework.security.core.GrantedAuthority>
Returns the authorities granted to the user.Returns the date when the user information was last changed.getEmail()
Returns the user's email address.getId()
Returns the unique identifier of the user.getLogin()
Returns the login username.Returns the user's primary address.getName()
Returns the full name of the user.Returns the password used to authenticate the user.getRole()
Returns the role assigned to the user.Returns the username used to authenticate the user.boolean
Indicates whether the user's account has expired.boolean
Indicates whether the user is locked or unlocked.boolean
Indicates whether the user's credentials (password) has expired.boolean
Indicates whether the user is enabled or disabled.void
setAddress
(List<Address> address) Sets the addresses of the user.
-
Constructor Details
-
User
Constructs a new User with specified details.- Parameters:
name
- the user's full nameemail
- the user's email addresslogin
- the login usernamepassword
- the password (hashed)role
- the role assigned to the user
-
User
public User()Default constructor for frameworks.
-
-
Method Details
-
getId
Returns the unique identifier of the user.- Returns:
- the user's UUID
-
getName
Returns the full name of the user.- Returns:
- user's name
-
getEmail
Returns the user's email address.- Returns:
- user's email
-
getLogin
Returns the login username.- Returns:
- user's login
-
getAuthorities
Returns the authorities granted to the user.- Specified by:
getAuthorities
in interfaceorg.springframework.security.core.userdetails.UserDetails
- Returns:
- a collection of granted authorities
-
getPassword
Returns the password used to authenticate the user.- Specified by:
getPassword
in interfaceorg.springframework.security.core.userdetails.UserDetails
- Returns:
- user's password (hashed)
-
getUsername
Returns the username used to authenticate the user. Here it returns the login.- Specified by:
getUsername
in interfaceorg.springframework.security.core.userdetails.UserDetails
- Returns:
- user's login
-
isAccountNonExpired
public boolean isAccountNonExpired()Indicates whether the user's account has expired.- Specified by:
isAccountNonExpired
in interfaceorg.springframework.security.core.userdetails.UserDetails
- Returns:
true
if the account is non-expired,false
otherwise
-
isAccountNonLocked
public boolean isAccountNonLocked()Indicates whether the user is locked or unlocked.- Specified by:
isAccountNonLocked
in interfaceorg.springframework.security.core.userdetails.UserDetails
- Returns:
true
if the user is not locked,false
otherwise
-
isCredentialsNonExpired
public boolean isCredentialsNonExpired()Indicates whether the user's credentials (password) has expired.- Specified by:
isCredentialsNonExpired
in interfaceorg.springframework.security.core.userdetails.UserDetails
- Returns:
true
if credentials are valid,false
otherwise
-
isEnabled
public boolean isEnabled()Indicates whether the user is enabled or disabled.- Specified by:
isEnabled
in interfaceorg.springframework.security.core.userdetails.UserDetails
- Returns:
true
if the user is active,false
otherwise
-
getDateLastChange
Returns the date when the user information was last changed.- Returns:
- date of last change
-
getMainAddress
Returns the user's primary address.- Returns:
- the main address
- Throws:
IndexOutOfBoundsException
- if the user has no addresses
-
getActive
Returns whether the user is currently active.- Returns:
- true if active, false otherwise
-
getRole
Returns the role assigned to the user.- Returns:
- user's role
-
getAddresses
Returns the list of addresses associated with the user.- Returns:
- list of addresses
-
setAddress
Sets the addresses of the user.- Parameters:
address
- list of addresses to set
-