diff options
3 files changed, 20 insertions, 3 deletions
diff --git a/sparkybe-onap-application/pom.xml b/sparkybe-onap-application/pom.xml index b08c9fd..cc5e004 100644 --- a/sparkybe-onap-application/pom.xml +++ b/sparkybe-onap-application/pom.xml @@ -224,7 +224,7 @@ <dependency> <groupId>org.onap.aai</groupId> <artifactId>rest-client</artifactId> - <version>1.2.1</version> + <version>1.3.0-SNAPSHOT</version> </dependency> <!-- https://mvnrepository.com/artifact/org.restlet.jee/org.restlet.ext.servlet --> diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/dal/ActiveInventoryAdapter.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/dal/ActiveInventoryAdapter.java index 9d33a3b..656ffba 100644 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/dal/ActiveInventoryAdapter.java +++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/dal/ActiveInventoryAdapter.java @@ -47,7 +47,9 @@ import org.onap.aai.sparky.dal.rest.RestClientConstructionException; import org.onap.aai.sparky.dal.rest.RestClientFactory; import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig; import org.onap.aai.sparky.logging.AaiUiMsgs; +import org.onap.aai.sparky.util.Encryptor; import org.onap.aai.sparky.util.NodeUtils; +import org.onap.aai.sparky.viewandinspect.config.SparkyConstants; /** * The Class ActiveInventoryAdapter. @@ -87,6 +89,21 @@ public class ActiveInventoryAdapter { this.oxmModelLoader = oxmModelLoader; this.oxmEntityLookup = oxmEntityLookup; this.endpointConfig = endpointConfig; + + /* + * Add support for de-obfuscating basic auth password (if obfuscated) + */ + + if (endpointConfig.getRestAuthenticationMode() == RestAuthenticationMode.SSL_BASIC) { + String basicAuthPassword = endpointConfig.getBasicAuthPassword(); + + if (basicAuthPassword != null + && basicAuthPassword.startsWith(SparkyConstants.OBFUSCATION_PREFIX)) { + Encryptor enc = new Encryptor(); + endpointConfig.setBasicAuthPassword(enc.decryptValue(basicAuthPassword)); + } + } + this.restClient = RestClientFactory.buildClient(endpointConfig); } @@ -102,16 +119,15 @@ public class ActiveInventoryAdapter { headers.get(HEADER_TRANS_ID).add(TRANSACTION_ID_PREFIX + NodeUtils.getRandomTxnId()); if (endpointConfig.getRestAuthenticationMode() == RestAuthenticationMode.SSL_BASIC) { - headers.putIfAbsent(HEADER_AUTHORIZATION, new ArrayList<String>()); headers.get(HEADER_AUTHORIZATION).add(getBasicAuthenticationCredentials()); - } return headers; } protected String getBasicAuthenticationCredentials() { + String usernameAndPassword = String.join(":", endpointConfig.getBasicAuthUserName(), endpointConfig.getBasicAuthPassword()); return "Basic " + java.util.Base64.getEncoder().encodeToString(usernameAndPassword.getBytes()); diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/config/SparkyConstants.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/config/SparkyConstants.java index e3c2577..b5f72bc 100644 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/config/SparkyConstants.java +++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/config/SparkyConstants.java @@ -26,6 +26,7 @@ package org.onap.aai.sparky.viewandinspect.config; public class SparkyConstants { public static String APP_NAME = "AAIUI"; + public static final String OBFUSCATION_PREFIX = "OBF:"; /** Default to unix file separator if system property file.separator is null */ public static final String FILESEP = |