MethodSecurityExpressionHandler class final

The engine behind method security: it parses the expressions of the security annotations and evaluates them for each call.

The auto-configuration builds it from the optional RoleHierarchy, PermissionEvaluator, GrantedAuthorityDefaults and SecurityExpressionContextCustomizer beans, so applications change its behaviour by declaring those. Declare your own bean of this type only to replace all of it.

Spring (Java): DefaultMethodSecurityExpressionHandler.

Constructors

MethodSecurityExpressionHandler({BeanIntrospector? introspector, BeanFactory? beanFactory, AuthenticationTrustResolver trustResolver = const AuthenticationTrustResolverImpl(), RoleHierarchy roleHierarchy = const NullRoleHierarchy(), PermissionEvaluator permissionEvaluator = const DenyAllPermissionEvaluator(), String defaultRolePrefix = 'ROLE_', List<SecurityExpressionContextCustomizer> customizers = const []})
A handler. introspector makes the application's classes (the arguments) readable in expressions, and beanFactory resolves @bean references; without them, those parts of an expression fail.

Properties

beanFactory → BeanFactory?
Resolves @bean references in expressions; null makes them fail.
final
customizers → List<SecurityExpressionContextCustomizer>
Run on every evaluation context, in order.
final
defaultRolePrefix → String
The prefix hasRole adds; ROLE_ by default.
final
hashCode → int
The hash code for this object.
no setterinherited
introspector → BeanIntrospector?
Makes the application's classes readable in expressions; null leaves only the security types readable.
final
permissionEvaluator → PermissionEvaluator
Answers hasPermission(...).
final
roleHierarchy → RoleHierarchy
Adds the authorities implied by the user's roles.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
trustResolver → AuthenticationTrustResolver
Tells anonymous users from real logins.
final

Methods

createEvaluationContext(MethodSecurityExpressionRoot root, MethodSignature signature, List<Object?> args) → StandardEvaluationContext
A new evaluation context for root in which the arguments args of signature are variables: by name (#order) and by position (#p0, #a0). The customizers have run on it.
createRoot(Authentication? authentication(), {Object? target}) → MethodSecurityExpressionRoot
A new root object for one call on target; authentication is called only when an expression needs the user.
evaluate(String text, StandardEvaluationContext context) → bool
Evaluates the expression text in context and returns its bool.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
parse(String text) → Expression
The parsed expression text, cached after the first call.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited