Added code to handle soapProcessor returning Map
This commit is contained in:
parent
db528c70cd
commit
8e17fd2848
@ -47,8 +47,8 @@ public class webService {
|
|||||||
|
|
||||||
if (varToEncrypt != null && !varToEncrypt.isEmpty())
|
if (varToEncrypt != null && !varToEncrypt.isEmpty())
|
||||||
{
|
{
|
||||||
String varToStore = salter.encrypt(varToEncrypt, varKey, varSalt);
|
String varToStore = encyptProcessor.encrypt(varToEncrypt, varKey, varSalt);
|
||||||
String varChecked = salter.decrypt(varToStore, varKey, varSalt);
|
String varChecked = encyptProcessor.decrypt(varToStore, varKey, varSalt);
|
||||||
|
|
||||||
System.out.println("Clear Text Password : " + varToEncrypt);
|
System.out.println("Clear Text Password : " + varToEncrypt);
|
||||||
System.out.println("Encryption Key : " + varKey);
|
System.out.println("Encryption Key : " + varKey);
|
||||||
@ -61,7 +61,7 @@ public class webService {
|
|||||||
String varProps = args.props;
|
String varProps = args.props;
|
||||||
if (varProps == null && varToEncrypt == null)
|
if (varProps == null && varToEncrypt == null)
|
||||||
{
|
{
|
||||||
debugProcessor.writer(true, "Check the program parameters. There is nothing to do!");
|
debugProcessor.writer(true, "Check the command line parameters. There is nothing to do!");
|
||||||
System.out.println();
|
System.out.println();
|
||||||
jct.usage();
|
jct.usage();
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
@ -76,7 +76,18 @@ public class webService {
|
|||||||
|
|
||||||
if (varProps != null)
|
if (varProps != null)
|
||||||
{
|
{
|
||||||
doSoap(new File(varProps));
|
Map thisFinal = doSoap(new File(varProps));
|
||||||
|
System.out.println();
|
||||||
|
debugProcessor.writer(true, "!! Total records : " + thisFinal.get("total"));
|
||||||
|
debugProcessor.writer(true, "!! Total passed : " + thisFinal.get("passed"));
|
||||||
|
debugProcessor.writer(true, "!! Total failed : " + thisFinal.get("failed"));
|
||||||
|
|
||||||
|
Boolean thisResult = thisFinal.get("total") == thisFinal.get("passed");
|
||||||
|
debugProcessor.writer(true, "!! ALL PROCESSED : " + thisResult.toString().toUpperCase());
|
||||||
|
if (!thisResult)
|
||||||
|
{
|
||||||
|
debugProcessor.writer(true, "!! PLEASE CHECK THE DEBUG LOG");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println();
|
System.out.println();
|
||||||
@ -84,8 +95,11 @@ public class webService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void doSoap(File thisProps) throws Exception {
|
private static Map doSoap(File thisProps) throws Exception {
|
||||||
String varPassword = "";
|
String varPassword = "";
|
||||||
|
int varFailed = 0;
|
||||||
|
Map varResult = new HashMap();
|
||||||
|
|
||||||
debugProcessor.writer(false, "Debug is set to : " + varDebug);
|
debugProcessor.writer(false, "Debug is set to : " + varDebug);
|
||||||
|
|
||||||
String varURL = propertyProcessor.getProperty(thisProps, "SHIM_URL", null);
|
String varURL = propertyProcessor.getProperty(thisProps, "SHIM_URL", null);
|
||||||
@ -130,33 +144,37 @@ public class webService {
|
|||||||
|
|
||||||
Boolean varUseSSL = Boolean.valueOf(varPropUseSSL);
|
Boolean varUseSSL = Boolean.valueOf(varPropUseSSL);
|
||||||
Boolean varAuthRequired = Boolean.valueOf(varPropAuthRequired);
|
Boolean varAuthRequired = Boolean.valueOf(varPropAuthRequired);
|
||||||
|
|
||||||
Boolean varEmptyColumns = Boolean.valueOf(varPropEmptyColumns);
|
Boolean varEmptyColumns = Boolean.valueOf(varPropEmptyColumns);
|
||||||
|
|
||||||
String varUsername = propertyProcessor.getProperty(thisProps, "USERNAME", null);
|
String varUsername = propertyProcessor.getProperty(thisProps, "USERNAME", null);
|
||||||
if (varAuthRequired && varUsername == null)
|
if (varAuthRequired && varUsername == null)
|
||||||
{
|
{
|
||||||
varUsername = userCreds.getUsername("Please enter your username : ");
|
varUsername = credentialsProcessor.getUsername("Please enter your username : ");
|
||||||
}
|
}
|
||||||
|
|
||||||
String varPasswordTemp = propertyProcessor.getProperty(thisProps, "PASSWORD", null);
|
String varPasswordTemp = propertyProcessor.getProperty(thisProps, "PASSWORD", null);
|
||||||
if (varAuthRequired && varPasswordTemp == null)
|
if (varAuthRequired && varPasswordTemp == null)
|
||||||
{
|
{
|
||||||
char[] varUserPW = userCreds.getPassword("Please enter your password : ");
|
char[] varUserPW = credentialsProcessor.getPassword("[" + varUsername + "] Please enter your password : ");
|
||||||
varPasswordTemp = salter.encrypt(String.copyValueOf(varUserPW), varKey, varSalt);
|
varPasswordTemp = encyptProcessor.encrypt(String.copyValueOf(varUserPW), varKey, varSalt);
|
||||||
|
}
|
||||||
|
else if (!varAuthRequired)
|
||||||
|
{
|
||||||
|
varPasswordTemp = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
varPassword = salter.decrypt(varPasswordTemp, varKey, varSalt);
|
varPassword = encyptProcessor.decrypt(varPasswordTemp, varKey, varSalt);
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
debugProcessor.writer(true, "The password could not be decrypted. Please check that the Encryption Key is correct!");
|
debugProcessor.writer(true, "The password could not be decrypted. Please check the encryption key!");
|
||||||
System.out.println();
|
System.out.println();
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
debugProcessor.writer(varDebug, "");
|
|
||||||
debugProcessor.writer(varDebug, thisProps + " => SOAP URL : " + (varURL == null ? "" : varURL));
|
debugProcessor.writer(varDebug, thisProps + " => SOAP URL : " + (varURL == null ? "" : varURL));
|
||||||
debugProcessor.writer(varDebug, thisProps + " => Authentication required : " + varAuthRequired);
|
debugProcessor.writer(varDebug, thisProps + " => Authentication required : " + varAuthRequired);
|
||||||
debugProcessor.writer(varDebug, thisProps + " => Use SSL : " + varUseSSL);
|
debugProcessor.writer(varDebug, thisProps + " => Use SSL : " + varUseSSL);
|
||||||
@ -179,6 +197,7 @@ public class webService {
|
|||||||
ArrayList thisCSV = userVerify.readCSV(varRoleFile, false, !varEmptyColumns);
|
ArrayList thisCSV = userVerify.readCSV(varRoleFile, false, !varEmptyColumns);
|
||||||
|
|
||||||
boolean validfile = (!thisCSV.isEmpty());
|
boolean validfile = (!thisCSV.isEmpty());
|
||||||
|
debugProcessor.writer(varDebug, "");
|
||||||
debugProcessor.writer(true, varRoleFile + " => CSV file is valid : " + validfile);
|
debugProcessor.writer(true, varRoleFile + " => CSV file is valid : " + validfile);
|
||||||
debugProcessor.writer(true, varRoleFile + " => records to process : " + thisCSV.size());
|
debugProcessor.writer(true, varRoleFile + " => records to process : " + thisCSV.size());
|
||||||
|
|
||||||
@ -191,7 +210,7 @@ public class webService {
|
|||||||
while (mapper1.hasNext()) {
|
while (mapper1.hasNext()) {
|
||||||
varCount++;
|
varCount++;
|
||||||
debugProcessor.writer(true, "");
|
debugProcessor.writer(true, "");
|
||||||
debugProcessor.writer(true, "[" + varCount + " of " + thisCSV.size() + "] : processing started");
|
debugProcessor.writer(varDebug, "[" + varCount + " of " + thisCSV.size() + "] : processing started");
|
||||||
|
|
||||||
Map hashMap = mapper1.next();
|
Map hashMap = mapper1.next();
|
||||||
debugProcessor.writer(varDebug, "record " + varCount + " : " + hashMap.values().toString());
|
debugProcessor.writer(varDebug, "record " + varCount + " : " + hashMap.values().toString());
|
||||||
@ -203,28 +222,58 @@ public class webService {
|
|||||||
debugProcessor.writer(varDebug, "record " + varCount + " : " + pair.getKey() + " => " + pair.getValue());
|
debugProcessor.writer(varDebug, "record " + varCount + " : " + pair.getKey() + " => " + pair.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
String varDocument = fileProcessor.replaceInFile(varInputFile, hashMap);
|
for(Object key: hashMap.keySet())
|
||||||
|
{
|
||||||
|
Boolean varHasText = fileProcessor.fileHasText(varInputFile, key.toString());
|
||||||
|
debugProcessor.writer(varDebug, "[before] " + varInputFile + " : " + key + " token exists => " + varHasText);
|
||||||
|
}
|
||||||
|
|
||||||
if (varDocument != null && !varDocument.isEmpty())
|
String varXML = fileProcessor.replaceInFile(varInputFile, hashMap);
|
||||||
|
for(Object key: hashMap.keySet())
|
||||||
|
{
|
||||||
|
Boolean varHasText = fileProcessor.stringHasText(varXML, key.toString());
|
||||||
|
debugProcessor.writer(varDebug, "[after] " + varInputFile + " : " + key + " token exists => " + varHasText);
|
||||||
|
}
|
||||||
|
|
||||||
|
HashMap<Boolean, String> errorMap = new HashMap();
|
||||||
|
errorMap.put(false, "FAILED");
|
||||||
|
errorMap.put(true, "SUCCESS");
|
||||||
|
|
||||||
|
if (varXML != null && !varXML.isEmpty())
|
||||||
{
|
{
|
||||||
String varCredentials = soapProcessor.getCredentials(varUsername, varPassword);
|
String varCredentials = soapProcessor.getCredentials(varUsername, varPassword);
|
||||||
|
|
||||||
debugProcessor.writer(varDebug, "connecting to URL : " + varURL);
|
debugProcessor.writer(true, "[" + varCount + " of " + thisCSV.size() + "] : opening connection [" + varURL + "]");
|
||||||
HttpURLConnection varConn = soapProcessor.getConnection(varCredentials, varURL, varUseSSL, varKeystore_LOC, varKeystore_PW);
|
HttpURLConnection varConn = soapProcessor.getConnection(varCredentials, varURL, varUseSSL, varKeystore_LOC, varKeystore_PW);
|
||||||
debugProcessor.writer(true, "[" + varCount + " of " + thisCSV.size() + "] : opened connection");
|
|
||||||
|
|
||||||
debugProcessor.writer(varDebug, "sending XML document : " + varDocument);
|
debugProcessor.writer(true, "[" + varCount + " of " + thisCSV.size() + "] : sending XML document");
|
||||||
|
debugProcessor.writer(varDebug, "[" + varCount + " of " + thisCSV.size() + "] : SOAP call sending data : " + varXML);
|
||||||
|
|
||||||
String response = soapProcessor.send(varConn, varInputFile, hashMap, varDocument.getBytes());
|
Map response = soapProcessor.send(varConn, varXML.getBytes());
|
||||||
debugProcessor.writer(true, "[" + varCount + " of " + thisCSV.size() + "] : XML document sent");
|
debugProcessor.writer(true, "[" + varCount + " of " + thisCSV.size() + "] : SOAP call response code : " + response.get("code"));
|
||||||
|
debugProcessor.writer(true, "[" + varCount + " of " + thisCSV.size() + "] : SOAP call was successful : " + Boolean.valueOf(response.get("success").toString()));
|
||||||
|
|
||||||
|
boolean varSuccess = Boolean.valueOf(response.get("success").toString());
|
||||||
|
if (!varSuccess)
|
||||||
|
{
|
||||||
|
debugProcessor.writer(varDebug, "[" + varCount + " of " + thisCSV.size() + "] : " + hashMap.toString());
|
||||||
|
varFailed++;
|
||||||
|
}
|
||||||
|
|
||||||
|
debugProcessor.writer(!varSuccess, "[" + varCount + " of " + thisCSV.size() + "] : SOAP call response data : " + response.get("response"));
|
||||||
|
|
||||||
debugProcessor.writer(varDebug, "response received : " + response);
|
|
||||||
if (varConn != null)
|
if (varConn != null)
|
||||||
{
|
{
|
||||||
soapProcessor.closeConnection(varConn);
|
soapProcessor.closeConnection(varConn);
|
||||||
debugProcessor.writer(true, "[" + varCount + " of " + thisCSV.size() + "] : closed connection");
|
debugProcessor.writer(true, "[" + varCount + " of " + thisCSV.size() + "] : connection closed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
varResult.put("total", thisCSV.size());
|
||||||
|
varResult.put("passed", thisCSV.size() - varFailed);
|
||||||
|
varResult.put("failed", varFailed);
|
||||||
|
return varResult;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user