Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

password policy defaults to generate passwords that are easier to read #307

Merged
merged 2 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public CharacterSet() {
}

public void add(CharacterClasses characterClass, int minOccurrence, int maxOccurrence) {
if (minOccurrence >= 0 && maxOccurrence >= minOccurrence && !characterClasses.contains(characterClass)) {
if (minOccurrence >= 0 && (PasswordPolicy.IGNORE_MAX_OCCURRENCENS || maxOccurrence >= minOccurrence) && !characterClasses.contains(characterClass)) {
characterClasses.add(characterClass);
minOccurrences.put(characterClass, minOccurrence);
maxOccurrences.put(characterClass, maxOccurrence);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public enum CharacterClasses {
SMALL_LETTERS, CAPITAL_LETTERS, DIGITS, UMLAUTS, WHITESPACES, ALT_SYMBOLS, SYMBOLS
}

final static boolean IGNORE_MAX_OCCURRENCENS = true; //if true, max_occurrences is used for generating passwords only
private final static String STRING_RANDOM_ALGORITHM = CoreUtil.RANDOM_ALGORITHM;
private final static HashMap<CharacterClasses, Character[]> CHARACTER_CLASSES = new HashMap<CharacterClasses, Character[]>();
private final static HashMap<CharacterClasses, String> CHARACTER_CLASS_L10NKEYS = new HashMap<CharacterClasses, String>();
Expand Down Expand Up @@ -280,7 +281,7 @@ public void checkStrength(String input) throws IllegalArgumentException {
if (minOccurrence != null && occurrenceCount < minOccurrence) {
throw new IllegalArgumentException(L10nUtil.getMessage(MessageCodes.PASSWORD_TOO_FEW_OCCURRENCES, DefaultMessages.PASSWORD_TOO_FEW_OCCURRENCES, minOccurrence,
characterClassName));
} else if (maxOccurrence != null && occurrenceCount > maxOccurrence) {
} else if (!IGNORE_MAX_OCCURRENCENS && maxOccurrence != null && occurrenceCount > maxOccurrence) {
throw new IllegalArgumentException(L10nUtil.getMessage(MessageCodes.PASSWORD_TOO_MANY_OCCURRENCES, DefaultMessages.PASSWORD_TOO_MANY_OCCURRENCES, maxOccurrence,
characterClassName));
}
Expand Down Expand Up @@ -346,7 +347,7 @@ private String getRandomString(int desiredLength) throws NoSuchAlgorithmExceptio
randomChars.clear();
candidates.clear();
it = characterSet.getCharacterClasses().iterator();
if (i < minRequiredLength) {
if (!IGNORE_MAX_OCCURRENCENS && i < minRequiredLength) {
while (it.hasNext()) {
CharacterClasses characterClass = it.next();
Integer minOccurrence = characterSet.getMinOccurrence(characterClass);
Expand All @@ -358,7 +359,6 @@ private String getRandomString(int desiredLength) throws NoSuchAlgorithmExceptio
}
}
} else {
it = characterSet.getCharacterClasses().iterator();
while (it.hasNext()) {
CharacterClasses characterClass = it.next();
Integer maxOccurrence = characterSet.getMaxOccurrence(characterClass);
Expand Down Expand Up @@ -395,7 +395,7 @@ public String getRequirements() {
requirements.append(L10nUtil.getMessage(MessageCodes.PASSWORD_CHARACTER_CLASS_MIN_REQUIREMENT, DefaultMessages.PASSWORD_CHARACTER_CLASS_MIN_REQUIREMENT,
minOccurrence, characterClassName));
}
if (maxOccurrence != null && maxOccurrence < maxLength) {
if (!IGNORE_MAX_OCCURRENCENS && maxOccurrence != null && maxOccurrence < maxLength) {
requirements.append("\n");
requirements.append(L10nUtil.getMessage(MessageCodes.PASSWORD_CHARACTER_CLASS_MAX_REQUIREMENT, DefaultMessages.PASSWORD_CHARACTER_CLASS_MAX_REQUIREMENT,
maxOccurrence, characterClassName));
Expand Down
26 changes: 13 additions & 13 deletions core/src/main/resources/ctsms-settings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ password_min_digits=1
password_min_umlauts=0
password_min_whitespaces=0
password_min_alt_symbols=0
password_min_symbols=1
password_min_symbols=0
password_max_small_letters=32
password_max_capital_letters=32
password_max_digits=32
password_max_umlauts=32
password_max_whitespaces=32
password_max_alt_symbols=32
password_max_symbols=32
password_max_capital_letters=0
password_max_digits=0
password_max_umlauts=0
password_max_whitespaces=0
password_max_alt_symbols=0
password_max_symbols=0
password_min_levenshtein_distance=2
password_distance_password_history=0
password_admin_ignore_policy=true
Expand All @@ -86,14 +86,14 @@ department_password_min_digits=1
department_password_min_umlauts=0
department_password_min_whitespaces=0
department_password_min_alt_symbols=0
department_password_min_symbols=1
department_password_min_symbols=0
department_password_max_small_letters=256
department_password_max_capital_letters=256
department_password_max_capital_letters=0
department_password_max_digits=256
department_password_max_umlauts=256
department_password_max_whitespaces=256
department_password_max_alt_symbols=256
department_password_max_symbols=256
department_password_max_umlauts=0
department_password_max_whitespaces=0
department_password_max_alt_symbols=0
department_password_max_symbols=0

logon_expires=true
logon_prolongable=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,16 +246,7 @@
</p:tooltip>
</h:panelGroup>
<p:message for="countryName" />











<h:outputLabel
styleClass="ctsms-field-icon ctsms-icon-encryption"
rendered="#{probandAddressBean.showProvince}"
Expand Down
Loading