Skip to content

Instantly share code, notes, and snippets.

@dploeger
Created October 14, 2014 13:33
Show Gist options
  • Save dploeger/f28275ce20f2e8c8922a to your computer and use it in GitHub Desktop.
Save dploeger/f28275ce20f2e8c8922a to your computer and use it in GitHub Desktop.
Calling Zimbra internal auth from a custom auth extension
String encodedPassword = acct.getAttr(Provisioning.A_userPassword);
if (acct instanceof LdapEntry) {
LdapProvisioning prov = (LdapProvisioning) acct.getProvisioning();
prov.zimbraLdapAuthenticate(acct, password, context);
return; // good password, RETURN
} else if (PasswordUtil.SSHA.isSSHA(encodedPassword)) {
if (PasswordUtil.SSHA.verifySSHA(encodedPassword, password)) {
return; // good password, RETURN
} else {
throw AccountServiceException.AuthFailedServiceException
.AUTH_FAILED(acct.getName(),
namePassedIn(context), "invalid password");
}
}
throw AccountServiceException.AuthFailedServiceException.AUTH_FAILED
(acct.getName(), namePassedIn(context));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment