Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/369.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java spring security中的ConcurrentSessionControl策略3.2.4_Java_Spring_Spring Mvc_Spring Security - Fatal编程技术网

Java spring security中的ConcurrentSessionControl策略3.2.4

Java spring security中的ConcurrentSessionControl策略3.2.4,java,spring,spring-mvc,spring-security,Java,Spring,Spring Mvc,Spring Security,我有一个ConcurrentSessionControlStrategy的工作配置和我自己的sessionRegistry实现。我升级到SpringSecurity3.2.4,不得不将ConcurrentSessionControlStrategy更改为ConcurrentSessionControlAuthenticationStrategy。现在,sessionRegistry似乎没有连接,这意味着ConcurrentSessionControlAuthenticationStrategy.

我有一个ConcurrentSessionControlStrategy的工作配置和我自己的sessionRegistry实现。我升级到SpringSecurity3.2.4,不得不将ConcurrentSessionControlStrategy更改为ConcurrentSessionControlAuthenticationStrategy。现在,sessionRegistry似乎没有连接,这意味着ConcurrentSessionControlAuthenticationStrategy.onAuthenticaton没有进入sessionRegistry.registerNewSession。要做什么

我的配置xml:

    <security:http use-expressions="true" auto-config="false"
        entry-point-ref="loginUrlAuthenticationEntryPoint">


        <security:intercept-url pattern="/**"
            access="isAuthenticated()" />

        <security:custom-filter position="FORM_LOGIN_FILTER"
            ref="twoFactorAuthenticationFilter" />



        <security:logout logout-url="/player/logout"
            logout-success-url="/demo/player/logoutSuccess" />

        <security:session-management>
            <security:concurrency-control
                max-sessions="1" session-registry-ref="clusteredSessionRegistryImpl"
                error-if-maximum-exceeded="false" />
        </security:session-management>

    </security:http>



    <bean
        class="org.springframework.security.web.authentication.session.ConcurrentSessionControlAuthenticationStrategy">
        <constructor-arg ref="clusteredSessionRegistryImpl" />
        <property name="maximumSessions" value="1" />
    </bean>

    <bean id="loginUrlAuthenticationEntryPoint"
        class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint">
        <property name="loginFormUrl" value="/demo/player/login?login_error=true" />
    </bean>

    <bean id="twoFactorAuthenticationFilter" class="com.XXX.filter.TwoFactorAuthenticationFilter">
        <property name="authenticationManager" ref="authenticationManager" />
        <property name="authenticationFailureHandler" ref="failureHandler" />
        <property name="authenticationSuccessHandler" ref="playerAuthenticationSuccessHandler" />
        <property name="postOnly" value="true" />
    </bean>


    <bean id="failureHandler"
        class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler">
        <property name="defaultFailureUrl" value="/login?login_error=true" />

    </bean>

    <bean id="bCryptPasswordEncoder"
        class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder" />

    <security:authentication-manager alias="authenticationManager">
        <security:authentication-provider
            ref="authenticationProvider">
        </security:authentication-provider>
    </security:authentication-manager>

</beans>

看来我的答案晚了,但无论如何

ConcurrentSessionControlStrategy
的功能现在正好分为三种策略——
ConcurrentSessionControlAuthenticationStrategy
SessionFixationProtectionStrategy
registersionauthenticationstrategy

要找到合适的替代者,您应该使用
CompositeSessionAuthenticationStrategy
按上述顺序添加这三个代理。

因此,恐怕,
ConcurrentSessionControlAuthenticationStrategy
在反对意见中被错误地提到,作为
ConcurrentSessionControlStrategy
的替代品。它至少需要可用的
RegisterSessionAuthenticationStrategy
来维护
SessionRegistry
。否则,
SessionRegistry
将保持为空,“替换”始终报告“ok”


我想,这种方法已经改变,使它更灵活,将多个处理程序作为代理,而不是一个(使用
CompositeSessionAuthenticationStrategy
,您可以让任意数量的
SessionAuthenticationStrategy
独立地做事情)

您对
ConcurrentSessionControlAuthenticationStrategy
的定义没有做任何事情或添加任何内容,相同的定义由命名空间配置。我不确定是否理解。我的xml放入会话注册表实现。当我调用身份验证时,它不会进入会话注册表。
ConcurrentSessionControlAuthenticationStrategy
bean定义是多余的。通过
也可以执行同样的操作,因此您可以将其删除。此外,它可能会破坏正确的配置(覆盖您不希望覆盖的内容)。关键是事情已经被分解,而在以前的版本中,一切都是在
ConcurrentSessionControlStrategy
中完成的,现在它被委托给多个类。但是,冗余bean的注册可能会破坏默认设置,并且不会注册
RegisterSessionAuthenticationStrategy
。我添加了一个CompositeSessionAuthenticationStrategy,它使用ConcurrentSessionControlAuthenticationStrategy和RegisterSessionAuthenticationStrategy等work@lior,我可以发布你的java配置来解决这个问题,我也有同样的问题,我的脑袋被这个问题弄得发热problem@Edgar,我用java配置获得空注册表,请帮助如何处理这一个java配置…我正在尝试获取所有登录用户列表