Spring Security - не удается войти после щелчка - PullRequest
3 голосов
/ 30 октября 2009

Я добавил Spring Security в свое приложение. Я могу нормально войти в систему, но после того, как я нажму кнопку «Выйти», я не смогу войти снова.

Вот мое приложение Context-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 ПО ВОСТОЧНОМУ ВРЕМЕНИ)

Некоторая дополнительная информация, я включил ведение журнала уровня 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"/> 

Я не уверен, почему, даже если я вышел из системы, он считает, что превысил максимальное количество сеансов.

Любая помощь приветствуется, спасибо!

1 Ответ

4 голосов
/ 30 октября 2009

На самом деле, я просто решил это. ;)

Этот слушатель отсутствовал в моем web.xml:

<listener>
  <listener-class>org.springframework.security.ui.session.HttpSessionEventPublisher</listener-class>
</listener>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...