public class SecurityServiceImpl extends Object implements SecurityService
SecurityService
Constructor and Description |
---|
SecurityServiceImpl() |
Modifier and Type | Method and Description |
---|---|
org.apache.shiro.subject.Subject |
getSubject() |
boolean |
hasAllPermissions(String permissions) |
boolean |
hasAllRoles(String roles) |
boolean |
hasAnyPermissions(String permissions) |
boolean |
hasAnyRoles(String roles)
Return true if the current user has any of the roles specified.
|
boolean |
hasPermission(String permission) |
boolean |
hasRole(String role) |
<T> T |
invokeWithSecurityDisabled(Callable<T> callable)
Temporarily disable security before invocation of Callable.
|
boolean |
isAuthenticated()
Return true only if the current user has executed a successful authentication attempt
during their current session.
|
boolean |
isGuest()
Return true if the current user is not known to the system, either because they
haven't logged in yet, or because they have no 'RememberMe' identity.
|
boolean |
isLacksPermission(String permission) |
boolean |
isLacksRole(String role) |
boolean |
isNotAuthenticated()
Return true only if the current user has not executed a successful authentication
attempt during their current session.
|
boolean |
isUser()
Return true if the current user known to the system, either from a successful login attempt
(not necessarily during the current session) or from 'RememberMe' services.
|
public SecurityServiceImpl()
public org.apache.shiro.subject.Subject getSubject()
getSubject
in interface SecurityService
public boolean isAuthenticated()
SecurityService
This is more restrictive than the SecurityService.isUser()
, which only
ensures the current user is known to the system, either via a current login or from Remember Me services,
which only makes the assumption that the current user is who they say they are, and does not guarantee it like
this method does.
isAuthenticated
in interface SecurityService
public boolean isNotAuthenticated()
SecurityService
The logically opposite tag of this one is the SecurityService.isAuthenticated()
.
isNotAuthenticated
in interface SecurityService
public boolean isUser()
SecurityService
Note: This is less restrictive than the SecurityService.isAuthenticated()
since it only assumes
the user is who they say they are, either via a current session login or via Remember Me services, which
makes no guarantee the user is who they say they are. The SecurityService.isAuthenticated()
however
guarantees that the current user has logged in during their current session, proving they really are
who they say they are.
The logically opposite method of this one is the SecurityService.isGuest()
.
isUser
in interface SecurityService
public boolean isGuest()
SecurityService
The logically opposite method of this one is the SecurityService.isUser()
. Please read that class's JavaDoc as it explains
more about the differences between Authenticated/Unauthenticated and User/Guest semantic differences.
isGuest
in interface SecurityService
public boolean hasAnyRoles(String roles)
SecurityService
hasAnyRoles
in interface SecurityService
public boolean hasAllRoles(String roles)
hasAllRoles
in interface SecurityService
public boolean hasAllPermissions(String permissions)
hasAllPermissions
in interface SecurityService
public boolean hasAnyPermissions(String permissions)
hasAnyPermissions
in interface SecurityService
public boolean hasPermission(String permission)
hasPermission
in interface SecurityService
public boolean hasRole(String role)
hasRole
in interface SecurityService
public boolean isLacksPermission(String permission)
isLacksPermission
in interface SecurityService
public boolean isLacksRole(String role)
isLacksRole
in interface SecurityService
public <T> T invokeWithSecurityDisabled(Callable<T> callable) throws Exception
SecurityService
invokeWithSecurityDisabled
in interface SecurityService
callable
- A callable that will be invoked with security disabledException
Copyright © 2004–2015. All rights reserved.