use of io.vertx.proton.sasl.MechanismMismatchException in project vertx-proton by vert-x3.
the class ProtonSaslClientAuthenticatorImpl method handleSaslInit.
private void handleSaslInit() throws SaslException {
String[] remoteMechanisms = sasl.getRemoteMechanisms();
if (remoteMechanisms != null && remoteMechanisms.length != 0) {
Principal localPrincipal = null;
SSLSession sslSession = socket.sslSession();
if (sslSession != null) {
localPrincipal = sslSession.getLocalPrincipal();
}
mechanism = ProtonSaslMechanismFinderImpl.findMatchingMechanism(username, password, localPrincipal, mechanismsRestriction, remoteMechanisms);
if (mechanism != null) {
mechanism.setUsername(username);
mechanism.setPassword(password);
sasl.setMechanisms(mechanism.getName());
byte[] response = mechanism.getInitialResponse();
if (response != null) {
sasl.send(response, 0, response.length);
}
} else {
throw new MechanismMismatchException("Could not find a suitable SASL mechanism for the remote peer using the available credentials.", remoteMechanisms);
}
}
}
Aggregations