本文整理汇总了Java中org.passay.CharacterRule类的典型用法代码示例。如果您正苦于以下问题:Java CharacterRule类的具体用法?Java CharacterRule怎么用?Java CharacterRule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CharacterRule类属于org.passay包,在下文中一共展示了CharacterRule类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getCharacterRules
import org.passay.CharacterRule; //导入依赖的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;
}
开发者ID:cloudfoundry-incubator,项目名称:credhub,代码行数:22,代码来源:CharacterRuleProvider.java
示例2: generatePassword
import org.passay.CharacterRule; //导入依赖的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();
}
开发者ID:MohamadSaada,项目名称:LogiGSK,代码行数:29,代码来源:Settings.java
示例3: generateEncryptionPassword
import org.passay.CharacterRule; //导入依赖的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();
}
开发者ID:MohamadSaada,项目名称:LogiGSK,代码行数:29,代码来源:Settings.java
示例4: getCharacterRules_canCreateCharacterRulesWithoutUppercase
import org.passay.CharacterRule; //导入依赖的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)
)));
}
开发者ID:cloudfoundry-incubator,项目名称:credhub,代码行数:19,代码来源:CharacterRuleProviderTest.java
示例5: getCharacterRules_canCreateCharacterRulesWithoutLowercase
import org.passay.CharacterRule; //导入依赖的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)
)));
}
开发者ID:cloudfoundry-incubator,项目名称:credhub,代码行数:19,代码来源:CharacterRuleProviderTest.java
示例6: getCharacterRules_canCreateCharacterRulesWithoutSpecialCharacters
import org.passay.CharacterRule; //导入依赖的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))));
}
开发者ID:cloudfoundry-incubator,项目名称:credhub,代码行数:17,代码来源:CharacterRuleProviderTest.java
示例7: getCharacterRules_canCreateCharacterRulesWithoutNumbers
import org.passay.CharacterRule; //导入依赖的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)
)));
}
开发者ID:cloudfoundry-incubator,项目名称:credhub,代码行数:18,代码来源:CharacterRuleProviderTest.java
示例8: usesCharacters
import org.passay.CharacterRule; //导入依赖的package包/类
private Matcher<CharacterRule> usesCharacters(CharacterData characterData) {
return new BaseMatcher<CharacterRule>() {
@Override
public boolean matches(final Object item) {
final CharacterRule rule = (CharacterRule) item;
return rule.getValidCharacters().equals(characterData.getCharacters());
}
@Override
public void describeTo(final Description description) {
description.appendText("getValidCharacters() should equal")
.appendValue(characterData.getCharacters());
}
};
}
开发者ID:cloudfoundry-incubator,项目名称:credhub,代码行数:17,代码来源:CharacterRuleProviderTest.java
示例9: generateCredential
import org.passay.CharacterRule; //导入依赖的package包/类
public StringCredentialValue generateCredential(StringGenerationParameters parameters) {
int passwordLength = normalizedLength(parameters.getLength());
List<CharacterRule> characterRules = CharacterRuleProvider.getCharacterRules(parameters);
return new StringCredentialValue(
passwordGenerator.generatePassword(passwordLength, characterRules));
}
开发者ID:cloudfoundry-incubator,项目名称:credhub,代码行数:9,代码来源:PassayStringCredentialGenerator.java
示例10: getCharacterRules_createdCharacterRulesFromDefaultParameters
import org.passay.CharacterRule; //导入依赖的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))));
}
开发者ID:cloudfoundry-incubator,项目名称:credhub,代码行数:14,代码来源:CharacterRuleProviderTest.java
示例11: getCharacterRules_canCreateCharacterRulesWithAllIncluded
import org.passay.CharacterRule; //导入依赖的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)
));
}
开发者ID:cloudfoundry-incubator,项目名称:credhub,代码行数:16,代码来源:CharacterRuleProviderTest.java
示例12: getCharacterRules_returnsAnEmptyListWhenAllAreExcluded
import org.passay.CharacterRule; //导入依赖的package包/类
@Test
public void getCharacterRules_returnsAnEmptyListWhenAllAreExcluded() {
StringGenerationParameters generationParameters = new StringGenerationParameters();
generationParameters.setIncludeSpecial(false);
generationParameters.setExcludeNumber(true);
generationParameters.setExcludeUpper(true);
generationParameters.setExcludeLower(true);
List<CharacterRule> characterRules = CharacterRuleProvider
.getCharacterRules(generationParameters);
assertThat(characterRules, iterableWithSize(0));
}
开发者ID:cloudfoundry-incubator,项目名称:credhub,代码行数:13,代码来源:CharacterRuleProviderTest.java
示例13: generatePassword
import org.passay.CharacterRule; //导入依赖的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);
}
开发者ID:cloudiator,项目名称:sword,代码行数:20,代码来源:AzureCreateVirtualMachineStrategy.java
示例14: mandatoryDigits
import org.passay.CharacterRule; //导入依赖的package包/类
public SecurityPasswordRulesBuilder mandatoryDigits(int min) {
rules.add(new CharacterRule(EnglishCharacterData.Digit, min));
return this;
}
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:5,代码来源:SecurityPasswordRulesBuilder.java
示例15: mandatoryNonAlphanumericCharacters
import org.passay.CharacterRule; //导入依赖的package包/类
public SecurityPasswordRulesBuilder mandatoryNonAlphanumericCharacters() {
rules.add(new CharacterRule(EnglishCharacterData.Special));
return this;
}
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:5,代码来源:SecurityPasswordRulesBuilder.java
示例16: mandatoryUpperCase
import org.passay.CharacterRule; //导入依赖的package包/类
public SecurityPasswordRulesBuilder mandatoryUpperCase() {
rules.add(new CharacterRule(EnglishCharacterData.UpperCase));
return this;
}
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:5,代码来源:SecurityPasswordRulesBuilder.java
示例17: mandatoryLowerCase
import org.passay.CharacterRule; //导入依赖的package包/类
public SecurityPasswordRulesBuilder mandatoryLowerCase() {
rules.add(new CharacterRule(EnglishCharacterData.LowerCase));
return this;
}
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:5,代码来源:SecurityPasswordRulesBuilder.java
示例18: mandatoryUpperLowerCase
import org.passay.CharacterRule; //导入依赖的package包/类
public SecurityPasswordRulesBuilder mandatoryUpperLowerCase() {
rules.add(new CharacterRule(EnglishCharacterData.LowerCase));
rules.add(new CharacterRule(EnglishCharacterData.UpperCase));
return this;
}
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:6,代码来源:SecurityPasswordRulesBuilder.java
示例19: generatePassword
import org.passay.CharacterRule; //导入依赖的package包/类
private String generatePassword() {
final List<CharacterRule> rules = Arrays.asList(
new CharacterRule(EnglishCharacterData.UpperCase, 1),
new CharacterRule(EnglishCharacterData.LowerCase, 1),
new CharacterRule(EnglishCharacterData.Digit, 1),
new CharacterRule(EnglishCharacterData.Special, 1));
final PasswordGenerator generator = new PasswordGenerator();
// Generated password is 12 characters long, which complies with policy
return generator.generatePassword(12, rules);
}
开发者ID:Hack23,项目名称:cia,代码行数:16,代码来源:UserRoleSystemTest.java
注:本文中的org.passay.CharacterRule类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论