Interface ServerAuthReplyHandler

All Superinterfaces:
ServerReplyHandler

public interface ServerAuthReplyHandler extends ServerReplyHandler
Handler for AUTH command responses during SASL authentication.

This handler receives responses during SASL authentication, which may involve multiple challenge-response rounds depending on the mechanism.

Single-round mechanisms (e.g., PLAIN):


 byte[] credentials = buildPlainCredentials(user, pass);
 auth.auth("PLAIN", credentials, new ServerAuthReplyHandler() {
     public void handleAuthSuccess(ClientTransactionState transaction) {
         transaction.stat(statHandler);
     }
     // ...
 });
 

Multi-round mechanisms (e.g., LOGIN):


 auth.auth("LOGIN", null, new ServerAuthReplyHandler() {
     private boolean sentUsername = false;

     public void handleChallenge(byte[] challenge,
                                 ClientAuthExchange exchange) {
         if (!sentUsername) {
             exchange.respond(username.getBytes(), this);
             sentUsername = true;
         } else {
             exchange.respond(password.getBytes(), this);
         }
     }
     // ...
 });
 
Author:
Chris Burdess
See Also:
  • Method Details

    • handleAuthSuccess

      void handleAuthSuccess(ClientTransactionState transaction)
      Called when authentication succeeds (+OK).
      Parameters:
      transaction - operations available in the TRANSACTION state
    • handleChallenge

      void handleChallenge(byte[] challenge, ClientAuthExchange exchange)
      Called when the server sends a SASL challenge ("+ " continuation).

      The handler should compute the appropriate response based on the SASL mechanism and call exchange.respond() to continue, or exchange.abort() to cancel.

      Parameters:
      challenge - the decoded challenge bytes (base64 decoded)
      exchange - operations to continue the exchange
    • handleAuthFailed

      void handleAuthFailed(ClientAuthorizationState auth, String message)
      Called when authentication fails (-ERR).

      The handler can retry with different credentials or try a different mechanism.

      Parameters:
      auth - operations to retry in the AUTHORIZATION state
      message - the server's error message