Class User

java.lang.Object
com.jk.webstack.security.User
All Implemented Interfaces:
Serializable, org.springframework.security.core.userdetails.UserDetails

@Entity public class User extends Object implements org.springframework.security.core.userdetails.UserDetails, Serializable
This entity class represents a user in the application.

This class implements the UserDetails interface, providing user-related information for authentication and authorization purposes.

Version:
1.0
Author:
Dr. Jalal H. Kiswani
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static User
    This method creates a new User.
    firstname(String firstname)
    This method sets the user first name to the provided value.
    Collection<? extends org.springframework.security.core.GrantedAuthority>
    Returns the authorities granted to the user.
    Returns the user name 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.
    lastname(String lastname)
    This method sets the user last name to the provided value.
    username(String username)
    This method sets the user name to the provided value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.security.core.userdetails.UserDetails

    getPassword
  • Constructor Details

    • User

      public User()
  • Method Details

    • create

      public static User create()
      This method creates a new User.
      Returns:
      the newly created user.
    • username

      public User username(String username)
      This method sets the user name to the provided value.
      Parameters:
      username - Specifies the new user name.
      Returns:
      the edited user instance.
    • firstname

      public User firstname(String firstname)
      This method sets the user first name to the provided value.
      Parameters:
      firstname - Specifies the new user first name.
      Returns:
      the edited user instance.
    • lastname

      public User lastname(String lastname)
      This method sets the user last name to the provided value.
      Parameters:
      lastname - Specifies the new user last name.
      Returns:
      the edited user instance.
    • 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:
      the authorities, sorted by natural key.
    • getUsername

      public String getUsername()
      Returns the user name used to authenticate the user.
      Specified by:
      getUsername in interface org.springframework.security.core.userdetails.UserDetails
      Returns:
      the user name.
    • isAccountNonExpired

      public boolean isAccountNonExpired()
      Indicates whether the user's account has expired.

      An expired account cannot be authenticated.

      Specified by:
      isAccountNonExpired in interface org.springframework.security.core.userdetails.UserDetails
      Returns:
      true if the user's account is valid (non-expired), false if no longer valid (expired).
    • isAccountNonLocked

      public boolean isAccountNonLocked()
      Indicates whether the user is locked or unlocked.

      A locked user cannot be authenticated.

      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.

      Expired credentials prevent authentication.

      Specified by:
      isCredentialsNonExpired in interface org.springframework.security.core.userdetails.UserDetails
      Returns:
      true if the user's credentials are valid (non-expired), false if no longer valid (expired)
    • isEnabled

      public boolean isEnabled()
      Indicates whether the user is enabled or disabled.

      A disabled user cannot be authenticated.

      Specified by:
      isEnabled in interface org.springframework.security.core.userdetails.UserDetails
      Returns:
      true if the user is enabled, false otherwise.