Esempio n. 1
0
  public List<User> getAll() {

    try {

      connection = connectionFactory.getConnection();

      String sql = "SELECT * FROM eeproject.Login;";
      Statement statement = connection.createStatement();

      ResultSet rs = statement.executeQuery(sql);

      while (rs.next()) {
        User user = new User();
        user.setUsername(rs.getString(1));
        user.setPassword(rs.getString(2));

        LOG.log(Level.INFO, "User: "******"List size: " + list.size());
      }

    } catch (SQLException ex) {
      LOG.log(Level.SEVERE, null, ex);
    } finally {
      connectionFactory.closeConnection();
      LOG.log(Level.INFO, "Connection closed");
    }

    return list;
  }
Esempio n. 2
0
  @Override
  public boolean isValidUsernameAndPassword(String username, String password) {
    list = getAll();
    if (username != null || password != null) {
      LOG.log(Level.INFO, " Login: "******" Password:"******" List size: " + list.size());
      for (int i = 0; i < list.size(); i++) {

        User user = list.get(i);
        LOG.log(Level.INFO, " Users: " + user.toString());
        if (user.getUsername().equals(username) && user.getPassword().equals(password)) {
          return true;
        }
      }
    }
    return false;
  }
Esempio n. 3
0
 public void testToString() throws Exception {
   assertEquals("admin", u.toString());
 }