Spring Security - Can't Login After Clicking Logout
I've added Spring Security to my application. I am able to login fine but after I click logout, I'm then unable to login again.
Here is my 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>
Here is my login form:
<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> </td>
开发者_开发技巧 <td>
<input type="submit" class="button-submit" name="submit" value="Login">
</td>
</tr>
</table>
And my logout link points to:/j_spring_security_logout
UPDATE: (10.30.2009 09:44 EDT)
Some additional info, I enabled DEBUG level logging and can now see this in my console:
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
It would seem that this line from my applicationContext-security.xml has something to do with it:
<concurrent-session-control max-sessions="1" exception-if-maximum-exceeded="true"/>
I'm not sure why even if I've logged out that it thinks I've exceeded the max num of sessions.
Any help appreciated, thanks!
-aj
Actually, I just solved it. ;)
This listener was missing from my web.xml:
<listener>
<listener-class>org.springframework.security.ui.session.HttpSessionEventPublisher</listener-class>
</listener>
精彩评论