Search in sources :

Example 11 with GroupPatch

use of org.apache.syncope.common.lib.patch.GroupPatch in project syncope by apache.

the class DefaultGroupPullResultHandler method doUpdate.

@Override
protected AnyPatch doUpdate(final AnyTO before, final AnyPatch anyPatch, final SyncDelta delta, final ProvisioningReport result) {
    GroupPatch groupPatch = GroupPatch.class.cast(anyPatch);
    Pair<GroupPatch, List<PropagationStatus>> updated = groupProvisioningManager.update(groupPatch, Collections.singleton(profile.getTask().getResource().getKey()), true);
    String groupOwner = null;
    for (AttrPatch attrPatch : groupPatch.getPlainAttrs()) {
        if (attrPatch.getOperation() == PatchOperation.ADD_REPLACE && attrPatch.getAttrTO() != null && attrPatch.getAttrTO().getSchema().isEmpty() && !attrPatch.getAttrTO().getValues().isEmpty()) {
            groupOwner = attrPatch.getAttrTO().getValues().get(0);
        }
    }
    if (groupOwner != null) {
        groupOwnerMap.put(updated.getLeft().getKey(), groupOwner);
    }
    return anyPatch;
}
Also used : List(java.util.List) GroupPatch(org.apache.syncope.common.lib.patch.GroupPatch) AttrPatch(org.apache.syncope.common.lib.patch.AttrPatch)

Example 12 with GroupPatch

use of org.apache.syncope.common.lib.patch.GroupPatch in project syncope by apache.

the class GroupServiceImpl method newPatch.

@Override
protected GroupPatch newPatch(final String key) {
    GroupPatch patch = new GroupPatch();
    patch.setKey(key);
    return patch;
}
Also used : GroupPatch(org.apache.syncope.common.lib.patch.GroupPatch)

Example 13 with GroupPatch

use of org.apache.syncope.common.lib.patch.GroupPatch in project syncope by apache.

the class GroupLogic method update.

@PreAuthorize("hasRole('" + StandardEntitlement.GROUP_UPDATE + "')")
@Override
public ProvisioningResult<GroupTO> update(final GroupPatch groupPatch, final boolean nullPriorityAsync) {
    GroupTO groupTO = binder.getGroupTO(groupPatch.getKey());
    Set<String> dynRealmsBefore = new HashSet<>(groupTO.getDynRealms());
    Pair<GroupPatch, List<LogicActions>> before = beforeUpdate(groupPatch, groupTO.getRealm());
    String realm = before.getLeft().getRealm() != null && StringUtils.isNotBlank(before.getLeft().getRealm().getValue()) ? before.getLeft().getRealm().getValue() : groupTO.getRealm();
    Set<String> effectiveRealms = RealmUtils.getEffective(AuthContextUtils.getAuthorizations().get(StandardEntitlement.GROUP_UPDATE), realm);
    boolean authDynRealms = securityChecks(effectiveRealms, realm, before.getLeft().getKey());
    Pair<GroupPatch, List<PropagationStatus>> updated = provisioningManager.update(groupPatch, nullPriorityAsync);
    return afterUpdate(binder.getGroupTO(updated.getLeft().getKey()), updated.getRight(), before.getRight(), authDynRealms, dynRealmsBefore);
}
Also used : List(java.util.List) GroupPatch(org.apache.syncope.common.lib.patch.GroupPatch) GroupTO(org.apache.syncope.common.lib.to.GroupTO) HashSet(java.util.HashSet) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 14 with GroupPatch

use of org.apache.syncope.common.lib.patch.GroupPatch in project syncope by apache.

the class GroupLogic method unassign.

@PreAuthorize("hasRole('" + StandardEntitlement.GROUP_UPDATE + "')")
@Override
public ProvisioningResult<GroupTO> unassign(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());
    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.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 15 with GroupPatch

use of org.apache.syncope.common.lib.patch.GroupPatch in project syncope by apache.

the class GroupLogic method link.

@PreAuthorize("hasRole('" + StandardEntitlement.GROUP_UPDATE + "')")
@Override
public GroupTO link(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.ADD_REPLACE).value(resource).build()).collect(Collectors.toList()));
    patch.getADynMembershipConds().putAll(group.getADynMembershipConds());
    patch.setUDynMembershipCond(group.getUDynMembershipCond());
    return binder.getGroupTO(provisioningManager.link(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)

Aggregations

GroupPatch (org.apache.syncope.common.lib.patch.GroupPatch)33 GroupTO (org.apache.syncope.common.lib.to.GroupTO)23 Test (org.junit.jupiter.api.Test)15 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)7 StringReplacePatchItem (org.apache.syncope.common.lib.patch.StringReplacePatchItem)7 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)6 List (java.util.List)5 AttrPatch (org.apache.syncope.common.lib.patch.AttrPatch)5 ProvisioningResult (org.apache.syncope.common.lib.to.ProvisioningResult)5 GroupService (org.apache.syncope.common.rest.api.service.GroupService)5 ForbiddenException (javax.ws.rs.ForbiddenException)4 Response (javax.ws.rs.core.Response)4 SyncopeClient (org.apache.syncope.client.lib.SyncopeClient)4 StringPatchItem (org.apache.syncope.common.lib.patch.StringPatchItem)4 AnyTypeClassTO (org.apache.syncope.common.lib.to.AnyTypeClassTO)4 AttrTO (org.apache.syncope.common.lib.to.AttrTO)4 AccessControlException (java.security.AccessControlException)3 Collections (java.util.Collections)3 Map (java.util.Map)3 NamingException (javax.naming.NamingException)3