And the ministry of communications development in the name of muhammad al khorezmi tashkent university of information technologies


We can see that each rule gives us a clear explanation if the password is not valid


Download 175,21 Kb.
bet5/8
Sana09.04.2023
Hajmi175,21 Kb.
#1343718
1   2   3   4   5   6   7   8
Bog'liq
Mustaqil Ish-1

We can see that each rule gives us a clear explanation if the password is not valid. There are notifications that the password is too short and has two illegal characters. We can also notice that the password doesn't match the provided regular expression.
What's more, we're informed that it contains insufficient lowercase letters.

5.2. CharacterCharacterisitcsRule


CharcterCharacterisitcsRule is more complex than rules presented before. To create a CharcterCharacterisitcsRule object, we need to provide a list of CharacterRules. What's more, we have to set how many of them the password must match. We can do it this way:

CharacterCharacteristicsRule characterCharacteristicsRule = new CharacterCharacteristicsRule(
3,
new CharacterRule(EnglishCharacterData.LowerCase, 5),
new CharacterRule(EnglishCharacterData.UpperCase, 5),
new CharacterRule(EnglishCharacterData.Digit),
new CharacterRule(EnglishCharacterData.Special)
);
Presented CharacterCharacteristicsRule requires a password to contain three of four provided rules.

5.3. LengthComplexityRule


On the other handPassay library provides us with LengthComplexityRuleIt allows us to define which rules should be applied to the password of which length. In contra st to CharacterCharacteristicsRule, they allow us to use all kind of rules – not only CharacterRule.
Let's analyze the example:
LengthComplexityRule lengthComplexityRule = new LengthComplexityRule();
lengthComplexityRule.addRules("[1,5]", new CharacterRule(EnglishCharacterData.LowerCase, 5));
lengthComplexityRule.addRules("[6,10]",
new AllowedCharacterRule(new char[] { 'a', 'b', 'c', 'd' }));

As we can see for password having one to five characters, we apply CharacterRule. But for a password containing six to ten characters, we want the password to match AllowedCharacterRule.



Download 175,21 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2025
ma'muriyatiga murojaat qiling