Debug writer update, credentials not required for SOAP, CSV header verification fix
This commit is contained in:
parent
5db076672c
commit
00f1357af1
@ -4,11 +4,15 @@ import java.io.BufferedWriter;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
public class debugProcessor {
|
public class debugProcessor {
|
||||||
|
|
||||||
public static void writer(boolean toScreen, String varMessage)
|
public static void writer(boolean toScreen, String varMessage)
|
||||||
{
|
{
|
||||||
|
SimpleDateFormat varFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
|
||||||
|
Date dateStart = new Date();
|
||||||
if (toScreen)
|
if (toScreen)
|
||||||
{
|
{
|
||||||
System.out.println(varMessage);
|
System.out.println(varMessage);
|
||||||
@ -24,7 +28,7 @@ public class debugProcessor {
|
|||||||
|
|
||||||
BufferedWriter bw = null;
|
BufferedWriter bw = null;
|
||||||
bw = new BufferedWriter(new FileWriter(file, true));
|
bw = new BufferedWriter(new FileWriter(file, true));
|
||||||
bw.write(varMessage);
|
bw.write( varFormat.format(dateStart) + ": " + varMessage);
|
||||||
bw.newLine();
|
bw.newLine();
|
||||||
bw.flush();
|
bw.flush();
|
||||||
bw.close();
|
bw.close();
|
||||||
|
@ -15,10 +15,6 @@ public class propertyProcessor
|
|||||||
{
|
{
|
||||||
props.load(new FileInputStream(MyFile));
|
props.load(new FileInputStream(MyFile));
|
||||||
propertyValue = props.getProperty(varProperty);
|
propertyValue = props.getProperty(varProperty);
|
||||||
if (propertyValue == null)
|
|
||||||
{
|
|
||||||
propertyValue = "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -48,6 +48,10 @@ public class salter {
|
|||||||
public static String decrypt(String strToDecrypt, String secretKey, String salt) {
|
public static String decrypt(String strToDecrypt, String secretKey, String salt) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (strToDecrypt == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
byte[] encryptedData = Base64.getDecoder().decode(strToDecrypt);
|
byte[] encryptedData = Base64.getDecoder().decode(strToDecrypt);
|
||||||
byte[] iv = new byte[16];
|
byte[] iv = new byte[16];
|
||||||
|
@ -17,6 +17,11 @@ public class soapProcessor {
|
|||||||
|
|
||||||
public static String getCredentials(String username, String password) throws Exception
|
public static String getCredentials(String username, String password) throws Exception
|
||||||
{
|
{
|
||||||
|
if (username == null || password == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
String login = username + ":" + password;
|
String login = username + ":" + password;
|
||||||
String credentials = Base64.getEncoder().encodeToString(login.getBytes());
|
String credentials = Base64.getEncoder().encodeToString(login.getBytes());
|
||||||
return credentials;
|
return credentials;
|
||||||
@ -38,7 +43,15 @@ public class soapProcessor {
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
URLConnection connection = url.openConnection();
|
URLConnection connection = url.openConnection();
|
||||||
|
if (thisCredentials != null)
|
||||||
|
{
|
||||||
|
debugProcessor.writer(false, "We are sending credentials!");
|
||||||
connection.setRequestProperty("Authorization", "Basic " + thisCredentials);
|
connection.setRequestProperty("Authorization", "Basic " + thisCredentials);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
debugProcessor.writer(false, "No Credentials will be sent!");
|
||||||
|
}
|
||||||
HttpURLConnection httpConn = (HttpURLConnection)connection;
|
HttpURLConnection httpConn = (HttpURLConnection)connection;
|
||||||
return httpConn;
|
return httpConn;
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,9 @@ public class userVerify
|
|||||||
System.out.println();
|
System.out.println();
|
||||||
Scanner myObj = new Scanner(System.in); // Create a Scanner object
|
Scanner myObj = new Scanner(System.in); // Create a Scanner object
|
||||||
|
|
||||||
String varFileName = new String();
|
String varFileName;
|
||||||
while (true) {
|
while (true) {
|
||||||
System.out.print("Enter the name of the file to verify : ");
|
System.out.print("Please enter the name of the CSV file to verify : ");
|
||||||
varFileName = myObj.nextLine(); // Read user input
|
varFileName = myObj.nextLine(); // Read user input
|
||||||
File thisFile = new File(varFileName);
|
File thisFile = new File(varFileName);
|
||||||
if (thisFile.exists())
|
if (thisFile.exists())
|
||||||
@ -62,6 +62,7 @@ public class userVerify
|
|||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String exceptionReason = null;
|
||||||
Boolean failedOnException = false;
|
Boolean failedOnException = false;
|
||||||
Boolean parsedCorrectly = false;
|
Boolean parsedCorrectly = false;
|
||||||
long lineNum = 0;
|
long lineNum = 0;
|
||||||
@ -72,7 +73,7 @@ public class userVerify
|
|||||||
String varHeader = new String();
|
String varHeader = new String();
|
||||||
varHeader = fileProcessor.readFirstLine(thisFile);
|
varHeader = fileProcessor.readFirstLine(thisFile);
|
||||||
if (varHeader.length() == 0) {
|
if (varHeader.length() == 0) {
|
||||||
System.out.println(thisFile + " : appears to be missing a valid header!");
|
System.out.println(thisFile + " : the CSV file appears to be missing a valid header!");
|
||||||
return finalArray;
|
return finalArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,13 +106,14 @@ public class userVerify
|
|||||||
{
|
{
|
||||||
invalidNum++;
|
invalidNum++;
|
||||||
String thisLine = Files.readAllLines(Paths.get(thisFile)).get(Math.toIntExact(lineNum - 1));
|
String thisLine = Files.readAllLines(Paths.get(thisFile)).get(Math.toIntExact(lineNum - 1));
|
||||||
debugProcessor.writer(fromUser, "!! " + lineNum + " [FAILED] : " + thisLine);
|
debugProcessor.writer(fromUser, "!! " + lineNum + " [failed] : " + thisLine);
|
||||||
debugProcessor.writer(fromUser, "!! " + lineNum + " [FAILED] : " + record.toMap().toString());
|
debugProcessor.writer(fromUser, "!! " + lineNum + " [failed] : " + record.toMap().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException | IllegalArgumentException e)
|
catch (IOException | IllegalArgumentException e)
|
||||||
{
|
{
|
||||||
|
exceptionReason = e.toString();
|
||||||
failedOnException = true;
|
failedOnException = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -119,8 +121,13 @@ public class userVerify
|
|||||||
}
|
}
|
||||||
|
|
||||||
debugProcessor.writer(fromUser,"");
|
debugProcessor.writer(fromUser,"");
|
||||||
|
debugProcessor.writer(fromUser, "CSV lines read : " + String.valueOf(readNum));
|
||||||
debugProcessor.writer(fromUser, "CSV lines passed : " + String.valueOf(readNum - invalidNum));
|
debugProcessor.writer(fromUser, "CSV lines passed : " + String.valueOf(readNum - invalidNum));
|
||||||
debugProcessor.writer(fromUser, "CSV lines failed : " + invalidNum);
|
debugProcessor.writer(fromUser, "CSV lines failed : " + invalidNum);
|
||||||
|
if (exceptionReason != null)
|
||||||
|
{
|
||||||
|
debugProcessor.writer(fromUser, "CSV failure error : " + exceptionReason);
|
||||||
|
}
|
||||||
|
|
||||||
if (invalidNum > 0)
|
if (invalidNum > 0)
|
||||||
{
|
{
|
||||||
|
@ -132,12 +132,12 @@ public class webService {
|
|||||||
ArrayList thisCSV = userVerify.readCSV(varRoleFile, false);
|
ArrayList thisCSV = userVerify.readCSV(varRoleFile, false);
|
||||||
|
|
||||||
boolean validfile = (thisCSV.size() > 0);
|
boolean validfile = (thisCSV.size() > 0);
|
||||||
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());
|
||||||
|
|
||||||
if (!validfile)
|
if (!validfile)
|
||||||
{
|
{
|
||||||
debugProcessor.writer(true, varRoleFile + " : please verify the file with com.belkast.soap.userVerify");
|
debugProcessor.writer(true, varRoleFile + " : verification failed. please verify the file with com.belkast.soap.userVerify!");
|
||||||
}
|
}
|
||||||
int varCount = 0;
|
int varCount = 0;
|
||||||
Iterator<Map> mapper1 = thisCSV.iterator();
|
Iterator<Map> mapper1 = thisCSV.iterator();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user