Interface User


public interface User
Encapsulates a username and password. Factory for User instances. Note that a User instance is mutable as the password can be cleared.
See Also:
  • Field Details

    • MAXIMUM_USERNAME_LENGTH

      static final PropertyValue<Integer> MAXIMUM_USERNAME_LENGTH
      Specifies the maximum allowed username length.
      • Value type: Integer
      • Default value: 256
    • MAXIMUM_PASSWORD_LENGTH

      static final PropertyValue<Integer> MAXIMUM_PASSWORD_LENGTH
      Specifies the maximum allowed password length.
      • Value type: Integer
      • Default value: 1024
  • Method Details

    • username

      String username()
      Returns:
      the username
    • password

      char[] password()
      Returns:
      the password, an empty array in case of an empty password
    • clearPassword

      User clearPassword()
      Clears the password
      Returns:
      this User instance
    • copy

      User copy()
      Returns:
      a copy of this User
    • user

      static User user(String username)
      Creates a new User with an empty password.
      Parameters:
      username - the username
      Returns:
      a new User
      Throws:
      IllegalArgumentException - in case username is an empty string or exceeds MAXIMUM_USERNAME_LENGTH
    • user

      static User user(String username, char @Nullable [] password)
      Creates a new User.
      Parameters:
      username - the username
      password - the password
      Returns:
      a new User
      Throws:
      IllegalArgumentException - in case username is an empty string, username exceeds MAXIMUM_USERNAME_LENGTH, or password exceeds MAXIMUM_PASSWORD_LENGTH
    • parse

      static User parse(String userPassword)
      Parses a User from a string, containing a username and password with a single ':' as delimiter, i.e. "user:pass" or "user:" for en empty password. If no delimiter is found the whole string is assumed to be the username and the password empty. The username portion is trimmed. Any delimeters beyond the initial one are assumed to be part of the password.
      Parameters:
      userPassword - the username and password string
      Returns:
      a User with the given username and password
      Throws:
      IllegalArgumentException - in case the username portion is empty, username exceeds MAXIMUM_USERNAME_LENGTH, or password exceeds MAXIMUM_PASSWORD_LENGTH