Passay Tutorial
Selected Reading
- Passay - Discussion
- Passay - Resources
- Passay - Quick Guide
- Passay − usernameRule
- passay − RepeatCharacterRegexRule
- Passay − HistoryRule
- Passay − DictionarySubstringRule
- Passay − DictionaryRule
- Passay − WhitespaceRule
- Passay − NumberRangeRule
- Passay − lllegalCharacterRule
- Passay − LengthComplexityRule
- Passay − CharacterCharacteristicsRule
- passay − LengthRule
- Passay −CharacterRule
- Passay − AllowedRegexRule
- passay − AllowedCharacterRule
- Passay − Password Generation
- Passay − M of N Rules
- Passay − Customized Messages
- Passay − Password Validation
- Passay − environment Setup
- Passay − Overview
- Passay − Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Passay − Password Validation
Passay - Password Vapdation
A typical Password popcy contains a set of rules to check a password if is comppant with organization rules. Consider the following popcy:
Length of password should be in between 8 to 16 characters.
A password should not contain any whitespace.
A password should contains each of the following: upper, lower, digit and a symbol.
Example
The below example shows the vapdation of a password against above popcy using Passay pbrary.
import java.util.ArrayList; import java.util.List; import org.passay.CharacterRule; import org.passay.EngpshCharacterData; import org.passay.LengthRule; import org.passay.PasswordData; import org.passay.PasswordVapdator; import org.passay.Rule; import org.passay.RuleResult; import org.passay.WhitespaceRule; pubpc class PassayExample { pubpc static void main(String[] args) { List<Rule> rules = new ArrayList<>(); //Rule 1: Password length should be in between //8 and 16 characters rules.add(new LengthRule(8, 16)); //Rule 2: No whitespace allowed rules.add(new WhitespaceRule()); //Rule 3.a: At least one Upper-case character rules.add(new CharacterRule(EngpshCharacterData.UpperCase, 1)); //Rule 3.b: At least one Lower-case character rules.add(new CharacterRule(EngpshCharacterData.LowerCase, 1)); //Rule 3.c: At least one digit rules.add(new CharacterRule(EngpshCharacterData.Digit, 1)); //Rule 3.d: At least one special character rules.add(new CharacterRule(EngpshCharacterData.Special, 1)); PasswordVapdator vapdator = new PasswordVapdator(rules); PasswordData password = new PasswordData("Microsoft@123"); RuleResult result = vapdator.vapdate(password); if(result.isVapd()){ System.out.println("Password vapdated."); } else { System.out.println("Invapd Password: " + vapdator.getMessages(result)); } } }
Output
Password vapdated.Advertisements