Package org.openqreg.bean

Examples of org.openqreg.bean.User


   */
  public String getListOfActiveUsers() {
    this.getReadLockUserTable();
    try {
      String users = new String();
      User u = null;
      for (Iterator<User> e = currentUsers.values().iterator(); e
          .hasNext();) {
        u = e.next();
        // if current user is active increase nr with one
        if ((new Date().getTime() - u.getLastActivityTimeStamp()
            .getTime()) < (maxInactiveTime * 60000)) {
          users = users + u.getId() + ", ";
        }
      }
      return users;
    } finally {
      this.releaseReadLockUserTable();
View Full Code Here


        disp.logToAccessLog(req, answer, "loginUser");
        return answer;

      }

      User userDB = disp.findUser(userId);

      // if user exists it is a relogin....
      if (disp.currentUsers.get(userId) == null) {
        answer.setRelogin(false);
      } else {
        answer.setRelogin(true);
      }
      // if more than our loginwaittimeout we reset logintimedoubler
      GregorianCalendar calendar = new GregorianCalendar();
      calendar.add(Calendar.MINUTE, -disp.loginWaitTimeOut);
      if (disp.currentFailedUsers.containsKey(userId)) {
        if (Dispatcher.logger.isDebugEnabled()) {
          Dispatcher.logger.log(
              Level.DEBUG,
              "calendar: "
                  + new SimpleDateFormat(
                      "yyyy-MM-dd HH:mm:ss")
                      .format(calendar.getTime()));
          Dispatcher.logger
              .log(Level.DEBUG,
                  "usercalendar: "
                      + new SimpleDateFormat(
                          "yyyy-MM-dd HH:mm:ss")
                          .format(((Calendar) disp.currentFailedUsers
                              .get(userId)
                              .getCalendar())
                              .getTime()));
          Dispatcher.logger.log(
              Level.DEBUG,
              "after: "
                  + calendar.after(disp.currentFailedUsers
                      .get(userId).getCalendar()));
        }
      }
      if (disp.currentFailedUsers.containsKey(userId)
          && calendar.after(disp.currentFailedUsers.get(userId)
              .getCalendar())) {
        disp.currentFailedUsers.remove(userId);
        // currentFailedUsers.put(userId,new LoginWait());
        if (Dispatcher.logger.isDebugEnabled()) {
          Dispatcher.logger.log(Level.DEBUG,
              "loginUser():  reset user ");
        }

      }

      // if to many tries no entry
      if (disp.currentFailedUsers.containsKey(userId)
          && disp.currentFailedUsers.get(userId).getNoOfWrongTries() > 10) {
        answer.setStatus(LoginAnswer.FAILED);
        answer.setInfo("To many tries");
        answer.getFetch().removeValue("PASSWORD");
        // log to accessLog
        disp.logToAccessLog(req, answer, "loginUser");
        return answer;
      }

      // wrong password
      if (null == userDB
          || !disp.passy
              .compareHashes(passWord, userDB.getPassword())) {
        // double wait time on wrong password.... holds thread for wait
        // time
        disp.doubleLoginWait(userId);

        // create answer
        answer.setLoginWait(disp.currentFailedUsers.get(userId)
            .getWait().intValue());
        answer.setStatus(LoginAnswer.FAILED);
        answer.setInfo("no match for username password in db");
        answer.getFetch().removeValue("PASSWORD");
        // log to accessLog
        disp.logToAccessLog(req, answer, "loginUser");
        return answer;
      }

      // no user with our userid in the internal user holder currentUsers
      if (disp.currentUsers.get(userId) == null) {
        // if we need to change password expired or forced
        if ((userDB.getTspassword() != null && ((new Date().getTime() / 1000) - (userDB
            .getTspassword().getTime() / 1000)) > disp
            .getPasswordLifeLength() * 60 * 60 * 24)
            || new Integer(1).equals(userDB.getChangepassword())) {
          // create answer
          answer.setStatus("changepassword");
          answer.setInfo("user needs to change password");
          // there is never any reason to return a password to
          // the client
          answer.getFetch().removeValue("PASSWORD");
          // log to accessLog
          disp.logToAccessLog(req, answer, "loginUser");
          return answer;
        }
        // !!!!!!!!!!!!!!!!!creating new
        // user!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        if (Dispatcher.logger.isDebugEnabled()) {
          Dispatcher.logger.log(Level.DEBUG,
              "loginUser(): creating new user: " + userId);
        }

        disp.getWriteLockUserTable();
        // currentUsers.put(userId, createUser());
        disp.currentUsers.put(userId, disp.findUser(userId));

        try {
          // populate the user
          User user = disp.currentUsers.get(userId);

          // Is the User on an active centre?
          if (!new Integer(1).equals(disp.getCentre(
              user.getCentreid()).getStatus())) {
            // Users centre is inactive, try to find an active one
            Map<String, UsercentrerelBean> ucrMap = null;
            ucrMap = UsercentrerelFinder.findByUseridReturnMap(user
                .getId());
            Iterator<String> it = ucrMap.keySet().iterator();
            UsercentrerelBean ucrBean = null;
            String tempCentreid = null;
            while (it.hasNext()) { // Loop users all centres
              tempCentreid = it.next();
              ucrBean = ucrMap.get(tempCentreid);
              if (new Integer(1).equals(ucrBean.getStatus())) {
                Dispatcher.logger.log(
                    Level.INFO,
                    "loginUser(): users centre inactive: "
                        + user.getCentreid()
                        + ", moved to: "
                        + ucrBean.getCentreid()
                        + ", userid: " + userId);
                // Active centre found, set info to user
                user.setCentreid(ucrBean.getCentreid());
                user.setGroupid(ucrBean.getGroupid());
                break;
              }
            }
          }
          user.setPrevTslastlogin(user.getTslastlogin());
          user.setTslastlogin(new Timestamp(System
              .currentTimeMillis()));
          ((UserBean) user).store();
          user.setLastActivityTimeStamp();
          /*
           * current session id is used to prevent problem when
           * restarting server and logging in from old sessionid
           */
          user.setSessionId(req.getSession().getId());

          // Set user's default sortlist from dispatcher's
          // list
          disp.setStandardSortOrder(user);

          // we set users donelogin to true as we have done a
          // login or relogin
          user.setFromPage("login.jsp");
          // new user should be sent to start, or something...
          answer.setReturnToPage(disp.getUserReturnToPage(user));
          if (isAjaxLogin) {
            // ajaxlogin can be on any page, set its name
            user.setFromPage(thisPageName);
          } else {
            // if loginpage login
            user.setDoneLogin(true);
          }
          // removes user from currentFailedUsers on successfull
          // login
          if (disp.currentFailedUsers.containsKey(userId)) {
            disp.currentFailedUsers.remove(userId);
          }

          // create answer
          // answer.setUserId(userId);
          answer.setStatus("loggedin");
          answer.setInfo("new user created");

        } finally {
          disp.releaseWriteLockUserTable();
        }
        if (Dispatcher.logger.isDebugEnabled()) {
          Dispatcher.logger.log(Level.DEBUG,
              "loginUser() new user complete: " + userId);
        }

      } else {
        // user exists in currentUsers
        User u = disp.currentUsers.get(userId);
        // update timestamp in user...
        u.setLastActivityTimeStamp();

        u.setSessionId(req.getSession().getId());
        // we set users frompage to login.jsp as we have done a
        // login or
        // relogin saving frompage in answer
        answer.setReturnToPage(u.getFromPage());
        if (!isAjaxLogin) {
          u.setDoneLogin(true);
        }
        // removes user from currentFailedUsers on successfull
        // login
        if (disp.currentFailedUsers.containsKey(userId)) {
          disp.currentFailedUsers.remove(userId);
        }

        // creating answer
        answer.setStatus("loggedin");
        answer.setInfo("old user checked password successfully");
        answer.setFetch(u.getFetch());
      }

      // there is never any reason to return a password to the client
      if (null != answer.getFetch()) {
        answer.getFetch().removeValue("PASSWORD");
View Full Code Here

          .getTranslation(langId, "ADMINUSERCENTREREL_DOUBLE_M");
      return;
    }

    // tempUser = the user we are inviting
    User tempUser = (User) UserFinderBase.findByPrimaryKey(con,
        new UserKey(userId));

    // user does not exist
    if (tempUser == null) {
      ucrBean = null;
      message = lang.getTranslation(langId,
          "ADMINUSERCENTREREL_NO_SUCH_USER_M");
      return;
    }

    // tempUser is nonUcr, can not be invited
    if (Integer.valueOf(0).equals(
        ((Usergroup) UsergroupFinderBase.findByPrimaryKey(con,
            new UsergroupKey(tempUser.getGroupid()))).getUseucr())) {
      ucrBean = null;
      message = lang.getTranslation(langId,
          "ADMINUSERCENTREREL_NO_ACCESS_M");
      return;
    }
View Full Code Here

      uga.setStatus(AjaxWidgetAnswer.STATUS_NOSERVICE);
      return uga;
    }

    // we have access carry on...
     User user = Dispatcher.getInstance().getUser(userId);
   
    //add default answer text, listboxtexts, guisettings, containers
    addDefaultAnswer(user, ugr, uga);
   
    // sa.setStatus("fetched");
View Full Code Here

    if (!Dispatcher.getInstance().checkAccess(userId, userGroup)) {
      // no userGroup, return that :)
      uga.setStatus(AjaxWidgetAnswer.STATUS_NOSERVICE);
      return uga;
    }
    User user = Dispatcher.getInstance().getUser(userId);
    // we have access carry on...
    UsergroupBean userGroupBean = ugr.getUserGroup();
    Collection<String> groupRelations = ugr.getGroupRelations();
    uga.setUserGroup(userGroupBean);
    Connection con = null;
View Full Code Here

  public AjaxWidgetListAnswer findByCountryIdAndSearchOthers(String userId,
      AjaxWidgetListRequest awlr) throws SQLException, NoServiceException {
    String service = "ADMINCENTRE_PAGE";
    if (hasService(userId, service)) {
     
      User user = Dispatcher.getInstance().getUser(userId);

      AjaxWidgetListAnswer awla = addDefaultAnswer(user, awlr, "centrenameList");
     
      Centre centre = Dispatcher.getInstance().getCentre(
          user.getCentreid());
      String countryId = centre.getCountryid();
      String centreValue = getOtherAsString(awlr, "centreValue");
      Collection<CentreBean> col = CentreFinder
          .findByCountryIdAndSearchOthers(user, 100, countryId,
              centreValue);
View Full Code Here

      awa.setStatus(AjaxWidgetAnswer.STATUS_NOSERVICE);
      return awa;
    }

    // we have access carry on...
    User user = Dispatcher.getInstance().getUser(userId);

    // add default answer text, listboxtexts, guisettings, containers
    addDefaultAnswer(user, awr, awa);

    return awa;
View Full Code Here

      fsa.setStatus(AjaxWidgetAnswer.STATUS_NOSERVICE);
      return fsa;
    }

    // we have access carry on...
    User user = Dispatcher.getInstance().getUser(userId);

    // add default answer text, listboxtexts, guisettings, containers
    addDefaultAnswer(user, fsr, fsa);

    fsa.setStatus(AjaxWidgetAnswer.STATUS_FETCHED);

    Collection<FileBean> col = FileFinder.findByOwner(user.getId());
    for (FileBean fb : col) {
      fb.setFileShareUserCol(FileshareuserFinder.findByFileid(fb.getId()));
    }
    fsa.setFileList(col);
View Full Code Here

    if (!Dispatcher.getInstance().checkAccess(userId, service)) {
      // no service, return that :)
      fsa.setStatus(AjaxWidgetAnswer.STATUS_NOSERVICE);
      return fsa;
    }
    User user = Dispatcher.getInstance().getUser(userId);
    // we have access carry on...
    FileBean fileBean = fsr.getFile();
    Collection<String> fileShareUsers = fsr.getFileShareUsers();
    fsa.setFile(fileBean);
    Connection con = null;
    try {
      try {
        // add default answer text, listboxtexts, guisettings,
        // containers
        addDefaultAnswer(user, fsr, fsa);

        con = DbHandler.getConnection();
        con.setAutoCommit(false);
        fileBean.setUpdatedby(userId);
        fileBean.setTsupdated(new Timestamp(System.currentTimeMillis()));
        fileBean.store(con);

        // service groups
        Collection<FileshareuserBean> col = FileshareuserFinder
            .findByFileid(con, fileBean.getId());
        // loop exsisting FileshareuserBean update or remove based on
        // status
        for (FileshareuserBean fsuBean : col) {
          if (!fileShareUsers.contains(fsuBean.getUserid())) {
            fsuBean.remove(con);
          }
          fileShareUsers.remove(fsuBean.getUserid());
        }
        User fileUser;
        // loop remaining services and create them
        for (String uId : fileShareUsers) {
          FileshareuserBean fsuBean = new FileshareuserBean();
          fsuBean.setFileid(fileBean.getId());
          fsuBean.setUserid(uId);
          fileUser = (User) UserFinderBase
              .findByPrimaryKey(new UserKey(uId));
          if (null != fileUser) {
            //set correct label ending up on switch
            fsuBean.setUserdescription(fileUser.getFirstname()
                + " " + fileUser.getLastname());
          }
          fsuBean.create(con);
        }
        con.commit();
        // sa.setStatus(AjaxWidgetAnswer.STATUS_UPDATED);
View Full Code Here

  public static AjaxGUIAnswer getContainer(String userId,
      Collection<String> containerIds, String langId,
      Collection<String> services, boolean overRide) {

    User u = Dispatcher.getInstance().getUser(userId);

    TreeMap<String, String> serviceMap = new TreeMap<String, String>();
    // read incoming services, yes these can be changed by an evil user,
    // but all they get then is a gui component that they could create
    // themselves
View Full Code Here

TOP

Related Classes of org.openqreg.bean.User

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.