![JAR search and dependency download from the Maven repository](/logo.png)
org.lognet.springboot.grpc.security.AuthenticationSchemeService Maven / Gradle / Ivy
// Generated by delombok at Wed Sep 27 05:27:18 UTC 2023
package org.lognet.springboot.grpc.security;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.springframework.security.core.Authentication;
class AuthenticationSchemeService
implements AuthenticationSchemeRegistry, AuthenticationSchemeSelector {
@java.lang.SuppressWarnings("all")
private static final org.slf4j.Logger log =
org.slf4j.LoggerFactory.getLogger(AuthenticationSchemeService.class);
private List selectors = new ArrayList<>();
@Override
public Optional getAuthScheme(CharSequence authorization) {
final List auth =
selectors.stream()
.map(selector -> selector.getAuthScheme(authorization))
.filter(Optional::isPresent)
.map(Optional::get)
.toList();
switch (auth.size()) {
case 0:
log.error(
String.format(
"Authentication scheme \'%s\' is not supported.",
Optional.ofNullable(authorization)
.map(s -> s.toString().split(" ", 2)[0])
.orElse(null)));
return Optional.empty();
case 1:
return Optional.of(auth.get(0));
default:
throw new IllegalStateException(
"Ambiguous authentication scheme " + authorization.toString());
}
}
@Override
public AuthenticationSchemeRegistry register(AuthenticationSchemeSelector selector) {
selectors.add(selector);
return this;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy