spring security中自定义authenticationProcessingFilter























public Authentication attemptAuthentication(
HttpServletRequest httpServletRequest)
throws AuthenticationException {
String check_code = httpServletRequest.getParameter("j_checkcode");
String sys_code = (String) httpServletRequest.getSession()
.getAttribute(checkCodeName);

if (sys_code == null) {
throw new AuthCodeValidationException("验证码不正确");
} else if (!sys_code.equals(check_code)) {
String username = obtainUsername(httpServletRequest);
httpServletRequest.getSession().setAttribute(
SPRING_SECURITY_LAST_USERNAME_KEY, username);
// 用户输入的值与看到的不一致,抛出异常
throw new AuthCodeValidationException("验证码输入不正确");
}
return super.attemptAuthentication(httpServletRequest);
}

你可能感兴趣的:(JAVA)