public GroupTO toGroupTO(final SCIMGroup group) { if (!GROUP_SCHEMAS.equals(group.getSchemas())) { throw new BadRequestException(ErrorType.invalidValue); } GroupTO groupTO = new GroupTO(); groupTO.setRealm(SyncopeConstants.ROOT_REALM); groupTO.setKey(group.getId()); groupTO.setName(group.getDisplayName()); return groupTO; }
/** * 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 {@link GroupUR} containing differences */ public static GroupUR diff(final GroupTO updated, final GroupTO original, final boolean incremental) { GroupUR result = new GroupUR(); 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; }
@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)); }
public GroupTO fillDynamicConditions() { this.anyTO.setUDynMembershipCond(this.getUDynMembershipCond()); this.anyTO.getADynMembershipConds().clear(); this.anyTO.getADynMembershipConds().putAll(this.getADynMembershipConds()); return this.anyTO; } }
@Override public String getObject() { if (groupWrapper.getInnerObject().getGroupOwner() == null) { return StringUtils.EMPTY; } else { GroupTO groupTO = groupRestClient.read(groupWrapper.getInnerObject().getGroupOwner()); if (groupTO == null) { return StringUtils.EMPTY; } else { return String.format("[%s] %s", groupTO.getKey(), groupTO.getName()); } } }
@Override public void onClick(final AjaxRequestTarget target, final TypeExtensionTO ignore) { groupTO.getTypeExtension(typeExtension.getAnyType()).ifPresent(typeExt -> { groupTO.getTypeExtensions().remove(typeExt); target.add(container); }); } }, ActionLink.ActionType.DELETE, StringUtils.EMPTY, true);
@Transactional(readOnly = true) @Override public GroupTO getGroupTO(final Group group, final boolean details) { GroupTO groupTO = new GroupTO(); groupTO.setCreator(group.getCreator()); groupTO.setCreationDate(group.getCreationDate()); groupTO.setLastModifier(group.getLastModifier()); groupTO.setLastChangeDate(group.getLastChangeDate()); groupTO.setStatus(group.getStatus()); groupTO.setKey(group.getKey()); groupTO.setName(group.getName()); groupTO.setUserOwner(group.getUserOwner().getKey()); groupTO.setGroupOwner(group.getGroupOwner().getKey()); groupTO.getDynRealms().addAll(groupDAO.findDynRealms(group.getKey())); groupTO.setStaticUserMembershipCount(groupDAO.countUMembers(group)); groupTO.setStaticAnyObjectMembershipCount(groupDAO.countAMembers(group)); groupTO.setDynamicUserMembershipCount(groupDAO.countUDynMembers(group)); groupTO.setDynamicAnyObjectMembershipCount(groupDAO.countADynMembers(group)); groupTO.setUDynMembershipCond(group.getUDynMembership().getFIQLCond()); groupTO.getADynMembershipConds().put(memb.getAnyType().getKey(), memb.getFIQLCond()); });
GroupTO updatedGroup = (GroupTO) updated; if (StringUtils.isBlank(updatedGroup.getName())) { updatedGroup.setName(originalGroup.getName()); updatedGroup.setUserOwner(originalGroup.getUserOwner()); updatedGroup.setGroupOwner(originalGroup.getGroupOwner()); updatedGroup.setUDynMembershipCond(originalGroup.getUDynMembershipCond()); updatedGroup.getADynMembershipConds().putAll(originalGroup.getADynMembershipConds()); updatedGroup.getTypeExtensions().addAll(originalGroup.getTypeExtensions());
((UserTO) anyTO).getRoles().addAll(((UserTO) template).getRoles()); } else if (template instanceof GroupTO) { if (StringUtils.isNotBlank(((GroupTO) template).getName())) { String evaluated = JexlUtils.evaluate(((GroupTO) template).getName(), jexlContext); if (StringUtils.isNotBlank(evaluated)) { ((GroupTO) anyTO).setName(evaluated); if (((GroupTO) template).getUserOwner() != null) { final User userOwner = userDAO.find(((GroupTO) template).getUserOwner()); if (userOwner != null) { ((GroupTO) anyTO).setUserOwner(userOwner.getKey()); if (((GroupTO) template).getGroupOwner() != null) { final Group groupOwner = groupDAO.find(((GroupTO) template).getGroupOwner()); if (groupOwner != null) { ((GroupTO) anyTO).setGroupOwner(groupOwner.getKey());
if (inner.getKey() == null) { GroupCR req = new GroupCR(); EntityTOUtils.toAnyCR(inner, req); !inner.getADynMembershipConds().equals(originaObj.getADynMembershipConds()) || (StringUtils.isNotBlank(originaObj.getUDynMembershipCond()) && StringUtils.isBlank(inner. getUDynMembershipCond())) || (StringUtils.isBlank(originaObj.getUDynMembershipCond()) && StringUtils.isNotBlank(inner. getUDynMembershipCond())) || StringUtils.isAllBlank(originaObj.getUDynMembershipCond(), inner.getUDynMembershipCond()) || !inner.getUDynMembershipCond().equals(originaObj.getUDynMembershipCond()) || !CollectionUtils.diff(inner.getTypeExtensions(), originaObj.getTypeExtensions()).isEmpty(); result.setEntity(inner); } else { result = groupRestClient.update(getOriginalItem().getInnerObject().getETagValue(), groupUR);
GroupCR groupCR = (GroupCR) anyCR; groupTO.setName(groupCR.getName()); groupTO.setUserOwner(groupCR.getUserOwner()); groupTO.setGroupOwner(groupCR.getGroupOwner()); groupTO.setUDynMembershipCond(groupCR.getUDynMembershipCond()); groupTO.getADynMembershipConds().putAll(groupCR.getADynMembershipConds()); groupTO.getTypeExtensions().addAll(groupCR.getTypeExtensions()); } else if (anyTO instanceof AnyObjectTO && anyCR instanceof AnyObjectCR) { AnyObjectTO anyObjectTO = (AnyObjectTO) anyTO;
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; }
@PreAuthorize("hasRole('" + StandardEntitlement.GROUP_DELETE + "')") @Override public ProvisioningResult<GroupTO> delete(final String key, final boolean nullPriorityAsync) { GroupTO group = binder.getGroupTO(key); Pair<GroupTO, List<LogicActions>> before = beforeDelete(group); Set<String> effectiveRealms = RealmUtils.getEffective( AuthContextUtils.getAuthorizations().get(StandardEntitlement.GROUP_DELETE), before.getLeft().getRealm()); securityChecks(effectiveRealms, before.getLeft().getRealm(), before.getLeft().getKey()); List<Group> ownedGroups = groupDAO.findOwnedByGroup(before.getLeft().getKey()); if (!ownedGroups.isEmpty()) { SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.GroupOwnership); sce.getElements().addAll(ownedGroups.stream(). map(g -> g.getKey() + " " + g.getName()).collect(Collectors.toList())); throw sce; } List<PropagationStatus> statuses = provisioningManager.delete(before.getLeft().getKey(), nullPriorityAsync); GroupTO groupTO = new GroupTO(); groupTO.setKey(before.getLeft().getKey()); return afterDelete(groupTO, statuses, before.getRight()); }
groupTO.getKey(), new Meta( Resource.Group, groupTO.getCreationDate(), groupTO.getLastChangeDate() == null ? groupTO.getCreationDate() : groupTO.getLastChangeDate(), groupTO.getETagValue(), location), output(attributes, excludedAttributes, "displayName", groupTO.getName())); membCond.setGroup(groupTO.getKey()); SearchCond searchCond = SearchCond.getLeafCond(membCond);
@Override protected String getName(final AnyTO anyTO) { return GroupTO.class.cast(anyTO).getName(); }
@Override public Response update(final GroupTO groupTO) { groupTO.setKey(getActualKey(getAnyDAO(), groupTO.getKey())); GroupTO before = logic.read(groupTO.getKey()); checkETag(before.getETagValue()); ProvisioningResult<GroupTO> updated = logic.update(AnyOperations.diff(groupTO, before, false), isNullPriorityAsync()); return modificationResponse(updated); }
@Override protected Details<GroupTO> addOptionalDetailsPanel(final AnyWrapper<GroupTO> modelObject) { return new GroupDetails( GroupWrapper.class.cast(modelObject), mode == AjaxWizard.Mode.TEMPLATE, modelObject.getInnerObject().getKey() != null, pageRef); } }
@Override public void onSubmit(final AjaxRequestTarget target) { GroupUR req = new GroupUR(); req.setKey(groupTO.getKey()); req.getTypeExtensions().addAll(groupTO.getTypeExtensions()); try { new GroupRestClient().update(groupTO.getETagValue(), req); this.baseModal.show(false); this.baseModal.close(target); SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED)); } catch (Exception e) { LOG.error("Group update failure", e); SyncopeConsoleSession.get().error(getString(Constants.ERROR) + ": " + e.getMessage()); } ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target); }
public GroupTemplateWizardBuilder( final TemplatableTO templatable, final List<String> anyTypeClasses, final GroupFormLayoutInfo formLayoutInfo, final PageReference pageRef) { super(null, anyTypeClasses, formLayoutInfo, pageRef); this.templatable = templatable; if (templatable.getTemplates().containsKey(AnyTypeKind.GROUP.name())) { setItem(new GroupWrapper(GroupTO.class.cast(templatable.getTemplates().get(AnyTypeKind.GROUP.name())))); } else { GroupTO groupTO = new GroupTO(); if (templatable instanceof RealmTO) { groupTO.setRealm(String.format("'%s'", RealmTO.class.cast(templatable).getFullPath())); } setItem(new GroupWrapper(groupTO)); } }
@PreAuthorize("hasRole('" + StandardEntitlement.GROUP_UPDATE + "')") @Override public ProvisioningResult<GroupTO> deprovision( 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()); List<PropagationStatus> statuses = provisioningManager.deprovision(key, resources, nullPriorityAsync); ProvisioningResult<GroupTO> result = new ProvisioningResult<>(); result.setEntity(binder.getGroupTO(key)); result.getPropagationStatuses().addAll(statuses); return result; }