spring security 获得session所有登入用户

我想通过spring security 获得所有登录用户
List<Object> slist = sessionRegistry.getAllPrincipals();
sessionRegistry.getAllPrincipals();一直报空指针异常
是不是我的配置文件写错了
下面是配置文件security部分
<!-- 登录认证器 -->

<b:bean id="loginAuthenticationFilter" class="cn.innosoft.orm.api.client.security.TokenUsernamePasswordAuthenticationFilter">
    <b:property name="sessionAuthenticationStrategy" ref="sas"/><!--此配置可实现获取所有登录用户信息 --> 
    <b:property name="authenticationManager" ref="authenticationManager"/>
    <b:property name="authenticationSuccessHandler" ref="specificUrlAuthenticationSuccessHandler"/>
    <b:property name="authenticationFailureHandler" ref="simpleUrlAuthenticationFailureHandler"/>
    <b:property name="usernameParameter" value="token"></b:property>
    <b:property name="filterProcessesUrl" value="/logon_token"></b:property>
    <b:property name="loginUserServer" ref="loginUserServer"></b:property>
</b:bean>

<!--sessionRegistry-->

<b:bean id="sessionRegistry" class="org.springframework.security.core.session.SessionRegistryImpl" /> 
<b:bean id="sas" class="org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy"/>  
       <b:constructor-arg name="sessionRegistry" ref="sessionRegistry" />  
    <b:property name="maximumSessions" value="1" />  
    <b:property name="exceptionIfMaximumExceeded" value="true" /> 
</b:bean> 

求大神指点

阅读 8.1k
1 个回答

原来在配置文件bean中多了一个斜杠,使标签不完整,启动报错,低级错误,但是却是致命的

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进