in folsom/src/main/java/com/spotify/folsom/authenticate/PlaintextAuthenticator.java [37:58]
public CompletionStage<RawMemcacheClient> authenticate(final RawMemcacheClient client) {
final PlaintextAuthenticateRequest authenticateRequest =
new PlaintextAuthenticateRequest(username, password);
return client
.connectFuture()
.thenCompose(
ignored ->
client
.send(authenticateRequest)
.thenApply(
status -> {
if (status == MemcacheStatus.OK) {
return client;
} else if (status == MemcacheStatus.UNAUTHORIZED) {
throw new MemcacheAuthenticationException("Authentication failed");
} else {
throw new RuntimeException("Unexpected status: " + status.name());
}
}));
}