@SuppressWarnings("java:S2095")
    private CloseableHttpClient buildHttpClient() {
        val sslFactory = Optional.ofNullable(this.sslSocketFactory)
            .orElseGet(() -> new SSLConnectionSocketFactory(
                ObjectUtils.defaultIfNull(this.sslContext, SSLContexts.createDefault()),
                ObjectUtils.defaultIfNull(this.hostnameVerifier, new DefaultHostnameVerifier())));
        
        val plainSocketFactory = PlainConnectionSocketFactory.getSocketFactory();
        val registry = RegistryBuilder.<ConnectionSocketFactory>create()
            .register("http", plainSocketFactory)
            .register("https", sslFactory)
            .build();
        
        val connConfig = ConnectionConfig.custom()
            .setConnectTimeout(Timeout.ofMilliseconds(this.connectionTimeout))
            .setSocketTimeout(Timeout.ofMilliseconds(this.socketTimeout))
            .setValidateAfterInactivity(Timeout.ofMilliseconds(DEFAULT_TIMEOUT))
            .build();

        val connectionManager = new PoolingHttpClientConnectionManager(registry);
        connectionManager.setMaxTotal(this.maxPooledConnections);
        connectionManager.setDefaultMaxPerRoute(this.maxConnectionsPerRoute);
        connectionManager.setValidateAfterInactivity(Timeout.ofMilliseconds(DEFAULT_TIMEOUT));
        connectionManager.setDefaultConnectionConfig(connConfig);

        val requestConfig = RequestConfig.custom()
            .setConnectTimeout(Timeout.ofMilliseconds(this.connectionTimeout))
            .setConnectionRequestTimeout(Timeout.ofMilliseconds(this.connectionTimeout))
            .setCircularRedirectsAllowed(this.circularRedirectsAllowed)
            .setRedirectsEnabled(this.redirectsEnabled)
            .setAuthenticationEnabled(this.authenticationEnabled)
            .setResponseTimeout(Timeout.ofMilliseconds(this.responseTimeout))
            .build();

        val builder = HttpClients.custom()
            .setConnectionManager(connectionManager)
            .setDefaultRequestConfig(requestConfig)
            .setRedirectStrategy(this.redirectionStrategy)
            .setDefaultCredentialsProvider(this.credentialsProvider)
            .setDefaultCookieStore(this.cookieStore)
            .setConnectionReuseStrategy(this.connectionReuseStrategy)
            .setKeepAliveStrategy(this.connectionKeepAliveStrategy)
            .setConnectionBackoffStrategy(this.connectionBackoffStrategy)
            .setRetryStrategy(this.retryStrategy)
            .setProxyAuthenticationStrategy(this.proxyAuthenticationStrategy)
            .setDefaultHeaders(this.defaultHeaders)
            .setProxy(this.proxy)
            .useSystemProperties();
        return builder.build();
    }
Build a HTTP client based on the current properties.

@return the built HTTP client
core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/http/SimpleHttpClientFactoryBean.java