Package NTNU.IDATT1002.utils
Class Authentication
java.lang.Object
NTNU.IDATT1002.utils.Authentication
public class Authentication
extends java.lang.Object
Handles the authentication logic for user login and signup
- Version:
- 1.0 06.04.20
- Author:
- madslun
-
Field Summary
Fields Modifier and Type Field Description static java.util.Random
r
-
Constructor Summary
Constructors Constructor Description Authentication()
-
Method Summary
Modifier and Type Method Description static boolean
isCorrectPassword(java.lang.String salt, java.lang.String password, java.lang.String expectedHash)
Gets hash and salt from database with the salt Hashes input password with same algorithm and salt as when created Compares the expected hash and the new hashstatic java.util.ArrayList<java.lang.String>
setPassword(java.lang.String password)
Hashes password with salt from getSalt method
-
Field Details
-
r
public static java.util.Random r
-
-
Constructor Details
-
Authentication
public Authentication()
-
-
Method Details
-
setPassword
public static java.util.ArrayList<java.lang.String> setPassword(java.lang.String password)Hashes password with salt from getSalt method- Parameters:
password
- desired password as input- Returns:
- hashed password
-
isCorrectPassword
public static boolean isCorrectPassword(java.lang.String salt, java.lang.String password, java.lang.String expectedHash)Gets hash and salt from database with the salt Hashes input password with same algorithm and salt as when created Compares the expected hash and the new hash- Parameters:
salt
- to get the stored hash on give userpassword
- that will be hashed and compared to original hash- Returns:
- boolean of whether the hashes are similiar or not
-