Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this lab you will need to download the associated . zip file from Pilot. The User class contains two fields: a username and a

For this lab you will need to download the associated .zip file from Pilot.
The User class contains two fields: a username and a password. It also has two methods: isValidPassword and authenticate. A password is consicered valid if it is at least eight characters long and it does not contain the username as part of the password. The authenticate method takes a String as an argument and returns true if that string matches the user's password; otherwise it returns false. The file Main.java contains code that thoroughly tests the User class.
Your task for this lab is to write and test a subclass of User called SecureUser. This subclass should override the authenticate method to meet more stringent requirements. In particular, a SecureUser class should "lock" a user out after three consecutive failed authentications. In other words, the authentication method should return true only if the string passed into the method matches the password AND there have not been three consecutive failed authentications. If the user has two failed authentications and then a successful authentication, you should reset the number of consecutive failed authentications to zero. You should also add code to Main.java so that it thoroughly tests the SecureUser class. It is up to you how many tests you want to create.
You should not make any changes to User.java, and you should only add to Main.java. Do not change any code that is already present.
Hint: You will probably find it useful to add a new field to the SecureUser class to keep track of the number of consecutive failed authentications.
Example
The SecureUser su has username Michelle and the password is "hello123".
su.isValidPassword(); should return true
su. authenticate ("hello"); should return false
su.authenticate("hello12"); should return false
su. authenticate ("Hello123"); should return false (case is important)
su. authenticate("hello123"); should return false, due to 3 consecutive failed authentications
image text in transcribed

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

Students also viewed these Databases questions