KerberosUtils { static KrbConfig getKrb5config() throws KrbException { if (krb5Config == null) { if (System.getProperty("java.security.krb5.conf") != null && fileExists(System.getProperty("java.security.krb5.conf"))) { krb5Config = ClientUtil.getConfig(new File(System.getProperty("java.security.krb5.conf"))); } else if (fileExists(System.getProperty("java.home") + File.separator + "lib" + File.separator + "security" + File.separator + "krb5.conf")) { krb5Config = ClientUtil.getConfig(new File(System.getProperty("java.home") + File.separator + "lib" + File.separator + "security" + File.separator + "krb5.conf")); } else if (fileExists("/etc/krb5.conf")) { krb5Config = ClientUtil.getConfig(new File("/etc/krb5.conf")); } else { throw new RuntimeException("Could not find a valid /etc/krb5.conf file"); } } return krb5Config; }  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 testGetKrb5Config() throws KrbException { System.setProperty("java.security.krb5.conf", testFolder.getRoot().getAbsolutePath() + File.separator + "krb5.conf"); KrbConfig config = KerberosUtils.getKrb5config(); assertNotNull(config); assertEquals("ENVELOPE.LOCAL", config.getDefaultRealm()); }