code: private void handleAuthResponse(ChannelHandlerContext ctx, FullBinaryMemcacheResponse msg) throws Exception {
          if (saslClient.isComplete()) {
              checkIsAuthed(msg);
              return;
          }
  
          byte[] response = new byte[msg.content().readableBytes()];
          msg.content().readBytes(response);
          byte[] evaluatedBytes = saslClient.evaluateChallenge(response);
  
          if (evaluatedBytes != null) {
              ByteBuf content;
  
              // This is needed against older server versions where the protocol does not
              // align on cram and plain, the else block is used for all the newer cram-sha*
              // mechanisms.
              //
              // Note that most likely this is only executed in the CRAM-MD5 case only, but
              // just to play it safe keep it for both mechanisms.
              if (selectedMechanism.equals("CRAM-MD5") || selectedMechanism.equals("PLAIN")) {
                  String[] evaluated = new String(evaluatedBytes).split(" ");
                  content = Unpooled.copiedBuffer(username + "\0" + evaluated[1], CharsetUtil.UTF_8);
              } else {
                  content = Unpooled.wrappedBuffer(evaluatedBytes);
              }
  
              FullBinaryMemcacheRequest stepRequest = new DefaultFullBinaryMemcacheRequest(
                  selectedMechanism.getBytes(CharsetUtil.UTF_8),
                  Unpooled.EMPTY_BUFFER,
                  content
              );
              stepRequest
                  .setOpcode(SASL_STEP_OPCODE)
                  .setKeyLength((short) selectedMechanism.length())
                  .setTotalBodyLength(content.readableBytes() + selectedMechanism.length());
  
              ChannelFuture future = ctx.writeAndFlush(stepRequest);
              future.addListener(new GenericFutureListener<Future<Void>>() {
                  @Override
                  public void operationComplete(Future<Void> future) throws Exception {
                      if (!future.isSuccess()) {
                          LOGGER.warn("Error during SASL Auth negotiation phase.", future);
                      }
                  }
              });
          } else {
              throw new AuthenticationException("SASL Challenge evaluation returned null.");
          }
      }
docs: Handles an incoming SASL AUTH response and - if needed - dispatches the SASL STEPs.
  
  @param ctx the handler context.
  @param msg the incoming message to investigate.
  @throws Exception if something goes wrong during negotiation.