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:
-
Method Summary
-
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
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
Creates a new User.- Parameters:
username
- the usernamepassword
- the password- Returns:
- a new User
- Throws:
IllegalArgumentException
- in case username is an empty string
-
parse
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
-