Class KeyValueAuthHandler
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- io.netty.channel.SimpleChannelInboundHandler<FullBinaryMemcacheResponse>
-
- com.couchbase.client.core.endpoint.kv.KeyValueAuthHandler
-
- All Implemented Interfaces:
ChannelHandler
,ChannelInboundHandler
,ChannelOutboundHandler
,CallbackHandler
public class KeyValueAuthHandler extends SimpleChannelInboundHandler<FullBinaryMemcacheResponse> implements CallbackHandler, ChannelOutboundHandler
A SASL Client which communicates through the memcache binary protocol.- Since:
- 1.0
- Author:
- Michael Nitschinger
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
-
Field Summary
Fields Modifier and Type Field Description static byte
SASL_LIST_MECHS_OPCODE
The memcache opcode for the SASL mechs list.
-
Constructor Summary
Constructors Constructor Description KeyValueAuthHandler(String username, String password, boolean forceSaslPlain)
Creates a newKeyValueAuthHandler
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise)
void
channelActive(ChannelHandlerContext ctx)
Once the channel is marked as active, the SASL negotiation is started.protected void
channelRead0(ChannelHandlerContext ctx, FullBinaryMemcacheResponse msg)
Dispatches incoming SASL responses to the appropriate handler methods.void
close(ChannelHandlerContext ctx, ChannelPromise promise)
void
connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise)
void
deregister(ChannelHandlerContext ctx, ChannelPromise promise)
void
disconnect(ChannelHandlerContext ctx, ChannelPromise promise)
void
flush(ChannelHandlerContext ctx)
void
handle(Callback[] callbacks)
Callback handler needed for theSaslClient
which supplies username and password.void
read(ChannelHandlerContext ctx)
void
write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
-
Methods inherited from class io.netty.channel.SimpleChannelInboundHandler
acceptInboundMessage, channelRead
-
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
-
-
-
Field Detail
-
SASL_LIST_MECHS_OPCODE
public static final byte SASL_LIST_MECHS_OPCODE
The memcache opcode for the SASL mechs list.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
KeyValueAuthHandler
public KeyValueAuthHandler(String username, String password, boolean forceSaslPlain)
Creates a newKeyValueAuthHandler
.- Parameters:
username
- the name of the user/bucket.password
- the password associated with the user/bucket.
-
-
Method Detail
-
channelActive
public void channelActive(ChannelHandlerContext ctx) throws Exception
Once the channel is marked as active, the SASL negotiation is started.- Specified by:
channelActive
in interfaceChannelInboundHandler
- Overrides:
channelActive
in classChannelInboundHandlerAdapter
- Parameters:
ctx
- the handler context.- Throws:
Exception
- if something goes wrong during negotiation.
-
handle
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
Callback handler needed for theSaslClient
which supplies username and password.- Specified by:
handle
in interfaceCallbackHandler
- Parameters:
callbacks
- the possible callbacks.- Throws:
IOException
- if something goes wrong during negotiation.UnsupportedCallbackException
- if something goes wrong during negotiation.
-
channelRead0
protected void channelRead0(ChannelHandlerContext ctx, FullBinaryMemcacheResponse msg) throws Exception
Dispatches incoming SASL responses to the appropriate handler methods.- Specified by:
channelRead0
in classSimpleChannelInboundHandler<FullBinaryMemcacheResponse>
- Parameters:
ctx
- the handler context.msg
- the incoming message to investigate.- Throws:
Exception
- if something goes wrong during negotiation.
-
bind
public void bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) throws Exception
- Specified by:
bind
in interfaceChannelOutboundHandler
- Throws:
Exception
-
connect
public void connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) throws Exception
- Specified by:
connect
in interfaceChannelOutboundHandler
- Throws:
Exception
-
disconnect
public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception
- Specified by:
disconnect
in interfaceChannelOutboundHandler
- Throws:
Exception
-
close
public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception
- Specified by:
close
in interfaceChannelOutboundHandler
- Throws:
Exception
-
deregister
public void deregister(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception
- Specified by:
deregister
in interfaceChannelOutboundHandler
- Throws:
Exception
-
read
public void read(ChannelHandlerContext ctx) throws Exception
- Specified by:
read
in interfaceChannelOutboundHandler
- Throws:
Exception
-
write
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception
- Specified by:
write
in interfaceChannelOutboundHandler
- Throws:
Exception
-
flush
public void flush(ChannelHandlerContext ctx) throws Exception
- Specified by:
flush
in interfaceChannelOutboundHandler
- Throws:
Exception
-
-