|
34 | 34 | import java.util.SortedSet;
|
35 | 35 | import java.util.TreeMap;
|
36 | 36 | import java.util.TreeSet;
|
| 37 | +import java.util.function.Supplier; |
37 | 38 | import java.util.stream.Stream;
|
38 | 39 |
|
39 | 40 | import reactor.core.publisher.Flux;
|
@@ -90,7 +91,7 @@ public final class AuthorizationAdvisorProxyFactory
|
90 | 91 | /**
|
91 | 92 | * The default {@link TargetVisitor}, which will proxy {@link Class} instances as well
|
92 | 93 | * as instances contained in reactive types (if reactor is present), collection types,
|
93 |
| - * and other container types like {@link Optional} |
| 94 | + * and other container types like {@link Optional} and {@link Supplier} |
94 | 95 | */
|
95 | 96 | public static final TargetVisitor DEFAULT_VISITOR = isReactivePresent
|
96 | 97 | ? new DelegateVisitor(new ClassVisitor(), new ReactiveTypeVisitor(), new ContainerTypeVisitor())
|
@@ -328,6 +329,9 @@ public Object visit(AuthorizationAdvisorProxyFactory proxyFactory, Object target
|
328 | 329 | if (target instanceof Optional<?> optional) {
|
329 | 330 | return proxyOptional(proxyFactory, optional);
|
330 | 331 | }
|
| 332 | + if (target instanceof Supplier<?> supplier) { |
| 333 | + return proxySupplier(proxyFactory, supplier); |
| 334 | + } |
331 | 335 | return null;
|
332 | 336 | }
|
333 | 337 |
|
@@ -460,6 +464,10 @@ private Optional<?> proxyOptional(AuthorizationProxyFactory proxyFactory, Option
|
460 | 464 | return optional.map(proxyFactory::proxy);
|
461 | 465 | }
|
462 | 466 |
|
| 467 | + private Supplier<?> proxySupplier(AuthorizationProxyFactory proxyFactory, Supplier<?> supplier) { |
| 468 | + return () -> proxyFactory.proxy(supplier.get()); |
| 469 | + } |
| 470 | + |
463 | 471 | }
|
464 | 472 |
|
465 | 473 | private static class ReactiveTypeVisitor implements TargetVisitor {
|
|
0 commit comments