use of org.apache.syncope.common.lib.patch.UserPatch in project syncope by apache.
the class AutoActivate method doExecute.
@Override
protected void doExecute(final String executionId) {
User user = engine.getRuntimeService().getVariable(executionId, FlowableUserWorkflowAdapter.USER, User.class);
UserTO userTO = engine.getRuntimeService().getVariable(executionId, FlowableUserWorkflowAdapter.USER_TO, UserTO.class);
if (userTO != null && userTO.getKey() != null && user.getKey() != null) {
user = userDAO.save(user);
UserPatch userPatch = AnyOperations.diff(userTO, dataBinder.getUserTO(user, true), false);
// don't mess with password, as the cleartext values was already properly saved
userPatch.setPassword(null);
dataBinder.update(user, userPatch);
engine.getRuntimeService().setVariable(executionId, FlowableUserWorkflowAdapter.USER, user);
}
engine.getRuntimeService().setVariable(executionId, FlowableUserWorkflowAdapter.PROPAGATE_ENABLE, Boolean.TRUE);
}
use of org.apache.syncope.common.lib.patch.UserPatch in project syncope by apache.
the class PasswordReset method doExecute.
@Override
protected void doExecute(final String executionId) {
User user = engine.getRuntimeService().getVariable(executionId, FlowableUserWorkflowAdapter.USER, User.class);
String token = engine.getRuntimeService().getVariable(executionId, FlowableUserWorkflowAdapter.TOKEN, String.class);
String password = engine.getRuntimeService().getVariable(executionId, FlowableUserWorkflowAdapter.PASSWORD, String.class);
if (!user.checkToken(token)) {
throw new WorkflowException(new IllegalArgumentException("Wrong token: " + token + " for " + user));
}
user.removeToken();
UserPatch userPatch = new UserPatch();
userPatch.setKey(user.getKey());
userPatch.setPassword(new PasswordPatch.Builder().onSyncope(true).resources(userDAO.findAllResourceKeys(user.getKey())).value(password).build());
PropagationByResource propByRes = dataBinder.update(user, userPatch);
// report updated user and propagation by resource as result
engine.getRuntimeService().setVariable(executionId, FlowableUserWorkflowAdapter.USER, user);
engine.getRuntimeService().setVariable(executionId, FlowableUserWorkflowAdapter.USER_PATCH, userPatch);
engine.getRuntimeService().setVariable(executionId, FlowableUserWorkflowAdapter.PROP_BY_RESOURCE, propByRes);
}
use of org.apache.syncope.common.lib.patch.UserPatch in project syncope by apache.
the class UserRestClient method mustChangePassword.
public ProvisioningResult<UserTO> mustChangePassword(final String etag, final boolean value, final String key) {
final UserPatch userPatch = new UserPatch();
userPatch.setKey(key);
userPatch.setMustChangePassword(new BooleanReplacePatchItem.Builder().value(value).build());
return update(etag, userPatch);
}
use of org.apache.syncope.common.lib.patch.UserPatch in project syncope by apache.
the class UserWizardBuilder method onApplyInternal.
@Override
protected Serializable onApplyInternal(final AnyWrapper<UserTO> modelObject) {
UserTO inner = modelObject.getInnerObject();
ProvisioningResult<UserTO> actual;
if (inner.getKey() == null) {
actual = userRestClient.create(inner, modelObject instanceof UserWrapper ? UserWrapper.class.cast(modelObject).isStorePasswordInSyncope() : StringUtils.isNotBlank(inner.getPassword()));
} else {
UserPatch patch = AnyOperations.diff(inner, getOriginalItem().getInnerObject(), false);
if (StringUtils.isNotBlank(inner.getPassword())) {
PasswordPatch passwordPatch = new PasswordPatch.Builder().value(inner.getPassword()).onSyncope(true).resources(inner.getResources()).build();
patch.setPassword(passwordPatch);
}
// update just if it is changed
if (patch.isEmpty()) {
actual = new ProvisioningResult<>();
actual.setEntity(inner);
} else {
actual = userRestClient.update(getOriginalItem().getInnerObject().getETagValue(), patch);
}
}
return actual;
}
use of org.apache.syncope.common.lib.patch.UserPatch in project syncope by apache.
the class UserLogic method doUpdate.
protected ProvisioningResult<UserTO> doUpdate(final UserPatch userPatch, final boolean self, final boolean nullPriorityAsync) {
UserTO userTO = binder.getUserTO(userPatch.getKey());
Set<String> dynRealmsBefore = new HashSet<>(userTO.getDynRealms());
Pair<UserPatch, List<LogicActions>> before = beforeUpdate(userPatch, userTO.getRealm());
boolean authDynRealms = false;
if (!self && before.getLeft().getRealm() != null && StringUtils.isNotBlank(before.getLeft().getRealm().getValue())) {
Set<String> effectiveRealms = RealmUtils.getEffective(AuthContextUtils.getAuthorizations().get(StandardEntitlement.USER_UPDATE), before.getLeft().getRealm().getValue());
authDynRealms = securityChecks(effectiveRealms, before.getLeft().getRealm().getValue(), before.getLeft().getKey());
}
Pair<UserPatch, List<PropagationStatus>> updated = provisioningManager.update(before.getLeft(), nullPriorityAsync);
return afterUpdate(binder.returnUserTO(binder.getUserTO(updated.getLeft().getKey())), updated.getRight(), before.getRight(), authDynRealms, dynRealmsBefore);
}
Aggregations