Search in sources :

Example 1 with SaslMechanismsSelectedEvent

use of com.couchbase.client.core.cnc.events.io.SaslMechanismsSelectedEvent in project couchbase-jvm-clients by couchbase.

the class SaslAuthenticationHandler method startAuthSequence.

/**
 * Starts the SASL auth sequence with the set of mechanisms that are valid for this specific run.
 *
 * @param ctx the channel handler context
 * @param usedMechanisms the mechanisms that can be used during this run
 */
private void startAuthSequence(final ChannelHandlerContext ctx, final Set<SaslMechanism> usedMechanisms) {
    try {
        saslClient = createSaslClient(usedMechanisms);
        SaslMechanism selectedMechanism = SaslMechanism.from(saslClient.getMechanismName());
        roundtripsToGo = selectedMechanism.roundtrips();
        endpointContext.environment().eventBus().publish(new SaslMechanismsSelectedEvent(ioContext, usedMechanisms, selectedMechanism));
        ctx.writeAndFlush(buildAuthRequest(ctx));
        maybePropagateChannelActive(ctx);
    } catch (SaslException e) {
        failConnect(ctx, "SASL Client could not be constructed", null, e, (short) 0);
    }
}
Also used : SaslMechanism(com.couchbase.client.core.env.SaslMechanism) SaslException(javax.security.sasl.SaslException) SaslMechanismsSelectedEvent(com.couchbase.client.core.cnc.events.io.SaslMechanismsSelectedEvent)

Aggregations

SaslMechanismsSelectedEvent (com.couchbase.client.core.cnc.events.io.SaslMechanismsSelectedEvent)1 SaslMechanism (com.couchbase.client.core.env.SaslMechanism)1 SaslException (javax.security.sasl.SaslException)1