aboutsummaryrefslogtreecommitdiffstats
path: root/common/src/main/java/org/openecomp/mso/properties
diff options
context:
space:
mode:
authorRob Daugherty <rd472p@att.com>2018-03-14 02:07:32 -0400
committerRob Daugherty <rd472p@att.com>2018-03-14 04:08:41 -0400
commit38f720752af4d4aad8c4e467a288d9048659f688 (patch)
treee81066a8b5c77272e30fb57a64999573c4db4d86 /common/src/main/java/org/openecomp/mso/properties
parentaee3d223f92a6f250f43e17558a2dfd576ff7294 (diff)
AT&T 1712 and 1802 release code
This is code from AT&T's 1712 and 1802 releases. Change-Id: Ie1e85851e94bc66c4d9514a0226c221939531a04 Issue-ID: SO-425 Signed-off-by: Rob Daugherty <rd472p@att.com>
Diffstat (limited to 'common/src/main/java/org/openecomp/mso/properties')
-rw-r--r--common/src/main/java/org/openecomp/mso/properties/MsoJavaProperties.java46
1 files changed, 45 insertions, 1 deletions
diff --git a/common/src/main/java/org/openecomp/mso/properties/MsoJavaProperties.java b/common/src/main/java/org/openecomp/mso/properties/MsoJavaProperties.java
index f0ca191978..c13b9e0b53 100644
--- a/common/src/main/java/org/openecomp/mso/properties/MsoJavaProperties.java
+++ b/common/src/main/java/org/openecomp/mso/properties/MsoJavaProperties.java
@@ -24,7 +24,11 @@ package org.openecomp.mso.properties;
import java.io.FileReader;
import java.io.IOException;
import java.security.GeneralSecurityException;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Properties;
+
+import org.apache.commons.codec.binary.Base64;
import org.openecomp.mso.utils.CryptoUtils;
public class MsoJavaProperties extends AbstractMsoProperties {
@@ -86,11 +90,43 @@ public class MsoJavaProperties extends AbstractMsoProperties {
}
+ /**
+ * @param encryptedAuth: encrypted credentials from properties
+ * @param msoKey: key to use to decrypt from properties
+ * @return base 64 encoded basic auth credentials
+ */
+ public synchronized String getBasicAuth(String encryptedAuth, String msoKey){
+ String encodedString = null;
+ if ((encryptedAuth == null || encryptedAuth.isEmpty()) || (msoKey == null || msoKey.isEmpty()))
+ return null;
+ try {
+ String auth = decrypt(encryptedAuth, msoKey);
+ byte[] encoded = Base64.encodeBase64(auth.getBytes());
+ encodedString = new String(encoded);
+ encodedString = "Basic " + encodedString;
+
+ } catch (Exception ex) {
+ LOGGER.debug("Exception while getBasicAuth " + encryptedAuth, ex);
+ }
+ return encodedString;
+ }
+
public synchronized int size() {
return this.msoProperties.size();
}
-
+ public synchronized String decrypt(String toDecrypt, String msokey){
+ String result = null;
+ try {
+ result = CryptoUtils.decrypt(toDecrypt, msokey);
+
+ }
+ catch (Exception e) {
+ LOGGER.debug("Failed to decrypt credentials: " + toDecrypt, e);
+ }
+ return result;
+ }
+
@Override
protected synchronized void reloadPropertiesFile() throws IOException {
this.loadPropertiesFile(this.propertiesFileName);
@@ -181,4 +217,12 @@ public class MsoJavaProperties extends AbstractMsoProperties {
return response.toString();
}
+
+ public Map<String, String> asMap() {
+ final Map<String, String> result = new HashMap<>();
+ msoProperties.forEach((key, value) -> result.put(key.toString(), value.toString()));
+
+ return result;
+ }
+
}