def _on_auth(self, response, connection, address): if response.is_success(): response = client_authentication_codec.decode_response( response.result()) status = response["status"] if status == _AuthenticationStatus.AUTHENTICATED: return self._handle_successful_auth(response, connection, address) if status == _AuthenticationStatus.CREDENTIALS_FAILED: err = AuthenticationError( "Authentication failed. The configured cluster name on " "the client does not match the one configured in the cluster." ) elif status == _AuthenticationStatus.NOT_ALLOWED_IN_CLUSTER: err = ClientNotAllowedInClusterError( "Client is not allowed in the cluster") elif status == _AuthenticationStatus.SERIALIZATION_VERSION_MISMATCH: err = IllegalStateError( "Server serialization version does not match to client") else: err = AuthenticationError( "Authentication status code not supported. status: %s" % status) connection.close("Failed to authenticate connection", err) raise err else: e = response.exception() # This will set the exception for the pending connection future connection.close("Failed to authenticate connection", e) six.reraise(e.__class__, e, response.traceback())
def _on_auth(self, response, connection): try: response = client_authentication_codec.decode_response( response.result()) except Exception as err: connection.close("Failed to authenticate connection", err) raise err status = response["status"] if status == _AuthenticationStatus.AUTHENTICATED: return self._handle_successful_auth(response, connection) if status == _AuthenticationStatus.CREDENTIALS_FAILED: err = AuthenticationError( "Authentication failed. Check cluster name and credentials.") elif status == _AuthenticationStatus.NOT_ALLOWED_IN_CLUSTER: err = ClientNotAllowedInClusterError( "Client is not allowed in the cluster") elif status == _AuthenticationStatus.SERIALIZATION_VERSION_MISMATCH: err = IllegalStateError( "Server serialization version does not match to client") else: err = AuthenticationError( "Authentication status code not supported. status: %s" % status) connection.close("Failed to authenticate connection", err) raise err