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.booleanIndicates whether the user's account has expired.booleanIndicates whether the user is locked or unlocked.booleanIndicates whether the user's credentials (password) has expired.booleanIndicates whether the user is enabled or disabled.voidsetAddress(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:
getAuthoritiesin interfaceorg.springframework.security.core.userdetails.UserDetails- Returns:
- a collection of granted authorities
-
getPassword
Returns the password used to authenticate the user.- Specified by:
getPasswordin 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:
getUsernamein interfaceorg.springframework.security.core.userdetails.UserDetails- Returns:
- user's login
-
isAccountNonExpired
public boolean isAccountNonExpired()Indicates whether the user's account has expired.- Specified by:
isAccountNonExpiredin interfaceorg.springframework.security.core.userdetails.UserDetails- Returns:
trueif the account is non-expired,falseotherwise
-
isAccountNonLocked
public boolean isAccountNonLocked()Indicates whether the user is locked or unlocked.- Specified by:
isAccountNonLockedin interfaceorg.springframework.security.core.userdetails.UserDetails- Returns:
trueif the user is not locked,falseotherwise
-
isCredentialsNonExpired
public boolean isCredentialsNonExpired()Indicates whether the user's credentials (password) has expired.- Specified by:
isCredentialsNonExpiredin interfaceorg.springframework.security.core.userdetails.UserDetails- Returns:
trueif credentials are valid,falseotherwise
-
isEnabled
public boolean isEnabled()Indicates whether the user is enabled or disabled.- Specified by:
isEnabledin interfaceorg.springframework.security.core.userdetails.UserDetails- Returns:
trueif the user is active,falseotherwise
-
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
-