X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ecomp-portal-BE-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fportalapp%2Fportal%2Fscheduler%2Fclient%2FHttpsBasicClient.java;h=3360104cefcd03fb957be5c8b10c839f9e3327ba;hb=da7323ca54971da34b0f18da7463e408951f67f2;hp=d618a6ee3f70d0bd763122832801d4a92ef3e209;hpb=e42eae64a6ed2dbdf9dd1112bb31633faf60e0a3;p=portal.git diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/client/HttpsBasicClient.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/client/HttpsBasicClient.java index d618a6ee..3360104c 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/client/HttpsBasicClient.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/client/HttpsBasicClient.java @@ -58,6 +58,10 @@ import org.onap.portalapp.portal.scheduler.SchedulerProperties; import org.onap.portalapp.portal.scheduler.util.CustomJacksonJaxBJsonProvider; import org.onap.portalapp.util.DateUtil; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.onap.portalsdk.core.onboarding.exception.CipherUtilException; +import org.onap.portalsdk.core.onboarding.util.CipherUtil; +import org.onap.portalsdk.core.onboarding.util.KeyConstants; +import org.onap.portalsdk.core.onboarding.util.KeyProperties; /** * General SSL client using the VID tomcat keystore. It doesn't use client certificates. @@ -77,8 +81,7 @@ public class HttpsBasicClient{ public static Client getClient() throws Exception { String methodName = "getClient"; ClientConfig config = new ClientConfig(); - //config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE); - //config.getClasses().add(org.onap.aai.util.CustomJacksonJaxBJsonProvider.class); + SSLContext ctx = null; @@ -87,17 +90,25 @@ public class HttpsBasicClient{ SimpleDateFormat dateFormat = DateUtil.getDateFormat(); config.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true); - String truststore_path = SchedulerProperties.getProperty(SchedulerProperties.VID_TRUSTSTORE_FILENAME); + String truststorePath = SchedulerProperties.getProperty(SchedulerProperties.VID_TRUSTSTORE_FILENAME); logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + " " + methodName + " " + "truststore_path=" + - truststore_path); - String truststore_password = SchedulerProperties.getProperty(SchedulerProperties.VID_TRUSTSTORE_PASSWD_X); + truststorePath); + String truststorePassword = SchedulerProperties.getProperty(SchedulerProperties.VID_TRUSTSTORE_PASSWD_X); - String decrypted_truststore_password = Password.deobfuscate(truststore_password); + String decryptedTruststorePassword = null; + try { + decryptedTruststorePassword = CipherUtil.decryptPKC(truststorePassword, KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); + } + catch (CipherUtilException e) { + logger.error(EELFLoggerDelegate.errorLogger, "failed to decrypt; Using as is", e); + decryptedTruststorePassword = truststorePassword; + } + //logger.debug(dateFormat.format(new Date()) + " " + methodName + " decrypted_truststore_password=" + decrypted_truststore_password); - File tr = new File (truststore_path); + File tr = new File (truststorePath); logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + " " + methodName + " absolute " + "truststore path=" + tr.getAbsolutePath()); @@ -105,8 +116,8 @@ public class HttpsBasicClient{ //String keystore_password = SystemProperties.getProperty(AAIProperties.AAI_KEYSTORE_PASSWD_X); //String decrypted_keystore_password = EncryptedPropValue.decryptTriple(keystore_password); - System.setProperty("javax.net.ssl.trustStore", truststore_path); - System.setProperty("javax.net.ssl.trustStorePassword", decrypted_truststore_password); + System.setProperty("javax.net.ssl.trustStore", truststorePath); + System.setProperty("javax.net.ssl.trustStorePassword", decryptedTruststorePassword); HttpsURLConnection.setDefaultHostnameVerifier( new HostnameVerifier(){ public boolean verify(String string,SSLSession ssls) { return true; @@ -134,9 +145,7 @@ public class HttpsBasicClient{ ctx.init(kmf.getKeyManagers(), null, null); */ ctx.init(null, null, null); - //config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, - // new HTTPSProperties( , ctx)); - + return ClientBuilder.newBuilder() .sslContext(ctx) .hostnameVerifier(new HostnameVerifier() { @@ -148,17 +157,9 @@ public class HttpsBasicClient{ .build() .register(CustomJacksonJaxBJsonProvider.class); - } catch (Exception e) { - logger.debug(EELFLoggerDelegate.debugLogger, "Error setting up config: exiting"); - //System.out.println("Error setting up config: exiting"); - e.printStackTrace(); - return null; - } - - //Client client = ClientBuilder.newClient(config); - // uncomment this line to get more logging for the request/response - // client.addFilter(new LoggingFilter(System.out)); - - //return client; - } -} + } catch (Exception e) { + logger.debug(EELFLoggerDelegate.debugLogger, "Error setting up config: exiting", e); + return null; + } + } +}