Add a PasswordPoliciesBean to the FreeMarker context.
Closes #32553 Signed-off-by: Garth <244253+xgp@users.noreply.github.com>
This commit is contained in:
parent
9a03828fe4
commit
7988f026e0
2 changed files with 71 additions and 0 deletions
|
@ -48,6 +48,7 @@ import org.keycloak.forms.login.freemarker.model.LoginBean;
|
||||||
import org.keycloak.forms.login.freemarker.model.LogoutConfirmBean;
|
import org.keycloak.forms.login.freemarker.model.LogoutConfirmBean;
|
||||||
import org.keycloak.forms.login.freemarker.model.OAuthGrantBean;
|
import org.keycloak.forms.login.freemarker.model.OAuthGrantBean;
|
||||||
import org.keycloak.forms.login.freemarker.model.OrganizationBean;
|
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.ProfileBean;
|
||||||
import org.keycloak.forms.login.freemarker.model.RealmBean;
|
import org.keycloak.forms.login.freemarker.model.RealmBean;
|
||||||
import org.keycloak.forms.login.freemarker.model.RecoveryAuthnCodeInputLoginBean;
|
import org.keycloak.forms.login.freemarker.model.RecoveryAuthnCodeInputLoginBean;
|
||||||
|
@ -548,6 +549,7 @@ public class FreeMarkerLoginFormsProvider implements LoginFormsProvider {
|
||||||
attributes.put("org", new OrganizationBean(organization, user));
|
attributes.put("org", new OrganizationBean(organization, user));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
attributes.put("passwordPolicies", new PasswordPoliciesBean(realm.getPasswordPolicy()));
|
||||||
}
|
}
|
||||||
if (realm != null && user != null && session != null) {
|
if (realm != null && user != null && session != null) {
|
||||||
attributes.put("authenticatorConfigured", new AuthenticatorConfiguredMethod(realm, user, session));
|
attributes.put("authenticatorConfigured", new AuthenticatorConfiguredMethod(realm, user, session));
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue