spring Security3 配置session并发无效!

wangzhuoyan 2013-06-03 02:55:12
项目中配置了spring Security3 的并发session管理,一直无效,2个相同账户依然可以登录,不知道什么原因,网上搜了很很多都不行,请大牛指点!
web.xml
<!-- 让SpringSecurity 获得session 生存周期事件 -->
<listener>
<listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
</listener>

applicationContext-security.xml
<!-- http安全配置 -->
<s:http auto-config="false"
entry-point-ref="authenticationProcessingFilterEntryPoint">
<s:intercept-url pattern="/common/**" filters="none" />
<s:intercept-url pattern="/css/**" filters="none" />
<s:intercept-url pattern="/images/**" filters="none" />
<s:intercept-url pattern="/scripts/**" filters="none" />
<s:custom-filter position="CONCURRENT_SESSION_FILTER" ref="concurrencyFilter" />
<s:session-management session-authentication-strategy-ref="sessionAuthenticationStrategy" />
<!-- Spring Security默认的Filter -->
<s:custom-filter before="FILTER_SECURITY_INTERCEPTOR" ref="myFilter" />
<s:custom-filter before="FORM_LOGIN_FILTER" ref="webLoginFilter" />
<s:custom-filter before="LOGOUT_FILTER" ref="webLogoutFilter" />
</s:http>
<bean id="concurrencyFilter" class="org.springframework.security.web.session.ConcurrentSessionFilter">
<property name="sessionRegistry" ref="sessionRegistry" />
<property name="expiredUrl" value="/index.jsp" />
</bean>
<bean id="sessionAuthenticationStrategy"
class="org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy">
<constructor-arg name="sessionRegistry" ref="sessionRegistry"/>
<property name="maximumSessions" value="1"/>
</bean>
<bean id="sessionRegistry" class="org.springframework.security.core.session.SessionRegistryImpl" />
启动不报错误,也看不出哪有问题。用的是spring-security-web-3.0.5.RELEASE 版本jar,在线等待!
...全文
563 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
jiang_gj 2015-04-20
  • 打赏
  • 举报
回复
<session-management session-fixation-protection="migrateSession"> <concurrency-control max-sessions="1" /> </session-management>
  • 打赏
  • 举报
回复
同求有大神解决的可以说明一下吗?
风神二少 2014-06-04
  • 打赏
  • 举报
回复
有哪位大神解决了吗?
hegaoyang 2014-05-26
  • 打赏
  • 举报
回复
这个问题解决了没?我也遇到这个问题,试了好多方法,还是可以重复登陆~
migrant423 2013-08-09
  • 打赏
  • 举报
回复
给你我的配置部分代码。 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:s="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd" default-lazy-init="true"> <s:global-method-security secured-annotations="enabled" /> <s:http use-expressions="true" access-decision-manager-ref="accessDecisionManager" access-denied-page="/403"> <s:intercept-url pattern="/css/**" filters="none" /> <s:intercept-url pattern="/images/**" filters="none" /> <s:intercept-url pattern="/js/**" filters="none" /> <s:intercept-url pattern="/login" filters="none" /> <s:intercept-url pattern="/" access="isAuthenticated()" /> <s:custom-filter position="CONCURRENT_SESSION_FILTER" ref="concurrencyFilter" /> <s:custom-filter before="FILTER_SECURITY_INTERCEPTOR" ref="resourceSecurityInterceptor" /> <s:session-management session-authentication-strategy-ref="sas"/> <!-- <s:form-login login-page="/login" login-processing-url="/j_security_check" default-target-url="/" authentication-failure-url="/login.jsp?error=1" always-use-default-target="true" /> --> <s:form-login login-page="/login" default-target-url="/" authentication-failure-url="/login?error=1" login-processing-url="/j_security_check"/> <s:logout invalidate-session="true" logout-success-url="/login" logout-url="/logout" /> </s:http> <bean id="sessionRegistry" class="org.springframework.security.core.session.SessionRegistryImpl" /> <bean id="sas" class="org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy"> <constructor-arg name="sessionRegistry" ref="sessionRegistry" /> <property name="maximumSessions" value="1" /> <property name="exceptionIfMaximumExceeded" value="false" /> </bean> <bean id="concurrencyFilter" class="org.springframework.security.web.session.ConcurrentSessionFilter"> <property name="sessionRegistry" ref="sessionRegistry" /> <property name="expiredUrl" value="/login?error=3" /> </bean> <s:authentication-manager alias="authenticationManager"> <s:authentication-provider user-service-ref="userDetailsService"> <s:password-encoder hash="md5" /> </s:authentication-provider> </s:authentication-manager>
wangzhuoyan 2013-06-05
  • 打赏
  • 举报
回复
继续求救。。。
wangzhuoyan 2013-06-04
  • 打赏
  • 举报
回复
继续求大牛协助!!!
wangzhuoyan 2013-06-04
  • 打赏
  • 举报
回复
没人知道怎么解决吗?
小丑哥_V5 2013-06-03
  • 打赏
  • 举报
回复
来我的博客下载那个security开源项目实例吧,相对你看了我的做法,相信对你有帮助
wangzhuoyan 2013-06-03
  • 打赏
  • 举报
回复
自己顶吧,别沉了
wangzhuoyan 2013-06-03
  • 打赏
  • 举报
回复
不太清楚,刚接触[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/16.gif][/img
七神之光 2013-06-03
  • 打赏
  • 举报
回复
帮顶 话说这玩意是通过fiter 控制的悲观锁吧

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧