@Override protected AnyObjectPatch newPatch(final String key) { AnyObjectPatch patch = new AnyObjectPatch(); patch.setKey(key); return patch; }
@Override public String unlink(final AnyObjectPatch anyObjectPatch) { return awfAdapter.update(anyObjectPatch).getResult().getKey(); }
@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); }
final AnyObjectTO updated, final AnyObjectTO original, final boolean incremental) { AnyObjectPatch result = new AnyObjectPatch(); result.setName(replacePatchItem(updated.getName(), original.getName(), new StringReplacePatchItem())); filter(entry -> (!originalRels.containsKey(entry.getKey()))). forEachOrdered(entry -> { result.getRelationships().add(new RelationshipPatch.Builder(). operation(PatchOperation.ADD_REPLACE). relationshipTO(entry.getValue()).build()); originalRels.keySet().stream().filter(relationship -> !updatedRels.containsKey(relationship)). forEach(key -> { result.getRelationships().add(new RelationshipPatch.Builder(). operation(PatchOperation.DELETE). relationshipTO(originalRels.get(key)).build()); || (!membershipPatch.getPlainAttrs().isEmpty() || !membershipPatch.getVirAttrs().isEmpty())) { result.getMemberships().add(membershipPatch); originalMembs.keySet().stream().filter(membership -> !updatedMembs.containsKey(membership)). forEach(key -> { result.getMemberships().add(new MembershipPatch.Builder(). operation(PatchOperation.DELETE).group(originalMembs.get(key).getGroupKey()).build()); });
patch(anyObjectTO, anyObjectPatch, result); if (anyObjectPatch.getName() != null) { result.setName(anyObjectPatch.getName().getValue()); anyObjectPatch.getRelationships(). forEach(relPatch -> { if (relPatch.getRelationshipTO() == null) { anyObjectPatch.getMemberships(). forEach(membPatch -> { if (membPatch.getGroup() == null) {
@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); }
@Transactional(propagation = Propagation.REQUIRES_NEW) @Override public Pair<AnyObjectPatch, List<PropagationStatus>> update( final AnyObjectPatch anyObjectPatch, final Set<String> excludedResources, final boolean nullPriorityAsync) { WorkflowResult<AnyObjectPatch> updated = awfAdapter.update(anyObjectPatch); List<PropagationTaskInfo> taskInfos = propagationManager.getUpdateTasks( AnyTypeKind.ANY_OBJECT, updated.getResult().getKey(), false, null, updated.getPropByRes(), anyObjectPatch.getVirAttrs(), excludedResources); PropagationReporter propagationReporter = taskExecutor.execute(taskInfos, nullPriorityAsync); return Pair.of(updated.getResult(), propagationReporter.getStatuses()); }
@Override public <P extends AnyPatch> P newAnyPatch(final String key) { P result = null; switch (anyTypeKind) { case USER: result = (P) new UserPatch(); break; case GROUP: result = (P) new GroupPatch(); break; case ANY_OBJECT: result = (P) new AnyObjectPatch(); break; default: } if (result != null) { result.setKey(key); } return result; }
@Override public AnyObjectTO link(final String key, final Collection<String> resources) { // 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.ADD_REPLACE).value(resource).build()). collect(Collectors.toList())); return binder.getAnyObjectTO(provisioningManager.link(patch)); }
if (anyObjectPatch.getName() != null && StringUtils.isNotBlank(anyObjectPatch.getName().getValue())) { propByRes.addAll(ResourceOperation.UPDATE, anyObjectDAO.findAllResourceKeys(anyObject.getKey())); anyObject.setName(anyObjectPatch.getName().getValue()); anyObjectPatch.getRelationships().stream(). filter(patch -> patch.getRelationshipTO() != null).forEachOrdered((patch) -> { RelationshipType relationshipType = relationshipTypeDAO.find(patch.getRelationshipTO().getType()); anyObjectPatch.getMemberships().stream(). filter((membPatch) -> (membPatch.getGroup() != null)).forEachOrdered(membPatch -> { anyObject.getMembership(membPatch.getGroup()).ifPresent(membership -> {
@Override public AnyObjectTO unlink(final String key, final Collection<String> resources) { // 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 binder.getAnyObjectTO(provisioningManager.unlink(patch)); }
@Override public String link(final AnyObjectPatch anyObjectPatch) { return awfAdapter.update(anyObjectPatch).getResult().getKey(); }
@Override public ProvisioningResult<AnyObjectTO> assign( final String key, final Collection<String> resources, final boolean changepwd, final String password, 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.ADD_REPLACE).value(resource).build()). collect(Collectors.toList())); return update(patch, nullPriorityAsync); }
@Override public String unlink(final AnyObjectPatch anyObjectPatch) { PollingConsumer pollingConsumer = getConsumer("direct:unlinkAnyObjectPort"); sendMessage("direct:unlinkAnyObject", anyObjectPatch); Exchange exchange = pollingConsumer.receive(); if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) { throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT); } return exchange.getIn().getBody(AnyObjectPatch.class).getKey(); }
@Override public String link(final AnyObjectPatch anyObjectPatch) { PollingConsumer pollingConsumer = getConsumer("direct:linkAnyObjectPort"); sendMessage("direct:linkAnyObject", anyObjectPatch); Exchange exchange = pollingConsumer.receive(); if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) { throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT); } return exchange.getIn().getBody(AnyObjectPatch.class).getKey(); }
@Override protected AnyObjectTO resolveReference(final Method method, final Object... args) throws UnresolvedReferenceException { String key = null; if (ArrayUtils.isNotEmpty(args)) { for (int i = 0; key == null && i < args.length; i++) { if (args[i] instanceof String) { key = (String) args[i]; } else if (args[i] instanceof AnyObjectTO) { key = ((AnyObjectTO) args[i]).getKey(); } else if (args[i] instanceof AnyObjectPatch) { key = ((AnyObjectPatch) args[i]).getKey(); } } } if (key != null) { try { return binder.getAnyObjectTO(key); } catch (Throwable ignore) { LOG.debug("Unresolved reference", ignore); throw new UnresolvedReferenceException(ignore); } } throw new UnresolvedReferenceException(); } }