Source:
<code>private RestClientBuilder getClientBuilder(final BasicCredentialsProvider credentialsProvider) { final String esAuthType = getESAuthType(); final String esProtocol = Config.getStringProperty("ES_PROTOCOL", "https"); final RestClientBuilder clientBuilder = RestClient .builder(new HttpHost(Config.getStringProperty("ES_HOSTNAME", "127.0.0.1"), Config.getIntProperty("ES_PORT", 9200), esProtocol)) .setHttpClientConfigCallback((httpClientBuilder) -> { if (sslContextFromPem != null) { httpClientBuilder .setSSLContext(sslContextFromPem); <START> } else if ("https".equals(esProtocol)){ <END> try { httpClientBuilder.setSSLContext(SSLContexts .custom().loadTrustMaterial(new TrustSelfSignedStrategy()).build()); } catch (NoSuchAlgorithmException | KeyManagementException | KeyStoreException e) { Logger.error(this.getClass(), "Error setting TrustSelfSignedStrategy for Elastic RestHighLevelClient", e); throw new DotRuntimeException(e); } } httpClientBuilder .setDefaultCredentialsProvider(credentialsProvider); return httpClientBuilder; }) .setFailureListener(new RestClient.FailureListener() { public void onFailure(Node node) { Logger.error(this, node.toString()); } }); if (esAuthType.equals(JWT_AUTH_TYPE)) { clientBuilder.setDefaultHeaders(new Header[]{new BasicHeader("Authorization", "Bearer " + Config.getStringProperty("ES_AUTH_JWT_TOKEN", null))}); Logger.info(DotRestHighLevelClientProvider.class, "Initializing Elastic RestHighLevelClient using JWT authentication"); } return clientBuilder; }</code><technical_language>"https" a constant</technical_language>

Target:
private RestClientBuilder getClientBuilder(final BasicCredentialsProvider credentialsProvider) { final String esAuthType = getESAuthType(); final String esProtocol = Config.getStringProperty("ES_PROTOCOL", HTTPS_PROTOCOL); final boolean securedConnection = HTTPS_PROTOCOL.equals(esProtocol); if (securedConnection){ Logger.info(this.getClass(), "Initializing Elastic RestHighLevelClient using a secured https connection"); } else{ Logger.warn(this.getClass(), "Initializing Elastic RestHighLevelClient using an unsecured http connection"); } final RestClientBuilder clientBuilder = RestClient .builder(new HttpHost(Config.getStringProperty("ES_HOSTNAME", "127.0.0.1"), Config.getIntProperty("ES_PORT", 9200), esProtocol)) .setHttpClientConfigCallback((httpClientBuilder) -> { if (sslContextFromPem != null) { httpClientBuilder.setSSLContext(sslContextFromPem); } else if (securedConnection){ try { httpClientBuilder.setSSLContext(SSLContexts .custom().loadTrustMaterial(new TrustSelfSignedStrategy()).build()); } catch (NoSuchAlgorithmException | KeyManagementException | KeyStoreException e) { Logger.error(this.getClass(), "Error setting TrustSelfSignedStrategy for Elastic RestHighLevelClient", e); throw new DotRuntimeException(e); } } httpClientBuilder .setDefaultCredentialsProvider(credentialsProvider); return httpClientBuilder; }) .setFailureListener(new RestClient.FailureListener() { public void onFailure(Node node) { Logger.error(this, node.toString()); } }); if (esAuthType.equals(JWT_AUTH_TYPE)) { clientBuilder.setDefaultHeaders(new Header[]{new BasicHeader("Authorization", "Bearer " + Config.getStringProperty("ES_AUTH_JWT_TOKEN", null))}); Logger.info(DotRestHighLevelClientProvider.class, "Initializing Elastic RestHighLevelClient using JWT authentication"); } return clientBuilder; }