* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017 Amdocs
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 Amdocs
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
package org.onap.aai.rest;
import org.apache.camel.Exchange;
-import org.apache.camel.impl.DefaultProducer;
+import org.apache.camel.support.DefaultProducer;
import org.eclipse.jetty.util.security.Password;
-import org.onap.aai.event.EventBusConsumer;
import org.onap.aai.restclient.client.Headers;
import org.onap.aai.restclient.client.OperationResult;
import org.onap.aai.restclient.client.RestClient;
+import org.onap.aai.restclient.enums.RestAuthenticationMode;
import org.onap.aai.restclient.rest.HttpUtil;
import org.onap.aai.cl.api.Logger;
import org.onap.aai.cl.eelf.LoggerFactory;
}
// Now, invoke the REST client to perform the operation.
- OperationResult result = null;
+ OperationResult result;
switch (getOperation(exchange)) {
case GET:
break;
}
- // Populate the OUT message with our result.
- exchange.getOut().setHeader(RestClientEndpoint.OUT_HEADER_RESPONSE_CODE,
+ /** Just use IN headers as camel does not pass incoming headers from IN to OUT so they might be lost .
+ Reference : http://camel.apache.org/using-getin-or-getout-methods-on-exchange.html **/
+ exchange.getIn().setHeader(RestClientEndpoint.OUT_HEADER_RESPONSE_CODE,
result.getResultCode());
if (HttpUtil.isHttpResponseClassSuccess(result.getResultCode())) {
- exchange.getOut().setHeader(RestClientEndpoint.OUT_HEADER_RESPONSE_MSG,
+ exchange.getIn().setHeader(RestClientEndpoint.OUT_HEADER_RESPONSE_MSG,
responseStatusStringFromResult(result));
- exchange.getOut().setBody(result.getResult());
+ exchange.getIn().setBody(result.getResult());
} else {
- exchange.getOut().setHeader(RestClientEndpoint.OUT_HEADER_RESPONSE_MSG,
+ exchange.getIn().setHeader(RestClientEndpoint.OUT_HEADER_RESPONSE_MSG,
result.getFailureCause());
}
private RestClient getRestClient() {
if (restClient == null) {
-
- String keystoreFilename = endpoint.getEcompKeystore();
+
String keystorePassword = endpoint.getEcompKeystorePassword();
String clientCertFilename = endpoint.getEcompClientCert();
if (logger.isDebugEnabled()) {
logger.debug("Instantiating REST Client with client_cert=" + clientCertFilename
- + " keystore=" + keystoreFilename + " keystorePassword=" + keystorePassword);
+ + " keystorePassword=" + keystorePassword);
}
+ String deobfuscatedCertPassword = keystorePassword.startsWith("OBF:")?Password.deobfuscate(keystorePassword):keystorePassword;
+
// Create REST client for search service
- restClient = new RestClient().validateServerHostname(false).validateServerCertChain(true)
- .clientCertFile(clientCertFilename)
- .clientCertPassword(Password.deobfuscate(keystorePassword)).trustStore(keystoreFilename);
+ restClient = new RestClient().authenticationMode(RestAuthenticationMode.SSL_CERT).validateServerHostname(false)
+ .validateServerCertChain(false).clientCertFile(clientCertFilename)
+ .clientCertPassword(deobfuscatedCertPassword);
}
return restClient;