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
- LongStream.Builder build() in Java
- DoubleStream.Builder build() in Java
- Java 8 | Consumer Interface in Java with Examples
- MouseListener and MouseMotionListener in Java
- Java Program for Selection Sort
- Java Program for Bubble Sort
- Java Program for Insertion Sort
- Java Program for Heap Sort
- Java Program for Radix Sort
- Java Program for n-th Fibonacci numbers
- Java Program for Counting Sort
- Java Program for ShellSort
- Java Program for Longest Common Subsequence
- Java Program for Binary Search (Recursive and Iterative)
- Java Program 0-1 Knapsack Problem
- Java Program for Min Cost Path
- Java Program for Longest Increasing Subsequence
- Java Program for GCD of more than two (or array) numbers
- Java Program for Common Divisors of Two Numbers
- Java Program for Bitonic Sort
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