/* * 覆盖默认实现,打印日志便于调试,查看具体登录是什么错误。 *(可以扩展把错误写入数据库之类的。) * (non-Javadoc) * @see org.apache.shiro.web.filter.authc.FormAuthenticationFilter#onLoginFailure(org.apache.shiro.authc.AuthenticationToken, org.apache.shiro.authc.AuthenticationException, javax.servlet.ServletRequest, javax.servlet.ServletResponse) */ @Override protected boolean onLoginFailure( AuthenticationToken token, AuthenticationException e, ServletRequest request, ServletResponse response) { if (log.isDebugEnabled()) { Class<?> clazz = e.getClass(); if (clazz.equals(AuthenticationException.class)) { log.debug(Exceptions.getStackTraceAsString(e)); } } return super.onLoginFailure(token, e, request, response); }
protected void setFailureAttribute(ServletRequest request, AuthenticationException ae) { String className = ae.getClass().getName(); request.setAttribute(getFailureKeyAttribute(), className); }