/** * Constructs a new Krb5Config entry with the specified ticket cache and logs in with that entry. * * <p>If <code>cache</code> is <code>null</code>, then <code>Krb5Config.setTicketCache</code> will * be set to <code>true</code> and the default ticket cache will be used. * * <p>Equivalent to the following calls: * * <pre> * Krb5Config kc = Krb5Config.getInstance(); * if (cache != null) * kc.setTicketCache(cache); * else * kc.setUseTicketCache(true); * LoginContext lc = Login.login(kc); * </pre> */ public static LoginContext withTicketCache(String cache) throws LoginException { Krb5Config kc = Krb5Config.getInstance(); // kc.setStoreKey(true); if (cache != null) { kc.setTicketCache(cache); } else { kc.setUseTicketCache(true); } Configuration dc = new DynamicConfiguration(S_CONFIG_NAME, new AppConfigurationEntry[] {kc}); return new LoginContext(S_CONFIG_NAME, null, null, dc); }