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 hash
    static java.util.ArrayList<java.lang.String> setPassword​(java.lang.String password)
    Hashes password with salt from getSalt method

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • r

      public static java.util.Random r
  • Constructor Details

  • 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 user
      password - that will be hashed and compared to original hash
      Returns:
      boolean of whether the hashes are similiar or not