本文整理汇总了Java中org.passay.EnglishCharacterData类的典型用法代码示例。如果您正苦于以下问题:Java EnglishCharacterData类的具体用法?Java EnglishCharacterData怎么用?Java EnglishCharacterData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EnglishCharacterData类属于org.passay包,在下文中一共展示了EnglishCharacterData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCharacterRules
import org.passay.EnglishCharacterData; //导入依赖的package包/类
public static List<CharacterRule> getCharacterRules(StringGenerationParameters parameters) {
List<CharacterRule> characterRules = new ArrayList<>();
if (parameters.isIncludeSpecial()) {
characterRules.add(new CharacterRule(CredHubCharacterData.Special));
}
if (!parameters.isExcludeNumber()) {
characterRules.add(new CharacterRule(EnglishCharacterData.Digit));
}
if (!parameters.isExcludeUpper()) {
characterRules.add(new CharacterRule(EnglishCharacterData.UpperCase));
}
if (!parameters.isExcludeLower()) {
characterRules.add(new CharacterRule(EnglishCharacterData.LowerCase));
}
return characterRules;
}
示例2: generatePassword
import org.passay.EnglishCharacterData; //导入依赖的package包/类
public void generatePassword() {
char[] special = new char[]{'!', '"', '#', '$', '%', '&', '\'', '(', ')', '*',
'+', '-', '.', '/', ':', '<', '=', '>', '?', '@', '[', '\\', ']',
'^', '_', '`', '{', '|', '}', '~'};
List<CharacterRule> rules = Arrays.asList(
// at least one upper-case character
new CharacterRule(EnglishCharacterData.UpperCase, 1),
// at least one lower-case character
new CharacterRule(EnglishCharacterData.LowerCase, 1),
// at least one digit character
new CharacterRule(EnglishCharacterData.Digit, 1),
new CharacterRule(new CharacterData() {
@Override
public String getErrorCode() {
return "INSUFFICIENT_SPECIAL";
}
@Override
public String getCharacters() {
return new String(special);
}
}, 1));
PasswordGenerator generator = new PasswordGenerator();
// Generated password is 16 characters long, which complies with policy
String password = generator.generatePassword(16, rules);
this.password = password.toCharArray();
}
示例3: generateEncryptionPassword
import org.passay.EnglishCharacterData; //导入依赖的package包/类
public void generateEncryptionPassword() {
char[] special = new char[]{'!', '"', '#', '$', '%', '&', '\'', '(', ')', '*',
'+', ',', '-', '.', '/', ':', '<', '=', '>', '?', '@', '[', '\\', ']',
'^', '_', '`', '{', '|', '}', '~'};
List<CharacterRule> rules = Arrays.asList(
// at least one upper-case character
new CharacterRule(EnglishCharacterData.UpperCase, 1),
// at least one lower-case character
new CharacterRule(EnglishCharacterData.LowerCase, 1),
// at least one digit character
new CharacterRule(EnglishCharacterData.Digit, 1),
new CharacterRule(new CharacterData() {
@Override
public String getErrorCode() {
return "INSUFFICIENT_SPECIAL";
}
@Override
public String getCharacters() {
return new String(special);
}
}, 1));
PasswordGenerator generator = new PasswordGenerator();
// Generated password is 16 characters long, which complies with policy
String password = generator.generatePassword(16, rules);
this.encryptionPassword = password.toCharArray();
}
示例4: getCharacterRules_canCreateCharacterRulesWithoutUppercase
import org.passay.EnglishCharacterData; //导入依赖的package包/类
@Test
public void getCharacterRules_canCreateCharacterRulesWithoutUppercase() {
StringGenerationParameters generationParameters = new StringGenerationParameters();
generationParameters.setExcludeUpper(true);
List<CharacterRule> characterRules = CharacterRuleProvider
.getCharacterRules(generationParameters);
assertThat(characterRules, iterableWithSize(2));
assertThat(characterRules, containsInAnyOrder(
usesCharacters(EnglishCharacterData.LowerCase),
usesCharacters(EnglishCharacterData.Digit)
));
assertThat(characterRules, not(containsInAnyOrder(
usesCharacters(EnglishCharacterData.UpperCase),
usesCharacters(CredHubCharacterData.Special),
usesCharacters(CredHubCharacterData.Hex)
)));
}
示例5: getCharacterRules_canCreateCharacterRulesWithoutLowercase
import org.passay.EnglishCharacterData; //导入依赖的package包/类
@Test
public void getCharacterRules_canCreateCharacterRulesWithoutLowercase() {
StringGenerationParameters generationParameters = new StringGenerationParameters();
generationParameters.setExcludeLower(true);
List<CharacterRule> characterRules = CharacterRuleProvider
.getCharacterRules(generationParameters);
assertThat(characterRules, iterableWithSize(2));
assertThat(characterRules, containsInAnyOrder(
usesCharacters(EnglishCharacterData.UpperCase),
usesCharacters(EnglishCharacterData.Digit)
));
assertThat(characterRules, not(containsInAnyOrder(
usesCharacters(EnglishCharacterData.LowerCase),
usesCharacters(CredHubCharacterData.Special),
usesCharacters(CredHubCharacterData.Hex)
)));
}
示例6: getCharacterRules_canCreateCharacterRulesWithoutSpecialCharacters
import org.passay.EnglishCharacterData; //导入依赖的package包/类
@Test
public void getCharacterRules_canCreateCharacterRulesWithoutSpecialCharacters() {
StringGenerationParameters generationParameters = new StringGenerationParameters();
generationParameters.setIncludeSpecial(false);
List<CharacterRule> characterRules = CharacterRuleProvider
.getCharacterRules(generationParameters);
assertThat(characterRules, iterableWithSize(3));
assertThat(characterRules, containsInAnyOrder(
usesCharacters(EnglishCharacterData.UpperCase),
usesCharacters(EnglishCharacterData.LowerCase),
usesCharacters(EnglishCharacterData.Digit)
));
assertThat(characterRules, not(hasItem(usesCharacters(CredHubCharacterData.Special))));
assertThat(characterRules, not(hasItem(usesCharacters(CredHubCharacterData.Hex))));
}
示例7: getCharacterRules_canCreateCharacterRulesWithoutNumbers
import org.passay.EnglishCharacterData; //导入依赖的package包/类
@Test
public void getCharacterRules_canCreateCharacterRulesWithoutNumbers() {
StringGenerationParameters generationParameters = new StringGenerationParameters();
generationParameters.setExcludeNumber(true);
List<CharacterRule> characterRules = CharacterRuleProvider
.getCharacterRules(generationParameters);
assertThat(characterRules, iterableWithSize(2));
assertThat(characterRules, containsInAnyOrder(
usesCharacters(EnglishCharacterData.UpperCase),
usesCharacters(EnglishCharacterData.LowerCase)
));
assertThat(characterRules, not(containsInAnyOrder(
usesCharacters(EnglishCharacterData.Digit),
usesCharacters(CredHubCharacterData.Special)
)));
}
示例8: getCharacterRules_createdCharacterRulesFromDefaultParameters
import org.passay.EnglishCharacterData; //导入依赖的package包/类
@Test
public void getCharacterRules_createdCharacterRulesFromDefaultParameters() {
StringGenerationParameters generationParameters = new StringGenerationParameters();
List<CharacterRule> characterRules = CharacterRuleProvider
.getCharacterRules(generationParameters);
assertThat(characterRules, containsInAnyOrder(
usesCharacters(EnglishCharacterData.Digit),
usesCharacters(EnglishCharacterData.LowerCase),
usesCharacters(EnglishCharacterData.UpperCase)
));
assertThat(characterRules, not(hasItem(usesCharacters(CredHubCharacterData.Hex))));
}
示例9: getCharacterRules_canCreateCharacterRulesWithAllIncluded
import org.passay.EnglishCharacterData; //导入依赖的package包/类
@Test
public void getCharacterRules_canCreateCharacterRulesWithAllIncluded() {
StringGenerationParameters generationParameters = new StringGenerationParameters();
generationParameters.setIncludeSpecial(true);
List<CharacterRule> characterRules = CharacterRuleProvider
.getCharacterRules(generationParameters);
assertThat(characterRules, iterableWithSize(4));
assertThat(characterRules, containsInAnyOrder(
usesCharacters(EnglishCharacterData.UpperCase),
usesCharacters(EnglishCharacterData.LowerCase),
usesCharacters(EnglishCharacterData.Digit),
usesCharacters(CredHubCharacterData.Special)
));
}
示例10: generatePassword
import org.passay.EnglishCharacterData; //导入依赖的package包/类
private String generatePassword() {
PasswordGenerator passwordGenerator = new PasswordGenerator();
List<CharacterRule> rules = Arrays.asList(
// at least one upper-case character
new CharacterRule(EnglishCharacterData.UpperCase, 1),
// at least one lower-case character
new CharacterRule(EnglishCharacterData.LowerCase, 1),
// at least one digit character
new CharacterRule(EnglishCharacterData.Digit, 1),
// at least one symbol (special character)
new CharacterRule(SpecialCharacterData.INSTANCE, 1));
return passwordGenerator.generatePassword(8, rules);
}
示例11: mandatoryDigits
import org.passay.EnglishCharacterData; //导入依赖的package包/类
public SecurityPasswordRulesBuilder mandatoryDigits(int min) {
rules.add(new CharacterRule(EnglishCharacterData.Digit, min));
return this;
}
示例12: mandatoryNonAlphanumericCharacters
import org.passay.EnglishCharacterData; //导入依赖的package包/类
public SecurityPasswordRulesBuilder mandatoryNonAlphanumericCharacters() {
rules.add(new CharacterRule(EnglishCharacterData.Special));
return this;
}
示例13: mandatoryUpperCase
import org.passay.EnglishCharacterData; //导入依赖的package包/类
public SecurityPasswordRulesBuilder mandatoryUpperCase() {
rules.add(new CharacterRule(EnglishCharacterData.UpperCase));
return this;
}
示例14: mandatoryLowerCase
import org.passay.EnglishCharacterData; //导入依赖的package包/类
public SecurityPasswordRulesBuilder mandatoryLowerCase() {
rules.add(new CharacterRule(EnglishCharacterData.LowerCase));
return this;
}
示例15: mandatoryUpperLowerCase
import org.passay.EnglishCharacterData; //导入依赖的package包/类
public SecurityPasswordRulesBuilder mandatoryUpperLowerCase() {
rules.add(new CharacterRule(EnglishCharacterData.LowerCase));
rules.add(new CharacterRule(EnglishCharacterData.UpperCase));
return this;
}