public class KeyValueAuthHandler extends io.netty.channel.SimpleChannelInboundHandler<FullBinaryMemcacheResponse> implements javax.security.auth.callback.CallbackHandler, io.netty.channel.ChannelOutboundHandler
A SASL Client which communicates through the memcache binary protocol.
Modifier and Type | Field and Description |
---|---|
static byte |
SASL_LIST_MECHS_OPCODE
The memcache opcode for the SASL mechs list.
|
Constructor and Description |
---|
KeyValueAuthHandler(java.lang.String username,
java.lang.String password)
Creates a new
KeyValueAuthHandler . |
Modifier and Type | Method and Description |
---|---|
void |
bind(io.netty.channel.ChannelHandlerContext ctx,
java.net.SocketAddress localAddress,
io.netty.channel.ChannelPromise promise) |
void |
channelActive(io.netty.channel.ChannelHandlerContext ctx)
Once the channel is marked as active, the SASL negotiation is started.
|
protected void |
channelRead0(io.netty.channel.ChannelHandlerContext ctx,
FullBinaryMemcacheResponse msg)
Dispatches incoming SASL responses to the appropriate handler methods.
|
void |
close(io.netty.channel.ChannelHandlerContext ctx,
io.netty.channel.ChannelPromise promise) |
void |
connect(io.netty.channel.ChannelHandlerContext ctx,
java.net.SocketAddress remoteAddress,
java.net.SocketAddress localAddress,
io.netty.channel.ChannelPromise promise) |
void |
deregister(io.netty.channel.ChannelHandlerContext ctx,
io.netty.channel.ChannelPromise promise) |
void |
disconnect(io.netty.channel.ChannelHandlerContext ctx,
io.netty.channel.ChannelPromise promise) |
void |
flush(io.netty.channel.ChannelHandlerContext ctx) |
void |
handle(javax.security.auth.callback.Callback[] callbacks)
Callback handler needed for the
SaslClient which supplies username and password. |
void |
read(io.netty.channel.ChannelHandlerContext ctx) |
void |
write(io.netty.channel.ChannelHandlerContext ctx,
java.lang.Object msg,
io.netty.channel.ChannelPromise promise) |
acceptInboundMessage, channelRead
channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
handlerAdded, handlerRemoved, isSharable
public static final byte SASL_LIST_MECHS_OPCODE
The memcache opcode for the SASL mechs list.
public KeyValueAuthHandler(java.lang.String username, java.lang.String password)
Creates a new KeyValueAuthHandler
.
username
- the name of the user/bucket.password
- the password associated with the user/bucket.public void channelActive(io.netty.channel.ChannelHandlerContext ctx) throws java.lang.Exception
Once the channel is marked as active, the SASL negotiation is started.
channelActive
in interface io.netty.channel.ChannelInboundHandler
channelActive
in class io.netty.channel.ChannelInboundHandlerAdapter
ctx
- the handler context.java.lang.Exception
- if something goes wrong during negotiation.public void handle(javax.security.auth.callback.Callback[] callbacks) throws java.io.IOException, javax.security.auth.callback.UnsupportedCallbackException
Callback handler needed for the SaslClient
which supplies username and password.
handle
in interface javax.security.auth.callback.CallbackHandler
callbacks
- the possible callbacks.java.io.IOException
javax.security.auth.callback.UnsupportedCallbackException
protected void channelRead0(io.netty.channel.ChannelHandlerContext ctx, FullBinaryMemcacheResponse msg) throws java.lang.Exception
Dispatches incoming SASL responses to the appropriate handler methods.
channelRead0
in class io.netty.channel.SimpleChannelInboundHandler<FullBinaryMemcacheResponse>
ctx
- the handler context.msg
- the incoming message to investigate.java.lang.Exception
public void bind(io.netty.channel.ChannelHandlerContext ctx, java.net.SocketAddress localAddress, io.netty.channel.ChannelPromise promise) throws java.lang.Exception
bind
in interface io.netty.channel.ChannelOutboundHandler
java.lang.Exception
public void connect(io.netty.channel.ChannelHandlerContext ctx, java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress, io.netty.channel.ChannelPromise promise) throws java.lang.Exception
connect
in interface io.netty.channel.ChannelOutboundHandler
java.lang.Exception
public void disconnect(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.ChannelPromise promise) throws java.lang.Exception
disconnect
in interface io.netty.channel.ChannelOutboundHandler
java.lang.Exception
public void close(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.ChannelPromise promise) throws java.lang.Exception
close
in interface io.netty.channel.ChannelOutboundHandler
java.lang.Exception
public void deregister(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.ChannelPromise promise) throws java.lang.Exception
deregister
in interface io.netty.channel.ChannelOutboundHandler
java.lang.Exception
public void read(io.netty.channel.ChannelHandlerContext ctx) throws java.lang.Exception
read
in interface io.netty.channel.ChannelOutboundHandler
java.lang.Exception
public void write(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object msg, io.netty.channel.ChannelPromise promise) throws java.lang.Exception
write
in interface io.netty.channel.ChannelOutboundHandler
java.lang.Exception
public void flush(io.netty.channel.ChannelHandlerContext ctx) throws java.lang.Exception
flush
in interface io.netty.channel.ChannelOutboundHandler
java.lang.Exception