public abstract class SecurityExpressionRoot extends java.lang.Object implements SecurityExpressionOperations
| Modifier and Type | Field and Description |
|---|---|
java.lang.String |
admin |
protected Authentication |
authentication |
java.lang.String |
create |
java.lang.String |
delete |
boolean |
denyAll
Allows "denyAll" expression
|
boolean |
permitAll
Allows "permitAll" expression
|
java.lang.String |
read |
java.lang.String |
write |
| Constructor and Description |
|---|
SecurityExpressionRoot(Authentication authentication)
Creates a new instance
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
denyAll()
Always denies access
|
Authentication |
getAuthentication()
Gets the
Authentication used for evaluating the expressions |
java.lang.Object |
getPrincipal()
Convenience method to access
Authentication.getPrincipal() from
getAuthentication() |
boolean |
hasAnyAuthority(java.lang.String... authorities)
Determines if the
SecurityExpressionOperations.getAuthentication() has any of the specified authorities
within Authentication.getAuthorities(). |
boolean |
hasAnyRole(java.lang.String... roles)
Determines if the
SecurityExpressionOperations.getAuthentication() has any of the specified authorities
within Authentication.getAuthorities(). |
boolean |
hasAuthority(java.lang.String authority)
Determines if the
SecurityExpressionOperations.getAuthentication() has a particular authority within
Authentication.getAuthorities(). |
boolean |
hasPermission(java.lang.Object target,
java.lang.Object permission)
Determines if the
SecurityExpressionOperations.getAuthentication() has permission to access the target
given the permission |
boolean |
hasPermission(java.lang.Object targetId,
java.lang.String targetType,
java.lang.Object permission)
Determines if the
SecurityExpressionOperations.getAuthentication() has permission to access the domain
object with a given id, type, and permission. |
boolean |
hasRole(java.lang.String role)
Determines if the
SecurityExpressionOperations.getAuthentication() has a particular authority within
Authentication.getAuthorities(). |
boolean |
isAnonymous()
Determines if the
SecurityExpressionOperations.getAuthentication() is anonymous |
boolean |
isAuthenticated()
Determines ifthe
SecurityExpressionOperations.getAuthentication() is authenticated |
boolean |
isFullyAuthenticated()
Determines if the
SecurityExpressionOperations.getAuthentication() authenticated without the use of
remember me |
boolean |
isRememberMe()
Determines if the
SecurityExpressionOperations.getAuthentication() was authenticated using remember me |
boolean |
permitAll()
Always grants access.
|
void |
setDefaultRolePrefix(java.lang.String defaultRolePrefix)
Sets the default prefix to be added to
hasAnyRole(String...) or
hasRole(String). |
void |
setPermissionEvaluator(PermissionEvaluator permissionEvaluator) |
void |
setRoleHierarchy(RoleHierarchy roleHierarchy) |
void |
setTrustResolver(AuthenticationTrustResolver trustResolver) |
protected final Authentication authentication
public final boolean permitAll
public final boolean denyAll
public final java.lang.String read
public final java.lang.String write
public final java.lang.String create
public final java.lang.String delete
public final java.lang.String admin
public SecurityExpressionRoot(Authentication authentication)
authentication - the Authentication to use. Cannot be null.public final boolean hasAuthority(java.lang.String authority)
SecurityExpressionOperationsSecurityExpressionOperations.getAuthentication() has a particular authority within
Authentication.getAuthorities().hasAuthority in interface SecurityExpressionOperationsauthority - the authority to test (i.e. "ROLE_USER")public final boolean hasAnyAuthority(java.lang.String... authorities)
SecurityExpressionOperationsSecurityExpressionOperations.getAuthentication() has any of the specified authorities
within Authentication.getAuthorities().hasAnyAuthority in interface SecurityExpressionOperationsauthorities - the authorities to test (i.e. "ROLE_USER", "ROLE_ADMIN")public final boolean hasRole(java.lang.String role)
SecurityExpressionOperations
Determines if the SecurityExpressionOperations.getAuthentication() has a particular authority within
Authentication.getAuthorities().
This is similar to SecurityExpressionOperations.hasAuthority(String) except that this method implies
that the String passed in is a role. For example, if "USER" is passed in the
implementation may convert it to use "ROLE_USER" instead. The way in which the role
is converted may depend on the implementation settings.
hasRole in interface SecurityExpressionOperationsrole - the authority to test (i.e. "USER")public final boolean hasAnyRole(java.lang.String... roles)
SecurityExpressionOperations
Determines if the SecurityExpressionOperations.getAuthentication() has any of the specified authorities
within Authentication.getAuthorities().
This is a similar to hasAnyAuthority except that this method implies that the String passed in is a role. For example, if "USER" is passed in the implementation may convert it to use "ROLE_USER" instead. The way in which the role is converted may depend on the implementation settings.
hasAnyRole in interface SecurityExpressionOperationsroles - the authorities to test (i.e. "USER", "ADMIN")public final Authentication getAuthentication()
SecurityExpressionOperationsAuthentication used for evaluating the expressionsgetAuthentication in interface SecurityExpressionOperationsAuthentication for evaluating the expressionspublic final boolean permitAll()
SecurityExpressionOperationspermitAll in interface SecurityExpressionOperationspublic final boolean denyAll()
SecurityExpressionOperationsdenyAll in interface SecurityExpressionOperationspublic final boolean isAnonymous()
SecurityExpressionOperationsSecurityExpressionOperations.getAuthentication() is anonymousisAnonymous in interface SecurityExpressionOperationspublic final boolean isAuthenticated()
SecurityExpressionOperationsSecurityExpressionOperations.getAuthentication() is authenticatedisAuthenticated in interface SecurityExpressionOperationsSecurityExpressionOperations.getAuthentication() is authenticated, else falsepublic final boolean isRememberMe()
SecurityExpressionOperationsSecurityExpressionOperations.getAuthentication() was authenticated using remember meisRememberMe in interface SecurityExpressionOperationsSecurityExpressionOperations.getAuthentication() authenticated using remember me,
else falsepublic final boolean isFullyAuthenticated()
SecurityExpressionOperationsSecurityExpressionOperations.getAuthentication() authenticated without the use of
remember meisFullyAuthenticated in interface SecurityExpressionOperationsSecurityExpressionOperations.getAuthentication() authenticated without the use of
remember me, else falsepublic java.lang.Object getPrincipal()
Authentication.getPrincipal() from
getAuthentication()public void setTrustResolver(AuthenticationTrustResolver trustResolver)
public void setRoleHierarchy(RoleHierarchy roleHierarchy)
public void setDefaultRolePrefix(java.lang.String defaultRolePrefix)
Sets the default prefix to be added to hasAnyRole(String...) or
hasRole(String). For example, if hasRole("ADMIN") or hasRole("ROLE_ADMIN")
is passed in, then the role ROLE_ADMIN will be used when the defaultRolePrefix is
"ROLE_" (default).
If null or empty, then no default role prefix is used.
defaultRolePrefix - the default prefix to add to roles. Default "ROLE_".public boolean hasPermission(java.lang.Object target,
java.lang.Object permission)
SecurityExpressionOperationsSecurityExpressionOperations.getAuthentication() has permission to access the target
given the permissionhasPermission in interface SecurityExpressionOperationstarget - the target domain object to check permission onpermission - the permission to check on the domain object (i.e. "read",
"write", etc).SecurityExpressionOperations.getAuthentication(), else
falsepublic boolean hasPermission(java.lang.Object targetId,
java.lang.String targetType,
java.lang.Object permission)
SecurityExpressionOperationsSecurityExpressionOperations.getAuthentication() has permission to access the domain
object with a given id, type, and permission.hasPermission in interface SecurityExpressionOperationstargetId - the identifier of the domain object to determine accesstargetType - the type (i.e. com.example.domain.Message)permission - the perission to check on the domain object (i.e. "read",
"write", etc)SecurityExpressionOperations.getAuthentication(), else
falsepublic void setPermissionEvaluator(PermissionEvaluator permissionEvaluator)