es.gob.fnmt.net

## Class DroidHttpClient.Builder

- java.lang.Object
- - es.gob.fnmt.net.DroidHttpClient.Builder

- Enclosing class:
    DroidHttpClient

      public static final class DroidHttpClient.Builder
      extends java.lang.Object

  Java builder pattern class used to set DroidHttpClient parameters.

- - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `DroidHttpClient.Builder` | `addHeaderInfo(java.lang.String param, java.lang.String value)` Add extra information to the header request.
    `DroidHttpClient.Builder` | `clientKeyStore(java.security.KeyStore clientKeyStore)` Set certificate keystore for client authentication.
    `DroidHttpClient` | `done()` Initialize SSL context and builds an http client instance.
    `DroidHttpClient.Builder` | `enableCustomRedirectHandler(boolean enabled)` Set custom redirect handling requests in order to avoid infinite circular redirects.
    `DroidHttpClient.Builder` | `enableCustomResponseProcessCookies(boolean enable)` Replace response interceptor by the custom one.
    `javax.net.ssl.SSLSocketFactory` | `getSSLSocketFactory()` Build and return a javax.net.ssl.SSLSocketFactory object instance.
    `DroidHttpClient.Builder` | `keyManager(javax.net.ssl.KeyManager certificateKeyManager)` Set key manager for retrieving the client certificate for authentication.
    `DroidHttpClient.Builder` | `keyManagerPolicy(KeyManagerPolicy certificateKeyManagerPolicy)` Set key manager policies for retrieving the client certificate for authentication.
    `DroidHttpClient.Builder` | `protocol(java.lang.String protocol)` Set protocol ("SSLv3", "TLSv1", ""TLSv1.1", "TLSv2", etc.).
    `DroidHttpClient.Builder` | `setCookiePolicy(DroidHttpClient.CookiePolicy cookiePolicy)` Set the cookie policy: [CookiePolicy.RFC2965 (default) | CookiePolicy.BEST_MATCH | CookiePolicy.BROWSER_COMPATIBILITY].
    `DroidHttpClient.Builder` | `setResponseProcessCookies(ResponseProcessCookies responseProcessCookies)` Set a user implementation handler for cookies management in request/response process.
    `DroidHttpClient.Builder` | `setTimeout(int timeout)` Set the timeout for HTTP requests.
    `DroidHttpClient.Builder` | `trustKeyStore(java.security.KeyStore trustKeyStore)` Set trusted CA (Certificate Authority) certificate keystore for server authentication.

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

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

- - ### Method Detail

    - #### addHeaderInfo

          public DroidHttpClient.Builder addHeaderInfo(java.lang.String param,
                                                       java.lang.String value)

      Add extra information to the header request.
      Returns:
        Builder.

    - #### clientKeyStore

          public DroidHttpClient.Builder clientKeyStore(java.security.KeyStore clientKeyStore)

      Set certificate keystore for client authentication.
      Parameters:
        `clientKeyStore` - container with the client certificates for authentication.
      Returns:
        Builder.

    - #### done

          public DroidHttpClient done()
                               throws java.security.NoSuchAlgorithmException,
                                      java.security.KeyStoreException,
                                      java.security.KeyManagementException,
                                      javax.net.ssl.SSLException,
                                      java.security.UnrecoverableKeyException,
                                      java.security.NoSuchProviderException

      Initialize SSL context and builds an http client instance.
      Returns:
        DroidHttpClient instance.
      Throws:
        `java.security.KeyStoreException`
        `java.security.NoSuchAlgorithmException`
        `java.security.KeyManagementException`
        `javax.net.ssl.SSLException`
        `java.security.UnrecoverableKeyException`
        `java.security.NoSuchProviderException`

    - #### enableCustomRedirectHandler

          public DroidHttpClient.Builder enableCustomRedirectHandler(boolean enabled)

      Set custom redirect handling requests in order to avoid infinite circular redirects.
      Parameters:
        `enabled` - true for enable, false for disable. Default is true.
      Returns:
        Builder.

    - #### enableCustomResponseProcessCookies

          public DroidHttpClient.Builder enableCustomResponseProcessCookies(boolean enable)

      Replace response interceptor by the custom one.
      Parameters:
        `enable` - true for enable, false for disable. Default is true.
      Returns:
        Builder.

    - #### getSSLSocketFactory

          public javax.net.ssl.SSLSocketFactory getSSLSocketFactory()
                                                             throws java.security.UnrecoverableKeyException,
                                                                    java.security.NoSuchAlgorithmException,
                                                                    java.security.KeyStoreException,
                                                                    java.security.NoSuchProviderException,
                                                                    java.security.KeyManagementException

      Build and return a javax.net.ssl.SSLSocketFactory object instance.
      Returns:
        SSLSocketFactory implementation.
      Throws:
        `java.security.UnrecoverableKeyException`
        `java.security.NoSuchAlgorithmException`
        `java.security.KeyStoreException`
        `java.security.NoSuchProviderException`
        `java.security.KeyManagementException`

    - #### keyManager

          public DroidHttpClient.Builder keyManager(javax.net.ssl.KeyManager certificateKeyManager)

      Set key manager for retrieving the client certificate for authentication.
      Parameters:
        `certificateKeyManager` - instance of class that implements javax.net.ssl.KeyManager
      Returns:
        Builder.
      See Also:
        `KeyManager`

    - #### keyManagerPolicy

          public DroidHttpClient.Builder keyManagerPolicy(KeyManagerPolicy certificateKeyManagerPolicy)

      Set key manager policies for retrieving the client certificate for authentication. This will be overridden by keyManager method.
      Parameters:
        `certificateKeyManagerPolicy` - instance of class KeyManagerPolicy.
      Returns:
        Builder.

    - #### protocol

          public DroidHttpClient.Builder protocol(java.lang.String protocol)

      Set protocol ("SSLv3", "TLSv1", ""TLSv1.1", "TLSv2", etc.).
      Parameters:
        `protocol` - SSL protocol as string.
      Returns:
        Builder.

    - #### setCookiePolicy

          public DroidHttpClient.Builder setCookiePolicy(DroidHttpClient.CookiePolicy cookiePolicy)

      Set the cookie policy: [CookiePolicy.RFC2965 (default) | CookiePolicy.BEST_MATCH | CookiePolicy.BROWSER_COMPATIBILITY].
      Parameters:
        `cookiePolicy` -
      Returns:

    - #### setResponseProcessCookies

          public DroidHttpClient.Builder setResponseProcessCookies(ResponseProcessCookies responseProcessCookies)

      Set a user implementation handler for cookies management in request/response process.
      Parameters:
        `responseProcessCookies` -
      Returns:

    - #### setTimeout

          public DroidHttpClient.Builder setTimeout(int timeout)

      Set the timeout for HTTP requests.
      Parameters:
        `timeout` - in milliseconds.
      Returns:
        Builder.

    - #### trustKeyStore

          public DroidHttpClient.Builder trustKeyStore(java.security.KeyStore trustKeyStore)

      Set trusted CA (Certificate Authority) certificate keystore for server authentication.
      Parameters:
        `trustKeyStore` - container with the server CA certificates.
      Returns:
        Builder.