org.apache.solr.client.solrj.impl

## Class PreemptiveBasicAuthClientBuilderFactory

- java.lang.Object
- - org.apache.solr.client.solrj.impl.PreemptiveBasicAuthClientBuilderFactory

All Implemented Interfaces:
  Closeable, AutoCloseable, HttpClientBuilderFactory

    public class PreemptiveBasicAuthClientBuilderFactory
    extends Object
    implements HttpClientBuilderFactory

HttpClientConfigurer implementation providing support for preemptive Http Basic authentication scheme.

### Field Summary

Fields
`static String` `SYS_PROP_BASIC_AUTH_CREDENTIALS` A system property to configure the Basic auth credentials via a java system property.
`static String` `SYS_PROP_HTTP_CLIENT_CONFIG` A system property used to specify a properties file containing default parameters used for creating a HTTP client.

### Constructor Summary

Constructors
Constructor and Description
`PreemptiveBasicAuthClientBuilderFactory()`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`void` `close()`
`SolrHttpClientBuilder` `getHttpClientBuilder(Optional<SolrHttpClientBuilder> optionalBuilder)` This method configures the SolrHttpClientBuilder by overriding the configuration of passed SolrHttpClientBuilder or as a new instance.
`static void` `setDefaultSolrParams(SolrParams params)` This method enables configuring system wide defaults (apart from using a config file based approach).
`void` `setup(Http2SolrClient client)`
`void` `setup(Http2SolrClient client, String basicAuthUser, String basicAuthPass)`

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

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

### Field Detail

#### SYS_PROP_HTTP_CLIENT_CONFIG

    public static final String SYS_PROP_HTTP_CLIENT_CONFIG

A system property used to specify a properties file containing default parameters used for creating a HTTP client. This is specifically useful for configuring the HTTP basic auth credentials (i.e. username/password). The name of the property must match the relevant Solr config property name.

See Also:
  Constant Field Values

#### SYS_PROP_BASIC_AUTH_CREDENTIALS

    public static final String SYS_PROP_BASIC_AUTH_CREDENTIALS

A system property to configure the Basic auth credentials via a java system property. Since this will expose the password on the command-line, it is not very secure. But this mechanism is added for backwards compatibility.

See Also:
  Constant Field Values

### Constructor Detail

#### PreemptiveBasicAuthClientBuilderFactory

    public PreemptiveBasicAuthClientBuilderFactory()

### Method Detail

#### setDefaultSolrParams

    public static void setDefaultSolrParams(SolrParams params)

This method enables configuring system wide defaults (apart from using a config file based approach).

#### close

    public void close()
               throws IOException

Specified by:
  `close` in interface `Closeable`
Specified by:
  `close` in interface `AutoCloseable`
Throws:
  `IOException`

#### setup

    public void setup(Http2SolrClient client)

Specified by:
  `setup` in interface `HttpClientBuilderFactory`

#### setup

    public void setup(Http2SolrClient client,
                      String basicAuthUser,
                      String basicAuthPass)

#### getHttpClientBuilder

    public SolrHttpClientBuilder getHttpClientBuilder(Optional<SolrHttpClientBuilder> optionalBuilder)

Description copied from interface: `HttpClientBuilderFactory`
This method configures the SolrHttpClientBuilder by overriding the configuration of passed SolrHttpClientBuilder or as a new instance.

Specified by:
  `getHttpClientBuilder` in interface `HttpClientBuilderFactory`
Parameters:
  `optionalBuilder` - The instance of the SolrHttpClientBuilder which should by configured (optional).
Returns:
  the SolrHttpClientBuilder