private void setupJAASConfig(Configuration conf) throws IOException { if (!UserGroupInformation.getLoginUser().isFromKeytab()) { // The process has not logged in using keytab // this should be a test mode, can't use keytab to authenticate // with zookeeper. LOGGER.warn("Login is not from keytab"); return; } String principal; String keytab; switch (serverMode) { case METASTORE: principal = getNonEmptyConfVar(conf, "hive.metastore.kerberos.principal"); keytab = getNonEmptyConfVar(conf, "hive.metastore.kerberos.keytab.file"); break; case HIVESERVER2: principal = getNonEmptyConfVar(conf, "hive.server2.authentication.kerberos.principal"); keytab = getNonEmptyConfVar(conf, "hive.server2.authentication.kerberos.keytab"); break; default: throw new AssertionError("Unexpected server mode " + serverMode); } SecurityUtils.setZookeeperClientKerberosJaasConfig(principal, keytab); }