Class DefaultHttpSecurityExpressionHandler
- java.lang.Object
-
- org.springframework.security.access.expression.AbstractSecurityExpressionHandler<RequestAuthorizationContext>
-
- org.springframework.security.web.access.expression.DefaultHttpSecurityExpressionHandler
-
- All Implemented Interfaces:
org.springframework.aop.framework.AopInfrastructureBean,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware,SecurityExpressionHandler<RequestAuthorizationContext>
public class DefaultHttpSecurityExpressionHandler extends AbstractSecurityExpressionHandler<RequestAuthorizationContext> implements SecurityExpressionHandler<RequestAuthorizationContext>
ASecurityExpressionHandlerthat uses aRequestAuthorizationContextto create aWebSecurityExpressionRoot.- Since:
- 5.8
-
-
Constructor Summary
Constructors Constructor Description DefaultHttpSecurityExpressionHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.springframework.expression.EvaluationContextcreateEvaluationContext(java.util.function.Supplier<Authentication> authentication, RequestAuthorizationContext context)Provides an evaluation context in which to evaluate security expressions for the invocation type.protected SecurityExpressionOperationscreateSecurityExpressionRoot(Authentication authentication, RequestAuthorizationContext context)Implement in order to create a root object of the correct type for the supported invocation type.voidsetDefaultRolePrefix(java.lang.String defaultRolePrefix)Sets the default prefix to be added toSecurityExpressionRoot.hasAnyRole(String...)orSecurityExpressionRoot.hasRole(String).voidsetTrustResolver(AuthenticationTrustResolver trustResolver)Sets theAuthenticationTrustResolverto be used.-
Methods inherited from class org.springframework.security.access.expression.AbstractSecurityExpressionHandler
createEvaluationContext, createEvaluationContextInternal, getBeanResolver, getExpressionParser, getPermissionEvaluator, getRoleHierarchy, setApplicationContext, setExpressionParser, setPermissionEvaluator, setRoleHierarchy
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.springframework.security.access.expression.SecurityExpressionHandler
createEvaluationContext, getExpressionParser
-
-
-
-
Method Detail
-
createEvaluationContext
public org.springframework.expression.EvaluationContext createEvaluationContext(java.util.function.Supplier<Authentication> authentication, RequestAuthorizationContext context)
Description copied from interface:SecurityExpressionHandlerProvides an evaluation context in which to evaluate security expressions for the invocation type. You can override this method in order to provide a custom implementation that uses lazy initialization of theAuthenticationobject. By default, this method uses eager initialization of theAuthenticationobject.- Specified by:
createEvaluationContextin interfaceSecurityExpressionHandler<RequestAuthorizationContext>- Parameters:
authentication- theSupplierof theAuthenticationto usecontext- theSecurityExpressionHandlerto use- Returns:
- the
EvaluationContextto use
-
createSecurityExpressionRoot
protected SecurityExpressionOperations createSecurityExpressionRoot(Authentication authentication, RequestAuthorizationContext context)
Description copied from class:AbstractSecurityExpressionHandlerImplement in order to create a root object of the correct type for the supported invocation type.- Specified by:
createSecurityExpressionRootin classAbstractSecurityExpressionHandler<RequestAuthorizationContext>- Parameters:
authentication- the current authentication objectcontext- the invocation (filter, method, channel)- Returns:
- the object
-
setTrustResolver
public void setTrustResolver(AuthenticationTrustResolver trustResolver)
Sets theAuthenticationTrustResolverto be used. The default isAuthenticationTrustResolverImpl.- Parameters:
trustResolver- theAuthenticationTrustResolverto use
-
setDefaultRolePrefix
public void setDefaultRolePrefix(java.lang.String defaultRolePrefix)
Sets the default prefix to be added toSecurityExpressionRoot.hasAnyRole(String...)orSecurityExpressionRoot.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).- Parameters:
defaultRolePrefix- the default prefix to add to roles. The default is "ROLE_".
-
-