Search in sources :

Example 1 with AutoProvAuthMech

use of com.zimbra.common.account.ZAttrProvisioning.AutoProvAuthMech in project zm-mailbox by Zimbra.

the class AutoProvisionLazy method auth.

private AutoProvAuthMech auth() {
    String authMechStr = domain.getAttr(Provisioning.A_zimbraAuthMech);
    AuthMech authMech = null;
    try {
        authMech = AuthMech.fromString(authMechStr);
    } catch (ServiceException e) {
        ZimbraLog.autoprov.debug("invalid auth mech " + authMechStr, e);
    }
    // only support external LDAP auth for now
    if (AuthMech.ldap == authMech || AuthMech.ad == authMech) {
        Map<String, Object> authCtxt = new HashMap<String, Object>();
        try {
            prov.externalLdapAuth(domain, authMech, loginName, loginPassword, authCtxt);
            return AutoProvAuthMech.LDAP;
        } catch (ServiceException e) {
            ZimbraLog.autoprov.info("unable to authenticate " + loginName + " for auto provisioning", e);
        }
    } else if (AuthMech.kerberos5 == authMech) {
        try {
            Krb5Login.verifyPassword(loginName, loginPassword);
            return AutoProvAuthMech.KRB5;
        } catch (LoginException e) {
            ZimbraLog.autoprov.info("unable to authenticate " + loginName + " for auto provisioning", e);
        }
    } else {
    // unsupported auth mechanism for lazy auto provision
    // Provisioning.AM_CUSTOM is not supported because the custom auth 
    // interface required a Zimrba Account instance.
    }
    return null;
}
Also used : AutoProvAuthMech(com.zimbra.common.account.ZAttrProvisioning.AutoProvAuthMech) AuthMech(com.zimbra.cs.account.auth.AuthMechanism.AuthMech) AuthFailedServiceException(com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException) ServiceException(com.zimbra.common.service.ServiceException) HashMap(java.util.HashMap) LoginException(javax.security.auth.login.LoginException)

Aggregations

AutoProvAuthMech (com.zimbra.common.account.ZAttrProvisioning.AutoProvAuthMech)1 ServiceException (com.zimbra.common.service.ServiceException)1 AuthFailedServiceException (com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException)1 AuthMech (com.zimbra.cs.account.auth.AuthMechanism.AuthMech)1 HashMap (java.util.HashMap)1 LoginException (javax.security.auth.login.LoginException)1