Question: Project 1A | Password Checker Design, implement and test a Java application that will validate passwords. For this project, a valid password: 1. is 6

Project 1A | Password Checker

Design, implement and test a Java application that will validate passwords. For this project, a valid password:

1. is 6 or more characters (long)

2. 10 or more characters is a strong password, however, between 6 and 9 characters is acceptable but considered a weak password

3. at least 1 numeric character

4. at least 1 uppercase alphabetic character

5. at least 1 lowercase alphabetic character

6. at least 1 special character

7. no more than 2 of the same character in a sequence

8. examples

Hello1@23 - Valid password

AAAbb@123 - NOT valid

Aaabbaa@123 - Valid ('a' and 'A' are NOT the same character)

Class PasswordCheckerUtility

java.lang.ObjectPasswordCheckerUtility

public class PasswordCheckerUtility extends java.lang.Object Constructor Summary Constructors Constructor and DescriptionPasswordCheckerUtility() Method Summary All Methods Static Methods Concrete Methods Modifier and TypeMethod and Descriptionstatic voidcomparePasswords(java.lang.String password, java.lang.String passwordConfirm) Compare equality of two passwords static booleancomparePasswordsWithReturn(java.lang.String password, java.lang.String passwordConfirm) Compare equality of two passwords static java.util.ArrayListgetInvalidPasswords(java.util.ArrayList passwords) Reads a file of passwords and the passwords that failed the check will be added to an invalidPasswords with the reason static booleanhasBetweenSixAndNineChars(java.lang.String password) Weak password length check - Password contains 6 to 9 characters , still considers valid, just weak static booleanhasDigit(java.lang.String password) Checks the password Digit requirement - Password must contain a numeric character static booleanhasLowerAlpha(java.lang.String password) Checks the password lowercase requirement - Password must contain a lowercase alpha character static booleanhasSameCharInSequence(java.lang.String password) Checks the password Sequence requirement - Password should not contain more than 2 of the same character in sequence static booleanhasSpecialChar(java.lang.String password) Checks the password SpecialCharacter requirement - Password must contain a Special Character static booleanhasUpperAlpha(java.lang.String password) Checks the password alpha character requirement - Password must contain an uppercase alpha character static booleanisValidLength(java.lang.String password) Checks the password length requirement - - The password must be at least 6 characters long static booleanisValidPassword(java.lang.String password) Return true if valid password (follows all rules from above), returns false if an invalid password static booleanisWeakPassword(java.lang.String password) Checks if password is valid but between 6 -9 characters Methods inherited from class java.lang.Object clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait Constructor Detail PasswordCheckerUtility public PasswordCheckerUtility() Method Detail comparePasswords public static void comparePasswords(java.lang.String password, java.lang.String passwordConfirm) throws UnmatchedException Compare equality of two passwords Parameters: password - - password string to be checked for passwordConfirm - - passwordConfirm string to be checked against password for Throws: UnmatchedException - thrown if not same (case sensitive) comparePasswordsWithReturn public static boolean comparePasswordsWithReturn(java.lang.String password, java.lang.String passwordConfirm) Compare equality of two passwords Parameters: password - - password string to be checked for passwordConfirm - - passwordConfirm string to be checked against password for Returns: true if both same (case sensitive) getInvalidPasswords public static java.util.ArrayList getInvalidPasswords(java.util.ArrayList passwords) Reads a file of passwords and the passwords that failed the check will be added to an invalidPasswords with the reason Parameters: passwords - - list of passwords read from a file Returns: invalidPasswords - ArrayList of invalid passwords in the correct format hasBetweenSixAndNineChars public static boolean hasBetweenSixAndNineChars(java.lang.String password) Weak password length check - Password contains 6 to 9 characters , still considers valid, just weak Parameters: password - - password string to be checked for Sequence requirement Returns: true if password contains 6 to 9 characters hasDigit public static boolean hasDigit(java.lang.String password) throws NoDigitException Checks the password Digit requirement - Password must contain a numeric character Parameters: password - - password string to be checked for Digit requirement Returns: true if meet Digit requirement Throws: NoDigitException - thrown if does not meet Digit requirement hasLowerAlpha public static boolean hasLowerAlpha(java.lang.String password) throws NoLowerAlphaException Checks the password lowercase requirement - Password must contain a lowercase alpha character Parameters: password - - password string to be checked for lowercase requirement Returns: true if meet lowercase requirement Throws: NoLowerAlphaException - thrown if does not meet lowercase requirement hasSameCharInSequence public static boolean hasSameCharInSequence(java.lang.String password) throws InvalidSequenceException Checks the password Sequence requirement - Password should not contain more than 2 of the same character in sequence Parameters: password - - password string to be checked for Sequence requirement Returns: false if does NOT meet Sequence requirement Throws: InvalidSequenceException - thrown if does not meet Sequence requirement hasSpecialChar public static boolean hasSpecialChar(java.lang.String password) throws NoSpecialCharacterException Checks the password SpecialCharacter requirement - Password must contain a Special Character Parameters: password - - password string to be checked for SpecialCharacter requirement Returns: true if meet SpecialCharacter requirement Throws: NoSpecialCharacterException - thrown if does not meet SpecialCharacter requirement hasUpperAlpha public static boolean hasUpperAlpha(java.lang.String password) throws NoUpperAlphaException Checks the password alpha character requirement - Password must contain an uppercase alpha character Parameters: password - - password string to be checked for alpha character requirement Returns: true if meet alpha character requirement Throws: NoUpperAlphaException - thrown if does not meet alpha character requirement isValidLength public static boolean isValidLength(java.lang.String password) throws LengthException Checks the password length requirement - - The password must be at least 6 characters long Parameters: password - - password string to be checked for length Returns: true if meet min length requirement Throws: LengthException - thrown if does not meet min length requirement isValidPassword public static boolean isValidPassword(java.lang.String password) throws LengthException, NoUpperAlphaException, NoLowerAlphaException, NoDigitException, NoSpecialCharacterException, InvalidSequenceException Return true if valid password (follows all rules from above), returns false if an invalid password Parameters: password - - string to be checked for validity Returns: true if valid password (follows all rules from above), false if an invalid password Throws: LengthException - thrown if length is less than 6 characters NoUpperAlphaException - thrown if no uppercase alphabetic NoLowerAlphaException - thrown if no lowercase alphabetic NoDigitException - thrown if no digit NoSpecialCharacterException - thrown if does not meet SpecialCharacter requirement InvalidSequenceException - thrown if more than 2 of same character. isWeakPassword public static boolean isWeakPassword(java.lang.String password) throws WeakPasswordException Checks if password is valid but between 6 -9 characters Parameters: password - - string to be checked if weak password Returns: true if length of password is between 6 and 9 (inclusive). Throws: WeakPasswordException

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!