use of org.apache.syncope.core.provisioning.api.WorkflowResult in project syncope by apache.
the class FlowableUserWorkflowAdapter method doConfirmPasswordReset.
@Override
protected WorkflowResult<Pair<UserPatch, Boolean>> doConfirmPasswordReset(final User user, final String token, final String password) {
Map<String, Object> variables = new HashMap<>(4);
variables.put(TOKEN, token);
variables.put(PASSWORD, password);
variables.put(USER_TO, dataBinder.getUserTO(user, true));
variables.put(EVENT, "confirmPasswordReset");
Set<String> tasks = doExecuteTask(user, "confirmPasswordReset", variables);
userDAO.save(user);
PropagationByResource propByRes = engine.getRuntimeService().getVariable(user.getWorkflowId(), PROP_BY_RESOURCE, PropagationByResource.class);
UserPatch updatedPatch = engine.getRuntimeService().getVariable(user.getWorkflowId(), USER_PATCH, UserPatch.class);
Boolean propagateEnable = engine.getRuntimeService().getVariable(user.getWorkflowId(), PROPAGATE_ENABLE, Boolean.class);
return new WorkflowResult<>(Pair.of(updatedPatch, propagateEnable), propByRes, tasks);
}
use of org.apache.syncope.core.provisioning.api.WorkflowResult in project syncope by apache.
the class FlowableUserWorkflowAdapter method doCreate.
@Override
protected WorkflowResult<Pair<String, Boolean>> doCreate(final UserTO userTO, final boolean disablePwdPolicyCheck, final Boolean enabled, final boolean storePassword) {
Map<String, Object> variables = new HashMap<>();
variables.put(WF_EXECUTOR, AuthContextUtils.getUsername());
variables.put(USER_TO, userTO);
variables.put(ENABLED, enabled);
variables.put(STORE_PASSWORD, storePassword);
ProcessInstance processInstance = null;
try {
processInstance = engine.getRuntimeService().startProcessInstanceByKey(WF_PROCESS_ID, variables);
} catch (FlowableException e) {
throwException(e, "While starting " + WF_PROCESS_ID + " instance");
}
User user = engine.getRuntimeService().getVariable(processInstance.getProcessInstanceId(), USER, User.class);
Boolean updatedEnabled = engine.getRuntimeService().getVariable(processInstance.getProcessInstanceId(), ENABLED, Boolean.class);
if (updatedEnabled != null) {
user.setSuspended(!updatedEnabled);
}
// this will make UserValidator not to consider password policies at all
if (disablePwdPolicyCheck) {
user.removeClearPassword();
}
updateStatus(user);
user = userDAO.save(user);
Boolean propagateEnable = engine.getRuntimeService().getVariable(processInstance.getProcessInstanceId(), PROPAGATE_ENABLE, Boolean.class);
if (propagateEnable == null) {
propagateEnable = enabled;
}
PropagationByResource propByRes = new PropagationByResource();
propByRes.set(ResourceOperation.CREATE, userDAO.findAllResourceKeys(user.getKey()));
saveForFormSubmit(user, userTO.getPassword(), propByRes);
Set<String> tasks = getPerformedTasks(user);
return new WorkflowResult<>(Pair.of(user.getKey(), propagateEnable), propByRes, tasks);
}
use of org.apache.syncope.core.provisioning.api.WorkflowResult in project syncope by apache.
the class FlowableUserWorkflowAdapter method doSuspend.
@Override
protected WorkflowResult<String> doSuspend(final User user) {
Set<String> performedTasks = doExecuteTask(user, "suspend", null);
updateStatus(user);
User updated = userDAO.save(user);
return new WorkflowResult<>(updated.getKey(), null, performedTasks);
}
use of org.apache.syncope.core.provisioning.api.WorkflowResult in project syncope by apache.
the class FlowableUserWorkflowAdapter method doReactivate.
@Override
protected WorkflowResult<String> doReactivate(final User user) {
Set<String> performedTasks = doExecuteTask(user, "reactivate", null);
updateStatus(user);
User updated = userDAO.save(user);
return new WorkflowResult<>(updated.getKey(), null, performedTasks);
}
use of org.apache.syncope.core.provisioning.api.WorkflowResult in project syncope by apache.
the class AbstractUserWorkflowAdapter method internalSuspend.
@Override
public Pair<WorkflowResult<String>, Boolean> internalSuspend(final String key) {
User user = userDAO.authFind(key);
Pair<WorkflowResult<String>, Boolean> result = null;
Pair<Boolean, Boolean> enforce = userDAO.enforcePolicies(user);
if (enforce.getKey()) {
LOG.debug("User {} {} is over the max failed logins", user.getKey(), user.getUsername());
// reduce failed logins number to avoid multiple request
user.setFailedLogins(user.getFailedLogins() - 1);
// set suspended flag
user.setSuspended(Boolean.TRUE);
result = ImmutablePair.of(doSuspend(user), enforce.getValue());
}
return result;
}
Aggregations