当前位置: 首页>>代码示例>>Java>>正文


Java EnglishCharacterData类代码示例

本文整理汇总了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;
}
 
开发者ID:cloudfoundry-incubator,项目名称:credhub,代码行数:22,代码来源:CharacterRuleProvider.java

示例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();
}
 
开发者ID:MohamadSaada,项目名称:LogiGSK,代码行数:29,代码来源:Settings.java

示例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();
}
 
开发者ID:MohamadSaada,项目名称:LogiGSK,代码行数:29,代码来源:Settings.java

示例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)
  )));
}
 
开发者ID:cloudfoundry-incubator,项目名称:credhub,代码行数:19,代码来源:CharacterRuleProviderTest.java

示例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)
  )));
}
 
开发者ID:cloudfoundry-incubator,项目名称:credhub,代码行数:19,代码来源:CharacterRuleProviderTest.java

示例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))));
}
 
开发者ID:cloudfoundry-incubator,项目名称:credhub,代码行数:17,代码来源:CharacterRuleProviderTest.java

示例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)
  )));
}
 
开发者ID:cloudfoundry-incubator,项目名称:credhub,代码行数:18,代码来源:CharacterRuleProviderTest.java

示例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))));
}
 
开发者ID:cloudfoundry-incubator,项目名称:credhub,代码行数:14,代码来源:CharacterRuleProviderTest.java

示例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)
  ));
}
 
开发者ID:cloudfoundry-incubator,项目名称:credhub,代码行数:16,代码来源:CharacterRuleProviderTest.java

示例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);
}
 
开发者ID:cloudiator,项目名称:sword,代码行数:20,代码来源:AzureCreateVirtualMachineStrategy.java

示例11: mandatoryDigits

import org.passay.EnglishCharacterData; //导入依赖的package包/类
public SecurityPasswordRulesBuilder mandatoryDigits(int min) {
	rules.add(new CharacterRule(EnglishCharacterData.Digit, min));
	return this;
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:5,代码来源:SecurityPasswordRulesBuilder.java

示例12: mandatoryNonAlphanumericCharacters

import org.passay.EnglishCharacterData; //导入依赖的package包/类
public SecurityPasswordRulesBuilder mandatoryNonAlphanumericCharacters() {
	rules.add(new CharacterRule(EnglishCharacterData.Special));
	return this;
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:5,代码来源:SecurityPasswordRulesBuilder.java

示例13: mandatoryUpperCase

import org.passay.EnglishCharacterData; //导入依赖的package包/类
public SecurityPasswordRulesBuilder mandatoryUpperCase() {
	rules.add(new CharacterRule(EnglishCharacterData.UpperCase));
	return this;
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:5,代码来源:SecurityPasswordRulesBuilder.java

示例14: mandatoryLowerCase

import org.passay.EnglishCharacterData; //导入依赖的package包/类
public SecurityPasswordRulesBuilder mandatoryLowerCase() {
	rules.add(new CharacterRule(EnglishCharacterData.LowerCase));
	return this;
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:5,代码来源:SecurityPasswordRulesBuilder.java

示例15: mandatoryUpperLowerCase

import org.passay.EnglishCharacterData; //导入依赖的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


注:本文中的org.passay.EnglishCharacterData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。