private void tryDecodeError(ByteBuf in, int offset, int readableBytes) throws IOException {
    if (readableBytes < 4) {
      return;
    }
    int classLen = in.getInt(offset);
    if (classLen <= 0) {
      throw new IOException("Invalid exception class name length " + classLen);
    }
    if (classLen > MAX_CHALLENGE_SIZE) {
      throw new IOException("Exception class name length too large(" + classLen
        + "), max allowed is " + MAX_CHALLENGE_SIZE);
    }
    if (readableBytes < 4 + classLen + 4) {
      return;
    }
    int msgLen = in.getInt(offset + 4 + classLen);
    if (msgLen <= 0) {
      throw new IOException("Invalid exception message length " + msgLen);
    }
    if (msgLen > MAX_CHALLENGE_SIZE) {
      throw new IOException(
        "Exception message length too large(" + msgLen + "), max allowed is " + MAX_CHALLENGE_SIZE);
    }
    int totalLen = classLen + msgLen + 8;
    if (readableBytes < totalLen) {
      return;
    }
    String className = in.toString(offset + 4, classLen, HConstants.UTF8_CHARSET);
    String msg = in.toString(offset + classLen + 8, msgLen, HConstants.UTF8_CHARSET);
    in.readerIndex(offset + totalLen);
    throw new RemoteException(className, msg);
  }
Decode the sasl challenge sent by RpcServer.
hbase-client/src/main/java/org/apache/hadoop/hbase/security/SaslChallengeDecoder.java