| | |
| | | |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.messages.QuickSetupMessages.INFO_CERTIFICATE_EXCEPTION; |
| | | import static org.opends.messages.QuickSetupMessages.INFO_NOT_AVAILABLE_LABEL; |
| | | |
| | | import java.awt.Component; |
| | | import java.awt.GridBagConstraints; |
| | | import java.awt.GridBagLayout; |
| | |
| | | import java.util.SortedSet; |
| | | import java.util.TreeSet; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | |
| | | import javax.naming.NamingException; |
| | | import javax.naming.ldap.InitialLdapContext; |
| | | import javax.swing.BorderFactory; |
| | |
| | | import javax.swing.tree.TreeNode; |
| | | import javax.swing.tree.TreePath; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.admin.ads.util.ApplicationTrustManager; |
| | | import org.opends.admin.ads.util.ConnectionUtils; |
| | | import org.opends.guitools.controlpanel.browser.BrowserController; |
| | |
| | | import org.opends.guitools.controlpanel.ui.nodes.BasicNode; |
| | | import org.opends.guitools.controlpanel.ui.renderer.CustomListCellRenderer; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.quicksetup.UserDataCertificateException; |
| | | import org.opends.quicksetup.ui.CertificateDialog; |
| | | import org.opends.quicksetup.util.UIKeyStore; |
| | | import org.opends.quicksetup.util.Utils; |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | |
| | | /** |
| | | * The abstract class used to refactor some code. The classes that extend this |
| | | * class are the 'Browse Entries' panel and the panel of the dialog we display |
| | |
| | | private GenericDialog otherBaseDNDlg; |
| | | |
| | | private boolean firstTimeDisplayed = true; |
| | | |
| | | private Object lastSelectedBaseDN = null; |
| | | private boolean ignoreBaseDNEvents = false; |
| | | private Object lastSelectedBaseDN; |
| | | private boolean ignoreBaseDNEvents; |
| | | |
| | | /** |
| | | * LDAP filter message. |
| | |
| | | createLayout(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean requiresBorder() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean requiresScroll() |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean callConfigurationChangedInBackground() |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void setInfo(ControlPanelInfo info) |
| | | { |
| | |
| | | info.addBackendPopulatedListener(this); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final GenericDialog.ButtonType getButtonType() |
| | | { |
| | |
| | | */ |
| | | protected abstract GenericDialog.ButtonType getBrowseButtonType(); |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void toBeDisplayed(boolean visible) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected void setEnabledOK(boolean enable) |
| | | { |
| | | okButton.setEnabled(enable); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected void setEnabledCancel(boolean enable) |
| | | { |
| | |
| | | baseDNs.setRenderer(new CustomComboBoxCellRenderer(baseDNs)); |
| | | baseDNs.addItemListener(new ItemListener() |
| | | { |
| | | @Override |
| | | public void itemStateChanged(ItemEvent ev) |
| | | { |
| | | if (ignoreBaseDNEvents || (ev.getStateChange() != ItemEvent.SELECTED)) |
| | |
| | | }); |
| | | filter.addActionListener(new ActionListener() |
| | | { |
| | | @Override |
| | | public void actionPerformed(ActionEvent ev) |
| | | { |
| | | filter.displayRefreshIcon(true); |
| | |
| | | add(applyButton, gbc); |
| | | applyButton.addActionListener(new ActionListener() |
| | | { |
| | | @Override |
| | | public void actionPerformed(ActionEvent ev) |
| | | { |
| | | applyButtonClicked(); |
| | |
| | | buttonsPanel.add(closeButton, gbc); |
| | | closeButton.addActionListener(new ActionListener() |
| | | { |
| | | @Override |
| | | public void actionPerformed(ActionEvent ev) |
| | | { |
| | | closeClicked(); |
| | |
| | | buttonsPanel.add(okButton, gbc); |
| | | okButton.addActionListener(new ActionListener() |
| | | { |
| | | @Override |
| | | public void actionPerformed(ActionEvent ev) |
| | | { |
| | | okClicked(); |
| | |
| | | buttonsPanel.add(okButton, gbc); |
| | | okButton.addActionListener(new ActionListener() |
| | | { |
| | | @Override |
| | | public void actionPerformed(ActionEvent ev) |
| | | { |
| | | okClicked(); |
| | |
| | | buttonsPanel.add(cancelButton, gbc); |
| | | cancelButton.addActionListener(new ActionListener() |
| | | { |
| | | @Override |
| | | public void actionPerformed(ActionEvent ev) |
| | | { |
| | | cancelClicked(); |
| | |
| | | return buttonsPanel; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Component getPreferredFocusComponent() |
| | | { |
| | | return baseDNs; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void cancelClicked() |
| | | { |
| | |
| | | DN theDN = null; |
| | | if (s != null) |
| | | { |
| | | displayAll = s.equals(ALL_BASE_DNS); |
| | | displayAll = ALL_BASE_DNS.equals(s); |
| | | if (!displayAll) |
| | | { |
| | | try |
| | |
| | | { |
| | | for (BaseDNDescriptor baseDN : backend.getBaseDns()) |
| | | { |
| | | boolean isBaseDN = false; |
| | | if ((theDN != null) && baseDN.getDn().equals(theDN)) |
| | | { |
| | | isBaseDN = true; |
| | | } |
| | | boolean isBaseDN = baseDN.getDn().equals(theDN); |
| | | String dn = Utilities.unescapeUtf8(baseDN.getDn().toString()); |
| | | if (displayAll) |
| | | { |
| | |
| | | } |
| | | else if (USER_FILTER.equals(attr)) |
| | | { |
| | | if (s.equals("*")) |
| | | if ("*".equals(s)) |
| | | { |
| | | returnValue = "(objectClass=person)"; |
| | | } |
| | |
| | | } |
| | | else if (GROUP_FILTER.equals(attr)) |
| | | { |
| | | if (s.equals("*")) |
| | | if ("*".equals(s)) |
| | | { |
| | | returnValue = |
| | | "(|(objectClass=groupOfUniqueNames)(objectClass=groupOfURLs))"; |
| | |
| | | protected abstract Component createMainPanel(); |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void backendPopulated(BackendPopulatedEvent ev) |
| | | { |
| | | if (controller.getConfigurationConnection() != null) |
| | |
| | | String s = getBaseDN(); |
| | | if (s != null) |
| | | { |
| | | displayAll = s.equals(ALL_BASE_DNS); |
| | | displayAll = ALL_BASE_DNS.equals(s); |
| | | if (!displayAll) |
| | | { |
| | | try |
| | |
| | | for (BaseDNDescriptor baseDN : backend.getBaseDns()) |
| | | { |
| | | boolean isBaseDN = false; |
| | | if ((theDN != null) && baseDN.getDn().equals(theDN)) |
| | | if (baseDN.getDn().equals(theDN)) |
| | | { |
| | | isBaseDN = true; |
| | | } |
| | | else if ((theDN != null) && baseDN.getDn().isAncestorOf(theDN)) |
| | | else if (baseDN.getDn().isAncestorOf(theDN)) |
| | | { |
| | | isSubordinate = true; |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | if (isSubordinate) |
| | | if (isSubordinate && controller.findChildNode(rootNode, s) == -1) |
| | | { |
| | | if (controller.findChildNode(rootNode, s) == -1) |
| | | { |
| | | controller.addNodeUnderRoot(s); |
| | | } |
| | | controller.addNodeUnderRoot(s); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void configurationChanged(ConfigurationChangeEvent ev) |
| | | { |
| | | final ServerDescriptor desc = ev.getNewDescriptor(); |
| | |
| | | Utilities.setBorder(lNoMatchFound, new EmptyBorder(15, 15, 15, 15)); |
| | | p.add(lNoMatchFound, gbc); |
| | | |
| | | if ((getInfo() != null) && (controller == null)) |
| | | if (getInfo() != null && controller == null) |
| | | { |
| | | createBrowserController(getInfo()); |
| | | } |
| | |
| | | controller.setMaxChildren(MAX_NUMBER_ENTRIES); |
| | | controller.addBrowserEventListener(new BrowserEventListener() |
| | | { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void processBrowserEvent(BrowserEvent ev) |
| | | { |
| | | if (ev.getType() == BrowserEvent.Type.SIZE_LIMIT_REACHED) |
| | |
| | | }); |
| | | controller.getTreeModel().addTreeModelListener(new TreeModelListener() |
| | | { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void treeNodesChanged(TreeModelEvent e) |
| | | { |
| | | } |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void treeNodesInserted(TreeModelEvent e) |
| | | { |
| | | checkRootNode(); |
| | | } |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void treeNodesRemoved(TreeModelEvent e) |
| | | { |
| | | checkRootNode(); |
| | | } |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void treeStructureChanged(TreeModelEvent e) |
| | | { |
| | | checkRootNode(); |
| | |
| | | }); |
| | | } |
| | | |
| | | final static String[] systemIndexes = {"aci", "dn2id", "ds-sync-hist", |
| | | static final String[] systemIndexes = {"aci", "dn2id", "ds-sync-hist", |
| | | "entryUUID", "id2children", "id2subtree"}; |
| | | private static boolean displayIndex(String name) |
| | | { |
| | |
| | | { |
| | | SwingUtilities.invokeLater(new Runnable() |
| | | { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void run() |
| | | { |
| | | Object selected = filterAttribute.getSelectedItem(); |
| | |
| | | } |
| | | } |
| | | hmBaseDNs.put(backendID, someBaseDNs); |
| | | if (backendID.equalsIgnoreCase("userRoot")) |
| | | if ("userRoot".equalsIgnoreCase(backendID)) |
| | | { |
| | | for (String baseDN : someBaseDNs) |
| | | { |
| | |
| | | baseDNNewElements.add(COMBO_SEPARATOR); |
| | | baseDNNewElements.add(OTHER_BASE_DN); |
| | | } |
| | | if (firstTimeDisplayed && (baseDNWithEntries != null)) |
| | | if (firstTimeDisplayed && baseDNWithEntries != null) |
| | | { |
| | | ignoreBaseDNEvents = true; |
| | | } |
| | | updateComboBoxModel(baseDNNewElements, |
| | | (DefaultComboBoxModel)baseDNs.getModel()); |
| | | // Select the element in the combo box. |
| | | if (firstTimeDisplayed && (baseDNWithEntries != null)) |
| | | if (firstTimeDisplayed && baseDNWithEntries != null) |
| | | { |
| | | final Object toSelect = new CategorizedComboBoxElement( |
| | | Utilities.unescapeUtf8(baseDNWithEntries.getDn().toString()), |
| | | CategorizedComboBoxElement.Type.REGULAR); |
| | | SwingUtilities.invokeLater(new Runnable() |
| | | { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void run() |
| | | { |
| | | // After this updateBrowseController is called. |
| | |
| | | LocalizableMessageBuilder mb = new LocalizableMessageBuilder(); |
| | | mb.append( |
| | | INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_TO_BROWSE_SUMMARY.get()); |
| | | mb.append("<br><br>"+getAuthenticateHTML()); |
| | | mb.append("<br><br>").append(getAuthenticateHTML()); |
| | | errorDetails = mb.toMessage(); |
| | | errorTitle = INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_SUMMARY.get(); |
| | | |
| | |
| | | final NamingException[] fNe = {null}; |
| | | Runnable runnable = new Runnable() |
| | | { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void run() |
| | | { |
| | | try |
| | |
| | | LocalizableMessageBuilder mb = new LocalizableMessageBuilder(); |
| | | mb.append(INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get( |
| | | desc.getHostname())); |
| | | mb.append("<br><br>"+getAuthenticateHTML()); |
| | | mb.append("<br><br>").append(getAuthenticateHTML()); |
| | | errorDetails = mb.toMessage(); |
| | | errorTitle = INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_SUMMARY.get(); |
| | | displayErrorPane = true; |
| | |
| | | final LocalizableMessage fErrorDetails = errorDetails; |
| | | SwingUtilities.invokeLater(new Runnable() |
| | | { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void run() |
| | | { |
| | | applyButton.setEnabled(!fDisplayErrorPane); |
| | |
| | | { |
| | | dn = null; |
| | | } |
| | | if (dn != null) |
| | | if (dn != null && dn.trim().length() == 0) |
| | | { |
| | | if (dn.trim().length() == 0) |
| | | { |
| | | dn = ALL_BASE_DNS; |
| | | } |
| | | // The following is never true. OTHER_BASE_DN is a LocalizableMessage |
| | | // Comment out buggy code |
| | | // else if (OTHER_BASE_DN.equals(dn)) |
| | | // { |
| | | // dn = null; |
| | | // } |
| | | dn = ALL_BASE_DNS; |
| | | } |
| | | return dn; |
| | | } |
| | |
| | | } |
| | | catch (NamingException ne) |
| | | { |
| | | if (Utils.isCertificateException(ne)) |
| | | if (isCertificateException(ne)) |
| | | { |
| | | ApplicationTrustManager.Cause cause = |
| | | getInfo().getTrustManager().getLastRefusedCause(); |
| | |
| | | { |
| | | SwingUtilities.invokeAndWait(new Runnable() |
| | | { |
| | | @Override |
| | | public void run() |
| | | { |
| | | try |
| | |
| | | String authType = ce.getAuthType(); |
| | | String host = ce.getHost(); |
| | | |
| | | if ((chain != null) && (authType != null) && (host != null)) |
| | | if (chain != null && authType != null && host != null) |
| | | { |
| | | logger.info(LocalizableMessage.raw("Accepting certificate presented by host "+host)); |
| | | getInfo().getTrustManager().acceptCertificate(chain, authType, host); |
| | |
| | | super(combo); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Component getListCellRendererComponent(JList list, Object value, |
| | | int index, boolean isSelected, boolean cellHasFocus) |
| | |
| | | recalculate = false; |
| | | SwingUtilities.invokeLater(new Runnable() |
| | | { |
| | | @Override |
| | | public void run() |
| | | { |
| | | int nEntries = 0; |
| | |
| | | { |
| | | SwingUtilities.invokeLater(new Runnable() |
| | | { |
| | | @Override |
| | | public void run() |
| | | { |
| | | filter.displayRefreshIcon(mustDisplayRefreshIcon); |