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.commons.EnduserConstants;
24 import org.apache.syncope.client.enduser.rest.UserSelfRestClient;
25 import org.apache.syncope.client.ui.commons.Constants;
26 import org.apache.syncope.client.ui.commons.markup.html.form.AjaxPasswordFieldPanel;
27 import org.apache.syncope.common.lib.to.UserTO;
28 import org.apache.wicket.ajax.AjaxRequestTarget;
29 import org.apache.wicket.request.mapper.parameter.PageParameters;
30 import org.apache.wicket.spring.injection.annot.SpringBean;
31
32 public class MustChangePassword extends AbstractChangePassword {
33
34 private static final long serialVersionUID = 8581970794722709800L;
35
36 @SpringBean
37 protected UserSelfRestClient userSelfRestClient;
38
39 public MustChangePassword(final PageParameters parameters) {
40 super(parameters);
41
42 setDomain(parameters);
43 disableSidebar();
44 }
45
46 @Override
47 protected void doPwdSubmit(final AjaxRequestTarget target, final AjaxPasswordFieldPanel passwordField) {
48 try {
49 userSelfRestClient.mustChangePassword(passwordField.getModelObject());
50
51 SyncopeEnduserSession.get().success(getString(Constants.OPERATION_SUCCEEDED));
52 SyncopeEnduserSession.get().invalidate();
53
54 PageParameters parameters = new PageParameters();
55 parameters.add(EnduserConstants.STATUS, Constants.OPERATION_SUCCEEDED);
56 parameters.add(Constants.NOTIFICATION_TITLE_PARAM, getString("self.pwd.change.success.msg"));
57 parameters.add(Constants.NOTIFICATION_MSG_PARAM, getString("self.pwd.change.success"));
58 parameters.add(
59 EnduserConstants.LANDING_PAGE,
60 SyncopeWebApplication.get().getPageClass("profile", Dashboard.class).getName());
61 setResponsePage(getApplication().getHomePage(), parameters);
62 } catch (Exception e) {
63 LOG.error("While changing password for {}",
64 SyncopeEnduserSession.get().getSelfTO().getUsername(), e);
65 SyncopeEnduserSession.get().onException(e);
66 notificationPanel.refresh(target);
67 }
68 }
69
70 @Override
71 protected UserTO getPwdLoggedUser() {
72 return SyncopeEnduserSession.get().getSelfTO();
73 }
74
75 @Override
76 protected void doPwdCancel() {
77 SyncopeEnduserSession.get().invalidate();
78 setResponsePage(getApplication().getHomePage(), new PageParameters());
79 }
80 }