Interface UserInfo

All Superinterfaces:
Normalisable<UserInfo>, org.wiremock.stringparser.ParsedString, PercentEncoded<UserInfo>

public interface UserInfo extends PercentEncoded<UserInfo>, org.wiremock.stringparser.ParsedString
Represents the user information component of a URI authority as defined in RFC 3986 Section 3.2.1.

User information typically consists of a username and optional password in the form username[:password]. It appears before the host in a URI, separated by an @ symbol.

Security Note: Including passwords in URIs is deprecated due to security concerns. Most modern protocols discourage this practice.

Implementations must be immutable and thread-safe.

See Also:
  • Method Details

    • parse

      static UserInfo parse(String userInfoString) throws IllegalUserInfo
      Parses a string into user info.
      Parameters:
      userInfoString - the string to parse
      Returns:
      the parsed user info
      Throws:
      IllegalUserInfo - if the string is not valid user info
    • encode

      static UserInfo encode(String unencoded)
      Encodes a string into valid user info with proper percent-encoding.
      Parameters:
      unencoded - the unencoded string
      Returns:
      the encoded user info
    • getUsername

      Username getUsername()
      Returns the username component.
      Returns:
      the username, never null
    • getPassword

      @Nullable Password getPassword()
      Returns the password component, or null if there is no password.
      Returns:
      the password, or null if absent