Class BasicAuthIntercept

java.lang.Object
io.avaje.http.client.BasicAuthIntercept
All Implemented Interfaces:
RequestIntercept

public final class BasicAuthIntercept extends Object implements RequestIntercept
Adds Basic Authorization header to requests.
  • Constructor Details

    • BasicAuthIntercept

      public BasicAuthIntercept(String username, String password)
      Construct with the username and password.
  • Method Details

    • header

      public static String header(String username, String password)
      Return the Basic header value with the encoding of username:password

      Provided as a helper method for code that wants the header value to then apply explicitly rather than using this as a request intercept.

      Returns:
      "Basic " + encode(username, password)
    • encode

      public static String encode(String username, String password)
      Return Base64 encoding of username:password

      Provided as a helper method for code that wants to encode the username password pair and use that explicitly rather than using this as a request intercept.

    • beforeRequest

      public void beforeRequest(HttpClientRequest request)
      Description copied from interface: RequestIntercept
      Before the request has been made.

      Typically we can add headers or modify the request prior to it being sent.

      Specified by:
      beforeRequest in interface RequestIntercept