Used CollectionUtils.newArrayList() and newLinkedList().
*.java:
Extracted a few methods to remove code duplication
| | |
| | | |
| | | import static org.opends.guitools.controlpanel.util.Utilities.*; |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | |
| | | /** |
| | | * The abstract table model used to display all the network groups. |
| | |
| | | CustomSearchResult monitor1 = desc1.getMonitoringEntry(); |
| | | CustomSearchResult monitor2 = desc2.getMonitoringEntry(); |
| | | |
| | | ArrayList<Integer> possibleResults = new ArrayList<>(); |
| | | possibleResults.add(getName(desc1).compareTo(getName(desc2))); |
| | | ArrayList<Integer> possibleResults = newArrayList(getName(desc1).compareTo(getName(desc2))); |
| | | computeMonitoringPossibleResults(monitor1, monitor2, possibleResults, attributes); |
| | | |
| | | int result = possibleResults.get(getSortColumn()); |
| | | if (result == 0) |
| | | { |
| | | for (int i : possibleResults) |
| | | { |
| | | if (i != 0) |
| | | { |
| | | result = i; |
| | | break; |
| | | } |
| | | } |
| | | result = getFirstNonZero(possibleResults); |
| | | } |
| | | if (!isSortAscending()) |
| | | { |
| | |
| | | return result; |
| | | } |
| | | |
| | | private int getFirstNonZero(ArrayList<Integer> possibleResults) |
| | | { |
| | | for (int i : possibleResults) |
| | | { |
| | | if (i != 0) |
| | | { |
| | | return i; |
| | | } |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | /** |
| | | * Returns whether the sort is ascending or descending. |
| | | * @return <CODE>true</CODE> if the sort is ascending and <CODE>false</CODE> |
| | |
| | | package org.opends.guitools.controlpanel.task; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | |
| | | |
| | | import javax.swing.SwingUtilities; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo; |
| | | import org.opends.guitools.controlpanel.ui.ColorAndFontConstants; |
| | | import org.opends.guitools.controlpanel.ui.ProgressDialog; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.OpenDsException; |
| | |
| | | /** |
| | | * The task that is in charge of modifying an attribute definition (and all |
| | | * the references to this attribute). |
| | | * |
| | | */ |
| | | public class ModifyAttributeTask extends Task |
| | | { |
| | |
| | | private void updateSchema() throws OpenDsException |
| | | { |
| | | Schema schema = getInfo().getServerDescriptor().getSchema(); |
| | | ArrayList<AttributeType> attrs = new ArrayList<>(); |
| | | attrs.add(oldAttribute); |
| | | ArrayList<AttributeType> attrs = newArrayList(oldAttribute); |
| | | LinkedHashSet<AttributeType> attrsToDelete = |
| | | DeleteSchemaElementsTask.getOrderedAttributesToDelete(attrs, schema); |
| | | LinkedHashSet<ObjectClass> ocsToDelete = |
| | |
| | | package org.opends.guitools.controlpanel.task; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | |
| | | private void updateSchema() throws OpenDsException |
| | | { |
| | | Schema schema = getInfo().getServerDescriptor().getSchema(); |
| | | ArrayList<ObjectClass> ocs = new ArrayList<>(); |
| | | ocs.add(oldObjectClass); |
| | | ArrayList<ObjectClass> ocs = newArrayList(oldObjectClass); |
| | | LinkedHashSet<ObjectClass> ocsToDelete = |
| | | DeleteSchemaElementsTask.getOrderedObjectClassesToDelete(ocs, schema); |
| | | |
| | |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.server.types.CommonSchemaElements.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | |
| | | import java.awt.Component; |
| | | import java.awt.Container; |
| | |
| | | import javax.swing.event.DocumentEvent; |
| | | import javax.swing.event.DocumentListener; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.schema.AttributeUsage; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.guitools.controlpanel.datamodel.ServerDescriptor; |
| | | import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent; |
| | | import org.opends.guitools.controlpanel.event. |
| | | ConfigurationElementCreatedListener; |
| | | import org.opends.guitools.controlpanel.event.ConfigurationElementCreatedListener; |
| | | import org.opends.guitools.controlpanel.event.ScrollPaneBorderListener; |
| | | import org.opends.guitools.controlpanel.task.DeleteSchemaElementsTask; |
| | | import org.opends.guitools.controlpanel.task.ModifyAttributeTask; |
| | | import org.opends.guitools.controlpanel.task.Task; |
| | | import org.opends.guitools.controlpanel.ui.components.BasicExpander; |
| | | import org.opends.guitools.controlpanel.ui.components.TitlePanel; |
| | | import org.opends.guitools.controlpanel.ui.renderer. |
| | | SchemaElementComboBoxCellRenderer; |
| | | import org.opends.guitools.controlpanel.ui.renderer.SchemaElementComboBoxCellRenderer; |
| | | import org.opends.guitools.controlpanel.util.LowerCaseComparator; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeUsage; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.Schema; |
| | | import org.opends.server.util.ServerConstants; |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | | import static org.opends.server.types.CommonSchemaElements.*; |
| | | |
| | | /** |
| | | * The panel that displays a custom attribute definition. |
| | | */ |
| | |
| | | availableMatchingRules.add(matchingRuleNameMap.get(key)); |
| | | } |
| | | JComboBox[] combos = {approximate, equality, ordering, substring}; |
| | | for (int i = 0; i < combos.length; i++) |
| | | for (JComboBox<LocalizableMessage> combo : combos) |
| | | { |
| | | final DefaultComboBoxModel model = (DefaultComboBoxModel)combos[i].getModel(); |
| | | final DefaultComboBoxModel<LocalizableMessage> model = (DefaultComboBoxModel) combo.getModel(); |
| | | final List<Object> el = new ArrayList<Object>(availableMatchingRules); |
| | | if (model.getSize() == 0) |
| | | { |
| | |
| | | String f = file.getText().trim(); |
| | | if (f.length() > 0) |
| | | { |
| | | ArrayList<String> list = new ArrayList<>(); |
| | | list.add(f); |
| | | map.put(ServerConstants.SCHEMA_PROPERTY_FILENAME, list); |
| | | map.put(ServerConstants.SCHEMA_PROPERTY_FILENAME, newArrayList(f)); |
| | | } |
| | | String or = origin.getText().trim(); |
| | | if (or.length() > 0) |
| | | { |
| | | ArrayList<String> list = new ArrayList<>(); |
| | | list.add(or); |
| | | map.put(ServerConstants.SCHEMA_PROPERTY_ORIGIN, list); |
| | | map.put(ServerConstants.SCHEMA_PROPERTY_ORIGIN, newArrayList(or)); |
| | | } |
| | | return map; |
| | | } |
| | |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.server.types.CommonSchemaElements.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | |
| | | import java.awt.Component; |
| | | import java.awt.Container; |
| | |
| | | import javax.swing.event.ListDataEvent; |
| | | import javax.swing.event.ListDataListener; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClassType; |
| | | import org.opends.guitools.controlpanel.datamodel.ServerDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.SortableListModel; |
| | | import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent; |
| | | import org.opends.guitools.controlpanel.event. |
| | | ConfigurationElementCreatedListener; |
| | | import org.opends.guitools.controlpanel.event.SuperiorObjectClassesChangedEvent; |
| | | import org.opends.guitools.controlpanel.event. |
| | | SuperiorObjectClassesChangedListener; |
| | | import org.opends.guitools.controlpanel.event.ConfigurationElementCreatedListener; |
| | | import org.opends.guitools.controlpanel.event.ScrollPaneBorderListener; |
| | | import org.opends.guitools.controlpanel.event.SuperiorObjectClassesChangedEvent; |
| | | import org.opends.guitools.controlpanel.event.SuperiorObjectClassesChangedListener; |
| | | import org.opends.guitools.controlpanel.task.DeleteSchemaElementsTask; |
| | | import org.opends.guitools.controlpanel.task.ModifyObjectClassTask; |
| | | import org.opends.guitools.controlpanel.task.Task; |
| | | import org.opends.guitools.controlpanel.ui.components.BasicExpander; |
| | | import org.opends.guitools.controlpanel.ui.components.DoubleAddRemovePanel; |
| | | import org.opends.guitools.controlpanel.ui.components. |
| | | SuperiorObjectClassesEditor; |
| | | import org.opends.guitools.controlpanel.ui.components.SuperiorObjectClassesEditor; |
| | | import org.opends.guitools.controlpanel.ui.components.TitlePanel; |
| | | import org.opends.guitools.controlpanel.ui.renderer. |
| | | SchemaElementComboBoxCellRenderer; |
| | | import org.opends.guitools.controlpanel.ui.renderer.SchemaElementComboBoxCellRenderer; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClassType; |
| | | import org.opends.server.types.Schema; |
| | | import org.opends.server.util.ServerConstants; |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | | import static org.opends.server.types.CommonSchemaElements.*; |
| | | |
| | | /** |
| | | * The panel that displays a custom object class definition. |
| | | * |
| | | */ |
| | | /** The panel that displays a custom object class definition. */ |
| | | public class CustomObjectClassPanel extends SchemaElementPanel |
| | | { |
| | | private static final long serialVersionUID = 2105520588901380L; |
| | |
| | | String f = file.getText().trim(); |
| | | if (f.length() > 0) |
| | | { |
| | | ArrayList<String> list = new ArrayList<>(); |
| | | list.add(f); |
| | | map.put(ServerConstants.SCHEMA_PROPERTY_FILENAME, list); |
| | | map.put(ServerConstants.SCHEMA_PROPERTY_FILENAME, newArrayList(f)); |
| | | } |
| | | String or = origin.getText().trim(); |
| | | if (or.length() > 0) |
| | | { |
| | | ArrayList<String> list = new ArrayList<>(); |
| | | list.add(or); |
| | | map.put(ServerConstants.SCHEMA_PROPERTY_ORIGIN, list); |
| | | map.put(ServerConstants.SCHEMA_PROPERTY_ORIGIN, newArrayList(or)); |
| | | } |
| | | return map; |
| | | } |
| | |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | |
| | | import java.awt.Component; |
| | | import java.awt.Dimension; |
| | |
| | | import java.awt.Insets; |
| | | import java.awt.event.ActionEvent; |
| | | import java.awt.event.ActionListener; |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.LinkedHashSet; |
| | | |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | /** |
| | | * |
| | | * The panel that allows the user to select which attributes must be displayed |
| | | * in the traffic monitoring tables. |
| | | * |
| | |
| | | } |
| | | if (selectedAttributes.isEmpty()) |
| | | { |
| | | ArrayList<LocalizableMessage> errors = new ArrayList<>(); |
| | | errors.add(INFO_CTRL_PANEL_NO_OPERATION_SELECTED.get()); |
| | | super.displayErrorDialog(errors); |
| | | super.displayErrorDialog(newArrayList(INFO_CTRL_PANEL_NO_OPERATION_SELECTED.get())); |
| | | } |
| | | else |
| | | { |
| | |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | |
| | | import java.awt.Component; |
| | | import java.awt.GridBagConstraints; |
| | |
| | | import javax.swing.event.ChangeEvent; |
| | | import javax.swing.event.ChangeListener; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClassType; |
| | | import org.opends.guitools.controlpanel.datamodel.ServerDescriptor; |
| | | import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent; |
| | | import org.opends.guitools.controlpanel.event. |
| | | ConfigurationElementCreatedListener; |
| | | import org.opends.guitools.controlpanel.event.ConfigurationElementCreatedListener; |
| | | import org.opends.guitools.controlpanel.event.SuperiorObjectClassesChangedEvent; |
| | | import org.opends.guitools.controlpanel.event. |
| | | SuperiorObjectClassesChangedListener; |
| | | import org.opends.guitools.controlpanel.event.SuperiorObjectClassesChangedListener; |
| | | import org.opends.guitools.controlpanel.task.NewSchemaElementsTask; |
| | | import org.opends.guitools.controlpanel.task.Task; |
| | | import org.opends.guitools.controlpanel.ui.components.BasicExpander; |
| | | import org.opends.guitools.controlpanel.ui.components.DoubleAddRemovePanel; |
| | | import org.opends.guitools.controlpanel.ui.components. |
| | | SuperiorObjectClassesEditor; |
| | | import |
| | | org.opends.guitools.controlpanel.ui.renderer.SchemaElementComboBoxCellRenderer; |
| | | import org.opends.guitools.controlpanel.ui.components.SuperiorObjectClassesEditor; |
| | | import org.opends.guitools.controlpanel.ui.renderer.SchemaElementComboBoxCellRenderer; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.opends.server.config.ConfigConstants; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClassType; |
| | | import org.opends.server.types.Schema; |
| | | import org.opends.server.util.ServerConstants; |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | | /** |
| | | * The panel displayed when the user wants to define a new object class in the |
| | | * schema. |
| | | * |
| | | */ |
| | | /** The panel displayed when the user wants to define a new object class in the schema. */ |
| | | public class NewObjectClassPanel extends StatusGenericPanel |
| | | { |
| | | private static final long serialVersionUID = -4956885827963184571L; |
| | |
| | | if (sel != null) |
| | | { |
| | | ArrayList<Integer> indexes = new ArrayList<>(); |
| | | for (int j=0; j<sel.length; j++) |
| | | for (int element : sel) |
| | | { |
| | | if (sel[j] < lists[i].getModel().getSize()) |
| | | if (element < lists[i].getModel().getSize()) |
| | | { |
| | | indexes.add(sel[j]); |
| | | indexes.add(element); |
| | | } |
| | | } |
| | | int[] newSelection = new int[indexes.size()]; |
| | |
| | | String f = file.getText().trim(); |
| | | if (f.length() > 0) |
| | | { |
| | | ArrayList<String> list = new ArrayList<>(); |
| | | list.add(f); |
| | | map.put(ServerConstants.SCHEMA_PROPERTY_FILENAME, list); |
| | | map.put(ServerConstants.SCHEMA_PROPERTY_FILENAME, newArrayList(f)); |
| | | } |
| | | String or = origin.getText().trim(); |
| | | if (or.length() > 0) |
| | | { |
| | | ArrayList<String> list = new ArrayList<>(); |
| | | list.add(or); |
| | | map.put(ServerConstants.SCHEMA_PROPERTY_ORIGIN, list); |
| | | map.put(ServerConstants.SCHEMA_PROPERTY_ORIGIN, newArrayList(or)); |
| | | } |
| | | return map; |
| | | } |
| | |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | |
| | | import java.awt.Container; |
| | | import java.awt.GridBagConstraints; |
| | |
| | | { |
| | | org.opends.server.types.Attribute attr = |
| | | Attributes.create(rdn.getAttributeType(i), value); |
| | | ArrayList<ByteString> newValues = new ArrayList<>(); |
| | | newValues.add(value); |
| | | entry.addAttribute(attr, newValues); |
| | | entry.addAttribute(attr, newArrayList(value)); |
| | | } |
| | | } |
| | | } |
| | |
| | | import org.opends.quicksetup.installer.NewSuffixOptions; |
| | | import org.opends.quicksetup.installer.SuffixesToReplicateOptions; |
| | | import org.opends.quicksetup.util.Utils; |
| | | import org.opends.server.util.CollectionUtils; |
| | | |
| | | import com.forgerock.opendj.cli.CliConstants; |
| | | |
| | |
| | | public class UserData |
| | | { |
| | | private String serverLocation; |
| | | |
| | | private String hostName; |
| | | |
| | | private int serverPort; |
| | | |
| | | private int adminConnectorPort; |
| | | |
| | | private String directoryManagerDn; |
| | | |
| | | private String directoryManagerPwd; |
| | | |
| | | private String globalAdministratorUID; |
| | | |
| | | private String globalAdministratorPassword; |
| | | |
| | | private SecurityOptions securityOptions; |
| | | private int serverJMXPort = -1; |
| | | |
| | | private boolean startServer; |
| | | |
| | | private boolean stopServer; |
| | | |
| | | private boolean enableWindowsService; |
| | | private boolean createAdministrator; |
| | | private boolean quiet; |
| | | private boolean verbose; |
| | | private boolean interactive; |
| | | private boolean forceOnError; |
| | | |
| | | private ManagedObjectDefinition<? extends BackendCfgClient, ? extends BackendCfg> backendType; |
| | | |
| | | private NewSuffixOptions newSuffixOptions; |
| | | |
| | | private DataReplicationOptions replicationOptions; |
| | | |
| | | private boolean createAdministrator; |
| | | |
| | | private SuffixesToReplicateOptions suffixesToReplicateOptions; |
| | | |
| | | private final Map<ServerDescriptor, AuthenticationData> |
| | | remoteWithNoReplicationPort; |
| | | |
| | | private boolean quiet; |
| | | |
| | | private boolean verbose; |
| | | |
| | | private boolean interactive; |
| | | |
| | | private boolean forceOnError; |
| | | private final Map<ServerDescriptor, AuthenticationData> remoteWithNoReplicationPort; |
| | | |
| | | private Map<String, JavaArguments> hmJavaArguments; |
| | | private Map<String, JavaArguments> hmDefaultJavaArguments; |
| | |
| | | forceOnError = true; |
| | | verbose = false; |
| | | |
| | | LinkedList<String> baseDn = new LinkedList<>(); |
| | | baseDn.add("dc=example,dc=com"); |
| | | LinkedList<String> baseDn = CollectionUtils.newLinkedList("dc=example,dc=com"); |
| | | NewSuffixOptions defaultNewSuffixOptions = NewSuffixOptions.createEmpty(baseDn); |
| | | setNewSuffixOptions(defaultNewSuffixOptions); |
| | | |
| | |
| | | import static com.forgerock.opendj.util.OperatingSystem.*; |
| | | |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | |
| | | * Runtime.exec (which is required to update the file system permissions). |
| | | */ |
| | | Map<String, ArrayList<String>> permissions = new HashMap<>(); |
| | | ArrayList<String> list = new ArrayList<>(); |
| | | list.add(destDir); |
| | | permissions.put(getProtectedDirectoryPermissionUnix(), list); |
| | | permissions.put(getProtectedDirectoryPermissionUnix(), newArrayList(destDir)); |
| | | try { |
| | | if(application != null) { |
| | | application.checkAbort(); |
| | |
| | | for (int i=0; i < rdn.getNumValues(); i++) |
| | | { |
| | | AttributeType type = rdn.getAttributeType(i); |
| | | List<Attribute> attrList = new LinkedList<>(); |
| | | attrList.add(Attributes.create(type, rdn.getAttributeValue(i))); |
| | | List<Attribute> attrList = newLinkedList(Attributes.create(type, rdn.getAttributeValue(i))); |
| | | if (type.isOperational()) |
| | | { |
| | | operationalAttributes.put(type, attrList); |
| | |
| | | { |
| | | Entry taskEntry = getTaskEntry(); |
| | | |
| | | ArrayList<Modification> modifications = new ArrayList<>(); |
| | | modifications.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create(name, value))); |
| | | List<Modification> modifications = newArrayList( |
| | | new Modification(ModificationType.REPLACE, Attributes.create(name, value))); |
| | | |
| | | taskEntry.applyModifications(modifications); |
| | | } |
| | |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault( |
| | | ATTR_TASK_LOG_MESSAGES.toLowerCase(), ATTR_TASK_LOG_MESSAGES); |
| | | |
| | | List<Attribute> attrList = taskEntry.getAttribute(type); |
| | | final List<Attribute> attrList = taskEntry.getAttribute(type); |
| | | ByteString value = ByteString.valueOf(messageString); |
| | | if (attrList == null) |
| | | { |
| | | attrList = new ArrayList<>(); |
| | | attrList.add(Attributes.create(type, value)); |
| | | taskEntry.putAttribute(type, attrList); |
| | | taskEntry.putAttribute(type, newArrayList(Attributes.create(type, value))); |
| | | } |
| | | else if (attrList.isEmpty()) |
| | | { |
| | |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.CollectionUtils; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | |
| | | this.hasUpperBound = hasUpperBound; |
| | | this.upperBound = upperBound; |
| | | |
| | | activeValues = new ArrayList<>(1); |
| | | activeValues.add(value); |
| | | |
| | | activeValues = CollectionUtils.newArrayList(value); |
| | | pendingValues = activeValues; |
| | | } |
| | | |
| | |
| | | |
| | | if (requiresAdminAction()) |
| | | { |
| | | pendingValues = new ArrayList<>(1); |
| | | pendingValues.add(value); |
| | | pendingValues = CollectionUtils.newArrayList(value); |
| | | setPendingValues(getValueSet(value)); |
| | | } |
| | | else |
| | |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | |
| | | if (iterator.hasNext()) |
| | | { |
| | | List<String> stringValues = new ArrayList<>(); |
| | | stringValues.add(value.toString()); |
| | | |
| | | List<String> stringValues = newArrayList(value.toString()); |
| | | while (iterator.hasNext()) |
| | | { |
| | | value = iterator.next(); |
| | |
| | | |
| | | if (iterator.hasNext()) |
| | | { |
| | | List<String> stringValues = new ArrayList<>(); |
| | | stringValues.add(value.toString()); |
| | | |
| | | List<String> stringValues = newArrayList(value.toString()); |
| | | while (iterator.hasNext()) |
| | | { |
| | | value = iterator.next(); |
| | |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.CollectionUtils; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | |
| | | } |
| | | else |
| | | { |
| | | activeValues = new ArrayList<>(1); |
| | | activeValues.add(value); |
| | | activeValues = CollectionUtils.newArrayList(value); |
| | | } |
| | | |
| | | pendingValues = activeValues; |
| | |
| | | |
| | | if (requiresAdminAction()) |
| | | { |
| | | pendingValues = new ArrayList<>(1); |
| | | pendingValues.add(value); |
| | | pendingValues = CollectionUtils.newArrayList(value); |
| | | setPendingValues(getValueSet(value)); |
| | | } |
| | | else |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | /** |
| | | * This class defines a configuration attribute that is only intended for use |
| | |
| | | } |
| | | else |
| | | { |
| | | values = new ArrayList<>(1); |
| | | values.add(value); |
| | | values = newArrayList(value); |
| | | } |
| | | } |
| | | |
| | |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | |
| | |
| | | } |
| | | else |
| | | { |
| | | activeValues = new ArrayList<>(1); |
| | | activeValues.add(value); |
| | | activeValues = newArrayList(value); |
| | | } |
| | | |
| | | pendingValues = activeValues; |
| | |
| | | |
| | | if (requiresAdminAction()) |
| | | { |
| | | pendingValues = new ArrayList<>(1); |
| | | pendingValues.add(value); |
| | | pendingValues = newArrayList(value); |
| | | setPendingValues(getValueSet(value)); |
| | | } |
| | | else |
| | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.DynamicConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | int supportedLDAPVersion, |
| | | ConnectionHandler connectionHandler) |
| | | { |
| | | List<ConnectionHandler> handlers = |
| | | directoryServer.supportedLDAPVersions.get(supportedLDAPVersion); |
| | | List<ConnectionHandler> handlers = directoryServer.supportedLDAPVersions.get(supportedLDAPVersion); |
| | | if (handlers == null) |
| | | { |
| | | handlers = new LinkedList<>(); |
| | | handlers.add(connectionHandler); |
| | | directoryServer.supportedLDAPVersions.put(supportedLDAPVersion, handlers); |
| | | directoryServer.supportedLDAPVersions.put(supportedLDAPVersion, newLinkedList(connectionHandler)); |
| | | } |
| | | else |
| | | else if (!handlers.contains(connectionHandler)) |
| | | { |
| | | if (! handlers.contains(connectionHandler)) |
| | | { |
| | | handlers.add(connectionHandler); |
| | | } |
| | | handlers.add(connectionHandler); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | import static org.opends.messages.CoreMessages.*; |
| | | import static org.opends.server.core.DirectoryServer.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.ALERT_DESCRIPTION_DISK_FULL; |
| | | import static org.opends.server.util.ServerConstants.ALERT_DESCRIPTION_DISK_SPACE_LOW; |
| | | import static org.opends.server.util.ServerConstants.ALERT_TYPE_DISK_FULL; |
| | |
| | | List<MonitoredDirectory> diskHelpers = monitoredDirs.get(fsMountPoint); |
| | | if (diskHelpers == null) |
| | | { |
| | | List<MonitoredDirectory> newList = new ArrayList<>(); |
| | | newList.add(newDSH); |
| | | monitoredDirs.put(fsMountPoint, newList); |
| | | monitoredDirs.put(fsMountPoint, newArrayList(newDSH)); |
| | | } |
| | | else |
| | | { |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | |
| | | import java.util.Iterator; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.LinkedHashSet; |
| | |
| | | import java.util.concurrent.LinkedBlockingQueue; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDAPURL; |
| | | import org.opends.server.types.MemberList; |
| | | import org.opends.server.types.MembershipException; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | |
| | | /** |
| | | * This class defines a mechanism that may be used to iterate over the |
| | |
| | | // the same hierarchy. |
| | | if (baseDNs.isEmpty()) |
| | | { |
| | | LinkedList<LDAPURL> urlList = new LinkedList<>(); |
| | | urlList.add(memberURL); |
| | | baseDNs.put(urlBaseDN, urlList); |
| | | baseDNs.put(urlBaseDN, newLinkedList(memberURL)); |
| | | } |
| | | else |
| | | { |
| | |
| | | |
| | | if (! found) |
| | | { |
| | | urlList = new LinkedList<>(); |
| | | urlList.add(memberURL); |
| | | baseDNs.put(urlBaseDN, urlList); |
| | | baseDNs.put(urlBaseDN, newLinkedList(memberURL)); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | // There was already a list with the same base DN, so just add the |
| | | // URL. |
| | | // There was already a list with the same base DN, so just add the URL. |
| | | urlList.add(memberURL); |
| | | } |
| | | } |
| | |
| | | import org.opends.server.admin.std.server.GroupImplementationCfg; |
| | | import org.opends.server.admin.std.server.StaticGroupImplementationCfg; |
| | | import org.opends.server.api.Group; |
| | | import org.opends.server.core.ModifyOperationBasis; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.core.ModifyOperationBasis; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryConfig; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.MemberList; |
| | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | import static org.opends.server.core.DirectoryServer.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.forgerock.util.Reject.*; |
| | | |
| | |
| | | throw new DirectoryException(ResultCode.ATTRIBUTE_OR_VALUE_EXISTS, msg); |
| | | } |
| | | |
| | | Attribute attr = Attributes.create(memberAttributeType, nestedGroupDN.toString()); |
| | | LinkedList<Modification> mods = new LinkedList<>(); |
| | | mods.add(new Modification(ModificationType.ADD, attr)); |
| | | |
| | | LinkedList<Control> requestControls = new LinkedList<>(); |
| | | requestControls.add(new LDAPControl(OID_INTERNAL_GROUP_MEMBERSHIP_UPDATE, false)); |
| | | |
| | | ModifyOperationBasis modifyOperation = new ModifyOperationBasis( |
| | | getRootConnection(), nextOperationID(), nextMessageID(), requestControls, groupEntryDN, mods); |
| | | ModifyOperation modifyOperation = newModifyOperation(ModificationType.ADD, nestedGroupDN); |
| | | modifyOperation.run(); |
| | | if (modifyOperation.getResultCode() != ResultCode.SUCCESS) |
| | | { |
| | |
| | | ERR_STATICGROUP_REMOVE_NESTED_GROUP_NO_SUCH_GROUP.get(nestedGroupDN, groupEntryDN)); |
| | | } |
| | | |
| | | Attribute attr = Attributes.create(memberAttributeType, nestedGroupDN.toString()); |
| | | LinkedList<Modification> mods = new LinkedList<>(); |
| | | mods.add(new Modification(ModificationType.DELETE, attr)); |
| | | |
| | | LinkedList<Control> requestControls = new LinkedList<>(); |
| | | requestControls.add(new LDAPControl(OID_INTERNAL_GROUP_MEMBERSHIP_UPDATE, false)); |
| | | |
| | | ModifyOperationBasis modifyOperation = new ModifyOperationBasis( |
| | | getRootConnection(), nextOperationID(), nextMessageID(), requestControls, groupEntryDN, mods); |
| | | ModifyOperation modifyOperation = newModifyOperation(ModificationType.DELETE, nestedGroupDN); |
| | | modifyOperation.run(); |
| | | if (modifyOperation.getResultCode() != ResultCode.SUCCESS) |
| | | { |
| | |
| | | throw new DirectoryException(ResultCode.ATTRIBUTE_OR_VALUE_EXISTS, message); |
| | | } |
| | | |
| | | Attribute attr = Attributes.create(memberAttributeType, userDN.toString()); |
| | | LinkedList<Modification> mods = new LinkedList<>(); |
| | | mods.add(new Modification(ModificationType.ADD, attr)); |
| | | |
| | | LinkedList<Control> requestControls = new LinkedList<>(); |
| | | requestControls.add(new LDAPControl(OID_INTERNAL_GROUP_MEMBERSHIP_UPDATE, false)); |
| | | |
| | | ModifyOperationBasis modifyOperation = new ModifyOperationBasis( |
| | | getRootConnection(), nextOperationID(), nextMessageID(), requestControls, groupEntryDN, mods); |
| | | ModifyOperation modifyOperation = newModifyOperation(ModificationType.ADD, userDN); |
| | | modifyOperation.run(); |
| | | if (modifyOperation.getResultCode() != ResultCode.SUCCESS) |
| | | { |
| | |
| | | throw new DirectoryException(ResultCode.NO_SUCH_ATTRIBUTE, message); |
| | | } |
| | | |
| | | Attribute attr = Attributes.create(memberAttributeType, userDN.toString()); |
| | | LinkedList<Modification> mods = new LinkedList<>(); |
| | | mods.add(new Modification(ModificationType.DELETE, attr)); |
| | | |
| | | LinkedList<Control> requestControls = new LinkedList<>(); |
| | | requestControls.add(new LDAPControl(OID_INTERNAL_GROUP_MEMBERSHIP_UPDATE, false)); |
| | | |
| | | ModifyOperationBasis modifyOperation = new ModifyOperationBasis( |
| | | getRootConnection(), nextOperationID(), nextMessageID(), requestControls, groupEntryDN, mods); |
| | | ModifyOperation modifyOperation = newModifyOperation(ModificationType.DELETE, userDN); |
| | | modifyOperation.run(); |
| | | if (modifyOperation.getResultCode() != ResultCode.SUCCESS) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private ModifyOperation newModifyOperation(ModificationType modType, DN userDN) |
| | | { |
| | | Attribute attr = Attributes.create(memberAttributeType, userDN.toString()); |
| | | LinkedList<Modification> mods = newLinkedList(new Modification(modType, attr)); |
| | | Control control = new LDAPControl(OID_INTERNAL_GROUP_MEMBERSHIP_UPDATE, false); |
| | | |
| | | return new ModifyOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), |
| | | newLinkedList(control), groupEntryDN, mods); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void toString(StringBuilder buffer) |
| | |
| | | */ |
| | | package org.opends.server.monitors; |
| | | |
| | | import java.util.ArrayList; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.TreeMap; |
| | |
| | | } |
| | | } |
| | | |
| | | ArrayList<Attribute> attrs = new ArrayList<>(); |
| | | attrs.add(builder.toAttribute()); |
| | | return attrs; |
| | | return newArrayList(builder.toAttribute()); |
| | | } |
| | | } |
| | |
| | | |
| | | import static org.opends.messages.ProtocolMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | try |
| | | { |
| | | LinkedHashMap<ObjectClass,String> objectClasses = new LinkedHashMap<>(); |
| | | ObjectClass topOC = DirectoryServer.getTopObjectClass(); |
| | | ObjectClass personOC = DirectoryServer.getObjectClass(OC_PERSON, true); |
| | | ObjectClass rootOC = DirectoryServer.getObjectClass(OC_ROOT_DN, true); |
| | | |
| | | objectClasses.put(topOC, topOC.getPrimaryName()); |
| | | objectClasses.put(personOC, personOC.getPrimaryName()); |
| | | objectClasses.put(rootOC, rootOC.getPrimaryName()); |
| | | |
| | | put(objectClasses, DirectoryServer.getTopObjectClass()); |
| | | put(objectClasses, DirectoryServer.getObjectClass(OC_PERSON, true)); |
| | | put(objectClasses, DirectoryServer.getObjectClass(OC_ROOT_DN, true)); |
| | | |
| | | LinkedHashMap<AttributeType,List<Attribute>> userAttrs = new LinkedHashMap<>(); |
| | | AttributeType cnAT = DirectoryServer.getAttributeTypeOrDefault(ATTR_COMMON_NAME); |
| | | AttributeType snAT = DirectoryServer.getAttributeTypeOrDefault(ATTR_SN); |
| | | AttributeType altDNAT = DirectoryServer.getAttributeTypeOrDefault(ATTR_ROOTDN_ALTERNATE_BIND_DN); |
| | | |
| | | LinkedList<Attribute> attrList = new LinkedList<>(); |
| | | attrList.add(Attributes.create(ATTR_COMMON_NAME, commonName)); |
| | | userAttrs.put(cnAT, attrList); |
| | | |
| | | attrList = new LinkedList<>(); |
| | | attrList.add(Attributes.create(ATTR_SN, commonName)); |
| | | userAttrs.put(snAT, attrList); |
| | | |
| | | attrList = new LinkedList<>(); |
| | | attrList.add(Attributes.create(ATTR_ROOTDN_ALTERNATE_BIND_DN, shortDNString)); |
| | | userAttrs.put(altDNAT, attrList); |
| | | |
| | | |
| | | LinkedHashMap<AttributeType,List<Attribute>> operationalAttrs = new LinkedHashMap<>(); |
| | | put(userAttrs, ATTR_COMMON_NAME, commonName); |
| | | put(userAttrs, ATTR_SN, commonName); |
| | | put(userAttrs, ATTR_ROOTDN_ALTERNATE_BIND_DN, shortDNString); |
| | | |
| | | AttributeType privType = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PRIVILEGE_NAME); |
| | | AttributeBuilder builder = new AttributeBuilder(privType); |
| | |
| | | { |
| | | builder.add(p.getName()); |
| | | } |
| | | attrList = new LinkedList<>(); |
| | | attrList.add(builder.toAttribute()); |
| | | |
| | | operationalAttrs.put(privType, attrList); |
| | | LinkedHashMap<AttributeType, List<Attribute>> operationalAttrs = new LinkedHashMap<>(); |
| | | operationalAttrs.put(privType, builder.toAttributeList()); |
| | | |
| | | |
| | | DN internalUserDN = DN.valueOf(fullDNString); |
| | |
| | | connectionID = nextConnectionID.getAndDecrement(); |
| | | } |
| | | |
| | | private void put(Map<ObjectClass, String> objectClasses, ObjectClass oc) |
| | | { |
| | | objectClasses.put(oc, oc.getPrimaryName()); |
| | | } |
| | | |
| | | private void put(Map<AttributeType, List<Attribute>> Attrs, String attrName, String value) |
| | | { |
| | | List<Attribute> attrs = newLinkedList(Attributes.create(attrName, value)); |
| | | Attrs.put(DirectoryServer.getAttributeTypeOrDefault(attrName), attrs); |
| | | } |
| | | |
| | | /** |
| | | * Creates a new internal client connection that will be |
| | |
| | | package org.opends.server.replication.plugin; |
| | | |
| | | import static org.opends.messages.ReplicationMessages.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | |
| | | import java.util.*; |
| | | |
| | |
| | | List<Modification> mods = modifyOperation.getModifications(); |
| | | CSN modOpCSN = OperationContext.getCSN(modifyOperation); |
| | | |
| | | for (Iterator<Modification> modsIterator = mods.iterator(); |
| | | modsIterator.hasNext(); ) |
| | | for (Iterator<Modification> it = mods.iterator(); it.hasNext(); ) |
| | | { |
| | | // Traverse the mods of this MOD operation |
| | | Modification m = modsIterator.next(); |
| | | Modification m = it.next(); |
| | | |
| | | // Read or create the attr historical for the attribute type and option |
| | | // contained in the mod |
| | | AttrHistorical attrHist = getOrCreateAttrHistorical(m); |
| | | |
| | | if (attrHist.replayOperation(modsIterator, modOpCSN, modifiedEntry, m)) |
| | | if (attrHist.replayOperation(it, modOpCSN, modifiedEntry, m)) |
| | | { |
| | | bConflict = true; |
| | | } |
| | |
| | | Attribute attr = Attributes.create(historicalAttrType, attrValue); |
| | | |
| | | // Set the created attribute to the operation |
| | | List<Attribute> attrList = new LinkedList<>(); |
| | | attrList.add(attr); |
| | | addOperation.setAttribute(historicalAttrType, attrList); |
| | | addOperation.setAttribute(historicalAttrType, newLinkedList(attr)); |
| | | } |
| | | |
| | | /** |
| | |
| | | import static org.opends.server.replication.protocol.ProtocolVersion.*; |
| | | import static org.opends.server.replication.server.changelog.api.DBCursor.KeyMatchingStrategy.*; |
| | | import static org.opends.server.replication.server.changelog.api.DBCursor.PositionStrategy.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | // Create info for the local RS |
| | | List<RSInfo> rsInfos = new ArrayList<>(); |
| | | rsInfos.add(toRSInfo(localReplicationServer, generationId)); |
| | | List<RSInfo> rsInfos = newArrayList(toRSInfo(localReplicationServer, generationId)); |
| | | |
| | | return new TopologyMsg(dsInfos, rsInfos); |
| | | } |
| | |
| | | import static org.opends.messages.ReplicationMessages.*; |
| | | import static org.opends.server.replication.common.AssuredMode.*; |
| | | import static org.opends.server.replication.common.StatusMachine.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | |
| | | import java.io.BufferedOutputStream; |
| | | import java.io.IOException; |
| | |
| | | // -> replay error occurred |
| | | ackMsg.setHasReplayError(true); |
| | | // -> replay error occurred in our server |
| | | List<Integer> idList = new ArrayList<>(); |
| | | idList.add(getServerId()); |
| | | ackMsg.setFailedServers(idList); |
| | | ackMsg.setFailedServers(newArrayList(getServerId())); |
| | | } |
| | | broker.publish(ackMsg); |
| | | if (replayErrorMsg != null) |
| | |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.tools; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.FileReader; |
| | | import java.io.IOException; |
| | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.protocols.ldap.LDAPResultCode.*; |
| | | import static com.forgerock.opendj.cli.ArgumentConstants.*; |
| | | |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static com.forgerock.opendj.cli.Utils.filterExitCode; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class provides a program that may be used to determine the differences |
| | | * between two LDIF files, generating the output in LDIF change format. There |
| | |
| | | * change record. |
| | | */ |
| | | private static boolean writeModify(LDIFWriter writer, Entry sourceEntry, |
| | | Entry targetEntry, Collection ignoreAttrs, |
| | | boolean singleValueChanges) |
| | | Entry targetEntry, Collection<String> ignoreAttrs, boolean singleValueChanges) |
| | | throws IOException |
| | | { |
| | | // Create a list to hold the modifications that are found. |
| | |
| | | else |
| | | { |
| | | // Compare the values. |
| | | AttributeBuilder addedValuesBuilder = new AttributeBuilder( |
| | | targetAttr); |
| | | AttributeBuilder addedValuesBuilder = new AttributeBuilder(targetAttr); |
| | | addedValuesBuilder.removeAll(sourceAttr); |
| | | Attribute addedValues = addedValuesBuilder.toAttribute(); |
| | | if (!addedValues.isEmpty()) |
| | | { |
| | | modifications.add(new Modification(ModificationType.ADD, |
| | | addedValues)); |
| | | modifications.add(new Modification(ModificationType.ADD, addedValues)); |
| | | } |
| | | |
| | | AttributeBuilder deletedValuesBuilder = new AttributeBuilder( |
| | | sourceAttr); |
| | | AttributeBuilder deletedValuesBuilder = new AttributeBuilder(sourceAttr); |
| | | deletedValuesBuilder.removeAll(targetAttr); |
| | | Attribute deletedValues = deletedValuesBuilder.toAttribute(); |
| | | if (!deletedValues.isEmpty()) |
| | | { |
| | | modifications.add(new Modification(ModificationType.DELETE, |
| | | deletedValues)); |
| | | modifications.add(new Modification(ModificationType.DELETE, deletedValues)); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | return false; |
| | | } |
| | | else |
| | | { |
| | | if (singleValueChanges) |
| | | { |
| | | for (Modification m : modifications) |
| | | { |
| | | Attribute a = m.getAttribute(); |
| | | if (a.isEmpty()) |
| | | { |
| | | LinkedList<Modification> attrMods = new LinkedList<>(); |
| | | attrMods.add(m); |
| | | writer.writeModifyChangeRecord(sourceEntry.getName(), attrMods); |
| | | } |
| | | else |
| | | { |
| | | LinkedList<Modification> attrMods = new LinkedList<>(); |
| | | for (ByteString v : a) |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(a, true); |
| | | builder.add(v); |
| | | Attribute attr = builder.toAttribute(); |
| | | |
| | | attrMods.clear(); |
| | | attrMods.add(new Modification(m.getModificationType(), attr)); |
| | | writer.writeModifyChangeRecord(sourceEntry.getName(), attrMods); |
| | | } |
| | | if (singleValueChanges) |
| | | { |
| | | for (Modification m : modifications) |
| | | { |
| | | Attribute a = m.getAttribute(); |
| | | if (a.isEmpty()) |
| | | { |
| | | writer.writeModifyChangeRecord(sourceEntry.getName(), newLinkedList(m)); |
| | | } |
| | | else |
| | | { |
| | | LinkedList<Modification> attrMods = new LinkedList<>(); |
| | | for (ByteString v : a) |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(a, true); |
| | | builder.add(v); |
| | | Attribute attr = builder.toAttribute(); |
| | | |
| | | attrMods.clear(); |
| | | attrMods.add(new Modification(m.getModificationType(), attr)); |
| | | writer.writeModifyChangeRecord(sourceEntry.getName(), attrMods); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | writer.writeModifyChangeRecord(sourceEntry.getName(), modifications); |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | writer.writeModifyChangeRecord(sourceEntry.getName(), modifications); |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | } |
| | |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.io.BufferedReader; |
| | |
| | | StringArgument filterFile; |
| | | IntegerArgument sizeLimit; |
| | | IntegerArgument timeLimit; |
| | | MultiChoiceArgument scopeString; |
| | | MultiChoiceArgument<String> scopeString; |
| | | StringArgument baseDNString; |
| | | StringArgument configClass; |
| | | StringArgument configFile; |
| | |
| | | INFO_LDIFSEARCH_DESCRIPTION_BASEDN.get()); |
| | | argParser.addArgument(baseDNString); |
| | | |
| | | scopeString = new MultiChoiceArgument( |
| | | scopeString = new MultiChoiceArgument<>( |
| | | "scope", 's', "searchScope", false, false, |
| | | true, INFO_SCOPE_PLACEHOLDER.get(), SCOPE_STRING_SUB, |
| | | null, scopeStrings, false, |
| | |
| | | err.println(message); |
| | | return 1; |
| | | } |
| | | else |
| | | |
| | | Iterator<String> iterator = trailingArguments.iterator(); |
| | | filterStrings = newLinkedList(iterator.next()); |
| | | |
| | | while (iterator.hasNext()) |
| | | { |
| | | Iterator<String> iterator = trailingArguments.iterator(); |
| | | |
| | | filterStrings = new LinkedList<>(); |
| | | filterStrings.add(iterator.next()); |
| | | |
| | | while (iterator.hasNext()) |
| | | String lowerName = toLowerCase(iterator.next()); |
| | | if (lowerName.equals("*")) |
| | | { |
| | | String lowerName = toLowerCase(iterator.next()); |
| | | if (lowerName.equals("*")) |
| | | { |
| | | allUserAttrs = true; |
| | | } |
| | | else if (lowerName.equals("+")) |
| | | { |
| | | allOperationalAttrs = true; |
| | | } |
| | | else if (lowerName.startsWith("@")) |
| | | { |
| | | objectClassNames.add(lowerName.substring(1)); |
| | | } |
| | | else |
| | | { |
| | | attributeNames.add(lowerName); |
| | | } |
| | | allUserAttrs = true; |
| | | } |
| | | else if (lowerName.equals("+")) |
| | | { |
| | | allOperationalAttrs = true; |
| | | } |
| | | else if (lowerName.startsWith("@")) |
| | | { |
| | | objectClassNames.add(lowerName.substring(1)); |
| | | } |
| | | else |
| | | { |
| | | attributeNames.add(lowerName); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | import static org.forgerock.util.Reject.*; |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | * @return The name or OID for this schema definition. |
| | | */ |
| | | public final String getNameOrOID() { |
| | | |
| | | if (primaryName != null) { |
| | | return primaryName; |
| | | } else { |
| | | // Guaranteed not to be null. |
| | | return oid; |
| | | } |
| | | // Guaranteed not to be null. |
| | | return oid; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return The name or OID for this schema definition. |
| | | */ |
| | | public final String getNormalizedPrimaryNameOrOID() { |
| | | |
| | | if (lowerName != null) { |
| | | return lowerName; |
| | | } else { |
| | | // Guaranteed not to be null. |
| | | return oid; |
| | | } |
| | | // Guaranteed not to be null. |
| | | return oid; |
| | | } |
| | | |
| | | |
| | |
| | | * @param name The name for the "extra" property. It must not be |
| | | * {@code null}. |
| | | * @param value The value for the "extra" property. If it is |
| | | * {@code null}, then any existing definition will be |
| | | * removed. |
| | | * {@code null}, then any existing definition will be removed. |
| | | */ |
| | | public static void setExtraProperty(SchemaFileElement elem, |
| | | String name, String value) |
| | |
| | | } |
| | | else |
| | | { |
| | | LinkedList<String> values = new LinkedList<>(); |
| | | values.add(value); |
| | | |
| | | elem.getExtraProperties().put(name, values); |
| | | elem.getExtraProperties().put(name, newLinkedList(value)); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | if (lowerName.equals(OBJECTCLASS_ATTRIBUTE_TYPE_NAME) && |
| | | (! objectClasses.isEmpty())) |
| | | if (lowerName.equals(OBJECTCLASS_ATTRIBUTE_TYPE_NAME) |
| | | && !objectClasses.isEmpty()) |
| | | { |
| | | List<Attribute> attrList = new LinkedList<>(); |
| | | attrList.add(getObjectClassAttribute()); |
| | | return attrList; |
| | | return newLinkedList(getObjectClassAttribute()); |
| | | } |
| | | return null; |
| | | } |
| | |
| | | } |
| | | |
| | | if (lowerName.equals(OBJECTCLASS_ATTRIBUTE_TYPE_NAME) && |
| | | ((options == null) || options.isEmpty())) |
| | | (options == null || options.isEmpty())) |
| | | { |
| | | List<Attribute> attributes = new LinkedList<>(); |
| | | attributes.add(getObjectClassAttribute()); |
| | | return attributes; |
| | | return newLinkedList(getObjectClassAttribute()); |
| | | } |
| | | return null; |
| | | } |
| | |
| | | attrList = operationalAttributes.get(attributeType); |
| | | if (attrList == null || attrList.isEmpty()) |
| | | { |
| | | // There aren't any conflicts, so we can just add the |
| | | // attribute to the entry. |
| | | attrList = new LinkedList<>(); |
| | | attrList.add(collectiveAttr); |
| | | putAttributes(attributeType, attrList); |
| | | // There aren't any conflicts, so we can just add the attribute to the entry. |
| | | putAttributes(attributeType, newLinkedList(collectiveAttr)); |
| | | } |
| | | else |
| | | { |
| | | // There is a conflict with an existing operational |
| | | // attribute. |
| | | // There is a conflict with an existing operational attribute. |
| | | resolveCollectiveConflict(subEntry.getConflictBehavior(), |
| | | collectiveAttr, attrList, operationalAttributes, |
| | | attributeType); |
| | | collectiveAttr, attrList, operationalAttributes, attributeType); |
| | | } |
| | | } |
| | | else |
| | |
| | | if (attrList.get(0).isVirtual()) |
| | | { |
| | | // The existing attribute is already virtual, |
| | | // so we've got a different conflict, but |
| | | // we'll let the first win. |
| | | // so we've got a different conflict, but we'll let the first win. |
| | | // FIXME -- Should we handle this differently? |
| | | return; |
| | | } |
| | |
| | | break; |
| | | |
| | | case VIRTUAL_OVERRIDES_REAL: |
| | | // We need to move the real attribute to the |
| | | // suppressed list and replace it with the |
| | | // virtual attribute. |
| | | // We need to move the real attribute to the suppressed list |
| | | // and replace it with the virtual attribute. |
| | | suppressedAttributes.put(attributeType, attrList); |
| | | attrList = new LinkedList<>(); |
| | | attrList.add(collectiveAttr); |
| | | attributes.put(attributeType, attrList); |
| | | attributes.put(attributeType, newLinkedList(collectiveAttr)); |
| | | break; |
| | | |
| | | case MERGE_REAL_AND_VIRTUAL: |
| | |
| | | */ |
| | | public void processVirtualAttributes() |
| | | { |
| | | // Virtual attributes. |
| | | for (VirtualAttributeRule rule : |
| | | DirectoryServer.getVirtualAttributes(this)) |
| | | for (VirtualAttributeRule rule : DirectoryServer.getVirtualAttributes(this)) |
| | | { |
| | | AttributeType attributeType = rule.getAttributeType(); |
| | | List<Attribute> attrList = userAttributes.get(attributeType); |
| | |
| | | attrList = operationalAttributes.get(attributeType); |
| | | if (attrList == null || attrList.isEmpty()) |
| | | { |
| | | // There aren't any conflicts, so we can just add the |
| | | // attribute to the entry. |
| | | attrList = new LinkedList<>(); |
| | | attrList.add(new VirtualAttribute(attributeType, this, rule)); |
| | | putAttributes(attributeType, attrList); |
| | | // There aren't any conflicts, so we can just add the attribute to the entry. |
| | | Attribute attr = new VirtualAttribute(attributeType, this, rule); |
| | | putAttributes(attributeType, newLinkedList(attr)); |
| | | } |
| | | else |
| | | { |
| | | // There is a conflict with an existing operational attribute. |
| | | resolveVirtualConflict(rule, attrList, operationalAttributes, |
| | | attributeType); |
| | | resolveVirtualConflict(rule, attrList, operationalAttributes, attributeType); |
| | | } |
| | | } |
| | | else |
| | |
| | | // We need to move the real attribute to the suppressed |
| | | // list and replace it with the virtual attribute. |
| | | suppressedAttributes.put(attributeType, attrList); |
| | | attrList = new LinkedList<>(); |
| | | attrList.add(new VirtualAttribute(attributeType, this, rule)); |
| | | attributes.put(attributeType, attrList); |
| | | Attribute attr = new VirtualAttribute(attributeType, this, rule); |
| | | attributes.put(attributeType, newLinkedList(attr)); |
| | | break; |
| | | |
| | | case MERGE_REAL_AND_VIRTUAL: |
| | |
| | | import org.forgerock.i18n.LocalizableMessageDescriptor.Arg1; |
| | | import org.opends.server.tools.makeldif.MakeLDIFInputStream; |
| | | import org.opends.server.tools.makeldif.TemplateFile; |
| | | import org.opends.server.util.CollectionUtils; |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | | /** |
| | |
| | | */ |
| | | public LDIFImportConfig(String ldifFile) |
| | | { |
| | | ldifFiles = new ArrayList<>(1); |
| | | ldifFiles.add(ldifFile); |
| | | ldifFiles = CollectionUtils.newArrayList(ldifFile); |
| | | ldifFileIterator = ldifFiles.iterator(); |
| | | } |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.SchemaConfigManager; |
| | | import org.opends.server.schema.AttributeTypeSyntax; |
| | |
| | | import static org.opends.messages.CoreMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.types.CommonSchemaElements.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | if (subTypes == null) |
| | | { |
| | | superiorType.setMayHaveSubordinateTypes(); |
| | | subTypes = new LinkedList<>(); |
| | | subTypes.add(attributeType); |
| | | subordinateTypes.put(superiorType, subTypes); |
| | | subordinateTypes.put(superiorType, newLinkedList(attributeType)); |
| | | } |
| | | else if (! subTypes.contains(attributeType)) |
| | | { |
| | |
| | | import java.util.List; |
| | | import java.util.Iterator; |
| | | |
| | | |
| | | |
| | | import org.opends.server.util.CollectionUtils; |
| | | |
| | | /** |
| | | * This class defines a data structure for storing information about a |
| | |
| | | */ |
| | | public SearchResultReference(String referralURL) |
| | | { |
| | | referralURLs = new ArrayList<>(1); |
| | | referralURLs.add(referralURL); |
| | | |
| | | referralURLs = CollectionUtils.newArrayList(referralURL); |
| | | this.controls = new ArrayList<>(0); |
| | | } |
| | | |
| | |
| | | this.sender = sender; |
| | | this.subject = subject; |
| | | |
| | | recipients = new ArrayList<>(); |
| | | recipients.add(recipient); |
| | | recipients = CollectionUtils.newArrayList(recipient); |
| | | |
| | | body = new LocalizableMessageBuilder(); |
| | | attachments = new LinkedList<>(); |
| | |
| | | |
| | | import static org.forgerock.util.Reject.*; |
| | | import static org.opends.messages.UtilityMessages.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.io.BufferedReader; |
| | |
| | | { |
| | | attrBuilders = userAttrBuilders; |
| | | } |
| | | List<AttributeBuilder> attrList = attrBuilders.get(attrType); |
| | | |
| | | final List<AttributeBuilder> attrList = attrBuilders.get(attrType); |
| | | if (attrList == null) |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(attribute, true); |
| | | builder.add(attributeValue); |
| | | attrList = new ArrayList<>(); |
| | | attrList.add(builder); |
| | | attrBuilders.put(attrType, attrList); |
| | | attrBuilders.put(attrType, newArrayList(builder)); |
| | | return; |
| | | } |
| | | |
| | |
| | | Map<AttributeType, List<Attribute>> attributes, AttributeType t, |
| | | ByteString v, String n) |
| | | { |
| | | List<Attribute> attrList = attributes.get(t); |
| | | final List<Attribute> attrList = attributes.get(t); |
| | | if (attrList == null) |
| | | { |
| | | attrList = new ArrayList<>(); |
| | | attrList.add(Attributes.create(t, n, v)); |
| | | attributes.put(t, attrList); |
| | | attributes.put(t, newArrayList(Attributes.create(t, n, v))); |
| | | return; |
| | | } |
| | | else |
| | | |
| | | for (int j = 0; j < attrList.size(); j++) |
| | | { |
| | | boolean found = false; |
| | | for (int j = 0; j < attrList.size(); j++) |
| | | Attribute a = attrList.get(j); |
| | | if (a.hasOptions()) |
| | | { |
| | | Attribute a = attrList.get(j); |
| | | |
| | | if (a.hasOptions()) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | if (!a.contains(v)) |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(a); |
| | | builder.add(v); |
| | | attrList.set(j, builder.toAttribute()); |
| | | } |
| | | |
| | | found = true; |
| | | break; |
| | | continue; |
| | | } |
| | | |
| | | if (!found) |
| | | if (!a.contains(v)) |
| | | { |
| | | attrList.add(Attributes.create(t, n, v)); |
| | | AttributeBuilder builder = new AttributeBuilder(a); |
| | | builder.add(v); |
| | | attrList.set(j, builder.toAttribute()); |
| | | } |
| | | |
| | | return; |
| | | } |
| | | |
| | | // not found |
| | | attrList.add(Attributes.create(t, n, v)); |
| | | } |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.workflowelement.localbackend; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | Map<AttributeType, List<Attribute>> attributes, AttributeType t, |
| | | ByteString v, String n) throws DirectoryException |
| | | { |
| | | List<Attribute> attrList = attributes.get(t); |
| | | final List<Attribute> attrList = attributes.get(t); |
| | | if (attrList == null) |
| | | { |
| | | if (isSynchronizationOperation() || |
| | | DirectoryServer.addMissingRDNAttributes()) |
| | | { |
| | | attrList = new ArrayList<>(); |
| | | attrList.add(Attributes.create(t, n, v)); |
| | | attributes.put(t, attrList); |
| | | } |
| | | else |
| | | if (!isSynchronizationOperation() |
| | | && !DirectoryServer.addMissingRDNAttributes()) |
| | | { |
| | | throw newDirectoryException(entryDN, ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_ADD_MISSING_RDN_ATTRIBUTE.get(entryDN, n)); |
| | | } |
| | | attributes.put(t, newArrayList(Attributes.create(t, n, v))); |
| | | return; |
| | | } |
| | | else |
| | | { |
| | | boolean found = false; |
| | | for (int j = 0; j < attrList.size(); j++) { |
| | | Attribute a = attrList.get(j); |
| | | |
| | | if (a.hasOptions()) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | if (!a.contains(v)) |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(a); |
| | | builder.add(v); |
| | | attrList.set(j, builder.toAttribute()); |
| | | } |
| | | |
| | | found = true; |
| | | break; |
| | | } |
| | | |
| | | if (!found) |
| | | for (int j = 0; j < attrList.size(); j++) { |
| | | Attribute a = attrList.get(j); |
| | | if (a.hasOptions()) |
| | | { |
| | | if (isSynchronizationOperation() || |
| | | DirectoryServer.addMissingRDNAttributes()) |
| | | { |
| | | attrList.add(Attributes.create(t, n, v)); |
| | | } |
| | | else |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_ADD_MISSING_RDN_ATTRIBUTE.get(entryDN, n)); |
| | | } |
| | | continue; |
| | | } |
| | | |
| | | if (!a.contains(v)) |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(a); |
| | | builder.add(v); |
| | | attrList.set(j, builder.toAttribute()); |
| | | } |
| | | |
| | | return; |
| | | } |
| | | |
| | | // not found |
| | | if (!isSynchronizationOperation() && !DirectoryServer.addMissingRDNAttributes()) |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_ADD_MISSING_RDN_ATTRIBUTE.get(entryDN, n)); |
| | | } |
| | | attrList.add(Attributes.create(t, n, v)); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | import java.net.InetAddress; |
| | | import java.util.Iterator; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | |
| | | import org.forgerock.opendj.ldap.responses.GenericExtendedResult; |
| | | import org.forgerock.opendj.ldap.responses.Responses; |
| | | import org.forgerock.opendj.ldap.responses.Result; |
| | | import org.opends.server.DirectoryServerTestCase; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.std.meta.VirtualAttributeCfgDefn.Scope; |
| | | import org.opends.server.core.BindOperation; |
| | | import org.opends.server.core.CompareOperation; |
| | |
| | | import org.opends.server.core.SearchOperation; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.opends.server.DirectoryServerTestCase; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.DirectoryException; |
| | |
| | | import org.opends.server.types.Operation; |
| | | import org.opends.server.types.SearchResultEntry; |
| | | import org.opends.server.types.SearchResultReference; |
| | | import org.opends.server.util.CollectionUtils; |
| | | import org.testng.annotations.BeforeGroups; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | |
| | | .newControl("dn:uid=kvaughan,ou=People,dc=example,dc=com"); |
| | | assertThat(control3.getOID()).isEqualTo("2.16.840.1.113730.3.4.18"); |
| | | |
| | | List<org.forgerock.opendj.ldap.controls.Control> mySDKControlsList = new LinkedList<>(); |
| | | mySDKControlsList.add(control); |
| | | mySDKControlsList.add(control2); |
| | | mySDKControlsList.add(control3); |
| | | return mySDKControlsList; |
| | | return CollectionUtils.newLinkedList(control, control2, control3); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | import java.util.ArrayList; |
| | | |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | // Modify the backend to enable it. |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("ds-cfg-enabled", "true"))); |
| | | ArrayList<Modification> mods = newArrayList(new Modification(REPLACE, Attributes.create("ds-cfg-enabled", "true"))); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(backendEntry.getName(), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | |
| | | |
| | | // Modify the backend to disable it. |
| | | mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("ds-cfg-enabled", "false"))); |
| | | mods = newArrayList(new Modification(REPLACE, Attributes.create("ds-cfg-enabled", "false"))); |
| | | modifyOperation = conn.processModify(backendEntry.getName(), mods); |
| | | assertNull(DirectoryServer.getBackend(backendID)); |
| | | assertFalse(DirectoryServer.entryExists(baseDN)); |
| | |
| | | |
| | | |
| | | // Disable the intermediate (child) backend. This should be allowed. |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, Attributes.create("ds-cfg-enabled", "false"))); |
| | | ArrayList<Modification> mods = |
| | | newArrayList(new Modification(REPLACE, Attributes.create("ds-cfg-enabled", "false"))); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(childBackendEntry.getName(), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | |
| | | |
| | | // Re-enable the intermediate backend. |
| | | mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("ds-cfg-enabled", "true"))); |
| | | mods = newArrayList(new Modification(REPLACE, Attributes.create("ds-cfg-enabled", "true"))); |
| | | modifyOperation = conn.processModify(childBackendEntry.getName(), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.plugins.DisconnectClientPlugin; |
| | |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | String attr = "ds-cfg-bind-with-dn-requires-password"; |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create(attr, "false"))); |
| | | ArrayList<Modification> mods = newArrayList(new Modification(REPLACE, Attributes.create(attr, "false"))); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(DN.valueOf("cn=config"), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | ByteString.empty()); |
| | | assertEquals(bindOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | mods.clear(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create(attr, "true"))); |
| | | mods = newArrayList(new Modification(REPLACE, Attributes.create(attr, "true"))); |
| | | modifyOperation = conn.processModify(DN.valueOf("cn=config"), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | @SuppressWarnings("javadoc") |
| | |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | LDAPFilter ldapFilter = LDAPFilter.decode("(preferredlanguage=ja)"); |
| | | LDAPAssertionRequestControl assertControl = |
| | | new LDAPAssertionRequestControl(true, ldapFilter); |
| | | List<Control> controls = new ArrayList<>(); |
| | | controls.add(assertControl); |
| | | Control assertControl = new LDAPAssertionRequestControl(true, ldapFilter); |
| | | List<Control> controls = newArrayList(assertControl); |
| | | |
| | | CompareOperationBasis compareOperation = |
| | | new CompareOperationBasis( |
| | |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | LDAPFilter ldapFilter = LDAPFilter.decode("(preferredlanguage=en)"); |
| | | LDAPAssertionRequestControl assertControl = |
| | | new LDAPAssertionRequestControl(true, ldapFilter); |
| | | List<Control> controls = new ArrayList<>(); |
| | | controls.add(assertControl); |
| | | Control assertControl = new LDAPAssertionRequestControl(true, ldapFilter); |
| | | List<Control> controls = newArrayList(assertControl); |
| | | |
| | | CompareOperationBasis compareOperation = |
| | | new CompareOperationBasis( |
| | |
| | | { |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | |
| | | ProxiedAuthV1Control authV1Control = |
| | | Control authV1Control = |
| | | new ProxiedAuthV1Control(ByteString.valueOf( |
| | | "cn=Directory Manager,cn=Root DNs,cn=config")); |
| | | List<Control> controls = new ArrayList<>(); |
| | | controls.add(authV1Control); |
| | | List<Control> controls = newArrayList(authV1Control); |
| | | |
| | | CompareOperationBasis compareOperation = |
| | | new CompareOperationBasis( |
| | |
| | | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | |
| | | ProxiedAuthV1Control authV1Control = |
| | | new ProxiedAuthV1Control(ByteString.valueOf("cn=nonexistent,o=test")); |
| | | List<Control> controls = new ArrayList<>(); |
| | | controls.add(authV1Control); |
| | | Control authV1Control = new ProxiedAuthV1Control(ByteString.valueOf("cn=nonexistent,o=test")); |
| | | List<Control> controls = newArrayList(authV1Control); |
| | | |
| | | CompareOperationBasis compareOperation = |
| | | new CompareOperationBasis( |
| | |
| | | { |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | |
| | | ProxiedAuthV2Control authV2Control = |
| | | Control authV2Control = |
| | | new ProxiedAuthV2Control(ByteString.valueOf( |
| | | "dn:cn=Directory Manager,cn=Root DNs,cn=config")); |
| | | List<Control> controls = new ArrayList<>(); |
| | | controls.add(authV2Control); |
| | | List<Control> controls = newArrayList(authV2Control); |
| | | |
| | | CompareOperationBasis compareOperation = |
| | | new CompareOperationBasis( |
| | |
| | | { |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | |
| | | ProxiedAuthV2Control authV2Control = new ProxiedAuthV2Control( |
| | | ByteString.valueOf("dn:cn=nonexistent,o=test")); |
| | | List<Control> controls = new ArrayList<>(); |
| | | controls.add(authV2Control); |
| | | Control authV2Control = new ProxiedAuthV2Control(ByteString.valueOf("dn:cn=nonexistent,o=test")); |
| | | List<Control> controls = newArrayList(authV2Control); |
| | | |
| | | CompareOperationBasis compareOperation = |
| | | new CompareOperationBasis( |
| | |
| | | new LDAPControl(ServerConstants.OID_PROXIED_AUTH_V2, false, |
| | | ByteString.empty()); |
| | | |
| | | List<Control> controls = new ArrayList<>(); |
| | | controls.add(authV2Control); |
| | | List<Control> controls = newArrayList(authV2Control); |
| | | |
| | | CompareOperationBasis compareOperation = |
| | | new CompareOperationBasis( |
| | |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | LDAPFilter.decode("(preferredlanguage=ja)"); |
| | | LDAPControl assertControl = |
| | | new LDAPControl("1.1.1.1.1.1", true); |
| | | List<Control> controls = new ArrayList<>(); |
| | | controls.add(assertControl); |
| | | Control assertControl = new LDAPControl("1.1.1.1.1.1", true); |
| | | List<Control> controls = newArrayList(assertControl); |
| | | CompareOperationBasis compareOperation = |
| | | new CompareOperationBasis( |
| | | conn, InternalClientConnection.nextOperationID(), |
| | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | { |
| | | // Add a matched values control. |
| | | LDAPFilter ldapFilter = LDAPFilter.decode("(title=*director*)"); |
| | | MatchedValuesFilter matchedValuesFilter = |
| | | MatchedValuesFilter.createFromLDAPFilter(ldapFilter); |
| | | ArrayList<MatchedValuesFilter> filters = new ArrayList<>(); |
| | | filters.add(matchedValuesFilter); |
| | | MatchedValuesControl mvc = new MatchedValuesControl(true, filters); |
| | | ArrayList<Control> controls = new ArrayList<>(); |
| | | controls.add(mvc); |
| | | ArrayList<MatchedValuesFilter> filters = newArrayList(MatchedValuesFilter.createFromLDAPFilter(ldapFilter)); |
| | | Control mvc = new MatchedValuesControl(true, filters); |
| | | ArrayList<Control> controls = newArrayList(mvc); |
| | | |
| | | SearchRequestProtocolOp searchRequest = |
| | | new SearchRequestProtocolOp( |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.server.AdminTestCaseUtils; |
| | | import org.opends.server.admin.std.meta.AttributeValuePasswordValidatorCfgDefn; |
| | | import org.opends.server.admin.std.server.AttributeValuePasswordValidatorCfg; |
| | | import org.opends.server.admin.server.AdminTestCaseUtils; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.ModifyOperationBasis; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.types.Attributes; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.Modification; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | |
| | | import org.opends.server.util.CollectionUtils; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * A set of test cases for the attribute value password validator. |
| | |
| | | validator.initializePasswordValidator(configuration); |
| | | |
| | | ByteString pwOS = ByteString.valueOf(password); |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("userpassword", password))); |
| | | ArrayList<Modification> mods = CollectionUtils.newArrayList( |
| | | new Modification(ModificationType.REPLACE, Attributes.create("userpassword", password))); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | ModifyOperationBasis modifyOperation = |
| | | new ModifyOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.Modification; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A set of test cases for the character set password validator. |
| | | */ |
| | |
| | | validator.initializePasswordValidator(configuration); |
| | | |
| | | ByteString pwOS = ByteString.valueOf(password); |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("userpassword", password))); |
| | | ArrayList<Modification> mods = newArrayList( |
| | | new Modification(REPLACE, Attributes.create("userpassword", password))); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.Modification; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A set of test cases for the dictionary password validator. |
| | | */ |
| | |
| | | validator.initializePasswordValidator(configuration); |
| | | |
| | | ByteString pwOS = ByteString.valueOf(password); |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("userpassword", password))); |
| | | ArrayList<Modification> mods = newArrayList( |
| | | new Modification(REPLACE, Attributes.create("userpassword", password))); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | LinkedList<ByteString> subAny = new LinkedList<>(); |
| | | subAny.add(ByteString.valueOf("=")); |
| | | LinkedList<ByteString> subAny = newLinkedList(ByteString.valueOf("=")); |
| | | |
| | | assertEquals(provider.matchesSubstring(entry, getRule(provider), null, subAny, null), |
| | | ConditionResult.UNDEFINED); |
| | |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | // Create a modification to change the map attribute from uid to cn. |
| | | ArrayList<ByteString> values = new ArrayList<>(); |
| | | values.add(ByteString.valueOf("cn")); |
| | | ArrayList<ByteString> values = newArrayList(ByteString.valueOf("cn")); |
| | | |
| | | ArrayList<RawModification> mods = new ArrayList<>(); |
| | | mods.add(new LDAPModification(ModificationType.REPLACE, |
| | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | // Create a modification to set the map base DN to "dc=example,dc=com". |
| | | ArrayList<ByteString> values = new ArrayList<>(); |
| | | values.add(ByteString.valueOf("dc=example,dc=com")); |
| | | ArrayList<ByteString> values = newArrayList(ByteString.valueOf("dc=example,dc=com")); |
| | | |
| | | ArrayList<RawModification> mods = new ArrayList<>(); |
| | | mods.add(new LDAPModification(ModificationType.REPLACE, |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | |
| | | |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.net.Socket; |
| | |
| | | import org.opends.server.tools.LDAPReader; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import org.opends.server.tools.LDAPWriter; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.util.Base64; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | String dnStr = "cn=EXTERNAL,cn=SASL Mechanisms,cn=config"; |
| | | String attrName = "ds-cfg-certificate-validation-policy"; |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create(attrName, "always"))); |
| | | ArrayList<Modification> mods = newArrayList(new Modification(REPLACE, Attributes.create(attrName, "always"))); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(DN.valueOf(dnStr), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | String dnStr = "cn=EXTERNAL,cn=SASL Mechanisms,cn=config"; |
| | | String attrName = "ds-cfg-certificate-validation-policy"; |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create(attrName, "always"))); |
| | | ArrayList<Modification> mods = newArrayList(new Modification(REPLACE, Attributes.create(attrName, "always"))); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(DN.valueOf(dnStr), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | String dnStr = "cn=EXTERNAL,cn=SASL Mechanisms,cn=config"; |
| | | String attrName = "ds-cfg-certificate-validation-policy"; |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create(attrName, "always"))); |
| | | ArrayList<Modification> mods = newArrayList(new Modification(REPLACE, Attributes.create(attrName, "always"))); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(DN.valueOf(dnStr), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.io.File; |
| | |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.server.AdminTestCaseUtils; |
| | |
| | | import org.opends.server.admin.std.server.FingerprintCertificateMapperCfg; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.Attributes; |
| | |
| | | Attributes.empty(DirectoryServer.getAttributeType( |
| | | "ds-cfg-fingerprint-attribute")); |
| | | |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.DELETE, a)); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ArrayList<Modification> mods = newArrayList(new Modification(DELETE, a)); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(DN.valueOf(mapperDN), mods); |
| | | getRootConnection().processModify(DN.valueOf(mapperDN), mods); |
| | | assertNotSame(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | Attributes.empty(DirectoryServer.getAttributeType( |
| | | "ds-cfg-fingerprint-algorithm")); |
| | | |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.DELETE, a)); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ArrayList<Modification> mods = newArrayList(new Modification(DELETE, a)); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(DN.valueOf(mapperDN), mods); |
| | | getRootConnection().processModify(DN.valueOf(mapperDN), mods); |
| | | assertNotSame(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | String externalDN = "cn=EXTERNAL,cn=SASL Mechanisms,cn=config"; |
| | | String mapperDN = "cn=Fingerprint Mapper,cn=Certificate Mappers,cn=config"; |
| | | |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("ds-cfg-certificate-mapper", |
| | | mapperDN))); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ArrayList<Modification> mods = newArrayList( |
| | | new Modification(REPLACE, Attributes.create("ds-cfg-certificate-mapper", mapperDN))); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(DN.valueOf(externalDN), mods); |
| | | getRootConnection().processModify(DN.valueOf(externalDN), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | String externalDN = "cn=EXTERNAL,cn=SASL Mechanisms,cn=config"; |
| | | String mapperDN = "cn=Subject Equals DN,cn=Certificate Mappers,cn=config"; |
| | | |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("ds-cfg-certificate-mapper", |
| | | mapperDN))); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ArrayList<Modification> mods = newArrayList( |
| | | new Modification(REPLACE, Attributes.create("ds-cfg-certificate-mapper", mapperDN))); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(DN.valueOf(externalDN), mods); |
| | | getRootConnection().processModify(DN.valueOf(externalDN), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | { |
| | | String mapperDN = "cn=Fingerprint Mapper,cn=Certificate Mappers,cn=config"; |
| | | |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("ds-cfg-fingerprint-attribute", |
| | | attrName))); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ArrayList<Modification> mods = newArrayList( |
| | | new Modification(REPLACE, Attributes.create("ds-cfg-fingerprint-attribute", attrName))); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(DN.valueOf(mapperDN), mods); |
| | | getRootConnection().processModify(DN.valueOf(mapperDN), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | { |
| | | String mapperDN = "cn=Fingerprint Mapper,cn=Certificate Mappers,cn=config"; |
| | | |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("ds-cfg-fingerprint-algorithm", |
| | | algorithm))); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ArrayList<Modification> mods = newArrayList( |
| | | new Modification(REPLACE, Attributes.create("ds-cfg-fingerprint-algorithm", algorithm))); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(DN.valueOf(mapperDN), mods); |
| | | getRootConnection().processModify(DN.valueOf(mapperDN), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | { |
| | | String mapperDN = "cn=Fingerprint Mapper,cn=Certificate Mappers,cn=config"; |
| | | |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("ds-cfg-user-base-dn", baseDNs))); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ArrayList<Modification> mods = newArrayList( |
| | | new Modification(REPLACE, Attributes.create("ds-cfg-user-base-dn", baseDNs))); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(DN.valueOf(mapperDN), mods); |
| | | getRootConnection().processModify(DN.valueOf(mapperDN), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | |
| | | VirtualAttributeRule rule = buildRule(provider); |
| | | |
| | | LinkedList<ByteString> subAny = new LinkedList<>(); |
| | | subAny.add(ByteString.valueOf("=")); |
| | | LinkedList<ByteString> subAny = newLinkedList(ByteString.valueOf("=")); |
| | | |
| | | assertEquals(provider.matchesSubstring(entry, rule, null, subAny, null), |
| | | ConditionResult.UNDEFINED); |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | |
| | | |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.ArrayList; |
| | |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.server.AdminTestCaseUtils; |
| | | import org.opends.server.admin.std.meta.LengthBasedPasswordValidatorCfgDefn; |
| | | import org.opends.server.admin.std.server.LengthBasedPasswordValidatorCfg; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.ModifyOperationBasis; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.types.Attributes; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.Modification; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A set of test cases for the length-based password validator. |
| | | */ |
| | |
| | | buffer.append('x'); |
| | | ByteString password = ByteString.valueOf(buffer.toString()); |
| | | |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("userpassword", buffer.toString()))); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ModifyOperationBasis op = |
| | | new ModifyOperationBasis(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), new ArrayList<Control>(), |
| | | DN.valueOf("cn=uid=test.user,o=test"), mods); |
| | | ModifyOperationBasis op = newModifyOperation(buffer); |
| | | |
| | | LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); |
| | | assertTrue(validator.passwordIsAcceptable(password, |
| | |
| | | validator.finalizePasswordValidator(); |
| | | } |
| | | |
| | | private ModifyOperationBasis newModifyOperation(StringBuilder buffer) throws DirectoryException |
| | | { |
| | | ArrayList<Modification> mods = newArrayList( |
| | | new Modification(REPLACE, Attributes.create("userpassword", buffer.toString()))); |
| | | |
| | | ModifyOperationBasis op = new ModifyOperationBasis( |
| | | getRootConnection(), nextOperationID(), nextMessageID(), |
| | | new ArrayList<Control>(), DN.valueOf("cn=uid=test.user,o=test"), mods); |
| | | return op; |
| | | } |
| | | |
| | | /** |
| | | * Tests the <CODE>passwordIsAcceptable</CODE> method with a constraint on the |
| | |
| | | buffer.append('x'); |
| | | ByteString password = ByteString.valueOf(buffer.toString()); |
| | | |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("userpassword", buffer.toString()))); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ModifyOperationBasis op = |
| | | new ModifyOperationBasis(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), new ArrayList<Control>(), |
| | | DN.valueOf("cn=uid=test.user,o=test"), mods); |
| | | ModifyOperationBasis op = newModifyOperation(buffer); |
| | | |
| | | LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); |
| | | assertEquals((buffer.length() >= 10), |
| | |
| | | buffer.append('x'); |
| | | ByteString password = ByteString.valueOf(buffer.toString()); |
| | | |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("userpassword", buffer.toString()))); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ModifyOperationBasis op = |
| | | new ModifyOperationBasis(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), new ArrayList<Control>(), |
| | | DN.valueOf("cn=uid=test.user,o=test"), mods); |
| | | ModifyOperationBasis op = newModifyOperation(buffer); |
| | | |
| | | LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); |
| | | assertEquals((buffer.length() <= 10), |
| | |
| | | buffer.append('x'); |
| | | ByteString password = ByteString.valueOf(buffer.toString()); |
| | | |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("userpassword", buffer.toString()))); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ModifyOperationBasis op = |
| | | new ModifyOperationBasis(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), new ArrayList<Control>(), |
| | | DN.valueOf("cn=uid=test.user,o=test"), mods); |
| | | ModifyOperationBasis op = newModifyOperation(buffer); |
| | | |
| | | LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); |
| | | assertEquals(((buffer.length() >= 6) && (buffer.length() <= 10)), |
| | |
| | | validator.finalizePasswordValidator(); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.server.AdminTestCaseUtils; |
| | | import org.opends.server.admin.std.meta.RepeatedCharactersPasswordValidatorCfgDefn; |
| | | import org.opends.server.admin.std.server.RepeatedCharactersPasswordValidatorCfg; |
| | | import org.opends.server.admin.server.AdminTestCaseUtils; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.ModifyOperationBasis; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.types.Attributes; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.Modification; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * A set of test cases for the repeated characters password validator. |
| | |
| | | public void testPasswordIsAcceptable2Consecutive() |
| | | throws Exception |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | Entry userEntry = TestCaseUtils.makeEntry( |
| | | "dn: uid=test.user,o=test", |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | | "objectClass: organizationalPerson", |
| | | "objectClass: inetOrgPerson", |
| | | "uid: test.user", |
| | | "givenName: Test", |
| | | "sn: User", |
| | | "cn: Test User", |
| | | "userPassword: doesntmatter"); |
| | | |
| | | Entry validatorEntry = TestCaseUtils.makeEntry( |
| | | "dn: cn=Repeated Characters,cn=Password Validators,cn=config", |
| | | "objectClass: top", |
| | | "objectClass: ds-cfg-password-validator", |
| | | "objectClass: ds-cfg-repeated-characters-password-validator", |
| | | "cn: Repeated Characters", |
| | | "ds-cfg-java-class: org.opends.server.extensions." + |
| | | "RepeatedCharactersPasswordValidator", |
| | | "ds-cfg-enabled: true", |
| | | "ds-cfg-max-consecutive-length: 2", |
| | | "ds-cfg-case-sensitive-validation: false"); |
| | | |
| | | RepeatedCharactersPasswordValidatorCfg configuration = |
| | | AdminTestCaseUtils.getConfiguration( |
| | | RepeatedCharactersPasswordValidatorCfgDefn.getInstance(), |
| | | validatorEntry); |
| | | |
| | | RepeatedCharactersPasswordValidator validator = |
| | | new RepeatedCharactersPasswordValidator(); |
| | | validator.initializePasswordValidator(configuration); |
| | | |
| | | ByteString password = ByteString.valueOf("password"); |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("userpassword", "password"))); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ModifyOperationBasis modifyOperation = |
| | | new ModifyOperationBasis(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | DN.valueOf("uid=test.user,o=test"), mods); |
| | | |
| | | LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); |
| | | assertTrue(validator.passwordIsAcceptable(password, |
| | | new HashSet<ByteString>(0), modifyOperation, |
| | | userEntry, invalidReason), |
| | | invalidReason.toString()); |
| | | |
| | | validator.finalizePasswordValidator(); |
| | | assertAcceptable("password", 2, false, true); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code passwordIsAcceptable} method with a password that falls |
| | | * outside of the constraints of the password validator. Case-sensitivity |
| | |
| | | public void testPasswordIsAcceptable3Consecutive() |
| | | throws Exception |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | Entry userEntry = TestCaseUtils.makeEntry( |
| | | "dn: uid=test.user,o=test", |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | | "objectClass: organizationalPerson", |
| | | "objectClass: inetOrgPerson", |
| | | "uid: test.user", |
| | | "givenName: Test", |
| | | "sn: User", |
| | | "cn: Test User", |
| | | "userPassword: doesntmatter"); |
| | | |
| | | Entry validatorEntry = TestCaseUtils.makeEntry( |
| | | "dn: cn=Repeated Characters,cn=Password Validators,cn=config", |
| | | "objectClass: top", |
| | | "objectClass: ds-cfg-password-validator", |
| | | "objectClass: ds-cfg-repeated-characters-password-validator", |
| | | "cn: Repeated Characters", |
| | | "ds-cfg-java-class: org.opends.server.extensions." + |
| | | "RepeatedCharactersPasswordValidator", |
| | | "ds-cfg-enabled: true", |
| | | "ds-cfg-max-consecutive-length: 2", |
| | | "ds-cfg-case-sensitive-validation: false"); |
| | | |
| | | RepeatedCharactersPasswordValidatorCfg configuration = |
| | | AdminTestCaseUtils.getConfiguration( |
| | | RepeatedCharactersPasswordValidatorCfgDefn.getInstance(), |
| | | validatorEntry); |
| | | |
| | | RepeatedCharactersPasswordValidator validator = |
| | | new RepeatedCharactersPasswordValidator(); |
| | | validator.initializePasswordValidator(configuration); |
| | | |
| | | ByteString password = ByteString.valueOf("passsword"); |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("userpassword", "passsword"))); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ModifyOperationBasis modifyOperation = |
| | | new ModifyOperationBasis(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | DN.valueOf("uid=test.user,o=test"), mods); |
| | | |
| | | LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); |
| | | assertFalse(validator.passwordIsAcceptable(password, |
| | | new HashSet<ByteString>(0), modifyOperation, |
| | | userEntry, invalidReason)); |
| | | |
| | | validator.finalizePasswordValidator(); |
| | | assertAcceptable("passsword", 2, false, false); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code passwordIsAcceptable} method with a password that falls |
| | | * within the constraints of the password validator only because it is |
| | |
| | | public void testPasswordIsAcceptableCaseSensitive() |
| | | throws Exception |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | Entry userEntry = TestCaseUtils.makeEntry( |
| | | "dn: uid=test.user,o=test", |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | | "objectClass: organizationalPerson", |
| | | "objectClass: inetOrgPerson", |
| | | "uid: test.user", |
| | | "givenName: Test", |
| | | "sn: User", |
| | | "cn: Test User", |
| | | "userPassword: doesntmatter"); |
| | | |
| | | Entry validatorEntry = TestCaseUtils.makeEntry( |
| | | "dn: cn=Repeated Characters,cn=Password Validators,cn=config", |
| | | "objectClass: top", |
| | | "objectClass: ds-cfg-password-validator", |
| | | "objectClass: ds-cfg-repeated-characters-password-validator", |
| | | "cn: Repeated Characters", |
| | | "ds-cfg-java-class: org.opends.server.extensions." + |
| | | "RepeatedCharactersPasswordValidator", |
| | | "ds-cfg-enabled: true", |
| | | "ds-cfg-max-consecutive-length: 2", |
| | | "ds-cfg-case-sensitive-validation: true"); |
| | | |
| | | RepeatedCharactersPasswordValidatorCfg configuration = |
| | | AdminTestCaseUtils.getConfiguration( |
| | | RepeatedCharactersPasswordValidatorCfgDefn.getInstance(), |
| | | validatorEntry); |
| | | |
| | | RepeatedCharactersPasswordValidator validator = |
| | | new RepeatedCharactersPasswordValidator(); |
| | | validator.initializePasswordValidator(configuration); |
| | | |
| | | ByteString password = ByteString.valueOf("passSword"); |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("userpassword", "passSword"))); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ModifyOperationBasis modifyOperation = |
| | | new ModifyOperationBasis(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | DN.valueOf("uid=test.user,o=test"), mods); |
| | | |
| | | LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); |
| | | assertTrue(validator.passwordIsAcceptable(password, |
| | | new HashSet<ByteString>(0), modifyOperation, |
| | | userEntry, invalidReason), |
| | | invalidReason.toString()); |
| | | |
| | | validator.finalizePasswordValidator(); |
| | | assertAcceptable("passSword", 2, true, true); |
| | | } |
| | | |
| | | |
| | |
| | | public void testPasswordIsAcceptableCaseInsensitive() |
| | | throws Exception |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | Entry userEntry = TestCaseUtils.makeEntry( |
| | | "dn: uid=test.user,o=test", |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | | "objectClass: organizationalPerson", |
| | | "objectClass: inetOrgPerson", |
| | | "uid: test.user", |
| | | "givenName: Test", |
| | | "sn: User", |
| | | "cn: Test User", |
| | | "userPassword: doesntmatter"); |
| | | |
| | | Entry validatorEntry = TestCaseUtils.makeEntry( |
| | | "dn: cn=Repeated Characters,cn=Password Validators,cn=config", |
| | | "objectClass: top", |
| | | "objectClass: ds-cfg-password-validator", |
| | | "objectClass: ds-cfg-repeated-characters-password-validator", |
| | | "cn: Repeated Characters", |
| | | "ds-cfg-java-class: org.opends.server.extensions." + |
| | | "RepeatedCharactersPasswordValidator", |
| | | "ds-cfg-enabled: true", |
| | | "ds-cfg-max-consecutive-length: 2", |
| | | "ds-cfg-case-sensitive-validation: false"); |
| | | |
| | | RepeatedCharactersPasswordValidatorCfg configuration = |
| | | AdminTestCaseUtils.getConfiguration( |
| | | RepeatedCharactersPasswordValidatorCfgDefn.getInstance(), |
| | | validatorEntry); |
| | | |
| | | RepeatedCharactersPasswordValidator validator = |
| | | new RepeatedCharactersPasswordValidator(); |
| | | validator.initializePasswordValidator(configuration); |
| | | |
| | | ByteString password = ByteString.valueOf("passSword"); |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("userpassword", "passSword"))); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ModifyOperationBasis modifyOperation = |
| | | new ModifyOperationBasis(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | DN.valueOf("uid=test.user,o=test"), mods); |
| | | |
| | | LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); |
| | | assertFalse(validator.passwordIsAcceptable(password, |
| | | new HashSet<ByteString>(0), modifyOperation, |
| | | userEntry, invalidReason)); |
| | | |
| | | validator.finalizePasswordValidator(); |
| | | assertAcceptable("passSword", 2, false, false); |
| | | } |
| | | |
| | | |
| | |
| | | public void testPasswordIsAcceptableUnlimitedRepeats() |
| | | throws Exception |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | Entry userEntry = TestCaseUtils.makeEntry( |
| | | "dn: uid=test.user,o=test", |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | | "objectClass: organizationalPerson", |
| | | "objectClass: inetOrgPerson", |
| | | "uid: test.user", |
| | | "givenName: Test", |
| | | "sn: User", |
| | | "cn: Test User", |
| | | "userPassword: doesntmatter"); |
| | | |
| | | Entry validatorEntry = TestCaseUtils.makeEntry( |
| | | "dn: cn=Repeated Characters,cn=Password Validators,cn=config", |
| | | "objectClass: top", |
| | | "objectClass: ds-cfg-password-validator", |
| | | "objectClass: ds-cfg-repeated-characters-password-validator", |
| | | "cn: Repeated Characters", |
| | | "ds-cfg-java-class: org.opends.server.extensions." + |
| | | "RepeatedCharactersPasswordValidator", |
| | | "ds-cfg-enabled: true", |
| | | "ds-cfg-max-consecutive-length: 0", |
| | | "ds-cfg-case-sensitive-validation: true"); |
| | | |
| | | RepeatedCharactersPasswordValidatorCfg configuration = |
| | | AdminTestCaseUtils.getConfiguration( |
| | | RepeatedCharactersPasswordValidatorCfgDefn.getInstance(), |
| | | validatorEntry); |
| | | |
| | | RepeatedCharactersPasswordValidator validator = |
| | | new RepeatedCharactersPasswordValidator(); |
| | | validator.initializePasswordValidator(configuration); |
| | | |
| | | ByteString password = ByteString.valueOf("aaaaaaaa"); |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("userpassword", "aaaaaaaa"))); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ModifyOperationBasis modifyOperation = |
| | | new ModifyOperationBasis(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | DN.valueOf("uid=test.user,o=test"), mods); |
| | | |
| | | LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); |
| | | assertTrue(validator.passwordIsAcceptable(password, |
| | | new HashSet<ByteString>(0), modifyOperation, |
| | | userEntry, invalidReason), |
| | | invalidReason.toString()); |
| | | |
| | | validator.finalizePasswordValidator(); |
| | | assertAcceptable("aaaaaaaa", 0, true, true); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the ability of the password validator to change its behavior when |
| | | * the configuration is updated. |
| | |
| | | new RepeatedCharactersPasswordValidator(); |
| | | validator.initializePasswordValidator(configuration); |
| | | |
| | | ByteString password = ByteString.valueOf("aaaaaaaa"); |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("userpassword", "aaaaaaaa"))); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ModifyOperationBasis modifyOperation = |
| | | new ModifyOperationBasis(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | DN.valueOf("uid=test.user,o=test"), mods); |
| | | |
| | | LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); |
| | | assertTrue(validator.passwordIsAcceptable(password, |
| | | new HashSet<ByteString>(0), modifyOperation, |
| | | userEntry, invalidReason), |
| | | invalidReason.toString()); |
| | | String value = "aaaaaaaa"; |
| | | assertAcceptable(validator, value, userEntry, true); |
| | | |
| | | Entry updatedValidatorEntry = TestCaseUtils.makeEntry( |
| | | "dn: cn=Repeated Characters,cn=Password Validators,cn=config", |
| | |
| | | validator.applyConfigurationChange(updatedConfiguration); |
| | | assertEquals(changeResult.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | assertFalse(validator.passwordIsAcceptable(password, |
| | | new HashSet<ByteString>(0), modifyOperation, |
| | | userEntry, invalidReason)); |
| | | assertAcceptable(validator, value, userEntry, false); |
| | | |
| | | validator.finalizePasswordValidator(); |
| | | } |
| | | } |
| | | |
| | | private void assertAcceptable(String value, int maxConsecutiveLength, boolean caseSensitiveValidation, |
| | | boolean expectedResult) throws Exception, ConfigException, DirectoryException |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | Entry userEntry = TestCaseUtils.makeEntry( |
| | | "dn: uid=test.user,o=test", |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | | "objectClass: organizationalPerson", |
| | | "objectClass: inetOrgPerson", |
| | | "uid: test.user", |
| | | "givenName: Test", |
| | | "sn: User", |
| | | "cn: Test User", |
| | | "userPassword: doesntmatter"); |
| | | |
| | | Entry validatorEntry = TestCaseUtils.makeEntry( |
| | | "dn: cn=Repeated Characters,cn=Password Validators,cn=config", |
| | | "objectClass: top", |
| | | "objectClass: ds-cfg-password-validator", |
| | | "objectClass: ds-cfg-repeated-characters-password-validator", |
| | | "cn: Repeated Characters", |
| | | "ds-cfg-java-class: org.opends.server.extensions.RepeatedCharactersPasswordValidator", |
| | | "ds-cfg-enabled: true", |
| | | "ds-cfg-max-consecutive-length: " + maxConsecutiveLength, |
| | | "ds-cfg-case-sensitive-validation: " + caseSensitiveValidation); |
| | | |
| | | RepeatedCharactersPasswordValidatorCfgDefn defn = RepeatedCharactersPasswordValidatorCfgDefn.getInstance(); |
| | | RepeatedCharactersPasswordValidatorCfg configuration = AdminTestCaseUtils.getConfiguration(defn, validatorEntry); |
| | | |
| | | RepeatedCharactersPasswordValidator validator = new RepeatedCharactersPasswordValidator(); |
| | | validator.initializePasswordValidator(configuration); |
| | | |
| | | assertAcceptable(validator, value, userEntry, expectedResult); |
| | | |
| | | validator.finalizePasswordValidator(); |
| | | } |
| | | |
| | | private void assertAcceptable(RepeatedCharactersPasswordValidator validator, String value, Entry userEntry, |
| | | boolean expectedResult) throws DirectoryException |
| | | { |
| | | ByteString password = ByteString.valueOf(value); |
| | | ModifyOperationBasis modifyOperation = replaceUserPasswordAttribute(value); |
| | | |
| | | LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder(); |
| | | boolean acceptable = |
| | | validator.passwordIsAcceptable(password, new HashSet<ByteString>(0), modifyOperation, userEntry, invalidReason); |
| | | assertEquals(acceptable, expectedResult, invalidReason.toString()); |
| | | } |
| | | |
| | | private ModifyOperationBasis replaceUserPasswordAttribute(String newValue) throws DirectoryException |
| | | { |
| | | ArrayList<Modification> mods = newArrayList( |
| | | new Modification(REPLACE, Attributes.create("userpassword", newValue))); |
| | | |
| | | return new ModifyOperationBasis( |
| | | getRootConnection(), nextOperationID(), nextMessageID(), |
| | | new ArrayList<Control>(), DN.valueOf("uid=test.user,o=test"), mods); |
| | | } |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.Modification; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | import org.opends.server.admin.std.meta.SimilarityBasedPasswordValidatorCfgDefn; |
| | | import org.opends.server.admin.std.server.SimilarityBasedPasswordValidatorCfg; |
| | | import org.opends.server.admin.server.AdminTestCaseUtils; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A set of test cases for the Similarity-Based Password Reject. |
| | | */ |
| | |
| | | buffer.append('x'); |
| | | ByteString password = ByteString.valueOf(buffer.toString()); |
| | | |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("userpassword", buffer.toString()))); |
| | | ArrayList<Modification> mods = newArrayList( |
| | | new Modification(REPLACE, Attributes.create("userpassword", buffer.toString()))); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | |
| | | buffer.append('x'); |
| | | ByteString password = ByteString.valueOf(buffer.toString()); |
| | | |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("userpassword", buffer.toString()))); |
| | | ArrayList<Modification> mods = newArrayList( |
| | | new Modification(REPLACE, Attributes.create("userpassword", buffer.toString()))); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.io.File; |
| | |
| | | import org.opends.server.admin.std.server.SubjectAttributeToUserAttributeCertificateMapperCfg; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.Modification; |
| | |
| | | Attributes.empty(DirectoryServer.getAttributeType( |
| | | "ds-cfg-subject-attribute-mapping")); |
| | | |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.DELETE, a)); |
| | | ArrayList<Modification> mods = newArrayList( |
| | | new Modification(ModificationType.DELETE, a)); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(DN.valueOf(mapperDN), mods); |
| | | ModifyOperation modifyOperation = getRootConnection().processModify(DN.valueOf(mapperDN), mods); |
| | | assertNotSame(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests to ensure that an attempt to set an attribute mapping with no colon |
| | | * will fail. |
| | |
| | | String mapperDN = "cn=Subject Attribute to User Attribute," + |
| | | "cn=Certificate Mappers,cn=config"; |
| | | |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("ds-cfg-certificate-mapper", mapperDN))); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(DN.valueOf(externalDN), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | Attribute attr = Attributes.create("ds-cfg-certificate-mapper", mapperDN); |
| | | assertModifyReplaceIsSuccess(externalDN, attr); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Alters the configuration of the SASL EXTERNAL mechanism handler so that it |
| | | * uses the Subject Equals DN certificate mapper. |
| | |
| | | String externalDN = "cn=EXTERNAL,cn=SASL Mechanisms,cn=config"; |
| | | String mapperDN = "cn=Subject Equals DN,cn=Certificate Mappers,cn=config"; |
| | | |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("ds-cfg-certificate-mapper", mapperDN))); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(DN.valueOf(externalDN), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | Attribute attr = Attributes.create("ds-cfg-certificate-mapper", mapperDN); |
| | | assertModifyReplaceIsSuccess(externalDN, attr); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Alters the configuration of the Subject Attribute to User Attribute |
| | | * certificate mapper so that it will use the specified set of mappings. |
| | |
| | | String mapperDN = "cn=Subject Attribute to User Attribute," + |
| | | "cn=Certificate Mappers,cn=config"; |
| | | |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("ds-cfg-subject-attribute-mapping", mappings))); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(DN.valueOf(mapperDN), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | Attribute attr = Attributes.create("ds-cfg-subject-attribute-mapping", mappings); |
| | | assertModifyReplaceIsSuccess(mapperDN, attr); |
| | | } |
| | | |
| | | |
| | |
| | | String mapperDN = "cn=Subject Attribute to User Attribute," + |
| | | "cn=Certificate Mappers,cn=config"; |
| | | |
| | | AttributeType attrType = |
| | | DirectoryServer.getAttributeType("ds-cfg-user-base-dn"); |
| | | |
| | | AttributeType attrType = DirectoryServer.getAttributeType("ds-cfg-user-base-dn"); |
| | | AttributeBuilder builder = new AttributeBuilder(attrType); |
| | | if (baseDNs != null) |
| | | { |
| | | builder.addAllStrings(Arrays.asList(baseDNs)); |
| | | } |
| | | |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, builder.toAttribute())); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(DN.valueOf(mapperDN), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertModifyReplaceIsSuccess(mapperDN, builder.toAttribute()); |
| | | } |
| | | |
| | | /** |
| | |
| | | disableMapper(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void assertModifyReplaceIsSuccess(String dn, Attribute replaceAttr) throws DirectoryException |
| | | { |
| | | ArrayList<Modification> mods = newArrayList(new Modification(REPLACE, replaceAttr)); |
| | | ModifyOperation modifyOperation = getRootConnection().processModify(DN.valueOf(dn), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.io.File; |
| | |
| | | import org.opends.server.admin.std.server.SubjectDNToUserAttributeCertificateMapperCfg; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.Modification; |
| | |
| | | public void testRemoveSubjectAttribute() |
| | | throws Exception |
| | | { |
| | | String mapperDN = |
| | | "cn=Subject DN to User Attribute,cn=Certificate Mappers,cn=config"; |
| | | String mapperDN = "cn=Subject DN to User Attribute,cn=Certificate Mappers,cn=config"; |
| | | Attribute a = Attributes.empty(DirectoryServer.getAttributeType("ds-cfg-subject-attribute")); |
| | | |
| | | Attribute a = |
| | | Attributes.empty(DirectoryServer.getAttributeType( |
| | | "ds-cfg-subject-attribute")); |
| | | |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.DELETE, a)); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ArrayList<Modification> mods = newArrayList(new Modification(ModificationType.DELETE, a)); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(DN.valueOf(mapperDN), mods); |
| | | getRootConnection().processModify(DN.valueOf(mapperDN), mods); |
| | | assertNotSame(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests to ensure that an attmept to set an undefined subject attribute will |
| | | * fail. |
| | | * Tests to ensure that an attempt to set an undefined subject attribute will fail. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | |
| | | |
| | | |
| | | /** |
| | | * Tests to ensure that an attmept to set an invalid base DN will fail. |
| | | * Tests to ensure that an attempt to set an invalid base DN will fail. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | |
| | | String mapperDN = |
| | | "cn=Subject DN to User Attribute,cn=Certificate Mappers,cn=config"; |
| | | |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("ds-cfg-certificate-mapper", mapperDN))); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(DN.valueOf(externalDN), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | Attribute attr = Attributes.create("ds-cfg-certificate-mapper", mapperDN); |
| | | assertModifyReplaceIsSuccess(externalDN, attr); |
| | | } |
| | | |
| | | |
| | |
| | | String externalDN = "cn=EXTERNAL,cn=SASL Mechanisms,cn=config"; |
| | | String mapperDN = "cn=Subject Equals DN,cn=Certificate Mappers,cn=config"; |
| | | |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("ds-cfg-certificate-mapper", mapperDN))); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(DN.valueOf(externalDN), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | Attribute attr = Attributes.create("ds-cfg-certificate-mapper", mapperDN); |
| | | assertModifyReplaceIsSuccess(externalDN, attr); |
| | | } |
| | | |
| | | |
| | |
| | | String mapperDN = |
| | | "cn=Subject DN to User Attribute,cn=Certificate Mappers,cn=config"; |
| | | |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("ds-cfg-subject-attribute", attrName))); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(DN.valueOf(mapperDN), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | Attribute attr = Attributes.create("ds-cfg-subject-attribute", attrName); |
| | | assertModifyReplaceIsSuccess(mapperDN, attr); |
| | | } |
| | | |
| | | |
| | |
| | | builder.addAllStrings(Arrays.asList(baseDNs)); |
| | | } |
| | | |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | builder.toAttribute())); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(DN.valueOf(mapperDN), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertModifyReplaceIsSuccess(mapperDN, builder.toAttribute()); |
| | | } |
| | | |
| | | /** |
| | |
| | | disableMapper(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void assertModifyReplaceIsSuccess(String mapperDN, Attribute attr) throws DirectoryException |
| | | { |
| | | ArrayList<Modification> mods = newArrayList(new Modification(REPLACE, attr)); |
| | | ModifyOperation modifyOperation = getRootConnection().processModify(DN.valueOf(mapperDN), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | |
| | | |
| | | import java.util.ArrayList; |
| | | |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | { |
| | | DN dn = DN.valueOf("cn=Work Queue,cn=config"); |
| | | String attr = "ds-cfg-num-worker-threads"; |
| | | ArrayList<Modification> mods = new ArrayList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create(attr, "30"))); |
| | | ArrayList<Modification> mods = newArrayList(new Modification(REPLACE, Attributes.create(attr, "30"))); |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | ModifyOperation modifyOperation = conn.processModify(dn, mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | mods.clear(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create(attr, "24"))); |
| | | mods = newArrayList(new Modification(REPLACE, Attributes.create(attr, "24"))); |
| | | modifyOperation = conn.processModify(dn, mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | ByteString v = ByteString.valueOf(u4.toString()); |
| | | assertTrue(a.contains(v)); |
| | | |
| | | LinkedList<Modification> mods = new LinkedList<>(); |
| | | mods.add(new Modification(ModificationType.ADD, |
| | | Attributes.create("memberurl", |
| | | "ldap:///o=test??sub?(objectClass=person)"))); |
| | | LinkedList<Modification> mods = newLinkedList(new Modification(ModificationType.ADD, |
| | | Attributes.create("memberurl", "ldap:///o=test??sub?(objectClass=person)"))); |
| | | ModifyOperation modifyOperation = getRootConnection().processModify(d1, mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | |
| | | LinkedList<Modification> mods = new LinkedList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | LinkedList<Modification> mods = newLinkedList(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("ds-cfg-allow-retrieving-membership", "false"))); |
| | | DN definitionDN = |
| | | DN.valueOf("cn=Virtual Static member,cn=Virtual Attributes,cn=config"); |
| | |
| | | assertTrue(a.contains(v)); |
| | | |
| | | |
| | | mods = new LinkedList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | mods = newLinkedList(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("ds-cfg-allow-retrieving-membership", "true"))); |
| | | modifyOperation = conn.processModify(definitionDN, mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | |
| | | */ |
| | | private ModifyOperation |
| | | addAttrEntry(DN dn, String attrName, String... attrValStrings) { |
| | | LinkedList<Modification> mods = new LinkedList<>(); |
| | | mods.add(new Modification(ModificationType.ADD, Attributes.create(attrName, attrValStrings))); |
| | | LinkedList<Modification> mods = newLinkedList( |
| | | new Modification(ADD, Attributes.create(attrName, attrValStrings))); |
| | | return getRootConnection().processModify(dn, mods); |
| | | } |
| | | |
| | |
| | | * @param attrValStrings The values to replace in the the entry. |
| | | */ |
| | | private ModifyOperation replaceAttrEntry(DN dn, String attrName, String... attrValStrings) { |
| | | LinkedList<Modification> mods = new LinkedList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, Attributes.create(attrName, attrValStrings))); |
| | | LinkedList<Modification> mods = newLinkedList( |
| | | new Modification(REPLACE, Attributes.create(attrName, attrValStrings))); |
| | | return getRootConnection().processModify(dn, mods); |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.plugins; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | * Samba administrative user needs a permission to manipulate user accounts. |
| | | * Hence, we add a very permissive ACI. |
| | | */ |
| | | InternalClientConnection conn = InternalClientConnection.getRootConnection(); |
| | | LinkedList<Modification> mods = new LinkedList<>(); |
| | | |
| | | mods.add(new Modification(ModificationType.ADD, Attributes.create("aci", |
| | | LinkedList<Modification> mods = |
| | | newLinkedList(new Modification(ModificationType.ADD, Attributes.create("aci", |
| | | "(target=\"ldap:///uid=*,o=test\")(targetattr=\"*\")" |
| | | + "(version 3.0; acl \"Samba admin\"; allow (all) " |
| | | + "userdn=\"ldap:///cn=samba admin,o=test\";)"))); |
| | | |
| | | ModifyOperation modOp = conn.processModify(DN.valueOf("o=test"), mods); |
| | | |
| | | ModifyOperation modOp = getRootConnection().processModify(DN.valueOf("o=test"), mods); |
| | | assertEquals(modOp.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | TestCaseUtils.addEntry(testEntry); |
| | | |
| | | // Perform the modify operation |
| | | InternalClientConnection conn = InternalClientConnection.getRootConnection(); |
| | | LinkedList<Modification> mods = newLinkedList( |
| | | new Modification(ModificationType.REPLACE, Attributes.create("userPassword", "password"))); |
| | | |
| | | LinkedList<Modification> mods = new LinkedList<>(); |
| | | |
| | | mods.add(new Modification(ModificationType.REPLACE, Attributes.create( |
| | | "userPassword", "password"))); |
| | | |
| | | ModifyOperation modOp = conn.processModify(testEntry.getName(), mods); |
| | | |
| | | ModifyOperation modOp = getRootConnection().processModify(testEntry.getName(), mods); |
| | | assertEquals(modOp.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | // Verification of the change |
| | |
| | | |
| | | InternalClientConnection conn = new InternalClientConnection(authInfo); |
| | | |
| | | LinkedList<Modification> mods = new LinkedList<>(); |
| | | |
| | | mods.add(new Modification(ModificationType.REPLACE, Attributes.create( |
| | | "userPassword", "password"))); |
| | | |
| | | LinkedList<Modification> mods = newLinkedList( |
| | | new Modification(ModificationType.REPLACE, Attributes.create("userPassword", "password"))); |
| | | ModifyOperation modOp = conn.processModify(testEntry.getName(), mods); |
| | | |
| | | assertEquals(modOp.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | // Verification of the result |
| | |
| | | |
| | | InternalClientConnection conn = new InternalClientConnection(authInfo); |
| | | |
| | | LinkedList<Modification> mods = new LinkedList<>(); |
| | | |
| | | mods.add(new Modification(ModificationType.REPLACE, Attributes.create( |
| | | "userPassword", "password1"))); |
| | | LinkedList<Modification> mods = newLinkedList( |
| | | new Modification(ModificationType.REPLACE, Attributes.create("userPassword", "password1"))); |
| | | |
| | | ModifyOperation modOp = conn.processModify(testEntry.getName(), mods); |
| | | |
| | | assertEquals(modOp.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | // Verification of the result |
| | | |
| | | Entry entry = DirectoryServer.getEntry(testEntry.getName()); |
| | | assertNotNull(entry); |
| | | |
| | | List<Attribute> sambaAttribute = entry.getAttribute("sambantpassword"); |
| | | |
| | | assertNull(sambaAttribute); |
| | | |
| | | sambaAttribute = entry.getAttribute("sambalmpassword"); |
| | | |
| | | assertNull(sambaAttribute); |
| | | assertNull(entry.getAttribute("sambantpassword")); |
| | | assertNull(entry.getAttribute("sambalmpassword")); |
| | | |
| | | TestCaseUtils.deleteEntry(entry); |
| | | } |
| | |
| | | TestCaseUtils.addEntry(testEntry); |
| | | |
| | | // Perform the modify operation |
| | | InternalClientConnection conn = InternalClientConnection |
| | | .getRootConnection(); |
| | | |
| | | LinkedList<Modification> mods = new LinkedList<>(); |
| | | mods.add(new Modification(ModificationType.ADD, Attributes.create("userPassword", "password1"))); |
| | | mods.add(new Modification(ModificationType.ADD, Attributes.create("userPassword", "password2"))); |
| | | mods.add(new Modification(ModificationType.ADD, Attributes.create("userPassword", "password3"))); |
| | | |
| | | mods.add(new Modification(ModificationType.ADD, Attributes.create( |
| | | "userPassword", "password1"))); |
| | | mods.add(new Modification(ModificationType.ADD, Attributes.create( |
| | | "userPassword", "password2"))); |
| | | |
| | | mods.add(new Modification(ModificationType.ADD, Attributes.create( |
| | | "userPassword", "password3"))); |
| | | |
| | | ModifyOperation modOp = conn.processModify(testEntry.getName(), mods); |
| | | |
| | | ModifyOperation modOp = getRootConnection().processModify(testEntry.getName(), mods); |
| | | assertEquals(modOp.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | // Verification of the result |
| | |
| | | InternalClientConnection conn = InternalClientConnection |
| | | .getRootConnection(); |
| | | |
| | | LinkedList<Modification> mods = new LinkedList<>(); |
| | | |
| | | mods.add(new Modification(ModificationType.REPLACE, Attributes.create( |
| | | "userPassword", "password"))); |
| | | LinkedList<Modification> mods = |
| | | newLinkedList(new Modification(ModificationType.REPLACE, Attributes.create("userPassword", "password"))); |
| | | |
| | | ModifyOperation modOp = conn.processModify(testEntry.getName(), mods); |
| | | |
| | | assertEquals(modOp.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | Attribute sambaPwdLastSetAttr = |
| | | Attributes.create("sambapwdlastset", String.valueOf(1339012789L)); |
| | | boolean attrPresent = false; |
| | | |
| | | for (Modification mod : modOp.getModifications()) |
| | | { |
| | | if (mod.getAttribute().equals(sambaPwdLastSetAttr)) |
| | | { |
| | | attrPresent = true; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | assertTrue(attrPresent); |
| | | assertTrue(containsAttribute(modOp, sambaPwdLastSetAttr)); |
| | | |
| | | TestCaseUtils.deleteEntry(testEntry); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | private boolean containsAttribute(ModifyOperation modOp, Attribute attr) |
| | | { |
| | | for (Modification mod : modOp.getModifications()) |
| | | { |
| | | if (mod.getAttribute().equals(attr)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * Test if the plugin properly updates the 'sambaPwdLastSet' attribute when |
| | | * the password is changed through the PMEO. |
| | |
| | | import org.testng.annotations.*; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | private void replaceAttrInEntry(DN dn, String attrName, String... attrValStrings) { |
| | | LinkedList<Modification> mods = new LinkedList<>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, Attributes.create(attrName, attrValStrings))); |
| | | LinkedList<Modification> mods = newLinkedList( |
| | | new Modification(ModificationType.REPLACE, Attributes.create(attrName, attrValStrings))); |
| | | getRootConnection().processModify(dn, mods); |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.replication; |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.LinkedList; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import java.util.List; |
| | | |
| | | import org.assertj.core.api.Assertions; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.std.server.MonitorProviderCfg; |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyOperation; |
| | |
| | | import org.opends.server.replication.protocol.ReplicationMsg; |
| | | import org.opends.server.replication.service.ReplicationBroker; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * Stress test for the synchronization code using the ReplicationBroker API. |
| | | */ |
| | |
| | | @Override |
| | | public List<Attribute> getMonitorData() |
| | | { |
| | | Attribute attr; |
| | | if (reader == null) |
| | | { |
| | | attr = Attributes.create("received-messages", "not yet started"); |
| | | } |
| | | else |
| | | { |
| | | attr = Attributes.create("received-messages", String.valueOf(reader.getCurrentCount())); |
| | | } |
| | | String value = reader != null ? String.valueOf(reader.getCurrentCount()) : "not yet started"; |
| | | List<Attribute> list = new LinkedList<>(); |
| | | list.add(attr); |
| | | attr = Attributes.create("base-dn", "ou=People," + TEST_ROOT_DN_STRING); |
| | | list.add(attr); |
| | | list.add(Attributes.create("received-messages", value)); |
| | | list.add(Attributes.create("base-dn", "ou=People," + TEST_ROOT_DN_STRING)); |
| | | return list; |
| | | } |
| | | |
| | |
| | | import org.opends.server.workflowelement.localbackend.LocalBackendModifyOperation; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.replication.protocol.OperationContext.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | attr = Attributes.create(DESCRIPTION, "Init Value"); |
| | | Modification mod2 = new Modification(ModificationType.ADD, attr); |
| | | |
| | | List<Modification> mods = new LinkedList<>(); |
| | | mods.add(mod1); |
| | | mods.add(mod2); |
| | | List<Modification> mods = newLinkedList(mod1, mod2); |
| | | |
| | | replayModifies(entry, hist, mods, 11); |
| | | assertEquals(mods.size(), 2, |
| | | "DEL and ADD of the same attribute same value was not correct"); |
| | | assertEquals(mods.get(0), mod1, |
| | | "DEL and ADD of the same attribute same value was not correct"); |
| | | assertEquals(mods.get(1), mod2, |
| | | "DEL and ADD of the same attribute same value was not correct"); |
| | | assertThat(mods).as("DEL and ADD of the same attribute same value was not correct").containsExactly(mod1, mod2); |
| | | attr = buildSyncHist(DESCRIPTION, |
| | | ":000000000000000b000000000000:add:Init Value"); |
| | | assertEquals(hist.encodeAndPurge(), attr); |
| | |
| | | attr = Attributes.empty(DESCRIPTION); |
| | | Modification mod2 = new Modification(ModificationType.REPLACE, attr); |
| | | |
| | | List<Modification> mods = new LinkedList<>(); |
| | | mods.add(mod1); |
| | | mods.add(mod2); |
| | | List<Modification> mods = newLinkedList(mod1, mod2); |
| | | |
| | | List<Modification> mods2 = new LinkedList<>(mods); |
| | | replayModifies(entry, hist, mods, 12); |
| | | assertEquals(hist.encodeAndPurge(), attrDel); |
| | | assertEquals(mods.size(), 2, |
| | | "DEL one value, del by Replace of the same attribute was not correct"); |
| | | assertEquals(mods.get(0), mod1, |
| | | "DEL one value, del by Replace of the same attribute was not correct"); |
| | | assertEquals(mods.get(1), mod2, |
| | | "DEL one value, del by Replace of the same attribute was not correct"); |
| | | assertThat(mods).as("DEL one value, del by Replace of the same attribute was not correct").containsExactly(mod1, mod2); |
| | | |
| | | // Replay the same modifs again |
| | | replayModifies(entry, hist, mods2, 12); |
| | |
| | | attr = Attributes.create(DESCRIPTION, "Init Value"); |
| | | Modification mod2 = new Modification(ModificationType.DELETE, attr); |
| | | |
| | | List<Modification> mods = new LinkedList<>(); |
| | | mods.add(mod1); |
| | | mods.add(mod2); |
| | | List<Modification> mods = newLinkedList(mod1, mod2); |
| | | |
| | | replayModifies(entry, hist, mods, 11); |
| | | attr = buildSyncHist(DESCRIPTION, |
| | | ":000000000000000b000000000000:del:Init Value"); |
| | | assertEquals(hist.encodeAndPurge(), attr); |
| | | assertEquals(mods.size(), 2, |
| | | "DEL and ADD of the same attribute same value was not correct"); |
| | | assertEquals(mods.get(0), mod1, |
| | | "DEL and ADD of the same attribute same value was not correct"); |
| | | assertEquals(mods.get(1), mod2, |
| | | "DEL and ADD of the same attribute same value was not correct"); |
| | | assertThat(mods).as("DEL and ADD of the same attribute same value was not correct").containsExactly(mod1, mod2); |
| | | } |
| | | |
| | | /** |
| | |
| | | entry.applyModifications(mods); |
| | | } |
| | | |
| | | private void replayModifies( |
| | | Entry entry, EntryHistorical hist, List<Modification> mods, int date) |
| | | private void replayModifies(Entry entry, EntryHistorical hist, List<Modification> mods, int date) |
| | | { |
| | | InternalClientConnection aConnection = |
| | | InternalClientConnection.getRootConnection(); |
| | | CSN t = new CSN(date, 0, 0); |
| | | |
| | | ModifyOperationBasis modOpBasis = |
| | | new ModifyOperationBasis(aConnection, 1, 1, null, entry.getName(), mods); |
| | | new ModifyOperationBasis(getRootConnection(), 1, 1, null, entry.getName(), mods); |
| | | LocalBackendModifyOperation modOp = new LocalBackendModifyOperation(modOpBasis); |
| | | ModifyContext ctx = new ModifyContext(t, "uniqueId"); |
| | | modOp.setAttachment(SYNCHROCONTEXT, ctx); |
| | |
| | | |
| | | // Create description with values value1 and value2 and add |
| | | // this attribute to the entry. |
| | | AttributeBuilder builder = new AttributeBuilder(DESCRIPTION); |
| | | builder.add("value1"); |
| | | builder.add("value2"); |
| | | Attribute attr = Attributes.create(DESCRIPTION, "value1", "value2"); |
| | | |
| | | List<ByteString> duplicateValues = new LinkedList<>(); |
| | | entry.addAttribute(builder.toAttribute(), duplicateValues); |
| | | entry.addAttribute(attr, duplicateValues); |
| | | |
| | | // load historical from the entry |
| | | EntryHistorical hist = EntryHistorical.newInstanceFromEntry(entry); |
| | | |
| | | // simulate a delete of same value in the same operation done at time t1 |
| | | testModify(entry, hist, 1, true, buildMod(DESCRIPTION, ModificationType.DELETE, "value1")); |
| | | Attribute attr = buildSyncHist(DESCRIPTION, |
| | | attr = buildSyncHist(DESCRIPTION, |
| | | ":0000000000000001000000000000:del:value1"); |
| | | assertEquals(hist.encodeAndPurge(), attr); |
| | | |
| | |
| | | |
| | | // The entry should have no value |
| | | List<Attribute> attrs = entry.getAttribute(DESCRIPTION); |
| | | builder = new AttributeBuilder(DESCRIPTION); |
| | | builder.add("value2"); |
| | | builder.add("value3"); |
| | | builder.add("value4"); |
| | | assertEquals(attrs.get(0), builder.toAttribute()); |
| | | attr = Attributes.create(DESCRIPTION, "value2", "value3", "value4"); |
| | | assertEquals(attrs.get(0), attr); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | // Create description with values value1 and value2 and add |
| | | // this attribute to the entry. |
| | | AttributeBuilder builder = new AttributeBuilder(DESCRIPTION); |
| | | builder.add("value1"); |
| | | builder.add("value2"); |
| | | builder.add("value3"); |
| | | Attribute attr = Attributes.create(DESCRIPTION, "value1", "value2", "value3"); |
| | | |
| | | List<ByteString> duplicateValues = new LinkedList<>(); |
| | | entry.addAttribute(builder.toAttribute(), duplicateValues); |
| | | entry.addAttribute(attr, duplicateValues); |
| | | |
| | | // load historical from the entry |
| | | EntryHistorical hist = EntryHistorical.newInstanceFromEntry(entry); |
| | | |
| | | // simulate a delete of a value in the same operation done at time t1 |
| | | testModify(entry, hist, 1, true, buildMod(DESCRIPTION, ModificationType.DELETE, "value1")); |
| | | Attribute attr = buildSyncHist(DESCRIPTION, |
| | | attr = buildSyncHist(DESCRIPTION, |
| | | ":0000000000000001000000000000:del:value1"); |
| | | assertEquals(hist.encodeAndPurge(), attr); |
| | | |
| | |
| | | |
| | | // The entry should have no value |
| | | List<Attribute> attrs = entry.getAttribute(DESCRIPTION); |
| | | builder = new AttributeBuilder(DESCRIPTION); |
| | | builder.add("value3"); |
| | | builder.add("value4"); |
| | | assertEquals(attrs.get(0), builder.toAttribute()); |
| | | attr = Attributes.create(DESCRIPTION, "value3", "value4"); |
| | | assertEquals(attrs.get(0), attr); |
| | | } |
| | | |
| | | /** |