in folsom/src/main/java/com/spotify/folsom/MemcacheClientBuilder.java [624:652]
private Authenticator getAuthenticator(Authenticator defaultValue) {
if (skipAuth) {
if (!passwords.isEmpty()) {
throw new IllegalStateException(
"You may not specify both withoutAuthenticationValidation() and withUsernamePassword()");
}
return NoAuthenticationValidation.getInstance();
}
if (passwords.isEmpty()) {
return defaultValue;
}
if (defaultValue instanceof BinaryAuthenticationValidator) {
List<PlaintextAuthenticator> authenticatorList =
passwords
.stream()
.map(UsernamePasswordPair::getPlainTextAuthenticator)
.collect(Collectors.toList());
return new MultiAuthenticator(authenticatorList);
} else if (defaultValue instanceof AsciiAuthenticationValidator) {
List<AsciiAuthenticator> authenticatorList =
passwords
.stream()
.map(UsernamePasswordPair::getAsciiAuthenticator)
.collect(Collectors.toList());
return new MultiAuthenticator(authenticatorList);
}
throw new IllegalStateException("Only ASCII and binary protocols support authentication.");
}