Search in sources :

Example 1 with Images

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"));
}
Also used : StrengthInfo(pl.edu.icm.unity.stdext.credential.pass.StrengthChecker.StrengthInfo) Images(pl.edu.icm.unity.webui.common.Images)

Aggregations

StrengthInfo (pl.edu.icm.unity.stdext.credential.pass.StrengthChecker.StrengthInfo)1 Images (pl.edu.icm.unity.webui.common.Images)1