From 3f4deb91789189521d577457bd6da27de8fd75b1 Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Wed, 07 Oct 2026 08:31:10 +0000
Subject: [PATCH] [#1153] Parse the whole DN string, and build or split DN strings through DN instead of string operations (#1171)
---
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractNewEntryPanel.java | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractNewEntryPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractNewEntryPanel.java
index cd1cce4..b96ee63 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractNewEntryPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractNewEntryPanel.java
@@ -13,6 +13,7 @@
*
* Copyright 2008-2010 Sun Microsystems, Inc.
* Portions Copyright 2014-2016 ForgeRock AS.
+ * Portions Copyright 2026 3A Systems, LLC.
*/
package org.opends.guitools.controlpanel.ui;
@@ -25,7 +26,9 @@
import javax.swing.SwingUtilities;
import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.i18n.LocalizedIllegalArgumentException;
import org.forgerock.opendj.ldap.DN;
+import org.forgerock.opendj.ldap.RDN;
import org.opends.guitools.controlpanel.browser.BrowserController;
import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
import org.opends.guitools.controlpanel.task.NewEntryTask;
@@ -48,6 +51,47 @@
/** The parent node that was selected when the user clicked on the new entry action. */
protected BasicNode parentNode;
+
+ /**
+ * Returns the DN of a new entry, with the naming value escaped: a value that contains ',', '+' or ';',
+ * or starts with '#', is part of the RDN, not a DN separator.
+ *
+ * @param rdnAttribute
+ * the naming attribute.
+ * @param rdnValue
+ * the naming value typed by the user.
+ * @param parentDN
+ * the DN of the parent entry.
+ * @return the string representation of the DN of the new entry.
+ */
+ static String getNewEntryDN(String rdnAttribute, String rdnValue, DN parentDN)
+ {
+ return parentDN.child(rdnAttribute, rdnValue).toString();
+ }
+
+ /**
+ * Returns the DN of a new entry, with the naming value escaped, under a parent DN typed by the user.
+ *
+ * @param rdnAttribute
+ * the naming attribute.
+ * @param rdnValue
+ * the naming value typed by the user.
+ * @param parentDN
+ * the DN of the parent entry, as typed by the user.
+ * @return the string representation of the DN of the new entry. If the parent DN is not a valid DN yet,
+ * the escaped RDN followed by the parent DN as typed.
+ */
+ static String getNewEntryDN(String rdnAttribute, String rdnValue, String parentDN)
+ {
+ try
+ {
+ return getNewEntryDN(rdnAttribute, rdnValue, DN.valueOf(parentDN));
+ }
+ catch (LocalizedIllegalArgumentException e)
+ {
+ return new RDN(rdnAttribute, rdnValue) + "," + parentDN;
+ }
+ }
/** The browser controller. */
protected BrowserController controller;
--
Gitblit v1.10.0