mirror of
https://github.com/hs-web/hsweb-framework.git
synced 2026-05-31 18:03:52 +08:00
优化
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user