Spring Security Framework

org.springframework.security.userdetails
Class User

java.lang.Object
  extended by org.springframework.security.userdetails.User
All Implemented Interfaces:
Serializable, UserDetails

public class User
extends Object
implements UserDetails

Models core user information retieved by an UserDetailsService.

Implemented with value object semantics (immutable after construction, like a String). Developers may use this class directly, subclass it, or write their own UserDetails implementation from scratch.

Version:
$Id$
Author:
Ben Alex
See Also:
Serialized Form

Constructor Summary
User(String username, String password, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked, GrantedAuthority[] authorities)
          Construct the User with the details required by DaoAuthenticationProvider.
User(String username, String password, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, GrantedAuthority[] authorities)
          Deprecated. use new constructor with extended properties (this constructor will be removed from release 1.0.0)
User(String username, String password, boolean enabled, GrantedAuthority[] authorities)
          Deprecated. use new constructor with extended properties (this constructor will be removed from release 1.0.0)
 
Method Summary
 boolean equals(Object rhs)
           
 GrantedAuthority[] getAuthorities()
          Returns the authorities granted to the user.
 String getPassword()
          Returns the password used to authenticate the user.
 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.
protected  void setAuthorities(GrantedAuthority[] authorities)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

User

public User(String username,
            String password,
            boolean enabled,
            GrantedAuthority[] authorities)
     throws IllegalArgumentException
Deprecated. use new constructor with extended properties (this constructor will be removed from release 1.0.0)

Construct the User with the details required by DaoAuthenticationProvider.

Parameters:
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
authorities - the authorities that should be granted to the caller if they presented the correct username and password and the user is enabled
Throws:
IllegalArgumentException - if a null value was passed either as a parameter or as an element in the GrantedAuthority[] array

User

public User(String username,
            String password,
            boolean enabled,
            boolean accountNonExpired,
            boolean credentialsNonExpired,
            GrantedAuthority[] authorities)
     throws IllegalArgumentException
Deprecated. use new constructor with extended properties (this constructor will be removed from release 1.0.0)

Construct the User with the details required by DaoAuthenticationProvider.

Parameters:
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
authorities - the authorities that should be granted to the caller if they presented the correct username and password and the user is enabled
Throws:
IllegalArgumentException - if a null value was passed either as a parameter or as an element in the GrantedAuthority[] array

User

public User(String username,
            String password,
            boolean enabled,
            boolean accountNonExpired,
            boolean credentialsNonExpired,
            boolean accountNonLocked,
            GrantedAuthority[] authorities)
     throws IllegalArgumentException
Construct the User with the details required by DaoAuthenticationProvider.

Parameters:
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
Throws:
IllegalArgumentException - if a null value was passed either as a parameter or as an element in the GrantedAuthority[] array
Method Detail

equals

public boolean equals(Object rhs)
Overrides:
equals in class Object

getAuthorities

public GrantedAuthority[] getAuthorities()
Description copied from interface: UserDetails
Returns the authorities granted to the user. Cannot return null.

Specified by:
getAuthorities in interface UserDetails
Returns:
the authorities, sorted by natural key (never null)

getPassword

public String getPassword()
Description copied from interface: UserDetails
Returns the password used to authenticate the user. Cannot return null.

Specified by:
getPassword in interface UserDetails
Returns:
the password (never null)

getUsername

public String getUsername()
Description copied from interface: UserDetails
Returns the username used to authenticate the user. Cannot return null.

Specified by:
getUsername in interface UserDetails
Returns:
the username (never null)

hashCode

public int hashCode()
Overrides:
hashCode in class Object

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 interface UserDetails
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 interface UserDetails
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 interface UserDetails
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 interface UserDetails
Returns:
true if the user is enabled, false otherwise

setAuthorities

protected void setAuthorities(GrantedAuthority[] authorities)

toString

public String toString()
Overrides:
toString in class Object

Spring Security Framework

Copyright © 2004-2010 SpringSource, Inc. All Rights Reserved.