1
當我做了如何在Spring Security 3.0.5中獲取所有應用程序的在線用戶?
org.springframework.security.core.userdetails.UserDetailsService
的實施和使用語句
內它sessionRegistry.registerNewSession(user.getUsername() ,用戶);
在成功認證之後,則
sessionRegistry.getAllPrincipals();
列表不爲空(但是當我從應用程序註銷時,會話仍然保留在列表中),否則此列表將爲空。我怎樣才能在sessionRegistry中自動進行會話註冊(以及在用戶註銷或會話過期期間註銷)?我的彈簧配置如下:
<sec:http auto-config="true" use-expressions="true" access-denied-page="/accessDenied.jsf">
<sec:form-login login-page="/login.jsf" />
<sec:session-management session-authentication-strategy-ref="sas" />
</sec:http>
<bean id="sessionRegistry" class="org.springframework.security.core.session.SessionRegistryImpl" />
<bean id="scr"
class="org.springframework.security.web.context.HttpSessionSecurityContextRepository" />
<bean id="smf"
class="org.springframework.security.web.session.SessionManagementFilter">
<constructor-arg name="securityContextRepository"
ref="scr" />
<property name="sessionAuthenticationStrategy"
ref="sas" />
</bean>
<bean id="sas"
class="org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy">
<constructor-arg name="sessionRegistry"
ref="sessionRegistry" />
<property name="maximumSessions" value="10" />
</bean>
否我的web.xml中存在HttpSessionEventPublisher。其實我想讓併發seseseions但我認爲使用sessionRegistry獲得所有在線用戶的列表,我必須使用ConcurrentSessionControlStrategy!如果我的想法不是真的,那麼使用sessionRegistry的替代方法是什麼?在我的測試中,我從不同的瀏覽器登錄,然後打印當前的會話 – nazila 2013-04-06 14:56:54