This commit is contained in:
zhouhao
2022-04-01 17:29:08 +08:00
parent 377c480e9e
commit 838e66ef96

View File

@@ -51,12 +51,16 @@ public final class AuthenticationHolder {
private static final ReadWriteLock lock = new ReentrantReadWriteLock();
private static Optional<Authentication> get(Function<AuthenticationSupplier, Optional<Authentication>> function) {
if (suppliers.size() == 1) {
int size = suppliers.size();
if (size == 0) {
return Optional.empty();
}
if (size == 1) {
return suppliers.get(0).get();
}
SimpleAuthentication merge = new SimpleAuthentication();
for (AuthenticationSupplier supplier : suppliers) {
supplier.get().ifPresent(merge::merge);
function.apply(supplier).ifPresent(merge::merge);
}
if (merge.getUser() == null) {
return Optional.empty();