Spring Security - 单击“注销”后无法登录

时间:2009-10-30 03:24:40

标签: spring-security

我已将Spring Security添加到我的应用程序中。我能够正常登录但是在我点击退出后,我无法再次登录。

这是我的applicationContext-security.xml

<http auto-config="true" access-denied-page="/accessDenied.html">
    <intercept-url pattern="/login.html*" filters="none"/>  
    <intercept-url pattern="/static/**" filters="none"/>
    <intercept-url pattern="/**" access="ROLE_USER" />
    <form-login login-page="/login.html"
                authentication-failure-url="/login.html?login_error=1"
                default-target-url="/search.html"/>
    <logout logout-success-url="/login.html"/>
    <concurrent-session-control max-sessions="1" exception-if-maximum-exceeded="true"/>  
</http>

<!--
Usernames/Passwords are
    rod/koala
-->
<authentication-provider>
    <password-encoder hash="md5"/>
    <user-service>
        <user name="rod" password="a564de63c2d0da68cf47586ee05984d7" authorities="ROLE_USER" />
 </user-service>

这是我的登录表单:

<form method="post" action="j_spring_security_check">

    <table>
        <tr>
            <td><label for="j_username">Username:</label></td>
            <td>
             <input type="text" name="j_username" id="j_username" size="20" maxlength="50"
             <c:if test="${not empty param.login_error}">
                value="<%= session.getAttribute(AuthenticationProcessingFilter.SPRING_SECURITY_LAST_USERNAME_KEY) %>"
             </c:if>/>
            </td>
        </tr>

        <tr>
            <td><label for="j_password">Password:</label></td>
            <td>
                <input type="password" name="j_password" id="j_password" size="20" maxlength="50"/>
            </td>    
        </tr>
        <tr>
            <td colspan="2" align="center">
                <input type="checkbox" name="_spring_security_remember_me"/> Remember me on this computer.
            </td>
        </tr>

        <tr>
            <td>&nbsp;</td>
            <td>
                <input type="submit" class="button-submit" name="submit" value="Login">
            </td>
        </tr>
    </table>

我的退出链接指向:/j_spring_security_logout

更新:(10.30.2009 09:44 EDT)

一些额外的信息,我启用了DEBUG级别日志记录,现在可以在我的控制台中看到:

09:42:14 DEBUG [http-8080-1] (AbstractProcessingFilter.java:412) - Authentication request failed: org.springframework.security.concurrent.ConcurrentLoginException: Maximum sessions of 1 for this principal exceeded

似乎我的applicationContext-security.xml中的这一行与它有关:

<concurrent-session-control max-sessions="1" exception-if-maximum-exceeded="true"/> 

我不确定为什么即使我已经注销它认为我已经超过最大会话数。

感谢任何帮助,谢谢!

-AJ

1 个答案:

答案 0 :(得分:4)

实际上,我刚解决了。 ;)

我的web.xml中缺少此侦听器:

<listener>
  <listener-class>org.springframework.security.ui.session.HttpSessionEventPublisher</listener-class>
</listener>