use of com.couchbase.client.core.cnc.events.io.SaslAuthenticationCompletedEvent in project couchbase-jvm-clients by couchbase.
the class SaslAuthenticationHandler method completeAuth.
/**
* Helper method to complete the SASL auth successfully.
*/
private void completeAuth(final ChannelHandlerContext ctx, ByteBuf msg) throws SaslException {
if (!saslClient.isComplete()) {
// validate final server response
ByteBuf responseBody = body(msg).orElse(Unpooled.EMPTY_BUFFER);
byte[] payload = ByteBufUtil.getBytes(responseBody);
saslClient.evaluateChallenge(payload);
if (!saslClient.isComplete()) {
throw new SaslException("Incomplete SASL exchange");
}
}
Optional<Duration> latency = ConnectTimings.stop(ctx.channel(), this.getClass(), false);
endpointContext.environment().eventBus().publish(new SaslAuthenticationCompletedEvent(latency.orElse(Duration.ZERO), ioContext));
interceptedConnectPromise.trySuccess();
ctx.pipeline().remove(this);
}
Aggregations