return new UnsupportedProtocolVersionException(address, triedVersion);
}
private void authenticateV1(Authenticator authenticator) throws ConnectionException, BusyConnectionException, ExecutionException, InterruptedException {
if (!(authenticator instanceof ProtocolV1Authenticator))
throw new AuthenticationException(address, String.format("Cannot use authenticator %s with protocol version 1, "
+ "only plain text authentication is supported with this protocol version", authenticator));
Requests.Credentials creds = new Requests.Credentials(((ProtocolV1Authenticator)authenticator).getCredentials());
Message.Response authResponse = write(creds).get();
switch (authResponse.type) {
case READY:
break;
case ERROR:
throw new AuthenticationException(address, ((Responses.Error)authResponse).message);
default:
throw defunct(new TransportException(address, String.format("Unexpected %s response message from server to a CREDENTIALS message", authResponse.type)));
}
}