Beispiel #1
0
  public void attributeReplaced(HttpSessionBindingEvent se) {

    if (se.getName().equals("orderDetailsMap")) {
      //			System.out.println(" replaced map attribute ");
      // do anything additional apart from updating the map, done
      // elsewhere

      // set a flag attribute for billing updating
      //			@SuppressWarnings("unused")
      //			Map<User, List<OrderDetails>> mapOfOrders = (HashMap<User, List<OrderDetails>>) (se
      //					.getSession().getAttribute("orderDetailsMap"));

      //			System.out.println(" replaced map attribute ");
    }

    if (se.getName().equals("orderDetailsMap")) {
      if (!se.getSession().isNew()) {
        //				System.out.println(" replaced map attribute ");
        @SuppressWarnings("unchecked")
        Map<User, List<OrderDetails>> mapOfOrders =
            (HashMap<User, List<OrderDetails>>) (se.getSession().getAttribute("orderDetailsMap"));

        //				OrderDetails orderDetails = new OrderDetails();
        // mapOfOrders.put(user,orderDetails);
        se.getSession().setAttribute("orderDetailsMap", mapOfOrders);
        //				System.out.println(" session attribute replaced, map size "
        //						+ mapOfOrders.size());
      }
    }
  }
Beispiel #2
0
 @Override
 public void attributeReplaced(final HttpSessionBindingEvent se) {
   se.getSession()
       .getServletContext()
       .log(
           "Session Attribute replaced (session id="
               + se.getSession().getId()
               + ") "
               + se.getName()
               + "="
               + se.getValue());
 }
Beispiel #3
0
  /*
   * (non-Javadoc)
   *
   * @see
   * javax.servlet.http.HttpSessionBindingListener#valueUnbound(javax.servlet
   * .http.HttpSessionBindingEvent)
   */
  public void valueUnbound(HttpSessionBindingEvent event) {
    // 刷新页面的时候,TSysUser为null,所以要判断一下
    LoginUserVO user = (LoginUserVO) event.getValue();
    if (user != null) {
      /** ********************** UniId begin ******************************** */
      // 通知统一身份认证服务中心。此处的实现是通过数据库
      boolean singleLogin =
          PropDbUtil.getBoolean(IdConstants.SINGLE_LOGIN); // 是否开启了同一用户同一时间所有节点上只能登录一个的要求
      if (singleLogin) {
        String sql = SQLConfigUtil.getSql("sql.loginUserVO.delete");
        DBUtil.executeSQL(sql, user.getUserloginid()); // 移除在线用户表中用户信息
      }
      /** ********************** UniId end ******************************** */
      onlineUsers.remove(event.getSession().getId());
      if (LOG.isInfoEnabled()) {
        LOG.info(
            user.getUsername()
                + "[账号:"
                + user.getUserloginid()
                + "]"
                + " 退出系统"
                + ",目前有"
                + getCurrentOnlineCount()
                + "个用户已登录");
      }

    } else {
      if (LOG.isInfoEnabled()) {
        LOG.info(" 一个用户刷新系统" + ",目前有" + getCurrentOnlineCount() + "个用户已登录");
      }
    }
  }
Beispiel #4
0
  /*
   * (non-Javadoc)
   *
   * @see
   * javax.servlet.http.HttpSessionBindingListener#valueBound(javax.servlet
   * .http.HttpSessionBindingEvent)
   */
  public void valueBound(HttpSessionBindingEvent event) {

    LoginUserVO user = (LoginUserVO) event.getValue();
    onlineUsers.put(event.getSession().getId(), user);
    if (LOG.isInfoEnabled()) {
      LOG.info(
          user.getUsername()
              + "[账号:"
              + user.getUserloginid()
              + "]"
              + " 登录系统"
              + ",目前有"
              + getCurrentOnlineCount()
              + "个用户已登录");
    }

    /** ********************** UniId begin ******************************** */
    // 通知统一身份认证服务中心。此处的实现是通过数据库
    boolean singleLogin =
        PropDbUtil.getBoolean(IdConstants.SINGLE_LOGIN); // 是否开启了同一用户同一时间所有节点上只能登录一个的要求
    if (singleLogin) {
      try {
        String sql = SQLConfigUtil.getSql("sql.loginUserVO.count");
        int onlineNum = DBUtil.count(sql, getUserloginid());
        if (onlineNum == 0) {
          sql = SQLConfigUtil.getSql("sql.loginUserVO.insert");
          DBUtil.executeSQL(
              sql, getUserloginid(), getClientIP(), getServerIP(), DateUtil.currentTime());
        }
      } catch (SQLException e) {
        LOG.error(e);
      }
    }
    /** ********************** UniId end ******************************** */
  }
 /**
  * This method is invoked when an attribute is replaced in the ServletContext object
  *
  * @param event Description of the Parameter
  */
 public void attributeReplaced(HttpSessionBindingEvent event) {
   // This event has a handle to the old User object
   ServletContext context = event.getSession().getServletContext();
   // The user has logged in
   if ("User".equals(event.getName())) {
     UserBean thisUser = (UserBean) event.getValue();
     thisUser.setSessionId(event.getSession().getId());
     Tracker tracker =
         ((SystemStatus)
                 ((Hashtable) context.getAttribute("SystemStatus"))
                     .get(thisUser.getConnectionElement().getUrl()))
             .getTracker();
     tracker.remove(event.getSession().getId());
     tracker.add(thisUser.getSessionId(), thisUser);
   }
 }
 public void attributeReplaced(HttpSessionBindingEvent evt) {
   final String name = evt.getName();
   if (!shallIgnore(name)) {
     final Session sess = Sessions.getCurrent();
     if (sess instanceof SimpleSession && evt.getSession().equals(sess.getNativeSession()))
       ((SimpleSession) sess).getScopeListeners().notifyReplaced(name, evt.getValue());
   }
 }
Beispiel #7
0
  /** {@inheritDoc} */
  @Override
  public void attributeReplaced(HttpSessionBindingEvent event) {
    if (event.getName().equals(EVENT_KEY) && !isAnonymous()) {
      Authentication auth = ((SecurityContext) event.getValue()).getAuthentication();

      if (auth != null && auth.getPrincipal() instanceof User) {
        addUser((User) auth.getPrincipal(), event.getSession().getServletContext());
      }
    }
  }
Beispiel #8
0
 /**
  * Seems like it called after our listeners was unbounded from http session. Looks like view scope
  * it destroyed. But should we call callback or not is a big question.
  *
  * @see HttpSessionBindingListener for more details
  */
 @Override
 public void valueUnbound(HttpSessionBindingEvent event) {
   // logger.trace("Session event unbound " + event.getName());
   final Set<ViewScopeViewMapListener> listeners;
   synchronized (sessionToListeners) {
     if (sessionToListeners.containsKey(event.getSession())) {
       listeners = sessionToListeners.get(event.getSession());
       sessionToListeners.remove(event.getSession());
     } else {
       listeners = null;
     }
   }
   if (listeners != null) {
     // I just hope that JSF context already done this job
     for (ViewScopeViewMapListener listener : listeners) {
       // As long as our callbacks can run only once - this is not such big deal
       listener.doCallback();
     }
   }
 }
 private void checkAttribute(
     HttpSessionBindingEvent event,
     String orderAttributeName,
     String keyItemName,
     String message) {
   String currentAttributeName = event.getName();
   String currentItemName = (String) event.getValue();
   if (currentAttributeName.equals(orderAttributeName) && currentItemName.equals(keyItemName)) {
     ServletContext context = event.getSession().getServletContext();
     context.log("Customer" + message + keyItemName + ".");
   }
 }
 /**
  * This method is invoked when an attribute is added to the ServletContext object
  *
  * @param event Description of the Parameter
  */
 public void attributeAdded(HttpSessionBindingEvent event) {
   ServletContext context = event.getSession().getServletContext();
   if ("User".equals(event.getName())) {
     // A user session has been created, can be a portal user or system user
     UserBean thisUser = (UserBean) event.getValue();
     thisUser.setSessionId(event.getSession().getId());
     // Track website users
     Hashtable systems = (Hashtable) context.getAttribute("SystemStatus");
     if (systems != null && thisUser.getConnectionElement() != null) {
       SystemStatus systemStatus =
           (SystemStatus) systems.get(thisUser.getConnectionElement().getUrl());
       if (systemStatus != null) {
         Tracker tracker =
             ((SystemStatus)
                     ((Hashtable) context.getAttribute("SystemStatus"))
                         .get(thisUser.getConnectionElement().getUrl()))
                 .getTracker();
         tracker.add(thisUser.getSessionId(), thisUser);
       }
     }
   }
 }
Beispiel #11
0
  public void attributeAdded(HttpSessionBindingEvent se) {

    HttpSession session = se.getSession();

    String attributeName = se.getName();
    if (attributeName.equals("orderDetailsMap")) {
      //			System.out.println(" session attribute is " + attributeName);
      //			System.out.println(" session id retrieved says : - "
      //					+ session.getId());
      //			System.out
      //					.println(" session id is New says : - " + session.isNew());

      // new user session -- set session id as the User identifier
      // only for the first time of session
      User user = new User(se.getSession().getId());
      List<OrderDetails> orderDetailsList = new ArrayList<OrderDetails>();
      Map<User, List<OrderDetails>> mapOfOrders = new HashMap<User, List<OrderDetails>>();
      mapOfOrders.put(user, orderDetailsList);
      se.getSession().setAttribute("orderDetailsMap", mapOfOrders);
      //			System.out.println(" attribute added, map size "
      //					+ mapOfOrders.size());
    }
  }
 /**
  * This method is invoked when an attribute is removed from the ServletContext object
  *
  * @param se Description of the Parameter
  */
 public void attributeRemoved(HttpSessionBindingEvent se) {
   ServletContext context = se.getSession().getServletContext();
   try {
     if (se.getName().equals("User")) {
       UserBean thisUser = (UserBean) se.getValue();
       if (thisUser != null) {
         // Internal SessionManager
         int userId = thisUser.getActualUserId();
         if (userId > -2) {
           // If context reloaded, then SystemStatus is null, but user is valid
           Hashtable systems = (Hashtable) context.getAttribute("SystemStatus");
           if (systems != null) {
             SystemStatus systemStatus =
                 (SystemStatus) systems.get(thisUser.getConnectionElement().getUrl());
             if (systemStatus != null) {
               // Remove the user from the session if it already is there
               SessionManager thisManager = systemStatus.getSessionManager();
               if (thisManager != null) {
                 UserSession thisSession = thisManager.getUserSession(userId);
                 if (thisSession != null && thisSession.getId().equals(thisUser.getSessionId())) {
                   if (System.getProperty("DEBUG") != null) {
                     System.out.println(
                         "ContextSessionListener-> Session for user " + userId + " ended");
                   }
                   thisManager.removeUser(userId);
                   if (System.getProperty("DEBUG") != null) {
                     System.out.println(
                         "ContextSessionListener-> User removed from valid user list");
                   }
                 }
               }
               // Website Tracker
               Tracker tracker = systemStatus.getTracker();
               tracker.remove(thisUser.getSessionId());
             }
           }
         }
       }
     }
   } catch (Exception e) {
     e.printStackTrace(System.out);
     System.out.println("ContextSessionListener-> attributeRemoved Error: " + e.toString());
   }
 }
Beispiel #13
0
 @Override
 public void valueUnbound(HttpSessionBindingEvent event) {
   WebContext.<Map<String, String>>getBean("loginHolderMap").remove(event.getSession().getId());
 }
 @Override
 public void attributeReplaced(HttpSessionBindingEvent event) {
   event.getSession().getServletContext().removeAttribute(event.getName());
   event.getSession().getServletContext().setAttribute(event.getName(), event.getValue());
 }
 public void valueUnbound(HttpSessionBindingEvent evt) {
   Debug.info("TT Session value unbound ... " + evt.getSession().getId());
 }
 @Override
 public void attributeReplaced(HttpSessionBindingEvent _event) {
   String sessionID = _event.getSession().getId();
 }
 /*
  * Оставлено для подстраховочной очистки ресурсов (закрытия соединений с БД)
  */
 @Override
 public void valueUnbound(HttpSessionBindingEvent bindingEvent) {
   if (JEP_SECURITY_MODULE_ATTRIBUTE_NAME.equals(bindingEvent.getName())) {
     onExpiredSession(bindingEvent.getSession().getId());
   }
 }