diff options
author | Jim Hahn <jrh3@att.com> | 2021-03-18 12:06:41 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2021-03-18 12:36:35 -0400 |
commit | 87e6b80d8c1a285c950fa840fd68fc123343ff5f (patch) | |
tree | 63c3fcea4dee7d913fdc2fde27b4206a714a3439 /plugins/forwarding-plugins/src/main/java | |
parent | d4be312db9288b8ea2b3a158a697918c9cc24eff (diff) |
Support self-signed certificates in distribution
Also modified the code to work with any HTTP response code in the range
200-299.
Issue-ID: POLICY-3143
Change-Id: Id7bcb0c98714c6d98ad7f5d7ceb3b033906aeab1
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'plugins/forwarding-plugins/src/main/java')
2 files changed, 5 insertions, 4 deletions
diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiForwarderParameters.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiForwarderParameters.java index 0fc4f457..4d141a95 100644 --- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiForwarderParameters.java +++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiForwarderParameters.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,6 +40,7 @@ public class LifecycleApiForwarderParameters extends PolicyForwarderConfiguratio private LifecycleApiParameters apiParameters; private LifecycleApiParameters papParameters; private boolean isHttps; + private boolean allowSelfSignedCerts; private boolean deployPolicies = true; public LifecycleApiForwarderParameters() { diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java index 242573cc..d45b07f6 100644 --- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java +++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix Foundation. - * Modifications Copyright (C) 2020 AT&T Inc. + * Modifications Copyright (C) 2020-2021 AT&T Inc. * Modifications Copyright (C) 2021 Bell Canada. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -32,7 +32,6 @@ import javax.ws.rs.client.Entity; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; import org.onap.policy.common.endpoints.http.client.HttpClient; import org.onap.policy.common.endpoints.http.client.HttpClientConfigException; @@ -144,7 +143,7 @@ public class LifecycleApiPolicyForwarder implements PolicyForwarder { try { response = getHttpClient(wantApi).post(path, entity, ImmutableMap.of(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON, HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)); - if (response.getStatus() != Status.OK.getStatusCode()) { + if (response.getStatus() / 100 != 2) { LOGGER.error( "Invocation of path {} failed for entity {}. Response status: {}, Response status info: {}", path, entity, response.getStatus(), response.getStatusInfo()); @@ -163,7 +162,7 @@ public class LifecycleApiPolicyForwarder implements PolicyForwarder { (wantApi ? forwarderParameters.getApiParameters() : forwarderParameters.getPapParameters()); final BusTopicParams params = BusTopicParams.builder().clientName("Policy Distribution").useHttps(https) .hostname(parameters.getHostName()).port(parameters.getPort()).userName(parameters.getUserName()) - .password(parameters.getPassword()) + .password(parameters.getPassword()).allowSelfSignedCerts(forwarderParameters.isAllowSelfSignedCerts()) .build(); return HttpClientFactoryInstance.getClientFactory().build(params); } |