Search in sources :

Example 31 with GroupPatch

use of org.apache.syncope.common.lib.patch.GroupPatch 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 32 with GroupPatch

use of org.apache.syncope.common.lib.patch.GroupPatch 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 33 with GroupPatch

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

the class RemediationLogic method remedy.

@PreAuthorize("hasRole('" + StandardEntitlement.REMEDIATION_REMEDY + "')")
public ProvisioningResult<?> remedy(final String key, final AnyPatch anyPatch, final boolean nullPriorityAsync) {
    Remediation remediation = remediationDAO.find(key);
    if (remediation == null) {
        LOG.error("Could not find remediation '" + key + "'");
        throw new NotFoundException(key);
    }
    ProvisioningResult<?> result;
    switch(remediation.getAnyType().getKind()) {
        case USER:
        default:
            result = userLogic.update((UserPatch) anyPatch, nullPriorityAsync);
            break;
        case GROUP:
            result = groupLogic.update((GroupPatch) anyPatch, nullPriorityAsync);
            break;
        case ANY_OBJECT:
            result = anyObjectLogic.update((AnyObjectPatch) anyPatch, nullPriorityAsync);
    }
    remediationDAO.delete(remediation);
    return result;
}
Also used : NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) Remediation(org.apache.syncope.core.persistence.api.entity.Remediation) AnyObjectPatch(org.apache.syncope.common.lib.patch.AnyObjectPatch) UserPatch(org.apache.syncope.common.lib.patch.UserPatch) GroupPatch(org.apache.syncope.common.lib.patch.GroupPatch) 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