aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common
diff options
context:
space:
mode:
authorUbuntu <brian.matt@windstream.com>2017-07-14 12:27:48 +0000
committerUbuntu <brian.matt@windstream.com>2017-07-14 12:36:01 +0000
commit41473519553c8e334c9471dfc88d7005f4ff613e (patch)
treed9ca8366cab33dfe0d8727442011ef761221285b /vid-app-common
parentf4760b48503d95ecd69c396c4015c8e6b31b9855 (diff)
ResPost Update for aai-traversal
Change-Id: I2a4ac963ac6db95e11315f3f96daab8a157ec832 Signed-off-by: Ubuntu <brian.matt@windstream.com>
Diffstat (limited to 'vid-app-common')
-rwxr-xr-xvid-app-common/src/main/java/org/openecomp/aai/util/AAIRestInterface.java54
1 files changed, 40 insertions, 14 deletions
diff --git a/vid-app-common/src/main/java/org/openecomp/aai/util/AAIRestInterface.java b/vid-app-common/src/main/java/org/openecomp/aai/util/AAIRestInterface.java
index fa4eefc6..cd509519 100755
--- a/vid-app-common/src/main/java/org/openecomp/aai/util/AAIRestInterface.java
+++ b/vid-app-common/src/main/java/org/openecomp/aai/util/AAIRestInterface.java
@@ -1,9 +1,9 @@
/*-
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 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.
* You may obtain a copy of the License at
@@ -14,7 +14,7 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License.
* ============LICENSE_END=========================================================
*/
package org.openecomp.aai.util;
@@ -276,17 +276,43 @@ public class AAIRestInterface {
if (xml)
responseType = "application/xml";
- initRestClient();
+ initRestClient();
+
+ String clientCert = SystemProperties.getProperty(AAIProperties.AAI_USE_CLIENT_CERT);
+
+ boolean useClientCert = false;
+ if (clientCert != null &&
+ SystemProperties.getProperty(AAIProperties.AAI_USE_CLIENT_CERT).equalsIgnoreCase("true")) {
+ useClientCert = true;
+ }
url = SystemProperties.getProperty(AAIProperties.AAI_SERVER_URL_BASE) + path;
- final Response cres = client.target(url)
- .request()
- .accept(responseType)
- .header("X-TransactionId", transId)
- .header("X-FromAppId", fromAppId)
- .post(Entity.entity(payload, MediaType.APPLICATION_JSON));
-
+ final Response cres;
+ if (useClientCert == true) {
+ cres = client.target(url)
+ .request()
+ .accept(responseType)
+ .header("X-TransactionId", transId)
+ .header("X-FromAppId", fromAppId)
+ .header("Content-Type", "application/json")
+ .post(Entity.entity(payload, MediaType.APPLICATION_JSON));
+ } else {
+
+ String vidUsername = SystemProperties.getProperty(AAIProperties.AAI_VID_USERNAME);
+ String vidPassword = Password.deobfuscate(SystemProperties.getProperty(AAIProperties.AAI_VID_PASSWD_X));
+ String encodeThis = vidUsername + ":" + vidPassword;
+
+ cres = client.target(url)
+ .request()
+ .accept(responseType)
+ .header("X-TransactionId", transId)
+ .header("X-FromAppId", fromAppId)
+ .header("Content-Type", "application/json")
+ .header("Authorization", "Basic " + Base64.getEncoder().encodeToString(encodeThis.getBytes("utf-8")))
+ .post(Entity.entity(payload, MediaType.APPLICATION_JSON));
+ }
+
if (cres.getStatus() == 200 && cres.getStatus() <= 299) {
logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + methodName + " REST api POST was successful!");
logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " REST api POST was successful!");