Class ApiBuilderHelper


  • public final class ApiBuilderHelper
    extends Object
    Utility class for adding proxy and ssl configurations to Apis
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void addConnectionSpecs​(okhttp3.OkHttpClient.Builder builder, List<okhttp3.ConnectionSpec> connectionSpecs)
      Specifies configuration for the socket connection that HTTP traffic travels through.
      static void addProxySettings​(String proxyHost, Integer proxyPort, String proxyUser, String proxyPass, okhttp3.OkHttpClient.Builder builder)
      Check the Proxy settings (host,port, username and password) and adds the ProxyConfiguration to the OkHttpClient.Builder if at least a Proxy Port is found
      static feign.Retryer createRetryer​(boolean isEnableRetrying)
      Creates a Retryer depending on the configuration param
      static void disableSsl​(okhttp3.OkHttpClient.Builder builder)
      Disables SSL checking when contacting LS servers Used for corner cases where the root cert is missing
      static void setHostnameVerifier​(okhttp3.OkHttpClient.Builder builder, HostnameVerifier hostnameVerifier)
      Sets the verifier used to confirm that response certificates apply to requested hostnames for HTTPS connections.
      static void setTimeout​(Long requestTimeout, okhttp3.OkHttpClient.Builder builder)
      Adds the timeout for read/write/connect for OkHttpClientBuilder
    • Method Detail

      • createRetryer

        public static feign.Retryer createRetryer​(boolean isEnableRetrying)
        Creates a Retryer depending on the configuration param
        Parameters:
        isEnableRetrying - configuration field if retrying is enabled
        Returns:
        Retryer - the default one or with retrying disabled
      • setTimeout

        public static void setTimeout​(Long requestTimeout,
                                      okhttp3.OkHttpClient.Builder builder)
        Adds the timeout for read/write/connect for OkHttpClientBuilder
        Parameters:
        requestTimeout - duration for the request timeout, in seconds
        builder - httpClient builder for adding proxy settings
      • addProxySettings

        public static void addProxySettings​(String proxyHost,
                                            Integer proxyPort,
                                            String proxyUser,
                                            String proxyPass,
                                            okhttp3.OkHttpClient.Builder builder)
        Check the Proxy settings (host,port, username and password) and adds the ProxyConfiguration to the OkHttpClient.Builder if at least a Proxy Port is found
        Parameters:
        proxyHost - host for proxy configuration
        proxyPort - port for proxy configuration
        proxyUser - username for proxy configuration
        proxyPass - password for proxy configuration
        builder - httpClient builder for adding proxy settings
      • disableSsl

        public static void disableSsl​(okhttp3.OkHttpClient.Builder builder)
        Disables SSL checking when contacting LS servers Used for corner cases where the root cert is missing
        Parameters:
        builder - httpClient builder for disabling ssl checks
      • addConnectionSpecs

        public static void addConnectionSpecs​(okhttp3.OkHttpClient.Builder builder,
                                              List<okhttp3.ConnectionSpec> connectionSpecs)
        Specifies configuration for the socket connection that HTTP traffic travels through.
        Parameters:
        builder - httpClient builder
        connectionSpecs - connection specs
      • setHostnameVerifier

        public static void setHostnameVerifier​(okhttp3.OkHttpClient.Builder builder,
                                               HostnameVerifier hostnameVerifier)
        Sets the verifier used to confirm that response certificates apply to requested hostnames for HTTPS connections. If unset, a default hostname verifier will be used.
        Parameters:
        builder - httpClient builder
        hostnameVerifier - verifier