aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/music/main
diff options
context:
space:
mode:
authorThomas Nelson arthudent3 <nelson24@att.com>2019-06-19 22:19:10 +0000
committerThomas Nelson arthudent3 <nelson24@att.com>2019-06-25 13:20:59 +0000
commit881f14bc8676cedd68e17bd007a869fa85578fa1 (patch)
tree0dc37c36af2483d5d0925dd84993f93f344688f8 /src/main/java/org/onap/music/main
parent078f69315e4b4faffc50e1c7dfde717396e48194 (diff)
Some bug fixes and Minor Chages.
Remove some Commented out code. Cleaned up Variables. Encryption of passwords added Updated Test Cases Fixed some errors in how they were reported. Reduced Logging clutter Some Vulnerability fixes. Change-Id: I64c7935d167d4a976681b5a18fd51aa667d0cd95 Issue-ID: MUSIC-413 Signed-off-by: Thomas Nelson arthudent3 <nelson24@att.com>
Diffstat (limited to 'src/main/java/org/onap/music/main')
-rw-r--r--src/main/java/org/onap/music/main/CipherUtil.java270
-rw-r--r--src/main/java/org/onap/music/main/MusicCore.java2
-rw-r--r--src/main/java/org/onap/music/main/MusicDigest.java79
-rwxr-xr-xsrc/main/java/org/onap/music/main/MusicUtil.java339
-rw-r--r--src/main/java/org/onap/music/main/PropertiesLoader.java76
5 files changed, 414 insertions, 352 deletions
diff --git a/src/main/java/org/onap/music/main/CipherUtil.java b/src/main/java/org/onap/music/main/CipherUtil.java
new file mode 100644
index 00000000..0d5b7710
--- /dev/null
+++ b/src/main/java/org/onap/music/main/CipherUtil.java
@@ -0,0 +1,270 @@
+/*
+ * ============LICENSE_START==========================================
+ * org.onap.music
+ * ===================================================================
+ * Copyright (c) 2017 AT&T Intellectual Property
+ * ===================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END=============================================
+ * ====================================================================
+ */
+
+package org.onap.music.main;
+
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.UnsupportedEncodingException;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.util.Scanner;
+
+import javax.crypto.BadPaddingException;
+import javax.crypto.Cipher;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.lang3.ArrayUtils;
+import org.onap.music.eelf.logging.EELFLoggerDelegate;
+
+public class CipherUtil {
+
+
+ /**
+ * Default key.
+ */
+ private static String keyString = MusicUtil.getCipherEncKey();
+
+ private static final String ALGORITHM = "AES";
+ private static final String ALGORYTHM_DETAILS = ALGORITHM + "/CBC/PKCS5PADDING";
+ private static final int BLOCK_SIZE = 128;
+ @SuppressWarnings("unused")
+ private static SecretKeySpec secretKeySpec;
+ private static IvParameterSpec ivspec;
+ private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(CipherUtil.class);
+ /**
+ * @deprecated Please use {@link #encryptPKC(String)} to encrypt the text.
+ *
+ * Encrypts the text using the specified secret key.
+ *
+ * @param plainText
+ * Text to encrypt
+ * @param secretKey
+ * Key to use for encryption
+ * @return encrypted version of plain text.
+ * @
+ * if any encryption step fails
+ *
+ */
+ @Deprecated
+ public static String encrypt(String plainText, String secretKey) {
+ String encryptedString = null;
+ try {
+ byte[] encryptText = plainText.getBytes("UTF-8");
+ byte[] rawKey = Base64.decodeBase64(secretKey);
+ SecretKeySpec sKeySpec = new SecretKeySpec(rawKey, "AES");
+ Cipher cipher = Cipher.getInstance("AES");
+ cipher.init(Cipher.ENCRYPT_MODE, sKeySpec);
+ encryptedString = Base64.encodeBase64String(cipher.doFinal(encryptText));
+ } catch (BadPaddingException | IllegalBlockSizeException | InvalidKeyException | NoSuchAlgorithmException
+ | NoSuchPaddingException | UnsupportedEncodingException ex) {
+ }
+ return encryptedString;
+ }
+
+ /**
+ * @deprecated Please use {@link #encryptPKC(String)} to encrypt the text.
+ * Encrypts the text using the secret key in key.properties file.
+ *
+ * @param plainText
+ * Text to encrypt
+ * @return Encrypted Text
+ * @
+ * if any decryption step fails
+ */
+ @Deprecated
+ public static String encrypt(String plainText) {
+ return CipherUtil.encrypt(plainText, keyString);
+ }
+
+ /**
+ * Encrypts the text using a secret key.
+ *
+ * @param plainText
+ * Text to encrypt
+ * @return Encrypted Text
+ * @
+ * if any decryption step fails
+ */
+ public static String encryptPKC(String plainText) {
+ return CipherUtil.encryptPKC(plainText, keyString);
+ }
+
+ /**
+ *
+ * @deprecated Please use {@link #decryptPKC(String)} to Decryption the text.
+ *
+ * Decrypts the text using the specified secret key.
+ *
+ * @param encryptedText
+ * Text to decrypt
+ * @param secretKey
+ * Key to use for decryption
+ * @return plain text version of encrypted text
+ * @
+ * if any decryption step fails
+ *
+ */
+ @Deprecated
+ public static String decrypt(String encryptedText, String secretKey) {
+ String encryptedString = null;
+ try {
+ byte[] rawKey = Base64.decodeBase64(secretKey);
+ SecretKeySpec sKeySpec = new SecretKeySpec(rawKey, "AES");
+ byte[] encryptText = Base64.decodeBase64(encryptedText.getBytes("UTF-8"));
+ Cipher cipher = Cipher.getInstance("AES");
+ cipher.init(Cipher.DECRYPT_MODE, sKeySpec);
+ encryptedString = new String(cipher.doFinal(encryptText));
+ } catch (BadPaddingException | IllegalBlockSizeException | InvalidKeyException | NoSuchAlgorithmException
+ | NoSuchPaddingException | UnsupportedEncodingException ex) {
+ }
+ return encryptedString;
+ }
+
+ private static SecretKeySpec getSecretKeySpec() {
+ byte[] key = Base64.decodeBase64(keyString);
+ return new SecretKeySpec(key, ALGORITHM);
+ }
+
+ private static SecretKeySpec getSecretKeySpec(String keyString) {
+ byte[] key = Base64.decodeBase64(keyString);
+ return new SecretKeySpec(key, ALGORITHM);
+ }
+
+ /**
+ * Encrypt the text using the secret key in key.properties file
+ *
+ * @param value
+ * @return The encrypted string
+ * @throws BadPaddingException
+ * @
+ * In case of issue with the encryption
+ */
+ public static String encryptPKC(String value, String skey) {
+ Cipher cipher = null;
+ byte[] iv = null, finalByte = null;
+
+ try {
+ cipher = Cipher.getInstance(ALGORYTHM_DETAILS, "SunJCE");
+
+ SecureRandom r = SecureRandom.getInstance("SHA1PRNG");
+ iv = new byte[BLOCK_SIZE / 8];
+ r.nextBytes(iv);
+ ivspec = new IvParameterSpec(iv);
+ cipher.init(Cipher.ENCRYPT_MODE, getSecretKeySpec(skey), ivspec);
+ finalByte = cipher.doFinal(value.getBytes());
+
+ } catch (Exception ex) {
+
+ }
+ return Base64.encodeBase64String(ArrayUtils.addAll(iv, finalByte));
+ }
+
+ /**
+ * Decrypts the text using the secret key in key.properties file.
+ *
+ * @param message
+ * The encrypted string that must be decrypted using the ecomp
+ * Encryption Key
+ * @return The String decrypted
+ * @
+ * if any decryption step fails
+ */
+ public static String decryptPKC(String message, String skey) {
+ byte[] encryptedMessage = Base64.decodeBase64(message);
+ Cipher cipher;
+ byte[] decrypted = null;
+ try {
+ cipher = Cipher.getInstance(ALGORYTHM_DETAILS, "SunJCE");
+ ivspec = new IvParameterSpec(ArrayUtils.subarray(encryptedMessage, 0, BLOCK_SIZE / 8));
+ byte[] realData = ArrayUtils.subarray(encryptedMessage, BLOCK_SIZE / 8, encryptedMessage.length);
+ cipher.init(Cipher.DECRYPT_MODE, getSecretKeySpec(skey), ivspec);
+ decrypted = cipher.doFinal(realData);
+
+ } catch (Exception ex) {
+
+
+ }
+
+ return new String(decrypted);
+ }
+
+ /**
+ * @deprecated Please use {@link #decryptPKC(String)} to Decrypt the text.
+ *
+ * Decrypts the text using the secret key in key.properties file.
+ *
+ * @param encryptedText
+ * Text to decrypt
+ * @return Decrypted text
+ * @
+ * if any decryption step fails
+ */
+ @Deprecated
+ public static String decrypt(String encryptedText) {
+ return CipherUtil.decrypt(encryptedText, keyString);
+ }
+
+ /**
+ *
+ * Decrypts the text using the secret key in key.properties file.
+ *
+ * @param encryptedText
+ * Text to decrypt
+ * @return Decrypted text
+ * @
+ * if any decryption step fails
+ */
+ public static String decryptPKC(String encryptedText) {
+ return CipherUtil.decryptPKC(encryptedText, keyString);
+ }
+
+
+ public static void readAndSetKeyString() {
+ try {
+ Scanner in = new Scanner(new FileReader("/opt/app/music/etc/properties.txt"));
+ StringBuilder sb = new StringBuilder();
+ while(in.hasNext()) {
+ sb.append(in.next());
+ }
+ in.close();
+ keyString = sb.toString();
+ } catch (FileNotFoundException e) {
+ logger.error(EELFLoggerDelegate.errorLogger, e.getMessage());
+ }
+ }
+
+ /*public static void main(String[] args) {
+
+ System.out.println("Encrypted password: "+encryptPKC("cassandra"));
+
+ System.out.println("Decrypted password: "+decryptPKC("dDhqAp5/RwZbl9yRSZg15fN7Qul9eiE/JFkKemtTib0="));
+ System.out.println("Decrypted password: "+decryptPKC("I/dOtD/YYzBStbtOYhKuUUyPHSW2G9ZzdSyB8bJp4vk="));
+ System.out.println("Decrypted password: "+decryptPKC("g7zJqg74dLsH/fyL7I75b4eySy3pbMS2xVqkrB5lDl8="));
+ }*/
+
+}
diff --git a/src/main/java/org/onap/music/main/MusicCore.java b/src/main/java/org/onap/music/main/MusicCore.java
index 324f4681..6a0d2471 100644
--- a/src/main/java/org/onap/music/main/MusicCore.java
+++ b/src/main/java/org/onap/music/main/MusicCore.java
@@ -122,7 +122,7 @@ public class MusicCore {
}
public static ResultType nonKeyRelatedPut(PreparedQueryObject queryObject, String consistency)
- throws MusicServiceException {
+ throws MusicServiceException,MusicQueryException {
return musicCore.nonKeyRelatedPut(queryObject, consistency);
}
diff --git a/src/main/java/org/onap/music/main/MusicDigest.java b/src/main/java/org/onap/music/main/MusicDigest.java
deleted file mode 100644
index d05969e3..00000000
--- a/src/main/java/org/onap/music/main/MusicDigest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * ============LICENSE_START==========================================
- * org.onap.music
- * ===================================================================
- * Copyright (c) 2017 AT&T Intellectual Property
- * ===================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * ============LICENSE_END=============================================
- * ====================================================================
- */
-
-package org.onap.music.main;
-
-/**
- *
- *
- */
-public class MusicDigest {
- private String evPutStatus;
- private String vectorTs;
-
- /**
- * @param evPutStatus
- * @param vectorTs
- */
- public MusicDigest(String evPutStatus, String vectorTs) {
- this.evPutStatus = evPutStatus;
- this.vectorTs = vectorTs;
- }
-
- /**
- * @return
- */
- public String getEvPutStatus() {
- return evPutStatus;
- }
-
- /**
- * @param evPutStatus
- */
- public void setEvPutStatus(String evPutStatus) {
- this.evPutStatus = evPutStatus;
- }
-
- /**
- * @return
- */
- public String getVectorTs() {
- return vectorTs;
- }
-
- /**
- * @param vectorTs
- */
- public void setVectorTs(String vectorTs) {
- this.vectorTs = vectorTs;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return vectorTs + "|" + evPutStatus;
- }
-}
-
diff --git a/src/main/java/org/onap/music/main/MusicUtil.java b/src/main/java/org/onap/music/main/MusicUtil.java
index 9ffa2503..21e5c255 100755
--- a/src/main/java/org/onap/music/main/MusicUtil.java
+++ b/src/main/java/org/onap/music/main/MusicUtil.java
@@ -31,20 +31,13 @@ import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.Row;
import java.io.File;
import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
import java.math.BigInteger;
import java.nio.ByteBuffer;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
import java.util.Scanner;
-import java.util.StringTokenizer;
import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;
@@ -61,7 +54,6 @@ import org.onap.music.service.impl.MusicCassaCore;
import com.datastax.driver.core.ConsistencyLevel;
import com.datastax.driver.core.DataType;
-import com.sun.jersey.core.util.Base64;
/**
* @author nelson24
@@ -103,30 +95,27 @@ public class MusicUtil {
private static final String PROPERTIES_FILE = "/opt/app/music/etc/music.properties";
public static final String DEFAULTKEYSPACENAME = "TBD";
- private static String myCassaHost = LOCALHOST;
- private static String defaultMusicIp = LOCALHOST;
- private static int cassandraPort = 9042;
- private static int notifytimeout = 30000;
- private static int notifyinterval = 5000;
private static long defaultLockLeasePeriod = 6000;
+ // Amount of times to retry to delete a lock in atomic.
private static int retryCount = 3;
- private static int cacheObjectMaxLife = -1;
private static String lockUsing = MusicUtil.CASSANDRA;
+ // Cadi OnOff
private static boolean isCadi = false;
+ // Keyspace Creation on/off
private static boolean isKeyspaceActive = false;
private static boolean debug = true;
private static String version = "0.0.0";
private static String build = "";
private static String musicPropertiesFilePath = PROPERTIES_FILE;
- private static final String[] propKeys = new String[] { "cassandra.host", "music.ip", "debug",
- "version", "music.rest.ip", "music.properties", "lock.lease.period", "id", "all.ids",
- "public.ip","all.pubic.ips", "cassandra.user", "cassandra.password", "aaf.endpoint.url",
- "admin.username","admin.password","aaf.admin.url","music.namespace","admin.aaf.role",
- "cassandra.port","lock.using","retry.count","transId.header.required",
- "conversation.header.required","clientId.header.required","messageId.header.required",
- "transId.header.prefix","conversation.header.prefix","clientId.header.prefix",
- "messageId.header.prefix"};
+ // private static final String[] propKeys = new String[] { MusicUtil.class.getDeclaredMethod(arg0, )"build","cassandra.host", "debug",
+ // "version", "music.properties", "lock.lease.period", "cassandra.user",
+ // "cassandra.password", "aaf.endpoint.url","admin.username","admin.password",
+ // "music.namespace","admin.aaf.role","cassandra.port","lock.using","retry.count",
+ // "transId.header.required","conversation.header.required","clientId.header.required",
+ // "messageId.header.required","transId.header.prefix","conversation.header.prefix",
+ // "clientId.header.prefix","messageId.header.prefix"};
+ // Consistency Constants and variables.
private static final String[] cosistencyLevel = new String[] {
"ALL","EACH_QUORUM","QUORUM","LOCAL_QUORUM","ONE","TWO",
"THREE","LOCAL_ONE","ANY","SERIAL","LOCAL_SERIAL"};
@@ -143,87 +132,42 @@ public class MusicUtil {
consistencyName.put("LOCAL_ONE",ConsistencyLevel.LOCAL_ONE);
consistencyName.put("LOCAL_SERIAL",ConsistencyLevel.LOCAL_SERIAL);
}
+
+ // Cassandra Values
private static String cassName = "cassandra";
private static String cassPwd;
- private static String aafEndpointUrl = null;
- private static String adminId = "username";
- private static String adminPass= "password";
- private static String aafAdminUrl= null;
- private static String musicNamespace= "org.onap.music.api";
- private static String adminAafRole= "org.onap.music.api.admin_api";
+ private static String myCassaHost = LOCALHOST;
+ private static int cassandraPort = 9042;
+
+ // AAF
+ private static String musicAafNs = "org.onap.music.cadi";
+ // Locking
public static final long MusicEternityEpochMillis = 1533081600000L; // Wednesday, August 1, 2018 12:00:00 AM
public static final long MaxLockReferenceTimePart = 1000000000000L; // millis after eternity (eq sometime in 2050)
public static final long MaxCriticalSectionDurationMillis = 1L * 24 * 60 * 60 * 1000; // 1 day
- private static String transIdPrefix= "false";
- private static String conversationIdPrefix= "false";
- private static String clientIdPrefix= "false";
- private static String messageIdPrefix= "false";
- private static String transIdRequired= "false";
- private static String conversationIdRequired= "false";
- private static String clientIdRequired= "false";
- private static String messageIdRequired= "false";
+ // Response/Request tracking headers
+ private static String transIdPrefix = "false";
+ private static String conversationIdPrefix = "false";
+ private static String clientIdPrefix = "false";
+ private static String messageIdPrefix = "false";
+ private static Boolean transIdRequired = false;
+ private static Boolean conversationIdRequired = false;
+ private static Boolean clientIdRequired = false;
+ private static Boolean messageIdRequired = false;
+ private static String cipherEncKey = "";
+
public static String getLockUsing() {
return lockUsing;
}
-
public static void setLockUsing(String lockUsing) {
MusicUtil.lockUsing = lockUsing;
}
-
- public static String getAafAdminUrl() {
- return aafAdminUrl;
- }
-
-
- public static void setAafAdminUrl(String aafAdminUrl) {
- MusicUtil.aafAdminUrl = aafAdminUrl;
- }
-
-
- public static String getMusicNamespace() {
- return musicNamespace;
- }
-
-
- public static void setMusicNamespace(String musicNamespace) {
- MusicUtil.musicNamespace = musicNamespace;
- }
-
-
- public static String getAdminAafRole() {
- return adminAafRole;
- }
-
-
- public static void setAdminAafRole(String adminAafRole) {
- MusicUtil.adminAafRole = adminAafRole;
- }
-
-
-
- public static String getAdminId() {
- return adminId;
- }
-
- public static void setAdminId(String adminId) {
- MusicUtil.adminId = adminId;
- }
-
-
- public static String getAdminPass() {
- return adminPass;
- }
-
- public static void setAdminPass(String adminPass) {
- MusicUtil.adminPass = adminPass;
- }
-
- private MusicUtil() {
+ public MusicUtil() {
throw new IllegalStateException("Utility Class");
}
/**
@@ -256,30 +200,14 @@ public class MusicUtil {
}
/**
- * @return the aafEndpointUrl
- */
- public static String getAafEndpointUrl() {
- return aafEndpointUrl;
- }
-
- /**
- *
- * @param aafEndpointUrl
- */
- public static void setAafEndpointUrl(String aafEndpointUrl) {
- MusicUtil.aafEndpointUrl = aafEndpointUrl;
- }
-
-
- /**
* Returns An array of property names that should be in the Properties
* files.
*
- * @return
- */
- public static String[] getPropkeys() {
- return propKeys.clone();
- }
+// * @return
+// */
+// public static String[] getPropkeys() {
+// return propKeys.clone();
+// }
/**
* Get MusicPropertiesFilePath - Default = /opt/music/music.properties
@@ -390,24 +318,6 @@ public class MusicUtil {
public static void setMyCassaHost(String myCassaHost) {
MusicUtil.myCassaHost = myCassaHost;
}
-
- /**
- * Get DefaultMusicIp - Default = localhost property file value - music.ip
- *
- * @return
- */
- public static String getDefaultMusicIp() {
- return defaultMusicIp;
- }
-
- /**
- * Set DefaultMusicIp
- *
- * @param defaultMusicIp .
- */
- public static void setDefaultMusicIp(String defaultMusicIp) {
- MusicUtil.defaultMusicIp = defaultMusicIp;
- }
/**
* Gey default retry count
@@ -443,9 +353,11 @@ public class MusicUtil {
}
/**
- * .
+ * This method depricated as its not used or needed.
+ *
* @return String
*/
+ @Deprecated
public static String getTestType() {
String testType = "";
try {
@@ -462,7 +374,9 @@ public class MusicUtil {
}
/**
- *
+ * Method to do a Thread Sleep.
+ * Used for adding a delay.
+ *
* @param time
*/
public static void sleep(long time) {
@@ -638,7 +552,7 @@ public class MusicUtil {
response.header(XPATCHVERSION,verArray[2]);
}
response.header(XLATESTVERSION,version);
- logger.info(EELFLoggerDelegate.applicationLogger,"Version In:" + versionIn);
+ logger.info(EELFLoggerDelegate.auditLogger,"Version In:" + versionIn);
return response;
}
@@ -655,29 +569,6 @@ public class MusicUtil {
return consistencyName.get(consistency.toUpperCase());
}
- public static void setNotifyInterval(int notifyinterval) {
- MusicUtil.notifyinterval = notifyinterval;
- }
- public static void setNotifyTimeOut(int notifytimeout) {
- MusicUtil.notifytimeout = notifytimeout;
- }
-
- public static int getNotifyInterval() {
- return MusicUtil.notifyinterval;
- }
-
- public static int getNotifyTimeout() {
- return MusicUtil.notifytimeout;
- }
-
- public static int getCacheObjectMaxLife() {
- return MusicUtil.cacheObjectMaxLife;
- }
-
- public static void setCacheObjectMaxLife(int cacheObjectMaxLife) {
- MusicUtil.cacheObjectMaxLife = cacheObjectMaxLife;
- }
-
/**
* Given the time of write for an update in a critical section, this method provides a transformed timestamp
* that ensures that a previous lock holder who is still alive can never corrupt a later critical section.
@@ -839,67 +730,89 @@ public class MusicUtil {
}
/**
- * @return the transIdRequired
- */
- public static String getTransIdRequired() {
- return transIdRequired;
- }
-
-
- /**
- * @param transIdRequired the transIdRequired to set
- */
- public static void setTransIdRequired(String transIdRequired) {
- MusicUtil.transIdRequired = transIdRequired;
- }
-
-
- /**
- * @return the conversationIdRequired
- */
- public static String getConversationIdRequired() {
- return conversationIdRequired;
- }
-
-
- /**
- * @param conversationIdRequired the conversationIdRequired to set
- */
- public static void setConversationIdRequired(String conversationIdRequired) {
- MusicUtil.conversationIdRequired = conversationIdRequired;
- }
-
-
- /**
- * @return the clientIdRequired
- */
- public static String getClientIdRequired() {
- return clientIdRequired;
- }
-
-
- /**
- * @param clientIdRequired the clientIdRequired to set
- */
- public static void setClientIdRequired(String clientIdRequired) {
- MusicUtil.clientIdRequired = clientIdRequired;
- }
-
-
- /**
- * @return the messageIdRequired
- */
- public static String getMessageIdRequired() {
- return messageIdRequired;
- }
-
-
- /**
- * @param messageIdRequired the messageIdRequired to set
- */
- public static void setMessageIdRequired(String messageIdRequired) {
- MusicUtil.messageIdRequired = messageIdRequired;
- }
+ * @return the transIdRequired
+ */
+ public static Boolean getTransIdRequired() {
+ return transIdRequired;
+ }
+
+
+ /**
+ * @param transIdRequired the transIdRequired to set
+ */
+ public static void setTransIdRequired(Boolean transIdRequired) {
+ MusicUtil.transIdRequired = transIdRequired;
+ }
+
+
+ /**
+ * @return the conversationIdRequired
+ */
+ public static Boolean getConversationIdRequired() {
+ return conversationIdRequired;
+ }
+
+
+ /**
+ * @param conversationIdRequired the conversationIdRequired to set
+ */
+ public static void setConversationIdRequired(Boolean conversationIdRequired) {
+ MusicUtil.conversationIdRequired = conversationIdRequired;
+ }
+
+
+ /**
+ * @return the clientIdRequired
+ */
+ public static Boolean getClientIdRequired() {
+ return clientIdRequired;
+ }
+
+
+ /**
+ * @param clientIdRequired the clientIdRequired to set
+ */
+ public static void setClientIdRequired(Boolean clientIdRequired) {
+ MusicUtil.clientIdRequired = clientIdRequired;
+ }
+
+
+ /**
+ * @return the messageIdRequired
+ */
+ public static Boolean getMessageIdRequired() {
+ return messageIdRequired;
+ }
+
+ /**
+ * @param messageIdRequired the messageIdRequired to set
+ */
+ public static void setMessageIdRequired(Boolean messageIdRequired) {
+ MusicUtil.messageIdRequired = messageIdRequired;
+ }
+
+
+ public static String getCipherEncKey() {
+ return MusicUtil.cipherEncKey;
+ }
+
+
+ public static void setCipherEncKey(String cipherEncKey) {
+ MusicUtil.cipherEncKey = cipherEncKey;
+ if ( null == cipherEncKey || cipherEncKey.equals("") ||
+ cipherEncKey.equals("nothing to see here")) {
+ logger.error(EELFLoggerDelegate.errorLogger, "Missing Cipher Encryption Key.");
+ }
+ }
+
+ public static String getMusicAafNs() {
+ return MusicUtil.musicAafNs;
+ }
+
+
+ public static void setMusicAafNs(String musicAafNs) {
+ MusicUtil.musicAafNs = musicAafNs;
+ }
diff --git a/src/main/java/org/onap/music/main/PropertiesLoader.java b/src/main/java/org/onap/music/main/PropertiesLoader.java
index c20ce5c5..f99650ae 100644
--- a/src/main/java/org/onap/music/main/PropertiesLoader.java
+++ b/src/main/java/org/onap/music/main/PropertiesLoader.java
@@ -22,9 +22,6 @@
package org.onap.music.main;
-import java.util.ArrayList;
-import java.util.Arrays;
-
import org.onap.music.eelf.logging.EELFLoggerDelegate;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
@@ -33,7 +30,7 @@ import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.stereotype.Component;
-@PropertySource(value = {"file:/opt/app/music/etc/music.properties", "classpath:/project.properties"})
+@PropertySource(value = {"file:/opt/app/music/etc/music.properties", "classpath:/project.properties","file:/opt/app/music/etc/key.properties"})
@Component
public class PropertiesLoader implements InitializingBean {
@@ -64,33 +61,9 @@ public class PropertiesLoader implements InitializingBean {
@Value("${cassandra.password}")
public String cassandraPassword;
- @Value("${aaf.endpoint.url}")
- public String aafEndpointUrl;
-
- @Value("${admin.username}")
- public String adminUsername;
-
- @Value("${admin.password}")
- public String adminPassword;
-
@Value("${cassandra.port}")
public String cassandraPort;
- @Value("${aaf.admin.url}")
- public String aafAdminUrl;
-
- @Value("${music.namespace}")
- public String musicNamespace;
-
- @Value("${admin.aaf.role}")
- public String adminAafRole;
-
- @Value("${notify.interval}")
- public String notifyInterval;
-
- @Value("${notify.timeout}")
- public String notifyTimeout;
-
@Value("${cadi}")
public String isCadi;
@@ -113,16 +86,22 @@ public class PropertiesLoader implements InitializingBean {
private String messageIdPrefix;
@Value("${transId.header.required}")
- private String transIdRequired;
+ private Boolean transIdRequired;
@Value("${conversation.header.required}")
- private String conversationIdRequired;
+ private Boolean conversationIdRequired;
@Value("${clientId.header.required}")
- private String clientIdRequired;
+ private Boolean clientIdRequired;
@Value("${messageId.header.required}")
- private String messageIdRequired;
+ private Boolean messageIdRequired;
+
+ @Value("${music.aaf.ns}")
+ private String musicAafNs;
+
+ @Value("${cipher.enc.key}")
+ private String cipherEncKey;
private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PropertiesLoader.class);
@@ -139,20 +118,11 @@ public class PropertiesLoader implements InitializingBean {
* .
*/
public void loadProperties() {
- if (aafAdminUrl != null && !aafAdminUrl.equals("${aaf.admin.url}")) {
- MusicUtil.setAafAdminUrl(aafAdminUrl);
+ if(cipherEncKey != null) {
+ MusicUtil.setCipherEncKey(cipherEncKey);
}
- if (aafEndpointUrl != null && !aafEndpointUrl.equals("${aaf.endpoint.url}")) {
- MusicUtil.setAafEndpointUrl(aafEndpointUrl);
- }
- if (adminAafRole != null && !adminAafRole.equals("${admin.aaf.role}")) {
- MusicUtil.setAdminAafRole(adminAafRole);
- }
- if (adminPassword != null && !adminPassword.equals("${admin.password}")) {
- MusicUtil.setAdminPass(adminPassword);
- }
- if (adminUsername != null && !adminUsername.equals("${admin.username}")) {
- MusicUtil.setAdminId(adminUsername);
+ if (musicAafNs != null) {
+ MusicUtil.setMusicAafNs(musicAafNs);
}
if (cassandraPort != null && !cassandraPort.equals("${cassandra.port}")) {
MusicUtil.setCassandraPort(Integer.parseInt(cassandraPort));
@@ -169,24 +139,12 @@ public class PropertiesLoader implements InitializingBean {
if (lockLeasePeriod != null && !lockLeasePeriod.equals("${lock.lease.period}")) {
MusicUtil.setDefaultLockLeasePeriod(Long.parseLong(lockLeasePeriod));
}
- if (musicIp != null && !musicIp.equals("${music.ip}")) {
- MusicUtil.setDefaultMusicIp(musicIp);
- }
- if (musicNamespace != null && !musicNamespace.equals("${music.namespace}")) {
- MusicUtil.setMusicNamespace(musicNamespace);
- }
if (musicProperties != null && !musicProperties.equals("${music.properties}")) {
MusicUtil.setMusicPropertiesFilePath(musicProperties);
}
if (cassandraHost != null && !cassandraHost.equals("${cassandra.host}")) {
MusicUtil.setMyCassaHost(cassandraHost);
}
- if (notifyInterval != null && !notifyInterval.equals("${notify.interval}")) {
- MusicUtil.setNotifyInterval(Integer.parseInt(notifyInterval));
- }
- if (notifyTimeout != null && !notifyTimeout.equals("${notify.timeout}")) {
- MusicUtil.setNotifyTimeOut(Integer.parseInt(notifyTimeout));
- }
if (version != null && !version.equals("${version}")) {
MusicUtil.setVersion(version);
}
@@ -202,8 +160,6 @@ public class PropertiesLoader implements InitializingBean {
if (isKeyspaceActive != null && !isKeyspaceActive.equals("${keyspace.active}")) {
MusicUtil.setKeyspaceActive(Boolean.parseBoolean(isKeyspaceActive));
}
-
-
if(transIdPrefix!=null) {
MusicUtil.setTransIdPrefix(transIdPrefix);
}
@@ -236,6 +192,8 @@ public class PropertiesLoader implements InitializingBean {
MusicUtil.setMessageIdRequired(messageIdRequired);
}
}
+
+
@Override