Spring安全性:用户重新登录后从子线程访问Authentication对象的问题

时间:2013-07-30 07:21:38

标签: spring-security

面对下一个问题:我需要从子线程获取当前登录的用户名,为此我使用SecurityContextHolder的MODE_INHERITABLETHREADLOCAL策略。一切正常,直到用户注销并再次登录。之后MODE_INHERITABLETHREADLOCAL不起作用。我不知道为什么,并试图找到解决方案。问题是,在从子线程调用的重新登录SecurityContextHolder.getContext().getAuthentication()之后,返回nullSecurityContextHolder.getContextHolderStrategy()返回MODE_INHERITABLETHREADLOCAL)。 我在security-config.xml中设置了上下文持有者策略

<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> <property name="targetClass" value="org.springframework.security.core.context.SecurityContextHolder"/> <property name="targetMethod" value="setStrategyName"/> <property name="arguments"><list><value>MODE_INHERITABLETHREADLOCAL</value></list></property> </bean> 如果有人能帮助我,我将不胜感激。提前谢谢!

0 个答案:

没有答案