| | |
| | | import javax.swing.tree.TreeNode; |
| | | import javax.swing.tree.TreePath; |
| | | |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.responses.SearchResultEntry; |
| | | import org.opends.admin.ads.ADSContext; |
| | | import org.opends.admin.ads.util.ConnectionWrapper; |
| | |
| | | * @throws IllegalArgumentException if a node with the given dn exists but |
| | | * is not a suffix node. |
| | | */ |
| | | public boolean hasSuffix(String suffixDn) throws IllegalArgumentException |
| | | public boolean hasSuffix(DN suffixDn) throws IllegalArgumentException |
| | | { |
| | | return findSuffixNode(suffixDn, rootNode) != null; |
| | | } |
| | |
| | | * @return the TreePath of the new node. |
| | | * @throws IllegalArgumentException if a node with the given dn exists. |
| | | */ |
| | | public TreePath addSuffix(String suffixDn, String parentSuffixDn) |
| | | throws IllegalArgumentException |
| | | public TreePath addSuffix(DN suffixDn, DN parentSuffixDn) throws IllegalArgumentException |
| | | { |
| | | SuffixNode parentNode; |
| | | if (parentSuffixDn != null) { |
| | | parentNode = findSuffixNode(parentSuffixDn, rootNode); |
| | | if (parentNode == null) { |
| | | throw new IllegalArgumentException("Invalid suffix dn " + |
| | | parentSuffixDn); |
| | | throw new IllegalArgumentException("Invalid suffix dn " + parentSuffixDn); |
| | | } |
| | | } |
| | | else { |
| | |
| | | * @param nodeDn the DN of the node to be added. |
| | | * @return the TreePath of the new node. |
| | | */ |
| | | public TreePath addNodeUnderRoot(String nodeDn) { |
| | | public TreePath addNodeUnderRoot(DN nodeDn) { |
| | | SuffixNode parentNode = rootNode; |
| | | int index = findChildNode(parentNode, nodeDn); |
| | | if (index >= 0) { // A node has already this dn -> bug |
| | |
| | | * @param newEntryDn the dn of the entry to be added. |
| | | * @return the tree path associated with the new entry. |
| | | */ |
| | | public TreePath notifyEntryAdded(BrowserNodeInfo parentInfo, |
| | | String newEntryDn) { |
| | | public TreePath notifyEntryAdded(BrowserNodeInfo parentInfo, DN newEntryDn) { |
| | | BasicNode parentNode = parentInfo.getNode(); |
| | | BasicNode childNode = new BasicNode(newEntryDn); |
| | | int childIndex; |
| | |
| | | } |
| | | if (node instanceof SuffixNode) |
| | | { |
| | | String dn = node.getDN(); |
| | | return Utilities.areDnsEqual(dn, ADSContext.getAdministrationSuffixDN().toString()) || |
| | | Utilities.areDnsEqual(dn, ConfigConstants.DN_DEFAULT_SCHEMA_ROOT) || |
| | | Utilities.areDnsEqual(dn, ConfigConstants.DN_TASK_ROOT) || |
| | | Utilities.areDnsEqual(dn, ConfigConstants.DN_CONFIG_ROOT) || |
| | | Utilities.areDnsEqual(dn, ConfigConstants.DN_MONITOR_ROOT) || |
| | | Utilities.areDnsEqual(dn, ConfigConstants.DN_TRUST_STORE_ROOT) || |
| | | Utilities.areDnsEqual(dn, ConfigConstants.DN_BACKUP_ROOT) || |
| | | Utilities.areDnsEqual(dn, DN_EXTERNAL_CHANGELOG_ROOT); |
| | | DN dn = node.getDN(); |
| | | String dnStr = dn.toString(); |
| | | return dn.equals(ADSContext.getAdministrationSuffixDN()) || |
| | | Utilities.areDnsEqual(dnStr, ConfigConstants.DN_DEFAULT_SCHEMA_ROOT) || |
| | | Utilities.areDnsEqual(dnStr, ConfigConstants.DN_TASK_ROOT) || |
| | | Utilities.areDnsEqual(dnStr, ConfigConstants.DN_CONFIG_ROOT) || |
| | | Utilities.areDnsEqual(dnStr, ConfigConstants.DN_MONITOR_ROOT) || |
| | | Utilities.areDnsEqual(dnStr, ConfigConstants.DN_TRUST_STORE_ROOT) || |
| | | Utilities.areDnsEqual(dnStr, ConfigConstants.DN_BACKUP_ROOT) || |
| | | Utilities.areDnsEqual(dnStr, DN_EXTERNAL_CHANGELOG_ROOT); |
| | | } |
| | | else |
| | | { |
| | |
| | | if (parent != null) |
| | | { |
| | | final LDAPURL parentUrl = findUrlForDisplayedEntry(parent); |
| | | return LDAPConnectionPool.makeLDAPUrl(parentUrl, node.getDN()); |
| | | return LDAPConnectionPool.makeLDAPUrl(parentUrl, node.getDN().toString()); |
| | | } |
| | | return LDAPConnectionPool.makeLDAPUrl(connConfig.getHostPort(), node.getDN(), connConfig.isLdaps()); |
| | | return LDAPConnectionPool.makeLDAPUrl(connConfig.getHostPort(), node.getDN().toString(), connConfig.isLdaps()); |
| | | } |
| | | |
| | | /** |
| | |
| | | if (followReferrals && node.getRemoteUrl() != null) { |
| | | return node.getRemoteUrl().getRawBaseDN(); |
| | | } |
| | | return node.getDN(); |
| | | return node.getDN().toString(); |
| | | } |
| | | |
| | | /** |
| | |
| | | // Search a child node matching the DN of the entry |
| | | int index; |
| | | if (differential) { |
| | | index = findChildNode(parent, entry.getName().toString()); |
| | | index = findChildNode(parent, entry.getName()); |
| | | } |
| | | else { |
| | | index = - (parent.getChildCount() + 1); |
| | |
| | | if (index < 0) { |
| | | // -(index + 1) is the location where to insert the new node |
| | | index = -(index + 1); |
| | | child = new BasicNode(entry.getName().toString()); |
| | | child = new BasicNode(entry.getName()); |
| | | parent.insert(child, index); |
| | | updateNodeRendering(child, entry); |
| | | insertIndex.add(index); |
| | |
| | | * @param childDn the DN of the entry that is being searched. |
| | | * @return the index of the node matching childDn. |
| | | */ |
| | | public int findChildNode(BasicNode parent, String childDn) { |
| | | public int findChildNode(BasicNode parent, DN childDn) { |
| | | int childCount = parent.getChildCount(); |
| | | int i = 0; |
| | | while (i < childCount |
| | |
| | | * @throws IllegalArgumentException if a node with the given dn exists but |
| | | * is not a suffix node. |
| | | */ |
| | | private SuffixNode findSuffixNode(String suffixDn, SuffixNode suffixNode) |
| | | private SuffixNode findSuffixNode(DN suffixDn, SuffixNode suffixNode) |
| | | throws IllegalArgumentException |
| | | { |
| | | if (Utilities.areDnsEqual(suffixNode.getDN(), suffixDn)) { |
| | | if (suffixNode.getDN().equals(suffixDn)) { |
| | | return suffixNode; |
| | | } |
| | | |
| | |
| | | do |
| | | { |
| | | child = (BasicNode) suffixNode.getChildAt(i); |
| | | if (Utilities.areDnsEqual(child.getDN(), suffixDn)) |
| | | if (child.getDN().equals(suffixDn)) |
| | | { |
| | | found = true; |
| | | } |
| | |
| | | */ |
| | | private void searchForCustomFilter(BasicNode node, ConnectionWrapper conn) throws IOException |
| | | { |
| | | SearchRequest request = newSearchRequest(node.getDN(), WHOLE_SUBTREE, controller.getFilter(), NO_ATTRIBUTES) |
| | | SearchRequest request = |
| | | newSearchRequest(node.getDN().toString(), WHOLE_SUBTREE, controller.getFilter(), NO_ATTRIBUTES) |
| | | .setSizeLimit(1); |
| | | try (ConnectionEntryReader s = conn.getConnection().search(request)) |
| | | { |
| | |
| | | |
| | | String filter = controller.getObjectSearchFilter(); |
| | | SearchRequest request = |
| | | newSearchRequest(node.getDN(), BASE_OBJECT, filter, controller.getAttrsForRedSearch()) |
| | | newSearchRequest(node.getDN().toString(), BASE_OBJECT, filter, controller.getAttrsForRedSearch()) |
| | | .setSizeLimit(controller.getMaxChildren()); |
| | | localEntry = conn.getConnection().searchSingleEntry(request); |
| | | localEntry.setName(node.getDN()); |
| | | if (localEntry == null) { |
| | | /* Not enough rights to read the entry or the entry simply does not exist */ |
| | | throw newLdapException(ResultCode.NO_SUCH_OBJECT, "Can't find entry: " + node.getDN()); |
| | |
| | | for (int i=0; i<getNode().getChildCount(); i++) |
| | | { |
| | | BasicNode node = (BasicNode)getNode().getChildAt(i); |
| | | try |
| | | if (node.getDN().equals(parentToAddDN)) |
| | | { |
| | | DN dn = DN.valueOf(node.getDN()); |
| | | if (dn.equals(parentToAddDN)) |
| | | { |
| | | resultValue[0] = false; |
| | | break; |
| | | } |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | throw new RuntimeException("Error decoding dn: "+ |
| | | node.getDN()+" . "+t, t); |
| | | resultValue[0] = false; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | |
| | | boolean checkSucceeded = true; |
| | | try |
| | | { |
| | | DN dn1 = DN.valueOf(getNode().getDN()); |
| | | DN dn2 = url.getBaseDN(); |
| | | if (dn2.isSuperiorOrEqualTo(dn1)) |
| | | if (url.getBaseDN().isSuperiorOrEqualTo(getNode().getDN())) |
| | | { |
| | | HostPort urlHostPort = new HostPort(url.getHost(), url.getPort()); |
| | | checkSucceeded = urlHostPort.equals(controller.getConfigurationConnection().getHostPort()); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.event; |
| | | |
| | | import org.forgerock.opendj.ldap.DN; |
| | | |
| | | //Note: in terms of synchronization, this implementation assumes that the |
| | | //interrupt method is only called in the event thread (this class is used |
| | | //when the user selects a node in the LDAP entry browser). |
| | |
| | | { |
| | | private Object source; |
| | | private Throwable t; |
| | | private String dn; |
| | | private DN dn; |
| | | |
| | | /** |
| | | * Constructor for the event. |
| | |
| | | * @param dn the DN of the entry we were searching. |
| | | * @param t the throwable that we got as error. |
| | | */ |
| | | public EntryReadErrorEvent(Object source, String dn, Throwable t) |
| | | public EntryReadErrorEvent(Object source, DN dn, Throwable t) |
| | | { |
| | | this.source = source; |
| | | this.t = t; |
| | |
| | | * Returns the DN of the entry we were searching. |
| | | * @return the DN of the entry we were searching. |
| | | */ |
| | | public String getDN() |
| | | public DN getDN() |
| | | { |
| | | return dn; |
| | | } |
| | |
| | | for (TreePath path : paths) |
| | | { |
| | | BasicNode node = (BasicNode)path.getLastPathComponent(); |
| | | entries.add(DN.valueOf(node.getDN())); |
| | | entries.add(node.getDN()); |
| | | } |
| | | for (BackendDescriptor backend : info.getServerDescriptor().getBackends()) |
| | | { |
| | |
| | | for (TreePath path : paths) |
| | | { |
| | | BasicNode node = (BasicNode)path.getLastPathComponent(); |
| | | try |
| | | DN dn = node.getDN(); |
| | | if (!isAlreadyDeleted(alreadyDeleted, dn)) |
| | | { |
| | | DN dn = DN.valueOf(node.getDN()); |
| | | boolean isDnDeleted = false; |
| | | for (DN deletedDn : alreadyDeleted) |
| | | ConnectionWrapper conn = controller.findConnectionForDisplayedEntry(node); |
| | | useAdminCtx = controller.isConfigurationNode(node); |
| | | if (node.hasSubOrdinates()) |
| | | { |
| | | if (dn.isSubordinateOrEqualTo(deletedDn)) |
| | | { |
| | | isDnDeleted = true; |
| | | break; |
| | | } |
| | | deleteSubtreeWithControl(conn, dn, path, toNotify); |
| | | } |
| | | if (!isDnDeleted) |
| | | else |
| | | { |
| | | ConnectionWrapper conn = controller.findConnectionForDisplayedEntry(node); |
| | | useAdminCtx = controller.isConfigurationNode(node); |
| | | if (node.hasSubOrdinates()) |
| | | { |
| | | deleteSubtreeWithControl(conn, dn, path, toNotify); |
| | | } |
| | | else |
| | | { |
| | | deleteSubtreeRecursively(conn, dn, path, toNotify); |
| | | } |
| | | alreadyDeleted.add(dn); |
| | | deleteSubtreeRecursively(conn, dn, path, toNotify); |
| | | } |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | throw new RuntimeException("Unexpected error parsing dn: "+ |
| | | node.getDN(), de); |
| | | alreadyDeleted.add(dn); |
| | | } |
| | | } |
| | | if (!toNotify.isEmpty()) |
| | |
| | | } |
| | | } |
| | | |
| | | private boolean isAlreadyDeleted(ArrayList<DN> dns, DN dnToFind) |
| | | { |
| | | for (DN dn : dns) |
| | | { |
| | | if (dnToFind.isSubordinateOrEqualTo(dn)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * Notifies that some entries have been deleted. This will basically update |
| | | * the browser controller so that the tree reflects the changes that have |
| | |
| | | controller.getNodeInfoFromPath(treePath)); |
| | | newPath[0] = controller.notifyEntryAdded( |
| | | controller.getNodeInfoFromPath(parentPath), |
| | | newEntry.getName().toString()); |
| | | newEntry.getName()); |
| | | } |
| | | }); |
| | | |
| | |
| | | { |
| | | getProgressDialog().appendProgressHtml( |
| | | Utilities.getProgressDone(ColorAndFontConstants.progressFont)); |
| | | final DN newEntryName = newEntry.getName(); |
| | | boolean entryInserted = false; |
| | | if (parentNode != null) |
| | | { |
| | | boolean isReallyParentNode = false; |
| | | try |
| | | { |
| | | DN parentDN = DN.valueOf(parentNode.getDN()); |
| | | isReallyParentNode = |
| | | parentDN.equals(newEntry.getName().parent()); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | // Bug |
| | | t.printStackTrace(); |
| | | isReallyParentNode = false; |
| | | } |
| | | boolean isReallyParentNode = parentNode.getDN().equals(newEntryName.parent()); |
| | | if (isReallyParentNode) |
| | | { |
| | | insertNode(parentNode, newEntry.getName(), |
| | | isBaseDN(newEntry.getName())); |
| | | insertNode(parentNode, newEntryName, isBaseDN(newEntryName)); |
| | | entryInserted = true; |
| | | } |
| | | } |
| | | if (!entryInserted) |
| | | { |
| | | BasicNode root = (BasicNode)controller.getTreeModel().getRoot(); |
| | | BasicNode realParentNode = findParentNode(newEntry.getName(), root); |
| | | BasicNode realParentNode = findParentNode(newEntryName, root); |
| | | if (realParentNode != null) |
| | | { |
| | | insertNode(realParentNode, newEntry.getName(), false); |
| | | insertNode(realParentNode, newEntryName, false); |
| | | } |
| | | else if (isBaseDN(newEntry.getName())) |
| | | else if (isBaseDN(newEntryName)) |
| | | { |
| | | int nRootChildren = controller.getTreeModel().getChildCount(controller.getTreeModel().getRoot()); |
| | | if (nRootChildren > 1) |
| | | { |
| | | // Insert in the root. |
| | | insertNode(root, newEntry.getName(), true); |
| | | insertNode(root, newEntryName, true); |
| | | } |
| | | } |
| | | } |
| | |
| | | int nRootChildren = controller.getTreeModel().getChildCount(root); |
| | | for (int i=0; i<nRootChildren; i++) |
| | | { |
| | | BasicNode node = |
| | | (BasicNode)controller.getTreeModel().getChild(root, i); |
| | | try |
| | | BasicNode node = (BasicNode) controller.getTreeModel().getChild(root, i); |
| | | DN nodeDN = node.getDN(); |
| | | if (dn.isSubordinateOrEqualTo(nodeDN)) |
| | | { |
| | | DN nodeDN = DN.valueOf(node.getDN()); |
| | | if (dn.isSubordinateOrEqualTo(nodeDN)) |
| | | if (dn.size() == nodeDN.size() + 1) |
| | | { |
| | | if (dn.size() == nodeDN.size() + 1) |
| | | { |
| | | parentNode = node; |
| | | break; |
| | | } |
| | | else |
| | | { |
| | | parentNode = findParentNode(dn, node); |
| | | break; |
| | | } |
| | | parentNode = node; |
| | | break; |
| | | } |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | // Bug |
| | | throw new RuntimeException("Unexpected error: "+t, t); |
| | | else |
| | | { |
| | | parentNode = findParentNode(dn, node); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | return parentNode; |
| | |
| | | TreePath newPath; |
| | | if (isSuffix) |
| | | { |
| | | newPath = controller.addSuffix(dn.toString(), parentNode.getDN()); |
| | | newPath = controller.addSuffix(dn, parentNode.getDN()); |
| | | } |
| | | else |
| | | { |
| | | newPath = controller.notifyEntryAdded(controller.getNodeInfoFromPath(parentPath), dn.toString()); |
| | | newPath = controller.notifyEntryAdded(controller.getNodeInfoFromPath(parentPath), dn); |
| | | } |
| | | if (newPath != null) |
| | | { |
| | |
| | | backendSet = new HashSet<>(); |
| | | this.node = node; |
| | | this.newPassword = pwd; |
| | | dn = DN.valueOf(node.getDN()); |
| | | dn = node.getDN(); |
| | | |
| | | for (BackendDescriptor backend : info.getServerDescriptor().getBackends()) |
| | | { |
| | |
| | | @Override |
| | | public LocalizableMessage getTaskDescription() |
| | | { |
| | | return INFO_CTRL_PANEL_RESET_USER_PASSWORD_TASK_DESCRIPTION.get( |
| | | node.getDN()); |
| | | return INFO_CTRL_PANEL_RESET_USER_PASSWORD_TASK_DESCRIPTION.get(node.getDN()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | controller.removeAllUnderRoot(); |
| | | controller.setFilter(filterValue); |
| | | controller.setAutomaticExpand(!BrowserController.ALL_OBJECTS_FILTER.equals(filterValue)); |
| | | SortedSet<String> allSuffixes = new TreeSet<>(); |
| | | SortedSet<DN> allSuffixes = new TreeSet<>(); |
| | | if (controller.getConfigurationConnection() != null) |
| | | { |
| | | treePane.getTree().setRootVisible(displayAll); |
| | |
| | | boolean added = false; |
| | | for (BackendDescriptor backend : getInfo().getServerDescriptor().getBackends()) |
| | | { |
| | | for (BaseDNDescriptor baseDN : backend.getBaseDns()) |
| | | for (BaseDNDescriptor baseDNDescriptor : backend.getBaseDns()) |
| | | { |
| | | boolean isBaseDN = baseDN.getDn().equals(theDN); |
| | | String dn = Utilities.unescapeUtf8(baseDN.getDn().toString()); |
| | | DN baseDN = baseDNDescriptor.getDn(); |
| | | boolean isBaseDN = baseDN.equals(theDN); |
| | | if (displayAll) |
| | | { |
| | | allSuffixes.add(dn); |
| | | allSuffixes.add(baseDN); |
| | | } |
| | | else if (isBaseDN) |
| | | { |
| | | controller.addSuffix(dn, null); |
| | | controller.addSuffix(baseDN, null); |
| | | added = true; |
| | | } |
| | | } |
| | | } |
| | | if (displayAll) |
| | | { |
| | | allSuffixes.add(ServerConstants.DN_EXTERNAL_CHANGELOG_ROOT); |
| | | for (String dn : allSuffixes) |
| | | allSuffixes.add(DN.valueOf(ServerConstants.DN_EXTERNAL_CHANGELOG_ROOT)); |
| | | for (DN baseDN : allSuffixes) |
| | | { |
| | | controller.addSuffix(dn, null); |
| | | controller.addSuffix(baseDN, null); |
| | | } |
| | | } |
| | | else if (!added && !displayAll) |
| | |
| | | if (isChangeLog(theDN)) |
| | | { |
| | | // Consider it a suffix |
| | | controller.addSuffix(s, null); |
| | | controller.addSuffix(theDN, null); |
| | | } |
| | | else |
| | | { |
| | | BasicNode rootNode = (BasicNode) controller.getTree().getModel().getRoot(); |
| | | if (controller.findChildNode(rootNode, s) == -1) |
| | | if (controller.findChildNode(rootNode, theDN) == -1) |
| | | { |
| | | controller.addNodeUnderRoot(s); |
| | | controller.addNodeUnderRoot(theDN); |
| | | } |
| | | } |
| | | } |
| | |
| | | boolean isSubordinate = false; |
| | | for (BackendDescriptor backend : ev.getBackends()) |
| | | { |
| | | for (BaseDNDescriptor baseDN : backend.getBaseDns()) |
| | | for (BaseDNDescriptor baseDNDescriptor : backend.getBaseDns()) |
| | | { |
| | | boolean isBaseDN = false; |
| | | if (baseDN.getDn().equals(theDN)) |
| | | DN baseDN = baseDNDescriptor.getDn(); |
| | | if (baseDN.equals(theDN)) |
| | | { |
| | | isBaseDN = true; |
| | | } |
| | | else if (baseDN.getDn().isSuperiorOrEqualTo(theDN)) |
| | | else if (baseDN.isSuperiorOrEqualTo(theDN)) |
| | | { |
| | | isSubordinate = true; |
| | | } |
| | | String dn = Utilities.unescapeUtf8(baseDN.getDn().toString()); |
| | | if (displayAll || isBaseDN) |
| | | { |
| | | try |
| | | { |
| | | if (!controller.hasSuffix(dn)) |
| | | if (!controller.hasSuffix(baseDN)) |
| | | { |
| | | controller.addSuffix(dn, null); |
| | | controller.addSuffix(baseDN, null); |
| | | } |
| | | else |
| | | { |
| | | int index = controller.findChildNode(rootNode, dn); |
| | | int index = controller.findChildNode(rootNode, baseDN); |
| | | if (index >= 0) |
| | | { |
| | | TreeNode node = rootNode.getChildAt(index); |
| | |
| | | { |
| | | // The suffix node exists but is not a suffix node. Simply log a message. |
| | | logger.warn( |
| | | LocalizableMessage.raw("Suffix: " + dn + " added as a non suffix node. Exception: " + iae, iae)); |
| | | LocalizableMessage.raw("Suffix: " + baseDN + " added as a non suffix node. Exception: " + iae, |
| | | iae)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (isSubordinate && controller.findChildNode(rootNode, s) == -1) |
| | | if (isSubordinate && controller.findChildNode(rootNode, theDN) == -1) |
| | | { |
| | | controller.addNodeUnderRoot(s); |
| | | controller.addNodeUnderRoot(theDN); |
| | | } |
| | | } |
| | | } |
| | |
| | | boolean added = false; |
| | | for (BackendDescriptor backend : getInfo().getServerDescriptor().getBackends()) |
| | | { |
| | | for (BaseDNDescriptor baseDN : backend.getBaseDns()) |
| | | for (BaseDNDescriptor baseDNDescriptor : backend.getBaseDns()) |
| | | { |
| | | String dn = Utilities.unescapeUtf8(baseDN.getDn().toString()); |
| | | boolean isBaseDN = baseDN.getDn().equals(theDN); |
| | | if (baseDN.getEntries() > 0) |
| | | DN baseDN = baseDNDescriptor.getDn(); |
| | | boolean isBaseDN = baseDN.equals(theDN); |
| | | if (baseDNDescriptor.getEntries() > 0) |
| | | { |
| | | try |
| | | { |
| | | if ((displayAll || isBaseDN) && !controller.hasSuffix(dn)) |
| | | if ((displayAll || isBaseDN) && !controller.hasSuffix(baseDN)) |
| | | { |
| | | controller.addSuffix(dn, null); |
| | | controller.addSuffix(baseDN, null); |
| | | added = true; |
| | | } |
| | | } |
| | |
| | | { |
| | | // The suffix node exists but is not a suffix node. Simply log a message. |
| | | logger.warn(LocalizableMessage.raw( |
| | | "Suffix: " + dn + " added as a non suffix node. Exception: " + iae, iae)); |
| | | "Suffix: " + baseDN + " added as a non suffix node. Exception: " + iae, iae)); |
| | | } |
| | | } |
| | | } |
| | | if (!added && !displayAll) |
| | | { |
| | | BasicNode rootNode = (BasicNode) controller.getTree().getModel().getRoot(); |
| | | if (controller.findChildNode(rootNode, s) == -1) |
| | | if (controller.findChildNode(rootNode, theDN) == -1) |
| | | { |
| | | controller.addNodeUnderRoot(s); |
| | | controller.addNodeUnderRoot(theDN); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | for (TreePath p : paths) |
| | | { |
| | | BasicNode n = (BasicNode)p.getLastPathComponent(); |
| | | if (!entryPane.canDelete(DN.valueOf(n.getDN()))) |
| | | BasicNode n = (BasicNode) p.getLastPathComponent(); |
| | | if (!entryPane.canDelete(n.getDN())) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | } |
| | | if (node != null) |
| | | { |
| | | String dn; |
| | | DN dn; |
| | | if (controller.getFollowReferrals() && |
| | | node.getReferral() != null && |
| | | node.getRemoteUrl() == null && |
| | |
| | | { |
| | | // We are in the case where we are following referrals but the referral |
| | | // could not be resolved. Display an error. |
| | | entryPane.referralSolveError(node.getDN(), node.getReferral(), |
| | | node.getError()); |
| | | entryPane.referralSolveError(node.getDN(), node.getReferral(), node.getError()); |
| | | dn = null; |
| | | } |
| | | else if (controller.getFollowReferrals() && node.getRemoteUrl() != null) |
| | | { |
| | | dn = node.getRemoteUrl().getRawBaseDN(); |
| | | dn = DN.valueOf(node.getRemoteUrl().getRawBaseDN()); |
| | | } |
| | | else |
| | | { |
| | |
| | | LinkedHashSet<DN> dns = new LinkedHashSet<>(); |
| | | for (TreePath path : paths) |
| | | { |
| | | BasicNode node = (BasicNode)path.getLastPathComponent(); |
| | | dns.add(DN.valueOf(node.getDN())); |
| | | BasicNode node = (BasicNode) path.getLastPathComponent(); |
| | | dns.add(node.getDN()); |
| | | } |
| | | if (addToGroupDlg == null) |
| | | { |
| | |
| | | |
| | | DN aParentDN; |
| | | String aRdn; |
| | | DN nodeDN = DN.valueOf(node.getDN()); |
| | | DN nodeDN = node.getDN(); |
| | | if (nodeDN.isRootDN()) |
| | | { |
| | | aParentDN = nodeDN; |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.guitools.controlpanel.browser.BasicNodeError; |
| | | import org.opends.guitools.controlpanel.browser.ReferralLimitExceededException; |
| | | import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent; |
| | |
| | | * @param dn the DN of the entry that caused a problem. |
| | | * @param t the Throwable that occurred when searching the entry. |
| | | */ |
| | | public void setError(String dn, Throwable t) |
| | | public void setError(DN dn, Throwable t) |
| | | { |
| | | LocalizableMessage title = INFO_CTRL_PANEL_ERROR_SEARCHING_ENTRY_TITLE.get(); |
| | | LocalizableMessage details; |
| | |
| | | * @param referrals the list of referrals defined in the entry. |
| | | * @param error the error that occurred resolving the referral. |
| | | */ |
| | | public void setReferralError(String dn, String[] referrals, |
| | | BasicNodeError error) |
| | | public void setReferralError(DN dn, String[] referrals, BasicNodeError error) |
| | | { |
| | | LocalizableMessage title = INFO_CTRL_PANEL_ERROR_RESOLVING_REFERRAL_TITLE.get(); |
| | | LocalizableMessageBuilder details = new LocalizableMessageBuilder(); |
| | |
| | | * @param referrals the list of referrals defined in the entry. |
| | | * @param error the error that occurred resolving the referral. |
| | | */ |
| | | public void referralSolveError(String dn, String[] referrals, |
| | | BasicNodeError error) |
| | | public void referralSolveError(DN dn, String[] referrals, BasicNodeError error) |
| | | { |
| | | searchResult = null; |
| | | |
| | |
| | | dns = new String[paths.length]; |
| | | for (int i=0; i<paths.length; i++) |
| | | { |
| | | dns[i] = ((BasicNode)paths[i].getLastPathComponent()).getDN(); |
| | | dns[i] = ((BasicNode) paths[i].getLastPathComponent()).getDN().toString(); |
| | | } |
| | | } |
| | | else |
| | |
| | | else if (comp == referenceGroup |
| | | && nodes.getNodes().length > 0) |
| | | { |
| | | String dn = nodes.getNodes()[0].getNode().getDN(); |
| | | String dn = nodes.getNodes()[0].getNode().getDN().toString(); |
| | | referenceGroup.setText(dn); |
| | | referenceGroup.setCaretPosition(dn.length()); |
| | | } |
| | |
| | | import javax.swing.JLabel; |
| | | import javax.swing.JPasswordField; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.guitools.controlpanel.browser.BrowserController; |
| | | import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent; |
| | | import org.opends.guitools.controlpanel.task.ResetUserPasswordTask; |
| | | import org.opends.guitools.controlpanel.task.Task; |
| | | import org.opends.guitools.controlpanel.ui.nodes.BasicNode; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | /** Panel that appears when the user wants to change the password of a user. */ |
| | | public class ResetUserPasswordPanel extends StatusGenericPanel |
| | |
| | | setPrimaryValid(lPassword); |
| | | setPrimaryValid(lConfirmPassword); |
| | | |
| | | dn.setText(node.getDN()); |
| | | dn.setText(node.getDN().toString()); |
| | | name.setText(node.getDisplayName()); |
| | | |
| | | password.setText(""); |
| | |
| | | JTextField tf = (JTextField)comp; |
| | | if (nodes.getNodes().length > 0) |
| | | { |
| | | String dn = nodes.getNodes()[0].getNode().getDN(); |
| | | String dn = nodes.getNodes()[0].getNode().getDN().toString(); |
| | | tf.setText(dn); |
| | | tf.setCaretPosition(dn.length()); |
| | | } |
| | |
| | | public class BasicNode extends DefaultMutableTreeNode { |
| | | |
| | | private static final long serialVersionUID = 5441658731908509872L; |
| | | private String localDn; |
| | | private DN localDn; |
| | | private String localRdn; |
| | | private String localRdnWithAttributeName; |
| | | private LDAPURL remoteUrl; |
| | |
| | | * Constructor. |
| | | * @param dn the DN of the entry. |
| | | */ |
| | | public BasicNode(String dn) { |
| | | public BasicNode(DN dn) { |
| | | localDn = dn; |
| | | localRdn = extractRDN(localDn); |
| | | localRdnWithAttributeName = extractRDN(localDn, true); |
| | | localRdn = extractRDN(localDn.toString()); |
| | | localRdnWithAttributeName = extractRDN(localDn.toString(), true); |
| | | isLeaf = true; |
| | | refreshNeededOnExpansion = true; |
| | | numSubOrdinates = -1; |
| | |
| | | * Returns the DN of the local entry. |
| | | * @return the DN of the local entry. |
| | | */ |
| | | public String getDN() { |
| | | public DN getDN() { |
| | | return localDn; |
| | | } |
| | | |
| | |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui.nodes; |
| | | |
| | | import org.forgerock.opendj.ldap.DN; |
| | | |
| | | /** |
| | | * The root node of the tree in the 'Manage Entries...' tree. It represents |
| | | * the root entry of the directory. |
| | |
| | | |
| | | /** Constructor of the node. */ |
| | | public RootNode() { |
| | | super(""); |
| | | super(DN.rootDN()); |
| | | setLeaf(false); |
| | | setRefreshNeededOnExpansion(false); |
| | | } |
| | |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui.nodes; |
| | | |
| | | import org.forgerock.opendj.ldap.DN; |
| | | |
| | | /** Represents a suffix in the tree in the 'Manage Entries...' tree. */ |
| | | public class SuffixNode extends BasicNode { |
| | | |
| | |
| | | * Constructor of the node. |
| | | * @param dn the DN of the suffix. |
| | | */ |
| | | public SuffixNode(String dn) { |
| | | public SuffixNode(DN dn) { |
| | | super(dn); |
| | | } |
| | | } |
| | |
| | | import java.util.HashSet; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.Filter; |
| | | import org.forgerock.opendj.ldap.requests.Requests; |
| | | import org.forgerock.opendj.ldap.requests.SearchRequest; |
| | | import org.forgerock.opendj.ldap.responses.SearchResultEntry; |
| | |
| | | */ |
| | | public class LDAPEntryReader extends BackgroundTask<CustomSearchResult> |
| | | { |
| | | private final String dn; |
| | | private final DN dn; |
| | | private final ConnectionWrapper conn; |
| | | private final Set<EntryReadListener> listeners = new HashSet<>(); |
| | | private boolean isOver; |
| | |
| | | * @param dn the DN of the entry. |
| | | * @param conn the connection to the server. |
| | | */ |
| | | public LDAPEntryReader(String dn, ConnectionWrapper conn) |
| | | public LDAPEntryReader(DN dn, ConnectionWrapper conn) |
| | | { |
| | | this.dn = dn; |
| | | this.conn = conn; |
| | |
| | | public CustomSearchResult processBackgroundTask() throws Throwable |
| | | { |
| | | isOver = false; |
| | | final String filter = "(|(objectclass=*)(objectclass=ldapsubentry))"; |
| | | final Filter filter = Filter.valueOf("(|(objectclass=*)(objectclass=ldapsubentry))"); |
| | | SearchRequest request = Requests.newSearchRequest(dn, BASE_OBJECT, filter, "*", "+"); |
| | | SearchResultEntry sr = conn.getConnection().searchSingleEntry(request); |
| | | if (isInterrupted()) |