code: public static UserGroupInformation loginFromSpnegoKeytabAndReturnUGI(HiveConf hiveConf)
      throws IOException {
      String principal = hiveConf.getVar(ConfVars.HIVE_SERVER2_SPNEGO_PRINCIPAL);
      String keyTabFile = hiveConf.getVar(ConfVars.HIVE_SERVER2_SPNEGO_KEYTAB);
      if (principal.isEmpty() || keyTabFile.isEmpty()) {
        throw new IOException("HiveServer2 SPNEGO principal or keytab is not correctly configured");
      } else {
        return UserGroupInformation.loginUserFromKeytabAndReturnUGI(SecurityUtil.getServerPrincipal(principal, "0.0.0.0"), keyTabFile);
      }
    }
docs: Perform SPNEGO login using the hadoop shim API if the configuration is available