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

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


    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);
View Full Code Here


    return result;
  }
 
  private void loginViaOAuth2(Map<String, String> params, long serverId) throws IOException, NoSuchAlgorithmException {
    UserDao userDao = getBean(UserDao.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.getByName(login, Type.oauth);
    // 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);
View Full Code Here

TOP

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

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.