ssh2框架单用户登录
我现在在做一个ssh2系统,客户想让用户实现单用户登录,比如一个账号登录了,在另一台电脑上登录该账号,则之前登录的那台电脑中的用户就不能使用了(可以出现“用户已在其他地区登录”这样的说明),我的是ssh2+spring security(spring权限验证),请问这样的怎样做,谢谢。
[解决办法]
spring security就可以实现单用户登录
<beans:bean id="sas" class="org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy">
<beans:constructor-arg name="sessionRegistry" ref="sessionRegistry"></beans:constructor-arg>
<beans:property name="maximumSessions" value="1"></beans:property>
<!-- 后登录的用户不能顶替前面已登录的用户
<beans:property name="exceptionIfMaximumExceeded" value="true"></beans:property>
-->
</beans:bean>
<http use-expressions="true" entry-point-ref="loginUrlEntryPoint">
<intercept-url pattern="/common/error.jsp" filters="none"/>
<intercept-url pattern="/common/403.jsp" filters="none"/>
<intercept-url pattern="/checkCode.do" filters="none"/>
<intercept-url pattern="/noLogin.do" filters="none"/>
<intercept-url pattern="/sessionConcurrent.do" filters="none"/>
<intercept-url pattern="/login.do" filters="none"/>
<intercept-url pattern="/checkPwd.do" filters="none"/>
<intercept-url pattern="/js/**" filters="none" />
<intercept-url pattern="/css/**" filters="none" />
<intercept-url pattern="/image/**" filters="none" />
<intercept-url pattern="/*.ico" filters="none" />
<intercept-url pattern="/workflow/uploadResource.do" filters="none"/>
<intercept-url pattern="/**" access="isAuthenticated()"/>
<access-denied-handler ref="accessDeniedHandler"/>
<intercept-url pattern="/common/upload.do" filters="none"/>
<intercept-url pattern="/common/deleteAttachFile.do" filters="none"/>
<intercept-url pattern="/phone/**" filters="none"/>
<custom-filter ref="customFilter" before="FILTER_SECURITY_INTERCEPTOR"/>
<!-- 登录 -->
<custom-filter ref="loginFilter" before="FORM_LOGIN_FILTER" />
<!-- 退出 -->
<custom-filter position="LOGOUT_FILTER" ref="logoutFilter"/>
<!-- session管理 防止session并发 -->
<custom-filter ref="concurentFilter" position="CONCURRENT_SESSION_FILTER"/>
<session-management session-authentication-strategy-ref="sas"/>
</http>
web.xml这样配置
<!-- Spring Secutiry3配置 -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- security session管理 -->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.security.web.session.HttpSessionEventPublisher
</listener-class>
</listener>
就是按照这个配置来的,还是不行。是不是要自己写代码管理session啊?