diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c87c9a9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,37 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +/.idea/*.xml +*.iws +*.iml +*.ipr +/.idea/ +.gitignore + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store diff --git a/src/main/java/io/github/pitzzahh/Atm.java b/src/main/java/io/github/pitzzahh/Atm.java index ed40971..d87c076 100644 --- a/src/main/java/io/github/pitzzahh/Atm.java +++ b/src/main/java/io/github/pitzzahh/Atm.java @@ -23,6 +23,7 @@ */ public class Atm { private static final ClientService CLIENT_SERVICE = new ClientService(); + @SuppressWarnings("InfiniteLoopStatement") public static void main(String[] args) { final Scanner scanner = new Scanner(System.in); CLIENT_SERVICE.setDataSource().accept(ClientService.getDataSource()); @@ -36,14 +37,13 @@ public static void main(String[] args) { System.out.println(RED_BOLD_BRIGHT + runtimeException.getMessage() + RESET); } } - } /** * The automated teller machine that handles most of the process. */ static class Machine { - private static final String $a = "?cl0m0#sq3s/q"; // @dm1n1$tr4t0r + private static final String $adm = "?cl0m0#sq3s/q"; private static String $an; /** * Searches the {@code Hashtable}, checks if the account number exists. @@ -116,7 +116,7 @@ private static void createClient(Scanner scanner) throws IllegalArgumentExceptio /** * method for asking for user details. - * @param scanner the scanner needed for keynoard input. + * @param scanner the scanner needed for keyboard input. * @return a {@code Client} object. * @throws IllegalArgumentException if any of the input is not valid. */ @@ -207,7 +207,7 @@ public static Status removeClient(Scanner scanner) { System.out.println(RED_BOLD_BRIGHT + "ENTER ACCOUNT NUMBER TO REMOVE: "); System.out.print(PURPLE_BOLD + ">>>: " + RESET); $an = scanner.nextLine().trim(); - return CLIENT_SERVICE.removeClientByAccountNumber().apply(SecurityUtil.encrypt($an)); + return CLIENT_SERVICE.removeClientByAccountNumber().apply($an); } /** @@ -322,7 +322,7 @@ private static Role home(Scanner scanner) throws IllegalArgumentException, Illeg System.out.println(YELLOW_BRIGHT + "ENTER YOUR ACCOUNT NUMBER" + RESET); System.out.print(RED_BOLD_BRIGHT + ">>>: " + RESET); var input = scanner.nextLine().trim(); - if (input.equals(SecurityUtil.decrypt(Machine.$a))) return Role.ADMIN; + if (input.equals(SecurityUtil.decrypt(Machine.$adm))) return Role.ADMIN; if (Validator.isDecimalNumber().test(input)) throw new IllegalArgumentException("\nACCOUNT NUMBER IS A WHOLE NUMBER\n"); if (Validator.isWholeNumber().negate().test(input)) throw new IllegalArgumentException("\nACCOUNT NUMBER IS A NUMBER\n"); var result = Machine.searchAccount(input); diff --git a/src/main/java/io/github/pitzzahh/dao/Queries.java b/src/main/java/io/github/pitzzahh/dao/Queries.java index a902f7e..13b9ba2 100644 --- a/src/main/java/io/github/pitzzahh/dao/Queries.java +++ b/src/main/java/io/github/pitzzahh/dao/Queries.java @@ -11,7 +11,6 @@ import static com.github.pitzzahh.utilities.classes.enums.Status.*; // TODO: create a test for this. -// TODO: implement updateClientAttemptsByAccountNumberQuery() and updateClientSavingsByAccountNumberQuery() public class Queries { public static Supplier>> getAllClientsQuery(JdbcTemplate jdbc) { @@ -20,13 +19,13 @@ public static Supplier>> getAllClientsQuery(JdbcTemplate j public static Optional getClientByAccountNumberQuery(String $an, JdbcTemplate jdbc) { try { - return jdbc.queryForObject("SELECT * FROM clients WHERE account_number = ?", new Object[]{SecurityUtil.encrypt($an)}, new ClientMapper()); + return jdbc.queryForObject("SELECT * FROM clients WHERE account_number = ?", new ClientMapper(), SecurityUtil.encrypt($an)); } catch (EmptyResultDataAccessException ignored) {} return Optional.empty(); } public static Status removeClientByAccountNumberQuery(String $an, JdbcTemplate jdbc) { - return jdbc.update("DELETE FROM clients WHERE account_number = ?", $an) > 0 ? SUCCESS : ERROR; + return jdbc.update("DELETE FROM clients WHERE account_number = ?", SecurityUtil.encrypt($an)) > 0 ? SUCCESS : ERROR; } public static Status updateClientAttemptsByAccountNumberQuery(String an, String at, JdbcTemplate jdbc) { diff --git a/src/main/java/io/github/pitzzahh/database/DatabaseConnection.java b/src/main/java/io/github/pitzzahh/database/DatabaseConnection.java index 0fea5bd..50e241d 100644 --- a/src/main/java/io/github/pitzzahh/database/DatabaseConnection.java +++ b/src/main/java/io/github/pitzzahh/database/DatabaseConnection.java @@ -9,7 +9,7 @@ public interface DatabaseConnection { /** - * Setup the datasource. + * Set up the datasource. * @see ClientService * @return the datasource. */