Search in sources :

Example 21 with PropagationStatus

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

the class GroupLogic method deprovision.

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

Example 22 with PropagationStatus

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

the class AnyObjectLogic method delete.

@Override
public ProvisioningResult<AnyObjectTO> delete(final String key, final boolean nullPriorityAsync) {
    AnyObjectTO anyObject = binder.getAnyObjectTO(key);
    Pair<AnyObjectTO, List<LogicActions>> before = beforeDelete(anyObject);
    Set<String> effectiveRealms = RealmUtils.getEffective(AuthContextUtils.getAuthorizations().get(AnyEntitlement.DELETE.getFor(before.getLeft().getType())), before.getLeft().getRealm());
    securityChecks(effectiveRealms, before.getLeft().getRealm(), before.getLeft().getKey());
    List<PropagationStatus> statuses = provisioningManager.delete(before.getLeft().getKey(), nullPriorityAsync);
    AnyObjectTO anyObjectTO = new AnyObjectTO();
    anyObjectTO.setKey(before.getLeft().getKey());
    return afterDelete(anyObjectTO, statuses, before.getRight());
}
Also used : AnyObjectTO(org.apache.syncope.common.lib.to.AnyObjectTO) PropagationStatus(org.apache.syncope.common.lib.to.PropagationStatus) List(java.util.List)

Example 23 with PropagationStatus

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

the class JAXBTest method provisioningResult.

@Test
public void provisioningResult() throws JAXBException {
    JAXBContext context = JAXBContext.newInstance(ProvisioningResult.class);
    Marshaller marshaller = context.createMarshaller();
    Unmarshaller unmarshaller = context.createUnmarshaller();
    GroupTO group = new GroupTO();
    group.setName(UUID.randomUUID().toString());
    group.setRealm(SyncopeConstants.ROOT_REALM);
    group.getVirAttrs().add(new AttrTO.Builder().schema("rvirtualdata").value("rvirtualvalue").build());
    group.getADynMembershipConds().put("USER", "username==a*");
    ProvisioningResult<GroupTO> original = new ProvisioningResult<>();
    original.setEntity(group);
    PropagationStatus status = new PropagationStatus();
    status.setFailureReason("failed");
    status.setBeforeObj(new ConnObjectTO());
    original.getPropagationStatuses().add(status);
    StringWriter writer = new StringWriter();
    marshaller.marshal(original, writer);
    Object actual = unmarshaller.unmarshal(new StringReader(writer.toString()));
    assertEquals(original, actual);
}
Also used : Marshaller(javax.xml.bind.Marshaller) StringWriter(java.io.StringWriter) ProvisioningResult(org.apache.syncope.common.lib.to.ProvisioningResult) StringReader(java.io.StringReader) PropagationStatus(org.apache.syncope.common.lib.to.PropagationStatus) JAXBContext(javax.xml.bind.JAXBContext) ConnObjectTO(org.apache.syncope.common.lib.to.ConnObjectTO) Unmarshaller(javax.xml.bind.Unmarshaller) GroupTO(org.apache.syncope.common.lib.to.GroupTO) Test(org.junit.jupiter.api.Test)

Example 24 with PropagationStatus

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

the class JSONTest method provisioningResult.

@Test
public void provisioningResult() throws IOException {
    GroupTO group = new GroupTO();
    group.setName(UUID.randomUUID().toString());
    group.setRealm(SyncopeConstants.ROOT_REALM);
    group.getVirAttrs().add(new AttrTO.Builder().schema("rvirtualdata").value("rvirtualvalue").build());
    group.getADynMembershipConds().put("USER", "username==a*");
    ProvisioningResult<GroupTO> original = new ProvisioningResult<>();
    original.setEntity(group);
    PropagationStatus status = new PropagationStatus();
    status.setFailureReason("failed");
    status.setBeforeObj(new ConnObjectTO());
    original.getPropagationStatuses().add(status);
    ObjectMapper mapper = new ObjectMapper();
    StringWriter writer = new StringWriter();
    mapper.writeValue(writer, original);
    ProvisioningResult<GroupTO> actual = mapper.readValue(writer.toString(), new TypeReference<ProvisioningResult<GroupTO>>() {
    });
    assertEquals(original, actual);
}
Also used : StringWriter(java.io.StringWriter) ProvisioningResult(org.apache.syncope.common.lib.to.ProvisioningResult) PropagationStatus(org.apache.syncope.common.lib.to.PropagationStatus) ConnObjectTO(org.apache.syncope.common.lib.to.ConnObjectTO) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) GroupTO(org.apache.syncope.common.lib.to.GroupTO) Test(org.junit.jupiter.api.Test)

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