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>
import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
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;
import org.onap.aai.sparky.logging.AaiUiMsgs;
import org.onap.aai.sparky.util.ConfigHelper;
/**
* Instantiates a new synchronizer configuration.
*/
/**
* Instantiates a new synchronizer configuration.
*/
- public SynchronizerConfiguration() throws Exception {
+ public SynchronizerConfiguration() throws NumberFormatException,PatternSyntaxException,Exception {
Properties props = ConfigHelper.loadConfigFromExplicitPath(CONFIG_FILE);
initialize(props);
}
Properties props = ConfigHelper.loadConfigFromExplicitPath(CONFIG_FILE);
initialize(props);
}
- public SynchronizerConfiguration(Properties props) throws Exception {
+ public SynchronizerConfiguration(Properties props) throws NumberFormatException, PatternSyntaxException, Exception {
*
* @throws Exception the exception
*/
*
* @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 {
// parse config for startup sync
try {
Integer.parseInt(props.getProperty("synchronizer.syncTask.initialDelayInMs",
SynchronizerConstants.DEFAULT_INITIAL_DELAY_IN_MS));
if (syncTaskInitialDelayInMs < 0) {
Integer.parseInt(props.getProperty("synchronizer.syncTask.initialDelayInMs",
SynchronizerConstants.DEFAULT_INITIAL_DELAY_IN_MS));
if (syncTaskInitialDelayInMs < 0) {
+ 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:"
this.setConfigOkForStartupSync(false);
syncTaskInitialDelayInMs = SynchronizerConstants.DEFAULT_CONFIG_ERROR_INT_VALUE;
String message = "Invalid configuration for synchronizer parameter:"
Integer.parseInt(props.getProperty("synchronizer.syncTask.taskFrequencyInDay",
SynchronizerConstants.DEFAULT_TASK_FREQUENCY_IN_DAY));
if (syncTaskFrequencyInDay < 0) {
Integer.parseInt(props.getProperty("synchronizer.syncTask.taskFrequencyInDay",
SynchronizerConstants.DEFAULT_TASK_FREQUENCY_IN_DAY));
if (syncTaskFrequencyInDay < 0) {
+ 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:"
this.setConfigOkForPeriodicSync(false);
syncTaskFrequencyInDay = SynchronizerConstants.DEFAULT_CONFIG_ERROR_INT_VALUE;
String message = "Invalid configuration for synchronizer parameter:"
Pattern pattern = Pattern.compile(SynchronizerConstants.TIMESTAMP24HOURS_PATTERN);
Matcher matcher = pattern.matcher(syncTaskStartTime);
if (!matcher.matches()) {
Pattern pattern = Pattern.compile(SynchronizerConstants.TIMESTAMP24HOURS_PATTERN);
Matcher matcher = pattern.matcher(syncTaskStartTime);
if (!matcher.matches()) {
+ throw new PatternSyntaxException("Pattern Mismatch","The erroneous pattern is not available",-1);
}
List<String> timestampVal = Arrays.asList(syncTaskStartTime.split(" "));
}
List<String> timestampVal = Arrays.asList(syncTaskStartTime.split(" "));
public String decryptValue(String value) {
String decyptedValue = "";
public String decryptValue(String value) {
String decyptedValue = "";
decyptedValue = Password.deobfuscate(value);
decyptedValue = Password.deobfuscate(value);
- } catch (Exception exc) {
- System.err.println("Cannot decrypt '" + value + "': " + exc.toString());
- }
-
} else {
System.out.println("keystore file doesn't exist, preloading new file with jssecacerts");
}
} else {
System.out.println("keystore file doesn't exist, preloading new file with jssecacerts");
}
+ password = keystorePassword;
System.exit(0);
} catch (SSLException exc) {
System.out.println("\nCaught SSL exception, we are not authorized to access this server yet");
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);
}
// e.printStackTrace(System.out);
}