Class SaslAuthenticationHandler
- java.lang.Object
-
- com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerAdapter
-
- com.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapter
-
- com.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandler
-
- com.couchbase.client.core.io.netty.kv.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
-
-
Constructor Summary
Constructors Constructor Description SaslAuthenticationHandler(EndpointContext endpointContext, String username, String password, Set<SaslMechanism> allowedSaslMechanisms)
-
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
-
-
-
-
Constructor Detail
-
SaslAuthenticationHandler
public SaslAuthenticationHandler(EndpointContext endpointContext, String username, String password, Set<SaslMechanism> allowedSaslMechanisms)
-
-
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 interfacecom.couchbase.client.core.deps.io.netty.channel.ChannelOutboundHandler
- Overrides:
connect
in classcom.couchbase.client.core.deps.io.netty.channel.ChannelDuplexHandler
- Parameters:
ctx
- theChannelHandlerContext
for which the connect operation is made.remoteAddress
- theSocketAddress
to which it should connect.localAddress
- theSocketAddress
which is used as source on connect.promise
- theChannelPromise
to notify once the operation completes.
-
channelActive
public void channelActive(com.couchbase.client.core.deps.io.netty.channel.ChannelHandlerContext ctx)
- Specified by:
channelActive
in interfacecom.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandler
- Overrides:
channelActive
in classcom.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 interfacecom.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandler
- Overrides:
channelRead
in classcom.couchbase.client.core.deps.io.netty.channel.ChannelInboundHandlerAdapter
-
handle
public void handle(Callback[] callbacks) throws UnsupportedCallbackException
This SASL callback handler is used to call certain callbacks during the authentication phases (to set the name and password if required).- Specified by:
handle
in interfaceCallbackHandler
- Parameters:
callbacks
- the callbacks to handle.- Throws:
UnsupportedCallbackException
-
-