Class ManagedUser


  • public class ManagedUser
    extends User
    A User that can be used for Logging in. Managed by the UserService.
    • Constructor Summary

      Constructors 
      Constructor Description
      ManagedUser​(java.lang.String id, java.lang.String name, Role role, byte[] password, byte[] salt)  
      ManagedUser​(java.lang.String id, java.lang.String name, Role role, java.lang.String passwordAsBase64, java.lang.String saltAsBase64)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] hashPassword​(char[] password, byte[] salt, int iterations, int keyLength)
      Hashes a password.
      static byte[] hashPassword​(java.lang.String password, byte[] salt, int iterations, int keyLength)
      Hashes a password.
      static boolean validatePassword​(byte[] password1, byte[] salt, java.lang.String password2)
      Validates if password+salt match the given password.
      boolean validatePassword​(java.lang.String password)
      Validates a given password against the Users password+salt.
      static boolean validatePassword​(java.lang.String passwordAsBase64, java.lang.String saltAsBase64, java.lang.String password)
      Validates if password+salt match the given password.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ManagedUser

        public ManagedUser​(java.lang.String id,
                           java.lang.String name,
                           Role role,
                           java.lang.String passwordAsBase64,
                           java.lang.String saltAsBase64)
      • ManagedUser

        public ManagedUser​(java.lang.String id,
                           java.lang.String name,
                           Role role,
                           byte[] password,
                           byte[] salt)
    • Method Detail

      • validatePassword

        public boolean validatePassword​(java.lang.String password)
        Validates a given password against the Users password+salt.
        Parameters:
        password - the given password
        Returns:
        true if passwords match
      • validatePassword

        public static boolean validatePassword​(java.lang.String passwordAsBase64,
                                               java.lang.String saltAsBase64,
                                               java.lang.String password)
        Validates if password+salt match the given password.
        Parameters:
        passwordAsBase64 - the hashed password
        saltAsBase64 - the salt
        password - the given password
        Returns:
        true if they match.
      • validatePassword

        public static boolean validatePassword​(byte[] password1,
                                               byte[] salt,
                                               java.lang.String password2)
        Validates if password+salt match the given password.
        Parameters:
        password1 - the hashed password
        salt - the salt
        password2 - the given password
        Returns:
        true if they match.
      • hashPassword

        public static byte[] hashPassword​(java.lang.String password,
                                          byte[] salt,
                                          int iterations,
                                          int keyLength)
        Hashes a password. Source: https://www.owasp.org/index.php/Hashing_Java.
        Parameters:
        password - the password
        salt - the salt
        iterations - the number of iterations
        keyLength - the length of the key
        Returns:
        the hashed password
      • hashPassword

        public static byte[] hashPassword​(char[] password,
                                          byte[] salt,
                                          int iterations,
                                          int keyLength)
        Hashes a password. Source: https://www.owasp.org/index.php/Hashing_Java.
        Parameters:
        password - the password
        salt - the salt
        iterations - the number of iterations
        keyLength - the length of the key
        Returns:
        the hashed password