Interface ServerAuthReplyHandler
- All Superinterfaces:
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);
}
}
// ...
});
-
Method Summary
Modifier and TypeMethodDescriptionvoidhandleAuthFailed(ClientAuthorizationState auth, String message) Called when authentication fails (-ERR).voidhandleAuthSuccess(ClientTransactionState transaction) Called when authentication succeeds (+OK).voidhandleChallenge(byte[] challenge, ClientAuthExchange exchange) Called when the server sends a SASL challenge ("+ " continuation).Methods inherited from interface org.bluezoo.gumdrop.pop3.client.handler.ServerReplyHandler
handleServiceClosing
-
Method Details
-
handleAuthSuccess
Called when authentication succeeds (+OK).- Parameters:
transaction- operations available in the TRANSACTION state
-
handleChallenge
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, orexchange.abort()to cancel.- Parameters:
challenge- the decoded challenge bytes (base64 decoded)exchange- operations to continue the exchange
-
handleAuthFailed
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 statemessage- the server's error message
-