예제 #1
0
파일: Krb5Login.java 프로젝트: koem/Zimbra
 /**
  * Constructs a new Krb5Config entry with the specified principal and keytab, logs in with that
  * entry, and then removes that entry and returns the new LoginContext.
  *
  * <p>Equivalent to the following calls:
  *
  * <pre>
  * Krb5Config kc = Krb5Config.getInstance();
  * kc.setPrincipal(principal);
  * kc.setKeyTab(keytab);
  * kc.setStoreKey(true);
  * LoginContext lc = Login.login(kc);
  * </pre>
  */
 public static LoginContext withKeyTab(String principal, String keytab) throws LoginException {
   /*
    * com.sun.security.auth.module.Krb5LoginModule required
    * useKeyTab=true
    * debug=true
    * keyTab="/apps/workgroup-audit/keytab/keytab.workgroup-audit"
    * doNotPrompt=true
    * storeKey=true
    * principal="service/[email protected]"
    * useTicketCache=true
    */
   Krb5Config kc = Krb5Config.getInstance();
   // kc.setDebug(true);
   kc.setPrincipal(principal);
   kc.setKeyTab(keytab);
   kc.setStoreKey(true);
   kc.setDoNotPrompt(true);
   kc.setUseTicketCache(true);
   Configuration dc = new DynamicConfiguration(S_CONFIG_NAME, new AppConfigurationEntry[] {kc});
   return new LoginContext(S_CONFIG_NAME, null, null, dc);
 }