| | |
| | | */ |
| | | package org.opends.server.admin; |
| | | |
| | | import java.util.LinkedHashSet; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.opends.server.protocols.internal.Requests; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.types.Attribute; |
| | | 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.LDAPException; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.SearchResultEntry; |
| | | |
| | |
| | | */ |
| | | private String getAttr(String baseDN, String attrName) |
| | | { |
| | | // Prepare the ldap search |
| | | LDAPFilter filter; |
| | | InternalSearchOperation search; |
| | | try |
| | | { |
| | | filter = LDAPFilter.decode("objectclass=*"); |
| | | SearchRequest request = Requests.newSearchRequest(baseDN, SearchScope.BASE_OBJECT, "objectclass=*") |
| | | .addAttribute(attrName); |
| | | search = internalConnection.processSearch(request); |
| | | if (search.getResultCode() != ResultCode.SUCCESS) |
| | | { |
| | | // can not happen |
| | | // best effort. |
| | | // TODO Log an Error. |
| | | return null; |
| | | } |
| | | } |
| | | catch (LDAPException e) |
| | | catch (DirectoryException e) |
| | | { |
| | | // can not happen |
| | | // best effort. |
| | |
| | | return null; |
| | | } |
| | | |
| | | LinkedHashSet<String> attributes = new LinkedHashSet<String>(1); |
| | | attributes.add(attrName); |
| | | InternalSearchOperation search = internalConnection.processSearch( |
| | | ByteString.valueOf(baseDN), SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.ALWAYS, 0, 0, false, filter, attributes); |
| | | |
| | | if ((search.getResultCode() != ResultCode.SUCCESS)) |
| | | { |
| | | // can not happen |
| | | // best effort. |
| | | // TODO Log an Error. |
| | | return null; |
| | | } |
| | | |
| | | // Read the port from the PORT attribute |
| | | SearchResultEntry adminConnectorEntry = null; |
| | | |
| | | /* |
| | | * Read the port from the PORT attribute |
| | | */ |
| | | LinkedList<SearchResultEntry> result = search.getSearchEntries(); |
| | | if (!result.isEmpty()) |
| | | { |
| | |
| | | } |
| | | |
| | | List<Attribute> attrs = adminConnectorEntry.getAttribute(attrType); |
| | | |
| | | if (attrs == null) |
| | | { |
| | | // can not happen |
| | |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | | import java.util.LinkedHashSet; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.types.*; |
| | | |
| | | import static org.opends.messages.AccessControlMessages.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | |
| | | /* |
| | | * TODO Evaluate making this class more efficient. |
| | |
| | | AttributeType attrType; |
| | | if((attrType = DirectoryServer.getAttributeType(attrStr)) == null) |
| | | attrType = DirectoryServer.getDefaultAttributeType(attrStr); |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation op = |
| | | conn.processSearch(evalCtx.getClientDN(), |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | filter, null); |
| | | final SearchRequest request = newSearchRequest(evalCtx.getClientDN(), SearchScope.BASE_OBJECT, filter); |
| | | InternalSearchOperation op = getRootConnection().processSearch(request); |
| | | LinkedList<SearchResultEntry> result = op.getSearchEntries(); |
| | | if (!result.isEmpty()) { |
| | | ByteString val= ByteString.valueOf(attrVal); |
| | |
| | | stop=true; |
| | | } |
| | | } else { |
| | | DN pDN= |
| | | getDNParentLevel(levels[i], evalCtx.getResourceDN()); |
| | | DN pDN = getDNParentLevel(levels[i], evalCtx.getResourceDN()); |
| | | if(pDN == null) |
| | | continue; |
| | | LinkedHashSet<String> reqAttrs = new LinkedHashSet<String>(1); |
| | | reqAttrs.add(parentInheritance.getAttrTypeStr()); |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation op = conn.processSearch(pDN, |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | filter, reqAttrs); |
| | | LinkedList<SearchResultEntry> result = |
| | | op.getSearchEntries(); |
| | | final SearchRequest request = newSearchRequest(pDN, SearchScope.BASE_OBJECT, filter) |
| | | .addAttribute(parentInheritance.getAttrTypeStr()); |
| | | InternalSearchOperation op = getRootConnection().processSearch(request); |
| | | LinkedList<SearchResultEntry> result = op.getSearchEntries(); |
| | | if (!result.isEmpty()) { |
| | | Entry e = result.getFirst(); |
| | | if(e.hasAttribute(attrType)) { |
| | |
| | | import javax.management.AttributeList; |
| | | import javax.management.AttributeNotFoundException; |
| | | import javax.management.DynamicMBean; |
| | | import javax.management.MBeanAttributeInfo; |
| | | import javax.management.InvalidAttributeValueException; |
| | | import javax.management.MBeanAttributeInfo; |
| | | import javax.management.MBeanConstructorInfo; |
| | | import javax.management.MBeanException; |
| | | import javax.management.MBeanInfo; |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.admin.std.server.MonitorProviderCfg; |
| | | import org.opends.server.api.AlertGenerator; |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.protocols.jmx.Credential; |
| | | import org.opends.server.protocols.jmx.JmxClientConnection; |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.InvokableMethod; |
| | | import org.opends.server.types.LDAPException; |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | // |
| | | // prepare the ldap search |
| | | |
| | | LDAPFilter filter; |
| | | try |
| | | { |
| | | filter = LDAPFilter.decode("objectclass=*"); |
| | | } |
| | | catch (LDAPException e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | LocalizableMessage message = ERR_CONFIG_JMX_CANNOT_GET_ATTRIBUTE. |
| | | get(attributeName, configEntryDN, getExceptionMessage(e)); |
| | | throw new AttributeNotFoundException(message.toString()); |
| | | } |
| | | |
| | | // |
| | | // Perform the Ldap operation for |
| | | // - ACI Check |
| | | // - Loggin purpose |
| | | InternalSearchOperation op=null; |
| | | if (clientConnection instanceof JmxClientConnection) { |
| | | // |
| | | // Perform the Ldap operation for |
| | | // - ACI Check |
| | | // - Loggin purpose |
| | | InternalSearchOperation op=null; |
| | | if (clientConnection instanceof JmxClientConnection) { |
| | | op = ((JmxClientConnection)clientConnection).processSearch( |
| | | ByteString.valueOf(configEntryDN.toString()), |
| | | SearchScope.BASE_OBJECT, filter); |
| | | } |
| | | else if (clientConnection instanceof InternalClientConnection) { |
| | | op = ((InternalClientConnection)clientConnection).processSearch( |
| | | ByteString.valueOf(configEntryDN.toString()), |
| | | SearchScope.BASE_OBJECT, filter); |
| | | } |
| | | // BUG : op may be null |
| | | ResultCode rc = op.getResultCode(); |
| | | if (rc != ResultCode.SUCCESS) { |
| | | clientConnection = null ; |
| | | SearchScope.BASE_OBJECT, getTrueFilter()); |
| | | } |
| | | else if (clientConnection instanceof InternalClientConnection) { |
| | | SearchRequest request = newSearchRequest(configEntryDN, SearchScope.BASE_OBJECT, "(objectclass=*)"); |
| | | op = ((InternalClientConnection) clientConnection).processSearch(request); |
| | | } |
| | | // BUG : op may be null |
| | | ResultCode rc = op.getResultCode(); |
| | | if (rc != ResultCode.SUCCESS) { |
| | | LocalizableMessage message = ERR_CONFIG_JMX_CANNOT_GET_ATTRIBUTE. |
| | | get(attributeName, configEntryDN, op.getErrorMessage()); |
| | | throw new AttributeNotFoundException(message.toString()); |
| | | } |
| | | |
| | | LocalizableMessage message = ERR_CONFIG_JMX_CANNOT_GET_ATTRIBUTE. |
| | | get(attributeName, configEntryDN, op.getErrorMessage()); |
| | | throw new AttributeNotFoundException(message.toString()); |
| | | } |
| | | |
| | | try |
| | | { |
| | | return getJmxAttribute(attributeName); |
| | | } |
| | | catch (AttributeNotFoundException e) |
| | | { |
| | | throw e; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | |
| | | } |
| | | } |
| | | |
| | | private LDAPFilter getTrueFilter() |
| | | { |
| | | try |
| | | { |
| | | return LDAPFilter.decode("(objectclass=*)"); |
| | | } |
| | | catch (LDAPException e) |
| | | { |
| | | // can never happen |
| | | logger.traceException(e); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Set the value of a specific attribute of the Dynamic MBean. In this case, |
| | | * it will always throw {@code InvalidAttributeValueException} because setting |
| | |
| | | } |
| | | |
| | | // |
| | | // prepare the ldap search |
| | | LDAPFilter filter; |
| | | try |
| | | { |
| | | filter = LDAPFilter.decode("objectclass=*"); |
| | | // Perform the Ldap operation for |
| | | // - ACI Check |
| | | // - Loggin purpose |
| | | InternalSearchOperation op = null; |
| | | if (clientConnection instanceof JmxClientConnection) { |
| | | op = ((JmxClientConnection)clientConnection).processSearch( |
| | | ByteString.valueOf(configEntryDN.toString()), |
| | | SearchScope.BASE_OBJECT, getTrueFilter()); |
| | | } |
| | | catch (LDAPException e) |
| | | else if (clientConnection instanceof InternalClientConnection) { |
| | | try |
| | | { |
| | | SearchRequest request = newSearchRequest(configEntryDN, SearchScope.BASE_OBJECT, "(objectclass=*)"); |
| | | op = ((InternalClientConnection) clientConnection).processSearch(request); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | logger.traceException(e); |
| | | } |
| | | } |
| | | |
| | | if (op == null) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | // |
| | | // Perform the Ldap operation for |
| | | // - ACI Check |
| | | // - Loggin purpose |
| | | InternalSearchOperation op=null; |
| | | if (clientConnection instanceof JmxClientConnection) { |
| | | op = ((JmxClientConnection)clientConnection).processSearch( |
| | | ByteString.valueOf(configEntryDN.toString()), |
| | | SearchScope.BASE_OBJECT, filter); |
| | | } |
| | | else if (clientConnection instanceof InternalClientConnection) { |
| | | op = ((InternalClientConnection)clientConnection).processSearch( |
| | | ByteString.valueOf(configEntryDN.toString()), |
| | | SearchScope.BASE_OBJECT, filter); |
| | | } |
| | | // BUG: op may be null |
| | | ResultCode rc = op.getResultCode(); |
| | | if (rc != ResultCode.SUCCESS) |
| | | { |
| | | clientConnection = null ; |
| | | return null; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | return attrList; |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | return clientConnection; |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.protocols.ldap.ExtendedRequestProtocolOp; |
| | | import org.opends.server.protocols.ldap.ExtendedResponseProtocolOp; |
| | | import org.opends.server.protocols.ldap.LDAPMessage; |
| | |
| | | |
| | | import static org.opends.messages.CoreMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | // Construct the search filter. |
| | | final String FILTER_OC_INSTANCE_KEY = "(objectclass=" + ocInstanceKey.getNameOrOID() + ")"; |
| | | // Construct the attribute list. |
| | | final LinkedHashSet<String> requestedAttributes |
| | | = new LinkedHashSet<String>(); |
| | | requestedAttributes.add( |
| | | attrPublicKeyCertificate.getNameOrOID() + ";binary"); |
| | | String requestedAttribute = attrPublicKeyCertificate.getNameOrOID() + ";binary"; |
| | | |
| | | // Retrieve the certificate from the entry. |
| | | final InternalClientConnection icc |
| | | = InternalClientConnection.getRootConnection(); |
| | | final InternalClientConnection icc = getRootConnection(); |
| | | byte[] certificate = null; |
| | | try { |
| | | for (int i = 0; i < 2; ++i) { |
| | |
| | | backend, add it using a special object class that induces |
| | | the backend to create the public-key certificate |
| | | attribute, then repeat the search. */ |
| | | InternalSearchOperation searchOp = icc.processSearch( |
| | | entryDN, |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | /* size limit */ 0, /* time limit */ 0, |
| | | /* types only */ false, |
| | | SearchFilter.createFilterFromString( |
| | | FILTER_OC_INSTANCE_KEY), |
| | | requestedAttributes); |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT, FILTER_OC_INSTANCE_KEY) |
| | | .addAttribute(requestedAttribute); |
| | | InternalSearchOperation searchOp = icc.processSearch(request); |
| | | for (Entry e : searchOp.getSearchEntries()) { |
| | | /* attribute ds-cfg-public-key-certificate is a MUST in |
| | | the schema */ |
| | |
| | | */ |
| | | static void publishInstanceKeyEntryInADS() |
| | | throws CryptoManagerException { |
| | | final byte[] instanceKeyCertificate |
| | | = getInstanceKeyCertificateFromLocalTruststore(); |
| | | final String instanceKeyID |
| | | = getInstanceKeyID(instanceKeyCertificate); |
| | | final byte[] instanceKeyCertificate = getInstanceKeyCertificateFromLocalTruststore(); |
| | | final String instanceKeyID = getInstanceKeyID(instanceKeyCertificate); |
| | | // Construct the key entry DN. |
| | | final ByteString distinguishedValue = ByteString.valueOf(instanceKeyID); |
| | | final DN entryDN = instanceKeysDN.child( |
| | | RDN.create(attrKeyID, distinguishedValue)); |
| | | // Construct the search filter. |
| | | final String FILTER_OC_INSTANCE_KEY = "(objectclass=" + ocInstanceKey.getNameOrOID() + ")"; |
| | | // Construct the attribute list. |
| | | final LinkedHashSet<String> requestedAttributes |
| | | = new LinkedHashSet<String>(); |
| | | requestedAttributes.add("dn"); |
| | | |
| | | // Check for the entry. If it does not exist, create it. |
| | | final InternalClientConnection icc |
| | | = InternalClientConnection.getRootConnection(); |
| | | final String FILTER_OC_INSTANCE_KEY = "(objectclass=" + ocInstanceKey.getNameOrOID() + ")"; |
| | | final InternalClientConnection icc = getRootConnection(); |
| | | try { |
| | | final InternalSearchOperation searchOp |
| | | = icc.processSearch( entryDN, SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | /* size limit */ 0, /* time limit */ 0, |
| | | /* types only */ false, |
| | | SearchFilter.createFilterFromString( |
| | | FILTER_OC_INSTANCE_KEY), |
| | | requestedAttributes); |
| | | final SearchRequest request = |
| | | newSearchRequest(entryDN, SearchScope.BASE_OBJECT, FILTER_OC_INSTANCE_KEY).addAttribute("dn"); |
| | | final InternalSearchOperation searchOp = icc.processSearch(request); |
| | | if (0 == searchOp.getSearchEntries().size()) { |
| | | final Entry entry = new Entry(entryDN, null, null, null); |
| | | entry.addObjectClass(DirectoryServer.getTopObjectClass()); |
| | | entry.addObjectClass(ocInstanceKey); |
| | | |
| | | // Add the key ID attribute. |
| | | final Attribute keyIDAttr = Attributes.create(attrKeyID, |
| | | distinguishedValue); |
| | | final Attribute keyIDAttr = Attributes.create(attrKeyID, distinguishedValue); |
| | | entry.addAttribute(keyIDAttr, new ArrayList<ByteString>(0)); |
| | | |
| | | // Add the public key certificate attribute. |
| | | AttributeBuilder builder = new AttributeBuilder( |
| | | attrPublicKeyCertificate); |
| | | AttributeBuilder builder = new AttributeBuilder(attrPublicKeyCertificate); |
| | | builder.setOption("binary"); |
| | | builder.add(ByteString.wrap(instanceKeyCertificate)); |
| | | final Attribute certificateAttr = builder.toAttribute(); |
| | |
| | | search operation. |
| | | @see org.opends.admin.ads.ADSContext#getTrustedCertificates() |
| | | */ |
| | | private Map<String, byte[]> getTrustedCertificates() |
| | | throws CryptoManagerException { |
| | | final Map<String, byte[]> certificateMap |
| | | = new HashMap<String, byte[]>(); |
| | | private Map<String, byte[]> getTrustedCertificates() throws CryptoManagerException { |
| | | final Map<String, byte[]> certificateMap = new HashMap<String, byte[]>(); |
| | | try { |
| | | // Construct the search filter. |
| | | final String FILTER_OC_INSTANCE_KEY = "(objectclass=" + ocInstanceKey.getNameOrOID() + ")"; |
| | | final String FILTER_NOT_COMPROMISED = "(!(" + attrCompromisedTime.getNameOrOID() + "=*))"; |
| | | final String searchFilter = "(&" + FILTER_OC_INSTANCE_KEY + FILTER_NOT_COMPROMISED + ")"; |
| | | // Construct the attribute list. |
| | | final LinkedHashSet<String> requestedAttributes |
| | | = new LinkedHashSet<String>(); |
| | | requestedAttributes.add(attrKeyID.getNameOrOID()); |
| | | requestedAttributes.add( |
| | | attrPublicKeyCertificate.getNameOrOID() + ";binary"); |
| | | // Invoke the search operation. |
| | | final InternalClientConnection icc |
| | | = InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOp = icc.processSearch( |
| | | instanceKeysDN, |
| | | SearchScope.SINGLE_LEVEL, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | /* size limit */ 0, /* time limit */ 0, |
| | | /* types only */ false, |
| | | SearchFilter.createFilterFromString(searchFilter), |
| | | requestedAttributes); |
| | | // Evaluate the search response. |
| | | final SearchRequest request = newSearchRequest(instanceKeysDN, SearchScope.SINGLE_LEVEL, searchFilter) |
| | | .addAttribute(attrKeyID.getNameOrOID(), attrPublicKeyCertificate.getNameOrOID() + ";binary"); |
| | | InternalSearchOperation searchOp = getRootConnection().processSearch(request); |
| | | for (Entry e : searchOp.getSearchEntries()) { |
| | | /* attribute ds-cfg-key-id is the RDN and attribute |
| | | ds-cfg-public-key-certificate is a MUST in the schema */ |
| | |
| | | */ |
| | | private String getSymmetricKey(Set<String> symmetricKeys) |
| | | { |
| | | InternalClientConnection internalConnection = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | for (String symmetricKey : symmetricKeys) |
| | | { |
| | | try |
| | |
| | | String instanceKeyID = elements[0]; |
| | | |
| | | // Find the server entry from the instance key ID. |
| | | String filter = "(" + |
| | | ConfigConstants.ATTR_CRYPTO_KEY_ID + "=" + |
| | | instanceKeyID + ")"; |
| | | InternalSearchOperation internalSearch = |
| | | internalConnection.processSearch( |
| | | serversDN, SearchScope.SUBORDINATES, |
| | | SearchFilter.createFilterFromString(filter)); |
| | | String filter = "(" + ATTR_CRYPTO_KEY_ID + "=" + instanceKeyID + ")"; |
| | | final SearchRequest request = newSearchRequest(serversDN, SearchScope.SUBORDINATES, filter); |
| | | InternalSearchOperation internalSearch = conn.processSearch(request); |
| | | if (internalSearch.getResultCode() != ResultCode.SUCCESS) |
| | | { |
| | | continue; |
| | |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | |
| | | |
| | | |
| | | import java.util.LinkedHashSet; |
| | | |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.api.DirectoryThread; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchListener; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.LDAPURL; |
| | | import org.opends.server.types.MembershipException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.opends.server.types.SearchResultEntry; |
| | | import org.opends.server.types.SearchResultReference; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | |
| | | /** |
| | | * This class implements a Directory Server thread that will be used to perform |
| | |
| | | * Performs the set of searches and provides the results to the associated |
| | | * member list. |
| | | */ |
| | | @Override |
| | | public void run() |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | LinkedHashSet<String> attributes = new LinkedHashSet<String>(0); |
| | | //Include all the user attributes along with the ismemberof. |
| | | attributes.add("*"); |
| | | attributes.add("ismemberof"); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | for (searchCounter = 0; searchCounter < baseDNs.length; searchCounter++) |
| | | { |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(baseDNs[searchCounter], SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, |
| | | false, searchFilters[searchCounter], attributes, |
| | | this); |
| | | DN baseDN = baseDNs[searchCounter]; |
| | | SearchFilter filter = searchFilters[searchCounter]; |
| | | // Include all the user attributes along with the ismemberof. |
| | | final SearchRequest request = newSearchRequest(baseDN, SearchScope.WHOLE_SUBTREE, filter) |
| | | .addAttribute("*", "ismemberof"); |
| | | InternalSearchOperation searchOperation = conn.processSearch(request, this); |
| | | |
| | | ResultCode resultCode = searchOperation.getResultCode(); |
| | | if (resultCode != ResultCode.SUCCESS) |
| | | { |
| | | if (resultCode == ResultCode.NO_SUCH_OBJECT) |
| | | { |
| | | logger.warn(WARN_DYNAMICGROUP_NONEXISTENT_BASE_DN, baseDNs[searchCounter], |
| | | logger.warn(WARN_DYNAMICGROUP_NONEXISTENT_BASE_DN, baseDN, |
| | | memberList.getDynamicGroupDN()); |
| | | continue; |
| | | } |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_DYNAMICGROUP_INTERNAL_SEARCH_FAILED.get( |
| | | baseDNs[searchCounter], |
| | | searchFilters[searchCounter], |
| | | baseDN, |
| | | filter, |
| | | memberList.getDynamicGroupDN(), |
| | | resultCode, |
| | | searchOperation.getErrorMessage()); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void handleInternalSearchEntry(InternalSearchOperation searchOperation, |
| | | SearchResultEntry searchEntry) |
| | | throws DirectoryException |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void handleInternalSearchReference( |
| | | InternalSearchOperation searchOperation, |
| | | SearchResultReference searchReference) |
| | |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.ExactMatchIdentityMapperCfg; |
| | | import org.opends.server.admin.std.server.IdentityMapperCfg; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.IdentityMapper; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | |
| | | /** |
| | | * This class provides an implementation of a Directory Server identity mapper |
| | |
| | | } |
| | | |
| | | SearchResultEntry matchingEntry = null; |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | for (DN baseDN : baseDNs) |
| | | { |
| | | InternalSearchOperation internalSearch = |
| | | conn.processSearch(baseDN, SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, 1, 10, |
| | | false, filter, requestedAttributes); |
| | | final SearchRequest request = newSearchRequest(baseDN, SearchScope.WHOLE_SUBTREE, filter) |
| | | .setSizeLimit(1) |
| | | .setTimeLimit(10) |
| | | .addAttribute(requestedAttributes); |
| | | InternalSearchOperation internalSearch = conn.processSearch(request); |
| | | |
| | | switch (internalSearch.getResultCode().asEnum()) |
| | | { |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.CertificateMapperCfg; |
| | | import org.opends.server.admin.std.server.FingerprintCertificateMapperCfg; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.CertificateMapper; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | /** |
| | |
| | | // For each base DN, issue an internal search in an attempt to map the |
| | | // certificate. |
| | | Entry userEntry = null; |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | for (DN baseDN : baseDNs) |
| | | { |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(baseDN, SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, 1, 10, |
| | | false, filter, requestedAttributes); |
| | | final SearchRequest request = newSearchRequest(baseDN, SearchScope.WHOLE_SUBTREE, filter) |
| | | .setSizeLimit(1) |
| | | .setTimeLimit(10) |
| | | .addAttribute(requestedAttributes); |
| | | InternalSearchOperation searchOperation = conn.processSearch(request); |
| | | |
| | | switch (searchOperation.getResultCode().asEnum()) |
| | | { |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.io.ASN1; |
| | | import org.forgerock.opendj.io.ASN1Reader; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.admin.std.server.PasswordPolicyStateExtendedOperationHandlerCfg; |
| | | import org.opends.server.api.AuthenticationPolicy; |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.api.ExtendedOperationHandler; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.*; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.schema.GeneralizedTimeSyntax; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.opends.messages.CoreMessages.*; |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | |
| | | ExtendedOperation operation, |
| | | DN targetDN) |
| | | { |
| | | Entry entry; |
| | | |
| | | InternalSearchOperation internalSearch = |
| | | conn.processSearch(targetDN, SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 1, 0, |
| | | false, userFilter, requestAttributes, null); |
| | | final SearchRequest request = newSearchRequest(targetDN, SearchScope.BASE_OBJECT, userFilter) |
| | | .setSizeLimit(1) |
| | | .addAttribute(requestAttributes); |
| | | InternalSearchOperation internalSearch = conn.processSearch(request); |
| | | if (internalSearch.getResultCode() != ResultCode.SUCCESS) |
| | | { |
| | | operation.setResultCode(internalSearch.getResultCode()); |
| | |
| | | } |
| | | else |
| | | { |
| | | entry = matchingEntries.get(0); |
| | | return matchingEntries.get(0); |
| | | } |
| | | |
| | | return entry; |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | import java.util.regex.PatternSyntaxException; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.IdentityMapperCfg; |
| | | import org.opends.server.admin.std.server.RegularExpressionIdentityMapperCfg; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.IdentityMapper; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | |
| | | /** |
| | | * This class provides an implementation of a Directory Server identity mapper |
| | |
| | | } |
| | | |
| | | SearchResultEntry matchingEntry = null; |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | for (DN baseDN : baseDNs) |
| | | { |
| | | InternalSearchOperation internalSearch = |
| | | conn.processSearch(baseDN, SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, 1, 10, |
| | | false, filter, requestedAttributes); |
| | | final SearchRequest request = newSearchRequest(baseDN, SearchScope.WHOLE_SUBTREE, filter) |
| | | .setSizeLimit(1) |
| | | .setTimeLimit(10) |
| | | .addAttribute(requestedAttributes); |
| | | InternalSearchOperation internalSearch = conn.processSearch(request); |
| | | |
| | | switch (internalSearch.getResultCode().asEnum()) |
| | | { |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.CertificateMapperCfg; |
| | | import org.opends.server.admin.std.server.SubjectAttributeToUserAttributeCertificateMapperCfg; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.CertificateMapper; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | /** |
| | |
| | | // For each base DN, issue an internal search in an attempt to map the |
| | | // certificate. |
| | | Entry userEntry = null; |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | for (DN baseDN : baseDNs) |
| | | { |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(baseDN, SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, 1, 10, |
| | | false, filter, requestedAttributes); |
| | | final SearchRequest request = newSearchRequest(baseDN, SearchScope.WHOLE_SUBTREE, filter) |
| | | .setSizeLimit(1) |
| | | .setTimeLimit(10) |
| | | .addAttribute(requestedAttributes); |
| | | InternalSearchOperation searchOperation = conn.processSearch(request); |
| | | |
| | | switch (searchOperation.getResultCode().asEnum()) |
| | | { |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | |
| | | import org.opends.server.admin.std.server.SubjectDNToUserAttributeCertificateMapperCfg; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.CertificateMapper; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.types.*; |
| | | |
| | | import static org.opends.messages.ExtensionMessages.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | |
| | | /** |
| | | * This class implements a very simple Directory Server certificate mapper that |
| | |
| | | // For each base DN, issue an internal search in an attempt to map the |
| | | // certificate. |
| | | Entry userEntry = null; |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | for (DN baseDN : baseDNs) |
| | | { |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(baseDN, SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, 1, 10, |
| | | false, filter, requestedAttributes); |
| | | final SearchRequest request = newSearchRequest(baseDN, SearchScope.WHOLE_SUBTREE, filter) |
| | | .setSizeLimit(1) |
| | | .setTimeLimit(10) |
| | | .addAttribute(requestedAttributes); |
| | | InternalSearchOperation searchOperation = conn.processSearch(request); |
| | | switch (searchOperation.getResultCode().asEnum()) |
| | | { |
| | | case SUCCESS: |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | |
| | | import org.opends.server.api.plugin.DirectoryServerPlugin; |
| | | import org.opends.server.api.plugin.PluginResult; |
| | | import org.opends.server.api.plugin.PluginType; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.DeleteOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.operation.SubordinateModifyDNOperation; |
| | | import org.opends.server.types.operation.PostOperationModifyDNOperation; |
| | | import org.opends.server.types.operation.PostOperationDeleteOperation; |
| | | import org.opends.server.types.operation.PostOperationModifyDNOperation; |
| | | import org.opends.server.types.operation.PreOperationAddOperation; |
| | | import org.opends.server.types.operation.PreOperationModifyOperation; |
| | | import org.opends.server.types.operation.SubordinateModifyDNOperation; |
| | | |
| | | import static org.opends.messages.PluginMessages.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | ByteString.valueOf(oldEntryDN.toString()))); |
| | | } |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation operation = conn.processSearch(baseDN, |
| | | SearchScope.WHOLE_SUBTREE, DereferenceAliasesPolicy.NEVER, 0, 0, |
| | | false, SearchFilter.createORFilter(componentFilters), null); |
| | | SearchFilter orFilter = SearchFilter.createORFilter(componentFilters); |
| | | final SearchRequest request = newSearchRequest(baseDN, SearchScope.WHOLE_SUBTREE, orFilter); |
| | | InternalSearchOperation operation = getRootConnection().processSearch(request); |
| | | |
| | | switch (operation.getResultCode().asEnum()) |
| | | { |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.operation.*; |
| | | |
| | | import static org.opends.messages.PluginMessages.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | /** |
| | |
| | | filter = SearchFilter.createORFilter(equalityFilters); |
| | | } |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | for (DN baseDN : baseDNs) |
| | | { |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(baseDN, SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, 2, 0, |
| | | false, filter, SEARCH_ATTRS); |
| | | final SearchRequest request = newSearchRequest(baseDN, SearchScope.WHOLE_SUBTREE, filter) |
| | | .setSizeLimit(2) |
| | | .addAttribute(SEARCH_ATTRS); |
| | | InternalSearchOperation searchOperation = conn.processSearch(request); |
| | | for (SearchResultEntry e : searchOperation.getSearchEntries()) |
| | | { |
| | | if (! e.getName().equals(targetDN)) |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt |
| | | * or http://forgerock.org/license/CDDLv1.0.html. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at legal-notices/CDDLv1_0.txt. |
| | | * If applicable, add the following below this CDDL HEADER, with the |
| | | * fields enclosed by brackets "[]" replaced with your own identifying |
| | | * information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2014 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.protocols.internal; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.util.Reject; |
| | | import org.opends.server.types.Control; |
| | | |
| | | /** |
| | | * Abstract request implementation. |
| | | * |
| | | * @see org.forgerock.opendj.ldap.requests.AbstractRequestImpl |
| | | */ |
| | | abstract class AbstractRequestImpl { |
| | | |
| | | /** |
| | | * To be removed |
| | | * |
| | | * @param controls |
| | | * the controls |
| | | * @param oid |
| | | * the oid |
| | | * @return a new control object |
| | | * @see org.forgerock.opendj.ldap.requests.AbstractRequestImpl#getControl( |
| | | * org.forgerock.opendj.ldap.controls.ControlDecoder, org.forgerock.opendj.ldap.DecodeOptions) |
| | | */ |
| | | static Control getControl(final List<Control> controls, final String oid) { |
| | | // Avoid creating an iterator if possible. |
| | | if (!controls.isEmpty()) { |
| | | for (final Control control : controls) { |
| | | if (control.getOID().equals(oid)) { |
| | | return control; |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private final List<Control> controls = new LinkedList<Control>(); |
| | | |
| | | /** Default constructor. */ |
| | | AbstractRequestImpl() { |
| | | // No implementation required. |
| | | } |
| | | |
| | | /** |
| | | * To be removed |
| | | * |
| | | * @param control |
| | | * the control |
| | | * @return the current object |
| | | * @see org.forgerock.opendj.ldap.requests.AbstractRequestImpl#addControl( |
| | | * org.forgerock.opendj.ldap.controls.Control) |
| | | */ |
| | | public AbstractRequestImpl addControl(final Control control) { |
| | | Reject.ifNull(control); |
| | | controls.add(control); |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * To be removed |
| | | * |
| | | * @param controls |
| | | * the controls |
| | | * @return the current object |
| | | * @see org.forgerock.opendj.ldap.requests.AbstractRequestImpl#addControl( |
| | | * org.forgerock.opendj.ldap.controls.Control) |
| | | */ |
| | | public AbstractRequestImpl addControl(final Collection<Control> controls) { |
| | | if (controls != null) { |
| | | for (Control c : controls) { |
| | | addControl(c); |
| | | } |
| | | } |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * To be removed |
| | | * |
| | | * @param oid |
| | | * the oid |
| | | * @return the current object |
| | | * @see org.forgerock.opendj.ldap.requests.AbstractRequestImpl#containsControl(String) |
| | | */ |
| | | public boolean containsControl(final String oid) { |
| | | return getControl(controls, oid) != null; |
| | | } |
| | | |
| | | /** |
| | | * To be removed |
| | | * |
| | | * @return the controls |
| | | * @see org.forgerock.opendj.ldap.requests.AbstractRequestImpl#getControls() |
| | | */ |
| | | public final List<Control> getControls() { |
| | | return controls; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public abstract String toString(); |
| | | |
| | | } |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.api.ConnectionHandler; |
| | | import org.opends.server.core.*; |
| | | import org.opends.server.core.networkgroups.NetworkGroup; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.util.AddChangeRecordEntry; |
| | | import org.opends.server.util.DeleteChangeRecordEntry; |
| | | import org.opends.server.util.ModifyChangeRecordEntry; |
| | |
| | | String filterString) |
| | | throws DirectoryException |
| | | { |
| | | RawFilter rawFilter; |
| | | try |
| | | { |
| | | rawFilter = RawFilter.create(filterString); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | throw new DirectoryException( |
| | | ResultCode.valueOf(le.getResultCode()), |
| | | le.getErrorMessage(), le); |
| | | } |
| | | |
| | | return processSearch(ByteString.valueOf(rawBaseDN), scope, rawFilter); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Processes an internal search operation with the provided |
| | | * information. |
| | | * |
| | | * @param rawBaseDN The base DN for the search. |
| | | * @param scope The scope for the search. |
| | | * @param derefPolicy The alias dereferencing policy for the |
| | | * search. |
| | | * @param sizeLimit The size limit for the search. |
| | | * @param timeLimit The time limit for the search. |
| | | * @param typesOnly The typesOnly flag for the search. |
| | | * @param filterString The string representation of the filter for |
| | | * the search. |
| | | * @param attributes The set of requested attributes for the |
| | | * search. |
| | | * |
| | | * @return A reference to the internal search operation that was |
| | | * processed and contains information about the result of |
| | | * the processing as well as lists of the matching entries |
| | | * and search references. |
| | | * |
| | | * @throws DirectoryException If the provided filter string cannot |
| | | * be decoded as a search filter. |
| | | */ |
| | | public InternalSearchOperation |
| | | processSearch(String rawBaseDN, SearchScope scope, |
| | | DereferenceAliasesPolicy derefPolicy, |
| | | int sizeLimit, int timeLimit, |
| | | boolean typesOnly, String filterString, |
| | | Set<String> attributes) |
| | | throws DirectoryException |
| | | { |
| | | return processSearch(rawBaseDN, scope, derefPolicy, sizeLimit, |
| | | timeLimit, typesOnly, filterString, |
| | | attributes, null, null); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Processes an internal search operation with the provided |
| | | * information. |
| | | * |
| | | * @param rawBaseDN The base DN for the search. |
| | | * @param scope The scope for the search. |
| | | * @param derefPolicy The alias dereferencing policy for the |
| | | * search. |
| | | * @param sizeLimit The size limit for the search. |
| | | * @param timeLimit The time limit for the search. |
| | | * @param typesOnly The typesOnly flag for the search. |
| | | * @param filterString The string representation of the filter |
| | | * for the search. |
| | | * @param attributes The set of requested attributes for the |
| | | * search. |
| | | * @param searchListener The internal search listener that should |
| | | * be used to handle the matching entries |
| | | * and references. |
| | | * |
| | | * @return A reference to the internal search operation that was |
| | | * processed and contains information about the result of |
| | | * the processing as well as lists of the matching entries |
| | | * and search references. |
| | | * |
| | | * @throws DirectoryException If the provided filter string cannot |
| | | * be decoded as a search filter. |
| | | */ |
| | | public InternalSearchOperation |
| | | processSearch(String rawBaseDN, SearchScope scope, |
| | | DereferenceAliasesPolicy derefPolicy, |
| | | int sizeLimit, int timeLimit, |
| | | boolean typesOnly, String filterString, |
| | | Set<String> attributes, |
| | | InternalSearchListener searchListener) |
| | | throws DirectoryException |
| | | { |
| | | return processSearch(rawBaseDN, scope, derefPolicy, sizeLimit, |
| | | timeLimit, typesOnly, filterString, |
| | | attributes, null, searchListener); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Processes an internal search operation with the provided |
| | | * information. |
| | | * |
| | | * @param rawBaseDN The base DN for the search. |
| | | * @param scope The scope for the search. |
| | | * @param derefPolicy The alias dereferencing policy for the |
| | | * search. |
| | | * @param sizeLimit The size limit for the search. |
| | | * @param timeLimit The time limit for the search. |
| | | * @param typesOnly The typesOnly flag for the search. |
| | | * @param filterString The string representation of the filter |
| | | * for the search. |
| | | * @param attributes The set of requested attributes for the |
| | | * search. |
| | | * @param controls The set of controls to include in the |
| | | * request. |
| | | * @param searchListener The internal search listener that should |
| | | * be used to handle the matching entries |
| | | * and references. |
| | | * |
| | | * @return A reference to the internal search operation that was |
| | | * processed and contains information about the result of |
| | | * the processing as well as lists of the matching entries |
| | | * and search references. |
| | | * |
| | | * @throws DirectoryException If the provided filter string cannot |
| | | * be decoded as a search filter. |
| | | */ |
| | | public InternalSearchOperation |
| | | processSearch(String rawBaseDN, SearchScope scope, |
| | | DereferenceAliasesPolicy derefPolicy, |
| | | int sizeLimit, int timeLimit, |
| | | boolean typesOnly, String filterString, |
| | | Set<String> attributes, |
| | | List<Control> controls, |
| | | InternalSearchListener searchListener) |
| | | throws DirectoryException |
| | | { |
| | | RawFilter rawFilter; |
| | | try |
| | | { |
| | | rawFilter = RawFilter.create(filterString); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | throw new DirectoryException( |
| | | ResultCode.valueOf(le.getResultCode()), |
| | | le.getErrorMessage(), le); |
| | | } |
| | | |
| | | return processSearch(ByteString.valueOf(rawBaseDN), scope, |
| | | derefPolicy, sizeLimit, timeLimit, typesOnly, |
| | | rawFilter, attributes, controls, |
| | | searchListener); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Processes an internal search operation with the provided |
| | | * information. It will not dereference any aliases, will not |
| | | * request a size or time limit, and will retrieve all user |
| | | * attributes. |
| | | * |
| | | * @param rawBaseDN The base DN for the search. |
| | | * @param scope The scope for the search. |
| | | * @param filter The filter for the search. |
| | | * |
| | | * @return A reference to the internal search operation that was |
| | | * processed and contains information about the result of |
| | | * the processing as well as lists of the matching entries |
| | | * and search references. |
| | | */ |
| | | public InternalSearchOperation processSearch(ByteString rawBaseDN, |
| | | SearchScope scope, |
| | | RawFilter filter) |
| | | { |
| | | return processSearch(rawBaseDN, scope, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, |
| | | false, filter, new LinkedHashSet<String>(0)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Processes an internal search operation with the provided |
| | | * information. |
| | | * |
| | | * @param rawBaseDN The base DN for the search. |
| | | * @param scope The scope for the search. |
| | | * @param derefPolicy The alias dereferencing policy for the |
| | | * search. |
| | | * @param sizeLimit The size limit for the search. |
| | | * @param timeLimit The time limit for the search. |
| | | * @param typesOnly The typesOnly flag for the search. |
| | | * @param filter The filter for the search. |
| | | * @param attributes The set of requested attributes for the |
| | | * search. |
| | | * |
| | | * @return A reference to the internal search operation that was |
| | | * processed and contains information about the result of |
| | | * the processing as well as lists of the matching entries |
| | | * and search references. |
| | | */ |
| | | public InternalSearchOperation |
| | | processSearch(ByteString rawBaseDN, |
| | | SearchScope scope, |
| | | DereferenceAliasesPolicy derefPolicy, |
| | | int sizeLimit, int timeLimit, |
| | | boolean typesOnly, RawFilter filter, |
| | | Set<String> attributes) |
| | | { |
| | | return processSearch(rawBaseDN, scope, derefPolicy, sizeLimit, |
| | | timeLimit, typesOnly, filter, attributes, |
| | | null, null); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Processes an internal search operation with the provided |
| | | * information. |
| | | * |
| | | * @param rawBaseDN The base DN for the search. |
| | | * @param scope The scope for the search. |
| | | * @param derefPolicy The alias dereferencing policy for the |
| | | * search. |
| | | * @param sizeLimit The size limit for the search. |
| | | * @param timeLimit The time limit for the search. |
| | | * @param typesOnly The typesOnly flag for the search. |
| | | * @param filter The filter for the search. |
| | | * @param attributes The set of requested attributes for the |
| | | * search. |
| | | * @param searchListener The internal search listener that should |
| | | * be used to handle the matching entries |
| | | * and references. |
| | | * |
| | | * @return A reference to the internal search operation that was |
| | | * processed and contains information about the result of |
| | | * the processing. |
| | | */ |
| | | public InternalSearchOperation |
| | | processSearch(ByteString rawBaseDN, |
| | | SearchScope scope, |
| | | DereferenceAliasesPolicy derefPolicy, |
| | | int sizeLimit, int timeLimit, |
| | | boolean typesOnly, RawFilter filter, |
| | | Set<String> attributes, |
| | | InternalSearchListener searchListener) |
| | | { |
| | | return processSearch(rawBaseDN, scope, derefPolicy, sizeLimit, |
| | | timeLimit, typesOnly, filter, attributes, |
| | | null, searchListener); |
| | | return processSearch(Requests.newSearchRequest(rawBaseDN, scope, filterString), null); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | /** |
| | | * Processes an internal search operation with the provided |
| | | * information. It will not dereference any aliases, will not |
| | | * request a size or time limit, and will retrieve all user |
| | | * attributes. |
| | | * |
| | | * @param baseDN The base DN for the search. |
| | | * @param scope The scope for the search. |
| | | * @param filter The filter for the search. |
| | | * |
| | | * @return A reference to the internal search operation that was |
| | | * processed and contains information about the result of |
| | | * the processing as well as lists of the matching entries |
| | | * and search references. |
| | | */ |
| | | public InternalSearchOperation processSearch(DN baseDN, |
| | | SearchScope scope, |
| | | SearchFilter filter) |
| | | { |
| | | return processSearch(baseDN, scope, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, |
| | | false, filter, new LinkedHashSet<String>(0)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Processes an internal search operation with the provided |
| | | * information. |
| | | * |
| | | * @param baseDN The base DN for the search. |
| | | * @param scope The scope for the search. |
| | | * @param derefPolicy The alias dereferencing policy for the |
| | | * search. |
| | | * @param sizeLimit The size limit for the search. |
| | | * @param timeLimit The time limit for the search. |
| | | * @param typesOnly The typesOnly flag for the search. |
| | | * @param filter The filter for the search. |
| | | * @param attributes The set of requested attributes for the |
| | | * search. |
| | | * |
| | | * @return A reference to the internal search operation that was |
| | | * processed and contains information about the result of |
| | | * the processing as well as lists of the matching entries |
| | | * and search references. |
| | | */ |
| | | public InternalSearchOperation |
| | | processSearch(DN baseDN, SearchScope scope, |
| | | DereferenceAliasesPolicy derefPolicy, |
| | | int sizeLimit, int timeLimit, |
| | | boolean typesOnly, SearchFilter filter, |
| | | Set<String> attributes) |
| | | { |
| | | return processSearch(baseDN, scope, derefPolicy, sizeLimit, |
| | | timeLimit, typesOnly, filter, attributes, |
| | | null, null); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Processes an internal search operation with the provided |
| | | * information. |
| | | * |
| | | * @param baseDN The base DN for the search. |
| | | * @param scope The scope for the search. |
| | | * @param derefPolicy The alias dereferencing policy for the |
| | | * search. |
| | | * @param sizeLimit The size limit for the search. |
| | | * @param timeLimit The time limit for the search. |
| | | * @param typesOnly The typesOnly flag for the search. |
| | | * @param filter The filter for the search. |
| | | * @param attributes The set of requested attributes for the |
| | | * search. |
| | | * @param searchListener The internal search listener that should |
| | | * be used to handle the matching entries |
| | | * and references. |
| | | * |
| | | * @param request The search request. |
| | | * @return A reference to the internal search operation that was |
| | | * processed and contains information about the result of |
| | | * the processing. |
| | | */ |
| | | public InternalSearchOperation |
| | | processSearch(DN baseDN, SearchScope scope, |
| | | DereferenceAliasesPolicy derefPolicy, |
| | | int sizeLimit, int timeLimit, |
| | | boolean typesOnly, SearchFilter filter, |
| | | Set<String> attributes, |
| | | InternalSearchListener searchListener) |
| | | public InternalSearchOperation processSearch(final SearchRequest request) |
| | | { |
| | | return processSearch(baseDN, scope, derefPolicy, sizeLimit, |
| | | timeLimit, typesOnly, filter, attributes, |
| | | null, searchListener); |
| | | return processSearch(request, null); |
| | | } |
| | | |
| | | |
| | |
| | | * Processes an internal search operation with the provided |
| | | * information. |
| | | * |
| | | * @param baseDN The base DN for the search. |
| | | * @param scope The scope for the search. |
| | | * @param derefPolicy The alias dereferencing policy for the |
| | | * search. |
| | | * @param sizeLimit The size limit for the search. |
| | | * @param timeLimit The time limit for the search. |
| | | * @param typesOnly The typesOnly flag for the search. |
| | | * @param filter The filter for the search. |
| | | * @param attributes The set of requested attributes for the |
| | | * search. |
| | | * @param controls The set of controls to include in the |
| | | * request. |
| | | * @param request The search request. |
| | | * @param searchListener The internal search listener that should |
| | | * be used to handle the matching entries |
| | | * and references. |
| | | * |
| | | * @return A reference to the internal search operation that was |
| | | * processed and contains information about the result of |
| | | * the processing. |
| | | */ |
| | | public InternalSearchOperation |
| | | processSearch(DN baseDN, SearchScope scope, |
| | | DereferenceAliasesPolicy derefPolicy, |
| | | int sizeLimit, int timeLimit, |
| | | boolean typesOnly, SearchFilter filter, |
| | | Set<String> attributes, |
| | | List<Control> controls, |
| | | InternalSearchListener searchListener) |
| | | public InternalSearchOperation processSearch(final SearchRequest request, InternalSearchListener searchListener) |
| | | { |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation(this, nextOperationID(), |
| | | nextMessageID(), controls, |
| | | baseDN, scope, derefPolicy, |
| | | sizeLimit, timeLimit, |
| | | typesOnly, filter, attributes, |
| | | searchListener); |
| | | |
| | | new InternalSearchOperation(this, nextOperationID(), nextMessageID(), |
| | | request.getControls(), request.getName(), request.getScope(), |
| | | request.getDereferenceAliasesPolicy(), request.getSizeLimit(), |
| | | request.getTimeLimit(), request.isTypesOnly(), request.getFilter(), |
| | | request.getAttributes(), searchListener); |
| | | searchOperation.run(); |
| | | return searchOperation; |
| | | } |
| | |
| | | return 256; |
| | | } |
| | | } |
| | | |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt |
| | | * or http://forgerock.org/license/CDDLv1.0.html. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at legal-notices/CDDLv1_0.txt. |
| | | * If applicable, add the following below this CDDL HEADER, with the |
| | | * fields enclosed by brackets "[]" replaced with your own identifying |
| | | * information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2014 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.server.protocols.internal; |
| | | |
| | | import org.forgerock.i18n.LocalizedIllegalArgumentException; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.util.Reject; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.SearchFilter; |
| | | |
| | | /** |
| | | * This class contains various methods for creating and manipulating requests. |
| | | * <p> |
| | | * All copy constructors of the form {@code copyOfXXXRequest} perform deep |
| | | * copies of their request parameter. More specifically, any controls, |
| | | * modifications, and attributes contained within the response will be |
| | | * duplicated. |
| | | * <p> |
| | | * Similarly, all unmodifiable views of request returned by methods of the form |
| | | * {@code unmodifiableXXXRequest} return deep unmodifiable views of their |
| | | * request parameter. More specifically, any controls, modifications, and |
| | | * attributes contained within the returned request will be unmodifiable. |
| | | * |
| | | * @see org.forgerock.opendj.ldap.requests.Requests |
| | | */ |
| | | public final class Requests { |
| | | |
| | | // TODO: search request from LDAP URL. |
| | | |
| | | // TODO: update request from persistent search result. |
| | | |
| | | // TODO: synchronized requests? |
| | | |
| | | /** |
| | | * Creates a new search request using the provided distinguished name, |
| | | * scope, and filter. |
| | | * |
| | | * @param name |
| | | * The distinguished name of the base entry relative to which the |
| | | * search is to be performed. |
| | | * @param scope |
| | | * The scope of the search. |
| | | * @param filter |
| | | * The filter that defines the conditions that must be fulfilled |
| | | * in order for an entry to be returned. |
| | | * @param attributeDescriptions |
| | | * The names of the attributes to be included with each entry. |
| | | * @return The new search request. |
| | | * @throws NullPointerException |
| | | * If the {@code name}, {@code scope}, or {@code filter} were |
| | | * {@code null}. |
| | | */ |
| | | public static SearchRequest newSearchRequest(final DN name, final SearchScope scope, |
| | | final SearchFilter filter, final String... attributeDescriptions) |
| | | throws NullPointerException { |
| | | Reject.ifNull(name, scope, filter); |
| | | final SearchRequest request = new SearchRequest(name, scope, filter); |
| | | for (final String attributeDescription : attributeDescriptions) { |
| | | request.addAttribute(attributeDescription); |
| | | } |
| | | return request; |
| | | } |
| | | |
| | | /** |
| | | * Creates a new search request using the provided distinguished name, |
| | | * scope, and filter, decoded using the default schema. |
| | | * |
| | | * @param name |
| | | * The distinguished name of the base entry relative to which the |
| | | * search is to be performed. |
| | | * @param scope |
| | | * The scope of the search. |
| | | * @param filter |
| | | * The filter that defines the conditions that must be fulfilled |
| | | * in order for an entry to be returned. |
| | | * @param attributeDescriptions |
| | | * The names of the attributes to be included with each entry. |
| | | * @return The new search request. |
| | | * @throws DirectoryException |
| | | * If a problem occurs while decoding the provided string as a |
| | | * search filter. |
| | | * @throws LocalizedIllegalArgumentException |
| | | * If {@code name} could not be decoded using the default |
| | | * schema, or if {@code filter} is not a valid LDAP string |
| | | * representation of a filter. |
| | | * @throws NullPointerException |
| | | * If the {@code name}, {@code scope}, or {@code filter} were |
| | | * {@code null}. |
| | | */ |
| | | public static SearchRequest newSearchRequest(final String name, final SearchScope scope, |
| | | final String filter, final String... attributeDescriptions) |
| | | throws NullPointerException, LocalizedIllegalArgumentException, DirectoryException { |
| | | Reject.ifNull(name, scope, filter); |
| | | SearchFilter f = SearchFilter.createFilterFromString(filter); |
| | | final SearchRequest request = new SearchRequest(DN.valueOf(name), scope, f); |
| | | for (final String attributeDescription : attributeDescriptions) { |
| | | request.addAttribute(attributeDescription); |
| | | } |
| | | return request; |
| | | } |
| | | |
| | | /** |
| | | * Return a new search request object. |
| | | * |
| | | * @param name |
| | | * the dn |
| | | * @param scope |
| | | * the search scope |
| | | * @param filter |
| | | * the search filter |
| | | * @return a new search request object |
| | | * @throws DirectoryException |
| | | * if a problem occurs |
| | | * @see #newSearchRequest(DN, SearchScope, SearchFilter, String...) |
| | | */ |
| | | public static SearchRequest newSearchRequest(final String name, final SearchScope scope, final String filter) |
| | | throws DirectoryException { |
| | | return newSearchRequest(DN.valueOf(name), scope, SearchFilter.createFilterFromString(filter)); |
| | | } |
| | | |
| | | /** |
| | | * Return a new search request object. |
| | | * |
| | | * @param name |
| | | * the dn |
| | | * @param scope |
| | | * the search scope |
| | | * @param filter |
| | | * the search filter |
| | | * @return a new search request object |
| | | * @throws DirectoryException |
| | | * if a problem occurs |
| | | * @see #newSearchRequest(DN, SearchScope, SearchFilter, String...) |
| | | */ |
| | | public static SearchRequest newSearchRequest(final DN name, final SearchScope scope, final String filter) |
| | | throws DirectoryException { |
| | | return newSearchRequest(name, scope, SearchFilter.createFilterFromString(filter)); |
| | | } |
| | | |
| | | private Requests() { |
| | | // Prevent instantiation. |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt |
| | | * or http://forgerock.org/license/CDDLv1.0.html. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at legal-notices/CDDLv1_0.txt. |
| | | * If applicable, add the following below this CDDL HEADER, with the |
| | | * fields enclosed by brackets "[]" replaced with your own identifying |
| | | * information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2014 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.protocols.internal; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.util.Reject; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.SearchFilter; |
| | | |
| | | /** |
| | | * Search request implementation. |
| | | * |
| | | * @see org.forgerock.opendj.ldap.requests.SearchRequestImpl |
| | | */ |
| | | public final class SearchRequest extends AbstractRequestImpl { |
| | | /** |
| | | * Use a LinkedHashSet to return the attributes in the same order as requested by the user |
| | | */ |
| | | private final Set<String> attributes = new LinkedHashSet<String>(); |
| | | private DereferenceAliasesPolicy dereferenceAliasesPolicy = DereferenceAliasesPolicy.NEVER; |
| | | private SearchFilter filter; |
| | | private DN name; |
| | | private SearchScope scope; |
| | | private int sizeLimit; |
| | | private int timeLimit; |
| | | private boolean typesOnly; |
| | | |
| | | /** |
| | | * To be removed. |
| | | * |
| | | * @param name |
| | | * the dn |
| | | * @param scope |
| | | * the search scope |
| | | * @param filter |
| | | * the search filter |
| | | */ |
| | | SearchRequest(final DN name, final SearchScope scope, final SearchFilter filter) { |
| | | this.name = name; |
| | | this.scope = scope; |
| | | this.filter = filter; |
| | | } |
| | | |
| | | /** |
| | | * To be removed. |
| | | * |
| | | * @param attributeDescriptions |
| | | * the attribute descriptions |
| | | * @return the current object |
| | | * @see org.forgerock.opendj.ldap.requests.SearchRequestImpl#addAttribute(String...) |
| | | */ |
| | | public SearchRequest addAttribute(final String... attributeDescriptions) { |
| | | for (final String attributeDescription : attributeDescriptions) { |
| | | attributes.add(Reject.checkNotNull(attributeDescription)); |
| | | } |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * To be added to {@link org.forgerock.opendj.ldap.requests.SearchRequestImpl}? |
| | | * |
| | | * @param attributeDescriptions |
| | | * the attribute descriptions |
| | | * @return the current object |
| | | */ |
| | | public SearchRequest addAttribute(final Collection<String> attributeDescriptions) { |
| | | for (final String attributeDescription : attributeDescriptions) { |
| | | attributes.add(Reject.checkNotNull(attributeDescription)); |
| | | } |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * To be removed. |
| | | * |
| | | * @return the attributes |
| | | * @see org.forgerock.opendj.ldap.requests.SearchRequestImpl#getAttributes() |
| | | */ |
| | | public Set<String> getAttributes() { |
| | | return attributes; |
| | | } |
| | | |
| | | /** |
| | | * To be removed. |
| | | * |
| | | * @return the dereference aliases policy |
| | | * @see org.forgerock.opendj.ldap.requests.SearchRequestImpl#getDereferenceAliasesPolicy() |
| | | */ |
| | | public DereferenceAliasesPolicy getDereferenceAliasesPolicy() { |
| | | return dereferenceAliasesPolicy; |
| | | } |
| | | |
| | | /** |
| | | * To be removed. |
| | | * |
| | | * @return the search filter |
| | | * @see org.forgerock.opendj.ldap.requests.SearchRequestImpl#getFilter() |
| | | */ |
| | | public SearchFilter getFilter() { |
| | | return filter; |
| | | } |
| | | |
| | | /** |
| | | * To be removed. |
| | | * |
| | | * @return the DN |
| | | * @see org.forgerock.opendj.ldap.requests.SearchRequestImpl#getName() |
| | | */ |
| | | public DN getName() { |
| | | return name; |
| | | } |
| | | |
| | | /** |
| | | * To be removed. |
| | | * |
| | | * @return the search scope |
| | | * @see org.forgerock.opendj.ldap.requests.SearchRequestImpl#getScope() |
| | | */ |
| | | public SearchScope getScope() { |
| | | return scope; |
| | | } |
| | | |
| | | /** |
| | | * To be removed. |
| | | * |
| | | * @return the size limit |
| | | * @see org.forgerock.opendj.ldap.requests.SearchRequestImpl#getSizeLimit() |
| | | */ |
| | | public int getSizeLimit() { |
| | | return sizeLimit; |
| | | } |
| | | |
| | | /** |
| | | * To be removed. |
| | | * |
| | | * @return is single entry search |
| | | * @see org.forgerock.opendj.ldap.requests.SearchRequestImpl#isSingleEntrySearch() |
| | | */ |
| | | public boolean isSingleEntrySearch() { |
| | | return sizeLimit == 1 || SearchScope.BASE_OBJECT.equals(scope); |
| | | } |
| | | |
| | | /** |
| | | * To be removed. |
| | | * |
| | | * @return the time limit |
| | | * @see org.forgerock.opendj.ldap.requests.SearchRequestImpl#getTimeLimit() |
| | | */ |
| | | public int getTimeLimit() { |
| | | return timeLimit; |
| | | } |
| | | |
| | | /** |
| | | * To be removed. |
| | | * |
| | | * @return the types only |
| | | * @see org.forgerock.opendj.ldap.requests.SearchRequestImpl#isTypesOnly() |
| | | */ |
| | | public boolean isTypesOnly() { |
| | | return typesOnly; |
| | | } |
| | | |
| | | /** |
| | | * To be removed. |
| | | * |
| | | * @param policy the dereference aliases policy |
| | | * @return the current request |
| | | * @see org.forgerock.opendj.ldap.requests.SearchRequestImpl#setDereferenceAliasesPolicy(DereferenceAliasesPolicy) |
| | | */ |
| | | public SearchRequest setDereferenceAliasesPolicy(final DereferenceAliasesPolicy policy) { |
| | | Reject.ifNull(policy); |
| | | |
| | | this.dereferenceAliasesPolicy = policy; |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * To be removed. |
| | | * |
| | | * @param filter the search filter |
| | | * @return the current request |
| | | * @see org.forgerock.opendj.ldap.requests.SearchRequestImpl#setFilter(org.forgerock.opendj.ldap.Filter) |
| | | */ |
| | | public SearchRequest setFilter(final SearchFilter filter) { |
| | | Reject.ifNull(filter); |
| | | |
| | | this.filter = filter; |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * To be removed. |
| | | * |
| | | * @param filter the search filter |
| | | * @return the current request |
| | | * @throws DirectoryException if problem occurs |
| | | * @see org.forgerock.opendj.ldap.requests.SearchRequestImpl#setFilter(String) |
| | | */ |
| | | public SearchRequest setFilter(final String filter) throws DirectoryException { |
| | | this.filter = SearchFilter.createFilterFromString(filter); |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * To be removed. |
| | | * |
| | | * @param dn the dn |
| | | * @return the current request |
| | | * @see org.forgerock.opendj.ldap.requests.SearchRequestImpl#setName(org.forgerock.opendj.ldap.DN) |
| | | */ |
| | | public SearchRequest setName(final DN dn) { |
| | | Reject.ifNull(dn); |
| | | |
| | | this.name = dn; |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * To be removed. |
| | | * |
| | | * @param dn the dn |
| | | * @return the current request |
| | | * @throws DirectoryException if problem occurs |
| | | * @see org.forgerock.opendj.ldap.requests.SearchRequestImpl#setName(String) |
| | | */ |
| | | public SearchRequest setName(final String dn) throws DirectoryException { |
| | | Reject.ifNull(dn); |
| | | |
| | | this.name = DN.valueOf(dn); |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * To be removed. |
| | | * |
| | | * @param scope the search scope |
| | | * @return the current request |
| | | * @see org.forgerock.opendj.ldap.requests.SearchRequestImpl#setScope(SearchScope) |
| | | */ |
| | | public SearchRequest setScope(final SearchScope scope) { |
| | | Reject.ifNull(scope); |
| | | |
| | | this.scope = scope; |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * To be removed. |
| | | * |
| | | * @param limit the size limit |
| | | * @return the current request |
| | | * @see org.forgerock.opendj.ldap.requests.SearchRequestImpl#setSizeLimit(int) |
| | | */ |
| | | public SearchRequest setSizeLimit(final int limit) { |
| | | Reject.ifFalse(limit >= 0, "negative size limit"); |
| | | |
| | | this.sizeLimit = limit; |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * To be removed. |
| | | * |
| | | * @param limit the time limit |
| | | * @return the current request |
| | | * @see org.forgerock.opendj.ldap.requests.SearchRequestImpl#setTimeLimit(int) |
| | | */ |
| | | public SearchRequest setTimeLimit(final int limit) { |
| | | Reject.ifFalse(limit >= 0, "negative time limit"); |
| | | |
| | | this.timeLimit = limit; |
| | | return this; |
| | | } |
| | | |
| | | /** |
| | | * To be removed. |
| | | * |
| | | * @param typesOnly the types only |
| | | * @return the current request |
| | | * @see org.forgerock.opendj.ldap.requests.SearchRequestImpl#setTypesOnly(boolean) |
| | | */ |
| | | public SearchRequest setTypesOnly(final boolean typesOnly) { |
| | | this.typesOnly = typesOnly; |
| | | return this; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public SearchRequest addControl(Control control) { |
| | | super.addControl(control); |
| | | return this; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public SearchRequest addControl(Collection<Control> controls) { |
| | | super.addControl(controls); |
| | | return this; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder builder = new StringBuilder(); |
| | | builder.append("SearchRequest(name="); |
| | | builder.append(getName()); |
| | | builder.append(", scope="); |
| | | builder.append(getScope()); |
| | | builder.append(", dereferenceAliasesPolicy="); |
| | | builder.append(getDereferenceAliasesPolicy()); |
| | | builder.append(", sizeLimit="); |
| | | builder.append(getSizeLimit()); |
| | | builder.append(", timeLimit="); |
| | | builder.append(getTimeLimit()); |
| | | builder.append(", typesOnly="); |
| | | builder.append(isTypesOnly()); |
| | | builder.append(", filter="); |
| | | builder.append(getFilter()); |
| | | builder.append(", attributes="); |
| | | builder.append(getAttributes()); |
| | | builder.append(", controls="); |
| | | builder.append(getControls()); |
| | | builder.append(")"); |
| | | return builder.toString(); |
| | | } |
| | | |
| | | } |
| | |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchListener; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.Requests; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.protocols.ldap.LDAPAttribute; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | |
| | | import static org.opends.messages.ReplicationMessages.*; |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.replication.plugin.EntryHistorical.*; |
| | | import static org.opends.server.replication.protocol.OperationContext.*; |
| | | import static org.opends.server.replication.service.ReplicationMonitor.*; |
| | |
| | | + "entry " + getBaseDNString()); |
| | | } |
| | | |
| | | LDAPFilter filter; |
| | | InternalSearchOperation search; |
| | | try |
| | | { |
| | | filter = LDAPFilter.decode("(objectclass=*)"); |
| | | } catch (LDAPException e) |
| | | // Search the domain root entry that is used to save the generation id |
| | | SearchRequest request = newSearchRequest(getBaseDN(), SearchScope.BASE_OBJECT, "(objectclass=*)") |
| | | .addAttribute(REPLICATION_GENERATION_ID, REPLICATION_FRACTIONAL_EXCLUDE, REPLICATION_FRACTIONAL_INCLUDE); |
| | | search = conn.processSearch(request); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | // Can not happen |
| | | return false; |
| | | } |
| | | |
| | | // Search the domain root entry that is used to save the generation id |
| | | final ByteString asn1BaseDn = ByteString.valueOf(getBaseDNString()); |
| | | final Set<String> attributes = newSet( |
| | | REPLICATION_GENERATION_ID, |
| | | REPLICATION_FRACTIONAL_EXCLUDE, |
| | | REPLICATION_FRACTIONAL_INCLUDE); |
| | | InternalSearchOperation search = conn.processSearch(asn1BaseDn, |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.ALWAYS, 0, 0, false, |
| | | filter, attributes); |
| | | if (search.getResultCode() != ResultCode.SUCCESS |
| | | && search.getResultCode() != ResultCode.NO_SUCH_OBJECT) |
| | | { |
| | |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | 0, 0, false, filter, |
| | | USER_AND_REPL_OPERATIONAL_ATTRS, null); |
| | | USER_AND_REPL_OPERATIONAL_ATTRS, null, null); |
| | | |
| | | Entry entryToRename = null; |
| | | CSN entryToRenameCSN = null; |
| | |
| | | } |
| | | try |
| | | { |
| | | final Set<String> attrs = newSet(ENTRYUUID_ATTRIBUTE_NAME); |
| | | |
| | | final InternalSearchOperation search = getRootConnection().processSearch( |
| | | dn, SearchScope.BASE_OBJECT, DereferenceAliasesPolicy.NEVER, |
| | | 0, 0, false, |
| | | SearchFilter.createFilterFromString("(objectclass=*)"), |
| | | attrs); |
| | | final SearchRequest request = newSearchRequest(dn, SearchScope.BASE_OBJECT, "(objectclass=*)") |
| | | .addAttribute(ENTRYUUID_ATTRIBUTE_NAME); |
| | | final InternalSearchOperation search = getRootConnection().processSearch(request); |
| | | final SearchResultEntry resultEntry = getFirstResult(search); |
| | | if (resultEntry != null) |
| | | { |
| | |
| | | { |
| | | try |
| | | { |
| | | InternalSearchOperation search = conn.processSearch(getBaseDN(), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | SearchFilter.createFilterFromString("entryuuid="+uuid)); |
| | | final SearchRequest request = newSearchRequest(getBaseDN(), SearchScope.WHOLE_SUBTREE, "entryuuid=" + uuid); |
| | | InternalSearchOperation search = conn.processSearch(request); |
| | | final SearchResultEntry resultEntry = getFirstResult(search); |
| | | if (resultEntry != null) |
| | | { |
| | |
| | | // Find an rename child entries. |
| | | try |
| | | { |
| | | final Set<String> attrs = |
| | | newSet(ENTRYUUID_ATTRIBUTE_NAME, HISTORICAL_ATTRIBUTE_NAME); |
| | | |
| | | InternalSearchOperation op = |
| | | conn.processSearch(entryDN, SearchScope.SINGLE_LEVEL, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.createFilterFromString("(objectClass=*)"), |
| | | attrs); |
| | | |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.SINGLE_LEVEL, "(objectClass=*)") |
| | | .addAttribute(ENTRYUUID_ATTRIBUTE_NAME, HISTORICAL_ATTRIBUTE_NAME); |
| | | InternalSearchOperation op = conn.processSearch(request); |
| | | if (op.getResultCode() == ResultCode.SUCCESS) |
| | | { |
| | | for (SearchResultEntry entry : op.getSearchEntries()) |
| | |
| | | * Search the database entry that is used to periodically |
| | | * save the generation id |
| | | */ |
| | | final Set<String> attributes = newSet(REPLICATION_GENERATION_ID); |
| | | final String filter = "(objectclass=*)"; |
| | | InternalSearchOperation search = conn.processSearch(getBaseDNString(), |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.ALWAYS, 0, 0, false, |
| | | filter,attributes); |
| | | final SearchRequest request = newSearchRequest(getBaseDN(), SearchScope.BASE_OBJECT, "(objectclass=*)") |
| | | .addAttribute(REPLICATION_GENERATION_ID); |
| | | InternalSearchOperation search = conn.processSearch(request); |
| | | if (search.getResultCode() == ResultCode.NO_SUCH_OBJECT) |
| | | { |
| | | // if the base entry does not exist look for the generationID |
| | | // in the config entry. |
| | | search = conn.processSearch(config.dn().toString(), |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.ALWAYS, 0, 0, false, |
| | | filter,attributes); |
| | | request.setName(config.dn()); |
| | | search = conn.processSearch(request); |
| | | } |
| | | |
| | | boolean found = false; |
| | |
| | | maxValueForId = lastCSN.toString(); |
| | | } |
| | | |
| | | LDAPFilter filter = LDAPFilter.decode( |
| | | String filter = |
| | | "(&(" + HISTORICAL_ATTRIBUTE_NAME + ">=dummy:" + fromCSN + ")" + |
| | | "(" + HISTORICAL_ATTRIBUTE_NAME + "<=dummy:" + maxValueForId + "))"); |
| | | |
| | | return getRootConnection().processSearch( |
| | | ByteString.valueOf(baseDN.toString()), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | 0, 0, false, filter, |
| | | USER_AND_REPL_OPERATIONAL_ATTRS, |
| | | resultListener); |
| | | "(" + HISTORICAL_ATTRIBUTE_NAME + "<=dummy:" + maxValueForId + "))"; |
| | | SearchRequest request = Requests.newSearchRequest(baseDN, SearchScope.WHOLE_SUBTREE, filter) |
| | | .addAttribute(USER_AND_REPL_OPERATIONAL_ATTRS); |
| | | return getRootConnection().processSearch(request, resultListener); |
| | | } |
| | | |
| | | /** |
| | |
| | | + "lastCSNPurgedFromHist: " |
| | | + lastCSNPurgedFromHist.toStringUI()); |
| | | |
| | | LDAPFilter filter = null; |
| | | try |
| | | { |
| | | filter = LDAPFilter.decode( |
| | | "(" + EntryHistorical.HISTORICAL_ATTRIBUTE_NAME + ">=dummy:" |
| | | + lastCSNPurgedFromHist + ")"); |
| | | |
| | | } catch (LDAPException e) |
| | | { |
| | | // Not possible. We know the filter just above is correct. |
| | | } |
| | | |
| | | InternalSearchOperation searchOp = conn.processSearch( |
| | | ByteString.valueOf(getBaseDNString()), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | 0, 0, false, filter, |
| | | USER_AND_REPL_OPERATIONAL_ATTRS, null); |
| | | String filter = "(" + HISTORICAL_ATTRIBUTE_NAME + ">=dummy:" + lastCSNPurgedFromHist + ")"; |
| | | SearchRequest request = Requests.newSearchRequest(getBaseDN(), SearchScope.WHOLE_SUBTREE, filter) |
| | | .addAttribute(USER_AND_REPL_OPERATIONAL_ATTRS); |
| | | InternalSearchOperation searchOp = conn.processSearch(request); |
| | | |
| | | int count = 0; |
| | | if (task != null) |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyOperationBasis; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.protocols.ldap.LDAPAttribute; |
| | | import org.opends.server.protocols.ldap.LDAPModification; |
| | | import org.opends.server.replication.common.CSN; |
| | |
| | | { |
| | | try |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("objectclass=*"); |
| | | final SearchRequest request = |
| | | newSearchRequest(baseDN, SearchScope.BASE_OBJECT, "objectclass=*").addAttribute(REPLICATION_STATE); |
| | | /* |
| | | * Search the database entry that is used to periodically |
| | | * save the ServerState |
| | | */ |
| | | final InternalSearchOperation search = getRootConnection().processSearch( |
| | | baseDN, SearchScope.BASE_OBJECT, DereferenceAliasesPolicy.NEVER, |
| | | 0, 0, false, filter, Collections.singleton(REPLICATION_STATE)); |
| | | final InternalSearchOperation search = getRootConnection().processSearch(request); |
| | | final ResultCode resultCode = search.getResultCode(); |
| | | if (resultCode != ResultCode.SUCCESS |
| | | && resultCode != ResultCode.NO_SUCH_OBJECT) |
| | |
| | | { |
| | | try |
| | | { |
| | | SearchFilter filter = SearchFilter.createFilterFromString( |
| | | "(&(objectclass=ds-cfg-replication-domain)" |
| | | + "(ds-cfg-base-dn=" + baseDN + "))"); |
| | | |
| | | final InternalSearchOperation op = getRootConnection().processSearch( |
| | | DN.valueOf("cn=config"), |
| | | SearchScope.SUBORDINATES, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | 1, 0, false, filter, Collections.singleton(REPLICATION_STATE)); |
| | | String filter = "(&(objectclass=ds-cfg-replication-domain)" + "(ds-cfg-base-dn=" + baseDN + "))"; |
| | | final SearchRequest request = newSearchRequest("cn=config", SearchScope.SUBORDINATES, filter) |
| | | .setSizeLimit(1) |
| | | .addAttribute(REPLICATION_STATE); |
| | | final InternalSearchOperation op = getRootConnection().processSearch(request); |
| | | return getFirstResult(op); |
| | | } |
| | | catch (DirectoryException e) |
| | |
| | | import org.assertj.core.api.Assertions; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | |
| | | import org.opends.server.core.ModifyDNOperationBasis; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchListener; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.Requests; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | | import org.opends.server.replication.common.CSN; |
| | | import org.opends.server.replication.common.CSNGenerator; |
| | |
| | | /** The port of the replicationServer. */ |
| | | private int replicationServerPort; |
| | | |
| | | /** |
| | | * When used in a search operation, it includes all attributes (user and |
| | | * operational) |
| | | */ |
| | | private static final Set<String> ALL_ATTRIBUTES = newSet("*", "+"); |
| | | private static final List<Control> NO_CONTROL = null; |
| | | |
| | | @BeforeClass |
| | | @Override |
| | | public void setUp() throws Exception |
| | |
| | | throws Exception |
| | | { |
| | | debugInfo(testName, "Search with cookie=[" + cookie + "] filter=[" + filterString + "]"); |
| | | return searchChangelog(filterString, ALL_ATTRIBUTES, createCookieControl(cookie), |
| | | expectedNbEntries, expectedResultCode, testName); |
| | | SearchRequest request = newSearchRequest(filterString).addControl(createCookieControl(cookie)); |
| | | return searchChangelog(request, expectedNbEntries, expectedResultCode, testName); |
| | | } |
| | | |
| | | private InternalSearchOperation searchChangelog(String filterString, int expectedNbEntries, |
| | | ResultCode expectedResultCode, String testName) throws Exception |
| | | { |
| | | return searchChangelog(filterString, ALL_ATTRIBUTES, NO_CONTROL, expectedNbEntries, expectedResultCode, testName); |
| | | SearchRequest request = newSearchRequest(filterString); |
| | | return searchChangelog(request, expectedNbEntries, expectedResultCode, testName); |
| | | } |
| | | |
| | | private InternalSearchOperation searchChangelog(String filterString, Set<String> attributes, |
| | | List<Control> controls, int expectedNbEntries, ResultCode expectedResultCode, String testName) throws Exception |
| | | private SearchRequest newSearchRequest(String filterString) throws DirectoryException |
| | | { |
| | | InternalSearchOperation searchOperation = null; |
| | | int sizeLimitZero = 0; |
| | | int timeLimitZero = 0; |
| | | InternalSearchListener noSearchListener = null; |
| | | return Requests.newSearchRequest("cn=changelog", SearchScope.WHOLE_SUBTREE, filterString) |
| | | .addAttribute("*", "+"); // all user and operational attributes |
| | | } |
| | | |
| | | private InternalSearchOperation searchChangelog(SearchRequest request, int expectedNbEntries, |
| | | ResultCode expectedResultCode, String testName) throws Exception |
| | | { |
| | | InternalSearchOperation searchOp = null; |
| | | int count = 0; |
| | | do |
| | | { |
| | | Thread.sleep(10); |
| | | boolean typesOnlyFalse = false; |
| | | searchOperation = connection.processSearch("cn=changelog", SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, sizeLimitZero, timeLimitZero, typesOnlyFalse, filterString, |
| | | attributes, controls, noSearchListener); |
| | | searchOp = connection.processSearch(request); |
| | | count++; |
| | | } |
| | | while (count < 300 && searchOperation.getSearchEntries().size() != expectedNbEntries); |
| | | while (count < 300 && searchOp.getSearchEntries().size() != expectedNbEntries); |
| | | |
| | | final List<SearchResultEntry> entries = searchOperation.getSearchEntries(); |
| | | final List<SearchResultEntry> entries = searchOp.getSearchEntries(); |
| | | assertThat(entries).hasSize(expectedNbEntries); |
| | | debugAndWriteEntries(getLDIFWriter(), entries, testName); |
| | | waitForSearchOpResult(searchOperation, expectedResultCode); |
| | | return searchOperation; |
| | | waitForSearchOpResult(searchOp, expectedResultCode); |
| | | return searchOp; |
| | | } |
| | | |
| | | private InternalSearchOperation searchDNWithBaseScope(String dn, Set<String> attributes) throws Exception |
| | | { |
| | | final InternalSearchOperation searchOp = connection.processSearch( |
| | | dn, |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | 0, // Size limit |
| | | 0, // Time limit |
| | | false, // Types only |
| | | "(objectclass=*)", |
| | | attributes); |
| | | SearchRequest request = Requests.newSearchRequest(dn, SearchScope.BASE_OBJECT, "(objectclass=*)") |
| | | .addAttribute(attributes); |
| | | final InternalSearchOperation searchOp = connection.processSearch(request); |
| | | waitForSearchOpResult(searchOp, ResultCode.SUCCESS); |
| | | return searchOp; |
| | | } |
| | |
| | | import org.opends.server.core.*; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.types.*; |
| | | import org.testng.annotations.BeforeClass; |
| | |
| | | { |
| | | DN schemaDN = DN.valueOf("cn=schema"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | DeleteOperationBasis deleteOperation = |
| | | new DeleteOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | null, schemaDN); |
| | |
| | | DN currentSchemaDN = DN.valueOf("cn=schema"); |
| | | DN newSchemaDN = DN.valueOf("cn=newschema"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | ModifyDNOperationBasis modifyDNOperation = |
| | | new ModifyDNOperationBasis(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), null, |
| | |
| | | { |
| | | String filterString = "(|(objectClass=*)(objectClass=ldapSubentry))"; |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(DN.valueOf("cn=schema"), SearchScope.BASE_OBJECT, |
| | | SearchFilter.createFilterFromString(filterString)); |
| | | final SearchRequest request = newSearchRequest("cn=schema", SearchScope.BASE_OBJECT, filterString); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertNotNull(searchOperation); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertFalse(searchOperation.getSearchEntries().isEmpty()); |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testSimpleOneLevelSearch() |
| | | throws Exception |
| | | public void testSimpleOneLevelSearch() throws Exception |
| | | { |
| | | String filterString = "(|(objectClass=*)(objectClass=ldapSubentry))"; |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(DN.valueOf("cn=schema"), SearchScope.SINGLE_LEVEL, |
| | | SearchFilter.createFilterFromString(filterString)); |
| | | final SearchRequest request = newSearchRequest("cn=schema", SearchScope.SINGLE_LEVEL, filterString); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertNotNull(searchOperation); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertTrue(searchOperation.getSearchEntries().isEmpty()); |
| | |
| | | { |
| | | String filterString = "(|(objectClass=*)(objectClass=ldapSubentry))"; |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(DN.valueOf("cn=schema"), SearchScope.WHOLE_SUBTREE, |
| | | SearchFilter.createFilterFromString(filterString)); |
| | | final SearchRequest request = newSearchRequest("cn=schema", SearchScope.WHOLE_SUBTREE, filterString); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertNotNull(searchOperation); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertFalse(searchOperation.getSearchEntries().isEmpty()); |
| | |
| | | { |
| | | String filterString = "(|(objectClass=*)(objectClass=ldapSubentry))"; |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(DN.valueOf("cn=schema"), |
| | | SearchScope.SUBORDINATES, |
| | | SearchFilter.createFilterFromString(filterString)); |
| | | final SearchRequest request = newSearchRequest("cn=schema", SearchScope.SUBORDINATES, filterString); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertNotNull(searchOperation); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertTrue(searchOperation.getSearchEntries().isEmpty()); |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testSearchMatchedDN() |
| | | throws Exception |
| | | public void testSearchMatchedDN() throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | DN baseDN = DN.valueOf("o=bogus,cn=schema"); |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | |
| | | for (SearchScope scope : SearchScope.values()) |
| | | { |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(baseDN, scope, filter); |
| | | final SearchRequest request = newSearchRequest(baseDN, scope, filter); |
| | | InternalSearchOperation searchOperation = conn.processSearch(request); |
| | | assertNotNull(searchOperation.getMatchedDN(), |
| | | "No matched DN for scope " + scope); |
| | | } |
| | |
| | | import org.opends.server.core.ModifyOperationBasis; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.Attributes; |
| | |
| | | import static org.forgerock.opendj.ldap.ConditionResult.*; |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.mockito.Mockito.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.types.Attributes.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | |
| | | @Test(dependsOnMethods = "testAdd") |
| | | public void testSearchScope() throws Exception { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | |
| | | InternalSearchOperation search = |
| | | conn.processSearch(DN.valueOf("dc=test,dc=com"), SearchScope.BASE_OBJECT, |
| | | LDAPFilter.decode("(objectClass=*)").toSearchFilter()); |
| | | InternalSearchOperation search = conn.processSearch("dc=test,dc=com", SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | List<SearchResultEntry> result = search.getSearchEntries(); |
| | | |
| | | assertEquals(result.size(), 1); |
| | | assertEquals(result.get(0).getName().toString(), "dc=test,dc=com"); |
| | | |
| | | search = conn.processSearch(DN.valueOf("dc=test,dc=com"), |
| | | SearchScope.BASE_OBJECT, LDAPFilter.decode("(ou=People)").toSearchFilter()); |
| | | search = conn.processSearch("dc=test,dc=com", SearchScope.BASE_OBJECT, "(ou=People)"); |
| | | result = search.getSearchEntries(); |
| | | |
| | | assertEquals(result.size(), 0); |
| | | |
| | | search = conn.processSearch(DN.valueOf("dc=test,dc=com"), |
| | | SearchScope.SINGLE_LEVEL, |
| | | LDAPFilter.decode("(objectClass=*)").toSearchFilter()); |
| | | search = conn.processSearch("dc=test,dc=com", SearchScope.SINGLE_LEVEL, "(objectClass=*)"); |
| | | result = search.getSearchEntries(); |
| | | |
| | | assertEquals(result.size(), 1); |
| | | assertEquals(result.get(0).getName().toString(), |
| | | "ou=People,dc=test,dc=com"); |
| | | |
| | | search = conn.processSearch(DN.valueOf("dc=test,dc=com"), |
| | | SearchScope.SUBORDINATES, |
| | | LDAPFilter.decode("(objectClass=*)").toSearchFilter()); |
| | | search = conn.processSearch("dc=test,dc=com", SearchScope.SUBORDINATES, "(objectClass=*)"); |
| | | result = search.getSearchEntries(); |
| | | |
| | | assertEquals(result.size(), 13); |
| | |
| | | assertThat(entry.getName().toString()).isNotEqualTo("dc=test,dc=com"); |
| | | } |
| | | |
| | | search = conn.processSearch(DN.valueOf("dc=test,dc=com"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | LDAPFilter.decode("(objectClass=*)").toSearchFilter()); |
| | | search = conn.processSearch("dc=test,dc=com", SearchScope.WHOLE_SUBTREE, "(objectClass=*)"); |
| | | result = search.getSearchEntries(); |
| | | |
| | | assertEquals(result.size(), 14); |
| | |
| | | private List<SearchResultEntry> doSubtreeSearch(InternalClientConnection conn, String filter, |
| | | Set<String> attribs) throws Exception |
| | | { |
| | | InternalSearchOperation search = |
| | | conn.processSearch(DN.valueOf("dc=test,dc=com"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | 0, |
| | | 0, |
| | | false, |
| | | LDAPFilter.decode(filter).toSearchFilter(), |
| | | attribs); |
| | | final SearchRequest request = |
| | | newSearchRequest("dc=test,dc=com", SearchScope.WHOLE_SUBTREE, filter).addAttribute(attribs); |
| | | InternalSearchOperation search = conn.processSearch(request); |
| | | return search.getSearchEntries(); |
| | | } |
| | | |
| | |
| | | assertFalse(orfound); |
| | | assertTrue(apfound); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | Set<String> attribs = new LinkedHashSet<String>(); |
| | | attribs.add(ATTR_DEBUG_SEARCH_INDEX); |
| | | |
| | | InternalSearchOperation search = |
| | | conn.processSearch(DN.valueOf("dc=test,dc=com"), |
| | | SearchScope.SUBORDINATES, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | 0, |
| | | 0, |
| | | false, |
| | | LDAPFilter.decode("(givenName~=Aaccf)").toSearchFilter(), |
| | | attribs); |
| | | final SearchRequest request = newSearchRequest("dc=test,dc=com", SearchScope.SUBORDINATES, "(givenName~=Aaccf)") |
| | | .addAttribute(ATTR_DEBUG_SEARCH_INDEX); |
| | | InternalSearchOperation search = getRootConnection().processSearch(request); |
| | | |
| | | List<SearchResultEntry> result = search.getSearchEntries(); |
| | | |
| | |
| | | assertEquals(resultCode, 0); |
| | | } |
| | | |
| | | |
| | | |
| | | @Test(dependsOnMethods = {"testDeleteEntry", "testSearchScope", |
| | | "testSearchIndex", "testMatchedDN"}) |
| | | public void testSearchNotIndexed() throws Exception { |
| | |
| | | assertNotNull(backend.getEntry(entry.getName())); |
| | | } |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | Set<String> attribs = new LinkedHashSet<String>(); |
| | | attribs.add(ATTR_DEBUG_SEARCH_INDEX); |
| | | |
| | | InternalSearchOperation search = |
| | | conn.processSearch(DN.valueOf("dc=test,dc=com"), |
| | | SearchScope.SUBORDINATES, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | 0, |
| | | 0, |
| | | false, |
| | | LDAPFilter.decode("(carLicense=377*)").toSearchFilter(), |
| | | attribs); |
| | | |
| | | final SearchRequest request = newSearchRequest("dc=test,dc=com", SearchScope.SUBORDINATES, "(carLicense=377*)") |
| | | .addAttribute(ATTR_DEBUG_SEARCH_INDEX); |
| | | InternalSearchOperation search = getRootConnection().processSearch(request); |
| | | List<SearchResultEntry> result = search.getSearchEntries(); |
| | | |
| | | //No indexes should be used. |
| | |
| | | ResultCode expectedResultCode |
| | | ) throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | // Filter for the search |
| | | SearchFilter filter = LDAPFilter.decode("(objectClass=*)").toSearchFilter(); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | SearchFilter filter = SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | |
| | | // Test is performed with each and every scope |
| | | for (SearchScope scope: SearchScope.values()) |
| | | { |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(searchBaseDN, scope, filter); |
| | | final SearchRequest request = newSearchRequest(searchBaseDN, scope, filter); |
| | | InternalSearchOperation searchOperation = conn.processSearch(request); |
| | | |
| | | assertEquals(searchOperation.getResultCode(), expectedResultCode); |
| | | assertEquals(searchOperation.getMatchedDN(), expectedMatchedDN); |
| | |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | 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.opends.server.core.ModifyOperation; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.protocols.ldap.LDAPAttribute; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.protocols.ldap.LDAPModification; |
| | | import org.opends.server.protocols.ldap.LDAPReader; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.controls.PersistentSearchChangeType.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | //Create a persistent search request. |
| | | Set<String> attributes = new LinkedHashSet<String>(); |
| | | attributes.add("cn"); |
| | | List<Control> controls = new LinkedList<Control>(); |
| | | // Creates psearch control |
| | | Set<PersistentSearchChangeType> changeTypes = |
| | | EnumSet.of(ADD, DELETE, MODIFY, MODIFY_DN); |
| | | PersistentSearchControl persSearchControl = new PersistentSearchControl( |
| | | changeTypes, true, true); |
| | | controls.add(persSearchControl); |
| | | final InternalSearchOperation search = |
| | | conn.processSearch("o=test", SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, // Size limit |
| | | 0, // Time limit |
| | | true, // Types only |
| | | "(objectClass=*)", attributes, controls, null); |
| | | Set<PersistentSearchChangeType> changeTypes = EnumSet.of(ADD, DELETE, MODIFY, MODIFY_DN); |
| | | SearchRequest request = newSearchRequest("o=test", SearchScope.BASE_OBJECT, "(objectClass=*)") |
| | | .setTypesOnly(true) |
| | | .addAttribute("cn") |
| | | .addControl(new PersistentSearchControl(changeTypes, true, true)); |
| | | final InternalSearchOperation search = conn.processSearch(request); |
| | | |
| | | Thread t = new Thread(new Runnable() { |
| | | @Override |
| | |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | 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.Modification; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | // Make sure that both entries exist. |
| | | InternalSearchOperation internalSearch = |
| | | conn.processSearch(parentBaseDN, SearchScope.WHOLE_SUBTREE, |
| | | SearchFilter.createFilterFromString("(objectClass=*)")); |
| | | final SearchRequest request = newSearchRequest(parentBaseDN, SearchScope.WHOLE_SUBTREE, "(objectClass=*)"); |
| | | InternalSearchOperation internalSearch = conn.processSearch(request); |
| | | assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(internalSearch.getSearchEntries().size(), 2); |
| | | |
| | |
| | | |
| | | // Make sure that we can't remove the parent backend with the child still |
| | | // in place. |
| | | DeleteOperation deleteOperation = |
| | | conn.processDelete(parentBackendEntry.getName()); |
| | | DeleteOperation deleteOperation = conn.processDelete(parentBackendEntry.getName()); |
| | | assertFalse(deleteOperation.getResultCode() == ResultCode.SUCCESS); |
| | | assertNotNull(DirectoryServer.getBackend(parentBackendID)); |
| | | |
| | |
| | | assertFalse(DirectoryServer.isNamingContext(childBaseDN)); |
| | | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | // Verify that we can see both entries with a subtree search. |
| | | InternalSearchOperation internalSearch = |
| | | conn.processSearch(parentBaseDN, SearchScope.WHOLE_SUBTREE, |
| | | SearchFilter.createFilterFromString("(objectClass=*)")); |
| | | final SearchRequest request = newSearchRequest(parentBaseDN, SearchScope.WHOLE_SUBTREE, "(objectClass=*)"); |
| | | InternalSearchOperation internalSearch = getRootConnection().processSearch(request); |
| | | assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(internalSearch.getSearchEntries().size(), 2); |
| | | |
| | | |
| | | // Delete the backends from the server. |
| | | DeleteOperation deleteOperation = |
| | | conn.processDelete(childBackendEntry.getName()); |
| | | DeleteOperation deleteOperation = getRootConnection().processDelete(childBackendEntry.getName()); |
| | | assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNull(DirectoryServer.getBackend(childBackendID)); |
| | | assertTrue(parentBackend.getSubordinateBackends().length == 0); |
| | | |
| | | deleteOperation = conn.processDelete(parentBackendEntry.getName()); |
| | | deleteOperation = getRootConnection().processDelete(parentBackendEntry.getName()); |
| | | assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertNull(DirectoryServer.getBackend(parentBackendID)); |
| | | } |
| | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | // Verify that a subtree search can see all three entries. |
| | | InternalSearchOperation internalSearch = |
| | | conn.processSearch(parentBaseDN, SearchScope.WHOLE_SUBTREE, |
| | | SearchFilter.createFilterFromString("(objectClass=*)")); |
| | | assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(internalSearch.getSearchEntries().size(), 3); |
| | | final SearchRequest request = newSearchRequest(parentBaseDN, SearchScope.WHOLE_SUBTREE, "(objectClass=*)"); |
| | | assertSearchResultsSize(request, 3); |
| | | |
| | | |
| | | // Disable the intermediate (child) backend. This should be allowed. |
| | | ArrayList<Modification> mods = new ArrayList<Modification>(); |
| | | mods.add(new Modification(ModificationType.REPLACE, |
| | | Attributes.create("ds-cfg-enabled", |
| | | "false"))); |
| | | mods.add(new Modification(ModificationType.REPLACE, Attributes.create("ds-cfg-enabled", "false"))); |
| | | ModifyOperation modifyOperation = |
| | | conn.processModify(childBackendEntry.getName(), mods); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | |
| | | // Make sure that we now only see two entries with the subtree search |
| | | // (and those two entries should be the parent and grandchild base entries). |
| | | internalSearch = |
| | | conn.processSearch(parentBaseDN, SearchScope.WHOLE_SUBTREE, |
| | | SearchFilter.createFilterFromString("(objectClass=*)")); |
| | | assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(internalSearch.getSearchEntries().size(), 2); |
| | | assertSearchResultsSize(request, 2); |
| | | |
| | | |
| | | // Re-enable the intermediate backend. |
| | |
| | | // entries across stops and restarts, a subtree search below the parent |
| | | // should still only return two entries, which means that it's going through |
| | | // the entire chain of backends. |
| | | internalSearch = |
| | | conn.processSearch(parentBaseDN, SearchScope.WHOLE_SUBTREE, |
| | | SearchFilter.createFilterFromString("(objectClass=*)")); |
| | | assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(internalSearch.getSearchEntries().size(), 2); |
| | | assertSearchResultsSize(request, 2); |
| | | |
| | | |
| | | // Add the child entry back into the server to get things back to the way |
| | |
| | | createEntry(childBaseDN, childBackend); |
| | | |
| | | |
| | | // We should again be able to see all three entries when performing a |
| | | // search. |
| | | internalSearch = |
| | | conn.processSearch(parentBaseDN, SearchScope.WHOLE_SUBTREE, |
| | | SearchFilter.createFilterFromString("(objectClass=*)")); |
| | | assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(internalSearch.getSearchEntries().size(), 3); |
| | | // We should again be able to see all three entries when performing a search |
| | | assertSearchResultsSize(request, 3); |
| | | |
| | | |
| | | // Get rid of the entries in the proper order. |
| | |
| | | assertNull(DirectoryServer.getBackend(parentBackendID)); |
| | | } |
| | | |
| | | private void assertSearchResultsSize(final SearchRequest request, int expected) |
| | | { |
| | | InternalSearchOperation internalSearch = getRootConnection().processSearch(request); |
| | | assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(internalSearch.getSearchEntries().size(), expected); |
| | | } |
| | | |
| | | private void createBackend(DN childBaseDN, Backend<?> childBackend, Backend<?> parentBackend, |
| | | Backend<?> grandchildBackend) throws DirectoryException |
| | | { |
| | |
| | | import org.opends.server.plugins.InvocationCounterPlugin; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.Requests; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.protocols.ldap.*; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.tools.LDAPWriter; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.ServerConstants; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | |
| | | |
| | | // Real attributes (these are all user attributes). |
| | | List<String> realAttrTypes = |
| | | Arrays.asList("objectclass", "uid", "cn", "sn", "givenname", |
| | | "userpassword"); |
| | | Arrays.asList("objectclass", "uid", "cn", "sn", "givenname", "userpassword"); |
| | | |
| | | // Virtual attributes (these are all operational attributes). |
| | | List<String> virtualAttrTypes = |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | Entry userEntry = DirectoryServer.getEntry(userDN); |
| | | assertNotNull(userEntry); |
| | | |
| | | LinkedHashSet<String> attributes = new LinkedHashSet<String>(); |
| | | final SearchRequest request = Requests.newSearchRequest(userDN, SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | request.setTypesOnly(typesOnly); |
| | | switch (filterType) |
| | | { |
| | | case DEFAULT: |
| | | // Only user attributes. |
| | | attributes = null; |
| | | break; |
| | | case WILDCARDS: |
| | | attributes.add("*"); |
| | | attributes.add("+"); |
| | | request.addAttribute("*", "+"); |
| | | break; |
| | | case ENUMERATED: |
| | | attributes.addAll(realAttrTypes); |
| | | attributes.addAll(virtualAttrTypes); |
| | | request.addAttribute(realAttrTypes); |
| | | request.addAttribute(virtualAttrTypes); |
| | | break; |
| | | } |
| | | |
| | | List<Control> controls = new LinkedList<Control>(); |
| | | |
| | | if (stripRealAttributes) |
| | | { |
| | | controls.add(new LDAPControl(ServerConstants.OID_VIRTUAL_ATTRS_ONLY, |
| | | false)); |
| | | request.addControl(new LDAPControl(OID_VIRTUAL_ATTRS_ONLY, false)); |
| | | } |
| | | |
| | | if (stripVirtualAttributes) |
| | | { |
| | | controls.add(new LDAPControl(ServerConstants.OID_REAL_ATTRS_ONLY, |
| | | false)); |
| | | request.addControl(new LDAPControl(OID_REAL_ATTRS_ONLY, false)); |
| | | } |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalSearchOperation search = |
| | | conn.processSearch(userDNString, SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, // Size limit |
| | | 0, // Time limit |
| | | typesOnly, // Types only |
| | | "(objectClass=*)", attributes, controls, null); |
| | | |
| | | InternalSearchOperation search = getRootConnection().processSearch(request); |
| | | assertEquals(search.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | LinkedList<SearchResultEntry> entries = search.getSearchEntries(); |
| | |
| | | { |
| | | if (!attr.isEmpty()) |
| | | { |
| | | messages.add("Unexpected non-empty real attribute: " |
| | | + attrType); |
| | | messages.add("Unexpected non-empty real attribute: " + attrType); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (attr.isEmpty()) |
| | | { |
| | | messages.add("Unexpected empty real attribute: " |
| | | + attrType); |
| | | messages.add("Unexpected empty real attribute: " + attrType); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | if (!attr.isEmpty()) |
| | | { |
| | | messages.add("Unexpected non-empty virtual attribute: " |
| | | + attrType); |
| | | messages.add("Unexpected non-empty virtual attribute: " + attrType); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (attr.isEmpty()) |
| | | { |
| | | messages.add("Unexpected empty virtual attribute: " |
| | | + attrType); |
| | | messages.add("Unexpected empty virtual attribute: " + attrType); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | assertTrue(messages.isEmpty(), "Entry invalid: " + messages); |
| | | assertThat(messages).isEmpty(); |
| | | } |
| | | |
| | | |
| | |
| | | Arrays.asList("objectClass", "cn", "cn;lang-fr") }, |
| | | { |
| | | Arrays.asList("*", "+"), |
| | | Arrays.asList("objectClass", "cn", "cn;lang-fr", "entryDN", |
| | | "createTimestamp") }, |
| | | Arrays.asList("objectClass", "cn", "cn;lang-fr", "entryDN", "createTimestamp") }, |
| | | { |
| | | Arrays.asList("objectClass", "cn", "cn;lang-fr", "entryDN", |
| | | "createTimestamp"), |
| | | Arrays.asList("objectClass", "cn", "cn;lang-fr", "entryDN", |
| | | "createTimestamp") }, |
| | | Arrays.asList("objectClass", "cn", "cn;lang-fr", "entryDN", "createTimestamp"), |
| | | Arrays.asList("objectClass", "cn", "cn;lang-fr", "entryDN", "createTimestamp") }, |
| | | { |
| | | Arrays.asList("OBJECTCLASS", "commonName", "commonName;LANG-FR", "entrydn", |
| | | "CREATETIMESTAMP"), |
| | | Arrays.asList("OBJECTCLASS", "commonName", |
| | | "commonName;LANG-FR", "entrydn", "CREATETIMESTAMP") }, |
| | | Arrays.asList("OBJECTCLASS", "commonName", "commonName;LANG-FR", "entrydn", "CREATETIMESTAMP"), |
| | | Arrays.asList("OBJECTCLASS", "commonName", "commonName;LANG-FR", "entrydn", "CREATETIMESTAMP") }, |
| | | { |
| | | Arrays.asList("*", "+", "OBJECTCLASS", "commonName", |
| | | "commonName;LANG-FR", "entrydn", "CREATETIMESTAMP"), |
| | | Arrays.asList("OBJECTCLASS", "commonName", |
| | | "commonName;LANG-FR", "entrydn", "CREATETIMESTAMP") }, |
| | | { Arrays.asList("name"), |
| | | Arrays.asList("givenName", "sn", "cn", "cn;lang-fr") }, |
| | | Arrays.asList("OBJECTCLASS", "commonName", "commonName;LANG-FR", "entrydn", "CREATETIMESTAMP") }, |
| | | { Arrays.asList("name"), Arrays.asList("givenName", "sn", "cn", "cn;lang-fr") }, |
| | | { Arrays.asList("name;lang-fr"), Arrays.asList("cn;lang-fr") }, |
| | | { Arrays.asList("name;LANG-FR"), Arrays.asList("cn;LANG-FR") }, }; |
| | | } |
| | |
| | | "cn;lang-fr: Test Usager", |
| | | "userPassword: password"); |
| | | |
| | | Entry userEntry = DirectoryServer.getEntry(userDN); |
| | | assertNotNull(userEntry); |
| | | |
| | | LinkedHashSet<String> attributes = |
| | | new LinkedHashSet<String>(requestedAttributes); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalSearchOperation search = |
| | | conn.processSearch(userDNString, SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, // Size limit |
| | | 0, // Time limit |
| | | false, // Types only |
| | | "(objectClass=*)", attributes); |
| | | |
| | | SearchRequest request = Requests.newSearchRequest(userDNString, SearchScope.BASE_OBJECT, "(objectClass=*)") |
| | | .addAttribute(requestedAttributes); |
| | | InternalSearchOperation search = getRootConnection().processSearch(request); |
| | | assertEquals(search.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | LinkedList<SearchResultEntry> entries = search.getSearchEntries(); |
| | |
| | | actualNames.add(attribute.getNameWithOptions()); |
| | | } |
| | | |
| | | assertTrue(actualNames.containsAll(expectedAttributes), |
| | | "Expected: " + expectedAttributes + " got " + actualNames); |
| | | assertThat(actualNames).containsAll(expectedAttributes); |
| | | } |
| | | |
| | | |
| | |
| | | "cn;lang-fr: Test Usager", |
| | | "userPassword: password"); |
| | | |
| | | Entry userEntry = DirectoryServer.getEntry(userDN); |
| | | assertNotNull(userEntry); |
| | | |
| | | LinkedHashSet<String> attributes = |
| | | new LinkedHashSet<String>(requestedAttributes); |
| | | |
| | |
| | | actualNames.add(attribute.getAttributeType()); |
| | | } |
| | | |
| | | assertTrue(actualNames.containsAll(expectedAttributes), |
| | | "Expected: " + expectedAttributes + " got " + actualNames); |
| | | assertThat(actualNames).containsAll(expectedAttributes); |
| | | } |
| | | |
| | | |
| | |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | |
| | | InternalClientConnection conn1 = new InternalClientConnection(DN.NULL_DN); |
| | | limits.addConnection(conn1); |
| | | |
| | | InternalSearchOperation search = conn1.processSearch( |
| | | DN.valueOf("dc=example,dc=com"), |
| | | SearchScope.BASE_OBJECT, |
| | | LDAPFilter.decode(searchFilter).toSearchFilter()); |
| | | final SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.BASE_OBJECT, searchFilter); |
| | | InternalSearchOperation search = conn1.processSearch(request); |
| | | |
| | | assertOperationIsAllowed(limits, conn1, search, success); |
| | | limits.removeConnection(conn1); |
| | |
| | | InternalClientConnection conn = new InternalClientConnection(DN.NULL_DN); |
| | | limits.addConnection(conn); |
| | | |
| | | final DN dn = DN.valueOf("dc=example,dc=com"); |
| | | final SearchFilter all = SearchFilter.createFilterFromString("(objectclass=*)"); |
| | | |
| | | final InternalSearchOperation search1 = |
| | | conn.processSearch(dn, SearchScope.BASE_OBJECT, all); |
| | | final SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.BASE_OBJECT, "(objectclass=*)"); |
| | | final InternalSearchOperation search1 = conn.processSearch(request); |
| | | assertOperationIsAllowed(limits, conn, search1, true, |
| | | "First operation should be allowed"); |
| | | |
| | | final InternalSearchOperation search2 = |
| | | conn.processSearch(dn, SearchScope.BASE_OBJECT, all); |
| | | assertOperationIsAllowed(limits, conn, |
| | | search2, false, |
| | | final InternalSearchOperation search2 = conn.processSearch(request); |
| | | assertOperationIsAllowed(limits, conn, search2, false, |
| | | "Second operation in the same interval should be disallowed"); |
| | | |
| | | // Wait for the end of the interval => counters are reset |
| | | Thread.sleep(interval); |
| | | |
| | | final InternalSearchOperation search3 = |
| | | conn.processSearch(dn, SearchScope.BASE_OBJECT, all); |
| | | final InternalSearchOperation search3 = conn.processSearch(request); |
| | | assertOperationIsAllowed(limits, conn, search3, true, |
| | | "Third operation should be allowed"); |
| | | } |
| | |
| | | import java.io.OutputStream; |
| | | import java.security.MessageDigest; |
| | | import java.util.Arrays; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | |
| | | import javax.naming.ldap.LdapName; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.admin.ads.ADSContext; |
| | | import org.opends.admin.ads.util.ConnectionUtils; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.config.ConfigConstants; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.types.CryptoManager; |
| | | import org.opends.server.types.CryptoManagerException; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.util.EmbeddedUtils; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.opends.server.util.TimeThread; |
| | |
| | | |
| | | import com.forgerock.opendj.cli.CliConstants; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | .append(FILTER_CIPHER_TRANSFORMATION_NAME) |
| | | .append(FILTER_CIPHER_KEY_LENGTH) |
| | | .append(")").toString(); |
| | | final LinkedHashSet<String> requestedAttributes |
| | | = new LinkedHashSet<String>(); |
| | | requestedAttributes.add("dn"); |
| | | final InternalClientConnection icc |
| | | = InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOp = icc.processSearch( |
| | | baseDN, |
| | | SearchScope.SINGLE_LEVEL, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | /* size limit */ 0, /* time limit */ 0, |
| | | /* types only */ false, |
| | | SearchFilter.createFilterFromString(searchFilter), |
| | | requestedAttributes); |
| | | final SearchRequest request = newSearchRequest(baseDN, SearchScope.SINGLE_LEVEL, searchFilter).addAttribute("dn"); |
| | | InternalSearchOperation searchOp = getRootConnection().processSearch(request); |
| | | assertTrue(0 < searchOp.getSearchEntries().size()); |
| | | |
| | | String compromisedTime = TimeThread.getGeneralizedTime(); |
| | |
| | | */ |
| | | package org.opends.server.crypto; |
| | | |
| | | import java.util.LinkedHashSet; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.admin.ads.ADSContext; |
| | |
| | | import org.opends.server.core.ExtendedOperation; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.opends.server.util.ServerConstants; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | .append(FILTER_CIPHER_TRANSFORMATION_NAME) |
| | | .append(FILTER_CIPHER_KEY_LENGTH) |
| | | .append(")").toString(); |
| | | final LinkedHashSet<String> requestedAttributes |
| | | = new LinkedHashSet<String>(); |
| | | requestedAttributes.add(ConfigConstants.ATTR_CRYPTO_SYMMETRIC_KEY); |
| | | final InternalClientConnection icc |
| | | = InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOp = icc.processSearch( |
| | | baseDN, |
| | | SearchScope.SINGLE_LEVEL, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | /* size limit */ 0, /* time limit */ 0, |
| | | /* types only */ false, |
| | | SearchFilter.createFilterFromString(searchFilter), |
| | | requestedAttributes); |
| | | final SearchRequest request = newSearchRequest(baseDN, SearchScope.SINGLE_LEVEL, searchFilter) |
| | | .addAttribute(ConfigConstants.ATTR_CRYPTO_SYMMETRIC_KEY); |
| | | InternalSearchOperation searchOp = getRootConnection().processSearch(request); |
| | | assertTrue(0 < searchOp.getSearchEntries().size()); |
| | | |
| | | final InternalClientConnection internalConnection = |
| | |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | | import java.util.SortedSet; |
| | | import java.util.TreeSet; |
| | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | |
| | | import org.opends.server.core.SearchOperationWrapper; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.Requests; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.opends.server.protocols.ldap.LDAPModification; |
| | | import org.opends.server.types.Attribute; |
| | |
| | | private Entry readEntry(InternalClientConnection conn, String userDN) |
| | | throws DirectoryException |
| | | { |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(2); |
| | | attrList.add("*"); |
| | | attrList.add(ETAG); |
| | | InternalSearchOperation searchOperation = conn.processSearch(userDN, |
| | | SearchScope.BASE_OBJECT, DereferenceAliasesPolicy.NEVER, 0, 0, |
| | | false, "(objectClass=*)", attrList); |
| | | SearchRequest request = Requests.newSearchRequest(userDN, SearchScope.BASE_OBJECT, "(objectClass=*)", "*", ETAG); |
| | | InternalSearchOperation searchOperation = conn.processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | |
| | | package org.opends.server.extensions; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.workflowelement.localbackend.LocalBackendSearchOperation; |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | public void testSearchEntryDNAttrInMatchingFilter(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(entryDN=" + entryDN.toString() + |
| | | ")"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("entrydn"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | filter, attrList); |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(entryDN=" + entryDN + ")") |
| | | .addAttribute("entrydn"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | |
| | | public void testSearchEntryDNAttrInNonMatchingFilter(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(entryDN=cn=Not A Match)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("entrydn"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | filter, attrList); |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(entryDN=cn=Not A Match)") |
| | | .addAttribute("entrydn"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 0); |
| | | } |
| | | |
| | |
| | | public void testSearchEntryDNAttrRealAttrsOnly(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("entrydn"); |
| | | |
| | | LinkedList<Control> requestControls = new LinkedList<Control>(); |
| | | requestControls.add(new LDAPControl(OID_REAL_ATTRS_ONLY, true)); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), requestControls, |
| | | entryDN, SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, |
| | | 0, false, filter, attrList, null); |
| | | searchOperation.run(); |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(objectClass=*)") |
| | | .addAttribute("entrydn") |
| | | .addControl(new LDAPControl(OID_REAL_ATTRS_ONLY, true)); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Performs an internal search to retrieve the specified entry, ensuring that |
| | | * the entryDN attribute is included when the entryDN attribute is |
| | |
| | | public void testSearchEntryDNAttrVirtualAttrsOnly(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("entrydn"); |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(objectClass=*)") |
| | | .addAttribute("entrydn") |
| | | .addControl(new LDAPControl(OID_VIRTUAL_ATTRS_ONLY, true)); |
| | | |
| | | LinkedList<Control> requestControls = new LinkedList<Control>(); |
| | | requestControls.add(new LDAPControl(OID_VIRTUAL_ATTRS_ONLY, true)); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), requestControls, |
| | | entryDN, SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, |
| | | 0, false, filter, attrList, null); |
| | | searchOperation.run(); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.types.*; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.testng.Assert.*; |
| | |
| | | String uuidString = UUID.nameUUIDFromBytes( |
| | | getBytes(entryDN.toNormalizedString())).toString(); |
| | | |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(entryUUID=" + uuidString + ")"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("entryuuid"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | filter, attrList); |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(entryUUID=" + uuidString + ")") |
| | | .addAttribute("entryuuid"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | |
| | | public void testSearchEntryUUIDAttrInNonMatchingFilter(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(entryUUID=wrong)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("entryuuid"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | filter, attrList); |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(entryUUID=wrong)") |
| | | .addAttribute("entryuuid"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 0); |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.LinkedHashSet; |
| | | |
| | | /** |
| | | * Utility class providing common code for extensions tests. |
| | | */ |
| | |
| | | public static void testSearchEmptyAttrs(DN entryDN, |
| | | AttributeType attributeType) throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, filter); |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | |
| | | public static void testSearchNoAttrs(DN entryDN, AttributeType attributeType) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add(SchemaConstants.NO_ATTRIBUTES); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, filter, |
| | | attrList); |
| | | final SearchRequest request = |
| | | newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(objectClass=*)") |
| | | .addAttribute(SchemaConstants.NO_ATTRIBUTES); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | |
| | | public static void testSearchAllUserAttrs(DN entryDN, |
| | | AttributeType attributeType) throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("*"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, filter, |
| | | attrList); |
| | | final SearchRequest request = |
| | | newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(objectClass=*)").addAttribute("*"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | |
| | | public static void testSearchAllOperationalAttrs(DN entryDN, |
| | | AttributeType attributeType) throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("+"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, filter, |
| | | attrList); |
| | | final SearchRequest request = |
| | | newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(objectClass=*)").addAttribute("+"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | |
| | | public static void testSearchAttr(DN entryDN, String attrName, |
| | | AttributeType attributeType) throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add(attrName); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, filter, |
| | | attrList); |
| | | final SearchRequest request = |
| | | newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(objectClass=*)").addAttribute(attrName); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | |
| | | public static void testSearchExcludeAttr(DN entryDN, |
| | | AttributeType attributeType) throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("objectClass"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, filter, |
| | | attrList); |
| | | final SearchRequest request = |
| | | newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(objectClass=*)").addAttribute("objectClass"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.std.meta.VirtualAttributeCfgDefn; |
| | | import org.opends.server.api.VirtualAttributeProvider; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DN; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.types.VirtualAttributeRule; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * A set of test cases for the governing structure rule virtual attribute |
| | | * provider. |
| | |
| | | public void testSearchGovStructRuleInMatchingFilter(DN entryDN,String oc) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("governingstructurerule="+oc); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("governingStructureRule"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | filter, attrList); |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "governingstructurerule=" + oc) |
| | | .addAttribute("governingStructureRule"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | |
| | | public void testSearchGovStructRuleAttrInNonMatchingFilter(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(governingStructureRule=1)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("governingStructureRuleType"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | filter, attrList); |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(governingStructureRule=1)") |
| | | .addAttribute("governingStructureRuleType"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Performs an internal search to retrieve the specified entry, ensuring that |
| | | * the governingStructureRule attribute is not included when that attribute is |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.types.*; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.testng.Assert.*; |
| | |
| | | public void testSearchhasSubordinatesAttrInMatchingFilter(DN entryDN, boolean hasSubs) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(hasSubordinates=" + hasSubs + ")"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("hasSubordinates"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | filter, attrList); |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(hasSubordinates=" + hasSubs + ")") |
| | | .addAttribute("hasSubordinates"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | |
| | | assertTrue(e.hasAttribute(hasSubordinatesType)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Performs an internal search to retrieve the specified entry, ensuring that |
| | | * no entries are returned when the hasSubordinates attribute is used in the search |
| | |
| | | public void testSearchhasSubordinatesAttrInNonMatchingFilter(DN entryDN, boolean hasSubs) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(hasSubordinates=wrong)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("hasSubordinates"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | filter, attrList); |
| | | final SearchRequest request = |
| | | newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(hasSubordinates=wrong)").addAttribute("hasSubordinates"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 0); |
| | | } |
| | | |
| | |
| | | public void testSearchhasSubordinatesAttrRealAttrsOnly(DN entryDN, boolean hasSubs) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("hasSubordinates"); |
| | | |
| | | LinkedList<Control> requestControls = new LinkedList<Control>(); |
| | | requestControls.add(new LDAPControl(OID_REAL_ATTRS_ONLY, true)); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), requestControls, |
| | | entryDN, SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, |
| | | 0, false, filter, attrList, null); |
| | | searchOperation.run(); |
| | | SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(objectClass=*)") |
| | | .addAttribute("hasSubordinates") |
| | | .addControl(new LDAPControl(OID_REAL_ATTRS_ONLY, true)); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import java.util.LinkedHashSet; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.DirectoryServerTestCase; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.types.*; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | public void testSearchnumSubordinatesAttrInMatchingFilter(DN entryDN, int count) |
| | | throws Exception |
| | | { |
| | | |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(numSubordinates=" + count + ")"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("numSubordinates"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | filter, attrList); |
| | | final SearchRequest request = |
| | | newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(numSubordinates=" + count + ")") |
| | | .addAttribute("numSubordinates"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | |
| | | assertTrue(e.hasAttribute(numSubordinatesType)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Performs an internal search to retrieve the specified entry, ensuring that |
| | | * no entries are returned when the numSubordinates attribute is used in the search |
| | |
| | | public void testSearchnumSubordinatesAttrInNonMatchingFilter(DN entryDN, int count) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(numSubordinates=wrong)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("numSubordinates"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | filter, attrList); |
| | | final SearchRequest request = |
| | | newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(numSubordinates=wrong)").addAttribute("numSubordinates"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 0); |
| | | } |
| | | |
| | |
| | | public void testSearchnumSubordinatesAttrRealAttrsOnly(DN entryDN, int count) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("numSubordinates"); |
| | | |
| | | LinkedList<Control> requestControls = new LinkedList<Control>(); |
| | | requestControls.add(new LDAPControl(OID_REAL_ATTRS_ONLY, true)); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), requestControls, |
| | | entryDN, SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, |
| | | 0, false, filter, attrList, null); |
| | | searchOperation.run(); |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(objectClass=*)") |
| | | .addAttribute("numSubordinates") |
| | | .addControl(new LDAPControl(OID_REAL_ATTRS_ONLY, true)); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | |
| | | public void testSearchnumSubordinatesAttrVirtualAttrsOnly(DN entryDN, int count) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("numSubordinates"); |
| | | |
| | | LinkedList<Control> requestControls = new LinkedList<Control>(); |
| | | requestControls.add(new LDAPControl(OID_VIRTUAL_ATTRS_ONLY, true)); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), requestControls, |
| | | entryDN, SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, |
| | | 0, false, filter, attrList, null); |
| | | searchOperation.run(); |
| | | final SearchRequest request = |
| | | newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(objectClass=*)").addAttribute("numSubordinates") |
| | | .addControl(new LDAPControl(OID_VIRTUAL_ATTRS_ONLY, true)); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | |
| | | public void testSearchnumSubordinatesAttrInGTEFilter(DN entryDN, int count) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(numSubordinates>=" + count + ")"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("numSubordinates"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | filter, attrList); |
| | | final SearchRequest request = |
| | | newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(numSubordinates>=" + count + ")") |
| | | .addAttribute("numSubordinates"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | |
| | | public void testSearchnumSubordinatesAttrInLTEFilter(DN entryDN, int count) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(numSubordinates<=" + count + ")"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("numSubordinates"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | filter, attrList); |
| | | final SearchRequest request = |
| | | newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(numSubordinates<=" + count + ")") |
| | | .addAttribute("numSubordinates"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | |
| | | @Test() |
| | | public void testIsMultiValued() |
| | | { |
| | | NumSubordinatesVirtualAttributeProvider provider = |
| | | new NumSubordinatesVirtualAttributeProvider(); |
| | | assertFalse(provider.isMultiValued()); |
| | | assertFalse(new NumSubordinatesVirtualAttributeProvider().isMultiValued()); |
| | | } |
| | | } |
| | |
| | | package org.opends.server.extensions; |
| | | |
| | | import java.util.Iterator; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.schema.GeneralizedTimeSyntax; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.DisconnectReason; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.SearchResultEntry; |
| | | import org.testng.annotations.AfterMethod; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.BeforeMethod; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | @SuppressWarnings("javadoc") |
| | |
| | | private long getTimeValueFromAttribute(String attributeName) |
| | | throws Exception |
| | | { |
| | | // Establish the internal connection as root |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | assertNotNull(conn); |
| | | |
| | | // Define the attribute to be returned |
| | | |
| | | LinkedHashSet<String> retAttr = new LinkedHashSet<String>(); |
| | | retAttr.add(attributeName); |
| | | retAttr.add("pwdpolicysubentry"); |
| | | |
| | | // Process the search request |
| | | |
| | | InternalSearchOperation search = |
| | | conn.processSearch(notExpired.getName().toString(), |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.ALWAYS, |
| | | 0, |
| | | 0, |
| | | false, |
| | | "(objectclass=*)", |
| | | retAttr); |
| | | SearchRequest request = newSearchRequest(notExpired.getName(), SearchScope.BASE_OBJECT, "(objectclass=*)") |
| | | .addAttribute(attributeName, "pwdpolicysubentry"); |
| | | InternalSearchOperation search = getRootConnection().processSearch(request); |
| | | assertEquals(search.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | LinkedList<SearchResultEntry> entries = search.getSearchEntries(); |
| | |
| | | |
| | | ByteString val = it.next(); |
| | | |
| | | conn.disconnect(DisconnectReason.UNBIND, true, LocalizableMessage.EMPTY); |
| | | getRootConnection().disconnect(DisconnectReason.UNBIND, true, LocalizableMessage.EMPTY); |
| | | |
| | | return GeneralizedTimeSyntax.decodeGeneralizedTimeValue(val); |
| | | } |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.opends.server.protocols.internal.Requests; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import org.opends.server.types.AuthenticationInfo; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | |
| | | @Test() |
| | | public void testSASLPlainAdvertised() throws Exception |
| | | { |
| | | InternalClientConnection conn = getRootConnection(); |
| | | InternalSearchOperation op = |
| | | conn.processSearch(ByteString.empty(), SearchScope.BASE_OBJECT, |
| | | LDAPFilter.decode("(supportedSASLMechanisms=PLAIN)")); |
| | | SearchRequest request = |
| | | Requests.newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT, "(supportedSASLMechanisms=PLAIN)"); |
| | | InternalSearchOperation op = getRootConnection().processSearch(request); |
| | | assertFalse(op.getSearchEntries().isEmpty()); |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.std.meta.VirtualAttributeCfgDefn; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DN; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.types.VirtualAttributeRule; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * A set of test cases for the structural object class virtual attribute |
| | | * provider. |
| | |
| | | public void testSearchStructuralOCAttrInMatchingFilter(DN entryDN,String oc) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString(oc); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("structuralObjectClass"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | filter, attrList); |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT, oc) |
| | | .addAttribute("structuralObjectClass"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | |
| | | public void testSearchStructuralOCAttrInNonMatchingFilter(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(structuralObjectClass=abc)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("structuralObjectClass"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | filter, attrList); |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(structuralObjectClass=abc)") |
| | | .addAttribute("structuralObjectClass"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 0); |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.std.meta.VirtualAttributeCfgDefn; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DN; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.types.VirtualAttributeRule; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * A set of test cases for the subschemaSubentry virtual attribute provider. |
| | | */ |
| | |
| | | public void testSearchSubschemaSubentryAttrInMatchingFilter(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(subschemaSubentry=cn=schema)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("subschemaSubentry"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | filter, attrList); |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(subschemaSubentry=cn=schema)") |
| | | .addAttribute("subschemaSubentry"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | |
| | | public void testSearchSubschemaSubentryAttrInNonMatchingFilter(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(subschemaSubentry=cn=foo)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("subschemaSubentry"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | filter, attrList); |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(subschemaSubentry=cn=foo)") |
| | | .addAttribute("subschemaSubentry"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 0); |
| | | } |
| | | |
| | |
| | | public void testSearchSubschemaSubentryAttrRealAttrsOnly(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("subschemaSubentry"); |
| | | |
| | | LinkedList<Control> requestControls = new LinkedList<Control>(); |
| | | requestControls.add(new LDAPControl(OID_REAL_ATTRS_ONLY, true)); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation(conn, InternalClientConnection |
| | | .nextOperationID(), InternalClientConnection |
| | | .nextMessageID(), requestControls, entryDN, |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, filter, |
| | | attrList, null); |
| | | searchOperation.run(); |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(objectClass=*)") |
| | | .addAttribute("subschemaSubentry") |
| | | .addControl(new LDAPControl(OID_REAL_ATTRS_ONLY, true)); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | |
| | | public void testSearchSubschemaSubentryAttrVirtualAttrsOnly(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("subschemaSubentry"); |
| | | |
| | | LinkedList<Control> requestControls = new LinkedList<Control>(); |
| | | requestControls.add(new LDAPControl(OID_VIRTUAL_ATTRS_ONLY, true)); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation(conn, InternalClientConnection |
| | | .nextOperationID(), InternalClientConnection |
| | | .nextMessageID(), requestControls, entryDN, |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, filter, |
| | | attrList, null); |
| | | searchOperation.run(); |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(objectClass=*)") |
| | | .addAttribute("subschemaSubentry") |
| | | .addControl(new LDAPControl(OID_VIRTUAL_ATTRS_ONLY, true)); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | |
| | | @Test() |
| | | public void testIsMultiValued() |
| | | { |
| | | SubschemaSubentryVirtualAttributeProvider provider = |
| | | new SubschemaSubentryVirtualAttributeProvider(); |
| | | assertFalse(provider.isMultiValued()); |
| | | assertFalse(new SubschemaSubentryVirtualAttributeProvider().isMultiValued()); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.types.*; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | "ds-cfg-conflict-behavior: real-overrides-virtual", |
| | | "ds-cfg-value: single value"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | try |
| | | { |
| | | InternalSearchOperation searchOperation = |
| | |
| | | "ds-cfg-value: first value", |
| | | "ds-cfg-value: second value"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | try |
| | | { |
| | | InternalSearchOperation searchOperation = |
| | |
| | | "cn: Test User", |
| | | "userPassword: test"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | try |
| | | { |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(DN.valueOf(userDN), |
| | | SearchScope.BASE_OBJECT, SearchFilter |
| | | .createFilterFromString("(objectClass=*)")); |
| | | final SearchRequest request = newSearchRequest(userDN, SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | InternalSearchOperation searchOperation = conn.processSearch(request); |
| | | |
| | | List<Attribute> attrList = |
| | | searchOperation.getSearchEntries().get(0).getAttribute( |
| | |
| | | "cn: Test User", |
| | | "userPassword: test"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | try |
| | | { |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(DN.valueOf(userDN), |
| | | SearchScope.BASE_OBJECT, SearchFilter |
| | | .createFilterFromString("(objectClass=*)")); |
| | | final SearchRequest request = newSearchRequest(userDN, SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | InternalSearchOperation searchOperation = conn.processSearch(request); |
| | | |
| | | List<Attribute> attrList = |
| | | searchOperation.getSearchEntries().get(0).getAttribute( |
| | |
| | | "userPassword: test", |
| | | "description: " + realValue); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | try |
| | | { |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(DN.valueOf(userDN), |
| | | SearchScope.BASE_OBJECT, SearchFilter |
| | | .createFilterFromString("(objectClass=*)")); |
| | | final SearchRequest request = newSearchRequest(userDN, SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | InternalSearchOperation searchOperation = conn.processSearch(request); |
| | | |
| | | List<Attribute> attrList = |
| | | searchOperation.getSearchEntries().get(0).getAttribute( |
| | |
| | | "userPassword: test", |
| | | "description: " + realValue); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | try |
| | | { |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(DN.valueOf(userDN), |
| | | SearchScope.BASE_OBJECT, SearchFilter |
| | | .createFilterFromString("(objectClass=*)")); |
| | | final SearchRequest request = newSearchRequest(userDN, SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | InternalSearchOperation searchOperation = conn.processSearch(request); |
| | | |
| | | List<Attribute> attrList = |
| | | searchOperation.getSearchEntries().get(0).getAttribute( |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the creation of a description virtual attribute when real and virtual |
| | | * values should be merged and the entry has a real value. |
| | |
| | | "userPassword: test", |
| | | "description: " + realValue); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | try |
| | | { |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(DN.valueOf(userDN), |
| | | SearchScope.BASE_OBJECT, SearchFilter |
| | | .createFilterFromString("(objectClass=*)")); |
| | | final SearchRequest request = newSearchRequest(userDN, SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | InternalSearchOperation searchOperation = conn.processSearch(request); |
| | | |
| | | List<Attribute> attrList = |
| | | searchOperation.getSearchEntries().get(0).getAttribute( |
| | |
| | | |
| | | try |
| | | { |
| | | LinkedHashSet<String> attributes = new LinkedHashSet<String>(1); |
| | | attributes.add("description"); |
| | | final SearchRequest request = |
| | | newSearchRequest(userDN, SearchScope.BASE_OBJECT, "(objectClass=*)").addAttribute("description"); |
| | | InternalSearchOperation searchOperation = conn.processSearch(request); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(DN.valueOf(userDN), |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.createFilterFromString("(objectClass=*)"), |
| | | attributes); |
| | | |
| | | List<Attribute> attrList = |
| | | searchOperation.getSearchEntries().get(0).getAttribute( |
| | | descriptionType); |
| | | List<Attribute> attrList = searchOperation.getSearchEntries().get(0).getAttribute(descriptionType); |
| | | assertNotNull(attrList); |
| | | assertEquals(attrList.size(), 1); |
| | | |
| | |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.types.*; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | private void cleanUp() |
| | | throws Exception |
| | | private void cleanUp() throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(DN.valueOf("ou=Groups,dc=example,dc=com"), |
| | | SearchScope.SINGLE_LEVEL, |
| | | SearchFilter.createFilterFromString("(objectClass=*)")); |
| | | final SearchRequest request = |
| | | newSearchRequest("ou=Groups,dc=example,dc=com", SearchScope.SINGLE_LEVEL, "(objectClass=*)"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | for (Entry e : searchOperation.getSearchEntries()) |
| | | { |
| | | conn.processDelete(e.getName()); |
| | | getRootConnection().processDelete(e.getName()); |
| | | } |
| | | } |
| | | } |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.types.SearchResultEntry; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | |
| | | |
| | | import static org.forgerock.opendj.ldap.SearchScope.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.types.SearchFilter.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | |
| | | for (SearchResultEntry sre : op.getSearchEntries()) |
| | | { |
| | | final InternalSearchOperation readOp = conn.processSearch( |
| | | sre.getName(), BASE_OBJECT, createFilterFromString("(objectClass=*)")); |
| | | final SearchRequest request = newSearchRequest(sre.getName(), BASE_OBJECT, "(objectClass=*)"); |
| | | final InternalSearchOperation readOp = conn.processSearch(request); |
| | | assertEquals(readOp.getResultCode(), ResultCode.SUCCESS, |
| | | "Failed to read " + sre.getName() + " entry. Got error message: " + readOp.getErrorMessage()); |
| | | } |
| | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.server.AdminTestCaseUtils; |
| | | import org.opends.server.admin.std.meta.LDAPAttributeDescriptionListPluginCfgDefn; |
| | | import org.opends.server.admin.std.server.LDAPAttributeDescriptionListPluginCfg; |
| | | import org.opends.server.api.plugin.PluginType; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.types.Entry; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.server.AdminTestCaseUtils; |
| | | import org.opends.server.admin.std.meta. |
| | | LDAPAttributeDescriptionListPluginCfgDefn; |
| | | import org.opends.server.admin.std.server.LDAPAttributeDescriptionListPluginCfg; |
| | | import org.opends.server.api.plugin.PluginType; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testDoPreParseSearchWithEmptyAttrList() |
| | | throws Exception |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(DN.valueOf("o=test"), SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.createFilterFromString("(objectClass=*)"), attrList); |
| | | final SearchRequest request = newSearchRequest("o=test", SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertFalse(searchOperation.getSearchEntries().isEmpty()); |
| | | |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testDoPreParseSearchWithRequestedAttribute() |
| | | throws Exception |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(); |
| | | attrList.add("o"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(DN.valueOf("o=test"), SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.createFilterFromString("(objectClass=*)"), attrList); |
| | | SearchRequest request = newSearchRequest("o=test", SearchScope.BASE_OBJECT, "(objectClass=*)") |
| | | .addAttribute("o"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertFalse(searchOperation.getSearchEntries().isEmpty()); |
| | | |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testDoPreParseSearchWithRequestedObjectClass() |
| | | throws Exception |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(); |
| | | attrList.add("@organization"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(DN.valueOf("o=test"), SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.createFilterFromString("(objectClass=*)"), attrList); |
| | | final SearchRequest request = newSearchRequest("o=test", SearchScope.BASE_OBJECT, "(objectClass=*)") |
| | | .addAttribute("@organization"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertFalse(searchOperation.getSearchEntries().isEmpty()); |
| | | |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testDoPreParseSearchWithRequestedUndefinedObjectClass() |
| | | throws Exception |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(); |
| | | attrList.add("@undefined"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(DN.valueOf("o=test"), SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.createFilterFromString("(objectClass=*)"), attrList); |
| | | final SearchRequest request = |
| | | newSearchRequest("o=test", SearchScope.BASE_OBJECT, "(objectClass=*)").addAttribute("@undefined"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertFalse(searchOperation.getSearchEntries().isEmpty()); |
| | | |
| | |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | |
| | | import org.opends.server.core.*; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.DN; |
| | |
| | | String... dns) |
| | | throws Exception { |
| | | AttributeType type= getAttrType(attr); |
| | | String filterStr="(" + attr + "=*)"; |
| | | InternalClientConnection conn = getRootConnection(); |
| | | InternalSearchOperation operation = conn.processSearch(DN.valueOf(entryDN), |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.createFilterFromString(filterStr), |
| | | null); |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(" + attr + "=*)"); |
| | | InternalSearchOperation operation = getRootConnection().processSearch(request); |
| | | for (SearchResultEntry entry : operation.getSearchEntries()) { |
| | | for(String dn : dns) { |
| | | ByteString value = ByteString.valueOf(dn); |
| | |
| | | package org.opends.server.protocols.internal; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashSet; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | |
| | | import org.opends.server.core.ModifyDNOperation; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.protocols.ldap.LDAPAttribute; |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.opends.server.protocols.ldap.LDAPModification; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.AuthenticationInfo; |
| | | import org.opends.server.types.CancelRequest; |
| | | import org.opends.server.types.CancelResult; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DisconnectReason; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.RDN; |
| | | import org.opends.server.types.RawAttribute; |
| | | import org.opends.server.types.RawModification; |
| | | import org.opends.server.types.SearchResultReference; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test |
| | | public void testProcessSearch1() |
| | | throws Exception |
| | | public void testProcessSearch1() throws Exception |
| | | { |
| | | InternalClientConnection conn = getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(ByteString.valueOf(""), SearchScope.BASE_OBJECT, |
| | | LDAPFilter.decode("(objectClass=*)")); |
| | | SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertFalse(searchOperation.getSearchEntries().isEmpty()); |
| | | assertTrue(searchOperation.getSearchReferences().isEmpty()); |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test |
| | | public void testProcessSearch2() |
| | | throws Exception |
| | | public void testProcessSearch2() throws Exception |
| | | { |
| | | InternalClientConnection conn = getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(ByteString.valueOf(""), SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | LDAPFilter.decode("(objectClass=*)"), |
| | | new LinkedHashSet<String>()); |
| | | SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertFalse(searchOperation.getSearchEntries().isEmpty()); |
| | | assertTrue(searchOperation.getSearchReferences().isEmpty()); |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test |
| | | public void testProcessSearch3() |
| | | throws Exception |
| | | public void testProcessSearch3() throws Exception |
| | | { |
| | | TestInternalSearchListener searchListener = |
| | | new TestInternalSearchListener(); |
| | | TestInternalSearchListener searchListener = new TestInternalSearchListener(); |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(ByteString.valueOf(""), SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | LDAPFilter.decode("(objectClass=*)"), |
| | | new LinkedHashSet<String>(), searchListener); |
| | | SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request, searchListener); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertFalse(searchListener.getSearchEntries().isEmpty()); |
| | | assertTrue(searchListener.getSearchReferences().isEmpty()); |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test |
| | | public void testProcessSearch4() |
| | | throws Exception |
| | | public void testProcessSearch4() throws Exception |
| | | { |
| | | InternalClientConnection conn = getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(DN.rootDN(), SearchScope.BASE_OBJECT, |
| | | SearchFilter.createFilterFromString("(objectClass=*)")); |
| | | final SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertFalse(searchOperation.getSearchEntries().isEmpty()); |
| | | assertTrue(searchOperation.getSearchReferences().isEmpty()); |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test |
| | | public void testProcessSearch5() |
| | | throws Exception |
| | | public void testProcessSearch5() throws Exception |
| | | { |
| | | InternalClientConnection conn = getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(DN.rootDN(), SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.createFilterFromString("(objectClass=*)"), |
| | | new LinkedHashSet<String>()); |
| | | final SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertFalse(searchOperation.getSearchEntries().isEmpty()); |
| | | assertTrue(searchOperation.getSearchReferences().isEmpty()); |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test |
| | | public void testProcessSearch6() |
| | | throws Exception |
| | | public void testProcessSearch6() throws Exception |
| | | { |
| | | TestInternalSearchListener searchListener = |
| | | new TestInternalSearchListener(); |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(DN.rootDN(), SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.createFilterFromString("(objectClass=*)"), |
| | | new LinkedHashSet<String>(), searchListener); |
| | | final SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request, searchListener); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertFalse(searchListener.getSearchEntries().isEmpty()); |
| | | assertTrue(searchListener.getSearchReferences().isEmpty()); |
| | |
| | | throws Exception |
| | | { |
| | | InternalClientConnection conn = getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(ByteString.valueOf(""), SearchScope.BASE_OBJECT, |
| | | LDAPFilter.decode("(objectClass=*)")); |
| | | InternalSearchOperation searchOperation = conn.processSearch("", SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertFalse(searchOperation.getSearchEntries().isEmpty()); |
| | | assertTrue(searchOperation.getSearchReferences().isEmpty()); |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | 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.protocols.internal.InternalClientConnection.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | public void testConstructor1WithoutListener() |
| | | throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | new InternalSearchOperation(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), new ArrayList<Control>(), |
| | | InternalClientConnection conn = getRootConnection(); |
| | | new InternalSearchOperation(conn, nextOperationID(), |
| | | nextMessageID(), new ArrayList<Control>(), |
| | | ByteString.empty(), SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, |
| | | false, LDAPFilter.decode("(objectClass=*)"), |
| | |
| | | public void testConstructor1WithListener() |
| | | throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | new InternalSearchOperation(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), new ArrayList<Control>(), |
| | | InternalClientConnection conn = getRootConnection(); |
| | | new InternalSearchOperation(conn, nextOperationID(), |
| | | nextMessageID(), new ArrayList<Control>(), |
| | | ByteString.empty(), SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, |
| | | false, LDAPFilter.decode("(objectClass=*)"), |
| | |
| | | SearchFilter searchFilter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | new InternalSearchOperation(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), new ArrayList<Control>(), |
| | | InternalClientConnection conn = getRootConnection(); |
| | | new InternalSearchOperation(conn, nextOperationID(), |
| | | nextMessageID(), new ArrayList<Control>(), |
| | | DN.rootDN(), SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, |
| | | false, searchFilter, |
| | |
| | | SearchFilter searchFilter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | new InternalSearchOperation(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), new ArrayList<Control>(), |
| | | InternalClientConnection conn = getRootConnection(); |
| | | new InternalSearchOperation(conn, nextOperationID(), |
| | | nextMessageID(), new ArrayList<Control>(), |
| | | DN.rootDN(), SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, |
| | | false, searchFilter, |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testGetSearchEntriesAndReferences() |
| | | throws Exception |
| | | public void testGetSearchEntriesAndReferences() throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(ByteString.valueOf(""), SearchScope.BASE_OBJECT, |
| | | LDAPFilter.decode("(objectClass=*)")); |
| | | SearchRequest request = Requests.newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertFalse(searchOperation.getSearchEntries().isEmpty()); |
| | | assertTrue(searchOperation.getSearchReferences().isEmpty()); |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testAddSearchEntryWithoutListener() |
| | | throws Exception |
| | | public void testAddSearchEntryWithoutListener() throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new InternalSearchOperation(conn, nextOperationID(), |
| | | nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.empty(), |
| | | SearchScope.BASE_OBJECT, |
| | |
| | | public void testAddSearchEntryWithListener() |
| | | throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new InternalSearchOperation(conn, nextOperationID(), |
| | | nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.empty(), |
| | | SearchScope.BASE_OBJECT, |
| | |
| | | public void testAddSearchReferenceWithoutListener() |
| | | throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new InternalSearchOperation(conn, nextOperationID(), |
| | | nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.empty(), |
| | | SearchScope.BASE_OBJECT, |
| | |
| | | public void testAddSearchReferenceWithListener() |
| | | throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new InternalSearchOperation(conn, nextOperationID(), |
| | | nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.empty(), |
| | | SearchScope.BASE_OBJECT, |
| | |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.replication.common.ServerStatus; |
| | | import org.opends.server.replication.plugin.LDAPReplicationDomain; |
| | | import org.opends.server.replication.protocol.*; |
| | |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.opends.server.util.Base64; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | |
| | | import static org.opends.messages.TaskMessages.*; |
| | | import static org.opends.server.backends.task.TaskState.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | // Wait until the task completes. |
| | | int timeout = 2000; |
| | | |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectclass=*)"); |
| | | |
| | | long startMillisecs = System.currentTimeMillis(); |
| | | do |
| | | { |
| | | InternalSearchOperation searchOperation = connection.processSearch( |
| | | taskEntry.getName(), SearchScope.BASE_OBJECT, filter); |
| | | final SearchRequest request = newSearchRequest(taskEntry.getName(), SearchScope.BASE_OBJECT, "(objectclass=*)"); |
| | | InternalSearchOperation searchOperation = connection.processSearch(request); |
| | | Entry resultEntry = searchOperation.getSearchEntries().getFirst(); |
| | | |
| | | String completionTime = resultEntry.parseAttribute( |
| | |
| | | */ |
| | | package org.opends.server.replication; |
| | | |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Collection; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.concurrent.locks.Lock; |
| | | |
| | | import org.assertj.core.api.Assertions; |
| | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | |
| | | import org.opends.server.core.DeleteOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchListener; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.replication.common.ServerState; |
| | | import org.opends.server.replication.plugin.*; |
| | | import org.opends.server.replication.plugin.DomainFakeCfg; |
| | | import org.opends.server.replication.plugin.DummyReplicationDomain; |
| | | import org.opends.server.replication.plugin.GenerationIdChecksum; |
| | | import org.opends.server.replication.plugin.LDAPReplicationDomain; |
| | | import org.opends.server.replication.plugin.MultimasterReplication; |
| | | import org.opends.server.replication.protocol.ReplSessionSecurity; |
| | | import org.opends.server.replication.protocol.ReplicationMsg; |
| | | import org.opends.server.replication.protocol.Session; |
| | |
| | | import org.opends.server.replication.server.changelog.file.FileChangelogDB; |
| | | import org.opends.server.replication.server.changelog.je.JEChangelogDB; |
| | | import org.opends.server.replication.service.ReplicationBroker; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LockManager; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.SearchResultEntry; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | |
| | | import static org.forgerock.opendj.ldap.SearchScope.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | /** The tracer object for the debug logger */ |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | private static final Set<String> ALL_ATTRIBUTES = newSet("*", "+"); |
| | | private static final List<Control> NO_CONTROL = null; |
| | | |
| | | /** |
| | | * This is the generation id matching the memory test backend with its initial |
| | | * root entry o=test created. This matches the backend obtained calling: |
| | |
| | | Entry taskEntry = TestCaseUtils.addEntry(task); |
| | | |
| | | // Wait until the task completes. |
| | | SearchFilter filter = SearchFilter.createFilterFromString("(objectclass=*)"); |
| | | Entry resultEntry = null; |
| | | String completionTime = null; |
| | | long startMillisecs = System.currentTimeMillis(); |
| | | do |
| | | { |
| | | InternalSearchOperation searchOperation = |
| | | connection.processSearch(taskEntry.getName(), |
| | | SearchScope.BASE_OBJECT, |
| | | filter); |
| | | final SearchRequest request = newSearchRequest(taskEntry.getName(), SearchScope.BASE_OBJECT, "(objectclass=*)"); |
| | | InternalSearchOperation searchOperation = connection.processSearch(request); |
| | | if (searchOperation.getSearchEntries().isEmpty()) |
| | | { |
| | | continue; |
| | |
| | | { |
| | | long startTime = System.currentTimeMillis(); |
| | | |
| | | SearchFilter filter = SearchFilter.createFilterFromString("(objectclass=*)"); |
| | | Entry resultEntry = null; |
| | | TaskState taskState = null; |
| | | do |
| | | { |
| | | InternalSearchOperation searchOperation = |
| | | connection.processSearch(taskEntry.getName(), SearchScope.BASE_OBJECT, filter); |
| | | final SearchRequest request = newSearchRequest(taskEntry.getName(), SearchScope.BASE_OBJECT, "(objectclass=*)"); |
| | | InternalSearchOperation searchOperation = connection.processSearch(request); |
| | | resultEntry = searchOperation.getSearchEntries().getFirst(); |
| | | |
| | | // Check that the task state is as expected. |
| | |
| | | ResultCode expectedResultCode, int expectedNbEntries) throws Exception |
| | | { |
| | | InternalSearchOperation searchOp = null; |
| | | int sizeLimitZero = 0; |
| | | int timeLimitZero = 0; |
| | | boolean typesOnlyFalse = false; |
| | | InternalSearchListener noSearchListener = null; |
| | | int count = 0; |
| | | do |
| | | { |
| | | Thread.sleep(10); |
| | | searchOp = connection.processSearch(dn, scope, DereferenceAliasesPolicy.NEVER, sizeLimitZero, |
| | | timeLimitZero, typesOnlyFalse, filter, ALL_ATTRIBUTES, NO_CONTROL, noSearchListener); |
| | | final SearchRequest request = newSearchRequest(dn, scope, filter).addAttribute("*", "+"); |
| | | searchOp = connection.processSearch(request); |
| | | count++; |
| | | System.out.println(searchOp.getResultCode() + " " + searchOp.getSearchEntries().size()); |
| | | } |
| | | while (count < 300 && searchOp.getResultCode() != expectedResultCode && |
| | | searchOp.getSearchEntries().size() != expectedNbEntries); |
| | | while (count < 300 |
| | | && searchOp.getResultCode() != expectedResultCode |
| | | && searchOp.getSearchEntries().size() != expectedNbEntries); |
| | | |
| | | final List<SearchResultEntry> entries = searchOp.getSearchEntries(); |
| | | Assertions.assertThat(entries).hasSize(expectedNbEntries); |
| | |
| | | import org.opends.server.core.DeleteOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | | import org.opends.server.replication.common.*; |
| | | import org.opends.server.replication.protocol.*; |
| | |
| | | { |
| | | if (count++>0) |
| | | Thread.sleep(100); |
| | | op = connection.processSearch(dn, SearchScope.WHOLE_SUBTREE, monitorFilter); |
| | | final SearchRequest request = newSearchRequest(dn, SearchScope.WHOLE_SUBTREE, monitorFilter); |
| | | op = connection.processSearch(request); |
| | | } |
| | | while (op.getSearchEntries().isEmpty() && count < 100); |
| | | |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.opends.server.types.AttributeParser; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | |
| | | "Add of the task definition was not successful"); |
| | | |
| | | // Wait until the task completes. |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectclass=*)"); |
| | | final SearchRequest request = newSearchRequest(taskEntry.getName(), SearchScope.BASE_OBJECT, "(objectclass=*)"); |
| | | Entry resultEntry = null; |
| | | String completionTime = null; |
| | | long startMillisecs = System.currentTimeMillis(); |
| | |
| | | do |
| | | { |
| | | Thread.sleep(100); |
| | | InternalSearchOperation searchOperation = |
| | | connection.processSearch(taskEntry.getName(), |
| | | SearchScope.BASE_OBJECT, |
| | | filter); |
| | | InternalSearchOperation searchOperation = connection.processSearch(request); |
| | | resultEntry = searchOperation.getSearchEntries().getFirst(); |
| | | completionTime = parseAttribute(resultEntry, ATTR_TASK_COMPLETION_TIME).asString(); |
| | | timedOut = System.currentTimeMillis() - startMillisecs > 1000 * timeout; |