Package com.dotcms.listeners

Examples of com.dotcms.listeners.SessionMonitor


        }
    }

    public void invalidateSession(String sessionId) throws PortalException, SystemException, NoSuchUserException, DotDataException, DotSecurityException {
        validateUser();
        SessionMonitor sm = (SessionMonitor)
                WebContextFactory.get().getServletContext().getAttribute(WebKeys.USER_SESSIONS);

        HttpServletRequest req = WebContextFactory.get().getHttpServletRequest();
        User currentUser = com.liferay.portal.util.PortalUtil.getUser(req);

        if(sm.getUserSessions().containsKey(sessionId)) {
            HttpSession session=sm.getUserSessions().get(sessionId);
            User user=APILocator.getUserAPI().loadUserById(sm.getSysUsers().get(sessionId), APILocator.getUserAPI().getSystemUser(), false);

            if(!currentUser.getUserId().equals(user.getUserId())) {
            session.invalidate();
          } else {
            throw new IllegalArgumentException("can't invalidate session "+sessionId);
View Full Code Here


        }
    }

    public void invalidateAllSessions() throws PortalException, SystemException, NoSuchUserException, DotDataException, DotSecurityException {
        validateUser();
        SessionMonitor sm = (SessionMonitor)
                WebContextFactory.get().getServletContext().getAttribute(WebKeys.USER_SESSIONS);

        HttpServletRequest req = WebContextFactory.get().getHttpServletRequest();
        User currentUser = com.liferay.portal.util.PortalUtil.getUser(req);

        for(String id : sm.getSysUsers().keySet()) {
          HttpSession session=sm.getUserSessions().get(id);
          User user=APILocator.getUserAPI().loadUserById(sm.getSysUsers().get(id), APILocator.getUserAPI().getSystemUser(), false);

          if(!currentUser.getUserId().equals(user.getUserId())) {
            session.invalidate();
          }
        }
View Full Code Here

    }

    public List<Map<String,String>> getSessionList() throws NoSuchUserException, DotDataException, DotSecurityException {
        validateUser();
        List<Map<String,String>> sessionList=new ArrayList<Map<String,String>>();
        SessionMonitor sm = (SessionMonitor)
                WebContextFactory.get().getServletContext().getAttribute(WebKeys.USER_SESSIONS);

        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");

        for(String id : sm.getSysUsers().keySet()) {
            Map<String,String> ss=new HashMap<String,String>();
            ss.put("sessionId",id);
            User user=APILocator.getUserAPI().loadUserById(sm.getSysUsers().get(id), APILocator.getUserAPI().getSystemUser(), false);
            ss.put("userId",user.getUserId());
            ss.put("userEmail", user.getEmailAddress());
            ss.put("userFullName", user.getFullName());
            ss.put("address", sm.getSysUsersAddress().get(id));
            HttpSession session=sm.getUserSessions().get(id);
            Date d = new Date();
            d.setTime(session.getCreationTime());
            ss.put("sessionTime", DateUtil.prettyDateSince(d, PublicCompanyFactory.getDefaultCompany().getLocale()) );
            sessionList.add(ss);
        }
View Full Code Here

TOP

Related Classes of com.dotcms.listeners.SessionMonitor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.