org.springframework.cloud.dataflow.rest.util

## Class HttpClientConfigurer

- java.lang.Object
- - org.springframework.cloud.dataflow.rest.util.HttpClientConfigurer

-     public class HttpClientConfigurer
      extends Object

  Utility for configuring a `CloseableHttpClient`. This class allows for chained method invocation. If both basic auth credentials and a target host are provided, the HTTP client will aggressively send the credentials without having to receive an HTTP 401 response first.

  This class can also be used to configure the client used by `RestTemplate` using `buildClientHttpRequestFactory()`.

  Author:
    Mike Heath, Gunnar Hillert

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `HttpClientConfigurer(URI targetHost)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `HttpClientConfigurer` | `addInterceptor(org.apache.http.HttpRequestInterceptor interceptor)`
    `HttpClientConfigurer` | `basicAuthCredentials(String username, String password)`
    `org.springframework.http.client.ClientHttpRequestFactory` | `buildClientHttpRequestFactory()`
    `org.apache.http.impl.client.CloseableHttpClient` | `buildHttpClient()`
    `static HttpClientConfigurer` | `create(URI targetHost)`
    `HttpClientConfigurer` | `skipTlsCertificateVerification()` Sets the client's `SSLContext` to use `HttpUtils.buildCertificateIgnoringSslContext()`.
    `HttpClientConfigurer` | `skipTlsCertificateVerification(boolean skipTlsCertificateVerification)`
    `HttpClientConfigurer` | `withProxyCredentials(URI proxyUri, String proxyUsername, String proxyPassword)` Configures the `HttpClientBuilder` with a proxy host.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### HttpClientConfigurer

          protected HttpClientConfigurer(URI targetHost)

  - ### Method Detail

    - #### create

          public static HttpClientConfigurer create(URI targetHost)

    - #### basicAuthCredentials

          public HttpClientConfigurer basicAuthCredentials(String username,
                                                           String password)

    - #### withProxyCredentials

          public HttpClientConfigurer withProxyCredentials(URI proxyUri,
                                                           String proxyUsername,
                                                           String proxyPassword)

      Configures the `HttpClientBuilder` with a proxy host. If the `proxyUsername` and `proxyPassword` are not `null` then a `CredentialsProvider` is also configured for the proxy host.
      Parameters:
        `proxyUri` - Must not be null and must be configured with a scheme (http or https).
        `proxyUsername` - May be null
        `proxyPassword` - May be null
      Returns:
        a reference to `this` to enable chained method invocation

    - #### skipTlsCertificateVerification

          public HttpClientConfigurer skipTlsCertificateVerification()

      Sets the client's `SSLContext` to use `HttpUtils.buildCertificateIgnoringSslContext()`.
      Returns:
        a reference to `this` to enable chained method invocation

    - #### skipTlsCertificateVerification

          public HttpClientConfigurer skipTlsCertificateVerification(boolean skipTlsCertificateVerification)

    - #### addInterceptor

          public HttpClientConfigurer addInterceptor(org.apache.http.HttpRequestInterceptor interceptor)

    - #### buildHttpClient

          public org.apache.http.impl.client.CloseableHttpClient buildHttpClient()

    - #### buildClientHttpRequestFactory

          public org.springframework.http.client.ClientHttpRequestFactory buildClientHttpRequestFactory()

Copyright © 2021 Pivotal Software, Inc.. All rights reserved.