use of com.rabbitmq.stream.AuthenticationFailureException in project rabbitmq-stream-java-client by rabbitmq.
the class Client method authenticate.
private void authenticate() {
List<String> saslMechanisms = getSaslMechanisms();
SaslMechanism saslMechanism = this.saslConfiguration.getSaslMechanism(saslMechanisms);
byte[] challenge = null;
boolean authDone = false;
while (!authDone) {
byte[] saslResponse = saslMechanism.handleChallenge(challenge, this.credentialsProvider);
SaslAuthenticateResponse saslAuthenticateResponse = sendSaslAuthenticate(saslMechanism, saslResponse);
if (saslAuthenticateResponse.isOk()) {
authDone = true;
} else if (saslAuthenticateResponse.isChallenge()) {
challenge = saslAuthenticateResponse.challenge;
} else if (saslAuthenticateResponse.isAuthenticationFailure()) {
throw new AuthenticationFailureException("Unexpected response code during authentication: " + formatConstant(saslAuthenticateResponse.getResponseCode()));
} else {
throw new StreamException("Unexpected response code during authentication: " + formatConstant(saslAuthenticateResponse.getResponseCode()));
}
}
}
Aggregations