use of org.apache.syncope.common.lib.patch.AnyObjectPatch in project syncope by apache.
the class AnyObjectLogic method update.
@Override
public ProvisioningResult<AnyObjectTO> update(final AnyObjectPatch anyObjectPatch, final boolean nullPriorityAsync) {
AnyObjectTO anyObjectTO = binder.getAnyObjectTO(anyObjectPatch.getKey());
Set<String> dynRealmsBefore = new HashSet<>(anyObjectTO.getDynRealms());
Pair<AnyObjectPatch, List<LogicActions>> before = beforeUpdate(anyObjectPatch, anyObjectTO.getRealm());
String realm = before.getLeft().getRealm() != null && StringUtils.isNotBlank(before.getLeft().getRealm().getValue()) ? before.getLeft().getRealm().getValue() : anyObjectTO.getRealm();
Set<String> effectiveRealms = RealmUtils.getEffective(AuthContextUtils.getAuthorizations().get(AnyEntitlement.UPDATE.getFor(anyObjectTO.getType())), realm);
boolean authDynRealms = securityChecks(effectiveRealms, realm, before.getLeft().getKey());
Pair<AnyObjectPatch, List<PropagationStatus>> updated = provisioningManager.update(anyObjectPatch, nullPriorityAsync);
return afterUpdate(binder.getAnyObjectTO(updated.getLeft().getKey()), updated.getRight(), before.getRight(), authDynRealms, dynRealmsBefore);
}
use of org.apache.syncope.common.lib.patch.AnyObjectPatch in project syncope by apache.
the class AnyObjectLogic method unassign.
@Override
public ProvisioningResult<AnyObjectTO> unassign(final String key, final Collection<String> resources, 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());
AnyObjectPatch patch = new AnyObjectPatch();
patch.setKey(key);
patch.getResources().addAll(resources.stream().map(resource -> new StringPatchItem.Builder().operation(PatchOperation.DELETE).value(resource).build()).collect(Collectors.toList()));
return update(patch, nullPriorityAsync);
}
use of org.apache.syncope.common.lib.patch.AnyObjectPatch in project syncope by apache.
the class AnyOperationsTest method mindiff.
@Test
public void mindiff() {
AnyObjectTO oldOne = new AnyObjectTO();
oldOne.setName("name");
oldOne.getPlainAttrs().add(new AttrTO.Builder().schema("plain").value("oldValue").build());
oldOne.getPlainAttrs().add(new AttrTO.Builder().schema("encrypted").value("oldValue").build());
AnyObjectTO newOne = new AnyObjectTO();
newOne.setName("name");
newOne.getPlainAttrs().add(new AttrTO.Builder().schema("plain").value("newValue").build());
newOne.getPlainAttrs().add(new AttrTO.Builder().schema("encrypted").value("oldValue").build());
AnyObjectPatch diff = AnyOperations.diff(newOne, oldOne, true);
assertEquals(1, diff.getPlainAttrs().size());
AttrPatch patch = diff.getPlainAttrs().iterator().next();
assertEquals(PatchOperation.ADD_REPLACE, patch.getOperation());
assertEquals("plain", patch.getAttrTO().getSchema());
}
Aggregations