- 论坛徽章:
- 0
|
Appfuse Version 1.9.3
org.acegisecurity.ui.webapp.AuthenticationProcessingFilter
这个验证过滤器做了比较多的事情,看security.xml
authenticationManager中注入的多个property就看的出来
authenticationManager代理了认证过程,如果通过验证那么返回一个通过验证的Authentication,它包含了此用户可以操作的所有权限信息,如果未通过验证,将抛出一个
AuthenticationException,doFilter方法中捕获了这个异常,并将用户引导到authenticationFailureUrl路径所指的位置
如果验证成功了,那么先将Authentication填充到SecurityContextHolder中
SecurityContextHolder.getContext().setAuthentication(authResult);
在response里面写入cookies
rememberMeServices.loginSuccess(request, response, authResult);
在这里是TokenBasedRememberMeServices中的loginSuccess方法,其中对cookie进行了加密操作
// construct token to put in cookie; format is:
// username + ":" + expiryTime + ":" + Md5Hex(username + ":" + expiryTime + ":" + password + ":" + key)
这个计算完成后做了Base64.encodeBase64,然后将这段字符串存入cookie
name=ACEGI_SECURITY_HASHED_REMEMBER_ME_COOKIE
最后重定向到
response.sendRedirect(response.encodeRedirectURL(targetUrl));
其中 targetUrl = obtainFullRequestUrl(request);即转向原来请求的路径
如果alwaysUseDefaultTargetUrl==false等情况会转向这个位置
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/19271/showart_146532.html |
|