use of com.evolveum.midpoint.web.component.form.MidpointForm in project midpoint by Evolveum.
the class PageAccountActivation method initLayout.
private void initLayout() {
WebMarkupContainer activationContainer = new WebMarkupContainer(ID_ACTIVATION_CONTAINER);
activationContainer.setOutputMarkupId(true);
add(activationContainer);
activationContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return !activated;
}
});
Form<?> form = new MidpointForm<>(ID_MAIN_FORM);
activationContainer.add(form);
Label usernamePanel = new Label(ID_NAME, createStringResource("PageAccountActivation.activate.accounts.label", userModel != null && userModel.getObject() != null && userModel.getObject().getName() != null ? getLocalizationService().translate(userModel.getObject().getName().toPolyString()) : ""));
usernamePanel.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
return false;
}
});
form.add(usernamePanel);
PasswordTextField passwordPanel = new PasswordTextField(ID_PASSWORD, Model.of(new String()));
form.add(passwordPanel);
AjaxSubmitButton confirmPasswrod = new AjaxSubmitButton(ID_CONFIRM) {
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(AjaxRequestTarget target) {
propagatePassword(target, getForm());
}
@Override
protected void onError(AjaxRequestTarget target) {
getSession().error(getString("PageAccountActivation.account.activation.failed"));
target.add(getFeedbackPanel());
}
};
form.setDefaultButton(confirmPasswrod);
form.add(confirmPasswrod);
WebMarkupContainer confirmationContainer = new WebMarkupContainer(ID_CONFIRMATION_CONTAINER);
confirmationContainer.setOutputMarkupId(true);
confirmationContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return activated;
}
});
add(confirmationContainer);
AjaxLink<Void> linkToLogin = new AjaxLink<Void>(ID_LINK_TO_LOGIN) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
setResponsePage(PageLogin.class);
}
};
confirmationContainer.add(linkToLogin);
RepeatingView activatedShadows = new RepeatingView(ID_ACTIVATED_SHADOWS);
confirmationContainer.add(activatedShadows);
List<ShadowType> shadowsToActivate = getShadowsToActivate();
if (shadowsToActivate.isEmpty()) {
LOGGER.error("No accounts to validate for user {}", userModel.getObject());
getSession().warn(getString("PageAccountActivation.nothing.to.activate"));
throw new RestartResponseException(PageLogin.class);
}
for (ShadowType shadow : shadowsToActivate) {
Label shadowDesc = new Label(activatedShadows.newChildId(), WebComponentUtil.getName(shadow) + " on resource " + WebComponentUtil.getName(shadow.getResourceRef()));
activatedShadows.add(shadowDesc);
}
}
use of com.evolveum.midpoint.web.component.form.MidpointForm in project midpoint by Evolveum.
the class PageValuePolicies method initLayout.
protected void initLayout() {
Form mainForm = new MidpointForm(ID_MAIN_FORM);
add(mainForm);
MainObjectListPanel<ValuePolicyType> table = new MainObjectListPanel<ValuePolicyType>(ID_TABLE, ValuePolicyType.class) {
@Override
protected void objectDetailsPerformed(AjaxRequestTarget target, ValuePolicyType valuePolicy) {
PageValuePolicies.this.valuePolicyDetailsPerformed(target, valuePolicy);
}
@Override
protected UserProfileStorage.TableId getTableId() {
return UserProfileStorage.TableId.TABLE_VALUE_POLICIES;
}
@Override
protected List<IColumn<SelectableBean<ValuePolicyType>, String>> createDefaultColumns() {
return PageValuePolicies.this.initValuePoliciesColumns();
}
@Override
protected List<InlineMenuItem> createInlineMenu() {
return PageValuePolicies.this.createInlineMenu();
}
};
table.setOutputMarkupId(true);
mainForm.add(table);
}
use of com.evolveum.midpoint.web.component.form.MidpointForm in project midpoint by Evolveum.
the class PageSecurityQuestions method initLayout.
public void initLayout() {
Form mainForm = new MidpointForm(ID_MAIN_FORM);
pqPanels = new ArrayList<>();
PrismObject<SecurityPolicyType> securityPolicy = getGlobalSecurityPolicy();
LOGGER.trace("Found security policy: {}", securityPolicy);
if (securityPolicy == null) {
LOGGER.error("No security policy, cannot process security questions");
// we do not want to provide any information to the attacker.
throw new RestartResponseException(PageError.class);
}
SecurityQuestionsCredentialsPolicyType secQuestionsPolicy = securityPolicy.asObjectable().getCredentials() != null ? securityPolicy.asObjectable().getCredentials().getSecurityQuestions() : null;
questionNumber = secQuestionsPolicy != null ? secQuestionsPolicy.getQuestionNumber() : 1;
questionList = secQuestionsPolicy != null ? secQuestionsPolicy.getQuestion() : new ArrayList<>();
List<SecurityQuestionAnswerDTO> userQuestionAnswerList = questions.getUserQuestionAnswers();
if (userQuestionAnswerList == null) {
getSession().error(getString("pageForgetPassword.message.ContactAdminQuestionsNotSet"));
SecurityContext securityContext = SecurityContextHolder.getContext();
securityContext.setAuthentication(null);
throw new RestartResponseException(PageForgotPassword.class);
}
int panelNumber = 0;
// Loop for finding the preset questions from the Policy Questions
for (SecurityQuestionDefinitionType question : questionList) {
// user's question List loop to match the questions
for (SecurityQuestionAnswerDTO questionAnswer : userQuestionAnswerList) {
// if the question is in the policy check
if (questionAnswer.getPwdQuestionIdentifier().equalsIgnoreCase(question.getIdentifier())) {
LoadableModel<SecurityQuestionAnswerDTO> model = new LoadableModel<SecurityQuestionAnswerDTO>() {
@Override
protected SecurityQuestionAnswerDTO load() {
SecurityQuestionAnswerDTO a = new SecurityQuestionAnswerDTO(questionAnswer.getPwdQuestionIdentifier(), "", questionAnswer.getPwdQuestion());
a = checkIfQuestionIsValid(a, questionList);
return a;
}
};
MyPasswordQuestionsPanel panel = new MyPasswordQuestionsPanel(ID_QUESTION_ANSWER_PANEL, model);
panel.getBaseFormComponent().setRequired(true);
pqPanels.add(panel);
panelNumber++;
}
}
if (panelNumber == questionNumber) {
// we have enough
break;
}
}
if (panelNumber < questionNumber) {
getSession().error(getString("pageForgetPassword.message.ContactAdminQuestionsNotSetEnough"));
SecurityContext securityContext = SecurityContextHolder.getContext();
securityContext.setAuthentication(null);
throw new RestartResponseException(PageForgotPassword.class);
}
add(mainForm);
mainForm.add(getPanels(pqPanels));
initButtons(mainForm);
}
use of com.evolveum.midpoint.web.component.form.MidpointForm in project midpoint by Evolveum.
the class PageAbstractFlow method initLayout.
private void initLayout() {
MidpointForm<?> mainForm = new MidpointForm<>(ID_MAIN_FORM);
mainForm.setMultiPart(true);
add(mainForm);
WebMarkupContainer content;
Fragment fragment;
if (!isCustomFormDefined()) {
fragment = new Fragment(ID_CONTENT_AREA, "staticContent", this);
content = initStaticLayout();
} else {
fragment = new Fragment(ID_CONTENT_AREA, "dynamicContent", this);
content = initDynamicLayout();
}
fragment.setOutputMarkupId(true);
content.setOutputMarkupId(true);
initCaptchaAndButtons(fragment);
fragment.add(content);
mainForm.add(fragment);
}
use of com.evolveum.midpoint.web.component.form.MidpointForm in project midpoint by Evolveum.
the class PageEmailNonse method initCustomLayer.
protected void initCustomLayer() {
MidpointForm form = new MidpointForm(ID_MAIN_FORM);
form.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return !submited;
}
});
add(form);
initStaticLayout(form);
initDynamicLayout(form, PageEmailNonse.this);
initButtons(form);
MultiLineLabel label = new MultiLineLabel(ID_PASSWORD_RESET_SUBMITED, createStringResource("PageForgotPassword.form.submited.message"));
add(label);
label.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return submited;
}
@Override
public boolean isEnabled() {
return submited;
}
});
}
Aggregations