Ejemplo n.º 1
0
 /**
  * Creates a new user.
  *
  * @param id The user id.
  * @param name The name of the user.
  * @param hashedPw The hashed password.
  * @param userdata The user data map.
  */
 User(long id, String name, String hashedPw, Map<String, String> userdata, UserBase userBase) {
   this.id = id;
   this.name = name;
   this.hashedPw = hashedPw;
   this.userdata = userdata;
   this.userBase = userBase;
   save();
 }
Ejemplo n.º 2
0
 /**
  * Adds to a counter in the user data.
  *
  * @param name The name of the user data element.
  * @param c The value by which the counter should be increased.
  */
 public void addToUserDataCounter(String name, int c) {
   String value = userdata.get(name);
   if (value == null) {
     userdata.put(name, c + "");
   } else {
     int v;
     try {
       v = new Integer(value);
     } catch (NumberFormatException ex) {
       v = 0;
     }
     userdata.put(name, (v + c) + "");
   }
   save();
 }
Ejemplo n.º 3
0
 /**
  * Changes the password for the user.
  *
  * @param oldPw The old password in plain text.
  * @param newPw The new password in plain text.
  */
 public void changePassword(String oldPw, String newPw) {
   if (!isCorrectPassword(oldPw)) return;
   hashedPw = getPasswordHash(newPw);
   save();
 }
Ejemplo n.º 4
0
 /**
  * Sets the user data element with the respective name.
  *
  * @param name The name of the user data element.
  * @param value The value to be set.
  */
 public void setUserData(String name, String value) {
   userdata.put(name, value);
   save();
 }