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;
}
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());
}
}
}
Aggregations