Skip to content
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 @@ -48,6 +48,7 @@
import org.keycloak.forms.login.freemarker.model.LogoutConfirmBean;
import org.keycloak.forms.login.freemarker.model.OAuthGrantBean;
import org.keycloak.forms.login.freemarker.model.OrganizationBean;
import org.keycloak.forms.login.freemarker.model.PasswordPoliciesBean;
import org.keycloak.forms.login.freemarker.model.ProfileBean;
import org.keycloak.forms.login.freemarker.model.RealmBean;
import org.keycloak.forms.login.freemarker.model.RecoveryAuthnCodeInputLoginBean;
Expand Down Expand Up @@ -548,6 +549,7 @@ protected void createCommonAttributes(Theme theme, Locale locale, Properties mes
attributes.put("org", new OrganizationBean(organization, user));
}
}
attributes.put("passwordPolicies", new PasswordPoliciesBean(realm.getPasswordPolicy()));
}
if (realm != null && user != null && session != null) {
attributes.put("authenticatorConfigured", new AuthenticatorConfiguredMethod(realm, user, session));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package org.keycloak.forms.login.freemarker.model;

import org.keycloak.models.PasswordPolicy;

public class PasswordPoliciesBean {
private final Integer length;
private final Integer maxLength;
private final Integer lowerCase;
private final Integer upperCase;
private final Integer specialChars;
private final Integer digits;
private final Integer passwordHistory;
private final Integer forceExpiredPasswordChange;
private final boolean notUsername;
private final boolean notEmail;

public PasswordPoliciesBean(PasswordPolicy policy) {
this.length = policy.getPolicyConfig("length");
this.maxLength = policy.getPolicyConfig("maxLength");
this.lowerCase = policy.getPolicyConfig("lowerCase");
this.upperCase = policy.getPolicyConfig("upperCase");
this.specialChars = policy.getPolicyConfig("specialChars");
this.digits = policy.getPolicyConfig("digits");
this.passwordHistory = policy.getPolicyConfig("passwordHistory");
this.forceExpiredPasswordChange = policy.getPolicyConfig("forceExpiredPasswordChange");
this.notUsername = policy.getPolicies().contains("notUsername");
this.notEmail = policy.getPolicies().contains("notEmail");
}

public Integer getLength() {
return length;
}

public Integer getMaxLength() {
return maxLength;
}

public Integer getLowerCase() {
return lowerCase;
}

public Integer getUpperCase() {
return upperCase;
}

public Integer getSpecialChars() {
return specialChars;
}

public Integer getDigits() {
return digits;
}

public Integer getPasswordHistory() {
return passwordHistory;
}

public Integer getForceExpiredPasswordChange() {
return forceExpiredPasswordChange;
}

public boolean isNotUsername() {
return notUsername;
}

public boolean isNotEmail() {
return notEmail;
}
}