how to kill all the session independent of the service

17 views
Skip to first unread message

carlos maddaleno cuellar

unread,
Oct 24, 2016, 5:22:53 PM10/24/16
to CAS Community
i want that when i logout of one application or service it kills the others but it dosent i haveto logout of every service i loggin  how can i do this?

what i do now is this.

<h:commandLink action="#{sesionMB.logout()}" style="text-decoration: none;">
                                    <h:graphicImage library="images" name="logout.png" style="right: 0px; margin-top: 10px; position: relative;" width="30px;"  /> 
                                    <h:outputLabel value="Logout" style="font-size: 16px; color: #F2F2F2; text-decoration: none; display: block;"/>
                                </h:commandLink>




 public void logout() {
        Factory<org.apache.shiro.mgt.SecurityManager> factory = new IniSecurityManagerFactory("classpath:shiro.ini");
        org.apache.shiro.mgt.SecurityManager securityManager = factory.getInstance();
        SecurityUtils.setSecurityManager(securityManager);
        if (SecurityUtils.getSubject() != null) {
            SecurityUtils.getSubject().logout();
        }
        redirectToLogOut();
    }



private void redirectToLogOut() {
        try {
            HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
            /*String url = request.getRequestURL().toString();
             String baseURL = url.substring(0, url.length() - request.getRequestURI().length()) + request.getContextPath() + "/";*/

            URL reconstructedURL = new URL(request.getScheme(),
                    request.getServerName(),
                    request.getServerPort(), ""
            );
            reconstructedURL.toString();
            log.info(String.format("ReconstructedURL: %s", reconstructedURL.toString()));
            //log.info(String.format("BaseURL obtained: %s", baseURL));
            FacesContext.getCurrentInstance().getExternalContext().redirect(reconstructedURL.toString() + "/cas/logout");
            FacesContext.getCurrentInstance().getExternalContext().invalidateSession();
        } catch (IOException ex) {
            log.error(ex);
        }
    }

carlos maddaleno cuellar

unread,
Oct 26, 2016, 9:57:32 AM10/26/16
to Misagh Moayyed, CAS Community
Reply all
Reply to author
Forward
0 new messages