Interface User


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

    Modifier and Type
    Method
    Description
    Clears the password
     
    static User
    parse(String userPassword)
    Parses a User from a string, containing a username and password with a single ':' as delimiter, i.e.
    char[]
     
    static User
    user(String username)
    Creates a new User with an empty password.
    static User
    user(String username, char[] password)
    Creates a new User.
     
  • 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
    • user

      static User user(String username, char[] 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
    • 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