Class User
java.lang.Object
edu.ntnu.idatt1002.g106.handballapp.finalprod.backend.User
- Direct Known Subclasses:
Administrator
Represents a user of the application
- Author:
- Gruppe 6
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
changePassword
(String oldPassword, String newPassword) This method changes a User's password to a new given password.byte[]
Generates a salt, for hashinggetEmail()
Gets user EmailGets first name os userGets last name of userGets hashed user passwordbyte[]
getSalt()
Gets salt for hashing passwordsThis method retrieves the tournament register.hashPassword
(String password, byte[] salt) Method to hash a password with saltvoid
Sets new user Emailvoid
setFirstName
(String firstName) Sets first name of uservoid
setLastName
(String lastName) Sets last name of uservoid
setPassword
(String password) Hashes and sets new user password
-
Field Details
-
tournamentRegister
-
emailPattern
-
firstName
-
lastName
-
password
-
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 StringlastName
- Last name of user as Stringpassword
- User password as Stringemail
- User Email as String- Throws:
NullPointerException
-
-
Method Details
-
getFirstName
Gets first name os user- Returns:
- first name of user as String
-
setFirstName
Sets first name of user- Parameters:
firstName
- new first name
-
getLastName
Gets last name of user- Returns:
- last name of user as String
-
setLastName
Sets last name of user- Parameters:
lastName
- new last name as String
-
getPassword
Gets hashed user password- Returns:
- hashed user password as String
-
setPassword
Hashes and sets new user password- Parameters:
password
- new password as String
-
getEmail
Gets user Email- Returns:
- user Email as String
-
setEmail
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
This method retrieves the tournament register.- Returns:
- The tournament register
-
changePassword
This method changes a User's password to a new given password.- Parameters:
oldPassword
- The User's old password, represented as a StringnewPassword
- 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
Method to hash a password with salt- Parameters:
password
- password to be hashedsalt
- salt to use when hashing- Returns:
- hashedPassword, null if unsuccessful
-