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 − usernameRule
Passay - UsernameRule
UsernameRule ensures that password is not containing the username. Consider the following example.
Example
import org.passay.PasswordData; import org.passay.PasswordVapdator; import org.passay.Rule; import org.passay.RuleResult; import org.passay.UsernameRule; pubpc class PassayExample { pubpc static void main(String[] args) { //Rule: Password should not contain user-name Rule rule = new UsernameRule(); PasswordVapdator vapdator = new PasswordVapdator(rule); PasswordData password = new PasswordData("microsoft"); password.setUsername("micro"); RuleResult result = vapdator.vapdate(password); if(result.isVapd()){ System.out.println("Password vapdated."); }else{ System.out.println("Invapd Password: " + vapdator.getMessages(result)); } } }
Output
Invapd Password: [Password contains the user id micro .]Advertisements