Search in sources :

Example 6 with PropagationStatus

use of org.apache.syncope.common.lib.to.PropagationStatus in project syncope by apache.

the class AnyObjectLogic method provision.

@Override
public ProvisioningResult<AnyObjectTO> provision(final String key, final Collection<String> resources, final boolean changePwd, final String password, final boolean nullPriorityAsync) {
    // security checks
    AnyObjectTO anyObjectTO = binder.getAnyObjectTO(key);
    Set<String> effectiveRealms = RealmUtils.getEffective(AuthContextUtils.getAuthorizations().get(AnyEntitlement.UPDATE.getFor(anyObjectTO.getType())), anyObjectTO.getRealm());
    securityChecks(effectiveRealms, anyObjectTO.getRealm(), anyObjectTO.getKey());
    List<PropagationStatus> statuses = provisioningManager.provision(key, resources, nullPriorityAsync);
    ProvisioningResult<AnyObjectTO> result = new ProvisioningResult<>();
    result.setEntity(binder.getAnyObjectTO(key));
    result.getPropagationStatuses().addAll(statuses);
    return result;
}
Also used : AnyObjectTO(org.apache.syncope.common.lib.to.AnyObjectTO) ProvisioningResult(org.apache.syncope.common.lib.to.ProvisioningResult) PropagationStatus(org.apache.syncope.common.lib.to.PropagationStatus)

Example 7 with PropagationStatus

use of org.apache.syncope.common.lib.to.PropagationStatus in project syncope by apache.

the class DefaultPropagationReporter method onSuccessOrNonPriorityResourceFailures.

@Override
public void onSuccessOrNonPriorityResourceFailures(final PropagationTaskTO taskTO, final PropagationTaskExecStatus executionStatus, final String failureReason, final ConnectorObject beforeObj, final ConnectorObject afterObj) {
    PropagationStatus status = new PropagationStatus();
    status.setResource(taskTO.getResource());
    status.setStatus(executionStatus);
    status.setFailureReason(failureReason);
    if (beforeObj != null) {
        status.setBeforeObj(ConnObjectUtils.getConnObjectTO(beforeObj));
    }
    if (afterObj != null) {
        status.setAfterObj(ConnObjectUtils.getConnObjectTO(afterObj));
    }
    add(status);
}
Also used : PropagationStatus(org.apache.syncope.common.lib.to.PropagationStatus)

Example 8 with PropagationStatus

use of org.apache.syncope.common.lib.to.PropagationStatus in project syncope by apache.

the class DefaultPropagationReporter method onPriorityResourceFailure.

@Override
public void onPriorityResourceFailure(final String failingResource, final Collection<PropagationTaskTO> tasks) {
    LOG.debug("Propagation error: {} priority resource failed to propagate", failingResource);
    Optional<PropagationTaskTO> propagationTask = tasks.stream().filter(task -> task.getResource().equals(failingResource)).findFirst();
    if (propagationTask.isPresent()) {
        PropagationStatus status = new PropagationStatus();
        status.setResource(propagationTask.get().getResource());
        status.setStatus(PropagationTaskExecStatus.FAILURE);
        status.setFailureReason("Propagation error: " + failingResource + " priority resource failed to propagate.");
        add(status);
    } else {
        LOG.error("Could not find {} for {}", PropagationTask.class.getName(), failingResource);
    }
}
Also used : Logger(org.slf4j.Logger) PropagationTaskExecStatus(org.apache.syncope.common.lib.types.PropagationTaskExecStatus) Collection(java.util.Collection) LoggerFactory(org.slf4j.LoggerFactory) PropagationReporter(org.apache.syncope.core.provisioning.api.propagation.PropagationReporter) PropagationTask(org.apache.syncope.core.persistence.api.entity.task.PropagationTask) ArrayList(java.util.ArrayList) ConnectorObject(org.identityconnectors.framework.common.objects.ConnectorObject) List(java.util.List) PropagationTaskTO(org.apache.syncope.common.lib.to.PropagationTaskTO) ConnObjectUtils(org.apache.syncope.core.provisioning.java.utils.ConnObjectUtils) Optional(java.util.Optional) PropagationStatus(org.apache.syncope.common.lib.to.PropagationStatus) Collections(java.util.Collections) PropagationTaskTO(org.apache.syncope.common.lib.to.PropagationTaskTO) PropagationTask(org.apache.syncope.core.persistence.api.entity.task.PropagationTask) PropagationStatus(org.apache.syncope.common.lib.to.PropagationStatus)

Example 9 with PropagationStatus

use of org.apache.syncope.common.lib.to.PropagationStatus in project syncope by apache.

the class UserRestClient method suspend.

public BulkActionResult suspend(final String etag, final String userKey, final List<StatusBean> statuses) {
    StatusPatch statusPatch = StatusUtils.buildStatusPatch(statuses, false);
    statusPatch.setKey(userKey);
    statusPatch.setType(StatusPatchType.SUSPEND);
    BulkActionResult result;
    synchronized (this) {
        result = new BulkActionResult();
        Map<String, BulkActionResult.Status> res = result.getResults();
        UserService service = getService(etag, UserService.class);
        @SuppressWarnings("unchecked") ProvisioningResult<UserTO> provisions = (ProvisioningResult<UserTO>) service.status(statusPatch).readEntity(ProvisioningResult.class);
        if (statusPatch.isOnSyncope()) {
            res.put(StringUtils.capitalize(Constants.SYNCOPE), "suspended".equalsIgnoreCase(provisions.getEntity().getStatus()) ? BulkActionResult.Status.SUCCESS : BulkActionResult.Status.FAILURE);
        }
        for (PropagationStatus status : provisions.getPropagationStatuses()) {
            res.put(status.getResource(), BulkActionResult.Status.valueOf(status.getStatus().name()));
        }
        resetClient(UserService.class);
    }
    return result;
}
Also used : PropagationStatus(org.apache.syncope.common.lib.to.PropagationStatus) UserService(org.apache.syncope.common.rest.api.service.UserService) UserTO(org.apache.syncope.common.lib.to.UserTO) ProvisioningResult(org.apache.syncope.common.lib.to.ProvisioningResult) StatusPatch(org.apache.syncope.common.lib.patch.StatusPatch) PropagationStatus(org.apache.syncope.common.lib.to.PropagationStatus) BulkActionResult(org.apache.syncope.common.lib.to.BulkActionResult)

Example 10 with PropagationStatus

use of org.apache.syncope.common.lib.to.PropagationStatus in project syncope by apache.

the class UserLogic method deprovision.

@PreAuthorize("hasRole('" + StandardEntitlement.USER_UPDATE + "')")
@Override
public ProvisioningResult<UserTO> deprovision(final String key, final Collection<String> resources, final boolean nullPriorityAsync) {
    // security checks
    UserTO user = binder.getUserTO(key);
    Set<String> effectiveRealms = RealmUtils.getEffective(AuthContextUtils.getAuthorizations().get(StandardEntitlement.USER_UPDATE), user.getRealm());
    securityChecks(effectiveRealms, user.getRealm(), user.getKey());
    List<PropagationStatus> statuses = provisioningManager.deprovision(key, resources, nullPriorityAsync);
    ProvisioningResult<UserTO> result = new ProvisioningResult<>();
    result.setEntity(binder.returnUserTO(binder.getUserTO(key)));
    result.getPropagationStatuses().addAll(statuses);
    return result;
}
Also used : UserTO(org.apache.syncope.common.lib.to.UserTO) ProvisioningResult(org.apache.syncope.common.lib.to.ProvisioningResult) PropagationStatus(org.apache.syncope.common.lib.to.PropagationStatus) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

PropagationStatus (org.apache.syncope.common.lib.to.PropagationStatus)24 UserTO (org.apache.syncope.common.lib.to.UserTO)12 ProvisioningResult (org.apache.syncope.common.lib.to.ProvisioningResult)11 Test (org.junit.jupiter.api.Test)9 GroupTO (org.apache.syncope.common.lib.to.GroupTO)7 UserPatch (org.apache.syncope.common.lib.patch.UserPatch)5 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)5 List (java.util.List)4 ConnObjectTO (org.apache.syncope.common.lib.to.ConnObjectTO)4 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)3 AnyObjectTO (org.apache.syncope.common.lib.to.AnyObjectTO)3 Group (org.apache.syncope.core.persistence.api.entity.group.Group)3 StringWriter (java.io.StringWriter)2 ArrayList (java.util.ArrayList)2 PasswordPatch (org.apache.syncope.common.lib.patch.PasswordPatch)2 StatusPatch (org.apache.syncope.common.lib.patch.StatusPatch)2 AttrTO (org.apache.syncope.common.lib.to.AttrTO)2 BulkActionResult (org.apache.syncope.common.lib.to.BulkActionResult)2 UserService (org.apache.syncope.common.rest.api.service.UserService)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1