@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); } }
@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()); }
@Override public void onClick(final AjaxRequestTarget target, final GroupTO ignore) { try { restClient.delete(model.getObject().getETagValue(), model.getObject().getKey()); SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED)); target.add(container); } catch (SyncopeClientException e) { LOG.error("While deleting object {}", model.getObject().getKey(), e); SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage()); } ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target); }
@Override public void onClick(final AjaxRequestTarget target, final GroupTO ignore) { try { restClient.provisionMembers(model.getObject().getKey(), ProvisionAction.PROVISION); SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED)); target.add(container); } catch (SyncopeClientException e) { LOG.error("While provisioning members of group {}", model.getObject().getKey(), e); SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage()); } ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target); } }, ActionType.PROVISION_MEMBERS,
@Override public void onClick(final AjaxRequestTarget target, final GroupTO ignore) { try { restClient.provisionMembers(model.getObject().getKey(), ProvisionAction.DEPROVISION); SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED)); target.add(container); } catch (SyncopeClientException e) { LOG.error("While provisioning members of group {}", model.getObject().getKey(), e); SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage()); } ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target); } }, ActionType.DEPROVISION_MEMBERS,
@Override public void onClick(final AjaxRequestTarget target, final GroupTO ignore) { send(GroupDirectoryPanel.this, Broadcast.EXACT, new AjaxWizard.EditItemActionEvent<>(new GroupWrapper( restClient.read(model.getObject().getKey())), target)); } }, ActionType.EDIT,
@Override public void onClick(final AjaxRequestTarget target, final GroupTO ignore) { target.add(utilityModal.setContent(new AnyPropagationTasks( utilityModal, AnyTypeKind.GROUP, model.getObject().getKey(), pageRef))); utilityModal.header(new StringResourceModel("any.propagation.tasks", model)); utilityModal.show(true); } }, ActionType.PROPAGATION_TASKS, StandardEntitlement.TASK_LIST);
@Override public void onClick(final AjaxRequestTarget target, final GroupTO ignore) { target.add(utilityModal.setContent( new NotificationTasks(AnyTypeKind.GROUP, model.getObject().getKey(), pageRef))); utilityModal.header(new StringResourceModel("any.notification.tasks", model)); utilityModal.show(true); } }, ActionType.NOTIFICATION_TASKS, StandardEntitlement.TASK_LIST);
@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 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 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(); } }
@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)); }
@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)); }
@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 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; }
@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); }
@PreAuthorize("hasRole('" + StandardEntitlement.GROUP_UPDATE + "')") @Override public ProvisioningResult<GroupTO> provision( 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()); List<PropagationStatus> statuses = provisioningManager.provision(key, resources, nullPriorityAsync); ProvisioningResult<GroupTO> result = new ProvisioningResult<>(); result.setEntity(binder.getGroupTO(key)); result.getPropagationStatuses().addAll(statuses); return result; }
@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); }
if (inner.getKey() == null) { GroupCR req = new GroupCR(); EntityTOUtils.toAnyCR(inner, req);
key = ((UserWrapper) modelObject).getInnerObject().getKey(); } else if (modelObject instanceof GroupWrapper) { key = ((GroupWrapper) modelObject).getInnerObject().getKey(); } else if (modelObject instanceof AnyWrapper && AnyWrapper.class.cast(modelObject).getInnerObject() instanceof AnyObjectTO) {