please help with this code.  Code so far: import java.util.Scanner; import java.io.File; Class Authenicator { private final int SIZE = 100; private User() users = new User[SIZE]; public Authenticator (String fileName) throws Exception; Scanner sc = new Scanner(new File(fileName)); int i = 0; While(sc.hasNext() && i < SIZE) { users[i] = Users.read(sc); i++ } } public void authenticate(String username, String password) throws Exception{ try { User u = null; for(User X : users) { if(x.getUsername().equals(username) && x.verifyPassword(password){ return ;    TASK Implement the following class name Authenticator: State An array of type User (use a capacity of 100 — I would recommend using a class constant the way I did in the 06-Array class of Lecture 2). An integer size Behavior A constructor accepting a file name, that opens a Scanner on the file and reads in User objects A method named authenticate that accepts a username and password and attempts to authenticate them against the User array (by doing a search). Not finding the username in the array causes an exception to be thrown finding the username, but not matching the password (via verifyPassword) causes an exception with a different message to be thrown (this one with the password hint included). See below for the exact exception messages expected The return type of the method is void, i.e., the method returns nothing if the username and password are matched; otherwise an exception is thrown, as described above. (This is a common pattern for authentication methods — if everything is fine, the method simply returns, otherwise it throws an exception.) The name of your class should be Authenticator. Please remove the public attribute from the class header. Your class is tested by a AuthenticatorApp class that reads in Users from a file using your read method, loads them into an array and prompts the keyboard for a login sequence (username/password). For example, if the file users.data contains: weiss  puppy2  woof-woof arnow  java  cuppa sokol  brooklyn  college here are some sample excutions of the program: username? arnow password? java Welcome to the system Sample Test Run #2 Given the same users.data file as above, execution of the program should look like: username? weiss password? dontremember *** Invalid password - hint: woof-woof username? weiss password? puppy2 Welcome to the system Sample Test Run #3 Given the same users.data file as above, execution of the program should look like: username? sokol password? CUNY *** Invalid password - hint: college username? sokol password? SUNY *** Invalid password - hint: college username? sokol password? BC *** Invalid password - hint: college Too many failed attempts... please try again later

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

please help with this code. 

Code so far:

import java.util.Scanner;
import java.io.File;

Class Authenicator {
private final int SIZE = 100;
private User() users = new User[SIZE];

public Authenticator (String fileName) throws Exception;
Scanner sc = new Scanner(new File(fileName));
int i = 0;
While(sc.hasNext() && i < SIZE) {
users[i] = Users.read(sc);
i++
}
}

public void authenticate(String username, String password) throws Exception{
try {
User u = null;
for(User X : users) {
if(x.getUsername().equals(username) && x.verifyPassword(password){

return ; 

 

TASK

Implement the following class name Authenticator:

State

An array of type User (use a capacity of 100 — I would recommend using a class constant the way I did in the 06-Array class of Lecture 2).

An integer size

Behavior

A constructor accepting a file name, that opens a Scanner on the file and reads in User objects

A method named authenticate that accepts a username and password and attempts to authenticate them against the User array (by doing a search).

Not finding the username in the array causes an exception to be thrown

finding the username, but not matching the password (via verifyPassword) causes an exception with a different message to be thrown (this one with the password hint included).

See below for the exact exception messages expected

The return type of the method is void, i.e., the method returns nothing if the username and password are matched; otherwise an exception is thrown, as described above. (This is a common pattern for authentication methods — if everything is fine, the method simply returns, otherwise it throws an exception.)

The name of your class should be Authenticator. Please remove the public attribute from the class header.

Your class is tested by a AuthenticatorApp class that reads in Users from a file using your read method, loads them into an array and prompts the keyboard for a login sequence (username/password).

For example, if the file users.data contains:

weiss  puppy2  woof-woof

arnow  java  cuppa

sokol  brooklyn  college

here are some sample excutions of the program:

username? arnow
password? java
Welcome to the system

Sample Test Run #2

Given the same users.data file as above, execution of the program should look like:

username? weiss
password? dontremember
*** Invalid password - hint: woof-woof
username? weiss
password? puppy2
Welcome to the system

Sample Test Run #3

Given the same users.data file as above, execution of the program should look like:

username? sokol
password? CUNY
*** Invalid password - hint: college
username? sokol
password? SUNY
*** Invalid password - hint: college
username? sokol
password? BC
*** Invalid password - hint: college
Too many failed attempts... please try again later

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY