mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

matthew_swift
11.34.2007 52af08b0ea5c494a01c5c32569edd0d6ee528ba1
Fix issues 1996 and 1998.

The previous fix in revision 2434 only catered for managed objects being created, not existing managed objects.

Also modify the ManagedObjectPath class to reject empty path names with an IllegalArgumentException. This will cause errors like this to be trapped earlier and fail predictably.
2 files modified
22 ■■■■■ changed files
opendj-sdk/opends/src/server/org/opends/server/admin/ManagedObjectPath.java 14 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java 8 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/server/org/opends/server/admin/ManagedObjectPath.java
@@ -719,11 +719,18 @@
   *          The relative name of the child managed object.
   * @return Returns a new child managed object path beneath the
   *         provided parent path.
   * @throws IllegalArgumentException
   *           If the provided name is empty or blank.
   */
  public <M extends ConfigurationClient, N extends Configuration>
      ManagedObjectPath<M, N> child(
      InstantiableRelationDefinition<? super M, ? super N> r,
      AbstractManagedObjectDefinition<M, N> d, String name) {
      AbstractManagedObjectDefinition<M, N> d, String name)
      throws IllegalArgumentException {
    if (name.trim().length() == 0) {
      throw new IllegalArgumentException(
          "Empty or blank managed object names are not allowed");
    }
    LinkedList<Element<?, ?>> celements = new LinkedList<Element<?, ?>>(
        elements);
    celements.add(new InstantiableElement<M, N>(r, d, name));
@@ -748,10 +755,13 @@
   *          The relative name of the child managed object.
   * @return Returns a new child managed object path beneath the
   *         provided parent path.
   * @throws IllegalArgumentException
   *           If the provided name is empty or blank.
   */
  public <M extends ConfigurationClient, N extends Configuration>
      ManagedObjectPath<M, N> child(
      InstantiableRelationDefinition<M, N> r, String name) {
      InstantiableRelationDefinition<M, N> r, String name)
      throws IllegalArgumentException {
    return child(r, r.getChildDefinition(), name);
  }
opendj-sdk/opends/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java
@@ -60,6 +60,7 @@
import org.opends.server.admin.client.AuthorizationException;
import org.opends.server.admin.client.CommunicationException;
import org.opends.server.admin.client.ConcurrentModificationException;
import org.opends.server.admin.client.IllegalManagedObjectNameException;
import org.opends.server.admin.client.ManagedObject;
import org.opends.server.admin.client.ManagedObjectDecodingException;
import org.opends.server.admin.client.ManagementContext;
@@ -140,6 +141,13 @@
              gotException = true;
              return;
            }
          } else if (childName.trim().length() == 0) {
            IllegalManagedObjectNameException e =
              new IllegalManagedObjectNameException(childName);
            ae = ArgumentExceptionFactory
                .adaptIllegalManagedObjectNameException(e, d);
            gotException = true;
            return;
          }
          ManagedObject<?> child = managedObject.getChild(r, childName);