Password checker program basically checks if the password is valid or not based on password policies mention below:
- Password should not contain any space.
- Password should contain at least one digit(0-9).
- Password length should be between 8 to 15 characters.
- Password should contain at least one lowercase letter(a-z).
- Password should contain at least one uppercase letter(A-Z).
- Password should contain at least one special character ( @, #, %, &, !, $, etc….).
Input: GeeksForGeeks Output: Invalid Password! This input contains lowercase as well as uppercase letters but does not contain digits and special characters. Input: Geek007@GFG Output: Valid Password This input satisfies all password policies mentioned above.
- Create a User-defined exception named “InvalidPasswordException” as explained below.
- Then check for the validity of the password on the required parameters.
- If any parameter is not met, then throw the InvalidPasswordException.
Below is the implementation of the above approach:
Is Password GeeksForGeeks valid? Invalid Password: Password should contain at least one digit(0-9) Is Password Geek007@GFG valid? Valid Password
- Java Program to Handle Checked Exception
- Java Program to Handle Unchecked Exception
- Java Program to use Catch to Handle the Exception
- Java Program to Handle the Exception Hierarchies
- Java Program to Handle the Exception Methods
- How to validate a Password using Regular Expressions in Java
- Version Enhancements in Exception Handling introduced in Java SE 7
- Program to validate a user using JSP
- Java Program to Demonstrate How User Authentication is Done
- Finding Data Type of User Input using Regular Expression in Java
- Java Swing | Simple User Registration Form
- Java Program to check whether it is possible to make a divisible by 3 number using all digits in an array
- Java Program for How to check if a given number is Fibonacci number?
- Java Program to Check if all digits of a number divide it
- Java Program to Check if count of divisors is even or odd
- Java Program to check Armstrong Number
- Java program to check if a number is prime or not
- Java Program to Check if two Arrays are Equal or not
- Java Program to Check if a Directory is Empty or Not
- Java Program to Check if a Given Integer is Positive or Negative
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Code_Mech