Package org.apache.openmeetings.db.dao.user

Examples of org.apache.openmeetings.db.dao.user.AdminUserDao


      SessiondataDao sessionDao = getBean(SessiondataDao.class);
      Sessiondata sd = sessionDao.getSessionByHash(soapLogin.getSessionHash());
      if (sd != null && sd.getSessionXml() != null) {
        RemoteSessionObject remoteUser = RemoteSessionObject.fromXml(sd.getSessionXml());
        if (remoteUser != null && !Strings.isEmpty(remoteUser.getExternalUserId())) {
          AdminUserDao userDao = getBean(AdminUserDao.class);
          User user = userDao.getExternalUser(remoteUser.getExternalUserId(), remoteUser.getExternalUserType());
          if (user == null) {
            user = userDao.getNewUserInstance(null);
            user.setFirstname(remoteUser.getFirstname());
            user.setLastname(remoteUser.getLastname());
            user.setLogin(remoteUser.getUsername()); //FIXME check if login UNIQUE
            user.setExternalUserId(remoteUser.getExternalUserId());
            user.setExternalUserType(remoteUser.getExternalUserType());
            user.getAdresses().setEmail(remoteUser.getEmail());
            user.setPictureuri(remoteUser.getPictureUrl());
          } else {
            user.setFirstname(remoteUser.getFirstname());
            user.setLastname(remoteUser.getLastname());
            user.setPictureuri(remoteUser.getPictureUrl());
          }
          user = userDao.update(user, null);

          soapLogin.setUsed(true);
          soapLogin.setUseDate(new Date());
          //soapLogin.setClientURL(clientURL); //FIXME
          soapDao.update(soapLogin);
View Full Code Here


        });
      }
     
      @Override
      protected void onValidate() {
        AdminUserDao dao = getBean(AdminUserDao.class);
        String n = nameField.getConvertedInput();
        if (n != null) {
          if (type == Type.email && null == dao.getUserByEmail(n)) {
            error(WebSession.getString(318));
          }
          if (type == Type.login && null == dao.getUserByName(n)) {
            error(WebSession.getString(320));
          }
        }
      }
    });
View Full Code Here

   * @param appLink
   * @return
   */
  private Long resetUser(String email, String username, String appLink) {
    try {
      AdminUserDao userDao = getBean(AdminUserDao.class);
      log.debug("resetUser " + email);

      // check if Mail given
      if (email.length() > 0) {
        // log.debug("getAdresses_id "+addr_e.getAdresses_id());
        User us = userDao.getUserByEmail(email);
        if (us != null) {
          sendHashByUser(us, appLink, userDao);
          return new Long(-4);
        } else {
          return new Long(-9);
        }
      } else if (username.length() > 0) {
        User us = userDao.getUserByName(username);
        if (us != null) {
          sendHashByUser(us, appLink, userDao);
          return new Long(-4);
        } else {
          return new Long(-3);
View Full Code Here

            //Profiles
            File profiles = OmFileHelper.getUploadProfilesDir();
            long invalid = 0;
            long deleted = 0;
            ClassPathXmlApplicationContext ctx = getApplicationContext(ctxName);
            AdminUserDao udao = ctx.getBean(AdminUserDao.class);
            for (File profile : profiles.listFiles()) {
              long pSize = OmFileHelper.getSize(profile);
              long userId = getUserIdByProfile(profile.getName());
              User u = udao.get(userId);
              if (profile.isFile() || userId < 0 || u == null) {
                if (cleanup) {
                  FileHelper.removeRec(profile);
                } else {
                  invalid += pSize;
                }
              } else if (u.getDeleted()) {
                if (cleanup) {
                  FileHelper.removeRec(profile);
                } else {
                  deleted += pSize;
                }
              }
            }
            long missing = 0;
            for (User u : udao.getAllUsersDeleted()) {
              if (!u.getDeleted() && u.getPictureuri() != null && !new File(OmFileHelper.getUploadProfilesUserDir(u.getUser_id()), u.getPictureuri()).exists()) {
                missing++;
              }
            }
            long size = OmFileHelper.getSize(profiles);
View Full Code Here

      SessiondataDao sessionDao = getBean(SessiondataDao.class);
      Sessiondata sd = sessionDao.getSessionByHash(soapLogin.getSessionHash());
      if (sd != null && sd.getSessionXml() != null) {
        RemoteSessionObject remoteUser = RemoteSessionObject.fromXml(sd.getSessionXml());
        if (remoteUser != null && !Strings.isEmpty(remoteUser.getExternalUserId())) {
          AdminUserDao userDao = getBean(AdminUserDao.class);
          User user = userDao.getExternalUser(remoteUser.getExternalUserId(), remoteUser.getExternalUserType());
          if (user == null) {
            user = userDao.getNewUserInstance(null);
            user.setFirstname(remoteUser.getFirstname());
            user.setLastname(remoteUser.getLastname());
            user.setLogin(remoteUser.getUsername()); //FIXME check if login UNIQUE
            user.setExternalUserId(remoteUser.getExternalUserId());
            user.setExternalUserType(remoteUser.getExternalUserType());
            user.getAdresses().setEmail(remoteUser.getEmail());
            user.setPictureuri(remoteUser.getPictureUrl());
          } else {
            user.setFirstname(remoteUser.getFirstname());
            user.setLastname(remoteUser.getLastname());
            user.setPictureuri(remoteUser.getPictureUrl());
          }
          user = userDao.update(user, null);

          soapLogin.setUsed(true);
          soapLogin.setUseDate(new Date());
          //soapLogin.setClientURL(clientURL); //FIXME
          soapDao.update(soapLogin);
View Full Code Here

    }
  }

  @Override
  protected void onNewSubmit(AjaxRequestTarget target, Form<?> form) {
    AdminUserDao usersDaoImpl = getBean(AdminUserDao.class);
    setModelObject(usersDaoImpl.getNewUserInstance(usersDaoImpl.get(getUserId())));
    target.add(this);
    target.appendJavaScript("omUserPanelInit();");
  }
View Full Code Here

    target.appendJavaScript("omUserPanelInit();");
  }

  @Override
  protected void onDeleteSubmit(AjaxRequestTarget target, Form<?> form) {
    AdminUserDao usersDaoImpl = getBean(AdminUserDao.class);
    usersDaoImpl.delete(this.getModelObject(), getUserId());
    this.setModelObject(usersDaoImpl.getNewUserInstance(usersDaoImpl.get(getUserId())));
    target.add(listContainer);
    target.add(this);
    target.appendJavaScript("omUserPanelInit();");
  }
View Full Code Here

        , new OmOrderByBorder<User>("orderByFirstName", "firstname", container)
        , new OmOrderByBorder<User>("orderByLastName", "lastname", container));
    add(container.orderLinks);
    add(navigator);

    AdminUserDao usersDaoImpl = getBean(AdminUserDao.class);
    form = new UserForm("form", listContainer, usersDaoImpl.getNewUserInstance(usersDaoImpl.get(getUserId())), warning);
    form.showNewRecord();
    add(form, warning);
  }
View Full Code Here

    }
    return result;
  }
 
  private void loginViaOAuth2(Map<String, String> params, long serverId) throws IOException, NoSuchAlgorithmException {
    AdminUserDao userDao = getBean(AdminUserDao.class);
    IUserManager userManager = getBean(IUserManager.class);
    ConfigurationDao configurationDao = getBean(ConfigurationDao.class);
    String login = params.get("login");
    String email = params.get("email");
    String lastname = params.get("lastname");
    String firstname = params.get("firstname");
    if (firstname == null) firstname = "";
    if (lastname == null) lastname = "";
    User user = userDao.getUserByName(login);
    // generate random password
    byte[] rawPass = new byte[16];
    Random rnd = new Random();
    for (int i = 0; i < 16; i++) {
      rawPass[i] = (byte) (97 + rnd.nextInt(25));
    }
    String pass = new String(rawPass);
    // check if the user already exists and register new one if it's needed
    if (user == null) {
      Integer defaultlangId = Integer.valueOf(configurationDao.getConfValue("default_lang_id", String.class, "1"));
      String defaultTimezone = configurationDao.getConfValue("default.timezone", String.class, "");   
      Long res = userManager.registerUserNoEmail(login, pass, lastname, firstname, email, null, null,
          null, null, null, 0, null, defaultlangId, null, false, true, defaultTimezone);
      if (res == null || res < 0) {
        throw new RuntimeException("Couldn't register new oauth user");
      }
      user = userDao.get(res);
      user.setExternalUserType("oauth2." + serverId);
      userDao.update(user, null);
    } else { // just change password
      // check user type before changing password, it must be match oauthServerId
      if (!("oauth2." + serverId).equals(user.getExternalUserType())) {
        log.error("User already registered!");
        return;
      }
      user = userDao.update(user, pass, -1);
    }
   
    if (WebSession.get().signIn(login, pass, null)) {
       setResponsePage(Application.get().getHomePage());
    } else {
View Full Code Here

  }

  @Override
  public void submitView(AjaxRequestTarget target, List<User> usersToAdd) {
    // TODO Auto-generated method stub
    AdminUserDao userDao = Application.getBean(AdminUserDao.class);
    Organisation organisation = getModelObject();
    for (User u : usersToAdd) {
      List<Organisation_Users> orgUsers = u.getOrganisation_users();
      boolean found = false;
      for (Organisation_Users ou : orgUsers) {
        if (ou.getOrganisation().getOrganisation_id().equals(organisation.getOrganisation_id())) {
          found = true;
          break;
        }
      }
      if (!found) {
        Organisation_Users orgUser = new Organisation_Users(organisation);
        orgUser.setDeleted(false);
        orgUsers.add(orgUser);
        userDao.update(u, WebSession.getUserId());
      }
    }
    target.add(usersPanel);
  }
View Full Code Here

TOP

Related Classes of org.apache.openmeetings.db.dao.user.AdminUserDao

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.