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.
introspectormakes the application's classes (the arguments) readable in expressions, andbeanFactoryresolves@beanreferences; without them, those parts of an expression fail.
Properties
- beanFactory → BeanFactory?
-
Resolves
@beanreferences in expressions;nullmakes them fail.final -
customizers
→ List<
SecurityExpressionContextCustomizer> -
Run on every evaluation context, in order.
final
- defaultRolePrefix → String
-
The prefix
hasRoleadds;ROLE_by default.final - hashCode → int
-
The hash code for this object.
no setterinherited
- introspector → BeanIntrospector?
-
Makes the application's classes readable in expressions;
nullleaves 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
rootin which the argumentsargsofsignatureare 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;authenticationis called only when an expression needs the user. -
evaluate(
String text, StandardEvaluationContext context) → bool -
Evaluates the expression
textincontextand returns itsbool. -
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