Search in sources :

Example 1 with AuthorizationContext

use of org.apache.ignite.internal.processors.authentication.AuthorizationContext in project ignite by apache.

the class OdbcConnectionContext method initializeFromHandshake.

/**
 * {@inheritDoc}
 */
@Override
public void initializeFromHandshake(ClientListenerProtocolVersion ver, BinaryReaderExImpl reader) throws IgniteCheckedException {
    assert SUPPORTED_VERS.contains(ver) : "Unsupported ODBC protocol version.";
    boolean distributedJoins = reader.readBoolean();
    boolean enforceJoinOrder = reader.readBoolean();
    boolean replicatedOnly = reader.readBoolean();
    boolean collocated = reader.readBoolean();
    boolean lazy = false;
    if (ver.compareTo(VER_2_1_5) >= 0)
        lazy = reader.readBoolean();
    boolean skipReducerOnUpdate = false;
    if (ver.compareTo(VER_2_3_0) >= 0)
        skipReducerOnUpdate = reader.readBoolean();
    String user = null;
    String passwd = null;
    if (ver.compareTo(VER_2_5_0) >= 0) {
        user = reader.readString();
        passwd = reader.readString();
    }
    AuthorizationContext actx = null;
    try {
        if (ctx.authentication().enabled()) {
            if (F.isEmpty(user))
                throw new IgniteCheckedException("Unauthenticated sessions are prohibited");
            actx = ctx.authentication().authenticate(user, passwd);
            if (actx == null)
                throw new IgniteCheckedException("Unknown authentication error");
        } else {
            if (!F.isEmpty(user))
                throw new IgniteCheckedException("Authentication is disabled for the node.");
        }
    } catch (Exception e) {
        throw new IgniteCheckedException("Handshake error: " + e.getMessage(), e);
    }
    handler = new OdbcRequestHandler(ctx, busyLock, maxCursors, distributedJoins, enforceJoinOrder, replicatedOnly, collocated, lazy, skipReducerOnUpdate, actx);
    parser = new OdbcMessageParser(ctx, ver);
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) AuthorizationContext(org.apache.ignite.internal.processors.authentication.AuthorizationContext) IgniteCheckedException(org.apache.ignite.IgniteCheckedException)

Example 2 with AuthorizationContext

use of org.apache.ignite.internal.processors.authentication.AuthorizationContext in project ignite by apache.

the class JdbcConnectionContext method initializeFromHandshake.

/**
 * {@inheritDoc}
 */
@Override
public void initializeFromHandshake(ClientListenerProtocolVersion ver, BinaryReaderExImpl reader) throws IgniteCheckedException {
    assert SUPPORTED_VERS.contains(ver) : "Unsupported JDBC protocol version.";
    boolean distributedJoins = reader.readBoolean();
    boolean enforceJoinOrder = reader.readBoolean();
    boolean collocated = reader.readBoolean();
    boolean replicatedOnly = reader.readBoolean();
    boolean autoCloseCursors = reader.readBoolean();
    boolean lazyExec = false;
    if (ver.compareTo(VER_2_1_5) >= 0)
        lazyExec = reader.readBoolean();
    boolean skipReducerOnUpdate = false;
    if (ver.compareTo(VER_2_3_0) >= 0)
        skipReducerOnUpdate = reader.readBoolean();
    AuthorizationContext actx = null;
    try {
        if (reader.available() > 0) {
            String user = reader.readString();
            String passwd = reader.readString();
            if (F.isEmpty(user) && ctx.authentication().enabled())
                throw new IgniteCheckedException("Unauthenticated sessions are prohibited");
            actx = ctx.authentication().authenticate(user, passwd);
            if (actx == null)
                throw new IgniteCheckedException("Unknown authentication error");
        } else {
            if (ctx.authentication().enabled())
                throw new IgniteCheckedException("Unauthenticated sessions are prohibited");
        }
    } catch (Exception e) {
        throw new IgniteCheckedException("Handshake error: " + e.getMessage(), e);
    }
    handler = new JdbcRequestHandler(ctx, busyLock, maxCursors, distributedJoins, enforceJoinOrder, collocated, replicatedOnly, autoCloseCursors, lazyExec, skipReducerOnUpdate, actx, ver);
    parser = new JdbcMessageParser(ctx);
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) AuthorizationContext(org.apache.ignite.internal.processors.authentication.AuthorizationContext) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IOException(java.io.IOException)

Aggregations

IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 AuthorizationContext (org.apache.ignite.internal.processors.authentication.AuthorizationContext)2 IOException (java.io.IOException)1