Tidying.
This commit is contained in:
parent
628227f5e7
commit
cb980f12d5
|
@ -25,56 +25,50 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a logout by modifying the
|
* Performs a logout by modifying the {@link org.springframework.security.context.SecurityContextHolder}.
|
||||||
* {@link org.springframework.security.context.SecurityContextHolder}.
|
|
||||||
*
|
|
||||||
* <p>
|
* <p>
|
||||||
* Will also invalidate the {@link HttpSession} if
|
* Will also invalidate the {@link HttpSession} if {@link #isInvalidateHttpSession()} is <code>true</code> and the
|
||||||
* {@link #isInvalidateHttpSession()} is <code>true</code> and the session is
|
* session is not <code>null</code>.
|
||||||
* not <code>null</code>.
|
|
||||||
*
|
*
|
||||||
* @author Ben Alex
|
* @author Ben Alex
|
||||||
* @version $Id: SecurityContextLogoutHandler.java 1784 2007-02-24 21:00:24Z
|
* @version $Id$
|
||||||
* luke_t $
|
|
||||||
*/
|
*/
|
||||||
public class SecurityContextLogoutHandler implements LogoutHandler {
|
public class SecurityContextLogoutHandler implements LogoutHandler {
|
||||||
// ~ Methods
|
//~ Methods ========================================================================================================
|
||||||
// ========================================================================================================
|
|
||||||
|
|
||||||
private boolean invalidateHttpSession = true;
|
private boolean invalidateHttpSession = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requires the request to be passed in.
|
* Requires the request to be passed in.
|
||||||
*
|
*
|
||||||
* @param request from which to obtain a HTTP session (cannot be null)
|
* @param request from which to obtain a HTTP session (cannot be null)
|
||||||
* @param response not used (can be <code>null</code>)
|
* @param response not used (can be <code>null</code>)
|
||||||
* @param authentication not used (can be <code>null</code>)
|
* @param authentication not used (can be <code>null</code>)
|
||||||
*/
|
*/
|
||||||
public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
|
public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
|
||||||
Assert.notNull(request, "HttpServletRequest required");
|
Assert.notNull(request, "HttpServletRequest required");
|
||||||
if (invalidateHttpSession) {
|
if (invalidateHttpSession) {
|
||||||
HttpSession session = request.getSession(false);
|
HttpSession session = request.getSession(false);
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
session.invalidate();
|
session.invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SecurityContextHolder.clearContext();
|
SecurityContextHolder.clearContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInvalidateHttpSession() {
|
public boolean isInvalidateHttpSession() {
|
||||||
return invalidateHttpSession;
|
return invalidateHttpSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Causes the {@link HttpSession} to be invalidated when this
|
* Causes the {@link HttpSession} to be invalidated when this {@link LogoutHandler} is invoked. Defaults to true.
|
||||||
* {@link LogoutHandler} is invoked. Defaults to true.
|
*
|
||||||
*
|
* @param invalidateHttpSession true if you wish the session to be invalidated (default) or false if it should
|
||||||
* @param invalidateHttpSession true if you wish the session to be
|
* not be.
|
||||||
* invalidated (default) or false if it should not be
|
*/
|
||||||
*/
|
public void setInvalidateHttpSession(boolean invalidateHttpSession) {
|
||||||
public void setInvalidateHttpSession(boolean invalidateHttpSession) {
|
this.invalidateHttpSession = invalidateHttpSession;
|
||||||
this.invalidateHttpSession = invalidateHttpSession;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue