KerberosUtils { public static String getKerberosRealm(Config config) { if (config.hasPath(REALM_CONFIG)) { return config.getString(REALM_CONFIG); } String realm; try { realm = getKrb5config().getDefaultRealm(); } catch (KrbException e) { throw new RuntimeException(e); } return realm; }  static KerberosLoginContext createKerberosLoginContext(String contextName, Config config); static boolean shouldLoginFromKeytab(Config config); static String getKerberosRealm(Config config); static void loginIfRequired(KerberosLoginContext loginContext, Config config);  }
@Test public void testGetKerberosRealm() throws KrbException { Config config = ConfigFactory.parseString(String.format("%s = foo.kt", KEYTAB_CONFIG)); System.setProperty("java.security.krb5.conf", testFolder.getRoot().getAbsolutePath() + File.separator + "krb5.conf"); String realm = KerberosUtils.getKerberosRealm(config); assertEquals("ENVELOPE.LOCAL", realm); config = ConfigFactory.parseString(String.format("%s = foo.kt\n%s = CORP.GLOBAL", KEYTAB_CONFIG, REALM_CONFIG)); realm = KerberosUtils.getKerberosRealm(config); assertEquals("CORP.GLOBAL", realm); }