use of org.apache.syncope.core.provisioning.api.PropagationByResource 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.core.provisioning.api.PropagationByResource in project syncope by apache.
the class DefaultAnyObjectWorkflowAdapter method doCreate.
@Override
protected WorkflowResult<String> doCreate(final AnyObjectTO anyObjectTO) {
AnyObject anyObject = entityFactory.newEntity(AnyObject.class);
dataBinder.create(anyObject, anyObjectTO);
anyObject = anyObjectDAO.save(anyObject);
PropagationByResource propByRes = new PropagationByResource();
propByRes.set(ResourceOperation.CREATE, anyObjectDAO.findAllResourceKeys(anyObject.getKey()));
return new WorkflowResult<>(anyObject.getKey(), propByRes, "create");
}
use of org.apache.syncope.core.provisioning.api.PropagationByResource in project syncope by apache.
the class DefaultUserWorkflowAdapter method doCreate.
@Override
protected WorkflowResult<Pair<String, Boolean>> doCreate(final UserTO userTO, final boolean disablePwdPolicyCheck, final Boolean enabled, final boolean storePassword) {
User user = entityFactory.newEntity(User.class);
dataBinder.create(user, userTO, storePassword);
// this will make UserValidator not to consider password policies at all
if (disablePwdPolicyCheck) {
user.removeClearPassword();
}
String status;
boolean propagateEnable;
if (enabled == null) {
status = "created";
propagateEnable = true;
} else {
status = enabled ? "active" : "suspended";
propagateEnable = enabled;
user.setSuspended(!enabled);
}
user.setStatus(status);
user = userDAO.save(user);
PropagationByResource propByRes = new PropagationByResource();
propByRes.set(ResourceOperation.CREATE, userDAO.findAllResourceKeys(user.getKey()));
return new WorkflowResult<>(Pair.of(user.getKey(), propagateEnable), propByRes, "create");
}
use of org.apache.syncope.core.provisioning.api.PropagationByResource in project syncope by apache.
the class RealmLogic method update.
@PreAuthorize("hasRole('" + StandardEntitlement.REALM_UPDATE + "')")
public ProvisioningResult<RealmTO> update(final RealmTO realmTO) {
Realm realm = realmDAO.findByFullPath(realmTO.getFullPath());
if (realm == null) {
LOG.error("Could not find realm '" + realmTO.getFullPath() + "'");
throw new NotFoundException(realmTO.getFullPath());
}
PropagationByResource propByRes = binder.update(realm, realmTO);
realm = realmDAO.save(realm);
List<PropagationTaskTO> tasks = propagationManager.createTasks(realm, propByRes, null);
PropagationReporter propagationReporter = taskExecutor.execute(tasks, false);
ProvisioningResult<RealmTO> result = new ProvisioningResult<>();
result.setEntity(binder.getRealmTO(realm, true));
result.getPropagationStatuses().addAll(propagationReporter.getStatuses());
return result;
}
use of org.apache.syncope.core.provisioning.api.PropagationByResource in project syncope by apache.
the class RealmLogic method create.
@PreAuthorize("hasRole('" + StandardEntitlement.REALM_CREATE + "')")
public ProvisioningResult<RealmTO> create(final String parentPath, final RealmTO realmTO) {
Realm parent;
if (StringUtils.isBlank(realmTO.getParent())) {
parent = realmDAO.findByFullPath(parentPath);
if (parent == null) {
LOG.error("Could not find parent realm " + parentPath);
throw new NotFoundException(parentPath);
}
realmTO.setParent(parent.getFullPath());
} else {
parent = realmDAO.find(realmTO.getParent());
if (parent == null) {
LOG.error("Could not find parent realm " + realmTO.getParent());
throw new NotFoundException(realmTO.getParent());
}
if (!parent.getFullPath().equals(parentPath)) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidPath);
sce.getElements().add("Mismatching parent realm: " + parentPath + " Vs " + parent.getFullPath());
throw sce;
}
}
String fullPath = StringUtils.appendIfMissing(parent.getFullPath(), "/") + realmTO.getName();
if (realmDAO.findByFullPath(fullPath) != null) {
throw new DuplicateException(fullPath);
}
Realm realm = realmDAO.save(binder.create(parent, realmTO));
PropagationByResource propByRes = new PropagationByResource();
realm.getResourceKeys().forEach(resource -> {
propByRes.add(ResourceOperation.CREATE, resource);
});
List<PropagationTaskTO> tasks = propagationManager.createTasks(realm, propByRes, null);
PropagationReporter propagationReporter = taskExecutor.execute(tasks, false);
ProvisioningResult<RealmTO> result = new ProvisioningResult<>();
result.setEntity(binder.getRealmTO(realm, true));
result.getPropagationStatuses().addAll(propagationReporter.getStatuses());
return result;
}
Aggregations