Search in sources :

Example 56 with MidpointForm

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);
    }
}
Also used : AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) Label(org.apache.wicket.markup.html.basic.Label) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) PasswordTextField(org.apache.wicket.markup.html.form.PasswordTextField) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) RestartResponseException(org.apache.wicket.RestartResponseException) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 57 with MidpointForm

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);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) ValuePolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType) Form(org.apache.wicket.markup.html.form.Form) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)

Example 58 with MidpointForm

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);
}
Also used : MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) Form(org.apache.wicket.markup.html.form.Form) ArrayList(java.util.ArrayList) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) RestartResponseException(org.apache.wicket.RestartResponseException) SecurityQuestionAnswerDTO(com.evolveum.midpoint.web.page.admin.home.dto.SecurityQuestionAnswerDTO) SecurityContext(org.springframework.security.core.context.SecurityContext) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) MyPasswordQuestionsPanel(com.evolveum.midpoint.web.page.admin.home.component.MyPasswordQuestionsPanel)

Example 59 with MidpointForm

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);
}
Also used : MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) Fragment(org.apache.wicket.markup.html.panel.Fragment) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 60 with MidpointForm

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;
        }
    });
}
Also used : MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) MultiLineLabel(org.apache.wicket.markup.html.basic.MultiLineLabel)

Aggregations

MidpointForm (com.evolveum.midpoint.web.component.form.MidpointForm)75 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)41 Form (org.apache.wicket.markup.html.form.Form)39 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)20 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)19 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)17 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)17 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)15 MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)14 ArrayList (java.util.ArrayList)14 Label (org.apache.wicket.markup.html.basic.Label)14 IModel (org.apache.wicket.model.IModel)14 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)11 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)9 ListItem (org.apache.wicket.markup.html.list.ListItem)8 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)7 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)7 List (java.util.List)7 OnChangeAjaxBehavior (org.apache.wicket.ajax.form.OnChangeAjaxBehavior)7 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)6