Search in sources :

Example 1 with GridClientAuthenticationException

use of org.apache.ignite.internal.client.GridClientAuthenticationException in project ignite by apache.

the class GridClientNioTcpConnection method handleClientResponse.

/**
     * Handler responses addressed to this client.
     *
     * @param fut Response future.
     * @param resp Response.
     */
@SuppressWarnings("unchecked")
private void handleClientResponse(TcpClientFuture fut, GridClientResponse resp) {
    if (resp.sessionToken() != null)
        sesTok = resp.sessionToken();
    GridClientMessage src = fut.pendingMessage();
    switch(fut.retryState()) {
        case TcpClientFuture.STATE_INITIAL:
            {
                if (resp.successStatus() == GridClientResponse.STATUS_AUTH_FAILURE) {
                    if (credentials() == null) {
                        fut.onDone(new GridClientAuthenticationException("Authentication failed on server " + "(client has no credentials) [clientId=" + clientId + ", srvAddr=" + serverAddress() + ", errMsg=" + resp.errorMessage() + ']'));
                        return;
                    }
                    fut.retryState(TcpClientFuture.STATE_AUTH_RETRY);
                    GridClientAuthenticationRequest req = buildAuthRequest();
                    req.requestId(resp.requestId());
                    ses.send(req);
                    return;
                }
                break;
            }
        case TcpClientFuture.STATE_AUTH_RETRY:
            {
                if (resp.successStatus() == GridClientResponse.STATUS_SUCCESS) {
                    fut.retryState(TcpClientFuture.STATE_REQUEST_RETRY);
                    src.sessionToken(sesTok);
                    ses.send(src);
                    return;
                }
                break;
            }
    }
    removePending(resp.requestId());
    if (resp.successStatus() == GridClientResponse.STATUS_AUTH_FAILURE)
        fut.onDone(new GridClientAuthenticationException("Client authentication failed [clientId=" + clientId + ", srvAddr=" + serverAddress() + ", errMsg=" + resp.errorMessage() + ']'));
    else if (resp.errorMessage() != null)
        fut.onDone(new GridClientException(resp.errorMessage()));
    else
        fut.onDone(resp.result());
}
Also used : GridClientException(org.apache.ignite.internal.client.GridClientException) GridClientAuthenticationRequest(org.apache.ignite.internal.processors.rest.client.message.GridClientAuthenticationRequest) GridClientAuthenticationException(org.apache.ignite.internal.client.GridClientAuthenticationException) GridClientMessage(org.apache.ignite.internal.processors.rest.client.message.GridClientMessage)

Aggregations

GridClientAuthenticationException (org.apache.ignite.internal.client.GridClientAuthenticationException)1 GridClientException (org.apache.ignite.internal.client.GridClientException)1 GridClientAuthenticationRequest (org.apache.ignite.internal.processors.rest.client.message.GridClientAuthenticationRequest)1 GridClientMessage (org.apache.ignite.internal.processors.rest.client.message.GridClientMessage)1