Java 类org.apache.hadoop.hbase.security.SaslStatus 实例源码

项目:hbase    文件:ServerRpcConnection.java   
/**
 * No protobuf encoding of raw sasl messages
 */
protected final void doRawSaslReply(SaslStatus status, Writable rv,
    String errorClass, String error) throws IOException {
  BufferChain bc;
  // In my testing, have noticed that sasl messages are usually
  // in the ballpark of 100-200. That's why the initial capacity is 256.
  try (ByteBufferOutputStream saslResponse = new ByteBufferOutputStream(256);
      DataOutputStream  out = new DataOutputStream(saslResponse)) {
    out.writeInt(status.state); // write status
    if (status == SaslStatus.SUCCESS) {
      rv.write(out);
    } else {
      WritableUtils.writeString(out, errorClass);
      WritableUtils.writeString(out, error);
    }
    bc = new BufferChain(saslResponse.getByteBuffer());
  }
  doRespond(() -> bc);
}