java.lang.Object | |
↳ | org.springframework.security.core.userdetails.User |
Models core user information retrieved by a UserDetailsService
.
Developers may use this class directly, subclass it, or write their own UserDetails
implementation from
scratch.
equals
and hashcode
implementations are based on the username
property only, as the
intention is that lookups of the same user principal object (in a user registry, for example) will match
where the objects represent the same user, not just when all the properties (authorities, password for
example) are the same.
Note that this implementation is not immutable. It implements the CredentialsContainer
interface, in order
to allow the password to be erased after authentication. This may cause side-effects if you are storing instances
in-memory and reusing them. If so, make sure you return a copy from your UserDetailsService
each time it is
invoked.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Calls the more complex constructor with all boolean arguments set to
true . | |||||||||||
Construct the
User with the details required by
DaoAuthenticationProvider . |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns
true if the supplied object is a User instance with the
same username value. | |||||||||||
Returns the authorities granted to the user.
| |||||||||||
Returns the password used to authenticate the user.
| |||||||||||
Returns the username used to authenticate the user.
| |||||||||||
Returns the hashcode of the
username . | |||||||||||
Indicates whether the user's account has expired.
| |||||||||||
Indicates whether the user is locked or unlocked.
| |||||||||||
Indicates whether the user's credentials (password) has expired.
| |||||||||||
Indicates whether the user is enabled or disabled.
| |||||||||||
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() |
Calls the more complex constructor with all boolean arguments set to true
.
Construct the User
with the details required by
DaoAuthenticationProvider
.
username | the username presented to the
DaoAuthenticationProvider |
---|---|
password | the password that should be presented to the
DaoAuthenticationProvider |
enabled | set to true if the user is enabled |
accountNonExpired | set to true if the account has not
expired |
credentialsNonExpired | set to true if the credentials
have not expired |
accountNonLocked | set to true if the account is not
locked |
authorities | the authorities that should be granted to the caller if they presented the correct username and password and the user is enabled. Not null. |
IllegalArgumentException | if a null value was passed
either as a parameter or as an element in the
GrantedAuthority collection
|
---|
Returns true
if the supplied object is a User
instance with the
same username
value.
In other words, the objects are equal if they have the same username, representing the same principal.
Returns the authorities granted to the user. Cannot return null
.
null
)
Returns the password used to authenticate the user. Cannot return null
.
null
)
Returns the username used to authenticate the user. Cannot return null
.
null
)
Returns the hashcode of the username
.
Indicates whether the user's account has expired. An expired account cannot be authenticated.
true
if the user's account is valid (ie non-expired), false
if no longer valid
(ie expired)
Indicates whether the user is locked or unlocked. A locked user cannot be authenticated.
true
if the user is not locked, false
otherwise
Indicates whether the user's credentials (password) has expired. Expired credentials prevent authentication.
true
if the user's credentials are valid (ie non-expired), false
if no longer
valid (ie expired)
Indicates whether the user is enabled or disabled. A disabled user cannot be authenticated.
true
if the user is enabled, false
otherwise