Class BasicAuthenticationHandler

java.lang.Object
org.eclipse.rdf4j.http.client.spi.BasicAuthenticationHandler
All Implemented Interfaces:
AuthenticationHandler

public class BasicAuthenticationHandler extends Object implements AuthenticationHandler
AuthenticationHandler that adds HTTP Basic authentication credentials to every request.

The Authorization: Basic <base64> header is computed once at construction time and appended to every request passed to authenticate(HttpRequest).

Example usage:

SPARQLProtocolSession session = ...;
session.setAuthenticationHandler(new BasicAuthenticationHandler("user", "secret"));
See Also:
  • Constructor Details

    • BasicAuthenticationHandler

      public BasicAuthenticationHandler(String username, String password)
      Creates a new BasicAuthenticationHandler for the given credentials.
      Parameters:
      username - the username; must not be null
      password - the password; must not be null
  • Method Details

    • authenticate

      public void authenticate(HttpRequest request)
      Description copied from interface: AuthenticationHandler
      Applies authentication credentials to the given request by modifying it in place.
      Specified by:
      authenticate in interface AuthenticationHandler
      Parameters:
      request - the outgoing HTTP request to authenticate; never null