Class HttpComponentsClientHttpRequestFactoryBasicAuth

java.lang.Object
org.springframework.http.client.HttpComponentsClientHttpRequestFactory
org.cruk.clarity.api.http.HttpComponentsClientHttpRequestFactoryBasicAuth
All Implemented Interfaces:
AuthenticatingClientHttpRequestFactory, DisposableBean, ClientHttpRequestFactory

public class HttpComponentsClientHttpRequestFactoryBasicAuth extends HttpComponentsClientHttpRequestFactory implements AuthenticatingClientHttpRequestFactory
Client HTTP request factory adding basic authentication to the request.
Since:
2.23.1
See Also:
  • Constructor Details

    • HttpComponentsClientHttpRequestFactoryBasicAuth

      public HttpComponentsClientHttpRequestFactoryBasicAuth()
      Constructor.
    • HttpComponentsClientHttpRequestFactoryBasicAuth

      public HttpComponentsClientHttpRequestFactoryBasicAuth(HttpClient client)
      Constructor with an HTTP client.
      Parameters:
      client - The underlying HTTP client.
    • HttpComponentsClientHttpRequestFactoryBasicAuth

      public HttpComponentsClientHttpRequestFactoryBasicAuth(HttpClient client, CredentialsProvider credentialsProvider)
      Constructor with an HTTP client and credentials provider.
      Parameters:
      client - The underlying HTTP client.
      credentialsProvider - The authentication credentials provider.
  • Method Details

    • getCredentialsProvider

      public CredentialsProvider getCredentialsProvider()
      Get the credentials provider used by this factory.
      Returns:
      The authentication credentials provider.
    • setCredentialsProvider

      public void setCredentialsProvider(CredentialsProvider credentialsProvider)
      Set the credentials provider to use.
      Parameters:
      credentialsProvider - The authentication credentials provider.
    • createHttpContext

      protected HttpContext createHttpContext(HttpMethod httpMethod, URI uri)
      Provide the HTTP context set up for basic authentication by this factory. Despite the method being called "create", the same HttpContext can be returned each time.
      Overrides:
      createHttpContext in class HttpComponentsClientHttpRequestFactory
      Parameters:
      httpMethod - The HTTP method.
      uri - The request URI.
      Returns:
      The HttpContext.
    • getHost

      public HttpHost getHost()
      Get the host to which the credentials will be applied.
      Specified by:
      getHost in interface AuthenticatingClientHttpRequestFactory
      Returns:
      The HttpHost specification to which the authentication applies.
    • getCredentials

      public Credentials getCredentials()
      Get the credentials currently in use.
      Specified by:
      getCredentials in interface AuthenticatingClientHttpRequestFactory
      Returns:
      The credentials.
    • setCredentials

      public void setCredentials(URI uri, Credentials credentials)
      Set the credentials based on the protocol, host and port in the URL.
      Specified by:
      setCredentials in interface AuthenticatingClientHttpRequestFactory
      Parameters:
      uri - The URI of the HTTP server.
      credentials - The credentials to use, or null to reset.
    • setCredentials

      public void setCredentials(HttpHost host, Credentials credentials)
      Set the credentials based on the HTTP host specification.
      Specified by:
      setCredentials in interface AuthenticatingClientHttpRequestFactory
      Parameters:
      host - The host specification of the HTTP server.
      credentials - The credentials to use, or null to reset.