diff --git a/perun-wui-core/src/main/java/cz/metacentrum/perun/wui/client/resources/PerunTranslation.java b/perun-wui-core/src/main/java/cz/metacentrum/perun/wui/client/resources/PerunTranslation.java index 8909b569..6126387d 100644 --- a/perun-wui-core/src/main/java/cz/metacentrum/perun/wui/client/resources/PerunTranslation.java +++ b/perun-wui-core/src/main/java/cz/metacentrum/perun/wui/client/resources/PerunTranslation.java @@ -288,4 +288,13 @@ public interface PerunTranslation extends Messages { @DefaultMessage("Password can`t contain login, name or surname, not even backwards!") public String einfraPasswordStrengthForNameLogin(); + @DefaultMessage("Password must
" + translation.einfraPasswordHelp()); } else if (Objects.equals(namespace, "vsup")) { help.setHTML("
"+translation.vsupHelp()); + } else if (Objects.equals(namespace, "mu")) { + help.setHTML("
"+translation.muPasswordHelp()); } return; @@ -509,6 +511,34 @@ private boolean validate() { return false; } + } else if (Objects.equals(namespace, "mu")) { + + // Check that password contains at least 3 of 4 character groups + + RegExp regExpDigit = RegExp.compile("^.*[0-9].*$"); + RegExp regExpLower = RegExp.compile("^.*[a-z].*$"); + RegExp regExpUpper = RegExp.compile("^.*[A-Z].*$"); + RegExp regExpSpec = RegExp.compile("^.*[\\x20-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7B-\\x7E].*$"); // FIXME - are those correct printable specific chars? + + int matchCounter = 0; + if (regExpDigit.exec(passwordTextBox.getValue()) != null) matchCounter++; + if (regExpLower.exec(passwordTextBox.getValue()) != null) matchCounter++; + if (regExpUpper.exec(passwordTextBox.getValue()) != null) matchCounter++; + if (regExpSpec.exec(passwordTextBox.getValue()) != null) matchCounter++; + + if(matchCounter < 3){ + passItem.setValidationState(ValidationState.ERROR); + itemStatus.setHTML(translation.muPasswordStrength()); + return false; + } + + // check length + if (passwordTextBox.getValue().length() < 12) { + passItem.setValidationState(ValidationState.ERROR); + itemStatus.setHTML(translation.muPasswordLength()); + return false; + } + } if (!Objects.equals(passwordTextBox.getValue(), passwordTextBox2.getValue())) {