opendj-core/src/main/java/org/forgerock/opendj/ldap/DN.java
@@ -808,6 +808,8 @@ /** * Returns the RDN of this DN, or {@code null} if this DN is the Root DN. * <p> * This is the equivalent of calling {@code dn.rdn(0)}. * * @return The RDN of this DN, or {@code null} if this DN is the Root DN. */ opendj-core/src/test/java/org/forgerock/opendj/ldap/DNTestCase.java
@@ -503,6 +503,7 @@ assertEquals(c.toString(), e.toString()); assertEquals(c.rdn(), RDN.valueOf("dc=foo")); assertEquals(c.rdn(), c.rdn(0)); assertEquals(c.parent(), DN.valueOf("dc=opendj,dc=org")); assertEquals(c.parent(), e.parent()); opendj-server-legacy/src/main/java/org/opends/admin/ads/util/ApplicationTrustManager.java
@@ -26,14 +26,13 @@ import java.util.ArrayList; import java.util.List; import javax.naming.ldap.LdapName; import javax.naming.ldap.Rdn; import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.X509TrustManager; import org.forgerock.i18n.LocalizableMessage; import org.forgerock.i18n.slf4j.LocalizedLogger; import org.forgerock.opendj.ldap.DN; import org.opends.server.util.Platform; /** @@ -364,10 +363,8 @@ boolean matches = false; try { LdapName dn = new LdapName(chain[0].getSubjectX500Principal().getName()); Rdn rdn = dn.getRdn(dn.getRdns().size() - 1); String value = rdn.getValue().toString(); DN dn = DN.valueOf(chain[0].getSubjectX500Principal().getName()); String value = dn.rdn(dn.size() - 1).getFirstAVA().getAttributeValue().toString(); matches = hostMatch(value, host); if (!matches) { opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/browser/NodeRefresher.java
@@ -424,7 +424,7 @@ } if (referral != null) { throwAbandonIfNeeded(new ReferralLimitExceededException( throwAbandonIfNeeded(newLdapException(CLIENT_SIDE_REFERRAL_LIMIT_EXCEEDED, AdminToolMessages.ERR_REFERRAL_LIMIT_EXCEEDED.get(hopCount))); } } @@ -924,7 +924,8 @@ && hp.equals(controller.getUserDataConnection().getConnectionWrapper().getHostPort()); if (!checkSucceeded) { Exception cause = new ReferralLimitExceededException(ERR_CTRL_PANEL_REFERRAL_LOOP.get(url.getRawBaseDN())); LdapException cause = newLdapException(CLIENT_SIDE_REFERRAL_LIMIT_EXCEEDED, ERR_CTRL_PANEL_REFERRAL_LOOP.get(url.getRawBaseDN())); throw new SearchAbandonException(State.FAILED, cause, referral); } } opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/browser/ReferralLimitExceededException.java
File was deleted opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteEntryTask.java
@@ -30,7 +30,6 @@ import java.util.SortedSet; import java.util.TreeSet; import javax.naming.NamingException; import javax.swing.SwingUtilities; import javax.swing.tree.TreePath; @@ -278,7 +277,7 @@ } private void deleteSubtreeRecursively(ConnectionWithControls conn, DN dnToRemove, TreePath path, List<BrowserNodeInfo> toNotify) throws NamingException, IOException, DirectoryException List<BrowserNodeInfo> toNotify) throws IOException, DirectoryException { lastDn = dnToRemove; @@ -371,7 +370,7 @@ } private void deleteSubtreeWithControl(ConnectionWithControls conn, DN dn, TreePath path, List<BrowserNodeInfo> toNotify) throws LdapException, NamingException List<BrowserNodeInfo> toNotify) throws LdapException { lastDn = dn; long t = System.currentTimeMillis(); opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseEntriesPanel.java
@@ -39,10 +39,10 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.io.InterruptedIOException; import java.util.ArrayList; import java.util.LinkedHashSet; import javax.naming.InterruptedNamingException; import javax.swing.ButtonGroup; import javax.swing.JCheckBoxMenuItem; import javax.swing.JComponent; @@ -1463,18 +1463,20 @@ private boolean isInterruptedException(Throwable t) { boolean isInterruptedException = false; isInterruptedException = t instanceof java.io.InterruptedIOException || t instanceof InterruptedNamingException; boolean isInterruptedException = isInterrupted(t); while (t != null && !isInterruptedException) { t = t.getCause(); isInterruptedException = t instanceof java.io.InterruptedIOException || t instanceof InterruptedNamingException; isInterruptedException = isInterrupted(t); } return isInterruptedException; } private boolean isInterrupted(Throwable t) { return t instanceof InterruptedIOException || t instanceof InterruptedException; } private void refreshClicked() { // Refresh the contents of the selected entry. opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LocalOrRemotePanel.java
@@ -639,7 +639,7 @@ Iterator<DN> it = info.getServerDescriptor().getAdministrativeUsers().iterator(); while (it.hasNext() && !found) { found = Utils.areDnsEqual(providedDn, it.next().toString()); found = DN.valueOf(providedDn).equals(it.next()); } if (!found) { opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LoginPanel.java
@@ -22,7 +22,6 @@ import java.util.Iterator; import java.util.LinkedHashSet; import javax.naming.NamingException; import javax.swing.JLabel; import javax.swing.JPasswordField; import javax.swing.JTextField; @@ -31,6 +30,7 @@ import org.forgerock.i18n.LocalizableMessage; import org.forgerock.i18n.slf4j.LocalizedLogger; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.LdapException; import org.opends.admin.ads.util.ApplicationTrustManager; import org.opends.admin.ads.util.ConnectionWrapper; import org.opends.guitools.controlpanel.datamodel.ConfigReadException; @@ -265,7 +265,7 @@ handleCertificateException = true; } } else if (throwable instanceof NamingException) else if (throwable instanceof LdapException) { boolean found = false; String providedDn = dn.getText(); @@ -273,7 +273,7 @@ getAdministrativeUsers().iterator(); while (it.hasNext() && !found) { found = Utils.areDnsEqual(providedDn, it.next().toString()); found = DN.valueOf(providedDn).equals(it.next()); } if (!found) { @@ -281,8 +281,7 @@ } else { errors.add(Utils.getMessageForException( (NamingException)throwable)); errors.add(Utils.getMessageForException((LdapException) throwable)); } setPrimaryInvalid(dnLabel); opendj-server-legacy/src/main/java/org/opends/quicksetup/ui/CertificateDialog.java
@@ -36,8 +36,6 @@ import java.util.HashMap; import java.util.Map; import javax.naming.ldap.LdapName; import javax.naming.ldap.Rdn; import javax.swing.Box; import javax.swing.JButton; import javax.swing.JComboBox; @@ -55,6 +53,7 @@ import org.forgerock.i18n.LocalizableMessage; import org.forgerock.i18n.LocalizableMessageBuilder; import org.forgerock.i18n.slf4j.LocalizedLogger; import org.forgerock.opendj.ldap.DN; import org.opends.quicksetup.UserDataCertificateException; import org.opends.quicksetup.event.MinimumSizeComponentListener; @@ -663,9 +662,8 @@ String name = cert.getSubjectX500Principal().getName(); try { LdapName dn = new LdapName(name); Rdn rdn = dn.getRdn(0); return rdn.getValue().toString(); DN dn = DN.valueOf(name); return dn.rdn().getFirstAVA().getAttributeValue().toString(); } catch (Throwable t) { opendj-server-legacy/src/main/java/org/opends/quicksetup/util/Utils.java
@@ -52,20 +52,17 @@ import java.util.Set; import java.util.TimeZone; import javax.naming.AuthenticationException; import javax.naming.CommunicationException; import javax.naming.NamingException; import javax.naming.NamingSecurityException; import javax.naming.NoPermissionException; import javax.naming.ldap.LdapName; import org.forgerock.i18n.LocalizableMessage; import org.forgerock.i18n.LocalizableMessageBuilder; import org.forgerock.i18n.LocalizedIllegalArgumentException; import org.forgerock.i18n.slf4j.LocalizedLogger; import org.forgerock.opendj.config.ManagedObjectDefinition; import org.forgerock.opendj.ldap.AuthorizationException; import org.forgerock.opendj.ldap.ConnectionException; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.LdapException; import org.forgerock.opendj.ldap.requests.SearchRequest; import org.forgerock.opendj.ldap.responses.SearchResultEntry; import org.forgerock.opendj.server.config.client.BackendCfgClient; @@ -87,6 +84,7 @@ import org.opends.quicksetup.installer.SuffixesToReplicateOptions; import org.opends.quicksetup.ui.UIFactory; import org.opends.server.tools.BackendTypeHelper; import org.opends.server.types.HostPort; import org.opends.server.util.SetupUtils; import com.forgerock.opendj.cli.ArgumentConstants; @@ -370,17 +368,27 @@ /** * Returns whether the provided string is a configuration DN. * * @param dn * @param dnStr * the String we are analyzing. * @return {@code true} if the provided string is a configuration DN and {@code false} otherwise. */ public static boolean isConfigurationDn(String dn) public static boolean isConfigurationDn(String dnStr) { DN dn; try { dn = DN.valueOf(dnStr); } catch (LocalizedIllegalArgumentException e) { return false; } boolean isConfigurationDn = false; String[] configDns = { "cn=config", Constants.SCHEMA_DN.toString() }; DN[] configDns = { DN.valueOf("cn=config"), Constants.SCHEMA_DN }; for (int i = 0; i < configDns.length && !isConfigurationDn; i++) { isConfigurationDn = areDnsEqual(dn, configDns[i]); isConfigurationDn = dn.equals(configDns[i]); } return isConfigurationDn; } @@ -553,18 +561,17 @@ { LocalizableMessageBuilder buf = new LocalizableMessageBuilder(); String ldapUrl = te.getLdapUrl(); if (ldapUrl != null) HostPort hp = te.getHostPort(); if (hp != null) { String hostName = ldapUrl.substring(ldapUrl.indexOf("://") + 3); buf.append(INFO_SERVER_ERROR.get(hostName)); buf.append(INFO_SERVER_ERROR.get(hp.getHost())); buf.append(" "); } if (te.getType() == TopologyCacheException.Type.TIMEOUT) { buf.append(INFO_ERROR_CONNECTING_TIMEOUT.get()); } else if (te.getCause() instanceof NamingException) else if (te.getCause() instanceof LdapException) { buf.append(getThrowableMsg(INFO_ERROR_CONNECTING_TO_LOCAL.get(), te.getCause())); } @@ -646,43 +653,6 @@ } /** * Returns a message object for the given NamingException. The code assume * that we are trying to connect to the local server. * * @param ne * the NamingException. * @return a message object for the given NamingException. */ public static LocalizableMessage getMessageForException(NamingException ne) { final String detailedException = ne.toString(true); if (isCertificateException(ne)) { return INFO_ERROR_READING_CONFIG_LDAP_CERTIFICATE.get(detailedException); } else if (ne instanceof AuthenticationException) { return ERR_CANNOT_CONNECT_TO_LOCAL_AUTHENTICATION.get(detailedException); } else if (ne instanceof NoPermissionException) { return ERR_CANNOT_CONNECT_TO_LOCAL_PERMISSIONS.get(detailedException); } else if (ne instanceof NamingSecurityException) { return ERR_CANNOT_CONNECT_TO_LOCAL_PERMISSIONS.get(detailedException); } else if (ne instanceof CommunicationException) { return ERR_CANNOT_CONNECT_TO_LOCAL_COMMUNICATION.get(detailedException); } else { return ERR_CANNOT_CONNECT_TO_LOCAL_GENERIC.get(detailedException); } } /** * Returns a message object for the given IOException. The code assume that we are trying to * connect to the local server. *