Beispiel #1
0
 public static void verifyPassword(String principal, String password) throws LoginException {
   LoginContext lc = null;
   try {
     lc = Krb5Login.withPassword(principal, password);
     lc.login();
   } finally {
     if (lc != null) {
       try {
         lc.logout();
       } catch (LoginException le) {
         ZimbraLog.account.warn("krb5 logout failed", le);
       }
     }
   }
 }
Beispiel #2
0
  public static void performAs(String principal, String keytab, PrivilegedExceptionAction action)
      throws PrivilegedActionException, LoginException {
    LoginContext lc = null;
    try {
      // Authenticate to Kerberos.
      lc = Krb5Login.withKeyTab(principal, keytab);
      lc.login();

      // Assume the identity of the authenticated principal.
      Subject.doAs(lc.getSubject(), action);

    } finally {
      if (lc != null) {
        try {
          lc.logout();
        } catch (LoginException le) {
          ZimbraLog.account.warn("krb5 logout failed", le);
        }
      }
    }
  }