Пример #1
0
  @Override
  public User getUser(String username) {

    User user = dao.findByUsername(username.toLowerCase());
    if (user != null) {
      if (user.getSif() != null) {
        return user;
      }
      return user;
    }
    return null;
  }
Пример #2
0
  @Override
  public boolean login(String username, String password) {
    log.info(username + " - " + password);

    User user = dao.findByUsername(username.toLowerCase());
    if (user != null) {
      if (user.getPassword() == null) {
        return true;
      }
      return JCrypt.check(password, user.getPassword());
    }
    return false;
  }
Пример #3
0
  @Override
  public List<User> loadUsersByIndustry(int id) {
    List<User> lista = new ArrayList<User>();

    List<User> listaAllUsers = loadAll();
    for (User u : listaAllUsers) {
      if (u.getSif() == null) continue;

      if (id == u.getSif().getEmpresa().getId()) {
        lista.add(u);
      }
    }
    return lista;
  }
Пример #4
0
  @Override
  public int createUser(String name, String username, String password, int perfil) {
    log.debug(username + " " + password + " " + perfil);

    User user = new User();
    user.setUser(username);
    user.setPassword(password);
    user.setGrtUser(name);
    user.setPerfil(userPerfilDao.get(perfil));
    user.setEnabled(1);
    user = dao.saveOrUpdate(user);

    return user.getId();
  }
Пример #5
0
  @Override
  public boolean save(User user) {
    user.setEnabled(1);
    if (user.getPassword().contains("???")) {
      user.setPassword(user.getPassword().substring(3));
    } else {
      user.setPassword(JCrypt.encrypt(user.getPassword()));
    }

    user = dao.saveOrUpdate(user);
    return true;
  }