Class AbstractSecurityExpressionHandler<T>
java.lang.Object
org.springframework.security.access.expression.AbstractSecurityExpressionHandler<T>
- All Implemented Interfaces:
- org.springframework.aop.framework.AopInfrastructureBean,- org.springframework.beans.factory.Aware,- org.springframework.context.ApplicationContextAware,- SecurityExpressionHandler<T>
- Direct Known Subclasses:
- DefaultHttpSecurityExpressionHandler,- DefaultMessageSecurityExpressionHandler,- DefaultMethodSecurityExpressionHandler,- DefaultWebSecurityExpressionHandler
public abstract class AbstractSecurityExpressionHandler<T>
extends Object
implements SecurityExpressionHandler<T>, org.springframework.context.ApplicationContextAware
Base implementation of the facade which isolates Spring Security's requirements for
 evaluating security expressions from the implementation of the underlying expression
 objects.
- Since:
- 3.1
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionfinal org.springframework.expression.EvaluationContextcreateEvaluationContext(@Nullable Authentication authentication, T invocation) Invokes the internal template methods to createStandardEvaluationContextandSecurityExpressionRootobjects.protected org.springframework.expression.spel.support.StandardEvaluationContextcreateEvaluationContextInternal(@Nullable Authentication authentication, T invocation) Override to create a custom instance ofStandardEvaluationContext.protected abstract SecurityExpressionOperationscreateSecurityExpressionRoot(@Nullable Authentication authentication, T invocation) Implement in order to create a root object of the correct type for the supported invocation type.protected final AuthorizationManagerFactory<T>protected @Nullable org.springframework.expression.BeanResolverprotected final DefaultAuthorizationManagerFactory<T>Deprecated.final org.springframework.expression.ExpressionParserprotected PermissionEvaluatorprotected @Nullable RoleHierarchyDeprecated.UsegetDefaultAuthorizationManagerFactory()insteadvoidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext) final voidsetAuthorizationManagerFactory(AuthorizationManagerFactory<T> authorizationManagerFactory) Sets theAuthorizationManagerFactoryto be used.final voidsetExpressionParser(org.springframework.expression.ExpressionParser expressionParser) voidsetPermissionEvaluator(PermissionEvaluator permissionEvaluator) voidsetRoleHierarchy(@Nullable RoleHierarchy roleHierarchy) Deprecated.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.security.access.expression.SecurityExpressionHandlercreateEvaluationContext
- 
Constructor Details- 
AbstractSecurityExpressionHandlerpublic AbstractSecurityExpressionHandler()
 
- 
- 
Method Details- 
getExpressionParserpublic final org.springframework.expression.ExpressionParser getExpressionParser()- Specified by:
- getExpressionParserin interface- SecurityExpressionHandler<T>
- Returns:
- an expression parser for the expressions used by the implementation.
 
- 
setExpressionParserpublic final void setExpressionParser(org.springframework.expression.ExpressionParser expressionParser) 
- 
createEvaluationContextpublic final org.springframework.expression.EvaluationContext createEvaluationContext(@Nullable Authentication authentication, T invocation) Invokes the internal template methods to createStandardEvaluationContextandSecurityExpressionRootobjects.- Specified by:
- createEvaluationContextin interface- SecurityExpressionHandler<T>
- Parameters:
- authentication- the current authentication object
- invocation- the invocation (filter, method, channel)
- Returns:
- the context object for use in evaluating the expression, populated with a suitable root object.
 
- 
createEvaluationContextInternalprotected org.springframework.expression.spel.support.StandardEvaluationContext createEvaluationContextInternal(@Nullable Authentication authentication, T invocation) Override to create a custom instance ofStandardEvaluationContext.The returned object will have a SecurityExpressionRootPropertyAccessoradded, allowing beans in theApplicationContextto be accessed via expression properties.- Parameters:
- authentication- the current authentication object
- invocation- the invocation (filter, method, channel)
- Returns:
- A StandardEvaluationContextor potentially a custom subclass if overridden.
 
- 
createSecurityExpressionRootprotected abstract SecurityExpressionOperations createSecurityExpressionRoot(@Nullable Authentication authentication, T invocation) Implement in order to create a root object of the correct type for the supported invocation type.- Parameters:
- authentication- the current authentication object
- invocation- the invocation (filter, method, channel)
- Returns:
- the object
 
- 
setAuthorizationManagerFactorypublic final void setAuthorizationManagerFactory(AuthorizationManagerFactory<T> authorizationManagerFactory) Sets theAuthorizationManagerFactoryto be used. The default isDefaultAuthorizationManagerFactory.- Parameters:
- authorizationManagerFactory- the- AuthorizationManagerFactoryto use. Cannot be null.
- Since:
- 7.0
 
- 
getAuthorizationManagerFactory
- 
getDefaultAuthorizationManagerFactory@Deprecated(since="7.0") protected final DefaultAuthorizationManagerFactory<T> getDefaultAuthorizationManagerFactory()Deprecated.Allows accessing theDefaultAuthorizationManagerFactoryfor getting and setting defaults. This method will be removed in Spring Security 8.- Returns:
- the DefaultAuthorizationManagerFactory
- Throws:
- IllegalStateException- if a different- AuthorizationManagerFactorywas already set
 
- 
getRoleHierarchyDeprecated.UsegetDefaultAuthorizationManagerFactory()instead
- 
setRoleHierarchyDeprecated.
- 
getPermissionEvaluator
- 
setPermissionEvaluator
- 
getBeanResolverprotected @Nullable org.springframework.expression.BeanResolver getBeanResolver()
- 
setApplicationContextpublic void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) - Specified by:
- setApplicationContextin interface- org.springframework.context.ApplicationContextAware
 
 
- 
setAuthorizationManagerFactory(AuthorizationManagerFactory)instead