Search in sources :

Example 1 with WorkflowResult

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);
}
Also used : WorkflowResult(org.apache.syncope.core.provisioning.api.WorkflowResult) HashMap(java.util.HashMap) PropagationByResource(org.apache.syncope.core.provisioning.api.PropagationByResource) UserPatch(org.apache.syncope.common.lib.patch.UserPatch)

Example 2 with WorkflowResult

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);
}
Also used : FlowableException(org.flowable.engine.common.api.FlowableException) WorkflowResult(org.apache.syncope.core.provisioning.api.WorkflowResult) User(org.apache.syncope.core.persistence.api.entity.user.User) HashMap(java.util.HashMap) PropagationByResource(org.apache.syncope.core.provisioning.api.PropagationByResource) ProcessInstance(org.flowable.engine.runtime.ProcessInstance)

Example 3 with WorkflowResult

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);
}
Also used : WorkflowResult(org.apache.syncope.core.provisioning.api.WorkflowResult) User(org.apache.syncope.core.persistence.api.entity.user.User)

Example 4 with WorkflowResult

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);
}
Also used : WorkflowResult(org.apache.syncope.core.provisioning.api.WorkflowResult) User(org.apache.syncope.core.persistence.api.entity.user.User)

Example 5 with WorkflowResult

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;
}
Also used : WorkflowResult(org.apache.syncope.core.provisioning.api.WorkflowResult) User(org.apache.syncope.core.persistence.api.entity.user.User)

Aggregations

WorkflowResult (org.apache.syncope.core.provisioning.api.WorkflowResult)32 PropagationByResource (org.apache.syncope.core.provisioning.api.PropagationByResource)18 User (org.apache.syncope.core.persistence.api.entity.user.User)14 UserPatch (org.apache.syncope.common.lib.patch.UserPatch)11 Pair (org.apache.commons.lang3.tuple.Pair)8 PropagationTaskTO (org.apache.syncope.common.lib.to.PropagationTaskTO)8 HashMap (java.util.HashMap)7 PropagationReporter (org.apache.syncope.core.provisioning.api.propagation.PropagationReporter)6 Exchange (org.apache.camel.Exchange)4 PollingConsumer (org.apache.camel.PollingConsumer)4 List (java.util.List)3 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)3 PasswordPatch (org.apache.syncope.common.lib.patch.PasswordPatch)3 AttrTO (org.apache.syncope.common.lib.to.AttrTO)3 AnyObjectPatch (org.apache.syncope.common.lib.patch.AnyObjectPatch)2 AnyObjectTO (org.apache.syncope.common.lib.to.AnyObjectTO)2 GroupTO (org.apache.syncope.common.lib.to.GroupTO)2 UserTO (org.apache.syncope.common.lib.to.UserTO)2 WorkflowException (org.apache.syncope.core.workflow.api.WorkflowException)2 FlowableException (org.flowable.engine.common.api.FlowableException)2