Search in sources :

Example 6 with AuthFailedServiceException

use of com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException in project zm-mailbox by Zimbra.

the class ZimbraLoginService method login.

@Override
public UserIdentity login(String username, Object credentials, ServletRequest req) {
    Account account;
    try {
        Provisioning prov = Provisioning.getInstance();
        account = prov.get(AccountBy.name, username);
        if (account != null) {
            if (!(credentials instanceof String)) {
                ZimbraLog.security.warn("passed credentials are not a String? [%s]", credentials == null ? "null" : credentials.getClass().getName());
            }
            tryLogin(account, (String) credentials, true);
            return makeUserIdentity(username);
        }
    } catch (AuthFailedServiceException e) {
        ZimbraLog.security.debug("Auth failed");
    } catch (ServiceException e) {
        ZimbraLog.security.warn("ServiceException in auth", e);
    }
    return null;
}
Also used : Account(com.zimbra.cs.account.Account) AuthFailedServiceException(com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException) AuthFailedServiceException(com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException) ServiceException(com.zimbra.common.service.ServiceException) CacheAwareProvisioning(com.zimbra.cs.account.CacheAwareProvisioning) Provisioning(com.zimbra.cs.account.Provisioning)

Example 7 with AuthFailedServiceException

use of com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException in project zm-mailbox by Zimbra.

the class SpnegoFilter method doFilter.

@Override
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException {
    HttpServletRequest hreq = (HttpServletRequest) req;
    HttpServletResponse hresp = (HttpServletResponse) resp;
    try {
        try {
            authenticate(hreq, hresp);
        } catch (SSOAuthenticatorServiceException e) {
            if (SSOAuthenticatorServiceException.SENT_CHALLENGE.equals(e.getCode())) {
                return;
            } else {
                throw e;
            }
        }
        chain.doFilter(req, resp);
    } catch (ServiceException e) {
        ZimbraServlet.addRemoteIpToLoggingContext(hreq);
        ZimbraServlet.addUAToLoggingContext(hreq);
        if (e instanceof AuthFailedServiceException) {
            AuthFailedServiceException afe = (AuthFailedServiceException) e;
            ZimbraLog.account.info("spnego auth failed: " + afe.getMessage() + afe.getReason(", %s"));
        } else {
            ZimbraLog.account.info("spnego auth failed: " + e.getMessage());
        }
        ZimbraLog.account.debug("spnego auth failed", e);
        ZimbraLog.clearContext();
        if (passThruOnAuthFailure(hreq)) {
            chain.doFilter(req, resp);
        } else {
            hresp.sendError(HttpServletResponse.SC_FORBIDDEN, e.getMessage());
        }
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) AuthFailedServiceException(com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException) ServiceException(com.zimbra.common.service.ServiceException) SSOAuthenticatorServiceException(com.zimbra.cs.service.authenticator.SSOAuthenticator.SSOAuthenticatorServiceException) AuthFailedServiceException(com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException) SSOAuthenticatorServiceException(com.zimbra.cs.service.authenticator.SSOAuthenticator.SSOAuthenticatorServiceException) HttpServletResponse(javax.servlet.http.HttpServletResponse)

Aggregations

ServiceException (com.zimbra.common.service.ServiceException)7 AuthFailedServiceException (com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException)7 AuthToken (com.zimbra.cs.account.AuthToken)5 Account (com.zimbra.cs.account.Account)4 Provisioning (com.zimbra.cs.account.Provisioning)4 AccountServiceException (com.zimbra.cs.account.AccountServiceException)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 AccountBy (com.zimbra.common.account.Key.AccountBy)2 Element (com.zimbra.common.soap.Element)2 AuthTokenException (com.zimbra.cs.account.AuthTokenException)2 Domain (com.zimbra.cs.account.Domain)2 EmailAddress (com.zimbra.cs.account.names.NameUtil.EmailAddress)2 SSOAuthenticatorServiceException (com.zimbra.cs.service.authenticator.SSOAuthenticator.SSOAuthenticatorServiceException)2 ZimbraPrincipal (com.zimbra.cs.service.authenticator.SSOAuthenticator.ZimbraPrincipal)2 HashMap (java.util.HashMap)2 SoapFaultException (com.zimbra.common.soap.SoapFaultException)1 SoapProtocol (com.zimbra.common.soap.SoapProtocol)1 Usage (com.zimbra.cs.account.AuthToken.Usage)1 CacheAwareProvisioning (com.zimbra.cs.account.CacheAwareProvisioning)1 GuestAccount (com.zimbra.cs.account.GuestAccount)1