Search in sources :

Example 1 with CaptchaPanel

use of com.evolveum.midpoint.gui.api.component.captcha.CaptchaPanel in project midpoint by Evolveum.

the class PageSelfRegistration method validateCaptcha.

private boolean validateCaptcha(AjaxRequestTarget target) {
    CaptchaPanel captcha = getCaptcha();
    if (captcha.getRandomText() == null) {
        String message = createStringResource("PageSelfRegistration.captcha.validation.failed").getString();
        LOGGER.error(message);
        getSession().error(message);
        target.add(getFeedbackPanel());
        updateCaptcha(target);
        return false;
    }
    if (captcha.getCaptchaText() != null && captcha.getRandomText() != null) {
        if (!captcha.getCaptchaText().equals(captcha.getRandomText())) {
            String message = createStringResource("PageSelfRegistration.captcha.validation.failed").getString();
            LOGGER.error(message);
            getSession().error(message);
            updateCaptcha(target);
            target.add(getFeedbackPanel());
            return false;
        }
    }
    LOGGER.trace("CAPTCHA Validation OK");
    return true;
}
Also used : CaptchaPanel(com.evolveum.midpoint.gui.api.component.captcha.CaptchaPanel)

Example 2 with CaptchaPanel

use of com.evolveum.midpoint.gui.api.component.captcha.CaptchaPanel in project midpoint by Evolveum.

the class PageSelfRegistration method updateCaptcha.

private void updateCaptcha(AjaxRequestTarget target) {
    CaptchaPanel captcha = new CaptchaPanel(ID_CAPTCHA);
    captcha.setOutputMarkupId(true);
    Form<?> form = (Form<?>) get(ID_MAIN_FORM);
    form.addOrReplace(captcha);
    target.add(form);
}
Also used : Form(com.evolveum.midpoint.web.component.form.Form) CaptchaPanel(com.evolveum.midpoint.gui.api.component.captcha.CaptchaPanel)

Example 3 with CaptchaPanel

use of com.evolveum.midpoint.gui.api.component.captcha.CaptchaPanel in project midpoint by Evolveum.

the class PageSelfRegistration method initLayout.

private void initLayout() {
    final Form<?> mainForm = new Form<>(ID_MAIN_FORM);
    initAccessBehaviour(mainForm);
    add(mainForm);
    addMultilineLable(ID_WELCOME, "PageSelfRegistration.welcome.message", mainForm);
    addMultilineLable(ID_ADDITIONAL_TEXT, "PageSelfRegistration.additional.message", mainForm);
    initStaticFormLayout(mainForm);
    initDynamicFormLayout(mainForm);
    CaptchaPanel captcha = new CaptchaPanel(ID_CAPTCHA);
    captcha.setOutputMarkupId(true);
    mainForm.add(captcha);
    AjaxSubmitButton register = new AjaxSubmitButton(ID_SUBMIT_REGISTRATION) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onError(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            showErrors(target);
        }

        protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            submitRegistration(target);
        }
    };
    mainForm.add(register);
    MultiLineLabel label = new MultiLineLabel(ID_REGISTRATION_SUBMITED, createStringResource("PageSelfRegistration.registration.confirm.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;
        }
    });
    AjaxButton back = new AjaxButton(ID_BACK) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            setResponsePage(PageLogin.class);
        }
    };
    mainForm.add(back);
}
Also used : AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) Form(com.evolveum.midpoint.web.component.form.Form) CaptchaPanel(com.evolveum.midpoint.gui.api.component.captcha.CaptchaPanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) MultiLineLabel(org.apache.wicket.markup.html.basic.MultiLineLabel)

Example 4 with CaptchaPanel

use of com.evolveum.midpoint.gui.api.component.captcha.CaptchaPanel in project midpoint by Evolveum.

the class PageAbstractFlow method initCaptchaAndButtons.

private void initCaptchaAndButtons(WebMarkupContainer content) {
    CaptchaPanel captcha = new CaptchaPanel(ID_CAPTCHA, this);
    captcha.setOutputMarkupId(true);
    content.add(captcha);
    AjaxSubmitButton register = new AjaxSubmitButton(ID_SUBMIT_REGISTRATION, createStringResource("PageSelfRegistration.register")) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onError(AjaxRequestTarget target) {
            showErrors(target);
        }

        protected void onSubmit(AjaxRequestTarget target) {
            doRegistration(target);
        }
    };
    content.add(register);
    AjaxButton back = new AjaxButton(ID_BACK, createStringResource("PageSelfRegistration.back")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            setResponsePage(PageLogin.class);
        }
    };
    back.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isBackButtonVisible();
        }
    });
    content.add(back);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) CaptchaPanel(com.evolveum.midpoint.gui.api.component.captcha.CaptchaPanel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 5 with CaptchaPanel

use of com.evolveum.midpoint.gui.api.component.captcha.CaptchaPanel in project midpoint by Evolveum.

the class PageAbstractFlow method updateCaptcha.

protected void updateCaptcha(AjaxRequestTarget target) {
    CaptchaPanel captcha = new CaptchaPanel(ID_CAPTCHA, this);
    captcha.setOutputMarkupId(true);
    Fragment fragment = (Fragment) get(createComponentPath(ID_MAIN_FORM, ID_CONTENT_AREA));
    fragment.addOrReplace(captcha);
    target.add(fragment);
}
Also used : CaptchaPanel(com.evolveum.midpoint.gui.api.component.captcha.CaptchaPanel) Fragment(org.apache.wicket.markup.html.panel.Fragment)

Aggregations

CaptchaPanel (com.evolveum.midpoint.gui.api.component.captcha.CaptchaPanel)6 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)2 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)2 Form (com.evolveum.midpoint.web.component.form.Form)2 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 MultiLineLabel (org.apache.wicket.markup.html.basic.MultiLineLabel)1 Fragment (org.apache.wicket.markup.html.panel.Fragment)1