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 Details

    • User

      public User(String name, String email, String login, String password, Role role)
      Constructs a new User with specified details.
      Parameters:
      name - the user's full name
      email - the user's email address
      login - the login username
      password - the password (hashed)
      role - the role assigned to the user
    • User

      public User()
      Default constructor for frameworks.
  • Method Details

    • getId

      public UUID getId()
      Returns the unique identifier of the user.
      Returns:
      the user's UUID
    • getName

      public String getName()
      Returns the full name of the user.
      Returns:
      user's name
    • getEmail

      public String getEmail()
      Returns the user's email address.
      Returns:
      user's email
    • getLogin

      public String getLogin()
      Returns the login username.
      Returns:
      user's login
    • getAuthorities

      public Collection<? extends org.springframework.security.core.GrantedAuthority> getAuthorities()
      Returns the authorities granted to the user.
      Specified by:
      getAuthorities in interface org.springframework.security.core.userdetails.UserDetails
      Returns:
      a collection of granted authorities
    • getPassword

      public String getPassword()
      Returns the password used to authenticate the user.
      Specified by:
      getPassword in interface org.springframework.security.core.userdetails.UserDetails
      Returns:
      user's password (hashed)
    • getUsername

      public String getUsername()
      Returns the username used to authenticate the user. Here it returns the login.
      Specified by:
      getUsername in interface org.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 interface org.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 interface org.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 interface org.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 interface org.springframework.security.core.userdetails.UserDetails
      Returns:
      true if the user is active, false otherwise
    • getDateLastChange

      public Date getDateLastChange()
      Returns the date when the user information was last changed.
      Returns:
      date of last change
    • getMainAddress

      public Address getMainAddress()
      Returns the user's primary address.
      Returns:
      the main address
      Throws:
      IndexOutOfBoundsException - if the user has no addresses
    • getActive

      public Boolean getActive()
      Returns whether the user is currently active.
      Returns:
      true if active, false otherwise
    • getRole

      public Role getRole()
      Returns the role assigned to the user.
      Returns:
      user's role
    • getAddresses

      public List<Address> getAddresses()
      Returns the list of addresses associated with the user.
      Returns:
      list of addresses
    • setAddress

      public void setAddress(List<Address> address)
      Sets the addresses of the user.
      Parameters:
      address - list of addresses to set