| 1 13 package info.magnolia.module.admininterface.pages; 14 15 import info.magnolia.module.admininterface.PageMVCHandler; 16 import info.magnolia.context.MgnlContext; 17 import info.magnolia.context.SystemContext; 18 import info.magnolia.cms.beans.config.ContentRepository; 19 20 import java.io.IOException ; 21 import java.util.Iterator ; 22 23 import javax.servlet.http.HttpServletRequest ; 24 import javax.servlet.http.HttpServletResponse ; 25 import javax.servlet.http.HttpSession ; 26 import javax.jcr.Session; 27 28 import org.slf4j.Logger; 29 import org.slf4j.LoggerFactory; 30 31 32 36 public class LogoutPage extends PageMVCHandler { 37 38 41 private static Logger log = LoggerFactory.getLogger(LogoutPage.class); 42 43 48 public LogoutPage(String name, HttpServletRequest request, HttpServletResponse response) { 49 super(name, request, response); 50 } 51 52 55 public void renderHtml(String view) throws IOException { 56 HttpSession session = getRequest().getSession(false); 57 if (session != null) { 58 if (!(MgnlContext.getInstance() instanceof SystemContext)) { 59 Iterator configuredStores = ContentRepository.getAllRepositoryNames(); 60 while (configuredStores.hasNext()) { 61 String store = (String ) configuredStores.next(); 62 try { 63 Session jcrSession = MgnlContext.getHierarchyManager(store).getWorkspace().getSession(); 64 if (jcrSession.isLive()) jcrSession.logout(); 65 } catch (Throwable t) { 66 log.debug("Failed to close JCR session",t); 67 } 68 } 69 } 70 session.invalidate(); 71 log.info("Logging out user"); 72 } 73 getResponse().sendRedirect(request.getContextPath() + "/"); 74 } 75 76 } 77 | Popular Tags |