diff --git a/lib/commons-codec-1.17.1.jar b/lib/commons-codec-1.17.1.jar new file mode 100644 index 0000000..5023670 Binary files /dev/null and b/lib/commons-codec-1.17.1.jar differ diff --git a/lib/commons-csv-1.12.0.jar b/lib/commons-csv-1.12.0.jar new file mode 100644 index 0000000..0c80d8c Binary files /dev/null and b/lib/commons-csv-1.12.0.jar differ diff --git a/lib/commons-io-2.18.0.jar b/lib/commons-io-2.18.0.jar new file mode 100644 index 0000000..6f1e48d Binary files /dev/null and b/lib/commons-io-2.18.0.jar differ diff --git a/lib/jcommander-1.82.jar b/lib/jcommander-1.82.jar new file mode 100644 index 0000000..90f4424 Binary files /dev/null and b/lib/jcommander-1.82.jar differ diff --git a/src/com/belkast/soap/jCommanderArgs.java b/src/com/belkast/soap/jCommanderArgs.java index b4af093..a11a3c8 100644 --- a/src/com/belkast/soap/jCommanderArgs.java +++ b/src/com/belkast/soap/jCommanderArgs.java @@ -13,6 +13,6 @@ public class jCommanderArgs { @Parameter(names = "--encrypt", description = "Value to encrypt using the Encryption Key") public String encrypt; - @Parameter(names = "--debug", description = "Display debug information on the screen") + @Parameter(names = "--debug", description = "Display debug information on the screen (true/false)") public String debug; } diff --git a/src/com/belkast/soap/jCommanderVerifyFile.java b/src/com/belkast/soap/jCommanderVerifyFile.java index 05a1aee..2a60554 100644 --- a/src/com/belkast/soap/jCommanderVerifyFile.java +++ b/src/com/belkast/soap/jCommanderVerifyFile.java @@ -9,14 +9,20 @@ public class jCommanderVerifyFile implements IParameterValidator { public void validate(String name, String value) throws ParameterException { - File file = new File (value); - boolean isThere = file.exists(); - - if (!isThere) + try + { + File file = new File(value); + boolean success = file.exists(); + if (!success) + { + throw new ParameterException("Parameter value " + name + " points to a file that does not exist : " + value); + } + } + catch (ParameterException ex) { System.out.println(); - System.out.println("Parameter value " + name + " points to a file that does not exist!"); - throw new ParameterException("Parameter value " + name + " points to a file that does not exist!"); + System.out.println(ex.toString()); + System.exit(0); } } } diff --git a/src/com/belkast/soap/jCommanderVerifyKey.java b/src/com/belkast/soap/jCommanderVerifyKey.java index 8a7b8c0..9aa11f3 100644 --- a/src/com/belkast/soap/jCommanderVerifyKey.java +++ b/src/com/belkast/soap/jCommanderVerifyKey.java @@ -7,11 +7,17 @@ public class jCommanderVerifyKey implements IParameterValidator { public void validate(String name, String value) throws ParameterException { + try { int n = value.length(); if (n != 16) { - System.out.println(); - System.out.println("Parameter value " + name + " must have a length of 16 characters!"); throw new ParameterException("Parameter value " + name + " must have a length of 16 characters!"); } } + catch (ParameterException ex) + { + System.out.println(); + System.out.println(ex.toString()); + System.exit(0); + } + } } diff --git a/src/com/belkast/soap/userVerify.java b/src/com/belkast/soap/userVerify.java index 9a8b69e..24fe7c5 100644 --- a/src/com/belkast/soap/userVerify.java +++ b/src/com/belkast/soap/userVerify.java @@ -13,14 +13,18 @@ public class userVerify public static void main (String[] args) { System.out.println(); Scanner myObj = new Scanner(System.in); // Create a Scanner object - System.out.print("Enter the name of the file to verify : "); - String varFileName = myObj.nextLine(); // Read user input - File thisFile = new File(varFileName); - if (!thisFile.exists()) { - System.out.println("The file " + varFileName + " does not exist. Please enter a valid filename!"); - System.exit(0); + String varFileName = new String(); + while (true) { + System.out.print("Enter the name of the file to verify : "); + varFileName = myObj.nextLine(); // Read user input + File thisFile = new File(varFileName); + if (thisFile.exists()) + { + break; + } } + System.out.println(); System.out.println("CSV input file : " + varFileName); ArrayList thisCSV = readCSV(varFileName, true); @@ -41,7 +45,7 @@ public class userVerify } System.out.println(); } - boolean validfile = (thisCSV.isEmpty()); + boolean validfile = (!thisCSV.isEmpty()); System.out.println("CSV file records : " + varIter); System.out.println("CSV file is valid : " + validfile); System.out.println(); @@ -62,10 +66,9 @@ public class userVerify Reader in = new FileReader(varFile); String varHeader = fileProcessor.readFirstLine(thisFile); - System.out.println(varHeader); if (varHeader.length() == 0) { - System.out.println("The " + thisFile + " file appears to be missing a valid header!"); + System.out.println(thisFile + " : appears to be missing a valid header!"); return finalArray; } @@ -97,7 +100,7 @@ public class userVerify finalArray.add(record.toMap()); if (fromUser) { - System.out.println("PASSED => CSV line : " + lineNum); + System.out.println("PASSED : CSV line " + lineNum); } } else @@ -105,8 +108,8 @@ public class userVerify invalidNum++; if (fromUser) { - System.out.println("FAILED => CSV line : " + lineNum); - System.out.println("FAILED => Contents : " + lineNum + " is " + record.toMap().toString()); + System.out.println("FAILED : CSV line " + lineNum); + System.out.println("FAILED : Contents " + record.toMap().toString()); } } } diff --git a/src/com/belkast/soap/webService.java b/src/com/belkast/soap/webService.java index 15cdf16..e30e6eb 100644 --- a/src/com/belkast/soap/webService.java +++ b/src/com/belkast/soap/webService.java @@ -46,7 +46,7 @@ public class webService { varKey = args.key; String varToEncrypt = args.encrypt; - if (varToEncrypt != null && varToEncrypt.length() > 0) + if (varToEncrypt != null && !varToEncrypt.isEmpty()) { String varToStore = secretProcessor.encode(secretProcessor.encrypt(varKey, varToEncrypt)); String varChecked = secretProcessor.decrypt(varKey, secretProcessor.decode(varToStore)); @@ -61,14 +61,14 @@ public class webService { String varProps = args.props; if (varProps == null && varToEncrypt == null) { - debugProcessor.writer(true, "Check your parameters. There is simply nothing to see here!"); + debugProcessor.writer(true, "Check the program parameters. There is nothing to do!"); System.out.println(); jct.usage(); System.exit(0); } - if (!fileProcessor.getFile(varProps)) { - debugProcessor.writer(true, "Please supply a valid properties file for --props"); + if (!fileProcessor.getFile(varProps)) + { System.exit(0); } @@ -123,7 +123,7 @@ public class webService { byte[] varDecoded = secretProcessor.decode(varPasswordTemp); varPassword = secretProcessor.decrypt(varKey, varDecoded); } catch (Exception e) { - debugProcessor.writer(varDebug, "The supplied password could not be decrypted. Please check the password!"); + debugProcessor.writer(true, "The password could not be decrypted. Please check that the Encryption Key is correct!"); System.exit(0); }