in src/hbase/connection/sasl-handler.cc [187:225]
void SaslHandler::ContinueSaslNegotiation(Context *ctx, folly::IOBufQueue *bufQueue) {
const char *out;
unsigned int outlen;
int bytes_sent = 0;
int bytes_received = 0;
std::unique_ptr<folly::IOBuf> iob = bufQueue->pop_front();
bytes_received = iob->length();
if (bytes_received == 0) {
throw std::runtime_error("Error in sasl handshake");
}
folly::io::RWPrivateCursor c(iob.get());
std::uint32_t status = c.readBE<std::uint32_t>();
std::uint32_t sz = c.readBE<std::uint32_t>();
if (status != 0 /*Status 0 is success*/) {
// Assumption here is that the response from server is not more than 8 * 1024
throw std::runtime_error("Error in sasl handshake " +
std::string(reinterpret_cast<char *>(c.writableData())));
}
out = nullptr;
outlen = 0;
int curr_rc =
sasl_client_step(sconn_, /* our context */
reinterpret_cast<char *>(c.writableData()), /* the data from the server */
sz, /* its length */
NULL, /* this should be unallocated and NULL */
&out, /* filled in on success */
&outlen); /* filled in on success */
if (curr_rc == SASL_OK || curr_rc == SASL_CONTINUE) {
WriteSaslOutput(ctx, out, outlen);
}
if (curr_rc == SASL_OK) {
FinishAuth(ctx, bufQueue);
}
}