Exemplo n.º 1
0
  @Override
  public synchronized boolean isPasswordValid(String username, String password) {
    UserModel user = this.users.get(username);

    if (user != null) return user.getPassword().equals(password);

    return false;
  }
Exemplo n.º 2
0
  // sorting
  @Override
  public String getOnlineUsersInAlphabeticalOrder() {
    String users = "";

    for (UserModel user : this.users.values()) {
      if (user.isOnline()) {
        users += String.format("* %s", user.getUserName());
      }
    }

    return users;
  }
Exemplo n.º 3
0
  @Override
  public synchronized void readUsers() {
    for (String userPropertyKey : config.listKeys()) {
      UserProperty property = new UserProperty(userPropertyKey, config.getString(userPropertyKey));

      UserModel user = getUser(property.getUsername());

      if (user == null) user = new UserModel(property.getUsername());

      PropertyMapper mapper = new PropertyMapper<UserModel>(user);

      mapper.map(property.getPropertyName(), property.getPropertyValue());

      users.put(user.getUserName(), user);
    }
  }