@Override protected GroupPatch newPatch(final String key) { GroupPatch patch = new GroupPatch(); patch.setKey(key); return patch; }
public static GroupTO patch(final GroupTO groupTO, final GroupPatch groupPatch) { GroupTO result = SerializationUtils.clone(groupTO); patch(groupTO, groupPatch, result); if (groupPatch.getName() != null) { result.setName(groupPatch.getName().getValue()); } if (groupPatch.getUserOwner() != null) { result.setGroupOwner(groupPatch.getUserOwner().getValue()); } if (groupPatch.getGroupOwner() != null) { result.setGroupOwner(groupPatch.getGroupOwner().getValue()); } result.setUDynMembershipCond(groupPatch.getUDynMembershipCond()); result.getADynMembershipConds().clear(); result.getADynMembershipConds().putAll(groupPatch.getADynMembershipConds()); return result; }
@Override public String link(final GroupPatch groupPatch) { return gwfAdapter.update(groupPatch).getResult().getKey(); } }
@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)); }
/** * Calculate modifications needed by first in order to be equal to second. * * @param updated updated GroupTO * @param original original GroupTO * @param incremental perform incremental diff (without removing existing info) * @return GroupPatch containing differences */ public static GroupPatch diff(final GroupTO updated, final GroupTO original, final boolean incremental) { GroupPatch result = new GroupPatch(); diff(updated, original, result, incremental); // 1. name result.setName(replacePatchItem(updated.getName(), original.getName(), new StringReplacePatchItem())); // 2. ownership result.setUserOwner( replacePatchItem(updated.getUserOwner(), original.getUserOwner(), new StringReplacePatchItem())); result.setGroupOwner( replacePatchItem(updated.getGroupOwner(), original.getGroupOwner(), new StringReplacePatchItem())); // 3. dynamic membership result.setUDynMembershipCond(updated.getUDynMembershipCond()); result.getADynMembershipConds().putAll(updated.getADynMembershipConds()); // 4. type extensions result.getTypeExtensions().addAll(updated.getTypeExtensions()); return result; }
if (groupPatch.getName() != null && StringUtils.isNotBlank(groupPatch.getName().getValue())) { propByRes.addAll(ResourceOperation.UPDATE, groupDAO.findAllResourceKeys(group.getKey())); group.setName(groupPatch.getName().getValue()); if (groupPatch.getUserOwner() != null) { group.setUserOwner(groupPatch.getUserOwner().getValue() == null ? null : userDAO.find(groupPatch.getUserOwner().getValue())); if (groupPatch.getGroupOwner() != null) { group.setGroupOwner(groupPatch.getGroupOwner().getValue() == null ? null : groupDAO.find(groupPatch.getGroupOwner().getValue())); if (groupPatch.getUDynMembershipCond() == null) { if (group.getUDynMembership() != null) { group.getUDynMembership().setGroup(null); setDynMembership(group, anyTypeDAO.findUser(), groupPatch.getUDynMembershipCond()); for (Map.Entry<String, String> entry : groupPatch.getADynMembershipConds().entrySet()) { AnyType anyType = anyTypeDAO.find(entry.getKey()); if (anyType == null) { for (TypeExtensionTO typeExtTO : groupPatch.getTypeExtensions()) { AnyType anyType = anyTypeDAO.find(typeExtTO.getAnyType()); if (anyType == null) {
@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); }
@Transactional(propagation = Propagation.REQUIRES_NEW) @Override public Pair<GroupPatch, List<PropagationStatus>> update( final GroupPatch groupPatch, final Set<String> excludedResources, final boolean nullPriorityAsync) { WorkflowResult<GroupPatch> updated = gwfAdapter.update(groupPatch); List<PropagationTaskInfo> tasks = propagationManager.getUpdateTasks( AnyTypeKind.GROUP, updated.getResult().getKey(), false, null, updated.getPropByRes(), groupPatch.getVirAttrs(), excludedResources); PropagationReporter propagationReporter = taskExecutor.execute(tasks, 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 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; }
@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); }
@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)); }
@Override public String unlink(final GroupPatch groupPatch) { return gwfAdapter.update(groupPatch).getResult().getKey(); }
@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); }
@Override public String unlink(final GroupPatch groupPatch) { PollingConsumer pollingConsumer = getConsumer("direct:unlinkGroupPort"); sendMessage("direct:unlinkGroup", groupPatch); Exchange exchange = pollingConsumer.receive(); if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) { throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT); } return exchange.getIn().getBody(GroupPatch.class).getKey(); }
@Override public String link(final GroupPatch groupPatch) { PollingConsumer pollingConsumer = getConsumer("direct:linkGroupPort"); sendMessage("direct:linkGroup", groupPatch); Exchange exchange = pollingConsumer.receive(); if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) { throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT); } return exchange.getIn().getBody(GroupPatch.class).getKey(); }
@Override protected GroupTO 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 GroupTO) { key = ((GroupTO) args[i]).getKey(); } else if (args[i] instanceof GroupPatch) { key = ((GroupPatch) args[i]).getKey(); } } } if (key != null) { try { return binder.getGroupTO(key); } catch (Throwable ignore) { LOG.debug("Unresolved reference", ignore); throw new UnresolvedReferenceException(ignore); } } throw new UnresolvedReferenceException(); } }