From 383eaa5cd37344ec93b46e211047bfff9da32d87 Mon Sep 17 00:00:00 2001
From: Keith Armstrong <keith@belkast.com>
Date: Thu, 2 Jan 2025 16:59:44 -0500
Subject: [PATCH] Added check for valid properties file

---
 src/com/belkast/soap/webService.java | 48 +++++++++++++++-------------
 1 file changed, 26 insertions(+), 22 deletions(-)

diff --git a/src/com/belkast/soap/webService.java b/src/com/belkast/soap/webService.java
index 4f81175..8f26615 100644
--- a/src/com/belkast/soap/webService.java
+++ b/src/com/belkast/soap/webService.java
@@ -70,8 +70,9 @@ public class webService {
             System.exit(0);
         }
 
-        if (!fileProcessor.getFile(varProps))
+        if (!fileProcessor.getFile(varProps) || !fileProcessor.validFile(varProps))
         {
+            debugProcessor.writer(true, "Something went wrong. Please check that the properties file is correctly formatted!");
             System.exit(0);
         }
 
@@ -85,11 +86,8 @@ public class webService {
 
     private static void doSoap(File thisProps) throws Exception {
         String varPassword = "";
-        String varDelimiter = propertyProcessor.getProperty(thisProps, "ARGUMENT_DELIMITER");
-
         debugProcessor.writer(false, "Debug is set to : " + varDebug);
 
-        System.out.println();
         String varURL = propertyProcessor.getProperty(thisProps, "SHIM_URL");
         String varUsername = propertyProcessor.getProperty(thisProps, "USERNAME");
         String varPasswordTemp = propertyProcessor.getProperty(thisProps, "PASSWORD");
@@ -104,28 +102,24 @@ public class webService {
         String varPropEmptyColumns = propertyProcessor.getProperty(thisProps, "CSV_ALLOW_EMPTY_COLUMN_VALUES");
         Boolean varEmptyColumns = Boolean.valueOf(varPropEmptyColumns);
 
-        debugProcessor.writer(varDebug, thisProps + " => SOAP URL : " + varURL);
-        debugProcessor.writer(varDebug, thisProps + " => Username : " + varUsername);
-        debugProcessor.writer(varDebug, thisProps + " => Use SSL : " + varUseSSL);
-        debugProcessor.writer(varDebug, thisProps + " => JAVA keystore : " + varKeystore_LOC);
-        debugProcessor.writer(varDebug, thisProps + " => JAVA keystore password : " + varKeystore_PW);
-        debugProcessor.writer(varDebug, thisProps + " => XML file : " + varInputFile);
-        debugProcessor.writer(varDebug, thisProps + " => CSV file : " + varRoleFile);
-        debugProcessor.writer(varDebug, thisProps + " => CSV allow empty : " + varEmptyColumns);
+        try {
+            File checkInput = new File(varInputFile);
+            if (!checkInput.exists()) {
+                debugProcessor.writer(true, thisProps + " => The file specified in XML_FILE does not exist [ " + varInputFile + " ]");
+                System.exit(0);
+            }
 
-        File checkInput = new File (varInputFile);
-        if (!checkInput.exists())
-        {
-            debugProcessor.writer(true, thisProps + " => The file specified in XML_FILE does not exist [ " + varInputFile + " ]");
-            System.exit(0);
-        }
-
-        File checkRole = new File (varRoleFile);
-        if (!checkRole.exists())
-            {
+            File checkRole = new File(varRoleFile);
+            if (!checkRole.exists()) {
                 debugProcessor.writer(true, thisProps + " => The file specified in CSV_FILE does not exist [ " + varRoleFile + " ]");
                 System.exit(0);
             }
+        }
+        catch (Exception e)
+        {
+            debugProcessor.writer(true, thisProps + " => Something went wrong. Please check that the properties file is correctly formatted!");
+            System.exit(0);
+        }
 
         try {
             varPassword = salter.decrypt(varPasswordTemp, varKey, varSalt);
@@ -135,6 +129,16 @@ public class webService {
             System.exit(0);
         }
 
+        System.out.println();
+        debugProcessor.writer(varDebug, thisProps + " => SOAP URL : " + varURL);
+        debugProcessor.writer(varDebug, thisProps + " => Username : " + varUsername);
+        debugProcessor.writer(varDebug, thisProps + " => Use SSL : " + varUseSSL);
+        debugProcessor.writer(varDebug, thisProps + " => JAVA keystore : " + varKeystore_LOC);
+        debugProcessor.writer(varDebug, thisProps + " => JAVA keystore password : " + varKeystore_PW);
+        debugProcessor.writer(varDebug, thisProps + " => XML file : " + varInputFile);
+        debugProcessor.writer(varDebug, thisProps + " => CSV file : " + varRoleFile);
+        debugProcessor.writer(varDebug, thisProps + " => CSV allow empty : " + varEmptyColumns);
+
         ArrayList thisCSV = userVerify.readCSV(varRoleFile, false, !varEmptyColumns);
 
         boolean validfile = (!thisCSV.isEmpty());