org.apache.calcite.avatica.remote

## Class AvaticaCommonsHttpClientImpl

- java.lang.Object
- - org.apache.calcite.avatica.remote.AvaticaCommonsHttpClientImpl

All Implemented Interfaces:
  AvaticaHttpClient, HostnameVerificationConfigurable, KeyStoreConfigurable, TrustStoreConfigurable, UsernamePasswordAuthenticateable

    public class AvaticaCommonsHttpClientImpl
    extends Object
    implements AvaticaHttpClient, UsernamePasswordAuthenticateable, TrustStoreConfigurable, KeyStoreConfigurable, HostnameVerificationConfigurable

A common class to invoke HTTP requests against the Avatica server agnostic of the data being sent and received across the wire.

### Nested Class Summary

### Nested classes/interfaces inherited from interface org.apache.calcite.avatica.remote.HostnameVerificationConfigurable

`HostnameVerificationConfigurable.HostnameVerification`

### Field Summary

Fields
`protected org.apache.http.impl.client.BasicAuthCache` `authCache`
`protected org.apache.http.config.Lookup<org.apache.http.auth.AuthSchemeProvider>` `authRegistry`
`protected org.apache.http.impl.client.CloseableHttpClient` `client`
`protected org.apache.http.auth.UsernamePasswordCredentials` `credentials`
`protected org.apache.http.client.CredentialsProvider` `credentialsProvider`
`protected org.apache.http.HttpHost` `host`
`protected HostnameVerificationConfigurable.HostnameVerification` `hostnameVerification`
`protected String` `keyPassword`
`protected File` `keystore`
`protected String` `keystorePassword`
`private static org.slf4j.Logger` `LOG`
`private static String` `MAX_POOLED_CONNECTION_PER_ROUTE_DEFAULT`
`private static String` `MAX_POOLED_CONNECTION_PER_ROUTE_KEY`
`private static String` `MAX_POOLED_CONNECTIONS_DEFAULT`
`private static String` `MAX_POOLED_CONNECTIONS_KEY`
`protected org.apache.http.impl.conn.PoolingHttpClientConnectionManager` `pool`
`protected org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory>` `socketFactoryRegistry`
`protected File` `truststore`
`protected String` `truststorePassword`
`protected URI` `uri`
`protected Object` `userToken`

### Constructor Summary

Constructors
Constructor and Description
`AvaticaCommonsHttpClientImpl(URL url)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`protected void` `configureConnectionPool(org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> registry)`
`protected void` `configureHttpRegistry(org.apache.http.config.RegistryBuilder<org.apache.http.conn.socket.ConnectionSocketFactory> registryBuilder)`
`protected void` `configureHttpsRegistry(org.apache.http.config.RegistryBuilder<org.apache.http.conn.socket.ConnectionSocketFactory> registryBuilder)`
`protected org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory>` `configureSocketFactories()`
`(package private) org.apache.http.client.methods.CloseableHttpResponse` `execute(org.apache.http.client.methods.HttpPost post, org.apache.http.client.protocol.HttpClientContext context)`
`(package private) HostnameVerifier` `getHostnameVerifier(HostnameVerificationConfigurable.HostnameVerification verification)` Creates the `HostnameVerifier` given the provided `verification`.
`private SSLContext` `getSSLContext()`
`private void` `initializeClient()`
`protected void` `loadKeyStore(org.apache.http.ssl.SSLContextBuilder sslContextBuilder)`
`protected void` `loadTrustStore(org.apache.http.ssl.SSLContextBuilder sslContextBuilder)`
`byte[]` `send(byte[] request)` Sends a serialized request to the Avatica server.
`void` `setHostnameVerification(HostnameVerificationConfigurable.HostnameVerification verification)` Instructs the `AvaticaHttpClient` how to perform hostname verification for SSL connections.
`void` `setKeyStore(File keystore, String keystorepassword, String keypassword)` Sets a keystore containing the collection of client side certificates to use for HTTPS mutual authentication along with password for keystore and password for key
`void` `setTrustStore(File truststore, String password)` Sets a truststore containing the collection of trust SSL/TLS server certificates to use for HTTPS calls and the password for that truststore.
`void` `setUsernamePassword(AuthenticationType authType, String username, String password)` Sets the username, password and method to be used for authentication.
`private static URI` `toURI(URL url)`

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

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

### Field Detail

#### LOG

    private static final org.slf4j.Logger LOG

#### MAX_POOLED_CONNECTION_PER_ROUTE_KEY

    private static final String MAX_POOLED_CONNECTION_PER_ROUTE_KEY

See Also:
  Constant Field Values

#### MAX_POOLED_CONNECTION_PER_ROUTE_DEFAULT

    private static final String MAX_POOLED_CONNECTION_PER_ROUTE_DEFAULT

See Also:
  Constant Field Values

#### MAX_POOLED_CONNECTIONS_KEY

    private static final String MAX_POOLED_CONNECTIONS_KEY

See Also:
  Constant Field Values

#### MAX_POOLED_CONNECTIONS_DEFAULT

    private static final String MAX_POOLED_CONNECTIONS_DEFAULT

See Also:
  Constant Field Values

#### host

    protected final org.apache.http.HttpHost host

#### uri

    protected final URI uri

#### authCache

    protected org.apache.http.impl.client.BasicAuthCache authCache

#### client

    protected org.apache.http.impl.client.CloseableHttpClient client

#### socketFactoryRegistry

    protected org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> socketFactoryRegistry

#### pool

    protected org.apache.http.impl.conn.PoolingHttpClientConnectionManager pool

#### credentials

    protected org.apache.http.auth.UsernamePasswordCredentials credentials

#### credentialsProvider

    protected org.apache.http.client.CredentialsProvider credentialsProvider

#### authRegistry

    protected org.apache.http.config.Lookup<org.apache.http.auth.AuthSchemeProvider> authRegistry

#### userToken

    protected Object userToken

#### truststore

    protected File truststore

#### keystore

    protected File keystore

#### truststorePassword

    protected String truststorePassword

#### keystorePassword

    protected String keystorePassword

#### keyPassword

    protected String keyPassword

#### hostnameVerification

    protected HostnameVerificationConfigurable.HostnameVerification hostnameVerification

### Constructor Detail

#### AvaticaCommonsHttpClientImpl

    public AvaticaCommonsHttpClientImpl(URL url)

### Method Detail

#### initializeClient

    private void initializeClient()

#### configureConnectionPool

    protected void configureConnectionPool(org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> registry)

#### configureSocketFactories

    protected org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> configureSocketFactories()

#### configureHttpsRegistry

    protected void configureHttpsRegistry(org.apache.http.config.RegistryBuilder<org.apache.http.conn.socket.ConnectionSocketFactory> registryBuilder)

#### getSSLContext

    private SSLContext getSSLContext()
                              throws Exception

Throws:
  `Exception`

#### loadKeyStore

    protected void loadKeyStore(org.apache.http.ssl.SSLContextBuilder sslContextBuilder)
                         throws Exception

Throws:
  `Exception`

#### loadTrustStore

    protected void loadTrustStore(org.apache.http.ssl.SSLContextBuilder sslContextBuilder)
                           throws Exception

Throws:
  `Exception`

#### configureHttpRegistry

    protected void configureHttpRegistry(org.apache.http.config.RegistryBuilder<org.apache.http.conn.socket.ConnectionSocketFactory> registryBuilder)

#### getHostnameVerifier

    HostnameVerifier getHostnameVerifier(HostnameVerificationConfigurable.HostnameVerification verification)

Creates the `HostnameVerifier` given the provided `verification`.

Parameters:
  `verification` - The intended hostname verification action.
Returns:
  A verifier for the request verification.
Throws:
  `IllegalArgumentException` - if the provided verification cannot be handled.

#### send

    public byte[] send(byte[] request)

Description copied from interface: `AvaticaHttpClient`
Sends a serialized request to the Avatica server.

Specified by:
  `send` in interface `AvaticaHttpClient`
Parameters:
  `request` - The serialized request.
Returns:
  The serialized response.

#### execute

    org.apache.http.client.methods.CloseableHttpResponse execute(org.apache.http.client.methods.HttpPost post,
                                                                 org.apache.http.client.protocol.HttpClientContext context)
                                                          throws IOException,
                                                                 org.apache.http.client.ClientProtocolException

Throws:
  `IOException`
  `org.apache.http.client.ClientProtocolException`

#### setUsernamePassword

    public void setUsernamePassword(AuthenticationType authType,
                                    String username,
                                    String password)

Description copied from interface: `UsernamePasswordAuthenticateable`
Sets the username, password and method to be used for authentication.

Specified by:
  `setUsernamePassword` in interface `UsernamePasswordAuthenticateable`
Parameters:
  `authType` - Type of authentication
  `username` - Username
  `password` - Password

#### toURI

    private static URI toURI(URL url)
                      throws RuntimeException

Throws:
  `RuntimeException`

#### setTrustStore

    public void setTrustStore(File truststore,
                              String password)

Description copied from interface: `TrustStoreConfigurable`
Sets a truststore containing the collection of trust SSL/TLS server certificates to use for HTTPS calls and the password for that truststore.

Specified by:
  `setTrustStore` in interface `TrustStoreConfigurable`
Parameters:
  `truststore` - The truststore on the local filesystem
  `password` - The truststore's password

#### setKeyStore

    public void setKeyStore(File keystore,
                            String keystorepassword,
                            String keypassword)

Description copied from interface: `KeyStoreConfigurable`
Sets a keystore containing the collection of client side certificates to use for HTTPS mutual authentication along with password for keystore and password for key

Specified by:
  `setKeyStore` in interface `KeyStoreConfigurable`
Parameters:
  `keystore` - The keystore on the local filesystem
  `keystorepassword` - The keystore's password
  `keypassword` - The key's password

#### setHostnameVerification

    public void setHostnameVerification(HostnameVerificationConfigurable.HostnameVerification verification)

Description copied from interface: `HostnameVerificationConfigurable`
Instructs the `AvaticaHttpClient` how to perform hostname verification for SSL connections.

Specified by:
  `setHostnameVerification` in interface `HostnameVerificationConfigurable`
Parameters:
  `verification` - The mode of hostname verification