summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNTNET\renealr <reneal.rogers@amdocs.com>2017-10-13 15:09:51 -0400
committerNTNET\renealr <reneal.rogers@amdocs.com>2017-10-13 16:02:56 -0400
commit615f200d630fa0e1b74317f193ca366a7980eb79 (patch)
treeb077e557c5ebbfd5e7e3e097f115867382b5c049 /src
parent25dea2d3021dd0b1e54a93dea5b296781abe828f (diff)
Fixed the critical issues sonar encountered
The hardcoded password has been fixed as well as the generic exceptions were changed to specific exceptions. Change-Id: I9b3b11bfaa2e680c46158d11d8f8f6e3d56aa6e5 Issue-ID:AAI-249 Signed-off-by: NTNET\renealr <reneal.rogers@amdocs.com>
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/aai/sparky/synchronizer/config/SynchronizerConfiguration.java17
-rw-r--r--src/main/java/org/onap/aai/sparky/util/Encryptor.java6
-rw-r--r--src/main/java/org/onap/aai/sparky/util/KeystoreBuilder.java3
3 files changed, 12 insertions, 14 deletions
diff --git a/src/main/java/org/onap/aai/sparky/synchronizer/config/SynchronizerConfiguration.java b/src/main/java/org/onap/aai/sparky/synchronizer/config/SynchronizerConfiguration.java
index 914629f..3e4afff 100644
--- a/src/main/java/org/onap/aai/sparky/synchronizer/config/SynchronizerConfiguration.java
+++ b/src/main/java/org/onap/aai/sparky/synchronizer/config/SynchronizerConfiguration.java
@@ -32,6 +32,7 @@ import java.util.Properties;
import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
import org.onap.aai.sparky.logging.AaiUiMsgs;
import org.onap.aai.sparky.util.ConfigHelper;
@@ -69,12 +70,12 @@ public class SynchronizerConfiguration {
/**
* Instantiates a new synchronizer configuration.
*/
- public SynchronizerConfiguration() throws Exception {
+ public SynchronizerConfiguration() throws NumberFormatException,PatternSyntaxException,Exception {
Properties props = ConfigHelper.loadConfigFromExplicitPath(CONFIG_FILE);
initialize(props);
}
- public SynchronizerConfiguration(Properties props) throws Exception {
+ public SynchronizerConfiguration(Properties props) throws NumberFormatException, PatternSyntaxException, Exception {
initialize(props);
}
/**
@@ -82,7 +83,7 @@ public class SynchronizerConfiguration {
*
* @throws Exception the exception
*/
- protected void initialize(Properties props) throws Exception {
+ protected void initialize(Properties props) throws NumberFormatException, PatternSyntaxException, Exception {
// parse config for startup sync
try {
@@ -90,9 +91,9 @@ public class SynchronizerConfiguration {
Integer.parseInt(props.getProperty("synchronizer.syncTask.initialDelayInMs",
SynchronizerConstants.DEFAULT_INITIAL_DELAY_IN_MS));
if (syncTaskInitialDelayInMs < 0) {
- throw new Exception();
+ throw new NumberFormatException("Error. Sync Task Delay has to be positive");
}
- } catch (Exception exc) {
+ } catch (NumberFormatException exc) {
this.setConfigOkForStartupSync(false);
syncTaskInitialDelayInMs = SynchronizerConstants.DEFAULT_CONFIG_ERROR_INT_VALUE;
String message = "Invalid configuration for synchronizer parameter:"
@@ -106,9 +107,9 @@ public class SynchronizerConfiguration {
Integer.parseInt(props.getProperty("synchronizer.syncTask.taskFrequencyInDay",
SynchronizerConstants.DEFAULT_TASK_FREQUENCY_IN_DAY));
if (syncTaskFrequencyInDay < 0) {
- throw new Exception();
+ throw new NumberFormatException("Error. Sync Task Frequency has to be positive");
}
- } catch (Exception exc) {
+ } catch (NumberFormatException exc) {
this.setConfigOkForPeriodicSync(false);
syncTaskFrequencyInDay = SynchronizerConstants.DEFAULT_CONFIG_ERROR_INT_VALUE;
String message = "Invalid configuration for synchronizer parameter:"
@@ -122,7 +123,7 @@ public class SynchronizerConfiguration {
Pattern pattern = Pattern.compile(SynchronizerConstants.TIMESTAMP24HOURS_PATTERN);
Matcher matcher = pattern.matcher(syncTaskStartTime);
if (!matcher.matches()) {
- throw new Exception();
+ throw new PatternSyntaxException("Pattern Mismatch","The erroneous pattern is not available",-1);
}
List<String> timestampVal = Arrays.asList(syncTaskStartTime.split(" "));
diff --git a/src/main/java/org/onap/aai/sparky/util/Encryptor.java b/src/main/java/org/onap/aai/sparky/util/Encryptor.java
index a9b2929..828a891 100644
--- a/src/main/java/org/onap/aai/sparky/util/Encryptor.java
+++ b/src/main/java/org/onap/aai/sparky/util/Encryptor.java
@@ -49,12 +49,8 @@ public class Encryptor {
public String decryptValue(String value) {
String decyptedValue = "";
- try {
decyptedValue = Password.deobfuscate(value);
- } catch (Exception exc) {
- System.err.println("Cannot decrypt '" + value + "': " + exc.toString());
- }
-
+
return decyptedValue;
}
diff --git a/src/main/java/org/onap/aai/sparky/util/KeystoreBuilder.java b/src/main/java/org/onap/aai/sparky/util/KeystoreBuilder.java
index 54474db..4058a0d 100644
--- a/src/main/java/org/onap/aai/sparky/util/KeystoreBuilder.java
+++ b/src/main/java/org/onap/aai/sparky/util/KeystoreBuilder.java
@@ -207,7 +207,7 @@ public class KeystoreBuilder {
} else {
System.out.println("keystore file doesn't exist, preloading new file with jssecacerts");
}
- password = "changeit";
+ password = keystorePassword;
}
@@ -270,6 +270,7 @@ public class KeystoreBuilder {
System.exit(0);
} catch (SSLException exc) {
System.out.println("\nCaught SSL exception, we are not authorized to access this server yet");
+ throw new SSLException("\nCaught SSL exception, we are not authorized to access this server yet");
// e.printStackTrace(System.out);
}