|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2024 the original author or authors. |
| 2 | + * Copyright 2002-2025 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
16 | 16 |
|
17 | 17 | package org.springframework.security.config.annotation.method.configuration;
|
18 | 18 |
|
| 19 | +import java.util.Optional; |
| 20 | + |
19 | 21 | import org.aopalliance.intercept.MethodInterceptor;
|
20 | 22 | import org.aopalliance.intercept.MethodInvocation;
|
21 | 23 |
|
@@ -83,15 +85,16 @@ final class ReactiveAuthorizationManagerMethodSecurityConfiguration
|
83 | 85 |
|
84 | 86 | private final AuthorizationManagerAfterReactiveMethodInterceptor postAuthorizeMethodInterceptor;
|
85 | 87 |
|
86 |
| - @Autowired(required = false) |
87 |
| - ReactiveAuthorizationManagerMethodSecurityConfiguration(MethodSecurityExpressionHandler expressionHandler, |
| 88 | + @Autowired |
| 89 | + ReactiveAuthorizationManagerMethodSecurityConfiguration(Optional<MethodSecurityExpressionHandler> expressionHandler, |
88 | 90 | ObjectProvider<ObjectPostProcessor<ReactiveAuthorizationManager<MethodInvocation>>> preAuthorizePostProcessor,
|
89 | 91 | ObjectProvider<ObjectPostProcessor<ReactiveAuthorizationManager<MethodInvocationResult>>> postAuthorizePostProcessor) {
|
90 |
| - if (expressionHandler != null) { |
91 |
| - this.preFilterMethodInterceptor = new PreFilterAuthorizationReactiveMethodInterceptor(expressionHandler); |
92 |
| - this.preAuthorizeAuthorizationManager = new PreAuthorizeReactiveAuthorizationManager(expressionHandler); |
93 |
| - this.postFilterMethodInterceptor = new PostFilterAuthorizationReactiveMethodInterceptor(expressionHandler); |
94 |
| - this.postAuthorizeAuthorizationManager = new PostAuthorizeReactiveAuthorizationManager(expressionHandler); |
| 92 | + if (expressionHandler.isPresent()) { |
| 93 | + final MethodSecurityExpressionHandler handler = expressionHandler.get(); |
| 94 | + this.preFilterMethodInterceptor = new PreFilterAuthorizationReactiveMethodInterceptor(handler); |
| 95 | + this.preAuthorizeAuthorizationManager = new PreAuthorizeReactiveAuthorizationManager(handler); |
| 96 | + this.postFilterMethodInterceptor = new PostFilterAuthorizationReactiveMethodInterceptor(handler); |
| 97 | + this.postAuthorizeAuthorizationManager = new PostAuthorizeReactiveAuthorizationManager(handler); |
95 | 98 | }
|
96 | 99 | ReactiveAuthorizationManager<MethodInvocation> preAuthorize = preAuthorizePostProcessor
|
97 | 100 | .getIfUnique(ObjectPostProcessor::identity)
|
|
0 commit comments