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.panels.any;
20
21 import de.agilecoders.wicket.extensions.markup.html.bootstrap.form.password.strength.PasswordStrengthBehavior;
22 import java.util.List;
23 import java.util.Optional;
24 import org.apache.commons.lang3.StringUtils;
25 import org.apache.syncope.client.ui.commons.ajax.markup.html.LabelInfo;
26 import org.apache.syncope.client.ui.commons.markup.html.form.AjaxDropDownChoicePanel;
27 import org.apache.syncope.client.ui.commons.markup.html.form.AjaxTextFieldPanel;
28 import org.apache.syncope.client.ui.commons.markup.html.form.FieldPanel;
29 import org.apache.syncope.client.ui.commons.markup.html.form.SyncopePasswordStrengthConfig;
30 import org.apache.syncope.client.ui.commons.wizards.any.PasswordPanel;
31 import org.apache.syncope.client.ui.commons.wizards.any.UserWrapper;
32 import org.apache.syncope.common.lib.SyncopeConstants;
33 import org.apache.syncope.common.lib.to.UserTO;
34 import org.apache.wicket.PageReference;
35 import org.apache.wicket.markup.html.basic.Label;
36 import org.apache.wicket.markup.html.panel.Panel;
37 import org.apache.wicket.model.PropertyModel;
38 import org.apache.wicket.model.ResourceModel;
39
40 public class UserDetails extends Details<UserTO> {
41
42 private static final long serialVersionUID = 6592027822510220463L;
43
44 protected final AjaxTextFieldPanel username;
45
46 protected final UserTO userTO;
47
48 public UserDetails(final String id, final UserWrapper wrapper, final PageReference pageRef) {
49 super(id, pageRef);
50
51 userTO = wrapper.getInnerObject();
52
53
54
55 username = new AjaxTextFieldPanel("username", "username", new PropertyModel<>(userTO, "username"), false);
56
57 if (wrapper.getPreviousUserTO() != null && StringUtils.
58 compare(wrapper.getPreviousUserTO().getUsername(), wrapper.getInnerObject().getUsername()) != 0) {
59 username.showExternAction(new LabelInfo("externalAction", wrapper.getPreviousUserTO().getUsername()));
60 }
61
62 username.addRequiredLabel();
63 add(username);
64
65
66
67
68
69 add(buildDestinationRealm());
70 }
71
72 protected FieldPanel<String> buildDestinationRealm() {
73 AjaxDropDownChoicePanel<String> destinationRealm = new AjaxDropDownChoicePanel<>(
74 "destinationRealm", "destinationRealm", new PropertyModel<>(userTO, "realm"), false);
75 destinationRealm.setNullValid(false);
76 destinationRealm.setChoices(List.of(
77 Optional.ofNullable(userTO.getRealm()).orElse(SyncopeConstants.ROOT_REALM)));
78 return destinationRealm;
79 }
80
81 protected static class EditUserPasswordPanel extends Panel {
82
83 private static final long serialVersionUID = -8198836979773590078L;
84
85 protected EditUserPasswordPanel(final String id, final UserWrapper wrapper) {
86 super(id);
87 setOutputMarkupId(true);
88 add(new Label("warning", new ResourceModel("password.change.warning")));
89 add(new PasswordPanel(
90 "passwordPanel",
91 wrapper,
92 false,
93 wrapper.getInnerObject().getKey() == null,
94 new PasswordStrengthBehavior(new SyncopePasswordStrengthConfig())));
95 }
96 }
97 }