java.lang.Object
edu.ntnu.idatt1002.g106.handballapp.finalprod.backend.User
Direct Known Subclasses:
Administrator

public class User extends Object
Represents a user of the application
Author:
Gruppe 6
  • Field Details

    • tournamentRegister

      private TournamentRegister tournamentRegister
    • emailPattern

      private final Pattern emailPattern
    • firstName

      private String firstName
    • lastName

      private String lastName
    • password

      private String password
    • email

      private String email
    • salt

      private byte[] salt
  • Constructor Details

    • User

      public User(String firstName, String lastName, String password, String email) throws NullPointerException
      Initializes a User object
      Parameters:
      firstName - First name of user as String
      lastName - Last name of user as String
      password - User password as String
      email - User Email as String
      Throws:
      NullPointerException
  • Method Details

    • getFirstName

      public String getFirstName()
      Gets first name os user
      Returns:
      first name of user as String
    • setFirstName

      public void setFirstName(String firstName)
      Sets first name of user
      Parameters:
      firstName - new first name
    • getLastName

      public String getLastName()
      Gets last name of user
      Returns:
      last name of user as String
    • setLastName

      public void setLastName(String lastName)
      Sets last name of user
      Parameters:
      lastName - new last name as String
    • getPassword

      public String getPassword()
      Gets hashed user password
      Returns:
      hashed user password as String
    • setPassword

      public void setPassword(String password)
      Hashes and sets new user password
      Parameters:
      password - new password as String
    • getEmail

      public String getEmail()
      Gets user Email
      Returns:
      user Email as String
    • setEmail

      public void setEmail(String email)
      Sets new user Email
      Parameters:
      email - new Email as String
    • getSalt

      public byte[] getSalt()
      Gets salt for hashing passwords
      Returns:
      salt as byte array
    • getTournamentRegister

      public TournamentRegister getTournamentRegister()
      This method retrieves the tournament register.
      Returns:
      The tournament register
    • changePassword

      public boolean changePassword(String oldPassword, String newPassword)
      This method changes a User's password to a new given password.
      Parameters:
      oldPassword - The User's old password, represented as a String
      newPassword - The User's new password, represented as a String
      Returns:
      Status of whether the password was successfully changed, true if it was, false if else
    • generateSalt

      public byte[] generateSalt()
      Generates a salt, for hashing
      Returns:
      a random salt
    • hashPassword

      public String hashPassword(String password, byte[] salt)
      Method to hash a password with salt
      Parameters:
      password - password to be hashed
      salt - salt to use when hashing
      Returns:
      hashedPassword, null if unsuccessful