use of pl.edu.icm.unity.webui.common.Images in project unity by unity-idm.
the class PasswordQualityComponent method onNewPassword.
public void onNewPassword(String password) {
StrengthInfo measure = StrengthChecker.measure(password, config.getMinScore(), msg);
int length = password.length();
boolean trivialSequences = StrengthChecker.hasNoTrivialSequences(password);
int classes = StrengthChecker.getCharacterClasses(password);
qualityMeter.setValue((float) measure.scoreNormalized);
if (config.getMinScore() > 0) {
boolean isScoreOK = measure.score >= config.getMinScore();
Images qualityIcon = isScoreOK ? Images.ok : Images.warn;
qualityMeter.setIcon(qualityIcon.getResource());
qualityMeter.setStyleName(Styles.iconError.toString(), !isScoreOK);
if (isScoreOK) {
qualityMeter.removeStyleName(Styles.redProgressBar.toString());
qualityMeter.setStyleName(Styles.greenProgressBar.toString());
} else {
qualityMeter.removeStyleName(Styles.greenProgressBar.toString());
qualityMeter.setStyleName(Styles.redProgressBar.toString());
}
}
if (!measure.warning.isEmpty()) {
mainInfo.setValue(msg.getMessage("PasswordCredentialEditor.hint", measure.warning));
} else if (!measure.suggestions.isEmpty()) {
mainInfo.setValue(msg.getMessage("PasswordCredentialEditor.hint", measure.suggestions.get(0)));
} else {
mainInfo.setValue("");
}
styleStatusLabel(minLengthStatus, length >= config.getMinLength(), msg.getMessage("PasswordCredentialEditor.minLengthStatus", length, config.getMinLength()));
styleStatusLabel(minClassesStatus, classes >= config.getMinClassesNum(), msg.getMessage("PasswordCredentialEditor.minClassesStatus", classes, config.getMinClassesNum()));
styleStatusLabel(sequencesStatus, trivialSequences, msg.getMessage("PasswordCredentialEditor.trivialSequences"));
}
Aggregations