Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

***All I need is the code for step 2. Which will create a text file with a report formatted as stated in the document.**** Below

***All I need is the code for step 2. Which will create a text file with a report formatted as stated in the document.****

Below is the code, problem, and CSV file.

import java.io.*; import java.util.Scanner; public class CustomerExceptions { /** * @param args the command line arguments */ public static void main(String[] args) throws IOException, InvalidPWException { Scanner fileScan; Scanner commaScan; String record; final int NUMATTRIBUTES = 7; String[] storage = new String[NUMATTRIBUTES]; InvalidPWException shortPassword = new InvalidPWException("Password is too short"); fileScan = new Scanner(new File("Customer.csv")); while (fileScan.hasNext()) { record = fileScan.nextLine(); commaScan = new Scanner(record); commaScan.useDelimiter(","); for(int index = 0; index = 0; index--) masked = masked + (char)(password.charAt(index)); for (int index=0; index = 0; index--) unmasked = unmasked + (char)(decryption.charAt(index)); password = unmasked; encrypted = false; } } public String getFirstName() { return firstName; } public String getLastName() { return lastName; } public String getPassword() { return password; } public String getUserID() { return ID; } } ================================================================================ Encryptable.java public interface Encryptable { public void encrypt(); public void decrypt(); } ============================================================================================== InvalidPWException.java public class InvalidPWException extends Exception { public InvalidPWException(String message) { super(message); } }

------------------------------

image text in transcribed

Customer.csv 617622,Thomas,Regina,ReginaRThomas@teleworm.us,Therwaseld,6812.2,boorish62 139016,Friend,Lila,LilaVFriend@teleworm.us,Womilorge,3525.32,daughter39 590106,Tighe,Allan,AllanGTighe@fleckens.hu,Ourighter,2225.75,hope75 635541,McDaniel,Josephine,JosephineMMcDaniel@teleworm.us,Recare,5841.61,spiffy14 548459,Brown,Andrew,AndrewKBrown@cuvox.de,Pokinklant,5521.38,mice36 164016,Brock,Brian,BrianMBrock@dayrep.com,Fick1954,3506.69,animated96 696036,Ayala,Gloria,GloriaEAyala@einrot.com,Whourpel,1242.66,mustard66 290593,Gorman,Samuel,SamuelEGorman@armyspy.com,Idowed,5639.14,immense63 225635,Logan,Robert,RobertCLogan@einrot.com,Majesigh,8338.41,fiveapples95 216332,Leach,Karen,KarenVLeach@rhyta.com,Buthrotimily,1898.08,beastly33 225880,Lair,Larry,LarryKLair@teleworm.us,Chancer,6332.63,smasherino91 566834,Lundy,Karen,KarenWLundy@cuvox.de,Kner1956,4838.61,magenta97 350381,Moore,Jasmine,JasmineTMoore@rhyta.com,Rivertand,1453.07,thoughtful74 350286,Soto,Ramon,RamonDSoto@einrot.com,Wentiont1974,6320.69,hotoven86 550578,Meade,Elizabeth,ElizabethKMeade@rhyta.com,Sice1983,4691.58,smokinggun89
Keys for the simple substitution cipher usually consist of 26 letters. An example key is: plain alphabet : abcdefghijklmnopqrstuvwxyz cipher alphabet: phqgiumeaylnofdxjkrcvstzwb plaintext : defend the east wall of the castle ciphertext: giuifg cei iprc tpnn du cei qprcni The substitution cipher can be implemented using arrays and you may include upper and lowercase letters, digits and special characters when needed. This assignment allows you to practice exception handling while using a simple cipher. The assignment requires you read from a text file The assignment requires you to prepare a report in the form of a text file (which can be viewed in a text editor or printed at a later date). Reports include titles, column headings, dates, detailed lines of data, and optionally summaries, totals, and counts Step 1: Customer Class A local bank needs a new Customer class. You are tasked with creating the class and testing it. The Customer class should include: 1. The following instance data: Customer ID - 6 digits represented as a String last name - String first name - String email address - String user name - String bank balance - float password - String 2. A constructor which requires 7 parameters (the items listed above). The following could be a sample instantiation of an object from the Customer class: Customer bank Customer = new Customer ("123456", "Smith", "John", "jsmith0001@ .edu","jsmith0001", 1511.20, "Sillygoat213"); All passwords will be encrypted when an object is instantiated. This means the constructor should call the encypt() method to encrypt the password. 3. An encrypt()method (required by the Encryptable interface): o O Use a substitution cipher to encrypt the password. Passwords contain upper and lowercase letters and digits. You may develop your own substitution cipher. 0 You may use static arrays (as class data) to hold the plain alphabet and the cipher alphabet. Remember, you will need to include digits since passwords may include these characters. 3. An encrypt()method (required by the Encryptable interface): o Use a substitution cipher to encrypt the password. Passwords contain upper and lowercase letters and digits. You may develop your own substitution cipher. You may use static arrays (as class data) to hold the plain alphabet and the cipher alphabet. Remember, you will need to include digits since passwords may include these characters. o 4. A decrypt()method (required by the Encryptable interface): o Use a substitution cipher to decrypt a password and return the decrypted password. DO NOT update the encrypted password for the object. This method simply returns a decrypted version of the password but does not update the password. 5. Include accessors and mutators for the class data as you deem necessary with security in mind. Include a comment within the class to explain how you secured the class." 6. Include a toString() method to build and return a string that contains class data that you deem appropriate from a security point of view. Step 2: Test the Customer class The bank wants you to create a program to test your new class. To do this, create a driver program named CustomerList which reads through the Customer.csv file and outputs the following formatted like a report: Customer ID First name Last name Original password from the text file Encrypted password - using the accessor for password Decrypted password - using the decrypt() method Note: You are not updating the Customer file, you are simply testing your new class. The driver will read a record from Customer.csv instantiate a student object with the data from the record (which encrypts the password) use accessors to prepare a line of output in the report Include headings, the current date, and a record count in the report. Step 3: Exceptions In addition to using encryption to store passwords, the bank is debating whether or not to enforce new password rules: Passwords should be 10 characters or longer and Passwords must contain letters and digits. You are to determine how many current customers violate the proposed new rules. Create a class called InvalidPWException to help with this. You will add some additional processing to your CustomerList program which tests the Customer class. Create a new InvalidPWException object in the driver program for: Password is too short. Password not complex. Your program should throw an exception if the password is too short and/or if the password does not contain letters and digits (is not complex). Count the number of each type of exception you encounter and display the counts at the end of the report. Add a new column to the report. This column indicates errors. If an error occurs, display the appropriate message: Too Short Not Complex Too Short and Not Complex

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions