Update apache camel from 2.x to 3.x
[aai/router-core.git] / src / main / java / org / onap / aai / rest / RestClientProducer.java
index 2a042d9..ccb8b89 100644 (file)
@@ -2,8 +2,8 @@
  * ============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;
@@ -233,20 +231,21 @@ public class RestClientProducer extends DefaultProducer {
   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;