Class SaslAuthenticationHandler

  • All Implemented Interfaces:
    com.couchbase.client.core.deps.io.netty.channel.ChannelHandler, com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandler, com.couchbase.client.core.deps.io.netty.channel.ChannelOutboundHandler, CallbackHandler

    public class SaslAuthenticationHandler
    extends com.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandler
    implements CallbackHandler
    This handler is responsible for perform SASL authentication against the KV engine.

    SASL is a complicated back-and-forth protocol which involves potentially many steps depending on the mechanism used. Couchbase supports a variety of protocols depending on the version, so the first step is to actually ask the server for the types of procotols it supports. Once the client has this figured out, it initializes the SASL client and starts the "back and forth" challenge response protocol. All of this opaque payload is framed over the memcache binary protocol as usual.

    Through configuration it is possible to change some defaults, for example limit the types of protocols accepted.

    Since:
    2.0.0
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface com.couchbase.client.core.deps.io.netty.channel.ChannelHandler

        com.couchbase.client.core.deps.io.netty.channel.ChannelHandler.Sharable
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Set<SaslMechanism> allowedMechanisms()
      Returns the allowed mechanisms for this handler, useful for testing assertions.
      void channelActive​(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx)  
      void channelRead​(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx, Object msg)  
      void connect​(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, com.couchbase.client.core.deps.io.netty.channel.ChannelPromise promise)
      Intercepts the connect process inside the pipeline to only propagate either success or failure if the hello process is completed either way.
      void handle​(Callback[] callbacks)
      This SASL callback handler is used to call certain callbacks during the authentication phases (to set the name and password if required).
      • Methods inherited from class com.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandler

        bind, close, deregister, disconnect, flush, read, write
      • Methods inherited from class com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapter

        channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
      • Methods inherited from class com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerAdapter

        ensureNotSharable, handlerAdded, handlerRemoved, isSharable
      • Methods inherited from interface com.couchbase.client.core.deps.io.netty.channel.ChannelHandler

        handlerAdded, handlerRemoved
    • Method Detail

      • allowedMechanisms

        @Internal
        public Set<SaslMechanism> allowedMechanisms()
        Returns the allowed mechanisms for this handler, useful for testing assertions.
        Returns:
        the set of allowed sasl mechanisms.
      • connect

        public void connect​(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx,
                            SocketAddress remoteAddress,
                            SocketAddress localAddress,
                            com.couchbase.client.core.deps.io.netty.channel.ChannelPromise promise)
        Intercepts the connect process inside the pipeline to only propagate either success or failure if the hello process is completed either way.
        Specified by:
        connect in interface com.couchbase.client.core.deps.io.netty.channel.ChannelOutboundHandler
        Overrides:
        connect in class com.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandler
        Parameters:
        ctx - the ChannelHandlerContext for which the connect operation is made.
        remoteAddress - the SocketAddress to which it should connect.
        localAddress - the SocketAddress which is used as source on connect.
        promise - the ChannelPromise to notify once the operation completes.
      • channelActive

        public void channelActive​(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx)
        Specified by:
        channelActive in interface com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandler
        Overrides:
        channelActive in class com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapter
      • channelRead

        public void channelRead​(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx,
                                Object msg)
        Specified by:
        channelRead in interface com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandler
        Overrides:
        channelRead in class com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapter