/*-\r
- * ============LICENSE_START=======================================================
- * VID
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================\r
+ * VID\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
* You may obtain a copy of the License at\r
* distributed under the License is distributed on an "AS IS" BASIS,\r
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
* See the License for the specific language governing permissions and\r
- * limitations under the License.
+ * limitations under the License.\r
* ============LICENSE_END=========================================================\r
*/\r
package org.openecomp.aai.util;\r
if (xml)\r
responseType = "application/xml";\r
\r
- initRestClient(); \r
+ initRestClient();\r
+\r
+ String clientCert = SystemProperties.getProperty(AAIProperties.AAI_USE_CLIENT_CERT);\r
+\r
+ boolean useClientCert = false;\r
+ if (clientCert != null &&\r
+ SystemProperties.getProperty(AAIProperties.AAI_USE_CLIENT_CERT).equalsIgnoreCase("true")) {\r
+ useClientCert = true;\r
+ }\r
\r
url = SystemProperties.getProperty(AAIProperties.AAI_SERVER_URL_BASE) + path;\r
\r
- final Response cres = client.target(url)\r
- .request()\r
- .accept(responseType)\r
- .header("X-TransactionId", transId)\r
- .header("X-FromAppId", fromAppId)\r
- .post(Entity.entity(payload, MediaType.APPLICATION_JSON));\r
- \r
+ final Response cres;\r
+ if (useClientCert == true) {\r
+ cres = client.target(url)\r
+ .request()\r
+ .accept(responseType)\r
+ .header("X-TransactionId", transId)\r
+ .header("X-FromAppId", fromAppId)\r
+ .header("Content-Type", "application/json")\r
+ .post(Entity.entity(payload, MediaType.APPLICATION_JSON));\r
+ } else {\r
+\r
+ String vidUsername = SystemProperties.getProperty(AAIProperties.AAI_VID_USERNAME);\r
+ String vidPassword = Password.deobfuscate(SystemProperties.getProperty(AAIProperties.AAI_VID_PASSWD_X));\r
+ String encodeThis = vidUsername + ":" + vidPassword;\r
+\r
+ cres = client.target(url)\r
+ .request()\r
+ .accept(responseType)\r
+ .header("X-TransactionId", transId)\r
+ .header("X-FromAppId", fromAppId)\r
+ .header("Content-Type", "application/json")\r
+ .header("Authorization", "Basic " + Base64.getEncoder().encodeToString(encodeThis.getBytes("utf-8")))\r
+ .post(Entity.entity(payload, MediaType.APPLICATION_JSON));\r
+ }\r
+\r
if (cres.getStatus() == 200 && cres.getStatus() <= 299) {\r
logger.info(EELFLoggerDelegate.errorLogger, dateFormat.format(new Date()) + "<== " + methodName + " REST api POST was successful!");\r
logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " REST api POST was successful!");\r