Try this:

  | import javax.faces.context.FacesContext;
  | import javax.servlet.http.Cookie;
  | import javax.servlet.http.HttpServletRequest;
  | import javax.servlet.http.HttpServletResponse;
  | 
  | import org.acegisecurity.context.SecurityContextHolder;
  | import org.acegisecurity.ui.rememberme.TokenBasedRememberMeServices;
  | import org.jboss.seam.Seam;
  | 
  | 
  | ...
  | 
  | private void logoutAuthentication() {
  |     HttpServletRequest request = 
  |             (HttpServletRequest)FacesContext.getCurrentInstance()
  |             .getExternalContext().getRequest();
  |     HttpServletResponse response = 
(HttpServletResponse)FacesContext.getCurrentInstance()
  |             .getExternalContext().getResponse();
  |     try {
  |             if (request.getRemoteUser() != null) {
  |                     Seam.invalidateSession(); // invalidate session
  |                     Cookie terminate = new 
Cookie(TokenBasedRememberMeServices
  |                                     
.ACEGI_SECURITY_HASHED_REMEMBER_ME_COOKIE_KEY, null);
  |                     terminate.setMaxAge(0);
  |                     terminate.setPath("/"); // You need to add this!!!!!
  |                     response.addCookie(terminate);
  |                     SecurityContextHolder.clearContext(); // invalidate
  |                     // authentication
  |             }
  | 
  |     } catch (Exception e) {
  |             log.error("Error logging out: ", e);
  |     }
  |     log.debug("SecurityContext invalidated!");
  | }
  | 
  | 

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4093559#4093559

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4093559
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to