use of com.evolveum.midpoint.web.page.forgetpassword.ResetPolicyDto.ResetMethod in project midpoint by Evolveum.
the class PageForgotPassword method initStaticLayout.
private void initStaticLayout(Form<?> mainForm) {
WebMarkupContainer staticLayout = new WebMarkupContainer(ID_STATIC_LAYOUT);
staticLayout.setOutputMarkupId(true);
mainForm.add(staticLayout);
staticLayout.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return !isDynamicForm();
}
});
WebMarkupContainer userNameContainer = new WebMarkupContainer(ID_USERNAME_CONTAINER);
userNameContainer.setOutputMarkupId(true);
staticLayout.add(userNameContainer);
RequiredTextField<String> userName = new RequiredTextField<>(ID_USERNAME, new Model<>());
userName.setOutputMarkupId(true);
userNameContainer.add(userName);
userNameContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
public boolean isVisible() {
return getResetPasswordPolicy().getResetMethod() == ResetMethod.SECURITY_QUESTIONS;
}
});
WebMarkupContainer emailContainer = new WebMarkupContainer(ID_EMAIL_CONTAINER);
emailContainer.setOutputMarkupId(true);
staticLayout.add(emailContainer);
RequiredTextField<String> email = new RequiredTextField<>(ID_EMAIL, new Model<>());
email.add(RfcCompliantEmailAddressValidator.getInstance());
email.setOutputMarkupId(true);
emailContainer.add(email);
emailContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
public boolean isVisible() {
ResetMethod resetMethod = getResetPasswordPolicy().getResetMethod();
return resetMethod == ResetMethod.SECURITY_QUESTIONS || resetMethod == ResetMethod.MAIL;
}
});
}
use of com.evolveum.midpoint.web.page.forgetpassword.ResetPolicyDto.ResetMethod in project midpoint by Evolveum.
the class PageForgotPassword method createStaticFormQuery.
private ObjectQuery createStaticFormQuery(Form form) {
RequiredTextField<String> usernameTextFiled = (RequiredTextField) form.get(createComponentPath(ID_STATIC_LAYOUT, ID_USERNAME_CONTAINER, ID_USERNAME));
RequiredTextField<String> emailTextField = (RequiredTextField) form.get(createComponentPath(ID_STATIC_LAYOUT, ID_EMAIL_CONTAINER, ID_EMAIL));
String username = usernameTextFiled != null ? usernameTextFiled.getModelObject() : null;
String email = emailTextField != null ? emailTextField.getModelObject() : null;
LOGGER.debug("Reset Password user info form submitted. username={}, email={}", username, email);
ResetPolicyDto resetPasswordPolicy = getResetPasswordPolicy();
if (resetPasswordPolicy == null) {
passwordResetNotSupported();
}
ResetMethod method = resetPasswordPolicy.getResetMethod();
if (method == null) {
passwordResetNotSupported();
}
switch(method) {
case MAIL:
return getPrismContext().queryFor(UserType.class).item(UserType.F_EMAIL_ADDRESS).eq(email).matchingCaseIgnore().build();
case SECURITY_QUESTIONS:
return getPrismContext().queryFor(UserType.class).item(UserType.F_NAME).eqPoly(username).matchingNorm().and().item(UserType.F_EMAIL_ADDRESS).eq(email).matchingCaseIgnore().build();
default:
passwordResetNotSupported();
// not reached
return null;
}
}
Aggregations