@Named(value="user") public class CurrentUser extends Object
CurrentUser class.
Constructor and Description |
---|
CurrentUser() |
Modifier and Type | Method and Description |
---|---|
Collection<? extends org.springframework.security.core.GrantedAuthority> |
getAuthorities()
Returns the authorities granted to the user.
|
String |
getEmail()
Returns the user's email
|
String |
getFirstName()
Returns the user's first name
|
String |
getFullName()
Returns the user's fullname
|
String |
getGravatarUrl(int size,
boolean https)
Computes the gravatar URL associated to the user email
|
String |
getLastName()
Returns the user's last name
|
String |
getPassword()
Returns the password used to authenticate the user.
|
String |
getUsername()
Returns the username used to authenticate the user.
|
boolean |
hasRole(String role)
Simple searches for an exactly matching
GrantedAuthority.getAuthority() . |
boolean |
isAccountNonExpired()
Indicates whether the user's account has expired.
|
boolean |
isAccountNonLocked()
Indicates whether the user is locked or unlocked.
|
boolean |
isAdmin()
Checks if the current user has the application ADMIN role.
|
boolean |
isAnonymous()
Checks if the current user is anonymous.
|
boolean |
isAuthenticated()
Is the user authenticated ?
|
boolean |
isCredentialsNonExpired()
Indicates whether the user's credentials (password) has expired.
|
boolean |
isEnabled()
Indicates whether the user is enabled or disabled.
|
boolean |
isUser()
Checks if the current user has the application USER role.
|
String |
toString()
Returns a string representation of the object.
|
public Collection<? extends org.springframework.security.core.GrantedAuthority> getAuthorities()
null
.null
)public String getPassword()
public boolean isAccountNonExpired()
true
if the user's account is valid (ie non-expired), false
if no longer valid
(ie expired)public boolean isAccountNonLocked()
true
if the user is not locked, false
otherwisepublic boolean isCredentialsNonExpired()
true
if the user's credentials are valid (ie non-expired), false
if no longer
valid (ie expired)public boolean isEnabled()
true
if the user is enabled, false
otherwisepublic boolean isAuthenticated()
public String getUsername()
null
.null
)public boolean hasRole(String role)
GrantedAuthority.getAuthority()
.
Will always return false if the SecurityContextHolder contains an Authentication with nullprincipal and/or GrantedAuthority[] objects.role
- the GrantedAuthorityString representation to check forpublic boolean isAnonymous()
public boolean isUser()
public boolean isAdmin()
public String getGravatarUrl(int size, boolean https) throws NoSuchAlgorithmException
size
- The size (width) of the image to generatehttps
- If the URL must be in HTTPs or noNoSuchAlgorithmException
- If MD5 Algorithm isn't availablepublic String toString()
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Copyright © 2011–2016 eXo Platform SAS. All rights reserved.