Class LdapUserDetailsImpl
- java.lang.Object
-
- org.springframework.security.ldap.userdetails.LdapUserDetailsImpl
-
- All Implemented Interfaces:
java.io.Serializable
,CredentialsContainer
,UserDetails
,PasswordPolicyData
,LdapUserDetails
- Direct Known Subclasses:
Person
public class LdapUserDetailsImpl extends java.lang.Object implements LdapUserDetails, PasswordPolicyData
A UserDetails implementation which is used internally by the Ldap services. It also contains the user's distinguished name and a set of attributes that have been retrieved from the Ldap server.An instance may be created as the result of a search, or when user information is retrieved during authentication.
An instance of this class will be used by the LdapAuthenticationProvider to construct the final user details object that it returns.
The
equals
andhashcode
methods are implemented using theDn
property and do not consider additional state, so it is not possible two store two instances with the same DN in the same set, or use them as keys in a map.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LdapUserDetailsImpl.Essence
Variation of essence pattern.
-
Constructor Summary
Constructors Modifier Constructor Description protected
LdapUserDetailsImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
void
eraseCredentials()
java.util.Collection<GrantedAuthority>
getAuthorities()
Returns the authorities granted to the user.java.lang.String
getDn()
The DN of the entry for this user's account.int
getGraceLoginsRemaining()
java.lang.String
getPassword()
Returns the password used to authenticate the user.int
getTimeBeforeExpiration()
java.lang.String
getUsername()
Returns the username used to authenticate the user.int
hashCode()
boolean
isAccountNonExpired()
Indicates whether the user's account has expired.boolean
isAccountNonLocked()
Indicates whether the user is locked or unlocked.boolean
isCredentialsNonExpired()
Indicates whether the user's credentials (password) has expired.boolean
isEnabled()
Indicates whether the user is enabled or disabled.java.lang.String
toString()
-
-
-
Method Detail
-
getAuthorities
public java.util.Collection<GrantedAuthority> getAuthorities()
Description copied from interface:UserDetails
Returns the authorities granted to the user. Cannot returnnull
.- Specified by:
getAuthorities
in interfaceUserDetails
- Returns:
- the authorities, sorted by natural key (never
null
)
-
getDn
public java.lang.String getDn()
Description copied from interface:LdapUserDetails
The DN of the entry for this user's account.- Specified by:
getDn
in interfaceLdapUserDetails
- Returns:
- the user's DN
-
getPassword
public java.lang.String getPassword()
Description copied from interface:UserDetails
Returns the password used to authenticate the user.- Specified by:
getPassword
in interfaceUserDetails
- Returns:
- the password
-
getUsername
public java.lang.String getUsername()
Description copied from interface:UserDetails
Returns the username used to authenticate the user. Cannot returnnull
.- Specified by:
getUsername
in interfaceUserDetails
- Returns:
- the username (never
null
)
-
isAccountNonExpired
public boolean isAccountNonExpired()
Description copied from interface:UserDetails
Indicates whether the user's account has expired. An expired account cannot be authenticated.- Specified by:
isAccountNonExpired
in interfaceUserDetails
- Returns:
true
if the user's account is valid (ie non-expired),false
if no longer valid (ie expired)
-
isAccountNonLocked
public boolean isAccountNonLocked()
Description copied from interface:UserDetails
Indicates whether the user is locked or unlocked. A locked user cannot be authenticated.- Specified by:
isAccountNonLocked
in interfaceUserDetails
- Returns:
true
if the user is not locked,false
otherwise
-
isCredentialsNonExpired
public boolean isCredentialsNonExpired()
Description copied from interface:UserDetails
Indicates whether the user's credentials (password) has expired. Expired credentials prevent authentication.- Specified by:
isCredentialsNonExpired
in interfaceUserDetails
- Returns:
true
if the user's credentials are valid (ie non-expired),false
if no longer valid (ie expired)
-
isEnabled
public boolean isEnabled()
Description copied from interface:UserDetails
Indicates whether the user is enabled or disabled. A disabled user cannot be authenticated.- Specified by:
isEnabled
in interfaceUserDetails
- Returns:
true
if the user is enabled,false
otherwise
-
eraseCredentials
public void eraseCredentials()
- Specified by:
eraseCredentials
in interfaceCredentialsContainer
-
getTimeBeforeExpiration
public int getTimeBeforeExpiration()
- Specified by:
getTimeBeforeExpiration
in interfacePasswordPolicyData
-
getGraceLoginsRemaining
public int getGraceLoginsRemaining()
- Specified by:
getGraceLoginsRemaining
in interfacePasswordPolicyData
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-