OPENDJ-1342 Migrate AVA, RDN, and DN classes: Removed methods from Converters
Removed methods from Converters class that converted from server to SDK
DNs and RDNs and vice versa
| | |
| | | public static ConnectionFactory newConnectionFactoryForUser(final DN userDN) { |
| | | InternalClientConnection icc = null; |
| | | try { |
| | | icc = new InternalClientConnection(to(userDN)); |
| | | icc = new InternalClientConnection(userDN); |
| | | } catch (DirectoryException e) { |
| | | throw new IllegalStateException(e.getMessage(), e); |
| | | } |
| | |
| | | */ |
| | | public static Connection newConnectionForUser(final DN dn) throws LdapException { |
| | | try { |
| | | return newConnection(new InternalClientConnection(to(dn))); |
| | | return newConnection(new InternalClientConnection(dn)); |
| | | } catch (DirectoryException e) { |
| | | throw newLdapException(Responses.newResult(ResultCode.NO_SUCH_OBJECT)); |
| | | } |
| | |
| | | |
| | | final SearchFilter filter = toSearchFilter(request.getFilter()); |
| | | final org.opends.server.protocols.internal.SearchRequest sr = |
| | | Requests.newSearchRequest(to(request.getName()), request.getScope(), filter) |
| | | Requests.newSearchRequest(request.getName(), request.getScope(), filter) |
| | | .setDereferenceAliasesPolicy(request.getDereferenceAliasesPolicy()) |
| | | .setSizeLimit(request.getSizeLimit()) |
| | | .setTimeLimit(request.getTimeLimit()) |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.SortedSet; |
| | | import java.util.TreeSet; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.io.ASN1; |
| | |
| | | import org.forgerock.opendj.ldap.LdapException; |
| | | import org.forgerock.opendj.ldap.LinkedAttribute; |
| | | import org.forgerock.opendj.ldap.LinkedHashMapEntry; |
| | | import org.forgerock.opendj.ldap.RDN; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.controls.Control; |
| | |
| | | final org.forgerock.opendj.ldap.Entry sdkEntry) { |
| | | if (sdkEntry != null) { |
| | | org.opends.server.types.Entry entry = |
| | | new org.opends.server.types.Entry(to(sdkEntry.getName()), null, null, null); |
| | | new org.opends.server.types.Entry(sdkEntry.getName(), null, null, null); |
| | | List<ByteString> duplicateValues = new ArrayList<>(); |
| | | for (org.opends.server.types.Attribute attribute : toAttributes(sdkEntry.getAllAttributes())) { |
| | | entry.addAttribute(attribute, duplicateValues); |
| | |
| | | final org.forgerock.opendj.ldap.responses.SearchResultEntry value) { |
| | | if (value != null) { |
| | | org.opends.server.types.Entry entry = |
| | | new org.opends.server.types.Entry(to(value.getName()), null, null, null); |
| | | new org.opends.server.types.Entry(value.getName(), null, null, null); |
| | | org.opends.server.types.SearchResultEntry searchResultEntry = |
| | | new org.opends.server.types.SearchResultEntry(entry, to(value.getControls())); |
| | | List<ByteString> duplicateValues = new ArrayList<>(); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Converts from OpenDJ LDAP SDK {@link DN} to OpenDJ server |
| | | * {@link org.forgerock.opendj.ldap.DN}. |
| | | * |
| | | * @param dn |
| | | * value to convert |
| | | * @return the converted value |
| | | */ |
| | | public static org.forgerock.opendj.ldap.DN to(final DN dn) { |
| | | try { |
| | | return org.forgerock.opendj.ldap.DN.valueOf(dn.toString()); |
| | | } catch (Exception e) { |
| | | throw new IllegalStateException(e.getMessage(), e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Converts a set of OpenDJ LDAP SDK {@link DN} to a set of |
| | | * OpenDJ server {@link org.forgerock.opendj.ldap.DN}. |
| | | * |
| | | * @param dnSet |
| | | * set to convert |
| | | * @return the converted set |
| | | */ |
| | | public static SortedSet<org.forgerock.opendj.ldap.DN> to(final SortedSet<DN> dnSet) { |
| | | try { |
| | | SortedSet<org.forgerock.opendj.ldap.DN> newSet = new TreeSet<>(); |
| | | for (DN dn : dnSet) { |
| | | newSet.add(org.forgerock.opendj.ldap.DN.valueOf(dn.toString())); |
| | | } |
| | | return newSet; |
| | | } catch (Exception e) { |
| | | throw new IllegalStateException(e.getMessage(), e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Converts an array of OpenDJ LDAP SDK {@link DN} to an array of |
| | | * OpenDJ server {@link org.forgerock.opendj.ldap.DN}. |
| | | * |
| | | * @param dns |
| | | * array of values to convert |
| | | * @return the converted array |
| | | */ |
| | | public static org.forgerock.opendj.ldap.DN[] to(final DN[] dns) { |
| | | try { |
| | | org.forgerock.opendj.ldap.DN[] newDns = new org.forgerock.opendj.ldap.DN[dns.length]; |
| | | for (int i = 0; i < dns.length; i++) { |
| | | newDns[i] = org.forgerock.opendj.ldap.DN.valueOf(dns[i].toString()); |
| | | } |
| | | return newDns; |
| | | } catch (Exception e) { |
| | | throw new IllegalStateException(e.getMessage(), e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Converts from OpenDJ LDAP SDK {@link RDN} to OpenDJ server |
| | | * {@link org.forgerock.opendj.ldap.RDN}. |
| | | * |
| | | * @param rdn |
| | | * value to convert |
| | | * @return the converted value |
| | | */ |
| | | public static org.forgerock.opendj.ldap.RDN to(final RDN rdn) { |
| | | try { |
| | | return org.forgerock.opendj.ldap.RDN.valueOf(rdn.toString()); |
| | | } catch (Exception e) { |
| | | throw new IllegalStateException(e.getMessage(), e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Converts from OpenDJ LDAP SDK {@link org.forgerock.opendj.ldap.Filter} to |
| | | * OpenDJ server {@link org.opends.server.types.RawFilter}. |
| | | * |
| | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Converts from OpenDJ server {@link org.forgerock.opendj.ldap.DN} to OpenDJ |
| | | * LDAP SDK {@link DN}. |
| | | * |
| | | * @param dn |
| | | * value to convert |
| | | * @return the converted value |
| | | */ |
| | | public static DN from(final org.forgerock.opendj.ldap.DN dn) { |
| | | try { |
| | | return DN.valueOf(dn.toString()); |
| | | } catch (Exception e) { |
| | | throw new IllegalStateException(e.getMessage(), e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Populates the result object with the operation details and return the |
| | | * result object if it was successful. Otherwise, it throws an |
| | |
| | | import javax.swing.event.DocumentListener; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.adapter.server3x.Converters; |
| | | import org.forgerock.opendj.config.LDAPProfile; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.guitools.controlpanel.datamodel.BackendDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.BaseDNDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo; |
| | |
| | | import org.opends.server.tools.ImportLDIF; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.tools.makeldif.MakeLDIF; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.OpenDsException; |
| | | import org.opends.server.util.RemoveOnceNewConfigFrameworkIsUsed; |
| | | import org.opends.server.util.SetupUtils; |
| | |
| | | { |
| | | try |
| | | { |
| | | Set<org.forgerock.opendj.ldap.DN> baseDN = Collections.singleton(Converters.from(DN.valueOf(newBaseDN))); |
| | | Set<DN> baseDN = Collections.singleton(DN.valueOf(newBaseDN)); |
| | | BackendCreationHelper.createBackendOffline(backendName, baseDN, getSelectedBackendType().getBackend()); |
| | | } |
| | | catch (Exception e) |
| | |
| | | import javax.swing.SwingUtilities; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.adapter.server3x.Converters; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.guitools.controlpanel.datamodel.BackendDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo; |
| | |
| | | import org.opends.server.admin.std.client.PluggableBackendCfgClient; |
| | | import org.opends.server.admin.std.meta.BackendVLVIndexCfgDefn; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.OpenDsException; |
| | | |
| | | /** |
| | |
| | | else |
| | | { |
| | | createVLVIndexOffline( |
| | | backendID, indexName, Converters.from(DN.valueOf(baseDN)), filterValue, searchScope, sortOrder); |
| | | backendID, indexName, DN.valueOf(baseDN), filterValue, searchScope, sortOrder); |
| | | } |
| | | SwingUtilities.invokeLater(new Runnable() |
| | | { |
| | |
| | | import javax.swing.event.ListDataListener; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.adapter.server3x.Converters; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.guitools.controlpanel.datamodel.AbstractIndexDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.CategorizedComboBoxElement; |
| | |
| | | import org.opends.server.admin.std.client.PluggableBackendCfgClient; |
| | | import org.opends.server.admin.std.client.RootCfgClient; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.OpenDsException; |
| | | |
| | | /** |
| | |
| | | } |
| | | else |
| | | { |
| | | modifyVLVIndexOffline(backendID, indexName, indexToModify, Converters.from(DN.valueOf(baseDN)), filterValue, |
| | | modifyVLVIndexOffline(backendID, indexName, indexToModify, DN.valueOf(baseDN), filterValue, |
| | | searchScope, sortOrder); |
| | | } |
| | | SwingUtilities.invokeLater(new Runnable() |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2014-2015 ForgeRock AS. |
| | | * Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.adapter.server3x.Converters; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.config.server.spi.ConfigAddListener; |
| | |
| | | import org.forgerock.opendj.ldap.CancelledResultException; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.Entry; |
| | | import org.forgerock.opendj.ldap.LdapException; |
| | | import org.forgerock.opendj.ldap.Filter; |
| | | import org.forgerock.opendj.ldap.LdapException; |
| | | import org.forgerock.opendj.ldap.LdapResultHandler; |
| | | import org.forgerock.opendj.ldap.MemoryBackend; |
| | | import org.forgerock.opendj.ldap.RequestContext; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.LdapResultHandler; |
| | | import org.forgerock.opendj.ldap.SearchResultHandler; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.requests.Requests; |
| | |
| | | if (!backend.contains(dn)) |
| | | { |
| | | throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, |
| | | ERR_CONFIG_FILE_DELETE_NO_SUCH_ENTRY.get(dn), Converters.to(getMatchedDN(dn)), null); |
| | | ERR_CONFIG_FILE_DELETE_NO_SUCH_ENTRY.get(dn), getMatchedDN(dn), null); |
| | | } |
| | | |
| | | // Entry must not have children. |
| | |
| | | if (!backend.contains(entryDN)) |
| | | { |
| | | throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, |
| | | ERR_CONFIG_FILE_MODIFY_NO_SUCH_ENTRY.get(oldEntry), Converters.to(getMatchedDN(entryDN)), null); |
| | | ERR_CONFIG_FILE_MODIFY_NO_SUCH_ENTRY.get(oldEntry), getMatchedDN(entryDN), null); |
| | | } |
| | | |
| | | //TODO : add objectclass and attribute to the config schema in order to get this code run |
| | |
| | | if (!backend.contains(parentDN)) |
| | | { |
| | | throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, |
| | | ERR_CONFIG_FILE_ADD_NO_PARENT.get(entryDN, parentDN), Converters.to(getMatchedDN(parentDN)), null); |
| | | ERR_CONFIG_FILE_ADD_NO_PARENT.get(entryDN, parentDN), getMatchedDN(parentDN), null); |
| | | } |
| | | return parentDN; |
| | | } |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.adapter.server3x.Converters; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DN; |
| | |
| | | */ |
| | | private CompactDn toCompactDn(DN dn) |
| | | { |
| | | return Converters.from(dn).compact(); |
| | | return dn.compact(); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | static DN fromCompactDn(CompactDn compactDn) |
| | | { |
| | | return Converters.to(compactDn.toDn()); |
| | | return compactDn.toDn(); |
| | | } |
| | | } |
| | | |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.protocols.http; |
| | | |
| | |
| | | { |
| | | final int messageID = nextMessageID.getAndIncrement(); |
| | | return enqueueOperation(new ModifyOperationBasis(clientConnection, messageID, messageID, |
| | | to(request.getControls()), to(request.getName()), |
| | | to(request.getControls()), request.getName(), |
| | | toModifications(request.getModifications()))); |
| | | } |
| | | |
| | |
| | | { |
| | | final int messageID = nextMessageID.getAndIncrement(); |
| | | return enqueueOperation(new ModifyDNOperationBasis(clientConnection, messageID, messageID, |
| | | to(request.getControls()), to(request.getName()), to(request |
| | | .getNewRDN()), request.isDeleteOldRDN(), to(request |
| | | .getNewSuperior()))); |
| | | to(request.getControls()), request.getName(), request.getNewRDN(), |
| | | request.isDeleteOldRDN(), request.getNewSuperior())); |
| | | } |
| | | |
| | | @Override |
| | |
| | | { |
| | | final int messageID = nextMessageID.getAndIncrement(); |
| | | return enqueueOperation(new SearchOperationBasis(clientConnection, messageID, messageID, |
| | | to(request.getControls()), to(request.getName()), |
| | | to(request.getControls()), request.getName(), |
| | | request.getScope(), request.getDereferenceAliasesPolicy(), |
| | | request.getSizeLimit(), request.getTimeLimit(), |
| | | request.isTypesOnly(), toSearchFilter(request.getFilter()), |
| | |
| | | */ |
| | | public ModifyDNOperation processModifyDN(ModifyDNRequest modifyDNRequest) |
| | | { |
| | | org.forgerock.opendj.ldap.DN newSuperior = modifyDNRequest.getNewSuperior(); |
| | | return processModifyDN(to(modifyDNRequest.getName()), |
| | | to(modifyDNRequest.getNewRDN()), |
| | | return processModifyDN(modifyDNRequest.getName(), |
| | | modifyDNRequest.getNewRDN(), |
| | | modifyDNRequest.isDeleteOldRDN(), |
| | | newSuperior != null ? to(newSuperior) : null); |
| | | modifyDNRequest.getNewSuperior()); |
| | | } |
| | | |
| | | /** |
| | |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | |
| | | import static org.forgerock.opendj.adapter.server3x.Converters.*; |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.forgerock.opendj.ldap.requests.Requests.*; |
| | | import static org.opends.messages.ConfigMessages.*; |
| | |
| | | e.getMessageObject(), e); |
| | | } |
| | | |
| | | ModifyRequest modifyRequest = newModifyRequest(from(configEntryDN)) |
| | | ModifyRequest modifyRequest = newModifyRequest(configEntryDN) |
| | | .addModification(REPLACE, ATTR_BACKEND_ENABLED, TRUE_VALUE); |
| | | ModifyOperation internalModify = getRootConnection().processModify(modifyRequest); |
| | | |
| | |
| | | e.getMessageObject(), e); |
| | | } |
| | | |
| | | ModifyRequest modifyRequest = newModifyRequest(from(configEntryDN)) |
| | | ModifyRequest modifyRequest = newModifyRequest(configEntryDN) |
| | | .addModification(REPLACE, ATTR_BACKEND_ENABLED, FALSE_VALUE); |
| | | ModifyOperation internalModify = getRootConnection().processModify(modifyRequest); |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * Converts a SDK Distinguished Name to a LDAP server Distinguish Name. Needs |
| | | * a running server to work. |
| | | * |
| | | * @throws DirectoryException |
| | | */ |
| | | @Test(groups = { "needRunningServer" }) |
| | | public final void testToDN() throws DirectoryException { |
| | | final String dnString = "uid=scarter,ou=People,dc=example,dc=com"; |
| | | org.forgerock.opendj.ldap.DN sdkDN = |
| | | org.forgerock.opendj.ldap.DN.valueOf(dnString); |
| | | |
| | | org.forgerock.opendj.ldap.DN srvDN = to(sdkDN); |
| | | assertThat(srvDN.toString()).isEqualTo(dnString); |
| | | } |
| | | |
| | | @Test |
| | | public final void testToRDN() throws DirectoryException { |
| | | final String rdnString = "uid=scarter"; |
| | | org.forgerock.opendj.ldap.RDN sdkRDN = |
| | | org.forgerock.opendj.ldap.RDN.valueOf(rdnString); |
| | | |
| | | org.forgerock.opendj.ldap.RDN srvRDN = to(sdkRDN); |
| | | assertThat(srvRDN.toString()).isEqualTo(rdnString); |
| | | } |
| | | |
| | | /** |
| | | * Converts a SDK control to a LDAP server control. |
| | | * |
| | | * @throws DirectoryException |
| | |
| | | } |
| | | |
| | | /** |
| | | * Converts a a LDAP server Distinguish Name to a SDK Distinguished Name. |
| | | * |
| | | * @throws DirectoryException |
| | | */ |
| | | @Test |
| | | public final void testFromDN() throws DirectoryException { |
| | | final String dnString = "uid=scarter,ou=People,dc=example,dc=com"; |
| | | org.forgerock.opendj.ldap.DN srvDN = org.forgerock.opendj.ldap.DN.valueOf(dnString); |
| | | org.forgerock.opendj.ldap.DN sdkDN = from(srvDN); |
| | | |
| | | assertThat(sdkDN.toString()).isEqualTo(dnString); |
| | | } |
| | | |
| | | /** |
| | | * For an SASL bind request, credentials are composed by uid and password |
| | | * (in this config). |
| | | */ |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.server; |
| | | |
| | |
| | | |
| | | return mo.getConfiguration(); |
| | | } catch (DefinitionDecodingException e) { |
| | | throw ConfigExceptionFactory.getInstance().createDecodingExceptionAdaptor(Converters.from(entry.getName()), e); |
| | | throw ConfigExceptionFactory.getInstance().createDecodingExceptionAdaptor(entry.getName(), e); |
| | | } catch (ServerManagedObjectDecodingException e) { |
| | | throw ConfigExceptionFactory.getInstance().createDecodingExceptionAdaptor(e); |
| | | } catch (ConstraintViolationException e) { |
| | |
| | | import static java.util.concurrent.TimeUnit.*; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.forgerock.opendj.adapter.server3x.Converters.*; |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.forgerock.opendj.ldap.ResultCode.*; |
| | | import static org.forgerock.opendj.ldap.requests.Requests.*; |
| | |
| | | |
| | | // mod 'sn' of fiona with 'sn' configured as ecl-incl-att |
| | | final ModifyOperation modOp1 = connection.processModify( |
| | | newModifyRequest(from(uentry1.getName())) |
| | | newModifyRequest(uentry1.getName()) |
| | | .addModification(REPLACE, "sn", "newsn")); |
| | | waitForSearchOpResult(modOp1, ResultCode.SUCCESS); |
| | | |
| | | // mod 'telephonenumber' of robert |
| | | final ModifyOperation modOp2 = connection.processModify( |
| | | newModifyRequest(from(uentry2.getName())) |
| | | newModifyRequest(uentry2.getName()) |
| | | .addModification(REPLACE, "telephonenumber", "555555")); |
| | | waitForSearchOpResult(modOp2, ResultCode.SUCCESS); |
| | | |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.forgerock.opendj.adapter.server3x.Converters.*; |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.forgerock.opendj.ldap.requests.Requests.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | |
| | | |
| | | private void enableBackend(Entry entry, boolean enabled) |
| | | { |
| | | ModifyRequest modifyRequest = newModifyRequest(from(entry.getName())) |
| | | ModifyRequest modifyRequest = newModifyRequest(entry.getName()) |
| | | .addModification(REPLACE, "ds-cfg-enabled", Boolean.toString(enabled)); |
| | | ModifyOperation modifyOperation = getRootConnection().processModify(modifyRequest); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.forgerock.opendj.adapter.server3x.Converters.*; |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.forgerock.opendj.ldap.requests.Requests.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | |
| | | |
| | | //Switch things around, change groups and members to odd numbered nested |
| | | //groups and odd numbered members via ldap modify. |
| | | final ModifyRequest modifyRequest = newModifyRequest(from(group1Instance.getGroupDN())); |
| | | final ModifyRequest modifyRequest = newModifyRequest(group1Instance.getGroupDN()); |
| | | modifyRequest.addModification(DELETE, "member", "cn=group 2,ou=Groups,o=test"); |
| | | modifyRequest.addModification(DELETE, "member", "cn=group 4,ou=Groups,o=test"); |
| | | modifyRequest.addModification(DELETE, "member", "uid=user.2,ou=People,o=test"); |
| | |
| | | "it didn't"); |
| | | } catch (DirectoryException ex) {} |
| | | //Modify list via ldap modify. |
| | | final ModifyRequest modifyRequest = newModifyRequest(from(group1Instance.getGroupDN())) |
| | | final ModifyRequest modifyRequest = newModifyRequest(group1Instance.getGroupDN()) |
| | | .addModification(DELETE, "member", "cn=group 2,ou=Groups,o=test") |
| | | .addModification(ADD, "member", "cn=group 1,ou=Groups,o=test"); |
| | | ModifyOperation modifyOperation = getRootConnection().processModify(modifyRequest); |
| | |
| | | |
| | | |
| | | // Modify the group and make sure the group manager gets updated accordingly |
| | | final ModifyRequest modifyRequest = newModifyRequest(from(groupDN)) |
| | | final ModifyRequest modifyRequest = newModifyRequest(groupDN) |
| | | .addModification(DELETE, "member", "uid=user.2,ou=People,o=test") |
| | | .addModification(ADD, "member", "uid=user.3,ou=People,o=test"); |
| | | ModifyOperation modifyOperation = getRootConnection().processModify(modifyRequest); |
| | |
| | | |
| | | |
| | | // Modify the group and make sure the group manager gets updated accordingly |
| | | final ModifyRequest modifyRequest = newModifyRequest(from(groupDN)) |
| | | final ModifyRequest modifyRequest = newModifyRequest(groupDN) |
| | | .addModification(DELETE, "uniquemember", "uid=user.2,ou=People,o=test") |
| | | .addModification(ADD, "uniquemember", "uid=user.3,ou=People,o=test"); |
| | | ModifyOperation modifyOperation = getRootConnection().processModify(modifyRequest); |
| | |
| | | |
| | | |
| | | // Modify the group and make sure the group manager gets updated accordingly |
| | | final ModifyRequest modifyRequest = newModifyRequest(from(groupDN)) |
| | | final ModifyRequest modifyRequest = newModifyRequest(groupDN) |
| | | .addModification(DELETE, "member", "uid=user.2,ou=People,o=test") |
| | | .addModification(ADD, "member", "uid=user.3,ou=People,o=test"); |
| | | ModifyOperation modifyOperation = getRootConnection().processModify(modifyRequest); |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.forgerock.opendj.adapter.server3x.Converters.*; |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.forgerock.opendj.ldap.requests.Requests.*; |
| | | import static org.mockito.Mockito.*; |
| | |
| | | AssertionRequestControl ctrl = AssertionRequestControl.newControl(true, Filter.equality(ETAG, etag1)); |
| | | |
| | | // Apply a change using the assertion control for optimistic concurrency. |
| | | ModifyRequest modifyRequest = newModifyRequest(from(userDN)) |
| | | ModifyRequest modifyRequest = newModifyRequest(userDN) |
| | | .addModification(REPLACE, DESCRIPTION, "first modify") |
| | | .addControl(ctrl); |
| | | ModifyOperation modifyOperation = conn.processModify(modifyRequest); |
| | |
| | | String description2 = assertDescriptionValue(e2, "first modify"); |
| | | |
| | | // Simulate a concurrent update: perform another update using the old etag. |
| | | modifyRequest = newModifyRequest(from(userDN)) |
| | | modifyRequest = newModifyRequest(userDN) |
| | | .addModification(REPLACE, DESCRIPTION, "second modify") |
| | | .addControl(ctrl); |
| | | modifyOperation = conn.processModify(modifyRequest); |
| | |
| | | assertNotNull(etag1); |
| | | |
| | | // Apply a change using the pre and post read controls. |
| | | ModifyRequest modifyRequest = newModifyRequest(from(userDN)) |
| | | ModifyRequest modifyRequest = newModifyRequest(userDN) |
| | | .addModification(REPLACE, DESCRIPTION, "modified value") |
| | | .addControl(PreReadRequestControl.newControl(true, ETAG)); |
| | | ModifyOperation modifyOperation = conn.processModify(modifyRequest); |
| | |
| | | assertNotNull(etag1); |
| | | |
| | | // Apply a change using the pre and post read controls. |
| | | ModifyRequest modifyRequest = newModifyRequest(from(userDN)) |
| | | ModifyRequest modifyRequest = newModifyRequest(userDN) |
| | | .addModification(REPLACE, DESCRIPTION, "modified value") |
| | | .addControl(PostReadRequestControl.newControl(true, ETAG)); |
| | | ModifyOperation modifyOperation = conn.processModify(modifyRequest); |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.forgerock.opendj.adapter.server3x.Converters.*; |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.opends.server.extensions.ExtensionsConstants.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | |
| | | } |
| | | |
| | | private void setPasswordChangedTime(Entry userEntry) { |
| | | ModifyRequest modifyRequest = Requests.newModifyRequest(from(userEntry.getName())) |
| | | ModifyRequest modifyRequest = Requests.newModifyRequest(userEntry.getName()) |
| | | .addModification(REPLACE, "pwdchangedtime", "20050101000000.000Z"); |
| | | ModifyOperation op = getRootConnection().processModify(modifyRequest); |
| | | assertEquals(op.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.forgerock.opendj.adapter.server3x.Converters.*; |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.opends.server.core.DirectoryServer.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | |
| | | */ |
| | | private ModifyOperation |
| | | addAttrEntry(DN dn, String attrName, Object... attrValStrings) { |
| | | ModifyRequest modifyRequest = Requests.newModifyRequest(from(dn)) |
| | | ModifyRequest modifyRequest = Requests.newModifyRequest(dn) |
| | | .addModification(ADD, attrName, attrValStrings); |
| | | return getRootConnection().processModify(modifyRequest); |
| | | } |
| | |
| | | * @param attrValStrings The values to replace in the the entry. |
| | | */ |
| | | private ModifyOperation replaceAttrEntry(DN dn, String attrName, Object... attrValStrings) { |
| | | ModifyRequest modifyRequest = Requests.newModifyRequest(from(dn)) |
| | | ModifyRequest modifyRequest = Requests.newModifyRequest(dn) |
| | | .addModification(REPLACE, attrName, attrValStrings); |
| | | return getRootConnection().processModify(modifyRequest); |
| | | } |
| | |
| | | */ |
| | | private void |
| | | deleteAttrsEntry(DN dn, String... attrTypeStrings) throws Exception { |
| | | ModifyRequest modifyRequest = Requests.newModifyRequest(from(dn)); |
| | | ModifyRequest modifyRequest = Requests.newModifyRequest(dn); |
| | | for(String attrTypeString : attrTypeStrings) { |
| | | modifyRequest.addModification(DELETE, attrTypeString); |
| | | } |
| | |
| | | package org.opends.server.plugins; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.forgerock.opendj.adapter.server3x.Converters.*; |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | |
| | | TestCaseUtils.addEntry(testEntry); |
| | | |
| | | // Perform the modify operation |
| | | ModifyRequest modifyRequest = Requests.newModifyRequest(from(testEntry.getName())) |
| | | ModifyRequest modifyRequest = Requests.newModifyRequest(testEntry.getName()) |
| | | .addModification(REPLACE, "userPassword", "password"); |
| | | ModifyOperation modOp = getRootConnection().processModify(modifyRequest); |
| | | assertEquals(modOp.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.forgerock.opendj.adapter.server3x.Converters.*; |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.opends.messages.ProtocolMessages.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | |
| | | private void processModify(DN dn, ModificationType modType, String attrName, String attrValue) |
| | | { |
| | | ModifyOperation modifyOp = getRootConnection().processModify( |
| | | Requests.newModifyRequest(from(dn)).addModification(modType, attrName, attrValue)); |
| | | Requests.newModifyRequest(dn).addModification(modType, attrName, attrValue)); |
| | | assertEquals(modifyOp.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | |
| | | |
| | | import static java.util.concurrent.TimeUnit.*; |
| | | |
| | | import static org.forgerock.opendj.adapter.server3x.Converters.*; |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.forgerock.opendj.ldap.ResultCode.*; |
| | | import static org.forgerock.opendj.ldap.SearchScope.*; |
| | |
| | | |
| | | protected static ModifyRequest modifyRequest(DN entryDN, ModificationType modType, String attrName, String attrValue) |
| | | { |
| | | return Requests.newModifyRequest(from(entryDN)).addModification(modType, attrName, attrValue); |
| | | return Requests.newModifyRequest(entryDN).addModification(modType, attrName, attrValue); |
| | | } |
| | | |
| | | /** Utility method to create, run a task and check its result. */ |