/** * Indicates the given group matches to the given pattern. */ private boolean matchPattern(final T group, final String criteria) { return StringUtils.containsIgnoreCase(group.getName(), criteria); }
@Override public String getDn() { return getDescription(); }
/** * Create the given container.<br> * The delegation system is involved for this operation and requires * administration privilege on the parent tree or group/company. * * @param container * The container to create. * @return The identifier of created {@link org.ligoj.app.iam.ContainerOrg}. */ @POST public String create(final V container) { return createInternal(container).getId(); }
/** * All arguments constructor. * * @param dn * Corresponds to the "Distinguished Name". Will be saved in "description". * @param name * "name" corresponds to the display name. Will be saved in "name", and in "id" in is normalized form. */ public ContainerOrg(final String dn, final String name) { setId(Normalizer.normalize(name)); setName(name); setDescription(dn); }
/** * Check the container can be deleted by the current user. * * @param container * The container to delete. */ protected void checkForDeletion(final ContainerOrg container) { // Check the container can be deleted by the current user. Used DN will // be FQN to match the delegates if (!delegateRepository.canCreate(securityHelper.getLogin(), Normalizer.normalize(container.getDn()), this.type.getDelegateType())) { // Not managed container, report this attempt and act as if this // company did not exist log.warn("Attempt to delete a {} '{}' out of scope", type, container.getName()); throw new ValidationJsonException(getTypeName(), BusinessException.KEY_UNKNOW_ID, "0", getTypeName(), "1", container.getId()); } // Check this container is not locked if (container.isLocked()) { throw new ValidationJsonException("company", "locked", "0", container.getName()); } }
@Override protected void checkForDeletion(final ContainerOrg container) { super.checkForDeletion(container); // Company deletion is only possible where there is no user inside this company, or inside any sub-company final Map<String, UserOrg> users = getUser().findAll(); if (getRepository().findAll().values().stream() .filter(c -> DnUtils.equalsOrParentOf(container.getDn(), c.getDn())) .anyMatch(c -> users.values().stream().map(UserOrg::getCompany).anyMatch(c.getId()::equals))) { // Locked container is inside the container to delete throw new ValidationJsonException(getTypeName(), "not-empty-company", "0", getTypeName(), "1", container.getId()); } }
/** * Return the closest {@link ContainerScope} name associated to the given * container. Order of scopes is important since the first matching item * from this list is returned. * * @param scopes * The available scopes. * @param container * The containers to check. * @return The closest {@link ContainerScope} or <code>null</code> if not * found. */ public ContainerScope toScope(final List<ContainerScope> scopes, final ContainerOrg container) { return scopes.stream().filter(s -> DnUtils.equalsOrParentOf(s.getDn(), container.getDn())).findFirst().orElse(null); }
securedUserOrg.setLocked(scope.isLocked()); securedUserOrg.setLocked(securedUserOrg.isLocked() || rawContainer.isLocked()); return securedUserOrg;
@Override public T create(final String dn, final String cn) { final T container = newContainer(dn, cn); // First create the LDAP entry log.info("{} {} will be created as {}", type.name(), container.getName(), dn); final DirContextAdapter context = new DirContextAdapter(dn); context.setAttributeValues("objectClass", new String[] { className }); mapToContext(container, context); template.bind(context); // Return the new container return container; }