1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.client.enduser.pages;
20
21 import org.apache.syncope.client.enduser.SyncopeEnduserSession;
22 import org.apache.syncope.client.enduser.SyncopeWebApplication;
23 import org.apache.syncope.client.enduser.panels.ChangePasswordPanel;
24 import org.apache.syncope.client.ui.commons.Constants;
25 import org.apache.syncope.client.ui.commons.markup.html.form.AjaxPasswordFieldPanel;
26 import org.apache.syncope.common.lib.to.UserTO;
27 import org.apache.wicket.AttributeModifier;
28 import org.apache.wicket.ajax.AjaxRequestTarget;
29 import org.apache.wicket.markup.html.WebMarkupContainer;
30 import org.apache.wicket.request.mapper.parameter.PageParameters;
31
32 public abstract class AbstractChangePassword extends BasePage {
33
34 private static final long serialVersionUID = 5889157642852559004L;
35
36 private static final String CHANGE_PASSWORD = "page.changePassword";
37
38 public AbstractChangePassword(final PageParameters parameters) {
39 super(parameters, CHANGE_PASSWORD);
40
41 WebMarkupContainer content = new WebMarkupContainer("content");
42 content.setOutputMarkupId(true);
43 contentWrapper.add(content);
44
45 ChangePasswordPanel changePasswordPanel = getPasswordPanel();
46 content.add(changePasswordPanel);
47 content.add(new AttributeModifier("style", "height: \"100%\""));
48 }
49
50 protected ChangePasswordPanel getPasswordPanel() {
51 ChangePasswordPanel changePasswordPanel = new ChangePasswordPanel("changePasswordPanel", notificationPanel) {
52
53 private static final long serialVersionUID = 5195544218030499386L;
54
55 @Override
56 protected void doSubmit(final AjaxRequestTarget target, final AjaxPasswordFieldPanel passwordField) {
57 boolean checked = true;
58 if (SyncopeWebApplication.get().isCaptchaEnabled()) {
59 checked = captcha.check();
60 }
61 if (!checked) {
62 SyncopeEnduserSession.get().error(getString(Constants.CAPTCHA_ERROR));
63 getNotificationPanel().refresh(target);
64 } else {
65 doPwdSubmit(target, passwordField);
66 }
67 }
68
69 @Override
70 protected void doCancel() {
71 doPwdCancel();
72 }
73
74 @Override
75 protected UserTO getLoggedUser() {
76 return getPwdLoggedUser();
77 }
78 };
79
80 changePasswordPanel.setOutputMarkupId(true);
81 return changePasswordPanel;
82 }
83
84 protected abstract void doPwdSubmit(AjaxRequestTarget target, AjaxPasswordFieldPanel passwordField);
85
86 protected abstract void doPwdCancel();
87
88 protected abstract UserTO getPwdLoggedUser();
89 }