code: public static void loginFromKeytab(HiveConf hiveConf) throws IOException {
      String principal = hiveConf.getVar(ConfVars.HIVE_SERVER2_KERBEROS_PRINCIPAL);
      String keyTabFile = hiveConf.getVar(ConfVars.HIVE_SERVER2_KERBEROS_KEYTAB);
      if (principal.isEmpty() || keyTabFile.isEmpty()) {
        throw new IOException("HiveServer2 Kerberos principal or keytab is not correctly configured");
      } else {
        UserGroupInformation.loginUserFromKeytab(SecurityUtil.getServerPrincipal(principal, "0.0.0.0"), keyTabFile);
      }
    }
docs: Perform kerberos login using the hadoop shim API if the configuration is available