- Passay Tutorial
- Passay − Home
- Passay − Overview
- Passay − environment Setup
- Validation/Generation
- Passay − Password Validation
- Passay − Customized Messages
- Passay − M of N Rules
- Passay − Password Generation
- Positive Matching Rules
- passay − AllowedCharacterRule
- Passay − AllowedRegexRule
- Passay −CharacterRule
- passay − LengthRule
- Passay − CharacterCharacteristicsRule
- Passay − LengthComplexityRule
- Negative Matching Rules
- Passay − lllegalCharacterRule
- Passay − NumberRangeRule
- Passay − WhitespaceRule
- Passay − DictionaryRule
- Passay − DictionarySubstringRule
- Passay − HistoryRule
- passay − RepeatCharacterRegexRule
- Passay − usernameRule
- Passay Useful Resources
- Passay - Quick Guide
- Passay - Resources
- Passay - Discussion
Passay - Password Generation
PasswordGenerator helps in generating password using given policy. Consider the following policy:
Length of password should be 8 characters.
A password should contains each of the following: upper, lower, digit and a symbol.
Example
The below example shows the generation of a password against above policy using Passay library.
import org.passay.CharacterRule; import org.passay.EnglishCharacterData; import org.passay.PasswordGenerator; public class PassayExample { public static void main(String[] args) { CharacterRule alphabets = new CharacterRule(EnglishCharacterData.Alphabetical); CharacterRule digits = new CharacterRule(EnglishCharacterData.Digit); CharacterRule special = new CharacterRule(EnglishCharacterData.Special); PasswordGenerator passwordGenerator = new PasswordGenerator(); String password = passwordGenerator.generatePassword(8, alphabets, digits, special); System.out.println(password); } }
Output
?\DE~@c3
Advertisements