in client/idrepo/console/src/main/java/org/apache/syncope/client/console/panels/UserDirectoryPanel.java [133:362]
public ActionsPanel<UserTO> getActions(final IModel<UserTO> model) {
final ActionsPanel<UserTO> panel = super.getActions(model);
panel.add(new ActionLink<>() {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target, final UserTO ignore) {
send(UserDirectoryPanel.this, Broadcast.EXACT,
new AjaxWizard.EditItemActionEvent<>(
new UserWrapper(restClient.read(model.getObject().getKey())), target));
}
}, ActionType.EDIT,
String.format("%s,%s", IdRepoEntitlement.USER_READ, IdRepoEntitlement.USER_UPDATE)).
setRealms(realm, model.getObject().getDynRealms());
panel.add(new ActionLink<>() {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target, final UserTO ignore) {
try {
model.setObject(restClient.read(model.getObject().getKey()));
restClient.mustChangePassword(
model.getObject().getETagValue(),
!model.getObject().isMustChangePassword(),
model.getObject().getKey());
SyncopeConsoleSession.get().success(getString(Constants.OPERATION_SUCCEEDED));
target.add(container);
} catch (Exception e) {
LOG.error("While actioning object {}", model.getObject().getKey(), e);
SyncopeConsoleSession.get().onException(e);
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}, ActionType.MUSTCHANGEPASSWORD, IdRepoEntitlement.USER_UPDATE).
setRealms(realm, model.getObject().getDynRealms());
if (wizardInModal) {
panel.add(new ActionLink<>() {
private static final long serialVersionUID = -4875218360625971340L;
@Override
public void onClick(final AjaxRequestTarget target, final UserTO ignore) {
model.setObject(restClient.read(model.getObject().getKey()));
IModel<AnyWrapper<UserTO>> formModel = new CompoundPropertyModel<>(
new UserWrapper(model.getObject()));
displayAttributeModal.setFormModel(formModel);
target.add(displayAttributeModal.setContent(new ChangePasswordModal(
displayAttributeModal,
new UserWrapper(model.getObject()),
pageRef)));
displayAttributeModal.header(new Model<>(
getString("any.edit", new Model<>(new UserWrapper(model.getObject())))));
displayAttributeModal.size(Modal.Size.Large);
displayAttributeModal.show(true);
}
}, ActionType.PASSWORD_MANAGEMENT, IdRepoEntitlement.USER_UPDATE).
setRealms(realm, model.getObject().getDynRealms());
PlatformInfo platformInfo = SyncopeConsoleSession.get().getAnonymousClient().platform();
if (platformInfo.isPwdResetAllowed() && !platformInfo.isPwdResetRequiringSecurityQuestions()) {
panel.add(new ActionLink<>() {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target, final UserTO ignore) {
try {
SyncopeConsoleSession.get().getAnonymousClient().getService(UserSelfService.class).
requestPasswordReset(model.getObject().getUsername(), null);
SyncopeConsoleSession.get().success(getString(Constants.OPERATION_SUCCEEDED));
target.add(container);
} catch (Exception e) {
LOG.error("While actioning object {}", model.getObject().getKey(), e);
SyncopeConsoleSession.get().onException(e);
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}, ActionType.REQUEST_PASSWORD_RESET, IdRepoEntitlement.USER_UPDATE).
setRealms(realm, model.getObject().getDynRealms());
}
SyncopeWebApplication.get().getAnyDirectoryPanelAdditionalActionLinksProvider().get(
model,
realm,
altDefaultModal,
getString("any.edit", new Model<>(new UserWrapper(model.getObject()))),
this,
pageRef).forEach(panel::add);
panel.add(new ActionLink<>() {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target, final UserTO ignore) {
target.add(utilityModal.setContent(new AnyPropagationTasks(
utilityModal, AnyTypeKind.USER, model.getObject().getKey(), pageRef)));
utilityModal.header(new StringResourceModel("any.propagation.tasks", model));
utilityModal.show(true);
}
}, ActionType.PROPAGATION_TASKS, IdRepoEntitlement.TASK_LIST);
panel.add(new ActionLink<>() {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target, final UserTO ignore) {
target.add(utilityModal.setContent(
new NotificationTasks(AnyTypeKind.USER, model.getObject().getKey(), pageRef)));
utilityModal.header(new StringResourceModel("any.notification.tasks", model));
utilityModal.show(true);
target.add(utilityModal);
}
}, ActionType.NOTIFICATION_TASKS, IdRepoEntitlement.TASK_LIST);
}
if (wizardInModal) {
panel.add(new ActionLink<>() {
private static final long serialVersionUID = -1978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target, final UserTO ignore) {
model.setObject(restClient.read(model.getObject().getKey()));
target.add(altDefaultModal.setContent(new AuditHistoryModal<>(
null,
null,
model.getObject(),
IdRepoEntitlement.USER_UPDATE,
auditRestClient) {
private static final long serialVersionUID = 959378158400669867L;
@Override
protected void restore(final String json, final AjaxRequestTarget target) {
// The original audit record masks the password and the security
// answer; so we cannot use the audit record to resurrect the entry
// based on mask data.
//
// The method behavior below will reset the audit record such
// that the current security answer and the password for the object
// are always maintained, and such properties for the
// user cannot be restored using audit records.
UserTO original = model.getObject();
try {
UserTO updated = MAPPER.readValue(json, UserTO.class);
UserUR updateReq = AnyOperations.diff(updated, original, false);
updateReq.setPassword(null);
updateReq.setSecurityAnswer(null);
ProvisioningResult<UserTO> result =
restClient.update(original.getETagValue(), updateReq);
model.getObject().setLastChangeDate(result.getEntity().getLastChangeDate());
SyncopeConsoleSession.get().success(getString(Constants.OPERATION_SUCCEEDED));
target.add(container);
} catch (Exception e) {
LOG.error("While restoring user {}", model.getObject().getKey(), e);
SyncopeConsoleSession.get().onException(e);
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}));
altDefaultModal.header(new Model<>(
getString("auditHistory.title", new Model<>(new UserWrapper(model.getObject())))));
altDefaultModal.show(true);
}
}, ActionType.VIEW_AUDIT_HISTORY,
String.format("%s,%s", IdRepoEntitlement.USER_READ, IdRepoEntitlement.AUDIT_LIST)).
setRealms(realm, model.getObject().getDynRealms());
}
panel.add(new ActionLink<>() {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target, final UserTO ignore) {
UserTO clone = SerializationUtils.clone(model.getObject());
clone.setKey(null);
clone.setUsername(model.getObject().getUsername() + "_clone");
send(UserDirectoryPanel.this, Broadcast.EXACT,
new AjaxWizard.NewItemActionEvent<>(new UserWrapper(clone), target));
}
@Override
protected boolean statusCondition(final UserTO modelObject) {
return addAjaxLink.isVisibleInHierarchy() && realm.startsWith(SyncopeConstants.ROOT_REALM);
}
}, ActionType.CLONE, IdRepoEntitlement.USER_CREATE).setRealm(realm);
panel.add(new ActionLink<>() {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target, final UserTO ignore) {
try {
restClient.delete(model.getObject().getETagValue(), model.getObject().getKey());
SyncopeConsoleSession.get().success(getString(Constants.OPERATION_SUCCEEDED));
target.add(container);
} catch (Exception e) {
LOG.error("While deleting user {}", model.getObject().getKey(), e);
SyncopeConsoleSession.get().onException(e);
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
@Override
protected boolean statusCondition(final UserTO modelObject) {
return realm.startsWith(SyncopeConstants.ROOT_REALM);
}
}, ActionType.DELETE, IdRepoEntitlement.USER_DELETE, true).setRealm(realm);
return panel;
}