public CompletionStage authenticate()

in folsom/src/main/java/com/spotify/folsom/authenticate/AsciiAuthenticator.java [38:59]


  public CompletionStage<RawMemcacheClient> authenticate(final RawMemcacheClient client) {

    final AsciiAuthenticateRequest asciiAuthenticateRequest =
        new AsciiAuthenticateRequest(username, password);

    return client
        .connectFuture()
        .thenCompose(
            ignored ->
                client
                    .send(asciiAuthenticateRequest)
                    .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());
                          }
                        }));
  }