ctx.pipeline().replace("length-field-based-frame-decoder",
"fixed-length-frame-decoder",
new FixedLengthFrameDecoder(RequestServerHandler.RESPONSE_BYTES));
return;
}
SaslTokenMessageRequest serverToken =
(SaslTokenMessageRequest) decodedMessage;
if (LOG.isDebugEnabled()) {
LOG.debug("handleUpstream: Responding to server's token of length: " +
serverToken.getSaslToken().length);
}
// Generate SASL response (but we only actually send the response if it's
// non-null.
byte[] responseToServer = saslNettyClient.saslResponse(serverToken);
if (responseToServer == null) {
// If we generate a null response, then authentication has completed (if
// not, warn), and return without sending a response back to the server.
if (LOG.isDebugEnabled()) {
LOG.debug("handleUpstream: Response to server is null: " +
"authentication should now be complete.");
}
if (!saslNettyClient.isComplete()) {
LOG.warn("handleUpstream: Generated a null response, " +
"but authentication is not complete.");
}
return;
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("handleUpstream: Response to server token has length:" +
responseToServer.length);
}
}
// Construct a message containing the SASL response and send it to the
// server.
SaslTokenMessageRequest saslResponse =
new SaslTokenMessageRequest(responseToServer);
ctx.channel().writeAndFlush(saslResponse);
}