免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 972 | 回复: 0
打印 上一主题 下一主题

appfuse开读8 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-07-27 17:34 |只看该作者 |倒序浏览
Appfuse Version 1.9.3

org.acegisecurity.ui.rememberme.RememberMeProcessingFilter

此filter做的事情非常简单

if (SecurityContextHolder.getContext().getAuthentication() == null) {

如果没有Authentication

那么

Authentication rememberMeAuth = rememberMeServices.autoLogin(httpRequest, httpResponse);

此方法所做的操作在前面的文章中已经写过,读取客户端cookie信息
Cookie[] cookies = request.getCookies();
ACEGI_SECURITY_HASHED_REMEMBER_ME_COOKIE_KEY.equals(cookies.getName())
然后通过验证此cookie的value来确定

它的cookie的value结构是username + ":" + expiryTime + ":" + Md5Hex(username + ":" + expiryTime + ":" + password + ":" + key)
所以通过分析这个value,可以得到这个username是不是有效的
日期是不是有效
然后将这些信息和key来算出这个md5码进行匹配最后确定是不是有效的,返回Authentication
然后验证这个Authentication
authenticationManager.authenticate(rememberMeAuth);
将其存入
  SecurityContextHolder.getContext().setAuthentication(rememberMeAuth);

如果验证失败 rememberMeServices.loginFail(httpRequest, httpResponse);

这里需要提出来一个细节


这个bean里面 此参数与页面的name是关联的!!

在LoginForm.jsp页面可以看到


这点在代码中也可以看到TokenBasedRememberMeServices的loginSuccess方法中

RequestUtils.getBooleanParameter(request, parameter, false),
此spring方法的作用是接受name=parameter的,这里是parameter=rememberMe
的, parameter可以是"true", "on", "yes" (any case) and "1" 都是true












本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/19271/showart_146629.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP