Example #1
0
    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
Example #3
0
 def callback(f):
     parameters = client_authentication_codec.decode_response(f.result())
     if parameters["status"] != 0:
         raise AuthenticationError("Authentication failed.")
     connection.endpoint = parameters["address"]
     self.owner_uuid = parameters["owner_uuid"]
     self.uuid = parameters["uuid"]
     return connection
Example #4
0
 def callback(f):
     parameters = client_authentication_codec.decode_response(f.result())
     if parameters["status"] != 0:
         raise AuthenticationError("Authentication failed.")
     connection.endpoint = parameters["address"]
     self.owner_uuid = parameters["owner_uuid"]
     self.uuid = parameters["uuid"]
     connection.server_version_str = parameters.get("server_hazelcast_version", "")
     connection.server_version = calculate_version(connection.server_version_str)
     return connection
Example #5
0
 def authenticate_manager(conn):
     request = client_authentication_codec.encode_request(
         username=self._config.username, password=self._config.password,
         uuid=None, owner_uuid=None, is_owner_connection=True, client_type=CLIENT_TYPE,
         serialization_version=SERIALIZATION_VERSION)
     response = self._client.invoker.invoke_on_connection(request, conn).result()
     parameters = client_authentication_codec.decode_response(response)
     if parameters["status"] != 0:
         raise RuntimeError("Authentication failed")
     conn.endpoint = parameters["address"]
     self.owner_uuid = parameters["owner_uuid"]
     self.uuid = parameters["uuid"]
    def _cluster_authenticator(self, conn):
        uuid = self._client.cluster.uuid
        owner_uuid = self._client.cluster.owner_uuid

        request = client_authentication_codec.encode_request(
            username=self._client.config.username,
            password=self._client.config.password,
            uuid=uuid,
            owner_uuid=owner_uuid,
            is_owner_connection=False,
            client_type="PHY",
            serialization_version=1)

        response = self._client.invoker.invoke_on_connection(request, conn).result()
        parameters = client_authentication_codec.decode_response(response)
        if parameters["status"] != 0:
            raise RuntimeError("Authentication failed")
        conn.endpoint = parameters["address"]
        self.owner_uuid = parameters["owner_uuid"]
        self.uuid = parameters["uuid"]
        pass