in src/hbase/connection/sasl-util.cc [75:92]
std::string SaslUtil::ParseServiceName(std::shared_ptr<hbase::Configuration> conf, bool secure) {
if (!secure) {
return std::string();
}
std::string svrPrincipal = conf->Get(kServerPrincipalConfKey, "");
// principal is of this form: hbase/23a03935850c@EXAMPLE.COM
// where 23a03935850c is the host (optional)
std::size_t pos = svrPrincipal.find("/");
if (pos == std::string::npos && svrPrincipal.find("@") != std::string::npos) {
pos = svrPrincipal.find("@");
}
if (pos == std::string::npos) {
throw std::runtime_error("Couldn't retrieve service principal from conf");
}
VLOG(1) << "pos " << pos << " " << svrPrincipal;
std::string service_name = svrPrincipal.substr(0, pos);
return service_name;
}