Search in sources :

Example 1 with SSOAuthenticatorServiceException

use of com.zimbra.cs.service.authenticator.SSOAuthenticator.SSOAuthenticatorServiceException 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)1 AuthFailedServiceException (com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException)1 SSOAuthenticatorServiceException (com.zimbra.cs.service.authenticator.SSOAuthenticator.SSOAuthenticatorServiceException)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1