AutoRefactor: common code in if else statements
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.task; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | |
| | | */ |
| | | private void deleteIndex(AbstractIndexDescriptor index) throws OpenDsException |
| | | { |
| | | String backendId = Utilities.getRDNString("ds-cfg-backend-id", index.getBackend().getBackendID()); |
| | | String dn; |
| | | if (isVLVIndex(index)) |
| | | { |
| | | String dn = Utilities.getRDNString("ds-cfg-name", index.getName())+ |
| | | ",cn=VLV Index,"+Utilities.getRDNString("ds-cfg-backend-id", |
| | | index.getBackend().getBackendID())+",cn=Backends,cn=config"; |
| | | DirectoryServer.getConfigHandler().deleteEntry(DN.valueOf(dn), null); |
| | | dn = Utilities.getRDNString("ds-cfg-name", index.getName()) |
| | | + ",cn=VLV Index," + backendId + ",cn=Backends,cn=config"; |
| | | } |
| | | else |
| | | { |
| | | String dn = Utilities.getRDNString("ds-cfg-attribute", index.getName())+ |
| | | ",cn=Index,"+Utilities.getRDNString("ds-cfg-backend-id", |
| | | index.getBackend().getBackendID())+",cn=Backends,cn=config"; |
| | | DirectoryServer.getConfigHandler().deleteEntry(DN.valueOf(dn), null); |
| | | dn = Utilities.getRDNString("ds-cfg-attribute", index.getName()) |
| | | + ",cn=Index," + backendId + ",cn=Backends,cn=config"; |
| | | } |
| | | DirectoryServer.getConfigHandler().deleteEntry(DN.valueOf(dn), null); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2014 ForgeRock AS. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.task; |
| | | |
| | | import static org.forgerock.util.Utils.*; |
| | |
| | | final boolean isSchemaFileDefined = isSchemaFileDefined(fileName); |
| | | SwingUtilities.invokeLater(new Runnable() |
| | | { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void run() |
| | | { |
| | | printEquivalentCommandToAddOffline(fileName, isSchemaFileDefined, |
| | | attributes, objectClasses); |
| | | final ProgressDialog progressDialog = getProgressDialog(); |
| | | final String command = equivalentCommandToAddOffline( |
| | | fileName, isSchemaFileDefined, attributes, objectClasses); |
| | | progressDialog.appendProgressHtml( |
| | | Utilities.applyFont(command, |
| | | ColorAndFontConstants.progressFont)); |
| | | |
| | | if (attributes.size() == 1 && objectClasses.isEmpty()) |
| | | { |
| | | String attributeName = attributes.get(0).getNameOrOID(); |
| | | getProgressDialog().appendProgressHtml( |
| | | progressDialog.appendProgressHtml( |
| | | Utilities.getProgressWithPoints( |
| | | INFO_CTRL_PANEL_CREATING_ATTRIBUTE_PROGRESS.get( |
| | | attributeName), |
| | | INFO_CTRL_PANEL_CREATING_ATTRIBUTE_PROGRESS.get(attributeName), |
| | | ColorAndFontConstants.progressFont)); |
| | | } |
| | | else if (objectClasses.size() == 1 && attributes.isEmpty()) |
| | | { |
| | | String ocName = objectClasses.get(0).getNameOrOID(); |
| | | getProgressDialog().appendProgressHtml( |
| | | progressDialog.appendProgressHtml( |
| | | Utilities.getProgressWithPoints( |
| | | INFO_CTRL_PANEL_CREATING_OBJECTCLASS_PROGRESS.get( |
| | | ocName), |
| | | INFO_CTRL_PANEL_CREATING_OBJECTCLASS_PROGRESS.get(ocName), |
| | | ColorAndFontConstants.progressFont)); |
| | | } |
| | | else |
| | | { |
| | | getProgressDialog().appendProgressHtml( |
| | | progressDialog.appendProgressHtml( |
| | | Utilities.getProgressWithPoints( |
| | | INFO_CTRL_PANEL_UPDATING_SCHEMA_FILE_PROGRESS.get( |
| | | fileName), |
| | | INFO_CTRL_PANEL_UPDATING_SCHEMA_FILE_PROGRESS.get(fileName), |
| | | ColorAndFontConstants.progressFont)); |
| | | } |
| | | } |
| | |
| | | }); |
| | | } |
| | | |
| | | private void printEquivalentCommandToAddOffline(String schemaFile, |
| | | private String equivalentCommandToAddOffline(String schemaFile, |
| | | boolean isSchemaFileDefined, |
| | | List<AttributeType> attributes, |
| | | List<ObjectClass> objectClasses) |
| | |
| | | { |
| | | names.add(oc.getNameOrOID()); |
| | | } |
| | | final String namesString = joinAsString(", ", names); |
| | | |
| | | final StringBuilder sb = new StringBuilder(); |
| | | if (isSchemaFileDefined) |
| | | { |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append( |
| | | INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_ADD_SCHEMA_ELEMENT_OFFLINE.get( |
| | | joinAsString(", ", names), |
| | | schemaFile)) |
| | | sb.append(INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_ADD_SCHEMA_ELEMENT_OFFLINE.get(namesString, schemaFile)) |
| | | .append("<br><b>"); |
| | | for (AttributeType attribute : attributes) |
| | | { |
| | | sb.append(getAttributeName(attribute)).append(": ") |
| | | .append(getValueOffline(attribute)).append("<br>"); |
| | | } |
| | | for (ObjectClass oc : objectClasses) |
| | | { |
| | | sb.append(getAttributeName(oc)).append(": ") |
| | | .append(getValueOffline(oc)).append("<br>"); |
| | | } |
| | | sb.append("</b><br><br>"); |
| | | |
| | | getProgressDialog().appendProgressHtml(Utilities.applyFont(sb.toString(), |
| | | ColorAndFontConstants.progressFont)); |
| | | } |
| | | else |
| | | { |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append(INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_ADD_SCHEMA_ENTRY_OFFLINE.get( |
| | | joinAsString(", ", names), |
| | | schemaFile)).append("<br><b>"); |
| | | sb.append(INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_ADD_SCHEMA_ENTRY_OFFLINE.get(namesString, schemaFile)) |
| | | .append("<br><b>"); |
| | | for (String line : getSchemaEntryLines()) |
| | | { |
| | | sb.append(line); |
| | | sb.append("<br>"); |
| | | } |
| | | for (AttributeType attribute : attributes) |
| | | { |
| | | sb.append(getAttributeName(attribute)).append(": ") |
| | | .append(getValueOffline(attribute)).append("<br>"); |
| | | } |
| | | for (ObjectClass oc : objectClasses) |
| | | { |
| | | sb.append(getAttributeName(oc)).append(": ") |
| | | .append(getValueOffline(oc)).append("<br>"); |
| | | } |
| | | sb.append("</b><br><br>"); |
| | | getProgressDialog().appendProgressHtml(Utilities.applyFont(sb.toString(), |
| | | ColorAndFontConstants.progressFont)); |
| | | } |
| | | |
| | | for (AttributeType attribute : attributes) |
| | | { |
| | | sb.append(getAttributeName(attribute)).append(": ") |
| | | .append(getValueOffline(attribute)).append("<br>"); |
| | | } |
| | | for (ObjectClass oc : objectClasses) |
| | | { |
| | | sb.append(getAttributeName(oc)).append(": ") |
| | | .append(getValueOffline(oc)).append("<br>"); |
| | | } |
| | | sb.append("</b><br><br>"); |
| | | return sb.toString(); |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | for (int i=0; i<extraComponentLabels.length; i++) |
| | | { |
| | | gbc.gridy ++; |
| | | gbc.gridx = 0; |
| | | gbc.insets.left = labelInsetLeft; |
| | | gbc.anchor = GridBagConstraints.NORTHWEST; |
| | | gbc.insets.top = 10; |
| | | |
| | | if (extraComponentLabels[i] == null) |
| | | { |
| | | gbc.gridy ++; |
| | | gbc.gridx = 0; |
| | | gbc.insets.left = labelInsetLeft; |
| | | gbc.anchor = GridBagConstraints.NORTHWEST; |
| | | gbc.insets.top = 10; |
| | | gbc.gridwidth = 2; |
| | | gbc.weightx = 1.0; |
| | | panel.add(extraComponents[i], gbc); |
| | | } |
| | | else |
| | | { |
| | | gbc.gridy ++; |
| | | gbc.gridx = 0; |
| | | gbc.insets.left = labelInsetLeft; |
| | | gbc.anchor = GridBagConstraints.NORTHWEST; |
| | | gbc.insets.top = 10; |
| | | gbc.gridwidth = 1; |
| | | gbc.weightx = 0.0; |
| | | panel.add(extraComponentLabels[i], gbc); |
| | |
| | | { |
| | | DefaultComboBoxModel model = (DefaultComboBoxModel)combos[i].getModel(); |
| | | int index = combos[i].getSelectedIndex(); |
| | | if (rules[i] != null) |
| | | if (model.getSize() > 0) |
| | | { |
| | | if (model.getSize() > 0) |
| | | { |
| | | model.removeElementAt(0); |
| | | } |
| | | model.insertElementAt(INFO_CTRL_PANEL_DEFAULT_DEFINED_IN_SYNTAX.get( |
| | | rules[i].getNameOrOID()), 0); |
| | | model.removeElementAt(0); |
| | | } |
| | | else |
| | | { |
| | | if (model.getSize() > 0) |
| | | { |
| | | model.removeElementAt(0); |
| | | } |
| | | model.insertElementAt(NO_MATCHING_RULE, 0); |
| | | } |
| | | |
| | | final LocalizableMessage msg = rules[i] != null |
| | | ? INFO_CTRL_PANEL_DEFAULT_DEFINED_IN_SYNTAX.get(rules[i].getNameOrOID()) |
| | | : NO_MATCHING_RULE; |
| | | model.insertElementAt(msg, 0); |
| | | combos[i].setSelectedIndex(index); |
| | | } |
| | | } |
| | |
| | | scroll.setVisible(showDetails); |
| | | extraStrut.setVisible(!showDetails); |
| | | details.setSelected(showDetails); |
| | | if (showDetails) |
| | | |
| | | final Window dialog = Utilities.getParentDialog(this); |
| | | if (dialog != null) |
| | | { |
| | | final Window dialog = Utilities.getParentDialog(this); |
| | | if (dialog != null) |
| | | final Runnable repaint = new Runnable() |
| | | { |
| | | lastCollapsedHeight = dialog.getSize().height; |
| | | public void run() |
| | | { |
| | | invalidate(); |
| | | dialog.invalidate(); |
| | | dialog.repaint(); |
| | | } |
| | | }; |
| | | |
| | | final Dimension dialogSize = dialog.getSize(); |
| | | if (showDetails) |
| | | { |
| | | lastCollapsedHeight = dialogSize.height; |
| | | if (lastExpandedHeight == -1) |
| | | { |
| | | dialog.setSize(new Dimension(dialog.getSize().width, |
| | | dialog.getSize().height + heightDiff)); |
| | | dialog.setSize(new Dimension(dialogSize.width, dialogSize.height + heightDiff)); |
| | | } |
| | | else |
| | | { |
| | | dialog.setSize(new Dimension(dialog.getSize().width, |
| | | lastExpandedHeight)); |
| | | dialog.setSize(new Dimension(dialogSize.width, lastExpandedHeight)); |
| | | } |
| | | SwingUtilities.invokeLater(new Runnable() |
| | | { |
| | | public void run() |
| | | { |
| | | invalidate(); |
| | | dialog.invalidate(); |
| | | dialog.repaint(); |
| | | } |
| | | }); |
| | | SwingUtilities.invokeLater(repaint); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | final Window dialog = Utilities.getParentDialog(this); |
| | | if (dialog != null) |
| | | else |
| | | { |
| | | lastExpandedHeight = dialog.getSize().height; |
| | | lastExpandedHeight = dialogSize.height; |
| | | if (lastCollapsedHeight == -1) |
| | | { |
| | | packParentDialog(); |
| | | } |
| | | else |
| | | { |
| | | dialog.setSize(new Dimension(dialog.getSize().width, |
| | | lastCollapsedHeight)); |
| | | SwingUtilities.invokeLater(new Runnable() |
| | | { |
| | | public void run() |
| | | { |
| | | invalidate(); |
| | | dialog.invalidate(); |
| | | dialog.repaint(); |
| | | } |
| | | }); |
| | | dialog.setSize(new Dimension(dialogSize.width, lastCollapsedHeight)); |
| | | SwingUtilities.invokeLater(repaint); |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static com.forgerock.opendj.cli.Utils.OBFUSCATED_VALUE; |
| | | |
| | | import java.awt.Component; |
| | | import java.awt.GridBagConstraints; |
| | |
| | | import javax.swing.text.JTextComponent; |
| | | import javax.swing.tree.TreePath; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.guitools.controlpanel.datamodel.BinaryValue; |
| | | import org.opends.guitools.controlpanel.datamodel.CheckEntrySyntaxException; |
| | | import org.opends.guitools.controlpanel.datamodel.CustomSearchResult; |
| | |
| | | import org.opends.guitools.controlpanel.ui.nodes.BrowserNodeInfo; |
| | | import org.opends.guitools.controlpanel.ui.nodes.DndBrowserNodes; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.Base64; |
| | |
| | | |
| | | /** |
| | | * The panel displaying a simplified view of an entry. |
| | | * |
| | | */ |
| | | public class SimplifiedViewEntryPanel extends ViewEntryPanel |
| | | { |
| | |
| | | } |
| | | else if (!isBinary) |
| | | { |
| | | Set<String> sValues = new TreeSet<String>(); |
| | | for (Object value : values) |
| | | { |
| | | sValues.add(String.valueOf(value)); |
| | | } |
| | | Set<String> sValues = toStrings(values); |
| | | LocalizableMessage text = LocalizableMessage.raw(Utilities.getStringFromCollection(sValues, "\n")); |
| | | final JTextArea ta; |
| | | JComponent toAdd; |
| | | if (values.size() > 15) |
| | | { |
| | | ta = Utilities.createNonEditableTextArea( |
| | | LocalizableMessage.raw(Utilities.getStringFromCollection(sValues, "\n")), |
| | | 15, 20); |
| | | ta = Utilities.createNonEditableTextArea(text, 15, 20); |
| | | toAdd = Utilities.createScrollPane(ta); |
| | | } |
| | | else |
| | | { |
| | | ta = Utilities.createNonEditableTextArea( |
| | | LocalizableMessage.raw(Utilities.getStringFromCollection(sValues, "\n")), |
| | | values.size(), 20); |
| | | ta = Utilities.createNonEditableTextArea(text, values.size(), 20); |
| | | toAdd = ta; |
| | | } |
| | | panel.add(toAdd, gbc); |
| | |
| | | return panel; |
| | | } |
| | | |
| | | private Set<String> toStrings(Collection<Object> objects) |
| | | { |
| | | Set<String> results = new TreeSet<String>(); |
| | | for (Object o : objects) |
| | | { |
| | | results.add(String.valueOf(o)); |
| | | } |
| | | return results; |
| | | } |
| | | |
| | | private JComponent getReadWriteComponent(final String attrName, |
| | | List<Object> values) |
| | | { |
| | |
| | | } |
| | | else if (isPassword(attrName) || isConfirmPassword(attrName)) |
| | | { |
| | | JPasswordField pf; |
| | | if (o.equals("")) |
| | | JPasswordField pf = Utilities.createPasswordField(); |
| | | if (!o.equals("")) |
| | | { |
| | | pf = Utilities.createPasswordField(); |
| | | } |
| | | else |
| | | { |
| | | pf = Utilities.createPasswordField(); |
| | | pf.setText(getPasswordStringValue(o)); |
| | | } |
| | | panel.add(pf, gbc); |
| | |
| | | { |
| | | final JTextField tf = Utilities.createMediumTextField(); |
| | | tf.setText(String.valueOf(o)); |
| | | gbc.gridx = 0; |
| | | panel.add(tf, gbc); |
| | | if (mustAddBrowseButton(attrName)) |
| | | { |
| | | gbc.gridx = 0; |
| | | panel.add(tf, gbc); |
| | | gbc.insets.left = 5; |
| | | gbc.weightx = 0.0; |
| | | gbc.gridx ++; |
| | | gbc.anchor = GridBagConstraints.NORTH; |
| | | JButton browse = Utilities.createButton( |
| | | INFO_CTRL_PANEL_BROWSE_BUTTON_LABEL.get()); |
| | | browse.addActionListener(new ActionListener() |
| | | { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void actionPerformed(ActionEvent ev) |
| | | { |
| | | addBrowseClicked(attrName, tf); |
| | | } |
| | | }); |
| | | JButton browse = Utilities.createButton(INFO_CTRL_PANEL_BROWSE_BUTTON_LABEL.get()); |
| | | browse.addActionListener(new AddBrowseClickedActionListener(tf, attrName)); |
| | | panel.add(browse, gbc); |
| | | new DropTarget(tf, dropTargetListener); |
| | | } |
| | | else |
| | | { |
| | | gbc.gridx = 0; |
| | | panel.add(tf, gbc); |
| | | } |
| | | components.add(new EditorComponent(tf)); |
| | | } |
| | | else |
| | | { |
| | | Set<String> sValues = new TreeSet<String>(); |
| | | for (Object value : values) |
| | | { |
| | | sValues.add(String.valueOf(value)); |
| | | } |
| | | Set<String> sValues = toStrings(values); |
| | | final LocalizableMessage text = LocalizableMessage.raw(Utilities.getStringFromCollection(sValues, "\n")); |
| | | final JTextArea ta; |
| | | JComponent toAdd; |
| | | if (values.size() > 15) |
| | | { |
| | | ta = Utilities.createTextArea( |
| | | LocalizableMessage.raw(Utilities.getStringFromCollection(sValues, "\n")), |
| | | 15, 20); |
| | | ta = Utilities.createTextArea(text, 15, 20); |
| | | toAdd = Utilities.createScrollPane(ta); |
| | | } |
| | | else |
| | | { |
| | | ta = Utilities.createTextAreaWithBorder( |
| | | LocalizableMessage.raw(Utilities.getStringFromCollection(sValues, "\n")), |
| | | values.size(), 20); |
| | | ta = Utilities.createTextAreaWithBorder(text, values.size(), 20); |
| | | toAdd = ta; |
| | | } |
| | | panel.add(toAdd, gbc); |
| | | if (mustAddBrowseButton(attrName)) |
| | | { |
| | | panel.add(toAdd, gbc); |
| | | gbc.insets.left = 5; |
| | | gbc.weightx = 0.0; |
| | | gbc.gridx ++; |
| | | gbc.anchor = GridBagConstraints.NORTH; |
| | | final JButton browse = Utilities.createButton( |
| | | INFO_CTRL_PANEL_BROWSE_BUTTON_LABEL.get()); |
| | | browse.addActionListener(new ActionListener() |
| | | { |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void actionPerformed(ActionEvent ev) |
| | | { |
| | | addBrowseClicked(attrName, ta); |
| | | } |
| | | }); |
| | | if (attrName.equalsIgnoreCase( |
| | | ServerConstants.ATTR_UNIQUE_MEMBER_LC)) |
| | | browse.addActionListener(new AddBrowseClickedActionListener(ta, attrName)); |
| | | if (attrName.equalsIgnoreCase(ServerConstants.ATTR_UNIQUE_MEMBER_LC)) |
| | | { |
| | | browse.setText( |
| | | INFO_CTRL_PANEL_ADD_MEMBERS_BUTTON.get().toString()); |
| | |
| | | panel.add(browse, gbc); |
| | | new DropTarget(ta, dropTargetListener); |
| | | } |
| | | else |
| | | { |
| | | panel.add(toAdd, gbc); |
| | | } |
| | | components.add(new EditorComponent(ta)); |
| | | } |
| | | break; |
| | |
| | | browseEntriesPanel.setMultipleSelection(!isSingleValue(attrName)); |
| | | |
| | | browseEntriesDlg.setVisible(true); |
| | | if (textComponent instanceof JTextArea) |
| | | String[] dns = browseEntriesPanel.getDNs(); |
| | | if (dns.length > 0) |
| | | { |
| | | String[] dns = browseEntriesPanel.getDNs(); |
| | | if (dns.length > 0) |
| | | if (textComponent instanceof JTextArea) |
| | | { |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append(textComponent.getText()); |
| | |
| | | textComponent.setText(sb.toString()); |
| | | textComponent.setCaretPosition(sb.length()); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | String[] dns = browseEntriesPanel.getDNs(); |
| | | if (dns.length > 0) |
| | | else |
| | | { |
| | | textComponent.setText(dns[0]); |
| | | } |
| | |
| | | |
| | | private boolean hasValue(EditorComponent editor) |
| | | { |
| | | boolean hasValue = false; |
| | | Object value = editor.getValue(); |
| | | if (value != null) |
| | | if (value instanceof byte[]) |
| | | { |
| | | if (value instanceof byte[]) |
| | | { |
| | | hasValue = ((byte[])value).length > 0; |
| | | } |
| | | else if (value instanceof String) |
| | | { |
| | | hasValue = ((String)value).trim().length() > 0; |
| | | } |
| | | else if (value instanceof Collection<?>) |
| | | { |
| | | hasValue = ((Collection<?>)value).size() > 0; |
| | | } |
| | | else |
| | | { |
| | | hasValue = true; |
| | | } |
| | | return ((byte[])value).length > 0; |
| | | } |
| | | return hasValue; |
| | | else if (value instanceof String) |
| | | { |
| | | return ((String)value).trim().length() > 0; |
| | | } |
| | | else if (value instanceof Collection<?>) |
| | | { |
| | | return ((Collection<?>)value).size() > 0; |
| | | } |
| | | else if (value != null) |
| | | { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** Calls #addBrowseClicked(). */ |
| | | private final class AddBrowseClickedActionListener implements ActionListener |
| | | { |
| | | private final JTextComponent tc; |
| | | private final String attrName; |
| | | |
| | | private AddBrowseClickedActionListener(JTextComponent tc, String attrName) |
| | | { |
| | | this.tc = tc; |
| | | this.attrName = attrName; |
| | | } |
| | | |
| | | @Override |
| | | public void actionPerformed(ActionEvent ev) |
| | | { |
| | | addBrowseClicked(attrName, tc); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | private Component comp; |
| | | |
| | | /** |
| | | * Creats an EditorComponent using a text component. |
| | | * Creates an EditorComponent using a text component. |
| | | * @param tf the text component. |
| | | */ |
| | | public EditorComponent(JTextComponent tf) |
| | |
| | | { |
| | | // It does fit on the line, so add it. |
| | | lineBuffer.append(delimBuffer).append(word); |
| | | |
| | | if (delimBuffer.length() > 0) |
| | | { |
| | | delimBuffer = new StringBuilder(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | |
| | | |
| | | lineBuffer = new StringBuilder(); |
| | | lineBuffer.append(word); |
| | | } |
| | | |
| | | if (delimBuffer.length() > 0) |
| | | { |
| | | delimBuffer = new StringBuilder(); |
| | | } |
| | | if (delimBuffer.length() > 0) |
| | | { |
| | | delimBuffer = new StringBuilder(); |
| | | } |
| | | } |
| | | } |
| | |
| | | boolean isAcceptable = true; |
| | | for (ManagedObject<?> mo : findReferences(context, |
| | | getManagedObjectDefinition(), path.getName())) { |
| | | LocalizableMessage msg; |
| | | String name = mo.getManagedObjectPath().getName(); |
| | | if (name == null) { |
| | | LocalizableMessage msg = ERR_CLIENT_REFINT_CANNOT_DELETE_WITHOUT_NAME.get( |
| | | msg = ERR_CLIENT_REFINT_CANNOT_DELETE_WITHOUT_NAME.get( |
| | | getName(), mo.getManagedObjectDefinition().getUserFriendlyName(), |
| | | getManagedObjectDefinition().getUserFriendlyName()); |
| | | unacceptableReasons.add(msg); |
| | | } else { |
| | | LocalizableMessage msg = ERR_CLIENT_REFINT_CANNOT_DELETE_WITH_NAME.get( |
| | | msg = ERR_CLIENT_REFINT_CANNOT_DELETE_WITH_NAME.get( |
| | | getName(), mo.getManagedObjectDefinition().getUserFriendlyName(), |
| | | name, getManagedObjectDefinition().getUserFriendlyName()); |
| | | unacceptableReasons.add(msg); |
| | | } |
| | | unacceptableReasons.add(msg); |
| | | isAcceptable = false; |
| | | } |
| | | return isAcceptable; |
| | |
| | | getManagedObjectDefinition(), managedObject.getManagedObjectPath() |
| | | .getName())) { |
| | | if (targetNeedsEnablingCondition.evaluate(context, mo)) { |
| | | LocalizableMessage msg; |
| | | String name = mo.getManagedObjectPath().getName(); |
| | | if (name == null) { |
| | | LocalizableMessage msg = ERR_CLIENT_REFINT_CANNOT_DISABLE_WITHOUT_NAME.get( |
| | | managedObject.getManagedObjectDefinition() |
| | | .getUserFriendlyName(), getName(), mo |
| | | .getManagedObjectDefinition().getUserFriendlyName()); |
| | | unacceptableReasons.add(msg); |
| | | msg = ERR_CLIENT_REFINT_CANNOT_DISABLE_WITHOUT_NAME.get( |
| | | managedObject.getManagedObjectDefinition().getUserFriendlyName(), |
| | | getName(), mo.getManagedObjectDefinition().getUserFriendlyName()); |
| | | } else { |
| | | LocalizableMessage msg = ERR_CLIENT_REFINT_CANNOT_DISABLE_WITH_NAME.get( |
| | | managedObject.getManagedObjectDefinition() |
| | | .getUserFriendlyName(), getName(), mo |
| | | .getManagedObjectDefinition().getUserFriendlyName(), name); |
| | | unacceptableReasons.add(msg); |
| | | msg = ERR_CLIENT_REFINT_CANNOT_DISABLE_WITH_NAME.get( |
| | | managedObject.getManagedObjectDefinition().getUserFriendlyName(), |
| | | getName(), mo.getManagedObjectDefinition().getUserFriendlyName(), name); |
| | | } |
| | | unacceptableReasons.add(msg); |
| | | isAcceptable = false; |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | writeLDIF(); |
| | | return; |
| | | } |
| | | else |
| | | { |
| | |
| | | { |
| | | subtreeDelete(childDN); |
| | | } |
| | | |
| | | writeLDIF(); |
| | | return; |
| | | } |
| | | |
| | | writeLDIF(); |
| | | } |
| | | finally |
| | | { |
| | |
| | | supportedTlsCiphers); |
| | | addAttribute(supportedTLSCiphersAttr, dseUserAttrs, dseOperationalAttrs); |
| | | |
| | | // Add all the standard "static" attributes. |
| | | for (Attribute a : staticDSEAttributes) |
| | | { |
| | | AttributeType type = a.getAttributeType(); |
| | | |
| | | if (type.isOperational() && !showAllAttributes) |
| | | { |
| | | List<Attribute> attrs = dseOperationalAttrs.get(type); |
| | | if (attrs == null) |
| | | { |
| | | attrs = new ArrayList<Attribute>(); |
| | | dseOperationalAttrs.put(type, attrs); |
| | | } |
| | | attrs.add(a); |
| | | } |
| | | else |
| | | { |
| | | List<Attribute> attrs = dseUserAttrs.get(type); |
| | | if (attrs == null) |
| | | { |
| | | attrs = new ArrayList<Attribute>(); |
| | | dseUserAttrs.put(type, attrs); |
| | | } |
| | | attrs.add(a); |
| | | } |
| | | } |
| | | |
| | | |
| | | // Add all the user-defined attributes. |
| | | for (Attribute a : userDefinedAttributes) |
| | | { |
| | | AttributeType type = a.getAttributeType(); |
| | | |
| | | if (type.isOperational() && !showAllAttributes) |
| | | { |
| | | List<Attribute> attrs = dseOperationalAttrs.get(type); |
| | | if (attrs == null) |
| | | { |
| | | attrs = new ArrayList<Attribute>(); |
| | | dseOperationalAttrs.put(type, attrs); |
| | | } |
| | | attrs.add(a); |
| | | } |
| | | else |
| | | { |
| | | List<Attribute> attrs = dseUserAttrs.get(type); |
| | | if (attrs == null) |
| | | { |
| | | attrs = new ArrayList<Attribute>(); |
| | | dseUserAttrs.put(type, attrs); |
| | | } |
| | | attrs.add(a); |
| | | } |
| | | } |
| | | |
| | | addAll(staticDSEAttributes, dseUserAttrs, dseOperationalAttrs); |
| | | addAll(userDefinedAttributes, dseUserAttrs, dseOperationalAttrs); |
| | | |
| | | // Construct and return the entry. |
| | | Entry e = new Entry(rootDSEDN, dseObjectClasses, dseUserAttrs, |
| | |
| | | return e; |
| | | } |
| | | |
| | | private void addAll(ArrayList<Attribute> attributes, |
| | | Map<AttributeType, List<Attribute>> userAttrs, Map<AttributeType, List<Attribute>> operationalAttrs) |
| | | { |
| | | for (Attribute a : attributes) |
| | | { |
| | | AttributeType type = a.getAttributeType(); |
| | | |
| | | final Map<AttributeType, List<Attribute>> attrsMap = type.isOperational() && !showAllAttributes |
| | | ? operationalAttrs |
| | | : userAttrs; |
| | | List<Attribute> attrs = attrsMap.get(type); |
| | | if (attrs == null) |
| | | { |
| | | attrs = new ArrayList<Attribute>(); |
| | | attrsMap.put(type, attrs); |
| | | } |
| | | attrs.add(a); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | private void addAttribute(Attribute publicNamingContextAttr, |
| | |
| | | // attributes that we don't recognize will be included directly in the |
| | | // schema entry. |
| | | userDefinedAttributes = new ArrayList<Attribute>(); |
| | | for (List<Attribute> attrs : |
| | | configEntry.getEntry().getUserAttributes().values()) |
| | | { |
| | | for (Attribute a : attrs) |
| | | { |
| | | if (! isSchemaConfigAttribute(a)) |
| | | { |
| | | userDefinedAttributes.add(a); |
| | | } |
| | | } |
| | | } |
| | | for (List<Attribute> attrs : |
| | | configEntry.getEntry().getOperationalAttributes().values()) |
| | | { |
| | | for (Attribute a : attrs) |
| | | { |
| | | if (! isSchemaConfigAttribute(a)) |
| | | { |
| | | userDefinedAttributes.add(a); |
| | | } |
| | | } |
| | | } |
| | | addAll(configEntry.getEntry().getUserAttributes().values()); |
| | | addAll(configEntry.getEntry().getOperationalAttributes().values()); |
| | | |
| | | |
| | | // Determine whether to show all attributes. |
| | | showAllAttributes = cfg.isShowAllAttributes(); |
| | | |
| | | |
| | | currentConfig = cfg; |
| | | } |
| | | |
| | | private void addAll(Collection<List<Attribute>> attrsList) |
| | | { |
| | | for (List<Attribute> attrs : attrsList) |
| | | { |
| | | for (Attribute a : attrs) |
| | | { |
| | | if (! isSchemaConfigAttribute(a)) |
| | | { |
| | | userDefinedAttributes.add(a); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeBackend() |
| | |
| | | // Create a list of modifications and add any differences between the old |
| | | // and new schema into them. |
| | | List<Modification> mods = new LinkedList<Modification>(); |
| | | Schema.compareConcatenatedSchema(oldATs, newATs, attributeTypesType, |
| | | mods); |
| | | Schema.compareConcatenatedSchema(oldATs, newATs, attributeTypesType, mods); |
| | | Schema.compareConcatenatedSchema(oldOCs, newOCs, objectClassesType, mods); |
| | | Schema.compareConcatenatedSchema(oldNFs, newNFs, nameFormsType, mods); |
| | | Schema.compareConcatenatedSchema(oldDCRs, newDCRs, ditContentRulesType, |
| | | mods); |
| | | Schema.compareConcatenatedSchema(oldDSRs, newDSRs, ditStructureRulesType, |
| | | mods); |
| | | Schema.compareConcatenatedSchema(oldMRUs, newMRUs, matchingRuleUsesType, |
| | | mods); |
| | | Schema.compareConcatenatedSchema(oldLSDs, newLSDs, ldapSyntaxesType, |
| | | mods); |
| | | Schema.compareConcatenatedSchema(oldDCRs, newDCRs, ditContentRulesType, mods); |
| | | Schema.compareConcatenatedSchema(oldDSRs, newDSRs, ditStructureRulesType, mods); |
| | | Schema.compareConcatenatedSchema(oldMRUs, newMRUs, matchingRuleUsesType, mods); |
| | | Schema.compareConcatenatedSchema(oldLSDs, newLSDs, ldapSyntaxesType, mods); |
| | | if (! mods.isEmpty()) |
| | | { |
| | | // TODO : Raise an alert notification. |
| | |
| | | for (int i = 0; i < numAVAs; i++) |
| | | { |
| | | AttributeType attrType = rdn.getAttributeType(i); |
| | | Attribute attribute = Attributes.create(attrType, |
| | | rdn.getAttributeValue(i)); |
| | | Attribute attribute = Attributes.create(attrType, rdn.getAttributeValue(i)); |
| | | addAttributeToSchemaEntry(attribute, userAttrs, operationalAttrs); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | addAttributeToSchemaEntry( |
| | | Attributes.create(creatorsNameType, creatorsName), userAttrs, |
| | | operationalAttrs); |
| | | Attributes.create(creatorsNameType, creatorsName), userAttrs, operationalAttrs); |
| | | addAttributeToSchemaEntry( |
| | | Attributes.create(createTimestampType, createTimestamp), userAttrs, |
| | | operationalAttrs); |
| | | Attributes.create(createTimestampType, createTimestamp), userAttrs, operationalAttrs); |
| | | addAttributeToSchemaEntry( |
| | | Attributes.create(modifiersNameType, modifiersName), userAttrs, |
| | | operationalAttrs); |
| | | Attributes.create(modifiersNameType, modifiersName), userAttrs, operationalAttrs); |
| | | addAttributeToSchemaEntry( |
| | | Attributes.create(modifyTimestampType, modifyTimestamp), userAttrs, |
| | | operationalAttrs); |
| | | Attributes.create(modifyTimestampType, modifyTimestamp), userAttrs, operationalAttrs); |
| | | |
| | | // Add the extra attributes. |
| | | for (Attribute attribute : DirectoryServer.getSchema().getExtraAttributes() |
| | | .values()) |
| | | for (Attribute attribute : DirectoryServer.getSchema().getExtraAttributes().values()) |
| | | { |
| | | addAttributeToSchemaEntry(attribute, userAttrs, operationalAttrs); |
| | | } |
| | |
| | | } |
| | | |
| | | // Construct and return the entry. |
| | | Entry e = new Entry(entryDN, schemaObjectClasses, userAttrs, |
| | | operationalAttrs); |
| | | Entry e = new Entry(entryDN, schemaObjectClasses, userAttrs, operationalAttrs); |
| | | e.processVirtualAttributes(); |
| | | return e; |
| | | } |
| | |
| | | Map<AttributeType, List<Attribute>> operationalAttrs) |
| | | { |
| | | AttributeType type = attribute.getAttributeType(); |
| | | if (type.isOperational()) |
| | | Map<AttributeType, List<Attribute>> attrsMap = type.isOperational() ? operationalAttrs : userAttrs; |
| | | List<Attribute> attrs = attrsMap.get(type); |
| | | if (attrs == null) |
| | | { |
| | | List<Attribute> attrs = operationalAttrs.get(type); |
| | | if (attrs == null) |
| | | { |
| | | attrs = new ArrayList<Attribute>(1); |
| | | operationalAttrs.put(type, attrs); |
| | | } |
| | | attrs.add(attribute); |
| | | attrs = new ArrayList<Attribute>(1); |
| | | attrsMap.put(type, attrs); |
| | | } |
| | | else |
| | | { |
| | | List<Attribute> attrs = userAttrs.get(type); |
| | | if (attrs == null) |
| | | { |
| | | attrs = new ArrayList<Attribute>(); |
| | | userAttrs.put(type, attrs); |
| | | } |
| | | attrs.add(attribute); |
| | | } |
| | | attrs.add(attribute); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | LocalizableMessage message; |
| | | if (allCleaned) |
| | | { |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_WRITE_ORIG_FILES_CLEANED.get( |
| | | getExceptionMessage(e)); |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | message, e); |
| | | message = ERR_SCHEMA_MODIFY_CANNOT_WRITE_ORIG_FILES_CLEANED.get(getExceptionMessage(e)); |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_WRITE_ORIG_FILES_NOT_CLEANED |
| | | .get(getExceptionMessage(e)); |
| | | message = ERR_SCHEMA_MODIFY_CANNOT_WRITE_ORIG_FILES_NOT_CLEANED.get(getExceptionMessage(e)); |
| | | |
| | | DirectoryServer.sendAlertNotification(this, |
| | | ALERT_TYPE_CANNOT_COPY_SCHEMA_FILES, |
| | | message); |
| | | |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | message, e); |
| | | } |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), message, e); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | LocalizableMessage message; |
| | | if (allRestored) |
| | | { |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_WRITE_NEW_FILES_RESTORED.get( |
| | | getExceptionMessage(e)); |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | message, e); |
| | | message = ERR_SCHEMA_MODIFY_CANNOT_WRITE_NEW_FILES_RESTORED.get(getExceptionMessage(e)); |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_WRITE_NEW_FILES_NOT_RESTORED |
| | | .get(getExceptionMessage(e)); |
| | | message = ERR_SCHEMA_MODIFY_CANNOT_WRITE_NEW_FILES_NOT_RESTORED.get(getExceptionMessage(e)); |
| | | |
| | | DirectoryServer.sendAlertNotification(this, |
| | | ALERT_TYPE_CANNOT_WRITE_NEW_SCHEMA_FILES, |
| | | message); |
| | | |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), |
| | | message, e); |
| | | } |
| | | throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), message, e); |
| | | } |
| | | |
| | | deleteFiles(origFileList); |
| | |
| | | entryLimitExceededCount++; |
| | | } |
| | | value = newImportIDSet.valueToByteString(); |
| | | put(txn, key, value); |
| | | } else { |
| | | if(!importIdSet.isDefined()) { |
| | | entryLimitExceededCount++; |
| | | } |
| | | value = importIdSet.valueToByteString(); |
| | | put(txn, key, value); |
| | | } |
| | | put(txn, key, value); |
| | | } |
| | | |
| | | /** |
| | |
| | | super(name, description, isRequired, isMultiValued, requiresAdminAction, |
| | | getValueSet(values)); |
| | | |
| | | |
| | | if (values == null) |
| | | { |
| | | activeValues = new ArrayList<DN>(); |
| | | pendingValues = activeValues; |
| | | } |
| | | else |
| | | { |
| | | activeValues = values; |
| | | pendingValues = activeValues; |
| | | } |
| | | activeValues = values != null ? values : new ArrayList<DN>(); |
| | | pendingValues = activeValues; |
| | | } |
| | | |
| | | |
| | |
| | | this.hasUpperBound = hasUpperBound; |
| | | this.upperBound = upperBound; |
| | | |
| | | if (values == null) |
| | | { |
| | | activeValues = new ArrayList<Long>(); |
| | | pendingValues = activeValues; |
| | | } |
| | | else |
| | | { |
| | | activeValues = values; |
| | | pendingValues = activeValues; |
| | | } |
| | | activeValues = values != null ? values : new ArrayList<Long>(); |
| | | pendingValues = activeValues; |
| | | } |
| | | |
| | | |
| | |
| | | String[] valueArray = new String[stringValues.size()]; |
| | | stringValues.toArray(valueArray); |
| | | attrList.add(new Attribute(name, valueArray)); |
| | | break monitorLoop; |
| | | } |
| | | else |
| | | { |
| | | attrList.add(new Attribute(name, value.toString())); |
| | | break monitorLoop; |
| | | } |
| | | break monitorLoop; |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | this.allowedValues = allowedValues; |
| | | |
| | | if (values == null) |
| | | { |
| | | activeValues = new ArrayList<String>(); |
| | | pendingValues = activeValues; |
| | | } |
| | | else |
| | | { |
| | | activeValues = values; |
| | | pendingValues = activeValues; |
| | | } |
| | | activeValues = values != null ? values : new ArrayList<String>(); |
| | | pendingValues = activeValues; |
| | | } |
| | | |
| | | |
| | |
| | | getValueSet(values)); |
| | | |
| | | |
| | | if (values == null) |
| | | { |
| | | activeValues = new ArrayList<String>(); |
| | | pendingValues = activeValues; |
| | | } |
| | | else |
| | | { |
| | | activeValues = values; |
| | | pendingValues = activeValues; |
| | | } |
| | | activeValues = values != null ? values : new ArrayList<String>(); |
| | | pendingValues = activeValues; |
| | | } |
| | | |
| | | |
| | |
| | | DN valueEntryDN = DN.decode(attrVal); |
| | | |
| | | final Entry valueEntry; |
| | | if (currentConfiguration.getCheckReferencesScopeCriteria() == CheckReferencesScopeCriteria.NAMING_CONTEXT) |
| | | if (currentConfiguration.getCheckReferencesScopeCriteria() == CheckReferencesScopeCriteria.NAMING_CONTEXT |
| | | && valueEntryDN.matchesBaseAndScope(entryBaseDN, SearchScope.SUBORDINATES)) |
| | | { |
| | | if (valueEntryDN.matchesBaseAndScope(entryBaseDN, SearchScope.SUBORDINATES)) |
| | | { |
| | | return PluginResult.PreOperation.stopProcessing(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_PLUGIN_REFERENT_NAMINGCONTEXT_MISMATCH.get(valueEntryDN, attr.getName(), entryDN)); |
| | | } |
| | | valueEntry = DirectoryServer.getEntry(valueEntryDN); |
| | | return PluginResult.PreOperation.stopProcessing(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_PLUGIN_REFERENT_NAMINGCONTEXT_MISMATCH.get(valueEntryDN, attr.getName(), entryDN)); |
| | | } |
| | | else |
| | | { |
| | | valueEntry = DirectoryServer.getEntry(valueEntryDN); |
| | | } |
| | | valueEntry = DirectoryServer.getEntry(valueEntryDN); |
| | | |
| | | // Verify that the value entry exists in the backend. |
| | | if (valueEntry == null) |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | |
| | | import java.io.IOException; |
| | | |
| | | import org.forgerock.opendj.io.*; |
| | | import org.opends.server.types.AuthenticationType; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines the structures and methods for an LDAP bind request |
| | | * protocol op, which is used to authenticate a user to the Directory Server. |
| | | */ |
| | | public class BindRequestProtocolOp |
| | | extends ProtocolOp |
| | | public class BindRequestProtocolOp extends ProtocolOp |
| | | { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | // The bind DN for this request. |
| | | /** The bind DN for this request. */ |
| | | private ByteString dn; |
| | | |
| | | // The SASL credentials for this request. |
| | | /** The SASL credentials for this request. */ |
| | | private ByteString saslCredentials; |
| | | |
| | | // The simple authentication password for this request. |
| | | /** The simple authentication password for this request. */ |
| | | private ByteString simplePassword; |
| | | |
| | | // The authentication type for this request. |
| | | /** The authentication type for this request. */ |
| | | private AuthenticationType authenticationType; |
| | | |
| | | // The protocol version for this bind request. |
| | | /** The protocol version for this bind request. */ |
| | | private int protocolVersion; |
| | | |
| | | // The SASL mechanism for this request. |
| | | /** The SASL mechanism for this request. */ |
| | | private String saslMechanism; |
| | | |
| | | |
| | |
| | | */ |
| | | public void toString(StringBuilder buffer) |
| | | { |
| | | buffer.append("BindRequest(version="); |
| | | buffer.append(protocolVersion); |
| | | buffer.append("BindRequest(version=").append(protocolVersion); |
| | | buffer.append(", dn="); |
| | | |
| | | if (dn != null) |
| | | { |
| | | buffer.append(dn.toString()); |
| | | buffer.append(dn); |
| | | } |
| | | |
| | | if (authenticationType == AuthenticationType.SIMPLE) |
| | | { |
| | | buffer.append(", password="); |
| | | buffer.append(simplePassword.toString()); |
| | | buffer.append(", password=").append(simplePassword); |
| | | } |
| | | else |
| | | { |
| | | buffer.append(", saslMechanism="); |
| | | buffer.append(saslMechanism); |
| | | buffer.append(", saslMechanism=").append(saslMechanism); |
| | | |
| | | if (saslCredentials != null) |
| | | { |
| | | buffer.append(", saslCredentials="); |
| | | buffer.append(saslCredentials.toString()); |
| | | buffer.append(", saslCredentials=").append(saslCredentials); |
| | | } |
| | | } |
| | | |
| | |
| | | indentBuf.append(' '); |
| | | } |
| | | |
| | | buffer.append(indentBuf); |
| | | buffer.append("Bind Request"); |
| | | buffer.append(EOL); |
| | | buffer.append(indentBuf).append("Bind Request").append(EOL); |
| | | buffer.append(indentBuf).append(" Protocol Version: ").append(protocolVersion).append(EOL); |
| | | |
| | | buffer.append(indentBuf); |
| | | buffer.append(" Protocol Version: "); |
| | | buffer.append(protocolVersion); |
| | | buffer.append(EOL); |
| | | |
| | | buffer.append(indentBuf); |
| | | buffer.append(" DN: "); |
| | | buffer.append(indentBuf).append(" DN: "); |
| | | if (dn != null) |
| | | { |
| | | buffer.append(dn.toString()); |
| | | buffer.append(dn); |
| | | } |
| | | buffer.append(EOL); |
| | | |
| | | if (authenticationType == AuthenticationType.SIMPLE) |
| | | { |
| | | buffer.append(indentBuf); |
| | | buffer.append(" Simple Password: "); |
| | | buffer.append(String.valueOf(simplePassword)); |
| | | buffer.append(EOL); |
| | | buffer.append(indentBuf).append(" Simple Password: ").append(simplePassword).append(EOL); |
| | | } |
| | | else |
| | | { |
| | | buffer.append(indentBuf); |
| | | buffer.append(" SASL Mechanism: "); |
| | | buffer.append(saslMechanism); |
| | | buffer.append(EOL); |
| | | buffer.append(indentBuf).append(" SASL Mechanism: ").append(saslMechanism).append(EOL); |
| | | |
| | | if (saslCredentials != null) |
| | | { |
| | | buffer.append(indentBuf); |
| | | buffer.append(" SASL Credentials:"); |
| | | buffer.append(EOL); |
| | | buffer.append(indentBuf).append(" SASL Credentials:").append(EOL); |
| | | buffer.append(saslCredentials.toHexPlusAsciiString(indent+4)); |
| | | } |
| | | } |
| | |
| | | // skip the offset |
| | | reader.skipBytes(SIZE_OF_BLOCK_OFFSET); |
| | | lengthBytes.append(reader, SIZE_OF_RECORD_SIZE - distanceToBlockStart); |
| | | return lengthBytes.toByteString().toInt(); |
| | | } |
| | | else |
| | | { |
| | |
| | | reader.skipBytes(SIZE_OF_BLOCK_OFFSET); |
| | | } |
| | | lengthBytes.append(reader, SIZE_OF_RECORD_SIZE); |
| | | return lengthBytes.toByteString().toInt(); |
| | | } |
| | | return lengthBytes.toByteString().toInt(); |
| | | } |
| | | |
| | | /** |
| | |
| | | import java.io.PrintStream; |
| | | import java.io.Reader; |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedList; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | |
| | | connectionOptions.setSASLExternal(saslExternal.isPresent()); |
| | | if(saslOptions.isPresent()) |
| | | { |
| | | LinkedList<String> values = saslOptions.getValues(); |
| | | for(String saslOption : values) |
| | | for (String saslOption : saslOptions.getValues()) |
| | | { |
| | | if(saslOption.startsWith("mech=")) |
| | | boolean val = saslOption.startsWith("mech=") |
| | | ? connectionOptions.setSASLMechanism(saslOption) |
| | | : connectionOptions.addSASLProperty(saslOption); |
| | | if (!val) |
| | | { |
| | | boolean val = connectionOptions.setSASLMechanism(saslOption); |
| | | if(val == false) |
| | | { |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } else |
| | | { |
| | | boolean val = connectionOptions.addSASLProperty(saslOption); |
| | | if(val == false) |
| | | { |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | | } |
| | |
| | | connectionOptions.setSASLExternal(saslExternal.isPresent()); |
| | | if(saslOptions.isPresent()) |
| | | { |
| | | LinkedList<String> values = saslOptions.getValues(); |
| | | for(String saslOption : values) |
| | | for (String saslOption : saslOptions.getValues()) |
| | | { |
| | | if(saslOption.startsWith("mech=")) |
| | | boolean val = saslOption.startsWith("mech=") |
| | | ? connectionOptions.setSASLMechanism(saslOption) |
| | | : connectionOptions.addSASLProperty(saslOption); |
| | | if (!val) |
| | | { |
| | | boolean val = connectionOptions.setSASLMechanism(saslOption); |
| | | if(val == false) |
| | | { |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } else |
| | | { |
| | | boolean val = connectionOptions.addSASLProperty(saslOption); |
| | | if(val == false) |
| | | { |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | | } |
| | |
| | | //Return objectclass attribute unless analysis of the arguments determines |
| | | //otherwise. |
| | | boolean includeObjectclassAttrs = true; |
| | | LinkedList<String> attributeNames; |
| | | final LinkedList<String> attributeNames = new LinkedList<String>(); |
| | | LinkedList<String> objectClassNames = new LinkedList<String>(); |
| | | LinkedList<String> filterStrings = new LinkedList<String>(); |
| | | if (filterFile.isPresent()) |
| | |
| | | } |
| | | |
| | | ArrayList<String> trailingArguments = argParser.getTrailingArguments(); |
| | | if ((trailingArguments == null) || trailingArguments.isEmpty()) |
| | | if (trailingArguments != null && !trailingArguments.isEmpty()) |
| | | { |
| | | attributeNames = new LinkedList<String>(); |
| | | } |
| | | else |
| | | { |
| | | attributeNames = new LinkedList<String>(); |
| | | for (String attributeName : trailingArguments) |
| | | { |
| | | String lowerName = toLowerCase(attributeName); |
| | |
| | | filterStrings = new LinkedList<String>(); |
| | | filterStrings.add(iterator.next()); |
| | | |
| | | attributeNames = new LinkedList<String>(); |
| | | while (iterator.hasNext()) |
| | | { |
| | | String lowerName = toLowerCase(iterator.next()); |
| | |
| | | } |
| | | } |
| | | |
| | | if (attributeNames.isEmpty() && objectClassNames.isEmpty() && |
| | | (! allOperationalAttrs)) |
| | | if (attributeNames.isEmpty() |
| | | && objectClassNames.isEmpty() |
| | | && !allOperationalAttrs) |
| | | { |
| | | // This will be true if no attributes were requested, which is effectively |
| | | // all user attributes. It will also be true if just "*" was included, |
| | |
| | | attributeNames.isEmpty()) |
| | | includeObjectclassAttrs=false; |
| | | //If "objectclass" isn't specified in the attributes to return, then |
| | | //don't include objectclass attribiute. |
| | | //don't include objectclass attribute. |
| | | if(!attributeNames.isEmpty() && objectClassNames.isEmpty() && |
| | | !attributeNames.contains("objectclass")) |
| | | includeObjectclassAttrs=false; |
| | |
| | | table.appendCell(INFO_TASKINFO_FIELD_STATUS.get()); |
| | | table.appendCell(taskEntry.getState()); |
| | | |
| | | table.startRow(); |
| | | table.appendCell(INFO_TASKINFO_FIELD_SCHEDULED_START.get()); |
| | | |
| | | if (TaskState.isRecurring(taskEntry.getTaskState())) { |
| | | table.startRow(); |
| | | table.appendCell(INFO_TASKINFO_FIELD_SCHEDULED_START.get()); |
| | | m = taskEntry.getScheduleTab(); |
| | | table.appendCell(m); |
| | | } else { |
| | | table.startRow(); |
| | | table.appendCell(INFO_TASKINFO_FIELD_SCHEDULED_START.get()); |
| | | m = taskEntry.getScheduledStartTime(); |
| | | if (m == null || m.equals(LocalizableMessage.EMPTY)) { |
| | | table.appendCell(INFO_TASKINFO_IMMEDIATE_EXECUTION.get()); |
| | |
| | | TemplateValue templateValue) |
| | | { |
| | | DN dn = templateEntry.getDN(); |
| | | if ((dn == null) || dn.isRootDN()) |
| | | { |
| | | return TagResult.SUCCESS_RESULT; |
| | | } |
| | | else |
| | | if (dn != null && !dn.isRootDN()) |
| | | { |
| | | dn.rdn().toString(templateValue.getValue()); |
| | | return TagResult.SUCCESS_RESULT; |
| | | } |
| | | return TagResult.SUCCESS_RESULT; |
| | | } |
| | | } |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.tools.makeldif; |
| | | |
| | | import static org.opends.server.util.LDIFWriter.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.io.BufferedWriter; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.LDIFException; |
| | | |
| | | import static org.opends.server.util.LDIFWriter.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | /** |
| | | * This class defines an entry that is generated using a MakeLDIF branch or |
| | | * template. |
| | |
| | | builder.add(v.getValue().toString()); |
| | | } |
| | | |
| | | ArrayList<Attribute> attrList = new ArrayList<Attribute>(1); |
| | | attrList.add(builder.toAttribute()); |
| | | operationalAttributes.put(t, attrList); |
| | | operationalAttributes.put(t, asList(builder)); |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | ArrayList<Attribute> attrList = new ArrayList<Attribute>(1); |
| | | attrList.add(builder.toAttribute()); |
| | | userAttributes.put(t, attrList); |
| | | |
| | | userAttributes.put(t, asList(builder)); |
| | | if (urlBuilder != null) |
| | | { |
| | | ArrayList<Attribute> urlAttrList = new ArrayList<Attribute>(1); |
| | | urlAttrList.add(urlBuilder.toAttribute()); |
| | | urlAttributes.put(t, urlAttrList); |
| | | urlAttributes.put(t, asList(urlBuilder)); |
| | | } |
| | | |
| | | if (base64Builder != null) |
| | | { |
| | | ArrayList<Attribute> base64AttrList = new ArrayList<Attribute>(1); |
| | | base64AttrList.add(base64Builder.toAttribute()); |
| | | base64Attributes.put(t, base64AttrList); |
| | | base64Attributes.put(t, asList(base64Builder)); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | // First, write the DN. It will always be included. |
| | | StringBuilder dnLine = new StringBuilder(); |
| | | dnLine.append("dn"); |
| | | StringBuilder dnLine = new StringBuilder("dn"); |
| | | appendLDIFSeparatorAndValue(dnLine, |
| | | ByteString.valueOf(getDN().toString())); |
| | | writeLDIFLine(dnLine, writer, wrapLines, wrapColumn); |
| | |
| | | { |
| | | for (String s : objectClasses.values()) |
| | | { |
| | | StringBuilder ocLine = new StringBuilder(); |
| | | ocLine.append("objectClass: "); |
| | | ocLine.append(s); |
| | | StringBuilder ocLine = new StringBuilder("objectClass: ").append(s); |
| | | writeLDIFLine(ocLine, writer, wrapLines, wrapColumn); |
| | | } |
| | | } |
| | |
| | | { |
| | | if (exportConfig.includeAttribute(attrType)) |
| | | { |
| | | List<Attribute> attrList = userAttributes.get(attrType); |
| | | for (Attribute a : attrList) |
| | | for (Attribute a : userAttributes.get(attrType)) |
| | | { |
| | | if (a.isVirtual() && |
| | | (! exportConfig.includeVirtualAttributes())) |
| | |
| | | continue; |
| | | } |
| | | |
| | | StringBuilder attrName = attrNameWithOptions(a); |
| | | if (typesOnly) |
| | | { |
| | | StringBuilder attrName = new StringBuilder(a.getName()); |
| | | for (String o : a.getOptions()) |
| | | { |
| | | attrName.append(";"); |
| | | attrName.append(o); |
| | | } |
| | | attrName.append(":"); |
| | | |
| | | writeLDIFLine(attrName, writer, wrapLines, wrapColumn); |
| | | } |
| | | else |
| | | { |
| | | StringBuilder attrName = new StringBuilder(a.getName()); |
| | | for (String o : a.getOptions()) |
| | | { |
| | | attrName.append(";"); |
| | | attrName.append(o); |
| | | } |
| | | |
| | | List<Attribute> urlAttrList = urlAttributes.get(attrType); |
| | | List<Attribute> base64AttrList = base64Attributes.get(attrType); |
| | | |
| | | for (ByteString v : a) |
| | | { |
| | | StringBuilder attrLine = new StringBuilder(); |
| | | attrLine.append(attrName); |
| | | boolean isURLValue = false; |
| | | if (urlAttrList != null) |
| | | { |
| | | for (Attribute urlAttr : urlAttrList) |
| | | { |
| | | for (ByteString urlValue : urlAttr) |
| | | { |
| | | if (urlValue.equals(v)) |
| | | { |
| | | isURLValue = true; |
| | | break; |
| | | } |
| | | } |
| | | if (isURLValue) |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | boolean isBase64Value = false; |
| | | if (base64AttrList != null) |
| | | { |
| | | for (Attribute base64Attr : base64AttrList) |
| | | { |
| | | for (ByteString base64Value : base64Attr) |
| | | { |
| | | if (base64Value.equals(v)) |
| | | { |
| | | isBase64Value = true; |
| | | break; |
| | | } |
| | | } |
| | | if (isBase64Value) |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | StringBuilder attrLine = new StringBuilder(attrName); |
| | | boolean isURLValue = contains(urlAttrList, v); |
| | | boolean isBase64Value = contains(base64AttrList, v); |
| | | appendLDIFSeparatorAndValue(attrLine, |
| | | v, |
| | | isURLValue, |
| | |
| | | { |
| | | if (exportConfig.includeAttribute(attrType)) |
| | | { |
| | | List<Attribute> attrList = |
| | | operationalAttributes.get(attrType); |
| | | for (Attribute a : attrList) |
| | | for (Attribute a : operationalAttributes.get(attrType)) |
| | | { |
| | | if (a.isVirtual() && |
| | | (! exportConfig.includeVirtualAttributes())) |
| | |
| | | continue; |
| | | } |
| | | |
| | | StringBuilder attrName = attrNameWithOptions(a); |
| | | if (typesOnly) |
| | | { |
| | | StringBuilder attrName = new StringBuilder(a.getName()); |
| | | for (String o : a.getOptions()) |
| | | { |
| | | attrName.append(";"); |
| | | attrName.append(o); |
| | | } |
| | | attrName.append(":"); |
| | | |
| | | writeLDIFLine(attrName, writer, wrapLines, wrapColumn); |
| | | } |
| | | else |
| | | { |
| | | StringBuilder attrName = new StringBuilder(a.getName()); |
| | | for (String o : a.getOptions()) |
| | | { |
| | | attrName.append(";"); |
| | | attrName.append(o); |
| | | } |
| | | |
| | | for (ByteString v : a) |
| | | { |
| | | StringBuilder attrLine = new StringBuilder(); |
| | | attrLine.append(attrName); |
| | | StringBuilder attrLine = new StringBuilder(attrName); |
| | | appendLDIFSeparatorAndValue(attrLine, v); |
| | | writeLDIFLine(attrLine, writer, wrapLines, wrapColumn); |
| | | } |
| | |
| | | // Make sure there is a blank line after the entry. |
| | | writer.newLine(); |
| | | |
| | | |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | private StringBuilder attrNameWithOptions(Attribute a) |
| | | { |
| | | StringBuilder attrName = new StringBuilder(a.getName()); |
| | | for (String o : a.getOptions()) |
| | | { |
| | | attrName.append(";"); |
| | | attrName.append(o); |
| | | } |
| | | return attrName; |
| | | } |
| | | |
| | | private ArrayList<Attribute> asList(AttributeBuilder builder) |
| | | { |
| | | ArrayList<Attribute> attrList = new ArrayList<Attribute>(1); |
| | | attrList.add(builder.toAttribute()); |
| | | return attrList; |
| | | } |
| | | |
| | | private boolean contains(List<Attribute> urlAttrList, ByteString v) |
| | | { |
| | | if (urlAttrList != null) |
| | | { |
| | | for (Attribute urlAttr : urlAttrList) |
| | | { |
| | | for (ByteString urlValue : urlAttr) |
| | | { |
| | | if (urlValue.equals(v)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | } |
| | |
| | | { |
| | | // Get the corresponding read-write lock from the lock table. |
| | | ReentrantReadWriteLock existingLock = lockTable.get(entryDN); |
| | | if (existingLock == null) |
| | | { |
| | | // This shouldn't happen, but if it does then all we can do is |
| | | // release the lock and return. |
| | | lock.unlock(); |
| | | return; |
| | | } |
| | | |
| | | // See if there's anything waiting on the lock. If so, then we |
| | | // can't remove it from the table when we unlock it. |
| | | if (existingLock.hasQueuedThreads() || |
| | | (existingLock.getReadLockCount() > 1)) |
| | | // it should never be null, if it is is then all we can do is |
| | | // release the lock and return. |
| | | lock.unlock(); |
| | | if (existingLock != null |
| | | && !existingLock.hasQueuedThreads() |
| | | && existingLock.getReadLockCount() <= 1) |
| | | { |
| | | lock.unlock(); |
| | | return; |
| | | } |
| | | else |
| | | { |
| | | lock.unlock(); |
| | | synchronized (existingLock) |
| | | { |
| | | if ((! existingLock.isWriteLocked()) && |
| | | (existingLock.getReadLockCount() == 0)) |
| | | if (!existingLock.isWriteLocked() |
| | | && existingLock.getReadLockCount() == 0) |
| | | { |
| | | // If there's nothing waiting on the lock, |
| | | // then we can remove it from the table when we unlock it. |
| | | lockTable.remove(entryDN, existingLock); |
| | | } |
| | | } |
| | | return; |
| | | } |
| | | } |
| | | |
| | |
| | | // Write the changetype. Some older tools may not support the "moddn" |
| | | // changetype, so only use it if a newSuperior element has been provided, |
| | | // but use modrdn elsewhere. |
| | | if (newSuperior == null) |
| | | { |
| | | StringBuilder changeTypeLine = new StringBuilder("changetype: modrdn"); |
| | | writeLDIFLine(changeTypeLine, writer, wrapLines, wrapColumn); |
| | | } |
| | | else |
| | | { |
| | | StringBuilder changeTypeLine = new StringBuilder("changetype: moddn"); |
| | | writeLDIFLine(changeTypeLine, writer, wrapLines, wrapColumn); |
| | | } |
| | | String changeType = newSuperior == null ? "changetype: modrdn" : "changetype: moddn"; |
| | | writeLDIFLine(new StringBuilder(changeType), writer, wrapLines, wrapColumn); |
| | | |
| | | |
| | | // Write the newRDN element. |
| | |
| | | return; |
| | | } |
| | | |
| | | // Apply any changes to the entry based on the change in its RDN. |
| | | // Also perform schema checking on the updated entry. |
| | | applyRDNChanges(modifications); |
| | | |
| | | // If the operation is not a synchronization operation, |
| | | // - Apply the RDN changes. |
| | | // - Invoke the pre-operation modify DN plugins. |
| | |
| | | // - apply the operation as it was originally done on the master. |
| | | if (!isSynchronizationOperation()) |
| | | { |
| | | // Apply any changes to the entry based on the change in its RDN. |
| | | // Also perform schema checking on the updated entry. |
| | | applyRDNChanges(modifications); |
| | | |
| | | // Check for a request to cancel this operation. |
| | | checkIfCanceled(false); |
| | | |
| | |
| | | } |
| | | else |
| | | { |
| | | // This is a synchronization operation |
| | | // Apply the modifications as they were originally done. |
| | | applyRDNChanges(modifications); |
| | | applyPreOpModifications(modifications, 0, false); |
| | | } |
| | | |