|
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;
|
@@ -91,7 +92,7 @@ public final class AuthorizationAdvisorProxyFactory
|
91 | 92 | /**
|
92 | 93 | * The default {@link TargetVisitor}, which will proxy {@link Class} instances as well
|
93 | 94 | * as instances contained in reactive types (if reactor is present), collection types,
|
94 |
| - * and other container types like {@link Optional} |
| 95 | + * and other container types like {@link Optional} and {@link Supplier} |
95 | 96 | */
|
96 | 97 | public static final TargetVisitor DEFAULT_VISITOR = isReactivePresent
|
97 | 98 | ? new DelegateVisitor(new ClassVisitor(), new ReactiveTypeVisitor(), new ContainerTypeVisitor())
|
@@ -330,6 +331,9 @@ public Object visit(AuthorizationAdvisorProxyFactory proxyFactory, Object target
|
330 | 331 | if (target instanceof Optional<?> optional) {
|
331 | 332 | return proxyOptional(proxyFactory, optional);
|
332 | 333 | }
|
| 334 | + if (target instanceof Supplier<?> supplier) { |
| 335 | + return proxySupplier(proxyFactory, supplier); |
| 336 | + } |
333 | 337 | return null;
|
334 | 338 | }
|
335 | 339 |
|
@@ -462,6 +466,10 @@ private Optional<?> proxyOptional(AuthorizationProxyFactory proxyFactory, Option
|
462 | 466 | return optional.map(proxyFactory::proxy);
|
463 | 467 | }
|
464 | 468 |
|
| 469 | + private Supplier<?> proxySupplier(AuthorizationProxyFactory proxyFactory, Supplier<?> supplier) { |
| 470 | + return () -> proxyFactory.proxy(supplier.get()); |
| 471 | + } |
| 472 | + |
465 | 473 | }
|
466 | 474 |
|
467 | 475 | private static class ReactiveTypeVisitor implements TargetVisitor {
|
|
0 commit comments