In your applicationContext-security.xml file add the success-handler like below
<logout logout-url="/resources/j_spring_security_logout" success-handler-ref="com.mycompany.security.SpringSecurityLogoutHandler" />
Create the Class which will be implemneting "org.springframework.security.web.authentication.logout.LogoutHandler" interface and in it's logout method do all the stuff you want at the time of logout.
package com.mycompany.security;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutHandler;
public class SpringSecurityLogoutHandler implements LogoutHandler {
@Override
public void logout(HttpServletRequest request, HttpServletResponse arg1,
Authentication arg2) {
// Write your logout logic here
}
}
<logout logout-url="/resources/j_spring_security_logout" success-handler-ref="com.mycompany.security.SpringSecurityLogoutHandler" />
Create the Class which will be implemneting "org.springframework.security.web.authentication.logout.LogoutHandler" interface and in it's logout method do all the stuff you want at the time of logout.
package com.mycompany.security;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutHandler;
public class SpringSecurityLogoutHandler implements LogoutHandler {
@Override
public void logout(HttpServletRequest request, HttpServletResponse arg1,
Authentication arg2) {
// Write your logout logic here
}
}
I am happy to see that this short but precise blog post was mentioned on Srping source web site as a source of information to implement Logout handler using Apring Security.It was mentioned as a 2nd item in below link
ReplyDeletehttp://www.springsource.org/node/3779
Aor u kidding? This has NEVER WORKED
Delete