Package com.jk.webstack.security
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic User
create()
This method creates a newUser
.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.This method sets the user last name to the provided value.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
This method creates a newUser
.- Returns:
- the newly created user.
-
username
This method sets the user name to the provided value.- Parameters:
username
- Specifies the new user name.- Returns:
- the edited user instance.
-
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
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
Returns the authorities granted to the user.- Specified by:
getAuthorities
in interfaceorg.springframework.security.core.userdetails.UserDetails
- Returns:
- the authorities, sorted by natural key.
-
getUsername
Returns the user name used to authenticate the user.- Specified by:
getUsername
in interfaceorg.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 interfaceorg.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 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.Expired credentials prevent authentication.
- Specified by:
isCredentialsNonExpired
in interfaceorg.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 interfaceorg.springframework.security.core.userdetails.UserDetails
- Returns:
true
if the user is enabled,false
otherwise.
-