.gitignore | 4 src/com/netscape/admin/dirserv/DSUtil.java | 171 ++++++++ src/com/netscape/admin/dirserv/browser/BasicNode.java | 5 src/com/netscape/admin/dirserv/node/DataRootResourceObject.java | 5 src/com/netscape/admin/dirserv/node/MappingNodeObject.java | 37 - src/com/netscape/admin/dirserv/node/MappingTreeRootResourceObject.java | 5 src/com/netscape/admin/dirserv/node/SuffixResourceObject.java | 133 ++---- src/com/netscape/admin/dirserv/panel/BackendPanel.java | 18 src/com/netscape/admin/dirserv/panel/MappingNodeSettingPanel.java | 3 src/com/netscape/admin/dirserv/panel/MappingUtils.java | 207 +++++----- src/com/netscape/admin/dirserv/panel/NewChainingInstancePanel.java | 8 src/com/netscape/admin/dirserv/panel/NewChainingPanel.java | 10 src/com/netscape/admin/dirserv/panel/NewLDBMPanel.java | 9 src/com/netscape/admin/dirserv/panel/NewMappingNodePanel.java | 9 src/com/netscape/admin/dirserv/panel/NewSuffixPanel.java | 3 src/com/netscape/admin/dirserv/panel/confirmDeleteSuffixPanel.java | 3 src/com/netscape/admin/dirserv/propedit/DSEntryPanel.java | 25 - src/com/netscape/admin/dirserv/propedit/RenameDialog.java | 36 - 18 files changed, 380 insertions(+), 311 deletions(-)
New commits: commit 1ce76be162d0ccd812511815e6176dfcd626ecea Author: Rich Megginson rmeggins@redhat.com Date: Thu Apr 29 16:10:43 2010 -0600
Bug 586571 - DS Console shows escaped DNs
https://bugzilla.redhat.com/show_bug.cgi?id=586571 Resolves: bug 586571 Bug Description: DS Console shows escaped DNs Reviewed by: nhosoi (Thanks!) Branch: HEAD Fix Description: Changed the console to be aware of LDAPv3 escapes. The console can now correctly read and display DN values that contain escapes, and can correctly escape DNs sent to the server. The console will still display the "raw" DN with the escapes in certain cases - for example, the status area at the bottom of the window shows the raw DN for the entry selected in the directory browser; the Advanced... editor will show the raw DN in DN valued fields. Platforms tested: RHEL5 x86_64 Flag Day: no Doc impact: no
diff --git a/.gitignore b/.gitignore index b25c15b..c9cd011 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ *~ +.classpath +.project +*.patch +bin diff --git a/src/com/netscape/admin/dirserv/DSUtil.java b/src/com/netscape/admin/dirserv/DSUtil.java index cf71b2c..6f0b3d1 100644 --- a/src/com/netscape/admin/dirserv/DSUtil.java +++ b/src/com/netscape/admin/dirserv/DSUtil.java @@ -26,6 +26,7 @@ import java.util.*; import java.util.regex.*; import java.io.*; import java.net.*; +import java.text.CharacterIterator; import java.text.SimpleDateFormat; import java.text.Collator; import java.text.ParsePosition; @@ -2021,6 +2022,172 @@ public class DSUtil { }
/** + * Returns the RDN value after unescaping any escaped characters. + * Can be a simple escape - a \ followed by any character - + * this will just remove the \ and leave the character in the + * result unescaped. + * Can be a hex escape - a \ followed by two hex digits - the + * \ will be removed and the two hex digits converted to a single + * char in the string. + * Note that this is different than netscape.ldap.LDAPDN#unEscapeRDN(java.lang.String + * in that this function will handle hex escapes. + * If the rdn value is bogus or otherwise cannot be parsed correctly, the original + * rdn value will be returned, with escapes if it had them. + * <P> + * + * @param rdnval the RDN value to unescape + * @return the unescaped RDN value or the original RDN value if there were errors + * @see netscape.ldap.LDAPDN#escapeRDN(java.lang.String) + */ + public static String unEscapeRDNVal(String rdnval) { + StringBuffer copy = new StringBuffer(); + CharacterIterator it = new StringCharacterIterator(rdnval); + for (char ch = it.first(); ch != CharacterIterator.DONE; ch = it.next()) { + if (ch == '\') { + ch = it.next(); + if (ch == CharacterIterator.DONE) { + // bogus - escape at end of string + return rdnval; + } + int val1 = Character.digit(ch, 16); + if ((val1 >= 0) && (val1 < 16)) { + val1 = val1 * 16; + ch = it.next(); + if (ch == CharacterIterator.DONE) { + // bogus - escape followed by only 1 hex digit + return rdnval; + } + int val2 = Character.digit(ch, 16); + if ((val2 < 0) || (val2 > 15)) { + return rdnval; + } + // must be a two digit hex code if we got here + ch = (char)(val1 + val2); + } + } + copy.append(ch); + } + return copy.toString(); + } + + /** + * Returns the RDN after unescaping any escaped characters. + * Can be a simple escape - a \ followed by any character - + * this will just remove the \ and leave the character in the + * result unescaped. + * Can be a hex escape - a \ followed by two hex digits - the + * \ will be removed and the two hex digits converted to a single + * char in the string. + * Note that this is different than netscape.ldap.LDAPDN#unEscapeRDN(java.lang.String + * in that this function will handle hex escapes. + * If the rdn is bogus or otherwise cannot be parsed correctly, the original + * rdn value will be returned, with escapes if it had them. + * <P> + * + * @param rdn the RDN to unescape + * @return the unescaped RDN or the original RDN if there were errors + * @see netscape.ldap.LDAPDN#escapeRDN(java.lang.String) + */ + public static String unEscapeRDN(String rdn) { + RDN name = new RDN(rdn); + String[] vals = name.getValues(); + if ( (vals == null) || (vals.length < 1) ) { + return rdn; + } + String[] types = name.getTypes(); + + StringBuffer rdnbuf = new StringBuffer(); + for (int ii = 0; ii < vals.length; ++ii) { + if (rdnbuf.length() > 0) { + rdnbuf.append("+"); + } + rdnbuf.append(types[ii] + "=" + unEscapeRDNVal(vals[ii])); + } + + return rdnbuf.toString(); + } + + /** + * Returns the DN after unescaping any escaped characters. + * Can be a simple escape - a \ followed by any character - + * this will just remove the \ and leave the character in the + * result unescaped. + * Can be a hex escape - a \ followed by two hex digits - the + * \ will be removed and the two hex digits converted to a single + * char in the string. + * If the dn is bogus or otherwise cannot be parsed correctly, the original + * dn value will be returned, with escapes if it had them. + * <P> + * + * @param dn the DN to unescape + * @return the unescaped DN or the original DN if there were errors + */ + public static String unEscapeDN(String dn) { + if ((dn == null) || (dn.equals(""))) { + return dn; + } + String[] rdns = LDAPDN.explodeDN(dn, false); + if ((rdns == null) || (rdns.length < 1)) { + return dn; + } + StringBuffer retdn = new StringBuffer(); + for (int ii = 0; ii < rdns.length; ++ii) { + if (retdn.length() > 0) { + retdn.append(","); + } + retdn.append(unEscapeRDN(rdns[ii])); + } + + return retdn.toString(); + } + + public static boolean[] DN_ESCAPE_CHARS = null; + static { + // get max val of DN.ESCAPED_CHAR + char maxval = 0; + for (char ii = 0; ii < DN.ESCAPED_CHAR.length; ++ii) { + if (maxval < DN.ESCAPED_CHAR[ii]) { + maxval = DN.ESCAPED_CHAR[ii]; + } + } + // add the '=' + if (maxval < '=') { + maxval = '='; + } + // create an array large enough to hold spaces + // for all values up to maxval + DN_ESCAPE_CHARS = new boolean[maxval+1]; + // set default value to false + for (char ii = 0; ii < (int)maxval; ++ii) { + DN_ESCAPE_CHARS[ii] = false; + } + // set escape char vals to true + for (char ii = 0; ii < DN.ESCAPED_CHAR.length; ++ii) { + DN_ESCAPE_CHARS[DN.ESCAPED_CHAR[ii]] = true; + } + // add the equals sign + DN_ESCAPE_CHARS['='] = true; + } + /** + * Escape the given DN string value for use as an RDN value. Uses + * the \XX hex escapes. + * @param dnval value to escape for use as an RDN value + * @return the escaped string + */ + public static String escapeDNVal(String dnval) { + StringBuffer copy = new StringBuffer(); + CharacterIterator it = new StringCharacterIterator(dnval); + for (char ch = it.first(); ch != CharacterIterator.DONE; ch = it.next()) { + if ((ch > 0) && (ch < DN_ESCAPE_CHARS.length) && DN_ESCAPE_CHARS[ch]) { + copy.append('\'); + copy.append(Integer.toHexString((int)ch).toUpperCase()); + } else { + copy.append(ch); + } + } + return copy.toString(); + } + /** * This function was stolen from dsalib_dn.c. It checks the string * for LDAPv2 style quoting e.g. o="foo, bar", c=US, a format which * is now deprecated. @@ -2050,7 +2217,7 @@ public class DSUtil {
return ret; } - + static public void checkForLDAPv2Quoting(String dn, JFrame frame, String label) { if (DNUsesLDAPv2Quoting(dn)) { @@ -2878,7 +3045,7 @@ public class DSUtil { }
return ret; - } + }
// This the subdir where the DS online help is stored public static final String HELP_DIRECTORY = "slapd"; diff --git a/src/com/netscape/admin/dirserv/browser/BasicNode.java b/src/com/netscape/admin/dirserv/browser/BasicNode.java index a9d13de..c4910e0 100644 --- a/src/com/netscape/admin/dirserv/browser/BasicNode.java +++ b/src/com/netscape/admin/dirserv/browser/BasicNode.java @@ -23,6 +23,9 @@ import java.util.Vector; import java.awt.Font; import javax.swing.Icon; import javax.swing.tree.DefaultMutableTreeNode; + +import com.netscape.admin.dirserv.DSUtil; + import netscape.ldap.util.DN; import netscape.ldap.LDAPUrl;
@@ -205,7 +208,7 @@ class BasicNode extends DefaultMutableTreeNode { else { DN dnObj = new DN(dn); if (dnObj.countRDNs() >= 1) { - result = dnObj.explodeDN(true)[0]; + result = DSUtil.unEscapeRDNVal(dnObj.explodeDN(true)[0]); } else { result = ""; diff --git a/src/com/netscape/admin/dirserv/node/DataRootResourceObject.java b/src/com/netscape/admin/dirserv/node/DataRootResourceObject.java index 9bfe29b..6c8006e 100644 --- a/src/com/netscape/admin/dirserv/node/DataRootResourceObject.java +++ b/src/com/netscape/admin/dirserv/node/DataRootResourceObject.java @@ -213,9 +213,8 @@ public class DataRootResourceObject extends DSResourceObject false ); while( res.hasMoreElements() ) { LDAPEntry entry = (LDAPEntry)res.nextElement(); - String name = entry.getDN(); - Debug.println( "Mapping node: " + name ); - name = MappingUtils.unQuote( LDAPDN.explodeDN(entry.getDN(),true)[0]); + String name = MappingUtils.getMappingNodeName(entry); + Debug.println( "Mapping node: dn=" + entry.getDN() + " name=" + name ); _isLeaf = false; /* Add a node for each plugin */ SuffixResourceObject MappNode = diff --git a/src/com/netscape/admin/dirserv/node/MappingNodeObject.java b/src/com/netscape/admin/dirserv/node/MappingNodeObject.java index 3b0e703..87a6767 100644 --- a/src/com/netscape/admin/dirserv/node/MappingNodeObject.java +++ b/src/com/netscape/admin/dirserv/node/MappingNodeObject.java @@ -114,23 +114,18 @@ public class MappingNodeObject extends DSResourceObject _model.fireChangeFeedbackCursor(null, FeedbackIndicator.FEEDBACK_WAIT ); LDAPConnection ldc = _model.getServerInfo().getLDAPConnection(); String psRDN = LDAPDN.explodeDN( _entry.getDN(), true)[0]; + String filt = MappingUtils.getParentSearchFilter(psRDN); LDAPSearchResults res = ldc.search( "cn=mapping tree, cn=config", ldc.SCOPE_ONE, - // "((objectclass=nsMappingTree)" + - "(nsslapd-parent-suffix=" + - MappingUtils.Quote( psRDN ) + - // ")"+ - ")", + filt, null, false ); - Debug.println( " *** ((objectclass=nsMappingTree)(nsslapd-parent-suffix=" + - MappingUtils.Quote(psRDN) +")): res.getCount()=" + res.getCount()); + Debug.println( " *** " + filt + ": res.getCount()=" + res.getCount()); while( res.hasMoreElements() ) { LDAPEntry bentry = (LDAPEntry)res.nextElement(); - String name = bentry.getDN(); - Debug.println( "*** Mapping node: " + name ); - name = MappingUtils.unQuote(LDAPDN.explodeDN( bentry.getDN(), true)[0]); + String name = MappingUtils.getMappingNodeName(bentry); + Debug.println( "*** Mapping node: dn=" + bentry.getDN() + " name=" + name ); _isLeaf = false ; /* Add a node for each Instance */ MappingNodeObject MapNode = @@ -221,7 +216,7 @@ public class MappingNodeObject extends DSResourceObject public boolean isLeaf() { // return _isLeaf; - return (isLeafMappingNode()); + return MappingUtils.isLeafMappingNode(_model.getServerInfo().getLDAPConnection(), _entry); }
/** @@ -302,26 +297,6 @@ public class MappingNodeObject extends DSResourceObject SECTION); } } - - - private boolean isLeafMappingNode( ) { - DN pDN = new DN( _entry.getDN() ); - String psRDN = LDAPDN.explodeDN( _entry.getDN(), true )[0]; - String filter = "nsslapd-parent-suffix=" + MappingUtils.Quote( psRDN ); - LDAPConnection ldc = _model.getServerInfo().getLDAPConnection(); - try { - LDAPSearchResults res = ldc.search( CONFIG_MAPPING, ldc.SCOPE_ONE, - filter, null, false); - if (res == null || !res.hasMoreElements()) { - return( true ); - } else { - return( false ); - } - } catch (LDAPException e) { - Debug.println( "MappingNodeObject.isLeafMappingNode() :" + e ); - return( false ); - } - } private LDAPEntry _entry = null; private boolean _isLeaf = false; diff --git a/src/com/netscape/admin/dirserv/node/MappingTreeRootResourceObject.java b/src/com/netscape/admin/dirserv/node/MappingTreeRootResourceObject.java index d6ac5d2..2943b26 100644 --- a/src/com/netscape/admin/dirserv/node/MappingTreeRootResourceObject.java +++ b/src/com/netscape/admin/dirserv/node/MappingTreeRootResourceObject.java @@ -103,9 +103,8 @@ public class MappingTreeRootResourceObject extends DSResourceObject false ); while( res.hasMoreElements() ) { LDAPEntry entry = (LDAPEntry)res.nextElement(); - String name = entry.getDN(); - Debug.println( "Mapping node: " + name ); - name = MappingUtils.unQuote( LDAPDN.explodeDN(entry.getDN(),true)[0]); + String name = MappingUtils.getMappingNodeName(entry); + Debug.println( "Mapping node: dn=" + entry.getDN() + " name=" + name ); _isLeaf = false; /* Add a node for each plugin */ MappingNodeObject MappNode = diff --git a/src/com/netscape/admin/dirserv/node/SuffixResourceObject.java b/src/com/netscape/admin/dirserv/node/SuffixResourceObject.java index 65848ce..251da84 100644 --- a/src/com/netscape/admin/dirserv/node/SuffixResourceObject.java +++ b/src/com/netscape/admin/dirserv/node/SuffixResourceObject.java @@ -131,22 +131,19 @@ public class SuffixResourceObject extends DSResourceObject
private void addSuffix(){ - String psRDN = LDAPDN.explodeDN( _entry.getDN(), true)[0]; + String suffix = MappingUtils.getMappingNodeSuffix(_entry); + String filter = MappingUtils.getParentSearchFilter(suffix); try { _model.fireChangeFeedbackCursor(null, FeedbackIndicator.FEEDBACK_WAIT ); LDAPConnection ldc = _model.getServerInfo().getLDAPConnection(); LDAPSearchResults res = ldc.search( "cn=mapping tree, cn=config", - ldc.SCOPE_ONE, - "(nsslapd-parent-suffix=" + - MappingUtils.Quote( psRDN ) + - ")", + ldc.SCOPE_ONE, filter, null, false ); while( res.hasMoreElements() ) { LDAPEntry bentry = (LDAPEntry)res.nextElement(); - String name = bentry.getDN(); - name = MappingUtils.unQuote(LDAPDN.explodeDN( bentry.getDN(), true)[0]); + String name = MappingUtils.getMappingNodeName(bentry); _isLeaf = false ; /* Add a node for each Instance */ SuffixResourceObject MapNode = @@ -155,13 +152,13 @@ public class SuffixResourceObject extends DSResourceObject } } catch ( LDAPException e ) { if( e.getLDAPResultCode() != e.NO_SUCH_OBJECT ) { - String[] args_m = { psRDN , e.toString() }; + String[] args_m = { suffix , e.toString() }; DSUtil.showErrorDialog( _model.getFrame(), "error-find-subsuffix", args_m, SECTION); Debug.println( "SuffixResourceObject.addSuffix: " + - "psRDN: " + psRDN + + "suffix: " + suffix + "Error: " + e.toString()); } } finally { @@ -180,12 +177,9 @@ public class SuffixResourceObject extends DSResourceObject _model.fireChangeFeedbackCursor(null, FeedbackIndicator.FEEDBACK_WAIT ); LDAPConnection ldc = _model.getServerInfo().getLDAPConnection(); - String psRDN = LDAPDN.explodeDN( _entry.getDN(), true)[0]; - psRDN = MappingUtils.escapeBackslash(psRDN); - String dbFilter = - "(&(objectclass=nsBackendInstance)" + - "(nsslapd-suffix=" + - MappingUtils.unQuote( psRDN )+ "))"; + String suffix = MappingUtils.getMappingNodeSuffix(_entry); + String filter = MappingUtils.getSuffixSearchFilter(suffix, "nsslapd-suffix"); + String dbFilter = "(&(objectclass=nsBackendInstance)" + filter + ")";
try { LDAPSearchResults res = @@ -229,7 +223,7 @@ public class SuffixResourceObject extends DSResourceObject } } catch ( LDAPException e ) { if( e.getLDAPResultCode() != e.NO_SUCH_OBJECT ) { - String[] args_m = { psRDN, e.toString() }; + String[] args_m = { suffix, e.toString() }; DSUtil.showErrorDialog( _model.getFrame(), "error-find-db", args_m, @@ -531,12 +525,10 @@ public class SuffixResourceObject extends DSResourceObject }
private int delete_suffix(LDAPEntry node) { - String dn2delete = node.getDN(); - String rdn2delete = (new DN(dn2delete)).explodeDN(true)[0]; - String[] args = { rdn2delete }; + String suffix = MappingUtils.getMappingNodeSuffix(node);
confirmDeleteSuffixPanel child = - new confirmDeleteSuffixPanel( _model, dn2delete ); + new confirmDeleteSuffixPanel( _model, suffix ); SimpleDialog dlg = new SimpleDialog( _model.getFrame(), @@ -558,19 +550,19 @@ public class SuffixResourceObject extends DSResourceObject StringBuffer sbDBLoc = new StringBuffer(); switch( resDiag ) { case confirmDeleteSuffixPanel.ALL: { - del_all_suffix( ldc, dn2delete, sbDBLoc); + del_all_suffix( ldc, suffix, node.getDN(), sbDBLoc); break; } case confirmDeleteSuffixPanel.ONE: LDAPAttribute dady_attr = node.getAttribute( "nsslapd-parent-suffix"); if( dady_attr == null) { - del_1_suffix( ldc, dn2delete, null, true, sbDBLoc); + del_1_suffix( ldc, suffix, node.getDN(), null, true, sbDBLoc); } else { Enumeration en = dady_attr.getStringValues(); if ( en.hasMoreElements() ) { - del_1_suffix( ldc, dn2delete, - (String)en.nextElement(), true, - sbDBLoc ); + del_1_suffix( ldc, suffix, + node.getDN(), (String)en.nextElement(), + true, sbDBLoc ); } } break; @@ -588,11 +580,10 @@ public class SuffixResourceObject extends DSResourceObject
private int del_all_suffix( LDAPConnection ldc, String dn2delete , - StringBuffer sbDBLoc) { - String rdn2delete = (new DN(dn2delete)).explodeDN(true)[0]; - String filter = - "(&(objectclass=nsMappingTree)(nsslapd-parent-suffix=" + - rdn2delete +"))"; + String mndn, StringBuffer sbDBLoc) { + String filter = "(&(objectclass=nsMappingTree)" + + MappingUtils.getParentSearchFilter(dn2delete) + + ")"; try { LDAPSearchResults res = ldc.search( DSUtil.MAPPING_TREE_BASE_DN, @@ -604,12 +595,12 @@ public class SuffixResourceObject extends DSResourceObject while(( res != null ) && res.hasMoreElements()) { Vector v = new Vector(); LDAPEntry entry = (LDAPEntry)res.nextElement(); - String dn2modify = entry.getDN(); - del_all_suffix( ldc, dn2modify, sbDBLoc ); + String dn2modify = MappingUtils.getMappingNodeSuffix(entry); + del_all_suffix( ldc, dn2modify, entry.getDN(), sbDBLoc ); } } catch( LDAPException e) { if( e.getLDAPResultCode() != e.NO_SUCH_OBJECT ) { - String[] args_m = { rdn2delete, e.toString() }; + String[] args_m = { dn2delete, e.toString() }; DSUtil.showErrorDialog( _model.getFrame(), "error-del-find-subsuffix", args_m, @@ -618,17 +609,16 @@ public class SuffixResourceObject extends DSResourceObject } }
- return( del_1_suffix( ldc, dn2delete, null, false, sbDBLoc)); + return( del_1_suffix( ldc, dn2delete, mndn, null, false, sbDBLoc)); }
private int del_1_suffix(LDAPConnection ldc, String dn2delete, + String mndn, String dndady, - boolean changeChildren, - StringBuffer sbDBLoc) { - String arg = (new DN(dn2delete)).explodeDN(true)[0]; - String[] dlg_arg = { arg }; + boolean changeChildren, StringBuffer sbDBLoc) { + String[] dlg_arg = { dn2delete }; GenericProgressDialog dlg = new GenericProgressDialog(_model.getFrame(), true, @@ -645,10 +635,10 @@ public class SuffixResourceObject extends DSResourceObject erase_one_suffix task = new erase_one_suffix( ldc, dn2delete, + mndn, dndady, changeChildren, - sbDBLoc, - dlg ); + sbDBLoc, dlg ); Thread th = new Thread(task); th.start(); dlg.packAndShow(); @@ -661,36 +651,17 @@ public class SuffixResourceObject extends DSResourceObject return( 1 ); }
- - private boolean isLeafMappingNode( ) { - DN pDN = new DN( _entry.getDN() ); - String psRDN = LDAPDN.explodeDN( _entry.getDN(), true )[0]; - String filter = "nsslapd-parent-suffix=" + MappingUtils.Quote( psRDN ); - LDAPConnection ldc = _model.getServerInfo().getLDAPConnection(); - try { - LDAPSearchResults res = ldc.search( CONFIG_MAPPING, ldc.SCOPE_ONE, - filter, null, false); - if (res == null || !res.hasMoreElements()) { - return( true ); - } else { - return( false ); - } - } catch (LDAPException e) { - Debug.println( "SuffixResourceObject.isLeafMappingNode() : error :" + e ); - return( false ); - } - } - class erase_one_suffix implements Runnable {
public erase_one_suffix(LDAPConnection ldc, String dn2delete, + String mndn, String dndady, boolean changeChildren, - StringBuffer sbDBLoc, - GenericProgressDialog dlg ) { + StringBuffer sbDBLoc, GenericProgressDialog dlg ) { _ldc = ldc; _dn2delete = dn2delete; + _mndn = mndn; _dndady = dndady; _changeChildren = changeChildren; _dlg = dlg; @@ -701,11 +672,10 @@ public class SuffixResourceObject extends DSResourceObject public void run() { boolean everythingUnderControl = true; if ( _changeChildren ) { - String rdn2delete = (new DN(_dn2delete)).explodeDN(true)[0]; - rdn2delete = MappingUtils.escapeBackslash(rdn2delete); - String filter = - "(&(objectclass=nsMappingTree)(nsslapd-parent-suffix=" + - rdn2delete +"))"; + String filter = "(&(objectclass=nsMappingTree)" + + MappingUtils.getParentSearchFilter(_dn2delete) + + ")"; + String suffix2delete = _dn2delete; try { LDAPSearchResults res = _ldc.search( DSUtil.MAPPING_TREE_BASE_DN, @@ -722,9 +692,9 @@ public class SuffixResourceObject extends DSResourceObject if( _dndady == null ) { attrs.add( LDAPModification.DELETE, new LDAPAttribute( "nsslapd-parent-suffix", - rdn2delete )); + suffix2delete )); } else { - rdn2delete = _dndady; + suffix2delete = _dndady; attrs.add( LDAPModification.REPLACE, new LDAPAttribute( "nsslapd-parent-suffix", _dndady)); @@ -740,14 +710,14 @@ public class SuffixResourceObject extends DSResourceObject SECTION); Debug.println("SuffixResourceObject.del_1_suffix(): " + - "rdn2 delete or mod = " + rdn2delete ); + "rdn2 delete or mod = " + suffix2delete ); everythingUnderControl = false; } } } catch(LDAPException e) { if( e.getLDAPResultCode() != e.NO_SUCH_OBJECT ) { - String[] args_m = { rdn2delete, e.toString() }; + String[] args_m = { suffix2delete, e.toString() }; DSUtil.showErrorDialog( _model.getFrame(), "error-del-find-subsuffix", args_m, @@ -763,8 +733,8 @@ public class SuffixResourceObject extends DSResourceObject this._dlg.closeCallBack(); }
- if (!DSUtil.deleteTree ( _dn2delete, _ldc, false, _dlg )) { - String[] args_m = { _dn2delete } ; + if (!DSUtil.deleteTree ( _mndn, _ldc, false, _dlg )) { + String[] args_m = { _mndn } ; DSUtil.showErrorDialog( _model.getFrame(), "error-remove", args_m, @@ -776,13 +746,11 @@ public class SuffixResourceObject extends DSResourceObject // check suffix this._dlg.stepCompleted(1);
- /* now get ride of all its database */ + /* now get rid of all its database */ - String rdn2delete = (new DN(_dn2delete)).explodeDN(true)[0]; - rdn2delete = MappingUtils.escapeBackslash(rdn2delete); - String filter = - "(&(objectclass=nsBackendInstance)(nsslapd-suffix=" + - MappingUtils.unQuote(rdn2delete) +"))"; + String filter = "(&(objectclass=nsBackendInstance) " + + MappingUtils.getSuffixSearchFilter(_dn2delete, "nsslapd-suffix") + + ")"; try { LDAPSearchResults res = _ldc.search( DSUtil.PLUGIN_CONFIG_BASE_DN, @@ -804,7 +772,7 @@ public class SuffixResourceObject extends DSResourceObject } } catch (LDAPException lde) { if( lde.getLDAPResultCode() != lde.NO_SUCH_OBJECT ) { - String[] args_m = { rdn2delete, lde.toString() }; + String[] args_m = { _dn2delete, lde.toString() }; DSUtil.showErrorDialog( _model.getFrame(), "error-del-find-subsuffix", args_m, @@ -826,8 +794,9 @@ public class SuffixResourceObject extends DSResourceObject }
LDAPConnection _ldc; - String _dn2delete; - String _dndady; + String _dn2delete; // the suffix DN i.e. dc=example,dc=com + String _mndn; // the DN of the mapping tree node e.g. cn=dc\3Dexample\2Cdc\3Dcom,cn=mapping tree,cn=config + String _dndady; // the parent suffix, if any boolean _changeChildren; GenericProgressDialog _dlg; StringBuffer _sbDBLoc; diff --git a/src/com/netscape/admin/dirserv/panel/BackendPanel.java b/src/com/netscape/admin/dirserv/panel/BackendPanel.java index cf02e5b..2d390f0 100644 --- a/src/com/netscape/admin/dirserv/panel/BackendPanel.java +++ b/src/com/netscape/admin/dirserv/panel/BackendPanel.java @@ -174,24 +174,6 @@ public class BackendPanel extends JPanel { return null; }
- public boolean setSelectedSuffix(String suffix) { - if (_htSuffixAndBackends != null) { - suffix = MappingUtils.unQuote(suffix); - DN suffixDN = new DN(suffix); - for (int i=0 ; i<_htSuffixAndBackends.size(); i++) { - String key = String.valueOf(i); - String currentSuffix = (String)(((Hashtable)(_htSuffixAndBackends.get(key))).get(SUFFIX_ATTR)); - currentSuffix = MappingUtils.unQuote(currentSuffix); - DN currentSuffixDN = new DN(currentSuffix); - if (currentSuffixDN.equals(suffixDN)) { - _theChoice.setSelectedIndex(i); - return true; - } - } - } - return false; - } - public boolean setSelectedBackend(String backend) { if (_htSuffixAndBackends != null) { for (int i=0 ; i<_htSuffixAndBackends.size(); i++) { diff --git a/src/com/netscape/admin/dirserv/panel/MappingNodeSettingPanel.java b/src/com/netscape/admin/dirserv/panel/MappingNodeSettingPanel.java index dfe19c2..87bb2a1 100644 --- a/src/com/netscape/admin/dirserv/panel/MappingNodeSettingPanel.java +++ b/src/com/netscape/admin/dirserv/panel/MappingNodeSettingPanel.java @@ -93,7 +93,8 @@ public class MappingNodeSettingPanel extends BlankPanel _myPanel.add( _NodeLabel, gbc );
_NodeText = new JLabel(); - _NodeText.setText( LDAPDN.explodeDN(_entry.getDN(),true)[0]); + String suffixval = MappingUtils.getMappingNodeName(_entry); + _NodeText.setText(suffixval); gbc.gridx = 1; gbc.anchor = gbc.WEST; _myPanel.add( _NodeText, gbc ); diff --git a/src/com/netscape/admin/dirserv/panel/MappingUtils.java b/src/com/netscape/admin/dirserv/panel/MappingUtils.java index 8910798..a9a2c03 100644 --- a/src/com/netscape/admin/dirserv/panel/MappingUtils.java +++ b/src/com/netscape/admin/dirserv/panel/MappingUtils.java @@ -38,6 +38,53 @@ public class MappingUtils {
private MappingUtils() {}
+ /** + * The mapping node name is the suffix DN. In the mapping tree entry, + * the values of the cn attribute hold the suffix DN. There are usually two + * values - the quoted or escaped value, and the unquoted value. We look + * for the first unquoted value and use that for the node name. If for some + * reason we could not find the cn attribute or a suitable value, assume the + * suffix is the value of the leftmost RDN in the entry DN. + * @param mnent - the mapping tree node entry + * @return the suffix to use as the name of the mapping tree node + */ + static public String getMappingNodeName(LDAPEntry mnent) { + String cnvals[] = DSUtil.getAttrValues(mnent, "cn"); + String suffixval = null; + for (int ii = 0; (cnvals != null) && (ii < cnvals.length); ++ii) { + if (!DSUtil.DNUsesLDAPv2Quoting(cnvals[ii])) { + suffixval = DSUtil.unEscapeDN(cnvals[ii]); + break; + } + } + if (suffixval == null) { + suffixval = DSUtil.unEscapeRDNVal(LDAPDN.explodeDN(mnent.getDN(),true)[0]); + } + return suffixval; + } + + /** + * Given a mapping tree node entry, return the suffix that this represents. + * @param mnent - the mapping tree node entry + * @return the suffix represented by this mapping tree node + */ + static public String getMappingNodeSuffix(LDAPEntry mnent) { + return getMappingNodeName(mnent); + } + + static public String getSuffixSearchFilter(String suffix, String attrname) { + String normsuffix = LDAPDN.normalize(suffix); + return "(|(" + attrname + "=" + suffix + ")(" + attrname + "=" + Quote(suffix) + ")(" + + attrname + "=" + normsuffix + ")(" + attrname + "=" + Quote(normsuffix) + "))"; + } + + static public String getSuffixSearchFilter(String suffix) { + return getSuffixSearchFilter(suffix, "cn"); + } + static public String getParentSearchFilter(String suffix) { + return getSuffixSearchFilter(suffix, "nsslapd-parent-suffix"); + } + static public String[] getMappingNode(LDAPConnection ldc ) { Vector v = new Vector(1);
@@ -51,8 +98,8 @@ public class MappingUtils { false ); while( res.hasMoreElements() ) { LDAPEntry bentry = (LDAPEntry)res.nextElement(); - String name = bentry.getDN(); - v.addElement(unQuote(LDAPDN.explodeDN(bentry.getDN(),true)[0])); + String name = getMappingNodeSuffix(bentry); + v.addElement(name); } } catch ( LDAPException e ) { Debug.println(0, "NewMappingNodePanel.getMappingNode() " + e ); @@ -62,32 +109,12 @@ public class MappingUtils { return mapList; }
- static public String unQuote( String line ) { - if (line != null) { - if (line.length() > 0) { - StringBuffer unquote_line = new StringBuffer(); - - Character deb = new Character( line.charAt(0) ); - Character fin = new Character( line.charAt( line.length() - 1 ) ); - Character tag = new Character( '"' ); - - if ( deb.compareTo(tag) == 0) { - for (int i=1; i < (line.length() - 1); i++) { - unquote_line.append(line.charAt(i)); - } - } else { - unquote_line.append( line ); - } - return(unquote_line.toString()); - } - return (new String(line)); - } - return null; - } - static public String Quote( String line ) { + if ((line == null) || (line.length() < 1)) { + return """"; + } StringBuffer quoted_line = new StringBuffer(); - + Character deb = new Character( line.charAt(0) ); Character tag = new Character( '"' );
@@ -101,51 +128,6 @@ public class MappingUtils { return(quoted_line.toString()); }
- /** - * Escape backslashes in RDNs for suffix search. E.g. to search for - * "o=Abc,Inc" as an attribute value it should be eacaped as - * "o=Abc\,Inc" in a search filter (nsslapd-suffix=o=Abc\,Inc). - */ - static public String escapeBackslash(String val) { - if (val.indexOf('\') < 0) { - return val; - } - StringBuffer res = new StringBuffer(); - for (int i=0; i < val.length(); i++) { - if (val.charAt(i) == '\') { - res.append('\'); - } - res.append(val.charAt(i)); - } - return res.toString(); - } - - /** - * Remove escape backslashes. This will be used when creating a suffix - * to convert a RDN with escaped characters into an attribute value. - * - * E.g. the user wants to create a domain for "Abc, Inc". The domain - * suffix DN must be input as "o=Abc, Inc", but when the suffix entry - * is created the corresponding attr value is "Abc, Inc". - */ - static public String unescapeBackslash(String val) { - if (val.indexOf('\') < 0) { - return val; - } - StringBuffer res = new StringBuffer(); - for (int i=0; i < val.length(); i++) { - if (val.charAt(i) == '\') { - if (++i < val.length()) { - res.append(val.charAt(i)); - } - } - else { - res.append(val.charAt(i)); - } - } - return res.toString(); - } - static public String[] getBackendList(LDAPConnection ldc) { if (ldc == null) { return null; @@ -226,7 +208,7 @@ public class MappingUtils { return suffixes; }
- /* Uses the bubble method to order the suffixes (the longuest goes first)*/ + /* Uses the bubble method to order the suffixes (the longest goes first)*/
static public void orderSuffixes(String[] suffixes) { if (suffixes==null) { @@ -328,13 +310,13 @@ public class MappingUtils { int index = values[i].indexOf(':'); if (index > 0) { String suffix = values[i].substring(index+1); - v.addElement(MappingUtils.unQuote(suffix)); + v.addElement(suffix); } } } } else { String suffix = DSUtil.getAttrValue(entry, SUFFIX_ATTR); - v.addElement(MappingUtils.unQuote(suffix)); + v.addElement(suffix); } } } catch ( LDAPException e ) { @@ -601,40 +583,23 @@ public class MappingUtils { ) { int resDiag;
- StringBuffer cn2add = new StringBuffer(); - // Check parms if( (newNodeName == null) || (newNodeName.trim().length() == 0) ) { return( false ); }
- // build the cn - Character deb = new Character(newNodeName.charAt(0)); - Character fin = new Character(newNodeName.charAt(newNodeName.length() - 1)); - Character tag = new Character( '"' ); - - if ( deb.compareTo(tag) != 0) { - cn2add.append( '"' ); - } - - cn2add.append( newNodeName ); - + StringBuffer cn2add = new StringBuffer(newNodeName); // Add the upperNode to the new node if ( upperNode.compareTo( ROOT_MAPPING_NODE )!=0 ) { cn2add.append( "," ); cn2add.append( upperNode ); }
+ // Building dn to add in mapping tree + // NOTE: we only need the escaped value in the DN - we use the + // "raw" value everywhere else + String dn2add = "cn=" + DSUtil.escapeDNVal(cn2add.toString()) + "," + CONFIG_MAPPING ;
- if ( fin.compareTo(tag) != 0) { - cn2add.append( '"' ); - } - - - // Building dn to add in mapping tree - String dn2add = "cn=" + cn2add.toString() + "," + CONFIG_MAPPING ; - - // Start LDAP job LDAPAttributeSet attrs = new LDAPAttributeSet();
@@ -644,13 +609,14 @@ public class MappingUtils { String state[] = { NStatus }; attrs.add( new LDAPAttribute( "nsslapd-state", state ));
- // Force a quoted value just to have a consistent display + // cn value is the "raw" suffix + // the server may also add the value from the RDN value from the DN String mycn[] = { cn2add.toString() }; attrs.add( new LDAPAttribute( "cn", mycn ));
- if ( upperNode.compareTo( ROOT_MAPPING_NODE ) != 0) { - String dady[] = { Quote( upperNode.trim() ) }; + // parent suffix is also the "raw" value, not escaped or quoted + String dady[] = { upperNode.trim() }; attrs.add( new LDAPAttribute( "nsslapd-parent-suffix", dady )); }
@@ -905,6 +871,49 @@ public class MappingUtils { }
+ public static boolean isLeafMappingNode(LDAPConnection ldc, LDAPEntry _entry) { + String suffix = MappingUtils.getMappingNodeSuffix(_entry); + String filter = MappingUtils.getParentSearchFilter(suffix); + // this node is a leaf if it is not the parent of another node + try { + LDAPSearchResults res = ldc.search( CONFIG_MAPPING, LDAPv3.SCOPE_ONE, + filter, null, false); + if ((res == null) || !res.hasMoreElements()) { + return( true ); + } else { + return( false ); + } + } catch (LDAPException e) { + Debug.println( "MappingNodeObject.isLeafMappingNode() :" + e ); + return( false ); + } + } + + /** + * Given a suffix DN, return the corresponding mapping tree node DN + * @param ldc the LDAP connection + * @param suffix the suffix DN + * @return the DN of the mapping tree node corresponding to this suffix + */ + public static String getMappingNodeForSuffix(LDAPConnection ldc, String suffix) { + String filter = getSuffixSearchFilter(suffix); + // this node is a leaf if it is not the parent of another node + String mndn = null; + try { + LDAPSearchResults res = ldc.search( CONFIG_MAPPING, LDAPv3.SCOPE_ONE, + filter, null, false); + if ((res == null) || !res.hasMoreElements()) { + Debug.println( "MappingNodeObject.getMappingNodeForSuffix() : " + + "no entries returned for filter " + filter ); + } else { + LDAPEntry entry = (LDAPEntry)res.nextElement(); + mndn = entry.getDN(); + } + } catch (LDAPException e) { + Debug.println( "MappingNodeObject.getMappingNodeForSuffix() :" + e ); + } + return mndn; + }
private final static String _section = "mappingtree"; public static final String CONFIG_BASEDN = "cn=plugins, cn=config" ; diff --git a/src/com/netscape/admin/dirserv/panel/NewChainingInstancePanel.java b/src/com/netscape/admin/dirserv/panel/NewChainingInstancePanel.java index 12c419f..4c62359 100644 --- a/src/com/netscape/admin/dirserv/panel/NewChainingInstancePanel.java +++ b/src/com/netscape/admin/dirserv/panel/NewChainingInstancePanel.java @@ -918,11 +918,6 @@ public class NewChainingInstancePanel extends BlankPanel } } else if ( _rbExistingNode.isSelected() ) { // Add backend instance in selected Mapping Node - String dn_instMapping = "cn=" + - MappingUtils.Quote( (String) _comboMapping.getSelectedItem() ) + - "," + - CONFIG_MAPPING; - Debug.println("okCallback updating :" + dn_instMapping); LDAPModificationSet mods = new LDAPModificationSet(); LDAPAttribute backend_instMapping = new LDAPAttribute( "nsslapd-backend", @@ -930,6 +925,9 @@ public class NewChainingInstancePanel extends BlankPanel mods.add( LDAPModification.ADD, backend_instMapping ); _model.setWaitCursor( true ); LDAPConnection ldc = _model.getServerInfo().getLDAPConnection(); + String dn_instMapping = MappingUtils.getMappingNodeForSuffix(ldc, + (String) _comboMapping.getSelectedItem()); + Debug.println("okCallback updating :" + dn_instMapping); try { ldc.modify(dn_instMapping, mods ); } catch (LDAPException e) { diff --git a/src/com/netscape/admin/dirserv/panel/NewChainingPanel.java b/src/com/netscape/admin/dirserv/panel/NewChainingPanel.java index ad6bd8f..08a8277 100644 --- a/src/com/netscape/admin/dirserv/panel/NewChainingPanel.java +++ b/src/com/netscape/admin/dirserv/panel/NewChainingPanel.java @@ -102,11 +102,7 @@ public class NewChainingPanel extends BlankPanel
HostPanel.setLayout(HLbag);
- LDAPAttribute suffixCN = _entrySuffix.getAttribute("cn"); - if ( suffixCN != null ){ - _suffix = MappingUtils.unQuote( suffixCN.getStringValueArray()[0]); - } - + _suffix = MappingUtils.getMappingNodeSuffix(_entrySuffix); _suffixLabel = makeJLabel( _section, "suffix-name" ); HLgbc.fill = HLgbc.NONE; HLgbc.weightx = 0; @@ -721,7 +717,7 @@ public class NewChainingPanel extends BlankPanel } }
- public int addChainingBackend(String _MappingNode ) { + public int addChainingBackend(String suffix ) {
String _instName = _instanceNameText.getText().trim(); getChainingLoc(); @@ -741,7 +737,7 @@ public class NewChainingPanel extends BlankPanel attrs.add( new LDAPAttribute( "cn", cn_dbInst ) );
- String suffix_dbInstConfig[] = { _MappingNode }; + String suffix_dbInstConfig[] = { suffix }; attrs.add( new LDAPAttribute ( "nsslapd-suffix", suffix_dbInstConfig ));
String nsBindDN = _bindDNText.getText(); diff --git a/src/com/netscape/admin/dirserv/panel/NewLDBMPanel.java b/src/com/netscape/admin/dirserv/panel/NewLDBMPanel.java index 6d264ac..5535fec 100644 --- a/src/com/netscape/admin/dirserv/panel/NewLDBMPanel.java +++ b/src/com/netscape/admin/dirserv/panel/NewLDBMPanel.java @@ -83,10 +83,7 @@ public class NewLDBMPanel extends BlankPanel { gbc.fill = gbc.HORIZONTAL; grid.add( panel, gbc );
- LDAPAttribute suffixCN = _entrySuffix.getAttribute("cn"); - if ( suffixCN != null ){ - _suffix = MappingUtils.unQuote( suffixCN.getStringValueArray()[0]); - } + _suffix = MappingUtils.getMappingNodeSuffix(_entrySuffix); _suffixLabel = makeJLabel( _section, "suffix-name" ); gbc.gridwidth = 3; gbc.fill = gbc.NONE; @@ -309,7 +306,7 @@ public class NewLDBMPanel extends BlankPanel { } }
- public int addLDBMBackend(String _MappingNode ) { + public int addLDBMBackend(String suffix ) {
String _instName = _instanceNameText.getText().trim();
@@ -335,7 +332,7 @@ public class NewLDBMPanel extends BlankPanel { attrs.add( new LDAPAttribute( "cn", cn_dbInst ) );
- String suffix_dbInstConfig[] = { _MappingNode }; + String suffix_dbInstConfig[] = { suffix }; attrs.add( new LDAPAttribute ( "nsslapd-suffix", suffix_dbInstConfig ));
String cachesize_dbInstConfig[] = { "-1" }; diff --git a/src/com/netscape/admin/dirserv/panel/NewMappingNodePanel.java b/src/com/netscape/admin/dirserv/panel/NewMappingNodePanel.java index 0243ab3..12a5f6d 100644 --- a/src/com/netscape/admin/dirserv/panel/NewMappingNodePanel.java +++ b/src/com/netscape/admin/dirserv/panel/NewMappingNodePanel.java @@ -218,11 +218,14 @@ public class NewMappingNodePanel extends BlankPanel { if ( mapList != null ) { int j =0; _comboNewNodeMapping.addItem( ROOT_MAPPING_NODE ); + String suffix = null; + if (_entry != null) { + suffix = MappingUtils.getMappingNodeSuffix(_entry); + } for( int i = 0; i < mapList.length; i++ ) { _comboNewNodeMapping.addItem( mapList[i] ); - if((_entry != null) && - ( mapList[i].compareTo(MappingUtils.unQuote( - LDAPDN.explodeDN( _entry.getDN(), true )[0])) == 0)) { + if((suffix != null) && + DSUtil.equalDNs(mapList[i], suffix)) { j = i + 1; } diff --git a/src/com/netscape/admin/dirserv/panel/NewSuffixPanel.java b/src/com/netscape/admin/dirserv/panel/NewSuffixPanel.java index 87bb368..ed88323 100644 --- a/src/com/netscape/admin/dirserv/panel/NewSuffixPanel.java +++ b/src/com/netscape/admin/dirserv/panel/NewSuffixPanel.java @@ -119,8 +119,7 @@ public class NewSuffixPanel extends BlankPanel implements SuiConstants { Mapanel.add( _newSuffixText, Magbc );
if(! _isRoot ) { - String dady = MappingUtils.unQuote( LDAPDN.explodeDN( _entry.getDN(), - true )[0]); + String dady = MappingUtils.getMappingNodeSuffix(_entry);
_subordinationLabel = makeJLabel( _section, "new-subordination" ); diff --git a/src/com/netscape/admin/dirserv/panel/confirmDeleteSuffixPanel.java b/src/com/netscape/admin/dirserv/panel/confirmDeleteSuffixPanel.java index 7c61a5b..7b889f1 100644 --- a/src/com/netscape/admin/dirserv/panel/confirmDeleteSuffixPanel.java +++ b/src/com/netscape/admin/dirserv/panel/confirmDeleteSuffixPanel.java @@ -70,8 +70,7 @@ public class confirmDeleteSuffixPanel extends BlankPanel _myPanel.setLayout(Mabag); - DN dnObj = new DN(_dnSuffix2delete); - String[] args = {dnObj.explodeDN(true)[0]}; + String[] args = {_dnSuffix2delete}; _introLabel = new MultilineLabel(resource.getString( _section, "intro-label", args )); _introLabel.setLineWrap(false); diff --git a/src/com/netscape/admin/dirserv/propedit/DSEntryPanel.java b/src/com/netscape/admin/dirserv/propedit/DSEntryPanel.java index 06bba44..aff65a8 100644 --- a/src/com/netscape/admin/dirserv/propedit/DSEntryPanel.java +++ b/src/com/netscape/admin/dirserv/propedit/DSEntryPanel.java @@ -1414,21 +1414,11 @@ public class DSEntryPanel extends JPanel implements ActionListener, String stringRDN = ""; for (int i=0; i < attributes.length ; i++) { - /* We add the quotes if necessary*/ - if (values[i].indexOf(',') >= 0) { - String unquotedValue = MappingUtils.unQuote(values[i]); - if (i>0) { - stringRDN = stringRDN + " + " + attributes[i]+"=""+unquotedValue+"""; - } else { - stringRDN = attributes[i]+"=""+unquotedValue+"""; - } - } else { - if (i>0) { - stringRDN = stringRDN + " + " +attributes[i]+"="+values[i]; - } else { - stringRDN = attributes[i]+"="+values[i]; - } - } + if (i>0) { + stringRDN = stringRDN + " + " +attributes[i]+"="+DSUtil.escapeDNVal(values[i]); + } else { + stringRDN = attributes[i]+"="+DSUtil.escapeDNVal(values[i]); + } } Debug.println("DSEntryPanel.updateDNValue: rdn = "+stringRDN); @@ -1442,7 +1432,7 @@ public class DSEntryPanel extends JPanel implements ActionListener, parentDN = new DN(stringRDN); } _dn = parentDN; - String dn = stringRDN+", "+_dn.getParent(); + String dn = stringRDN+","+_dn.getParent(); Debug.println("DSEntryPanel.updateDNValue: dn = "+dn); if (dn != null) { _dnLabel.setText("dn: "+dn); @@ -1498,8 +1488,7 @@ public class DSEntryPanel extends JPanel implements ActionListener, String currentValue = (String)en.nextElement(); /* Just in case we have quotes... */ if (value.equals(currentValue) || - MappingUtils.unescapeBackslash(value).equals(currentValue) || - value.equals('"'+currentValue+'"')) { + DSUtil.escapeDNVal(value).equals(currentValue)) { typeWithValue = true; break; } diff --git a/src/com/netscape/admin/dirserv/propedit/RenameDialog.java b/src/com/netscape/admin/dirserv/propedit/RenameDialog.java index 40805c7..303ace3 100644 --- a/src/com/netscape/admin/dirserv/propedit/RenameDialog.java +++ b/src/com/netscape/admin/dirserv/propedit/RenameDialog.java @@ -209,21 +209,11 @@ class RenameDialog extends AbstractDialog implements TableUpdateListener { private String getInitRdn() { String rdn = ""; for (int i=0; i< _saveNamingAttributes.length; i++) { - /* We add the quotes if necessary*/ - if (_saveNamingValues[i].indexOf(',') >= 0) { - String unquotedValue = MappingUtils.unQuote(_saveNamingValues[i]); - if (i>0) { - rdn = rdn + " + " + _saveNamingAttributes[i]+"=""+unquotedValue+"""; - } else { - rdn = _saveNamingAttributes[i]+"=""+unquotedValue+"""; - } - } else { - if (i>0) { - rdn = rdn + " + " +_saveNamingAttributes[i]+"= "+_saveNamingValues[i]; - } else { - rdn = _saveNamingAttributes[i]+"= "+_saveNamingValues[i]; - } - } + if (i>0) { + rdn = rdn + " + " +_saveNamingAttributes[i]+"= "+DSUtil.escapeDNVal(_saveNamingValues[i]); + } else { + rdn = _saveNamingAttributes[i]+"= "+DSUtil.escapeDNVal(_saveNamingValues[i]); + } } return rdn; } @@ -237,20 +227,10 @@ class RenameDialog extends AbstractDialog implements TableUpdateListener { for (int i=0; i< _namingAttributes.size(); i++) { String namingAttribute = (String)_namingAttributes.elementAt(i); String namingValue = (String)_namingValues.elementAt(i); - /* We add the quotes if necessary*/ - if (namingValue.indexOf(',') >= 0) { - String unquotedValue = MappingUtils.unQuote(namingValue); - if (i>0) { - rdn = rdn + " + " + namingAttribute+"=""+unquotedValue+"""; - } else { - rdn = namingAttribute+"=""+unquotedValue+"""; - } + if (i>0) { + rdn = rdn + "+" +namingAttribute+"="+DSUtil.escapeDNVal(namingValue); } else { - if (i>0) { - rdn = rdn + " + " +namingAttribute+"= "+namingValue; - } else { - rdn = namingAttribute+"= "+namingValue; - } + rdn = namingAttribute+"="+DSUtil.escapeDNVal(namingValue); } } return rdn;
389-commits@lists.fedoraproject.org