Spring Security 3.0控制一个帐号只允许登录一次的问题

Spring Security 3 自定义UserDetails后,控制一个帐号只能登录一次的功能不能起作用,原因出在自定义的UserDetails上:

org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy 里面的checkAuthenticationAllowed方法,调用了sessionRegistry.getAllSessions,用authentication.getPrincipal(),也就是UserDetails实现对象。 但是sessionRegistry存储的时候使用的是Hash的数据结构,在自定义的UserDetails里必须重写equals和hashCode

见flashing的论坛主题:

http://www.javaeye.com/topic/823666

posted @ 2011-01-24 15:08  Jamie  阅读(2588)  评论(0编辑  收藏  举报