aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/HealthCheckScheduledTask.java
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/HealthCheckScheduledTask.java')
-rw-r--r--catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/HealthCheckScheduledTask.java23
1 files changed, 21 insertions, 2 deletions
diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/HealthCheckScheduledTask.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/HealthCheckScheduledTask.java
index 2d99f84b9a..0db9fe9a44 100644
--- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/HealthCheckScheduledTask.java
+++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/HealthCheckScheduledTask.java
@@ -37,15 +37,22 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
+
+import javax.servlet.ServletException;
+
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpStatus;
+import org.eclipse.jetty.client.HttpClient;
+import org.eclipse.jetty.util.ssl.SslContextFactory;
+import org.onap.config.api.JettySSLUtils;
import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.common.api.HealthCheckInfo;
import org.openecomp.sdc.common.api.HealthCheckWrapper;
import org.openecomp.sdc.common.config.EcompErrorEnum;
import org.openecomp.sdc.common.http.client.api.HttpRequest;
import org.openecomp.sdc.common.http.client.api.HttpResponse;
+import org.openecomp.sdc.common.http.config.ClientCertificate;
import org.openecomp.sdc.common.http.config.HttpClientConfig;
import org.openecomp.sdc.common.http.config.Timeouts;
import org.openecomp.sdc.common.impl.ExternalConfiguration;
@@ -116,7 +123,9 @@ public class HealthCheckScheduledTask implements Runnable {
if (healthCheckUrl != null) {
ObjectMapper mapper = new ObjectMapper();
try {
- HttpResponse<String> response = HttpRequest.get(healthCheckUrl, new HttpClientConfig(new Timeouts(connectTimeoutMs, readTimeoutMs)));
+ HttpClientConfig clientConfig = new HttpClientConfig(new Timeouts(connectTimeoutMs, readTimeoutMs), getHttpClientCertificate());
+
+ HttpResponse<String> response = HttpRequest.get(healthCheckUrl, clientConfig);
int beStatus = response.getStatusCode();
if (beStatus == HttpStatus.SC_OK || beStatus == HttpStatus.SC_INTERNAL_SERVER_ERROR) {
String beJsonResponse = response.getResponse();
@@ -135,6 +144,15 @@ public class HealthCheckScheduledTask implements Runnable {
String compName = requestedByBE ? Constants.HC_COMPONENT_FE : baseComponent;
return Collections.singletonList(new HealthCheckInfo(compName, HealthCheckInfo.HealthCheckStatus.DOWN, null, description.toString()));
}
+
+ private ClientCertificate getHttpClientCertificate() {
+ ClientCertificate clientCertificate = new ClientCertificate();
+ clientCertificate.setKeyStore(JettySSLUtils.getSSLConfig().getKeystorePath());
+ clientCertificate.setKeyStorePassword(JettySSLUtils.getSSLConfig().getKeystorePass(), false);
+ clientCertificate.setTrustStore(JettySSLUtils.getSSLConfig().getTruststorePath());
+ clientCertificate.setTrustStorePassword(JettySSLUtils.getSSLConfig().getTruststorePass());
+ return clientCertificate;
+ }
private String getExternalComponentHcUri(String baseComponent) {
String healthCheckUri = null;
@@ -197,7 +215,8 @@ public class HealthCheckScheduledTask implements Runnable {
ErrorLogOptionalData errorLogOptionalData = ErrorLogOptionalData.newBuilder().targetEntity(LOG_TARGET_ENTITY_BE)
.targetServiceName(LOG_SERVICE_NAME).build();
try {
- HttpResponse<String> response = HttpRequest.get(redirectedUrl, new HttpClientConfig(new Timeouts(connectTimeoutMs, readTimeoutMs)));
+ HttpClientConfig clientConfig = new HttpClientConfig(new Timeouts(connectTimeoutMs, readTimeoutMs), getHttpClientCertificate());
+ HttpResponse<String> response = HttpRequest.get(redirectedUrl, clientConfig);
log.debug("HC call to BE - status code is {}", response.getStatusCode());
String beJsonResponse = response.getResponse();
feAggHealthCheck = getFeHealthCheckInfos(gson, beJsonResponse);