Search in sources :

Example 86 with GroupTO

use of org.apache.syncope.common.lib.to.GroupTO 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 87 with GroupTO

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

the class GroupLogic method assign.

@PreAuthorize("hasRole('" + StandardEntitlement.GROUP_UPDATE + "')")
@Override
public ProvisioningResult<GroupTO> assign(final String key, final Collection<String> resources, final boolean changepwd, final String password, 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());
    GroupPatch patch = new GroupPatch();
    patch.setKey(key);
    patch.getResources().addAll(resources.stream().map(resource -> new StringPatchItem.Builder().operation(PatchOperation.ADD_REPLACE).value(resource).build()).collect(Collectors.toList()));
    patch.getADynMembershipConds().putAll(group.getADynMembershipConds());
    patch.setUDynMembershipCond(group.getUDynMembershipCond());
    return update(patch, nullPriorityAsync);
}
Also used : GroupPatch(org.apache.syncope.common.lib.patch.GroupPatch) GroupTO(org.apache.syncope.common.lib.to.GroupTO) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 88 with GroupTO

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

the class GroupLogic method unlink.

@PreAuthorize("hasRole('" + StandardEntitlement.GROUP_UPDATE + "')")
@Override
public GroupTO unlink(final String key, final Collection<String> resources) {
    // 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());
    GroupPatch patch = new GroupPatch();
    patch.setKey(key);
    patch.getResources().addAll(resources.stream().map(resource -> new StringPatchItem.Builder().operation(PatchOperation.DELETE).value(resource).build()).collect(Collectors.toList()));
    patch.setUDynMembershipCond(group.getUDynMembershipCond());
    patch.getADynMembershipConds().putAll(group.getADynMembershipConds());
    return binder.getGroupTO(provisioningManager.unlink(patch));
}
Also used : GroupPatch(org.apache.syncope.common.lib.patch.GroupPatch) GroupTO(org.apache.syncope.common.lib.to.GroupTO) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 89 with GroupTO

use of org.apache.syncope.common.lib.to.GroupTO 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 90 with GroupTO

use of org.apache.syncope.common.lib.to.GroupTO 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

GroupTO (org.apache.syncope.common.lib.to.GroupTO)90 Test (org.junit.jupiter.api.Test)47 UserTO (org.apache.syncope.common.lib.to.UserTO)34 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)27 GroupPatch (org.apache.syncope.common.lib.patch.GroupPatch)23 MembershipTO (org.apache.syncope.common.lib.to.MembershipTO)17 AnyObjectTO (org.apache.syncope.common.lib.to.AnyObjectTO)16 List (java.util.List)15 AttrTO (org.apache.syncope.common.lib.to.AttrTO)15 ConnObjectTO (org.apache.syncope.common.lib.to.ConnObjectTO)14 ProvisioningResult (org.apache.syncope.common.lib.to.ProvisioningResult)14 Response (javax.ws.rs.core.Response)13 NamingException (javax.naming.NamingException)12 PropagationStatus (org.apache.syncope.common.lib.to.PropagationStatus)12 Map (java.util.Map)11 ForbiddenException (javax.ws.rs.ForbiddenException)11 AccessControlException (java.security.AccessControlException)10 BulkActionResult (org.apache.syncope.common.lib.to.BulkActionResult)10 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)10 Collections (java.util.Collections)9