|
@@ -51,14 +51,17 @@ public final class AuthenticationHolder {
|
|
|
private static final ReadWriteLock lock = new ReentrantReadWriteLock();
|
|
|
|
|
|
private static Optional<Authentication> get(Function<AuthenticationSupplier, Optional<Authentication>> function) {
|
|
|
-
|
|
|
- return Flux.fromStream(suppliers.stream().map(function))
|
|
|
- .filter(Optional::isPresent)
|
|
|
- .map(Optional::get)
|
|
|
- .reduceWith(SimpleAuthentication::new, SimpleAuthentication::merge)
|
|
|
- .filter(auth->auth.getUser()!=null)
|
|
|
- .map(Authentication.class::cast)
|
|
|
- .blockOptional();
|
|
|
+ if (suppliers.size() == 1) {
|
|
|
+ return suppliers.get(0).get();
|
|
|
+ }
|
|
|
+ SimpleAuthentication merge = new SimpleAuthentication();
|
|
|
+ for (AuthenticationSupplier supplier : suppliers) {
|
|
|
+ supplier.get().ifPresent(merge::merge);
|
|
|
+ }
|
|
|
+ if (merge.getUser() == null) {
|
|
|
+ return Optional.empty();
|
|
|
+ }
|
|
|
+ return Optional.of(merge);
|
|
|
}
|
|
|
|
|
|
/**
|