| | |
| | | import java.util.TreeSet; |
| | | |
| | | import org.opends.admin.ads.ADSContext; |
| | | import org.opends.server.backends.jeb.RemoveOnceLocalDBBackendIsPluggable; |
| | | |
| | | /** The class that describes the backend configuration. */ |
| | | public class BackendDescriptor |
| | |
| | | /** The backend is a backup backend. */ |
| | | BACKUP, |
| | | /** The backend is a local backend. */ |
| | | @RemoveOnceLocalDBBackendIsPluggable |
| | | LOCAL_DB, |
| | | /** The backend is a LDIF backend. */ |
| | | LDIF, |
| | |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.datamodel; |
| | | |
| | | import static org.opends.server.backends.pluggable.SuffixContainer.*; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.Set; |
| | | import java.util.SortedSet; |
| | | import java.util.TreeSet; |
| | |
| | | public class IndexDescriptor extends AbstractIndexDescriptor |
| | | { |
| | | |
| | | private static final String[] DATABASE_INDEXES = new String[] {"dn2id", "id2children", "id2subtree"}; |
| | | private static final String[] DATABASE_INDEXES = new String[] { |
| | | DN2ID_INDEX_NAME, ID2CHILDREN_INDEX_NAME, ID2SUBTREE_INDEX_NAME }; |
| | | |
| | | private final SortedSet<IndexTypeDescriptor> types = new TreeSet<IndexTypeDescriptor>(); |
| | | private final boolean isDatabaseIndex; |
| | |
| | | /** |
| | | * Constructor of the index descriptor. |
| | | * |
| | | * @param indexName |
| | | * name of the index. |
| | | */ |
| | | public IndexDescriptor(String indexName) |
| | | { |
| | | this(indexName, null, null, Collections.EMPTY_SET, -1); |
| | | } |
| | | |
| | | /** |
| | | * Constructor of the index descriptor. |
| | | * |
| | | * @param name |
| | | * name of the index. |
| | | * @param attr |
| | |
| | | * @param entryLimit |
| | | * the entry limit for the index. |
| | | */ |
| | | public IndexDescriptor(String name, AttributeType attr, |
| | | BackendDescriptor backend, |
| | | Set<IndexTypeDescriptor> types, int entryLimit) |
| | | public IndexDescriptor( |
| | | String name, AttributeType attr, BackendDescriptor backend, Set<IndexTypeDescriptor> types, int entryLimit) |
| | | { |
| | | super(name, backend); |
| | | this.attr = attr; |
| | |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | |
| | | |
| | | private boolean backendIdEqual(IndexDescriptor index) |
| | | { |
| | | return getBackend() != null |
| | | && index.getBackend() != null |
| | | && getBackend().getBackendID().equals(index.getBackend().getBackendID()); |
| | | BackendDescriptor backend1 = getBackend(); |
| | | BackendDescriptor backend2 = index.getBackend(); |
| | | return backend1 != null && backend2 != null && backend1.getBackendID().equals(backend2.getBackendID()); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | hashCode = (getName()+sb+entryLimit).hashCode(); |
| | | } |
| | | |
| | | } |
| | |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | |
| | | import java.awt.GridBagConstraints; |
| | | import java.awt.event.ItemEvent; |
| | | import java.awt.event.ItemListener; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.Iterator; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.SortedSet; |
| | |
| | | import javax.swing.ListCellRenderer; |
| | | import javax.swing.SwingUtilities; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.guitools.controlpanel.datamodel.AbstractIndexDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.BackendDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.CategorizedComboBoxElement; |
| | |
| | | import org.opends.guitools.controlpanel.ui.renderer.IndexCellRenderer; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.guitools.controlpanel.util.ViewPositions; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | /** |
| | | * The panel that appears when the user wants to rebuild indexes. |
| | |
| | | private final Map<String, SortedSet<AbstractIndexDescriptor>> hmIndexes = |
| | | new HashMap<String, SortedSet<AbstractIndexDescriptor>>(); |
| | | |
| | | /** |
| | | * Constructor of the panel. |
| | | */ |
| | | /** Constructor of the panel. */ |
| | | public RebuildIndexPanel() |
| | | { |
| | | super(); |
| | | createLayout(); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public void configurationChanged(final ConfigurationChangeEvent ev) |
| | | { |
| | | ServerDescriptor desc = ev.getNewDescriptor(); |
| | | refreshContents(desc); |
| | | refreshContents(ev.getNewDescriptor()); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | updateBaseDNComboBoxModel((DefaultComboBoxModel) baseDNs.getModel(), desc); |
| | | |
| | | // Check that all backends |
| | | boolean allDisabled = false; |
| | | for (BackendDescriptor backend : desc.getBackends()) |
| | | { |
| | | if (displayBackend(backend) && backend.isEnabled()) |
| | | { |
| | | allDisabled = false; |
| | | break; |
| | | } |
| | | } |
| | | if (!allDisabled) |
| | | if (!allDisabled(desc.getBackends())) |
| | | { |
| | | updateErrorPaneAndOKButtonIfAuthRequired(desc, |
| | | isLocal() ? INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_DISABLE_BACKEND.get() |
| | |
| | | }); |
| | | } |
| | | |
| | | private boolean allDisabled(Set<BackendDescriptor> backends) |
| | | { |
| | | for (BackendDescriptor backend : backends) |
| | | { |
| | | if (displayBackend(backend) && backend.isEnabled()) |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void cancelClicked() |
| | |
| | | |
| | | private String getSelectedBaseDN() |
| | | { |
| | | String dn = null; |
| | | CategorizedComboBoxElement o = (CategorizedComboBoxElement) baseDNs.getSelectedItem(); |
| | | if (o != null) |
| | | { |
| | | dn = (String) o.getValue(); |
| | | } |
| | | return dn; |
| | | return o != null ? (String) o.getValue() : null; |
| | | } |
| | | |
| | | private void filterIndexes(final Map<String, SortedSet<AbstractIndexDescriptor>> hmIndexes) |
| | |
| | | // Remove the indexes that are not to be added. |
| | | for (SortedSet<AbstractIndexDescriptor> indexes : hmIndexes.values()) |
| | | { |
| | | List<AbstractIndexDescriptor> toRemove = new ArrayList<AbstractIndexDescriptor>(); |
| | | for (AbstractIndexDescriptor index : indexes) |
| | | for (Iterator<AbstractIndexDescriptor> it = indexes.iterator(); it.hasNext();) |
| | | { |
| | | if (!mustBeDisplayed(index)) |
| | | if (!mustBeDisplayed(it.next())) |
| | | { |
| | | toRemove.add(index); |
| | | it.remove(); |
| | | } |
| | | } |
| | | indexes.removeAll(toRemove); |
| | | } |
| | | } |
| | | |
| | | private boolean mustBeDisplayed(final AbstractIndexDescriptor index) |
| | | { |
| | | boolean mustBeDisplayed = true; |
| | | if (index instanceof IndexDescriptor) |
| | | { |
| | | for (String name : RebuildIndexTask.INDEXES_NOT_TO_SPECIFY) |
| | | { |
| | | if (name.equalsIgnoreCase(index.getName())) |
| | | { |
| | | mustBeDisplayed = false; |
| | | break; |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | return mustBeDisplayed; |
| | | return true; |
| | | } |
| | | } |
| | |
| | | import javax.naming.directory.SearchControls; |
| | | import javax.naming.directory.SearchResult; |
| | | import javax.swing.Box; |
| | | import javax.swing.ComboBoxModel; |
| | | import javax.swing.DefaultComboBoxModel; |
| | | import javax.swing.JComboBox; |
| | | import javax.swing.JComponent; |
| | |
| | | { |
| | | if (selectedItem == null) |
| | | { |
| | | // Look for the first element that is not a category |
| | | for (int i = 0; i < combo.getModel().getSize(); i++) |
| | | { |
| | | Object item = combo.getModel().getElementAt(i); |
| | | if (item instanceof CategorizedComboBoxElement && !isCategory(item)) |
| | | { |
| | | selectedItem = item; |
| | | break; |
| | | } |
| | | } |
| | | selectedItem = firstNonCategoryItem(combo.getModel()); |
| | | } |
| | | if (selectedItem != null) |
| | | { |
| | |
| | | selectedItem = o; |
| | | } |
| | | } |
| | | |
| | | private Object firstNonCategoryItem(ComboBoxModel model) |
| | | { |
| | | for (int i = 0; i < model.getSize(); i++) |
| | | { |
| | | Object item = model.getElementAt(i); |
| | | if (item instanceof CategorizedComboBoxElement && !isCategory(item)) |
| | | { |
| | | return item; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | private void updatePane(final JEditorPane pane, final LocalizableMessage title, final Font titleFont, |
| | | final LocalizableMessage details, final Font detailsFont, final PanelType type) |
| | | { |
| | | String text; |
| | | switch (type) |
| | | { |
| | | case ERROR: |
| | | text = Utilities.getFormattedError(title, titleFont, details, detailsFont); |
| | | break; |
| | | case CONFIRMATION: |
| | | text = Utilities.getFormattedConfirmation(title, titleFont, details, detailsFont); |
| | | break; |
| | | case WARNING: |
| | | text = Utilities.getFormattedWarning(title, titleFont, details, detailsFont); |
| | | break; |
| | | default: |
| | | text = Utilities.getFormattedSuccess(title, titleFont, details, detailsFont); |
| | | break; |
| | | } |
| | | String text = getText(type, title, titleFont, details, detailsFont); |
| | | if (!text.equals(lastDisplayedError)) |
| | | { |
| | | LocalizableMessage wrappedTitle = Utilities.wrapHTML(title, 80); |
| | |
| | | } |
| | | } |
| | | |
| | | private String getText( |
| | | PanelType type, LocalizableMessage title, Font titleFont, LocalizableMessage details, Font detailsFont) |
| | | { |
| | | switch (type) |
| | | { |
| | | case ERROR: |
| | | return Utilities.getFormattedError(title, titleFont, details, detailsFont); |
| | | case CONFIRMATION: |
| | | return Utilities.getFormattedConfirmation(title, titleFont, details, detailsFont); |
| | | case WARNING: |
| | | return Utilities.getFormattedWarning(title, titleFont, details, detailsFont); |
| | | default: |
| | | return Utilities.getFormattedSuccess(title, titleFont, details, detailsFont); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Commodity method used to update the elements of a combo box that contains |
| | | * the different user backends. If no backends are found the combo box will be |
| | |
| | | import javax.swing.ListCellRenderer; |
| | | import javax.swing.SwingUtilities; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.guitools.controlpanel.datamodel.AbstractIndexDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.BackendDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.CategorizedComboBoxElement; |
| | |
| | | import org.opends.guitools.controlpanel.ui.renderer.IndexComboBoxCellRenderer; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.opends.guitools.controlpanel.util.ViewPositions; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | /** |
| | | * The panel that appears when the user wants to verify an index. |
| | |
| | | private JLabel lIndex; |
| | | private JLabel lNoBaseDNsFound; |
| | | |
| | | /** |
| | | * Constructor of the panel. |
| | | */ |
| | | /** Constructor of the panel. */ |
| | | public VerifyIndexPanel() |
| | | { |
| | | super(); |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void setInfo(ControlPanelInfo info) |
| | | { |
| | | super.setInfo(info); |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void indexModified(IndexModifiedEvent ev) |
| | | { |
| | | refreshContents(getInfo().getServerDescriptor()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void backendIndexesModified(IndexModifiedEvent ev) |
| | | { |
| | | refreshContents(getInfo().getServerDescriptor()); |
| | |
| | | baseDNs.addItemListener(listener); |
| | | baseDNs.addItemListener(new ItemListener() |
| | | { |
| | | @Override |
| | | public void itemStateChanged(ItemEvent ev) |
| | | { |
| | | comboBoxSelected(hmIndexes, (CategorizedComboBoxElement) baseDNs.getSelectedItem(), addRemove); |
| | |
| | | verifyIndexContents.setSelected(true); |
| | | listener = new ItemListener() |
| | | { |
| | | @Override |
| | | public void itemStateChanged(ItemEvent ev) |
| | | { |
| | | addRemove.setEnabled(verifyIndexContents.isSelected()); |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage getTitle() |
| | | { |
| | | return INFO_CTRL_PANEL_VERIFY_INDEXES_PANEL_TITLE.get(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Component getPreferredFocusComponent() |
| | | { |
| | | return baseDNs; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void configurationChanged(ConfigurationChangeEvent ev) |
| | | { |
| | | refreshContents(ev.getNewDescriptor()); |
| | |
| | | updateBaseDNComboBoxModel((DefaultComboBoxModel) baseDNs.getModel(), desc); |
| | | SwingUtilities.invokeLater(new Runnable() |
| | | { |
| | | @Override |
| | | public void run() |
| | | { |
| | | ViewPositions pos; |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void cancelClicked() |
| | | { |
| | | setPrimaryValid(lBaseDN); |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void okClicked() |
| | | { |
| | | setPrimaryValid(lBaseDN); |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected boolean displayBackend(BackendDescriptor backend) |
| | | { |
| | | return !backend.isConfigBackend() && (backend.getType() == BackendDescriptor.Type.LOCAL_DB |
| | |
| | | |
| | | private String getSelectedBaseDN() |
| | | { |
| | | String dn = null; |
| | | CategorizedComboBoxElement o = (CategorizedComboBoxElement) baseDNs.getSelectedItem(); |
| | | if (o != null) |
| | | { |
| | | dn = (String) o.getValue(); |
| | | } |
| | | return dn; |
| | | return o != null ? (String) o.getValue() : null; |
| | | } |
| | | |
| | | private AbstractIndexDescriptor getSelectedIndex() |
| | | { |
| | | AbstractIndexDescriptor index = null; |
| | | CategorizedComboBoxElement o = (CategorizedComboBoxElement) keyEntryIDs.getSelectedItem(); |
| | | if (o != null) |
| | | { |
| | | index = (AbstractIndexDescriptor) o.getValue(); |
| | | } |
| | | return index; |
| | | return o != null ? (AbstractIndexDescriptor) o.getValue() : null; |
| | | } |
| | | |
| | | private void updateVerifyKeyEntriesComboBox() |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Type getType() |
| | | { |
| | | return Type.VERIFY_INDEXES; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage getTaskDescription() |
| | | { |
| | | return INFO_CTRL_PANEL_VERIFY_INDEX_TASK_DESCRIPTION.get(baseDN); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean canLaunch(Task taskToBeLaunched, Collection<LocalizableMessage> incompatibilityReasons) |
| | | { |
| | | boolean canLaunch = true; |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void runTask() |
| | | { |
| | | state = State.RUNNING; |
| | |
| | | try |
| | | { |
| | | List<String> arguments = getCommandLineArguments(); |
| | | String[] args = new String[arguments.size()]; |
| | | String[] args = arguments.toArray(new String[arguments.size()]); |
| | | |
| | | arguments.toArray(args); |
| | | returnCode = executeCommandLine(getCommandLinePath(), args); |
| | | |
| | | if (returnCode != 0) |
| | | { |
| | | state = State.FINISHED_WITH_ERROR; |
| | | } |
| | | else |
| | | { |
| | | state = State.FINISHED_SUCCESSFULLY; |
| | | } |
| | | state = returnCode == 0 ? State.FINISHED_SUCCESSFULLY : State.FINISHED_WITH_ERROR; |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected List<String> getCommandLineArguments() |
| | | { |
| | | List<String> args = new ArrayList<String>(); |
| | |
| | | for (AbstractIndexDescriptor index : model.getData()) |
| | | { |
| | | args.add("--index"); |
| | | if (index instanceof VLVIndexDescriptor) |
| | | { |
| | | args.add(Utilities.getVLVNameInCommandLine((VLVIndexDescriptor) index)); |
| | | } |
| | | else |
| | | { |
| | | args.add(index.getName()); |
| | | } |
| | | args.add(getName(index)); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | args.add("--index"); |
| | | AbstractIndexDescriptor index = getSelectedIndex(); |
| | | if (index instanceof VLVIndexDescriptor) |
| | | { |
| | | args.add(Utilities.getVLVNameInCommandLine((VLVIndexDescriptor) index)); |
| | | } |
| | | else |
| | | { |
| | | args.add(index.getName()); |
| | | } |
| | | getName(getSelectedIndex()); |
| | | args.add("--clean"); |
| | | } |
| | | |
| | |
| | | return args; |
| | | } |
| | | |
| | | private String getName(AbstractIndexDescriptor index) |
| | | { |
| | | if (index instanceof VLVIndexDescriptor) |
| | | { |
| | | return Utilities.getVLVNameInCommandLine((VLVIndexDescriptor) index); |
| | | } |
| | | return index.getName(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected String getCommandLinePath() |
| | | { |
| | | return getCommandLinePath("verify-index"); |
| | |
| | | package org.opends.guitools.controlpanel.util; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.server.backends.pluggable.SuffixContainer.*; |
| | | |
| | | import java.net.InetAddress; |
| | | import java.text.DateFormat; |
| | |
| | | import org.opends.server.admin.std.client.SNMPConnectionHandlerCfgClient; |
| | | import org.opends.server.admin.std.client.TaskBackendCfgClient; |
| | | import org.opends.server.backends.jeb.RemoveOnceLocalDBBackendIsPluggable; |
| | | import org.opends.server.backends.pluggable.SuffixContainer; |
| | | import org.opends.server.config.ConfigConstants; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.tools.tasks.TaskEntry; |
| | |
| | | private void readBackendIndexes(final Set<IndexDescriptor> indexes, final List<OpenDsException> errors, |
| | | final PluggableBackendCfgClient db) |
| | | { |
| | | indexes.add(new IndexDescriptor( |
| | | SuffixContainer.DN2ID_INDEX_NAME, null, null, new TreeSet<IndexTypeDescriptor>(), -1)); |
| | | indexes.add(new IndexDescriptor(DN2ID_INDEX_NAME)); |
| | | // FIXME: Remove the two following indexes when they will be deleted |
| | | indexes.add(new IndexDescriptor( |
| | | SuffixContainer.ID2CHILDREN_INDEX_NAME, null, null, new TreeSet<IndexTypeDescriptor>(), -1)); |
| | | indexes.add(new IndexDescriptor( |
| | | SuffixContainer.ID2SUBTREE_INDEX_NAME, null, null, new TreeSet<IndexTypeDescriptor>(), -1)); |
| | | indexes.add(new IndexDescriptor(ID2CHILDREN_INDEX_NAME)); |
| | | indexes.add(new IndexDescriptor(ID2SUBTREE_INDEX_NAME)); |
| | | try |
| | | { |
| | | for (final String indexName : db.listBackendIndexes()) |
| | |
| | | errors.add(oe); |
| | | } |
| | | |
| | | indexes.add(new IndexDescriptor( |
| | | SuffixContainer.DN2ID_INDEX_NAME, null, null, new TreeSet<IndexTypeDescriptor>(), -1)); |
| | | indexes.add(new IndexDescriptor(DN2ID_INDEX_NAME)); |
| | | if (localDBBackend.isSubordinateIndexesEnabled()) |
| | | { |
| | | indexes.add(new IndexDescriptor( |
| | | SuffixContainer.ID2CHILDREN_INDEX_NAME, null, null, new TreeSet<IndexTypeDescriptor>(), -1)); |
| | | indexes.add(new IndexDescriptor( |
| | | SuffixContainer.ID2SUBTREE_INDEX_NAME, null, null, new TreeSet<IndexTypeDescriptor>(), -1)); |
| | | indexes.add(new IndexDescriptor(ID2CHILDREN_INDEX_NAME)); |
| | | indexes.add(new IndexDescriptor(ID2SUBTREE_INDEX_NAME)); |
| | | } |
| | | |
| | | try |
| | |
| | | * Copyright 2008-2011 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.util; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.server.backends.pluggable.SuffixContainer.*; |
| | | |
| | | import java.net.InetAddress; |
| | | import java.util.ArrayList; |
| | |
| | | import org.opends.server.admin.std.server.BackendVLVIndexCfg; |
| | | import org.opends.server.admin.std.server.BackupBackendCfg; |
| | | import org.opends.server.admin.std.server.ConnectionHandlerCfg; |
| | | import org.opends.server.admin.std.server.CryptoManagerCfg; |
| | | import org.opends.server.admin.std.server.HTTPConnectionHandlerCfg; |
| | | import org.opends.server.admin.std.server.JMXConnectionHandlerCfg; |
| | | import org.opends.server.admin.std.server.LDAPConnectionHandlerCfg; |
| | |
| | | import org.opends.server.admin.std.server.RootDNUserCfg; |
| | | import org.opends.server.admin.std.server.SNMPConnectionHandlerCfg; |
| | | import org.opends.server.admin.std.server.TaskBackendCfg; |
| | | import org.opends.server.backends.pluggable.SuffixContainer; |
| | | import org.opends.server.backends.jeb.RemoveOnceLocalDBBackendIsPluggable; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.OpenDsException; |
| | |
| | | if (backend instanceof LocalDBBackendCfg) |
| | | { |
| | | type = BackendDescriptor.Type.LOCAL_DB; |
| | | final LocalDBBackendCfg db = (LocalDBBackendCfg) backend; |
| | | try |
| | | { |
| | | for (final String indexName : db.listLocalDBIndexes()) |
| | | { |
| | | final LocalDBIndexCfg index = db.getLocalDBIndex(indexName); |
| | | indexes.add(new IndexDescriptor(index.getAttribute().getNameOrOID(), index.getAttribute(), null, |
| | | IndexTypeDescriptor.fromLocalDBIndexTypes(index.getIndexType()), index.getIndexEntryLimit())); |
| | | } |
| | | } |
| | | catch (final ConfigException ce) |
| | | { |
| | | errors.add(toConfigException(ce)); |
| | | } |
| | | indexes.add(new IndexDescriptor( |
| | | SuffixContainer.DN2ID_INDEX_NAME, null, null, new TreeSet<IndexTypeDescriptor>(), -1)); |
| | | if (db.isSubordinateIndexesEnabled()) |
| | | { |
| | | indexes.add(new IndexDescriptor( |
| | | SuffixContainer.ID2CHILDREN_INDEX_NAME, null, null, new TreeSet<IndexTypeDescriptor>(), -1)); |
| | | indexes.add(new IndexDescriptor( |
| | | SuffixContainer.ID2SUBTREE_INDEX_NAME, null, null, new TreeSet<IndexTypeDescriptor>(), -1)); |
| | | } |
| | | |
| | | try |
| | | { |
| | | for (final String vlvIndexName : db.listLocalDBVLVIndexes()) |
| | | { |
| | | final LocalDBVLVIndexCfg index = db.getLocalDBVLVIndex(vlvIndexName); |
| | | final String s = index.getSortOrder(); |
| | | final List<VLVSortOrder> sortOrder = getVLVSortOrder(s); |
| | | vlvIndexes.add(new VLVIndexDescriptor( |
| | | index.getName(), null, index.getBaseDN(), VLVIndexDescriptor.toSearchScope(index.getScope()), |
| | | index.getFilter(), sortOrder)); |
| | | } |
| | | } |
| | | catch (final ConfigException ce) |
| | | { |
| | | errors.add(toConfigException(ce)); |
| | | } |
| | | refreshLocalDBBackendConfig(errors, backend, indexes, vlvIndexes); |
| | | } |
| | | else if (backend instanceof PluggableBackendCfg) |
| | | { |
| | |
| | | private void readBackendIndexes(final Set<IndexDescriptor> indexes, final List<OpenDsException> errors, |
| | | final PluggableBackendCfg db) |
| | | { |
| | | indexes.add(new IndexDescriptor( |
| | | SuffixContainer.DN2ID_INDEX_NAME, null, null, new TreeSet<IndexTypeDescriptor>(), -1)); |
| | | indexes.add(new IndexDescriptor(DN2ID_INDEX_NAME)); |
| | | // FIXME: Remove the two following indexes when they will be deleted |
| | | indexes.add(new IndexDescriptor( |
| | | SuffixContainer.ID2CHILDREN_INDEX_NAME, null, null, new TreeSet<IndexTypeDescriptor>(), -1)); |
| | | indexes.add(new IndexDescriptor( |
| | | SuffixContainer.ID2SUBTREE_INDEX_NAME, null, null, new TreeSet<IndexTypeDescriptor>(), -1)); |
| | | indexes.add(new IndexDescriptor(ID2CHILDREN_INDEX_NAME)); |
| | | indexes.add(new IndexDescriptor(ID2SUBTREE_INDEX_NAME)); |
| | | try |
| | | { |
| | | for (final String indexName : db.listBackendIndexes()) |
| | |
| | | } |
| | | } |
| | | |
| | | private boolean readIfReplicationIsSecure(final RootCfg root, final List<OpenDsException> errors) |
| | | @RemoveOnceLocalDBBackendIsPluggable |
| | | private void refreshLocalDBBackendConfig(final List<OpenDsException> errors, final BackendCfg backend, |
| | | final Set<IndexDescriptor> indexes, final Set<VLVIndexDescriptor> vlvIndexes) |
| | | { |
| | | boolean isReplicationSecure = false; |
| | | final LocalDBBackendCfg db = (LocalDBBackendCfg) backend; |
| | | try |
| | | { |
| | | final CryptoManagerCfg cryptoManager = root.getCryptoManager(); |
| | | isReplicationSecure = cryptoManager.isSSLEncryption(); |
| | | for (final String indexName : db.listLocalDBIndexes()) |
| | | { |
| | | final LocalDBIndexCfg index = db.getLocalDBIndex(indexName); |
| | | indexes.add(new IndexDescriptor(index.getAttribute().getNameOrOID(), index.getAttribute(), null, |
| | | IndexTypeDescriptor.fromLocalDBIndexTypes(index.getIndexType()), index.getIndexEntryLimit())); |
| | | } |
| | | } |
| | | catch (final ConfigException ce) |
| | | { |
| | | errors.add(toConfigException(ce)); |
| | | } |
| | | return isReplicationSecure; |
| | | indexes.add(new IndexDescriptor(DN2ID_INDEX_NAME)); |
| | | if (db.isSubordinateIndexesEnabled()) |
| | | { |
| | | indexes.add(new IndexDescriptor(ID2CHILDREN_INDEX_NAME)); |
| | | indexes.add(new IndexDescriptor(ID2SUBTREE_INDEX_NAME)); |
| | | } |
| | | |
| | | try |
| | | { |
| | | for (final String vlvIndexName : db.listLocalDBVLVIndexes()) |
| | | { |
| | | final LocalDBVLVIndexCfg index = db.getLocalDBVLVIndex(vlvIndexName); |
| | | final String s = index.getSortOrder(); |
| | | final List<VLVSortOrder> sortOrder = getVLVSortOrder(s); |
| | | vlvIndexes.add(new VLVIndexDescriptor(index.getName(), null, index.getBaseDN(), VLVIndexDescriptor |
| | | .toSearchScope(index.getScope()), index.getFilter(), sortOrder)); |
| | | } |
| | | } |
| | | catch (final ConfigException ce) |
| | | { |
| | | errors.add(toConfigException(ce)); |
| | | } |
| | | } |
| | | |
| | | private boolean readIfReplicationIsSecure(final RootCfg root, final List<OpenDsException> errors) |
| | | { |
| | | try |
| | | { |
| | | return root.getCryptoManager().isSSLEncryption(); |
| | | } |
| | | catch (final ConfigException ce) |
| | | { |
| | | errors.add(toConfigException(ce)); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | private ReplicationSynchronizationProviderCfg readSyncProviderIfExists(final RootCfg root) |
| | | { |
| | | replicationPort = -1; |
| | | ReplicationSynchronizationProviderCfg sync = null; |
| | | try |
| | | { |
| | | sync = (ReplicationSynchronizationProviderCfg) root.getSynchronizationProvider("Multimaster Synchronization"); |
| | | return (ReplicationSynchronizationProviderCfg) root.getSynchronizationProvider("Multimaster Synchronization"); |
| | | } |
| | | catch (final ConfigException ce) |
| | | { |
| | | // Ignore this one |
| | | return null; |
| | | } |
| | | return sync; |
| | | } |
| | | |
| | | private void readReplicationConfig(final Set<ConnectionHandlerDescriptor> connectionHandlers, |
| | |
| | | public void initializeKeyManagerProvider( |
| | | FileBasedKeyManagerProviderCfg configuration) |
| | | throws ConfigException, InitializationException { |
| | | // Store the DN of the configuration entry and register as a change |
| | | // listener. |
| | | // Store the DN of the configuration entry and register as a change listener |
| | | currentConfig = configuration; |
| | | configEntryDN = configuration.dn(); |
| | | configuration.addFileBasedChangeListener(this); |
| | |
| | | throw new InitializationException(message); |
| | | } |
| | | |
| | | String pinStr; |
| | | try { |
| | | BufferedReader br = new BufferedReader( |
| | | new FileReader(pinFile)); |
| | | pinStr = br.readLine(); |
| | | br.close(); |
| | | } catch (IOException ioe) { |
| | | LocalizableMessage message = ERR_FILE_KEYMANAGER_PIN_FILE_CANNOT_READ. |
| | | get(fileName, configEntryDN, getExceptionMessage(ioe)); |
| | | throw new InitializationException(message, ioe); |
| | | } |
| | | |
| | | String pinStr = readPinFromFile(fileName, pinFile); |
| | | if (pinStr == null) { |
| | | LocalizableMessage message = ERR_FILE_KEYMANAGER_PIN_FILE_EMPTY.get(fileName, configEntryDN); |
| | | throw new InitializationException(message); |
| | |
| | | } |
| | | } |
| | | |
| | | private String readPinFromFile(String fileName, File pinFile) throws InitializationException |
| | | { |
| | | BufferedReader br = null; |
| | | try |
| | | { |
| | | br = new BufferedReader(new FileReader(pinFile)); |
| | | return br.readLine(); |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_FILE_KEYMANAGER_PIN_FILE_CANNOT_READ.get(fileName, configEntryDN, getExceptionMessage(ioe)); |
| | | throw new InitializationException(message, ioe); |
| | | } |
| | | finally |
| | | { |
| | | close(br); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Performs any finalization that may be necessary for this key |
| | | * manager provider. |
| | | */ |
| | | /** Performs any finalization that may be necessary for this key manager provider. */ |
| | | @Override |
| | | public void finalizeKeyManagerProvider() |
| | | { |
| | | currentConfig.removeFileBasedChangeListener(this); |
| | |
| | | * @throws DirectoryException If a problem occurs while attempting to obtain |
| | | * the set of key managers. |
| | | */ |
| | | public KeyManager[] getKeyManagers() |
| | | throws DirectoryException |
| | | @Override |
| | | public KeyManager[] getKeyManagers() throws DirectoryException |
| | | { |
| | | KeyStore keyStore; |
| | | try |
| | |
| | | |
| | | FileInputStream inputStream = |
| | | new FileInputStream(getFileForPath(keyStoreFile)); |
| | | keyStore.load(inputStream, keyStorePIN); |
| | | inputStream.close(); |
| | | try |
| | | { |
| | | keyStore.load(inputStream, keyStorePIN); |
| | | } |
| | | finally |
| | | { |
| | | close(inputStream); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | |
| | | try { |
| | | // Troubleshooting aid; Analyse the keystore for the presence of at least one private entry. |
| | | boolean foundOneKeyEntry = false; |
| | | Enumeration<String> aliases = keyStore.aliases(); |
| | | while (aliases.hasMoreElements()) { |
| | | String alias = aliases.nextElement(); |
| | | if (keyStore.entryInstanceOf(alias, KeyStore.PrivateKeyEntry.class)) { |
| | | foundOneKeyEntry = true; |
| | | break; |
| | | } |
| | | } |
| | | if (!foundOneKeyEntry) { |
| | | if (!findOneKeyEntry(keyStore)) |
| | | { |
| | | logger.warn(INFO_NO_KEY_ENTRY_IN_KEYSTORE, keyStoreFile); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | private boolean findOneKeyEntry(KeyStore keyStore) throws KeyStoreException |
| | | { |
| | | Enumeration<String> aliases = keyStore.aliases(); |
| | | while (aliases.hasMoreElements()) |
| | | { |
| | | String alias = aliases.nextElement(); |
| | | if (keyStore.entryInstanceOf(alias, KeyStore.PrivateKeyEntry.class)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | FileBasedKeyManagerProviderCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | | { |
| | | boolean configAcceptable = true; |
| | | int startSize = unacceptableReasons.size(); |
| | | DN cfgEntryDN = configuration.dn(); |
| | | |
| | | |
| | |
| | | if (!f.exists() || !f.isFile()) |
| | | { |
| | | unacceptableReasons.add(ERR_FILE_KEYMANAGER_NO_SUCH_FILE.get(newKeyStoreFile, cfgEntryDN)); |
| | | configAcceptable = false; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | |
| | | logger.traceException(e); |
| | | |
| | | unacceptableReasons.add(ERR_FILE_KEYMANAGER_CANNOT_DETERMINE_FILE.get(cfgEntryDN, getExceptionMessage(e))); |
| | | configAcceptable = false; |
| | | } |
| | | |
| | | // Get the keystore type. If none is specified, then use the default type. |
| | |
| | | |
| | | unacceptableReasons.add(ERR_FILE_KEYMANAGER_INVALID_TYPE.get( |
| | | configuration.getKeyStoreType(), cfgEntryDN, getExceptionMessage(kse))); |
| | | configAcceptable = false; |
| | | } |
| | | } |
| | | |
| | |
| | | if (pinStr == null) |
| | | { |
| | | unacceptableReasons.add(ERR_FILE_KEYMANAGER_PIN_PROPERTY_NOT_SET.get(propertyName, cfgEntryDN)); |
| | | configAcceptable = false; |
| | | } |
| | | } |
| | | else if (configuration.getKeyStorePinEnvironmentVariable() != null) |
| | |
| | | if (pinStr == null) |
| | | { |
| | | unacceptableReasons.add(ERR_FILE_KEYMANAGER_PIN_ENVAR_NOT_SET.get(enVarName, cfgEntryDN)); |
| | | configAcceptable = false; |
| | | } |
| | | } |
| | | else if (configuration.getKeyStorePinFile() != null) |
| | |
| | | if (!pinFile.exists()) |
| | | { |
| | | unacceptableReasons.add(ERR_FILE_KEYMANAGER_PIN_NO_SUCH_FILE.get(fileName, cfgEntryDN)); |
| | | configAcceptable = false; |
| | | } |
| | | else |
| | | { |
| | | String pinStr = null; |
| | | BufferedReader br = null; |
| | | try { |
| | | br = new BufferedReader(new FileReader(pinFile)); |
| | | pinStr = br.readLine(); |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | unacceptableReasons.add(ERR_FILE_KEYMANAGER_PIN_FILE_CANNOT_READ.get( |
| | | fileName, cfgEntryDN, getExceptionMessage(ioe))); |
| | | configAcceptable = false; |
| | | } |
| | | finally |
| | | { |
| | | close(br); |
| | | } |
| | | |
| | | String pinStr = readPinFromFile(pinFile, fileName, cfgEntryDN, unacceptableReasons); |
| | | if (pinStr == null) |
| | | { |
| | | unacceptableReasons.add(ERR_FILE_KEYMANAGER_PIN_FILE_EMPTY.get(fileName, cfgEntryDN)); |
| | | configAcceptable = false; |
| | | } |
| | | } |
| | | } |
| | |
| | | if (pinStr == null) |
| | | { |
| | | unacceptableReasons.add(ERR_FILE_KEYMANAGER_CANNOT_DETERMINE_PIN_FROM_ATTR.get(cfgEntryDN, null)); |
| | | configAcceptable = false; |
| | | } |
| | | } |
| | | |
| | | return configAcceptable; |
| | | return startSize != unacceptableReasons.size(); |
| | | } |
| | | |
| | | |
| | | private String readPinFromFile(File pinFile, String fileName, DN cfgEntryDN, |
| | | List<LocalizableMessage> unacceptableReasons) |
| | | { |
| | | BufferedReader br = null; |
| | | try |
| | | { |
| | | br = new BufferedReader(new FileReader(pinFile)); |
| | | return br.readLine(); |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | unacceptableReasons.add( |
| | | ERR_FILE_KEYMANAGER_PIN_FILE_CANNOT_READ.get(fileName, cfgEntryDN, getExceptionMessage(ioe))); |
| | | return null; |
| | | } |
| | | finally |
| | | { |
| | | close(br); |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | FileBasedKeyManagerProviderCfg configuration) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | String pinStr = null; |
| | | BufferedReader br = null; |
| | | try { |
| | | br = new BufferedReader(new FileReader(pinFile)); |
| | | pinStr = br.readLine(); |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | ccr.setResultCode(DirectoryServer.getServerErrorResultCode()); |
| | | ccr.addMessage(ERR_FILE_KEYMANAGER_PIN_FILE_CANNOT_READ.get( |
| | | fileName, configEntryDN, getExceptionMessage(ioe))); |
| | | } |
| | | finally |
| | | { |
| | | close(br); |
| | | } |
| | | |
| | | String pinStr = readPinFromFile(pinFile, fileName, ccr); |
| | | if (pinStr == null) |
| | | { |
| | | ccr.setResultCode(DirectoryServer.getServerErrorResultCode()); |
| | |
| | | |
| | | return ccr; |
| | | } |
| | | |
| | | private String readPinFromFile(File pinFile, String fileName, ConfigChangeResult ccr) |
| | | { |
| | | BufferedReader br = null; |
| | | try |
| | | { |
| | | br = new BufferedReader(new FileReader(pinFile)); |
| | | return br.readLine(); |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | ccr.setResultCode(DirectoryServer.getServerErrorResultCode()); |
| | | ccr.addMessage(ERR_FILE_KEYMANAGER_PIN_FILE_CANNOT_READ.get(fileName, configEntryDN, getExceptionMessage(ioe))); |
| | | return null; |
| | | } |
| | | finally |
| | | { |
| | | close(br); |
| | | } |
| | | } |
| | | } |