(CR-4811) Converted opendj3 code to use SearchRequest like API
SearchFilter.java, LDAPFilter.java:
Added objectClassPresent() to match the Filter.objectClassPresent().
InternalClientConnection.java:
Removed two processSearch() methods.
Requests.java:
Added a newSearchRequest(DN, SearchScope) which defaults the filter to "(objectclass=*)".
Converted a lot of code to use InternalClientConnection.processSearch().
| | |
| | | try |
| | | { |
| | | SearchRequestProtocolOp protocolOp = new SearchRequestProtocolOp( |
| | | ByteString.wrap(new byte[]{}), SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | 0, 0, |
| | | true, LDAPFilter.decode("(objectClass=*)"), attributes); |
| | | ByteString.empty(), SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, true, |
| | | LDAPFilter.objectClassPresent(), attributes); |
| | | byte opType; |
| | | LDAPMessage msg = |
| | | new LDAPMessage(DSMLServlet.nextMessageID(), protocolOp, controls); |
| | |
| | | conflict information could not be added. Operation: %s, Result: %s |
| | | ERR_CANNOT_RENAME_CONFLICT_ENTRY_58=An error happened trying to \ |
| | | rename a conflicting entry. DN: %s, Operation: %s, Result: %s |
| | | ERR_EXCEPTION_RENAME_CONFLICT_ENTRY_59=An Exception happened when \ |
| | | trying to rename a conflicting entry. DN: %s, Operation: %s, Stacktrace: %s |
| | | ERR_REPLICATION_COULD_NOT_CONNECT_61=The Replication is configured for \ |
| | | suffix %s but was not able to connect to any Replication Server |
| | | ERR_CHANGELOG_ERROR_SENDING_ERROR_65=An unexpected error occurred \ |
| | |
| | | ERR_BAD_HISTORICAL_56=Eintrag %s hat einige unbekannte historische Informatinoen enthalten. Dadurch k\u00f6nnen Inkonsistenzen f\u00fcr diesen Eintrag auftreten |
| | | ERR_CANNOT_ADD_CONFLICT_ATTRIBUTE_57=Es wurde ein Konflikt entdeckt, aber die Konfliktinformationen konnten nicht hinzugef\u00fcgt werden. Vorgang: %s, Ergebnis: %s |
| | | ERR_CANNOT_RENAME_CONFLICT_ENTRY_58=Bei dem Versuch, einen widerspr\u00fcchlichen Eintrag umzubenennen, ist ein Fehler aufgetreten. DN: %s, Vorgang: %s, Ergebnis: %s |
| | | ERR_EXCEPTION_RENAME_CONFLICT_ENTRY_59=Bei dem Versuch, einen widerspr\u00fcchlichen Eintrag umzubenennen, ist ein Ausnahmefehler aufgetreten. DN: %s, Vorgang: %s, Stacktrace: %s |
| | | ERR_REPLICATION_COULD_NOT_CONNECT_61=Die Replikation ist f\u00fcr Suffix %s konfiguriert, konnte jedoch keine Verbindung zu einem Replikationsserver herstellen |
| | | ERR_CHANGELOG_ERROR_SENDING_ERROR_65=Beim Senden einer Fehlernachricht an %s ist ein unerwarteter Fehler aufgetreten. Diese Verbindung wird geschlossen und erneut ge\u00f6ffnet |
| | | ERR_CHANGELOG_ERROR_SENDING_MSG_66=Beim Senden einer Nachricht an %s ist ein unerwarteter Fehler aufgetreten. Diese Verbindung wird geschlossen und erneut ge\u00f6ffnet |
| | |
| | | ERR_BAD_HISTORICAL_56=La entrada %s conten\u00eda informaci\u00f3n hist\u00f3rica desconocida. Es posible que esto genere incoherencias con respecto a esta entrada |
| | | ERR_CANNOT_ADD_CONFLICT_ATTRIBUTE_57=Se detect\u00f3 un conflicto pero no se pudo agregar su informaci\u00f3n. Operaci\u00f3n: %s, Resultado: %s |
| | | ERR_CANNOT_RENAME_CONFLICT_ENTRY_58=Se produjo un error al intentar cambiar el nombre de una entrada contradictoria. DN: %s, Operaci\u00f3n: %s, Resultado: %s |
| | | ERR_EXCEPTION_RENAME_CONFLICT_ENTRY_59=Se produjo una excepci\u00f3n al intentar cambiar el nombre de una entrada contradictoria. DN: %s, Operaci\u00f3n: %s, Stacktrace: %s |
| | | ERR_REPLICATION_COULD_NOT_CONNECT_61=La repetici\u00f3n est\u00e1 configurada para el sufijo %s, pero no pudo conectarse con ning\u00fan Servidor de repetici\u00f3n |
| | | ERR_CHANGELOG_ERROR_SENDING_ERROR_65=Se ha producido un error inesperado al enviar un mensaje de error a %s. Esta conexi\u00f3n se cerrar\u00e1 y volver\u00e1 a abrirse |
| | | ERR_CHANGELOG_ERROR_SENDING_MSG_66=Se ha producido un error inesperado al enviar un mensaje a %s. Esta conexi\u00f3n se cerrar\u00e1 y volver\u00e1 a abrirse |
| | |
| | | ERR_BAD_HISTORICAL_56=L'entr\u00e9e %s contenait des informations historiques inconnues, ce qui peut provoquer des incoh\u00e9rences pour cette entr\u00e9e |
| | | ERR_CANNOT_ADD_CONFLICT_ATTRIBUTE_57=Un conflit a \u00e9t\u00e9 d\u00e9tect\u00e9 mais des informations sur ce conflit n'ont pas pu \u00eatre ajout\u00e9es. Op\u00e9ration\u00a0: %s, R\u00e9sultat\u00a0: %s |
| | | ERR_CANNOT_RENAME_CONFLICT_ENTRY_58=Une erreur s'est produite lors de la tentative de renommage d'une entr\u00e9e conflictuelle. DN\u00a0: %s, Op\u00e9ration\u00a0: %s, R\u00e9sultat\u00a0: %s |
| | | ERR_EXCEPTION_RENAME_CONFLICT_ENTRY_59=Une exception s'est produite lors de la tentative de renommage d'une entr\u00e9e conflictuelle. DN\u00a0: %s, Op\u00e9ration\u00a0: %s, Stacktrace\u00a0: %s |
| | | ERR_REPLICATION_COULD_NOT_CONNECT_61=La r\u00e9plication est configur\u00e9e pour le suffixe %s mais n'a pu se connecter \u00e0 aucun serveur de r\u00e9plication |
| | | ERR_CHANGELOG_ERROR_SENDING_ERROR_65=Une erreur inattendue s'est produite lors de l'envoi d'un message d'erreur \u00e0 %s. Cette connexion va \u00eatre ferm\u00e9e, puis rouverte |
| | | ERR_CHANGELOG_ERROR_SENDING_MSG_66=Une erreur inattendue s'est produite lors de l'envoi d'un message \u00e0 %s. Cette connexion va \u00eatre ferm\u00e9e, puis rouverte |
| | |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.SearchResultEntry; |
| | | |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | |
| | | /** |
| | | * Check if information found in "cn=admin data" is coherent with |
| | | * cn=config. If and inconsistency is detected, we log a warning |
| | |
| | | // Look for a local server with the Ldap Port. |
| | | try |
| | | { |
| | | InternalSearchOperation op = internalConnection.processSearch( |
| | | "cn=Servers,cn=admin data", |
| | | SearchScope.SINGLE_LEVEL, "objectclass=*"); |
| | | SearchRequest request = newSearchRequest(DN.valueOf("cn=Servers,cn=admin data"), SearchScope.SINGLE_LEVEL); |
| | | InternalSearchOperation op = internalConnection.processSearch(request); |
| | | if (op.getResultCode() == ResultCode.SUCCESS) |
| | | { |
| | | Entry entry = null; |
| | |
| | | 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.types.*; |
| | | |
| | | import static org.opends.messages.AccessControlMessages.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | |
| | | /* |
| | | * TODO Evaluate making this class more efficient. |
| | |
| | | * the "#" token. |
| | | */ |
| | | private enum UserAttrType { |
| | | USERDN, GROUPDN, ROLEDN, URL, VALUE |
| | | } |
| | | USERDN, GROUPDN, ROLEDN, URL, VALUE; |
| | | |
| | | /** Filter used internal search. */ |
| | | private static SearchFilter filter; |
| | | private static UserAttrType getType(String expr) throws AciException { |
| | | if("userdn".equalsIgnoreCase(expr)) { |
| | | return UserAttrType.USERDN; |
| | | } else if("groupdn".equalsIgnoreCase(expr)) { |
| | | return UserAttrType.GROUPDN; |
| | | } else if("roledn".equalsIgnoreCase(expr)) { |
| | | return UserAttrType.ROLEDN; |
| | | } else if("ldapurl".equalsIgnoreCase(expr)) { |
| | | return UserAttrType.URL; |
| | | } |
| | | return UserAttrType.VALUE; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Used to create an attribute type that can compare the value below in |
| | | * an entry returned from an internal search. |
| | | */ |
| | | private String attrStr=null; |
| | | private String attrStr; |
| | | |
| | | /** |
| | | * Used to compare a attribute value returned from a search against this |
| | | * value which might have been defined in the ACI userattr rule. |
| | | */ |
| | | private String attrVal=null; |
| | | private String attrVal; |
| | | |
| | | /** Contains the type of the userattr, one of the above enumerations. */ |
| | | private UserAttrType userAttrType=null; |
| | | private UserAttrType userAttrType; |
| | | |
| | | /** An enumeration representing the bind rule type. */ |
| | | private EnumBindRuleType type=null; |
| | | private EnumBindRuleType type; |
| | | |
| | | /** The class used to hold the parent inheritance information. */ |
| | | private ParentInheritance parentInheritance=null; |
| | | |
| | | static { |
| | | /* |
| | | * Set up the filter used to search private and public contexts. |
| | | */ |
| | | try { |
| | | filter=SearchFilter.createFilterFromString("(objectclass=*)"); |
| | | } catch (DirectoryException ex) { |
| | | //TODO should never happen, error message? |
| | | } |
| | | } |
| | | private ParentInheritance parentInheritance; |
| | | |
| | | /** |
| | | * Create an non-USERDN/GROUPDN instance of the userattr keyword class. |
| | |
| | | WARN_ACI_SYNTAX_INVALID_USERATTR_EXPRESSION.get(expression); |
| | | throw new AciException(message); |
| | | } |
| | | UserAttrType userAttrType=getType(vals[1]); |
| | | UserAttrType userAttrType = UserAttrType.getType(vals[1]); |
| | | switch (userAttrType) { |
| | | case GROUPDN: |
| | | case USERDN: { |
| | |
| | | case ROLEDN: { |
| | | //The roledn keyword is not supported. Throw an exception with |
| | | //a message if it is seen in the expression. |
| | | LocalizableMessage message = |
| | | WARN_ACI_SYNTAX_ROLEDN_NOT_SUPPORTED.get(expression); |
| | | throw new AciException(message); |
| | | throw new AciException(WARN_ACI_SYNTAX_ROLEDN_NOT_SUPPORTED.get(expression)); |
| | | } |
| | | } |
| | | return new UserAttr(vals[0], vals[1], userAttrType, type); |
| | |
| | | EnumEvalResult matched= EnumEvalResult.FALSE; |
| | | boolean undefined=false; |
| | | AttributeType attrType; |
| | | if((attrType = DirectoryServer.getAttributeType(attrStr)) == null) |
| | | if((attrType = DirectoryServer.getAttributeType(attrStr)) == null) { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attrStr); |
| | | final SearchRequest request = newSearchRequest(evalCtx.getClientDN(), SearchScope.BASE_OBJECT, filter); |
| | | } |
| | | final SearchRequest request = newSearchRequest(evalCtx.getClientDN(), SearchScope.BASE_OBJECT); |
| | | InternalSearchOperation op = getRootConnection().processSearch(request); |
| | | LinkedList<SearchResultEntry> result = op.getSearchEntries(); |
| | | if (!result.isEmpty()) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Parses the substring after the '#' character to determine the userattr |
| | | * type. |
| | | * @param expr The string with the substring. |
| | | * @return An enumeration containing the type. |
| | | * @throws AciException If the substring contains an invalid type (roledn |
| | | * or groupdn). |
| | | */ |
| | | private static UserAttrType getType(String expr) throws AciException { |
| | | UserAttrType userAttrType; |
| | | if(expr.equalsIgnoreCase("userdn")) |
| | | userAttrType=UserAttrType.USERDN; |
| | | else if(expr.equalsIgnoreCase("groupdn")) { |
| | | userAttrType=UserAttrType.GROUPDN; |
| | | /* |
| | | LocalizableMessage message = WARN_ACI_SYNTAX_INVALID_USERATTR_KEYWORD.get( |
| | | "The groupdn userattr" + |
| | | "keyword is not supported."); |
| | | throw new AciException(message); |
| | | */ |
| | | } else if(expr.equalsIgnoreCase("roledn")) { |
| | | userAttrType=UserAttrType.ROLEDN; |
| | | /* |
| | | LocalizableMessage message = WARN_ACI_SYNTAX_INVALID_USERATTR_KEYWORD.get( |
| | | "The roledn userattr" + |
| | | "keyword is not supported."); |
| | | throw new AciException(message); |
| | | */ |
| | | } else if(expr.equalsIgnoreCase("ldapurl")) |
| | | userAttrType=UserAttrType.URL; |
| | | else |
| | | userAttrType=UserAttrType.VALUE; |
| | | return userAttrType; |
| | | } |
| | | |
| | | /** |
| | | * Evaluate an URL userattr type. Look into the resource entry for the |
| | | * specified attribute and values. Assume it is an URL. Decode it an try |
| | | * and match it against the client entry attribute. |
| | |
| | | EnumEvalResult matched= EnumEvalResult.FALSE; |
| | | boolean undefined=false; |
| | | AttributeType attrType; |
| | | if((attrType = DirectoryServer.getAttributeType(attrStr)) == null) |
| | | if((attrType = DirectoryServer.getAttributeType(attrStr)) == null) { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attrStr); |
| | | } |
| | | List<Attribute> attrs=evalCtx.getResourceEntry().getAttribute(attrType); |
| | | if(!attrs.isEmpty()) { |
| | | for(Attribute a : attrs) { |
| | |
| | | AttributeType attrType=parentInheritance.getAttributeType(); |
| | | DN baseDN=parentInheritance.getBaseDN(); |
| | | if(baseDN != null) { |
| | | if (evalCtx.getResourceEntry().hasAttribute(attrType)) |
| | | if (evalCtx.getResourceEntry().hasAttribute(attrType)) { |
| | | matched=GroupDN.evaluate(evalCtx.getResourceEntry(), |
| | | evalCtx,attrType, baseDN); |
| | | } |
| | | } else { |
| | | for(int i=0;((i < numLevels) && !stop); i++ ) { |
| | | for(int i=0;(i < numLevels && !stop); i++ ) { |
| | | //The ROLEDN keyword will always enter this statement. The others |
| | | //might. For the add operation, the resource itself (level 0) |
| | | //must never be allowed to give access. |
| | |
| | | matched = |
| | | evalEntryAttr(evalCtx.getResourceEntry(), |
| | | evalCtx,attrType); |
| | | if(matched.equals(EnumEvalResult.TRUE)) |
| | | if(matched.equals(EnumEvalResult.TRUE)) { |
| | | stop=true; |
| | | } |
| | | } |
| | | } else { |
| | | DN pDN = getDNParentLevel(levels[i], evalCtx.getResourceDN()); |
| | | if(pDN == null) |
| | | if(pDN == null) { |
| | | continue; |
| | | final SearchRequest request = newSearchRequest(pDN, SearchScope.BASE_OBJECT, filter) |
| | | } |
| | | final SearchRequest request = newSearchRequest(pDN, SearchScope.BASE_OBJECT) |
| | | .addAttribute(parentInheritance.getAttrTypeStr()); |
| | | InternalSearchOperation op = getRootConnection().processSearch(request); |
| | | LinkedList<SearchResultEntry> result = op.getSearchEntries(); |
| | |
| | | Entry e = result.getFirst(); |
| | | if(e.hasAttribute(attrType)) { |
| | | matched = evalEntryAttr(e, evalCtx, attrType); |
| | | if(matched.equals(EnumEvalResult.TRUE)) |
| | | if(matched.equals(EnumEvalResult.TRUE)) { |
| | | stop=true; |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | private DN getDNParentLevel(int l, DN dn) { |
| | | int rdns=dn.size(); |
| | | if(l > rdns) |
| | | if(l > rdns) { |
| | | return null; |
| | | } |
| | | DN theDN=dn; |
| | | for(int i=0; i < l;i++) { |
| | | theDN=theDN.parent(); |
| | |
| | | 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.*; |
| | |
| | | if (clientConnection instanceof JmxClientConnection) { |
| | | op = ((JmxClientConnection)clientConnection).processSearch( |
| | | ByteString.valueOf(configEntryDN.toString()), |
| | | SearchScope.BASE_OBJECT, getTrueFilter()); |
| | | SearchScope.BASE_OBJECT, LDAPFilter.objectClassPresent()); |
| | | } |
| | | else if (clientConnection instanceof InternalClientConnection) { |
| | | SearchRequest request = newSearchRequest(configEntryDN, SearchScope.BASE_OBJECT, "(objectclass=*)"); |
| | | SearchRequest request = newSearchRequest(configEntryDN, SearchScope.BASE_OBJECT); |
| | | op = ((InternalClientConnection) clientConnection).processSearch(request); |
| | | } |
| | | // BUG : op may be null |
| | |
| | | } |
| | | } |
| | | |
| | | 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 |
| | |
| | | if (clientConnection instanceof JmxClientConnection) { |
| | | op = ((JmxClientConnection)clientConnection).processSearch( |
| | | ByteString.valueOf(configEntryDN.toString()), |
| | | SearchScope.BASE_OBJECT, getTrueFilter()); |
| | | SearchScope.BASE_OBJECT, LDAPFilter.objectClassPresent()); |
| | | } |
| | | 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); |
| | | } |
| | | SearchRequest request = newSearchRequest(configEntryDN, SearchScope.BASE_OBJECT); |
| | | op = ((InternalClientConnection) clientConnection).processSearch(request); |
| | | } |
| | | |
| | | if (op == null) |
| | |
| | | PasswordPolicyStateExtendedOperationHandlerCfg config) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | // Construct the filter that will be used to retrieve user entries. |
| | | try |
| | | { |
| | | userFilter = SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | // This should never happen. |
| | | logger.traceException(e); |
| | | } |
| | | |
| | | userFilter = SearchFilter.objectClassPresent(); |
| | | |
| | | // Construct the set of request attributes. |
| | | requestAttributes = new LinkedHashSet<String>(2); |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | 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.*; |
| | |
| | | modifyDNRecord.getNewSuperiorDN()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 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 filterString The string representation of 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. |
| | | * |
| | | * @throws DirectoryException If the provided filter string cannot |
| | | * be decoded as a search filter. |
| | | */ |
| | | public InternalSearchOperation processSearch(String rawBaseDN, |
| | | SearchScope scope, |
| | | String filterString) |
| | | throws DirectoryException |
| | | { |
| | | return processSearch(Requests.newSearchRequest(rawBaseDN, scope, filterString), 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 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. |
| | | */ |
| | | public InternalSearchOperation |
| | | processSearch(ByteString rawBaseDN, |
| | | SearchScope scope, |
| | | DereferenceAliasesPolicy derefPolicy, |
| | | int sizeLimit, int timeLimit, |
| | | boolean typesOnly, RawFilter filter, |
| | | Set<String> attributes, |
| | | List<Control> controls, |
| | | InternalSearchListener searchListener) |
| | | { |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation(this, nextOperationID(), |
| | | nextMessageID(), controls, |
| | | rawBaseDN, scope, derefPolicy, |
| | | sizeLimit, timeLimit, |
| | | typesOnly, filter, attributes, |
| | | searchListener); |
| | | |
| | | searchOperation.run(); |
| | | return searchOperation; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Processes an internal search operation with the provided |
| | | * information. |
| | |
| | | */ |
| | | public InternalSearchOperation processSearch(final SearchRequest request, InternalSearchListener searchListener) |
| | | { |
| | | // FIXME uncomment this after we move to the SDK: |
| | | // if (Filter.objectClassPresent().equals(filter)) { |
| | | // filter = Filter.alwaysTrue(); |
| | | // } |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation(this, nextOperationID(), nextMessageID(), |
| | | request.getControls(), request.getName(), request.getScope(), |
| | |
| | | return newSearchRequest(name, scope, SearchFilter.createFilterFromString(filter)); |
| | | } |
| | | |
| | | /** |
| | | * Return a new search request object. |
| | | * |
| | | * @param name |
| | | * the dn |
| | | * @param scope |
| | | * the search scope |
| | | * @return a new search request object |
| | | * @see #newSearchRequest(DN, SearchScope, SearchFilter, String...) |
| | | */ |
| | | public static SearchRequest newSearchRequest(final DN name, final SearchScope scope) { |
| | | return newSearchRequest(name, scope, SearchFilter.objectClassPresent()); |
| | | } |
| | | |
| | | private Requests() { |
| | | // Prevent instantiation. |
| | | } |
| | |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.HashSet; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.StringTokenizer; |
| | | import java.util.Collection; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | |
| | | { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | private static LDAPFilter objectClassPresent; |
| | | |
| | | // The set of subAny elements for substring filters. |
| | | private ArrayList<ByteString> subAnyElements; |
| | | |
| | |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Returns the {@code objectClass} presence filter {@code (objectClass=*)}. |
| | | * |
| | | * @return The {@code objectClass} presence filter {@code (objectClass=*)}. |
| | | */ |
| | | public static LDAPFilter objectClassPresent() |
| | | { |
| | | if (objectClassPresent == null) |
| | | { |
| | | try |
| | | { |
| | | objectClassPresent = LDAPFilter.decode("(objectclass=*)"); |
| | | } |
| | | catch (LDAPException canNeverHappen) |
| | | { |
| | | logger.traceException(canNeverHappen); |
| | | } |
| | | } |
| | | return objectClassPresent; |
| | | } |
| | | } |
| | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | 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.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.Operation; |
| | | import org.opends.server.types.OperationType; |
| | | import org.opends.server.types.RDN; |
| | | import org.opends.server.types.operation.*; |
| | | import org.opends.server.util.LDIFReader; |
| | |
| | | + "entry " + getBaseDNString()); |
| | | } |
| | | |
| | | InternalSearchOperation search; |
| | | try |
| | | { |
| | | // 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 |
| | | SearchRequest request = newSearchRequest(getBaseDN(), SearchScope.BASE_OBJECT) |
| | | .addAttribute(REPLICATION_GENERATION_ID, REPLICATION_FRACTIONAL_EXCLUDE, REPLICATION_FRACTIONAL_INCLUDE); |
| | | InternalSearchOperation search = conn.processSearch(request); |
| | | |
| | | if (search.getResultCode() != ResultCode.SUCCESS |
| | | && search.getResultCode() != ResultCode.NO_SUCH_OBJECT) |
| | |
| | | return; |
| | | } |
| | | |
| | | LDAPFilter filter = LDAPFilter.createEqualityFilter(DS_SYNC_CONFLICT, |
| | | ByteString.valueOf(freedDN.toString())); |
| | | SearchFilter filter; |
| | | try |
| | | { |
| | | filter = LDAPFilter.createEqualityFilter(DS_SYNC_CONFLICT, |
| | | ByteString.valueOf(freedDN.toString())).toSearchFilter(); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | // can not happen? |
| | | logger.traceException(e); |
| | | return; |
| | | } |
| | | |
| | | InternalSearchOperation searchOp = conn.processSearch( |
| | | ByteString.valueOf(getBaseDNString()), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | 0, 0, false, filter, |
| | | USER_AND_REPL_OPERATIONAL_ATTRS, null, null); |
| | | SearchRequest request = newSearchRequest(getBaseDN(), SearchScope.WHOLE_SUBTREE, filter) |
| | | .addAttribute(USER_AND_REPL_OPERATIONAL_ATTRS); |
| | | InternalSearchOperation searchOp = conn.processSearch(request); |
| | | |
| | | Entry entryToRename = null; |
| | | CSN entryToRenameCSN = null; |
| | |
| | | { |
| | | return null; |
| | | } |
| | | try |
| | | final SearchRequest request = newSearchRequest(dn, SearchScope.BASE_OBJECT) |
| | | .addAttribute(ENTRYUUID_ATTRIBUTE_NAME); |
| | | final InternalSearchOperation search = getRootConnection().processSearch(request); |
| | | final SearchResultEntry resultEntry = getFirstResult(search); |
| | | if (resultEntry != null) |
| | | { |
| | | 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) |
| | | { |
| | | return getEntryUUID(resultEntry); |
| | | } |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | // never happens because the filter is always valid. |
| | | return getEntryUUID(resultEntry); |
| | | } |
| | | return null; |
| | | } |
| | |
| | | */ |
| | | boolean conflict = false; |
| | | |
| | | // Find an rename child entries. |
| | | try |
| | | // Find and rename child entries. |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.SINGLE_LEVEL) |
| | | .addAttribute(ENTRYUUID_ATTRIBUTE_NAME, HISTORICAL_ATTRIBUTE_NAME); |
| | | InternalSearchOperation op = conn.processSearch(request); |
| | | if (op.getResultCode() == ResultCode.SUCCESS) |
| | | { |
| | | 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()) |
| | | { |
| | | for (SearchResultEntry entry : op.getSearchEntries()) |
| | | { |
| | | /* |
| | | * Check the ADD and ModRDN date of the child entry |
| | | * (All of them, not only the one that are newer than the DEL op) |
| | | * and keep the entry as a conflicting entry. |
| | | */ |
| | | conflict = true; |
| | | renameConflictEntry(conflictOp, entry.getName(), getEntryUUID(entry)); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | // log error and information for the REPAIR tool. |
| | | logger.error(ERR_CANNOT_RENAME_CONFLICT_ENTRY, |
| | | entryDN, conflictOp, op.getResultCode()); |
| | | /* |
| | | * Check the ADD and ModRDN date of the child entry |
| | | * (All of them, not only the one that are newer than the DEL op) |
| | | * and keep the entry as a conflicting entry. |
| | | */ |
| | | conflict = true; |
| | | renameConflictEntry(conflictOp, entry.getName(), getEntryUUID(entry)); |
| | | } |
| | | } |
| | | catch (DirectoryException e) |
| | | else |
| | | { |
| | | // log error and information for the REPAIR tool. |
| | | logger.error(ERR_EXCEPTION_RENAME_CONFLICT_ENTRY, |
| | | entryDN, conflictOp, stackTraceToSingleLineString(e)); |
| | | logger.error(ERR_CANNOT_RENAME_CONFLICT_ENTRY, entryDN, conflictOp, op.getResultCode()); |
| | | } |
| | | |
| | | return conflict; |
| | |
| | | * Search the database entry that is used to periodically |
| | | * save the generation id |
| | | */ |
| | | final SearchRequest request = newSearchRequest(getBaseDN(), SearchScope.BASE_OBJECT, "(objectclass=*)") |
| | | final SearchRequest request = newSearchRequest(getBaseDN(), SearchScope.BASE_OBJECT) |
| | | .addAttribute(REPLICATION_GENERATION_ID); |
| | | InternalSearchOperation search = conn.processSearch(request); |
| | | if (search.getResultCode() == ResultCode.NO_SUCH_OBJECT) |
| | |
| | | { |
| | | Set<DN> baseDNs = Collections.singleton(DN.valueOf("")); |
| | | Set<DN> groupDNs = Collections.emptySet(); |
| | | Set<SearchFilter> filters = Collections.singleton( |
| | | SearchFilter.createFilterFromString("(objectclass=*)")); |
| | | Set<SearchFilter> filters = Collections.singleton(SearchFilter.objectClassPresent()); |
| | | |
| | | // To avoid the configuration in cn=config just |
| | | // create a rule and register it into the DirectoryServer |
| | |
| | | this.scope = scope; |
| | | } |
| | | |
| | | if (rawFilter == null) |
| | | if (rawFilter != null) |
| | | { |
| | | this.rawFilter = "(objectClass=*)"; |
| | | this.rawFilter = rawFilter; |
| | | } |
| | | else |
| | | { |
| | | this.rawFilter = rawFilter; |
| | | setFilter(SearchFilter.objectClassPresent()); |
| | | } |
| | | |
| | | if (extensions == null) |
| | |
| | | package org.opends.server.types; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.HashSet; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | |
| | | { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | private static SearchFilter objectClassPresent; |
| | | |
| | | // The attribute type for this filter. |
| | | private final AttributeType attributeType; |
| | | |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Returns the {@code objectClass} presence filter {@code (objectClass=*)}. |
| | | * |
| | | * @return The {@code objectClass} presence filter {@code (objectClass=*)}. |
| | | */ |
| | | public static SearchFilter objectClassPresent() |
| | | { |
| | | if (objectClassPresent == null) |
| | | { |
| | | try |
| | | { |
| | | objectClassPresent = SearchFilter.createFilterFromString("(objectclass=*)"); |
| | | } |
| | | catch (DirectoryException canNeverHappen) |
| | | { |
| | | logger.traceException(canNeverHappen); |
| | | } |
| | | } |
| | | return objectClassPresent; |
| | | } |
| | | } |
| | |
| | | public void searchingWithoutPrivilegeShouldFail() throws Exception |
| | | { |
| | | AuthenticationInfo nonPrivilegedUser = new AuthenticationInfo(); |
| | | |
| | | InternalClientConnection conn = new InternalClientConnection(nonPrivilegedUser); |
| | | InternalSearchOperation op = conn.processSearch("cn=changelog", SearchScope.WHOLE_SUBTREE, "(objectclass=*)"); |
| | | |
| | | SearchRequest request = Requests.newSearchRequest(DN.valueOf("cn=changelog"), SearchScope.WHOLE_SUBTREE); |
| | | InternalSearchOperation op = conn.processSearch(request); |
| | | |
| | | assertEquals(op.getResultCode(), ResultCode.INSUFFICIENT_ACCESS_RIGHTS); |
| | | assertEquals(op.getErrorMessage().toMessage(), NOTE_SEARCH_CHANGELOG_INSUFFICIENT_PRIVILEGES.get()); |
| | |
| | | import org.opends.server.core.ModifyDNOperation; |
| | | 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.tasks.LdifFileWriter; |
| | | import org.opends.server.tasks.TasksTestCase; |
| | | import org.opends.server.tools.LDAPModify; |
| | |
| | | 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.*; |
| | | |
| | | /** |
| | |
| | | @Test |
| | | public void testBaseSearch() throws Exception |
| | | { |
| | | InternalSearchOperation searchOperation = |
| | | getRootConnection().processSearch("o=ldif", SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | SearchRequest request = newSearchRequest(DN.valueOf("o=ldif"), SearchScope.BASE_OBJECT); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | } |
| | |
| | | public void testBaseSearchNonMatchingFilter() throws Exception |
| | | { |
| | | InternalSearchOperation searchOperation = |
| | | getRootConnection().processSearch("o=ldif", SearchScope.BASE_OBJECT, "(o=not ldif)"); |
| | | getRootConnection().processSearch(newSearchRequest("o=ldif", SearchScope.BASE_OBJECT, "(o=not ldif)")); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 0); |
| | | } |
| | |
| | | @Test |
| | | public void testBaseSearchNoSuchEntry() throws Exception |
| | | { |
| | | InternalClientConnection conn = getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch("o=nonexistent2,o=nonexistent1,o=ldif", |
| | | SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | DN dn = DN.valueOf("o=nonexistent2,o=nonexistent1,o=ldif"); |
| | | SearchRequest request = newSearchRequest(dn, SearchScope.BASE_OBJECT); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.NO_SUCH_OBJECT); |
| | | assertEquals(searchOperation.getMatchedDN(), DN.valueOf("o=ldif")); |
| | | } |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test |
| | | public void testSingleLevelSearch() |
| | | throws Exception |
| | | public void testSingleLevelSearch() throws Exception |
| | | { |
| | | InternalClientConnection conn = getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch("o=ldif", SearchScope.SINGLE_LEVEL, |
| | | "(objectClass=*)"); |
| | | SearchRequest request = newSearchRequest(DN.valueOf("o=ldif"), SearchScope.SINGLE_LEVEL); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | } |
| | |
| | | @Test |
| | | public void testSubtreeSearch() throws Exception |
| | | { |
| | | InternalClientConnection conn = getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch("o=ldif", SearchScope.WHOLE_SUBTREE, |
| | | "(uid=user.1)"); |
| | | SearchRequest request = newSearchRequest("o=ldif", SearchScope.WHOLE_SUBTREE, "(uid=user.1)"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | } |
| | |
| | | @Test |
| | | public void testSubordinateSubtreeSearch() throws Exception |
| | | { |
| | | InternalClientConnection conn = getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch("o=ldif", SearchScope.SUBORDINATES, |
| | | "(uid=user.1)"); |
| | | SearchRequest request = newSearchRequest("o=ldif", SearchScope.SUBORDINATES, "(uid=user.1)"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | } |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test |
| | | public void testHasSubordinates() |
| | | throws Exception |
| | | public void testHasSubordinates() throws Exception |
| | | { |
| | | Backend<?> b = DirectoryServer.getBackend("ldifRoot"); |
| | | assertNotNull(b); |
| | |
| | | { |
| | | InternalClientConnection conn = getRootConnection(); |
| | | DN baseDN = DN.valueOf("o=bogus,cn=schema"); |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | SearchFilter filter = SearchFilter.objectClassPresent(); |
| | | |
| | | for (SearchScope scope : SearchScope.values()) |
| | | { |
| | |
| | | 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.Attribute; |
| | | import org.opends.server.types.Attributes; |
| | |
| | | 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.protocols.internal.Requests.*; |
| | | import static org.opends.server.types.Attributes.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | public void testSearchScope() throws Exception { |
| | | InternalClientConnection conn = getRootConnection(); |
| | | |
| | | InternalSearchOperation search = conn.processSearch("dc=test,dc=com", SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | DN dn = DN.valueOf("dc=test,dc=com"); |
| | | InternalSearchOperation search = conn.processSearch(newSearchRequest(dn, SearchScope.BASE_OBJECT)); |
| | | List<SearchResultEntry> result = search.getSearchEntries(); |
| | | |
| | | assertEquals(result.size(), 1); |
| | | assertEquals(result.get(0).getName().toString(), "dc=test,dc=com"); |
| | | assertEquals(result.get(0).getName(), dn); |
| | | |
| | | search = conn.processSearch("dc=test,dc=com", SearchScope.BASE_OBJECT, "(ou=People)"); |
| | | search = conn.processSearch(newSearchRequest(dn, SearchScope.BASE_OBJECT, "(ou=People)")); |
| | | result = search.getSearchEntries(); |
| | | |
| | | assertEquals(result.size(), 0); |
| | | |
| | | search = conn.processSearch("dc=test,dc=com", SearchScope.SINGLE_LEVEL, "(objectClass=*)"); |
| | | search = conn.processSearch(newSearchRequest(dn, SearchScope.SINGLE_LEVEL)); |
| | | result = search.getSearchEntries(); |
| | | |
| | | assertEquals(result.size(), 1); |
| | | assertEquals(result.get(0).getName().toString(), |
| | | "ou=People,dc=test,dc=com"); |
| | | |
| | | search = conn.processSearch("dc=test,dc=com", SearchScope.SUBORDINATES, "(objectClass=*)"); |
| | | search = conn.processSearch(newSearchRequest(dn, SearchScope.SUBORDINATES)); |
| | | result = search.getSearchEntries(); |
| | | |
| | | assertEquals(result.size(), 13); |
| | | for (Entry entry : result) { |
| | | assertThat(entry.getName().toString()).isNotEqualTo("dc=test,dc=com"); |
| | | assertThat(entry.getName()).isNotEqualTo(dn); |
| | | } |
| | | |
| | | search = conn.processSearch("dc=test,dc=com", SearchScope.WHOLE_SUBTREE, "(objectClass=*)"); |
| | | search = conn.processSearch(newSearchRequest(dn, SearchScope.WHOLE_SUBTREE)); |
| | | result = search.getSearchEntries(); |
| | | |
| | | assertEquals(result.size(), 14); |
| | |
| | | ) throws Exception |
| | | { |
| | | InternalClientConnection conn = getRootConnection(); |
| | | SearchFilter filter = SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | SearchFilter filter = SearchFilter.objectClassPresent(); |
| | | |
| | | // Test is performed with each and every scope |
| | | for (SearchScope scope: SearchScope.values()) |
| | |
| | | package org.opends.server.backends.jeb; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.TreeSet; |
| | | |
| | | 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.DirectoryServerTestCase; |
| | |
| | | import org.opends.server.controls.VLVRequestControl; |
| | | import org.opends.server.controls.VLVResponseControl; |
| | | 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.Requests; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.types.*; |
| | | import org.testng.Assert; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | | 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.*; |
| | | |
| | |
| | | * @throws Exception If an unexpected problem occurred. |
| | | */ |
| | | @Test( dependsOnMethods = { "testAdd" } ) |
| | | public void testInternalSearchByOffsetOneOffset() |
| | | throws Exception |
| | | public void testInternalSearchByOffsetOneOffset() throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | ArrayList<Control> requestControls = new ArrayList<Control>(); |
| | | requestControls.add(new ServerSideSortRequestControl(sortOrder)); |
| | | requestControls.add(new VLVRequestControl(0, 3, 1, 0)); |
| | | |
| | | InternalSearchOperation internalSearch = |
| | | new InternalSearchOperation(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), requestControls, |
| | | DN.valueOf("dc=vlvtest,dc=com"), SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.createFilterFromString("(objectClass=*)"), |
| | | null, null); |
| | | |
| | | internalSearch.run(); |
| | | SearchRequest request = Requests.newSearchRequest(DN.valueOf("dc=vlvtest,dc=com"), SearchScope.WHOLE_SUBTREE) |
| | | .addControl(new ServerSideSortRequestControl(sortOrder)) |
| | | .addControl(new VLVRequestControl(0, 3, 1, 0)); |
| | | InternalSearchOperation internalSearch = getRootConnection().processSearch(request); |
| | | assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | ArrayList<DN> expectedDNOrder = new ArrayList<DN>(); |
| | | expectedDNOrder.add(aaccfJohnsonDN); // Aaccf |
| | | expectedDNOrder.add(aaronZimmermanDN); // Aaron |
| | | expectedDNOrder.add(albertZimmermanDN); // Albert, bigger |
| | | expectedDNOrder.add(albertSmithDN); // Albert, smaller sn |
| | | |
| | | ArrayList<DN> returnedDNOrder = new ArrayList<DN>(); |
| | | for (Entry e : internalSearch.getSearchEntries()) |
| | | { |
| | | returnedDNOrder.add(e.getName()); |
| | | } |
| | | |
| | | assertEquals(returnedDNOrder, expectedDNOrder); |
| | | assertThat(getDNs(internalSearch)).isEqualTo(expectedDNOrder()); |
| | | |
| | | List<Control> responseControls = internalSearch.getResponseControls(); |
| | | assertNotNull(responseControls); |
| | |
| | | { |
| | | if (c.getOID().equals(OID_SERVER_SIDE_SORT_RESPONSE_CONTROL)) |
| | | { |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | sortResponse = ServerSideSortResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | sortResponse = (ServerSideSortResponseControl)c; |
| | | } |
| | | sortResponse = asServerSideSortResponseControl(c); |
| | | } |
| | | else if (c.getOID().equals(OID_VLV_RESPONSE_CONTROL)) |
| | | { |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | vlvResponse = VLVResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | vlvResponse = (VLVResponseControl)c; |
| | | } |
| | | vlvResponse = asVLVResponseControl(c); |
| | | } |
| | | else |
| | | { |
| | | fail("Response control with unexpected OID " + c.getOID()); |
| | | Assert.fail("Response control with unexpected OID " + c.getOID()); |
| | | } |
| | | } |
| | | |
| | |
| | | assertEquals(vlvResponse.getContentCount(), 10); |
| | | } |
| | | |
| | | private ArrayList<DN> getDNs(InternalSearchOperation internalSearch) |
| | | { |
| | | ArrayList<DN> results = new ArrayList<DN>(); |
| | | for (Entry e : internalSearch.getSearchEntries()) |
| | | { |
| | | results.add(e.getName()); |
| | | } |
| | | return results; |
| | | } |
| | | |
| | | private List<DN> expectedDNOrder() |
| | | { |
| | | return Arrays.asList( |
| | | aaccfJohnsonDN, // Aaccf |
| | | aaronZimmermanDN, // Aaron |
| | | albertZimmermanDN, // Albert, bigger |
| | | albertSmithDN); // Albert, smaller sn |
| | | } |
| | | |
| | | /** |
| | | * Tests performing an internal search using the VLV control to retrieve a |
| | | * subset of the entries using an offset of zero, which should be treated like |
| | |
| | | * @throws Exception If an unexpected problem occurred. |
| | | */ |
| | | @Test( dependsOnMethods = { "testAdd" } ) |
| | | public void testInternalSearchByOffsetZeroOffset() |
| | | throws Exception |
| | | public void testInternalSearchByOffsetZeroOffset() throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | ArrayList<Control> requestControls = new ArrayList<Control>(); |
| | | requestControls.add(new ServerSideSortRequestControl(sortOrder)); |
| | | requestControls.add(new VLVRequestControl(0, 3, 0, 0)); |
| | | |
| | | InternalSearchOperation internalSearch = |
| | | new InternalSearchOperation(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), requestControls, |
| | | DN.valueOf("dc=vlvtest,dc=com"), SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.createFilterFromString("(objectClass=*)"), |
| | | null, null); |
| | | |
| | | internalSearch.run(); |
| | | final SearchRequest request = Requests.newSearchRequest(DN.valueOf("dc=vlvtest,dc=com"), SearchScope.WHOLE_SUBTREE) |
| | | .addControl(new ServerSideSortRequestControl(sortOrder)) |
| | | .addControl(new VLVRequestControl(0, 3, 0, 0)); |
| | | InternalSearchOperation internalSearch = getRootConnection().processSearch(request); |
| | | assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | ArrayList<DN> expectedDNOrder = new ArrayList<DN>(); |
| | | expectedDNOrder.add(aaccfJohnsonDN); // Aaccf |
| | | expectedDNOrder.add(aaronZimmermanDN); // Aaron |
| | | expectedDNOrder.add(albertZimmermanDN); // Albert, bigger |
| | | expectedDNOrder.add(albertSmithDN); // Albert, smaller sn |
| | | |
| | | ArrayList<DN> returnedDNOrder = new ArrayList<DN>(); |
| | | for (Entry e : internalSearch.getSearchEntries()) |
| | | { |
| | | returnedDNOrder.add(e.getName()); |
| | | } |
| | | |
| | | assertEquals(returnedDNOrder, expectedDNOrder); |
| | | assertThat(getDNs(internalSearch)).isEqualTo(expectedDNOrder()); |
| | | |
| | | List<Control> responseControls = internalSearch.getResponseControls(); |
| | | assertNotNull(responseControls); |
| | |
| | | { |
| | | if (c.getOID().equals(OID_SERVER_SIDE_SORT_RESPONSE_CONTROL)) |
| | | { |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | sortResponse = ServerSideSortResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | sortResponse = (ServerSideSortResponseControl)c; |
| | | } |
| | | sortResponse = asServerSideSortResponseControl(c); |
| | | } |
| | | else if (c.getOID().equals(OID_VLV_RESPONSE_CONTROL)) |
| | | { |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | vlvResponse = VLVResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | vlvResponse = (VLVResponseControl)c; |
| | | } |
| | | vlvResponse = asVLVResponseControl(c); |
| | | } |
| | | else |
| | | { |
| | | fail("Response control with unexpected OID " + c.getOID()); |
| | | Assert.fail("Response control with unexpected OID " + c.getOID()); |
| | | } |
| | | } |
| | | |
| | |
| | | * @throws Exception If an unexpected problem occurred. |
| | | */ |
| | | @Test( dependsOnMethods = { "testAdd" } ) |
| | | public void testInternalSearchByOffsetThreeOffset() |
| | | throws Exception |
| | | public void testInternalSearchByOffsetThreeOffset() throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | ArrayList<Control> requestControls = new ArrayList<Control>(); |
| | | requestControls.add(new ServerSideSortRequestControl(sortOrder)); |
| | | requestControls.add(new VLVRequestControl(0, 3, 3, 0)); |
| | | |
| | | InternalSearchOperation internalSearch = |
| | | new InternalSearchOperation(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), requestControls, |
| | | DN.valueOf("dc=vlvtest,dc=com"), SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.createFilterFromString("(objectClass=*)"), |
| | | null, null); |
| | | |
| | | internalSearch.run(); |
| | | final SearchRequest request = Requests.newSearchRequest(DN.valueOf("dc=vlvtest,dc=com"), SearchScope.WHOLE_SUBTREE) |
| | | .addControl(new ServerSideSortRequestControl(sortOrder)) |
| | | .addControl(new VLVRequestControl(0, 3, 3, 0)); |
| | | InternalSearchOperation internalSearch = getRootConnection().processSearch(request); |
| | | assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | ArrayList<DN> expectedDNOrder = new ArrayList<DN>(); |
| | |
| | | expectedDNOrder.add(lowercaseMcGeeDN); // lowercase |
| | | expectedDNOrder.add(margaretJonesDN); // Maggie |
| | | |
| | | ArrayList<DN> returnedDNOrder = new ArrayList<DN>(); |
| | | for (Entry e : internalSearch.getSearchEntries()) |
| | | { |
| | | returnedDNOrder.add(e.getName()); |
| | | } |
| | | |
| | | assertEquals(returnedDNOrder, expectedDNOrder); |
| | | assertThat(getDNs(internalSearch)).isEqualTo(expectedDNOrder); |
| | | |
| | | List<Control> responseControls = internalSearch.getResponseControls(); |
| | | assertNotNull(responseControls); |
| | |
| | | { |
| | | if (c.getOID().equals(OID_SERVER_SIDE_SORT_RESPONSE_CONTROL)) |
| | | { |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | sortResponse = ServerSideSortResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | sortResponse = (ServerSideSortResponseControl)c; |
| | | } |
| | | sortResponse = asServerSideSortResponseControl(c); |
| | | } |
| | | else if (c.getOID().equals(OID_VLV_RESPONSE_CONTROL)) |
| | | { |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | vlvResponse = VLVResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | vlvResponse = (VLVResponseControl)c; |
| | | } |
| | | vlvResponse = asVLVResponseControl(c); |
| | | } |
| | | else |
| | | { |
| | | fail("Response control with unexpected OID " + c.getOID()); |
| | | Assert.fail("Response control with unexpected OID " + c.getOID()); |
| | | } |
| | | } |
| | | |
| | |
| | | * @throws Exception If an unexpected problem occurred. |
| | | */ |
| | | @Test( dependsOnMethods = { "testAdd" } ) |
| | | public void testInternalSearchByOffsetNegativeOffset() |
| | | throws Exception |
| | | public void testInternalSearchByOffsetNegativeOffset() throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | ArrayList<Control> requestControls = new ArrayList<Control>(); |
| | | requestControls.add(new ServerSideSortRequestControl(sortOrder)); |
| | | requestControls.add(new VLVRequestControl(0, 3, -1, 0)); |
| | | |
| | | InternalSearchOperation internalSearch = |
| | | new InternalSearchOperation(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), requestControls, |
| | | DN.valueOf("dc=vlvtest,dc=com"), SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.createFilterFromString("(objectClass=*)"), |
| | | null, null); |
| | | |
| | | internalSearch.run(); |
| | | final SearchRequest request = Requests.newSearchRequest(DN.valueOf("dc=vlvtest,dc=com"), SearchScope.WHOLE_SUBTREE) |
| | | .addControl(new ServerSideSortRequestControl(sortOrder)) |
| | | .addControl(new VLVRequestControl(0, 3, -1, 0)); |
| | | InternalSearchOperation internalSearch = getRootConnection().processSearch(request); |
| | | |
| | | // It will be successful because it's not a critical control. |
| | | assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | { |
| | | if (c.getOID().equals(OID_VLV_RESPONSE_CONTROL)) |
| | | { |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | vlvResponse = VLVResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | vlvResponse = (VLVResponseControl)c; |
| | | } |
| | | vlvResponse = asVLVResponseControl(c); |
| | | } |
| | | } |
| | | |
| | |
| | | * @throws Exception If an unexpected problem occurred. |
| | | */ |
| | | @Test( dependsOnMethods = { "testAdd" } ) |
| | | public void testInternalSearchByOffsetNegativeStartPosition() |
| | | throws Exception |
| | | public void testInternalSearchByOffsetNegativeStartPosition() throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | ArrayList<Control> requestControls = new ArrayList<Control>(); |
| | | requestControls.add(new ServerSideSortRequestControl(sortOrder)); |
| | | requestControls.add(new VLVRequestControl(3, 3, 1, 0)); |
| | | |
| | | InternalSearchOperation internalSearch = |
| | | new InternalSearchOperation(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), requestControls, |
| | | DN.valueOf("dc=vlvtest,dc=com"), SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.createFilterFromString("(objectClass=*)"), |
| | | null, null); |
| | | |
| | | internalSearch.run(); |
| | | final SearchRequest request = Requests.newSearchRequest(DN.valueOf("dc=vlvtest,dc=com"), SearchScope.WHOLE_SUBTREE) |
| | | .addControl(new ServerSideSortRequestControl(sortOrder)) |
| | | .addControl(new VLVRequestControl(3, 3, 1, 0)); |
| | | InternalSearchOperation internalSearch = getRootConnection().processSearch(request); |
| | | |
| | | // It will be successful because it's not a critical control. |
| | | assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | { |
| | | if (c.getOID().equals(OID_VLV_RESPONSE_CONTROL)) |
| | | { |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | vlvResponse = VLVResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | vlvResponse = (VLVResponseControl)c; |
| | | } |
| | | vlvResponse = asVLVResponseControl(c); |
| | | } |
| | | } |
| | | |
| | |
| | | * @throws Exception If an unexpected problem occurred. |
| | | */ |
| | | @Test( dependsOnMethods = { "testAdd" } ) |
| | | public void testInternalSearchByOffsetStartPositionTooHigh() |
| | | throws Exception |
| | | public void testInternalSearchByOffsetStartPositionTooHigh() throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | ArrayList<Control> requestControls = new ArrayList<Control>(); |
| | | requestControls.add(new ServerSideSortRequestControl(sortOrder)); |
| | | requestControls.add(new VLVRequestControl(3, 3, 30, 0)); |
| | | |
| | | InternalSearchOperation internalSearch = |
| | | new InternalSearchOperation(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), requestControls, |
| | | DN.valueOf("dc=vlvtest,dc=com"), SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.createFilterFromString("(objectClass=*)"), |
| | | null, null); |
| | | |
| | | internalSearch.run(); |
| | | final SearchRequest request = Requests.newSearchRequest(DN.valueOf("dc=vlvtest,dc=com"), SearchScope.WHOLE_SUBTREE) |
| | | .addControl(new ServerSideSortRequestControl(sortOrder)) |
| | | .addControl(new VLVRequestControl(3, 3, 30, 0)); |
| | | InternalSearchOperation internalSearch = getRootConnection().processSearch(request); |
| | | |
| | | assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | |
| | | expectedDNOrder.add(zorroDN); // No first name |
| | | expectedDNOrder.add(suffixDN); // No sort attributes |
| | | |
| | | ArrayList<DN> returnedDNOrder = new ArrayList<DN>(); |
| | | for (Entry e : internalSearch.getSearchEntries()) |
| | | { |
| | | returnedDNOrder.add(e.getName()); |
| | | } |
| | | |
| | | assertEquals(returnedDNOrder, expectedDNOrder); |
| | | assertThat(getDNs(internalSearch)).isEqualTo(expectedDNOrder); |
| | | |
| | | List<Control> responseControls = internalSearch.getResponseControls(); |
| | | assertNotNull(responseControls); |
| | |
| | | { |
| | | if (c.getOID().equals(OID_VLV_RESPONSE_CONTROL)) |
| | | { |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | vlvResponse = VLVResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | vlvResponse = (VLVResponseControl)c; |
| | | } |
| | | vlvResponse = asVLVResponseControl(c); |
| | | } |
| | | } |
| | | |
| | |
| | | * @throws Exception If an unexpected problem occurred. |
| | | */ |
| | | @Test( dependsOnMethods = { "testAdd" } ) |
| | | public void testInternalSearchByOffsetIncompleteAfterCount() |
| | | throws Exception |
| | | public void testInternalSearchByOffsetIncompleteAfterCount() throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | final SearchRequest request = Requests.newSearchRequest(DN.valueOf("dc=vlvtest,dc=com"), SearchScope.WHOLE_SUBTREE) |
| | | .addControl(new ServerSideSortRequestControl(sortOrder)) |
| | | .addControl(new VLVRequestControl(0, 4, 7, 0)); |
| | | |
| | | ArrayList<Control> requestControls = new ArrayList<Control>(); |
| | | requestControls.add(new ServerSideSortRequestControl(sortOrder)); |
| | | requestControls.add(new VLVRequestControl(0, 4, 7, 0)); |
| | | |
| | | InternalSearchOperation internalSearch = |
| | | new InternalSearchOperation(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), requestControls, |
| | | DN.valueOf("dc=vlvtest,dc=com"), SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.createFilterFromString("(objectClass=*)"), |
| | | null, null); |
| | | |
| | | internalSearch.run(); |
| | | InternalSearchOperation internalSearch = getRootConnection().processSearch(request); |
| | | assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | ArrayList<DN> expectedDNOrder = new ArrayList<DN>(); |
| | |
| | | expectedDNOrder.add(zorroDN); // No first name |
| | | expectedDNOrder.add(suffixDN); // No sort attributes |
| | | |
| | | ArrayList<DN> returnedDNOrder = new ArrayList<DN>(); |
| | | for (Entry e : internalSearch.getSearchEntries()) |
| | | { |
| | | returnedDNOrder.add(e.getName()); |
| | | } |
| | | |
| | | assertEquals(returnedDNOrder, expectedDNOrder); |
| | | assertThat(getDNs(internalSearch)).isEqualTo(expectedDNOrder); |
| | | |
| | | List<Control> responseControls = internalSearch.getResponseControls(); |
| | | assertNotNull(responseControls); |
| | |
| | | { |
| | | if (c.getOID().equals(OID_SERVER_SIDE_SORT_RESPONSE_CONTROL)) |
| | | { |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | sortResponse = ServerSideSortResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | sortResponse = (ServerSideSortResponseControl)c; |
| | | } |
| | | sortResponse = asServerSideSortResponseControl(c); |
| | | } |
| | | else if (c.getOID().equals(OID_VLV_RESPONSE_CONTROL)) |
| | | { |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | vlvResponse = VLVResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | vlvResponse = (VLVResponseControl)c; |
| | | } |
| | | vlvResponse = asVLVResponseControl(c); |
| | | } |
| | | else |
| | | { |
| | | fail("Response control with unexpected OID " + c.getOID()); |
| | | Assert.fail("Response control with unexpected OID " + c.getOID()); |
| | | } |
| | | } |
| | | |
| | |
| | | assertEquals(vlvResponse.getContentCount(), 10); |
| | | } |
| | | |
| | | private VLVResponseControl asVLVResponseControl(Control c) throws DirectoryException |
| | | { |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | return VLVResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl) c).getValue()); |
| | | } |
| | | return (VLVResponseControl) c; |
| | | } |
| | | |
| | | private ServerSideSortResponseControl asServerSideSortResponseControl(Control c) throws DirectoryException |
| | | { |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | return ServerSideSortResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl) c).getValue()); |
| | | } |
| | | return (ServerSideSortResponseControl) c; |
| | | } |
| | | |
| | | /** |
| | | * Tests performing an internal search using the VLV control to retrieve a |
| | | * subset of the entries using an assertion value before any actual value in |
| | |
| | | * @throws Exception If an unexpected problem occurred. |
| | | */ |
| | | @Test( dependsOnMethods = { "testAdd" } ) |
| | | public void testInternalSearchByValueBeforeAll() |
| | | throws Exception |
| | | public void testInternalSearchByValueBeforeAll() throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | final SearchRequest request = Requests.newSearchRequest(DN.valueOf("dc=vlvtest,dc=com"), SearchScope.WHOLE_SUBTREE) |
| | | .addControl(new ServerSideSortRequestControl(sortOrder)) |
| | | .addControl(new VLVRequestControl(0, 3, ByteString.valueOf("a"))); |
| | | InternalSearchOperation internalSearch = getRootConnection().processSearch(request); |
| | | |
| | | ArrayList<Control> requestControls = new ArrayList<Control>(); |
| | | requestControls.add(new ServerSideSortRequestControl(sortOrder)); |
| | | requestControls.add(new VLVRequestControl(0, 3, ByteString.valueOf("a"))); |
| | | |
| | | InternalSearchOperation internalSearch = |
| | | new InternalSearchOperation(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), requestControls, |
| | | DN.valueOf("dc=vlvtest,dc=com"), SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.createFilterFromString("(objectClass=*)"), |
| | | null, null); |
| | | |
| | | internalSearch.run(); |
| | | assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | ArrayList<DN> expectedDNOrder = new ArrayList<DN>(); |
| | | expectedDNOrder.add(aaccfJohnsonDN); // Aaccf |
| | | expectedDNOrder.add(aaronZimmermanDN); // Aaron |
| | | expectedDNOrder.add(albertZimmermanDN); // Albert, lower entry ID |
| | | expectedDNOrder.add(albertSmithDN); // Albert, higher entry ID |
| | | |
| | | ArrayList<DN> returnedDNOrder = new ArrayList<DN>(); |
| | | for (Entry e : internalSearch.getSearchEntries()) |
| | | { |
| | | returnedDNOrder.add(e.getName()); |
| | | } |
| | | |
| | | assertEquals(returnedDNOrder, expectedDNOrder); |
| | | assertThat(getDNs(internalSearch)).isEqualTo(expectedDNOrder()); |
| | | |
| | | List<Control> responseControls = internalSearch.getResponseControls(); |
| | | assertNotNull(responseControls); |
| | |
| | | { |
| | | if (c.getOID().equals(OID_SERVER_SIDE_SORT_RESPONSE_CONTROL)) |
| | | { |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | sortResponse = ServerSideSortResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | sortResponse = (ServerSideSortResponseControl)c; |
| | | } |
| | | sortResponse = asServerSideSortResponseControl(c); |
| | | } |
| | | else if (c.getOID().equals(OID_VLV_RESPONSE_CONTROL)) |
| | | { |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | vlvResponse = VLVResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | vlvResponse = (VLVResponseControl)c; |
| | | } |
| | | vlvResponse = asVLVResponseControl(c); |
| | | } |
| | | else |
| | | { |
| | | fail("Response control with unexpected OID " + c.getOID()); |
| | | Assert.fail("Response control with unexpected OID " + c.getOID()); |
| | | } |
| | | } |
| | | |
| | |
| | | * @throws Exception If an unexpected problem occurred. |
| | | */ |
| | | @Test( dependsOnMethods = { "testAdd" } ) |
| | | public void testInternalSearchByValueMatchesFirst() |
| | | throws Exception |
| | | public void testInternalSearchByValueMatchesFirst() throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | final SearchRequest request = Requests.newSearchRequest(DN.valueOf("dc=vlvtest,dc=com"), SearchScope.WHOLE_SUBTREE) |
| | | .addControl(new ServerSideSortRequestControl(sortOrder)) |
| | | .addControl(new VLVRequestControl(0, 3, ByteString.valueOf("aaccf"))); |
| | | |
| | | ArrayList<Control> requestControls = new ArrayList<Control>(); |
| | | requestControls.add(new ServerSideSortRequestControl(sortOrder)); |
| | | requestControls.add(new VLVRequestControl(0, 3, |
| | | ByteString.valueOf("aaccf"))); |
| | | |
| | | InternalSearchOperation internalSearch = |
| | | new InternalSearchOperation(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), requestControls, |
| | | DN.valueOf("dc=vlvtest,dc=com"), SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.createFilterFromString("(objectClass=*)"), |
| | | null, null); |
| | | |
| | | internalSearch.run(); |
| | | InternalSearchOperation internalSearch = getRootConnection().processSearch(request); |
| | | assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | ArrayList<DN> expectedDNOrder = new ArrayList<DN>(); |
| | | expectedDNOrder.add(aaccfJohnsonDN); // Aaccf |
| | | expectedDNOrder.add(aaronZimmermanDN); // Aaron |
| | | expectedDNOrder.add(albertZimmermanDN); // Albert, lower entry ID |
| | | expectedDNOrder.add(albertSmithDN); // Albert, higher entry ID |
| | | |
| | | ArrayList<DN> returnedDNOrder = new ArrayList<DN>(); |
| | | for (Entry e : internalSearch.getSearchEntries()) |
| | | { |
| | | returnedDNOrder.add(e.getName()); |
| | | } |
| | | |
| | | assertEquals(returnedDNOrder, expectedDNOrder); |
| | | assertThat(getDNs(internalSearch)).isEqualTo(expectedDNOrder()); |
| | | |
| | | List<Control> responseControls = internalSearch.getResponseControls(); |
| | | assertNotNull(responseControls); |
| | |
| | | { |
| | | if (c.getOID().equals(OID_SERVER_SIDE_SORT_RESPONSE_CONTROL)) |
| | | { |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | sortResponse = ServerSideSortResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | sortResponse = (ServerSideSortResponseControl)c; |
| | | } |
| | | sortResponse = asServerSideSortResponseControl(c); |
| | | } |
| | | else if (c.getOID().equals(OID_VLV_RESPONSE_CONTROL)) |
| | | { |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | vlvResponse = VLVResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | vlvResponse = (VLVResponseControl)c; |
| | | } |
| | | vlvResponse = asVLVResponseControl(c); |
| | | } |
| | | else |
| | | { |
| | | fail("Response control with unexpected OID " + c.getOID()); |
| | | Assert.fail("Response control with unexpected OID " + c.getOID()); |
| | | } |
| | | } |
| | | |
| | |
| | | * @throws Exception If an unexpected problem occurred. |
| | | */ |
| | | @Test( dependsOnMethods = { "testAdd" } ) |
| | | public void testInternalSearchByValueMatchesThird() |
| | | throws Exception |
| | | public void testInternalSearchByValueMatchesThird() throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | final SearchRequest request = Requests.newSearchRequest(DN.valueOf("dc=vlvtest,dc=com"), SearchScope.WHOLE_SUBTREE) |
| | | .addControl(new ServerSideSortRequestControl(sortOrder)) |
| | | .addControl(new VLVRequestControl(0, 3, ByteString.valueOf("albert"))); |
| | | |
| | | ArrayList<Control> requestControls = new ArrayList<Control>(); |
| | | requestControls.add(new ServerSideSortRequestControl(sortOrder)); |
| | | requestControls.add(new VLVRequestControl(0, 3, |
| | | ByteString.valueOf("albert"))); |
| | | |
| | | InternalSearchOperation internalSearch = |
| | | new InternalSearchOperation(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), requestControls, |
| | | DN.valueOf("dc=vlvtest,dc=com"), SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.createFilterFromString("(objectClass=*)"), |
| | | null, null); |
| | | |
| | | internalSearch.run(); |
| | | InternalSearchOperation internalSearch = getRootConnection().processSearch(request); |
| | | assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | ArrayList<DN> expectedDNOrder = new ArrayList<DN>(); |
| | |
| | | expectedDNOrder.add(lowercaseMcGeeDN); // lowercase |
| | | expectedDNOrder.add(margaretJonesDN); // Maggie |
| | | |
| | | ArrayList<DN> returnedDNOrder = new ArrayList<DN>(); |
| | | for (Entry e : internalSearch.getSearchEntries()) |
| | | { |
| | | returnedDNOrder.add(e.getName()); |
| | | } |
| | | |
| | | assertEquals(returnedDNOrder, expectedDNOrder); |
| | | assertThat(getDNs(internalSearch)).isEqualTo(expectedDNOrder); |
| | | |
| | | List<Control> responseControls = internalSearch.getResponseControls(); |
| | | assertNotNull(responseControls); |
| | |
| | | { |
| | | if (c.getOID().equals(OID_SERVER_SIDE_SORT_RESPONSE_CONTROL)) |
| | | { |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | sortResponse = ServerSideSortResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | sortResponse = (ServerSideSortResponseControl)c; |
| | | } |
| | | sortResponse = asServerSideSortResponseControl(c); |
| | | } |
| | | else if (c.getOID().equals(OID_VLV_RESPONSE_CONTROL)) |
| | | { |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | vlvResponse = VLVResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | vlvResponse = (VLVResponseControl)c; |
| | | } |
| | | vlvResponse = asVLVResponseControl(c); |
| | | } |
| | | else |
| | | { |
| | | fail("Response control with unexpected OID " + c.getOID()); |
| | | Assert.fail("Response control with unexpected OID " + c.getOID()); |
| | | } |
| | | } |
| | | |
| | |
| | | * @throws Exception If an unexpected problem occurred. |
| | | */ |
| | | @Test( dependsOnMethods = { "testAdd" } ) |
| | | public void testInternalSearchByValueMatchesThirdWithBeforeCount() |
| | | throws Exception |
| | | public void testInternalSearchByValueMatchesThirdWithBeforeCount() throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | final SearchRequest request = Requests.newSearchRequest(DN.valueOf("dc=vlvtest,dc=com"), SearchScope.WHOLE_SUBTREE) |
| | | .addControl(new ServerSideSortRequestControl(sortOrder)) |
| | | .addControl(new VLVRequestControl(1, 3, ByteString.valueOf("albert"))); |
| | | |
| | | ArrayList<Control> requestControls = new ArrayList<Control>(); |
| | | requestControls.add(new ServerSideSortRequestControl(sortOrder)); |
| | | requestControls.add(new VLVRequestControl(1, 3, |
| | | ByteString.valueOf("albert"))); |
| | | |
| | | InternalSearchOperation internalSearch = |
| | | new InternalSearchOperation(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), requestControls, |
| | | DN.valueOf("dc=vlvtest,dc=com"), SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.createFilterFromString("(objectClass=*)"), |
| | | null, null); |
| | | |
| | | internalSearch.run(); |
| | | InternalSearchOperation internalSearch = getRootConnection().processSearch(request); |
| | | assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | ArrayList<DN> expectedDNOrder = new ArrayList<DN>(); |
| | |
| | | expectedDNOrder.add(lowercaseMcGeeDN); // lowercase |
| | | expectedDNOrder.add(margaretJonesDN); // Maggie |
| | | |
| | | ArrayList<DN> returnedDNOrder = new ArrayList<DN>(); |
| | | for (Entry e : internalSearch.getSearchEntries()) |
| | | { |
| | | returnedDNOrder.add(e.getName()); |
| | | } |
| | | |
| | | assertEquals(returnedDNOrder, expectedDNOrder); |
| | | assertThat(getDNs(internalSearch)).isEqualTo(expectedDNOrder); |
| | | |
| | | List<Control> responseControls = internalSearch.getResponseControls(); |
| | | assertNotNull(responseControls); |
| | |
| | | { |
| | | if (c.getOID().equals(OID_SERVER_SIDE_SORT_RESPONSE_CONTROL)) |
| | | { |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | sortResponse = ServerSideSortResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | sortResponse = (ServerSideSortResponseControl)c; |
| | | } |
| | | sortResponse = asServerSideSortResponseControl(c); |
| | | } |
| | | else if (c.getOID().equals(OID_VLV_RESPONSE_CONTROL)) |
| | | { |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | vlvResponse = VLVResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | vlvResponse = (VLVResponseControl)c; |
| | | } |
| | | vlvResponse = asVLVResponseControl(c); |
| | | } |
| | | else |
| | | { |
| | | fail("Response control with unexpected OID " + c.getOID()); |
| | | Assert.fail("Response control with unexpected OID " + c.getOID()); |
| | | } |
| | | } |
| | | |
| | |
| | | * @throws Exception If an unexpected problem occurred. |
| | | */ |
| | | @Test( dependsOnMethods = { "testAdd" } ) |
| | | public void testInternalSearchByValueAfterAll() |
| | | throws Exception |
| | | public void testInternalSearchByValueAfterAll() throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | ArrayList<Control> requestControls = new ArrayList<Control>(); |
| | | requestControls.add(new ServerSideSortRequestControl(sortOrder)); |
| | | requestControls.add(new VLVRequestControl(0, 3, ByteString.valueOf("zz"))); |
| | | |
| | | InternalSearchOperation internalSearch = |
| | | new InternalSearchOperation(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), requestControls, |
| | | DN.valueOf("dc=vlvtest,dc=com"), SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.createFilterFromString("(objectClass=*)"), |
| | | null, null); |
| | | |
| | | internalSearch.run(); |
| | | final SearchRequest request = Requests.newSearchRequest(DN.valueOf("dc=vlvtest,dc=com"), SearchScope.WHOLE_SUBTREE) |
| | | .addControl(new ServerSideSortRequestControl(sortOrder)) |
| | | .addControl(new VLVRequestControl(0, 3, ByteString.valueOf("zz"))); |
| | | InternalSearchOperation internalSearch = getRootConnection().processSearch(request); |
| | | |
| | | // It will be successful because the control isn't critical. |
| | | assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | expectedDNOrder.add(zorroDN); // No first name |
| | | expectedDNOrder.add(suffixDN); // No sort attributes |
| | | |
| | | ArrayList<DN> returnedDNOrder = new ArrayList<DN>(); |
| | | for (Entry e : internalSearch.getSearchEntries()) |
| | | { |
| | | returnedDNOrder.add(e.getName()); |
| | | } |
| | | |
| | | assertEquals(returnedDNOrder, expectedDNOrder); |
| | | assertThat(getDNs(internalSearch)).isEqualTo(expectedDNOrder); |
| | | |
| | | List<Control> responseControls = internalSearch.getResponseControls(); |
| | | assertNotNull(responseControls); |
| | |
| | | { |
| | | if (c.getOID().equals(OID_VLV_RESPONSE_CONTROL)) |
| | | { |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | vlvResponse = VLVResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | vlvResponse = (VLVResponseControl)c; |
| | | } |
| | | vlvResponse = asVLVResponseControl(c); |
| | | } |
| | | } |
| | | |
| | |
| | | SearchRequestProtocolOp searchRequest = |
| | | new SearchRequestProtocolOp(ByteString.valueOf("o=test"), |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, |
| | | 0, false, |
| | | LDAPFilter.decode("(objectClass=*)"), |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | LDAPFilter.objectClassPresent(), |
| | | new LinkedHashSet<String>()); |
| | | |
| | | List<Control> controls = new ArrayList<Control>(); |
| | |
| | | |
| | | //Create a persistent search request. |
| | | Set<PersistentSearchChangeType> changeTypes = EnumSet.of(ADD, DELETE, MODIFY, MODIFY_DN); |
| | | SearchRequest request = newSearchRequest("o=test", SearchScope.BASE_OBJECT, "(objectClass=*)") |
| | | SearchRequest request = newSearchRequest(DN.valueOf("o=test"), SearchScope.BASE_OBJECT) |
| | | .setTypesOnly(true) |
| | | .addAttribute("cn") |
| | | .addControl(new PersistentSearchControl(changeTypes, true, true)); |
| | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | // Make sure that both entries exist. |
| | | final SearchRequest request = newSearchRequest(parentBaseDN, SearchScope.WHOLE_SUBTREE, "(objectClass=*)"); |
| | | final SearchRequest request = newSearchRequest(parentBaseDN, SearchScope.WHOLE_SUBTREE); |
| | | InternalSearchOperation internalSearch = conn.processSearch(request); |
| | | assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(internalSearch.getSearchEntries().size(), 2); |
| | |
| | | |
| | | |
| | | // Verify that we can see both entries with a subtree search. |
| | | final SearchRequest request = newSearchRequest(parentBaseDN, SearchScope.WHOLE_SUBTREE, "(objectClass=*)"); |
| | | final SearchRequest request = newSearchRequest(parentBaseDN, SearchScope.WHOLE_SUBTREE); |
| | | InternalSearchOperation internalSearch = getRootConnection().processSearch(request); |
| | | assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(internalSearch.getSearchEntries().size(), 2); |
| | |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | // Verify that a subtree search can see all three entries. |
| | | final SearchRequest request = newSearchRequest(parentBaseDN, SearchScope.WHOLE_SUBTREE, "(objectClass=*)"); |
| | | final SearchRequest request = newSearchRequest(parentBaseDN, SearchScope.WHOLE_SUBTREE); |
| | | assertSearchResultsSize(request, 3); |
| | | |
| | | |
| | |
| | | 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.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | // group operations correctly. |
| | | InternalClientConnection conn0 = new InternalClientConnection(DN.rootDN()); |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation(conn0, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), null, DN.rootDN(), |
| | | SearchScope.BASE_OBJECT, |
| | | new InternalSearchOperation(conn0, nextOperationID(), nextMessageID(), null, |
| | | DN.rootDN(), SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.createFilterFromString("(objectClass=*)"), null, |
| | | null); |
| | | SearchFilter.objectClassPresent(), null, null); |
| | | |
| | | assertFalse(conn0.isMemberOf(group1, null)); |
| | | assertFalse(conn0.isMemberOf(group2, null)); |
| | |
| | | // group operations correctly. |
| | | InternalClientConnection conn1 = new InternalClientConnection(user1DN); |
| | | searchOperation = |
| | | new InternalSearchOperation(conn1, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), null, DN.rootDN(), |
| | | new InternalSearchOperation(conn1, nextOperationID(), |
| | | nextMessageID(), null, DN.rootDN(), |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.createFilterFromString("(objectClass=*)"), null, |
| | | null); |
| | | SearchFilter.objectClassPresent(), null, null); |
| | | |
| | | assertTrue(conn1.isMemberOf(group1, null)); |
| | | assertFalse(conn1.isMemberOf(group2, null)); |
| | |
| | | // group operations correctly. |
| | | InternalClientConnection conn2 = new InternalClientConnection(user2DN); |
| | | searchOperation = |
| | | new InternalSearchOperation(conn2, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), null, DN.rootDN(), |
| | | new InternalSearchOperation(conn2, nextOperationID(), |
| | | nextMessageID(), null, DN.rootDN(), |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.createFilterFromString("(objectClass=*)"), null, |
| | | null); |
| | | SearchFilter.objectClassPresent(), null, null); |
| | | |
| | | assertTrue(conn2.isMemberOf(group1, null)); |
| | | assertTrue(conn2.isMemberOf(group2, null)); |
| | |
| | | // group operations correctly. |
| | | InternalClientConnection conn3 = new InternalClientConnection(user3DN); |
| | | searchOperation = |
| | | new InternalSearchOperation(conn3, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), null, DN.rootDN(), |
| | | new InternalSearchOperation(conn3, nextOperationID(), |
| | | nextMessageID(), null, DN.rootDN(), |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.createFilterFromString("(objectClass=*)"), null, |
| | | null); |
| | | SearchFilter.objectClassPresent(), null, null); |
| | | |
| | | assertFalse(conn3.isMemberOf(group1, null)); |
| | | assertTrue(conn3.isMemberOf(group2, null)); |
| | |
| | | |
| | | |
| | | // Perform a filtered iteration across the member DNs. |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | memberList = groupInstance.getMembers(DN.valueOf("o=test"), |
| | | SearchScope.WHOLE_SUBTREE, filter); |
| | | memberList = groupInstance.getMembers( |
| | | DN.valueOf("o=test"), SearchScope.WHOLE_SUBTREE, SearchFilter.objectClassPresent()); |
| | | while (memberList.hasMoreMembers()) |
| | | { |
| | | try |
| | |
| | | |
| | | |
| | | // Perform a filtered iteration across the member entries. |
| | | filter = SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | memberList = groupInstance.getMembers(DN.valueOf("o=test"), |
| | | SearchScope.WHOLE_SUBTREE, filter); |
| | | memberList = groupInstance.getMembers( |
| | | DN.valueOf("o=test"), SearchScope.WHOLE_SUBTREE, SearchFilter.objectClassPresent()); |
| | | while (memberList.hasMoreMembers()) |
| | | { |
| | | try |
| | |
| | | memberSet.add(user1DN); |
| | | memberSet.add(user2DN); |
| | | |
| | | MemberList memberList = |
| | | groupInstance.getMembers(DN.rootDN(), SearchScope.WHOLE_SUBTREE, |
| | | SearchFilter.createFilterFromString("(objectClass=*)")); |
| | | MemberList memberList = groupInstance.getMembers( |
| | | DN.rootDN(), SearchScope.WHOLE_SUBTREE, SearchFilter.objectClassPresent()); |
| | | assertNotNull(memberList); |
| | | while (memberList.hasMoreMembers()) |
| | | { |
| | |
| | | import org.opends.server.controls.MatchedValuesFilter; |
| | | import org.opends.server.controls.SubentriesControl; |
| | | 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; |
| | |
| | | @Override |
| | | protected Operation[] createTestOperations() throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | return new Operation[] |
| | | { |
| | | new SearchOperationBasis(conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new SearchOperationBasis( |
| | | getRootConnection(), nextOperationID(), nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(BASE), |
| | | SearchScope.WHOLE_SUBTREE, |
| | |
| | | -1, |
| | | -1, |
| | | false, |
| | | LDAPFilter.decode("(objectclass=*)"), |
| | | LDAPFilter.objectClassPresent(), |
| | | null) |
| | | }; |
| | | } |
| | |
| | | { |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(BASE), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("(objectclass=*)"), |
| | | null, null); |
| | | |
| | | InternalSearchOperation searchOperation = newInternalSearchOperation(LDAPFilter.objectClassPresent()); |
| | | searchOperation.run(); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(searchOperation.getEntriesSent(), 4); |
| | |
| | | @Test |
| | | public void testSearchInternalUnspecifiedAttributes() throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(BASE), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("(objectclass=inetorgperson)"), |
| | | null, null); |
| | | |
| | | newInternalSearchOperation(LDAPFilter.decode("(objectclass=inetorgperson)")); |
| | | Entry resultEntry = searchInternalForSingleEntry(searchOperation); |
| | | |
| | | assertEquals(resultEntry.getObjectClasses(), testEntry.getObjectClasses()); |
| | |
| | | public void testSearchInternalUnspecifiedAttributesOmitValues() |
| | | throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | getRootConnection(), nextOperationID(), nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(BASE), |
| | | SearchScope.WHOLE_SUBTREE, |
| | |
| | | @Test |
| | | public void testSearchInternalAllOperationalAttributes() throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | LinkedHashSet<String> attributes = new LinkedHashSet<String>(); |
| | | attributes.add("+"); |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(BASE), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("(objectclass=inetorgperson)"), |
| | | attributes, null); |
| | | |
| | | newInternalSearchOperation(LDAPFilter.decode("(objectclass=inetorgperson)"), "+"); |
| | | Entry resultEntry = searchInternalForSingleEntry(searchOperation); |
| | | |
| | | assertEquals(resultEntry.getObjectClasses().size(), 0); |
| | |
| | | public void testSearchInternalAllUserAndOperationalAttributes() |
| | | throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | LinkedHashSet<String> attributes = new LinkedHashSet<String>(); |
| | | attributes.add("*"); |
| | | attributes.add("+"); |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(BASE), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("(objectclass=inetorgperson)"), |
| | | attributes, null); |
| | | |
| | | newInternalSearchOperation(LDAPFilter.decode("(objectclass=inetorgperson)"), "*", "+"); |
| | | Entry resultEntry = searchInternalForSingleEntry(searchOperation); |
| | | |
| | | assertEquals(resultEntry.getObjectClasses(), testEntry.getObjectClasses()); |
| | |
| | | public void testSearchInternalAllUserAttributesPlusSelectedOperational() |
| | | throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | LinkedHashSet<String> attributes = new LinkedHashSet<String>(); |
| | | attributes.add("*"); |
| | | attributes.add("createtimestamp"); |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(BASE), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("(objectclass=inetorgperson)"), |
| | | attributes, null); |
| | | |
| | | newInternalSearchOperation(LDAPFilter.decode("(objectclass=inetorgperson)"), "*", "createtimestamp"); |
| | | Entry resultEntry = searchInternalForSingleEntry(searchOperation); |
| | | |
| | | assertEquals(resultEntry.getObjectClasses(), testEntry.getObjectClasses()); |
| | |
| | | public void testSearchInternalSelectedAttributes() |
| | | throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | LinkedHashSet<String> attributes = new LinkedHashSet<String>(); |
| | | attributes.add("uid"); |
| | | attributes.add("createtimestamp"); |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(BASE), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("(objectclass=inetorgperson)"), |
| | | attributes, null); |
| | | |
| | | newInternalSearchOperation(LDAPFilter.decode("(objectclass=inetorgperson)"), "uid", "createtimestamp"); |
| | | Entry resultEntry = searchInternalForSingleEntry(searchOperation); |
| | | |
| | | assertEquals(resultEntry.getObjectClasses().size(), 0); |
| | |
| | | assertEquals(resultEntry.getOperationalAttributes().size(), 1); |
| | | } |
| | | |
| | | private InternalSearchOperation newInternalSearchOperation(LDAPFilter filter, String... attributes) |
| | | { |
| | | return new InternalSearchOperation( |
| | | getRootConnection(), nextOperationID(), nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(BASE), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, Integer.MAX_VALUE, Integer.MAX_VALUE, false, |
| | | filter, new LinkedHashSet<String>(Arrays.asList(attributes)), null); |
| | | } |
| | | |
| | | @Test |
| | | public void testSearchExternalUnspecifiedAttributes() throws Exception |
| | | { |
| | |
| | | { |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(BASE), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("(objectclass=inetorgperson)"), |
| | | null, null); |
| | | |
| | | newInternalSearchOperation(LDAPFilter.decode("(objectclass=inetorgperson)")); |
| | | searchOperation.run(); |
| | | |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | { |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | InternalSearchOperation searchOperation = new InternalSearchOperation( |
| | | getRootConnection(), nextOperationID(), nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(BASE), |
| | | SearchScope.SINGLE_LEVEL, |
| | |
| | | { |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(BASE), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("(objectclass=ldapsubentry)"), |
| | | null, null); |
| | | |
| | | newInternalSearchOperation(LDAPFilter.decode("(objectclass=ldapsubentry)")); |
| | | searchOperation.run(); |
| | | |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | { |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | getRootConnection(), nextOperationID(), nextMessageID(), |
| | | Collections.singletonList((Control)new SubentriesControl(true, true)), |
| | | ByteString.valueOf(BASE), |
| | | SearchScope.WHOLE_SUBTREE, |
| | |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("(objectclass=*)"), |
| | | LDAPFilter.objectClassPresent(), |
| | | null, null); |
| | | |
| | | searchOperation.run(); |
| | |
| | | { |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalSearchOperation searchOperation = new InternalSearchOperation(conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | InternalSearchOperation searchOperation = new InternalSearchOperation( |
| | | getRootConnection(), nextOperationID(), nextMessageID(), |
| | | Collections.singletonList((Control) new LDAPControl( |
| | | OID_LDUP_SUBENTRIES, true)), ByteString.valueOf(BASE), |
| | | SearchScope.WHOLE_SUBTREE, DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, Integer.MAX_VALUE, false, |
| | | LDAPFilter.decode("(objectclass=*)"), null, null); |
| | | LDAPFilter.objectClassPresent(), null, null); |
| | | |
| | | searchOperation.run(); |
| | | |
| | |
| | | { |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(BASE), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("(&(cn=*)(objectclass=ldapsubentry))"), |
| | | null, null); |
| | | |
| | | newInternalSearchOperation(LDAPFilter.decode("(&(cn=*)(objectclass=ldapsubentry))")); |
| | | searchOperation.run(); |
| | | |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(searchOperation.getEntriesSent(), 1); |
| | | assertEquals(searchOperation.getErrorMessage().length(), 0); |
| | | |
| | | searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(BASE), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("(&(&(cn=*)(objectclass=ldapsubentry)))"), |
| | | null, null); |
| | | |
| | | searchOperation = newInternalSearchOperation(LDAPFilter.decode("(&(&(cn=*)(objectclass=ldapsubentry)))")); |
| | | searchOperation.run(); |
| | | |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | { |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(BASE), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("(|(objectclass=ldapsubentry)(objectclass=top))"), |
| | | null, null); |
| | | |
| | | newInternalSearchOperation(LDAPFilter.decode("(|(objectclass=ldapsubentry)(objectclass=top))")); |
| | | searchOperation.run(); |
| | | |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | getRootConnection(), nextOperationID(), nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf("ou=nonexistent,o=test"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("(objectclass=*)"), |
| | | LDAPFilter.objectClassPresent(), |
| | | null, null); |
| | | |
| | | searchOperation.run(); |
| | |
| | | "cn: Test User", |
| | | "userPassword: password"); |
| | | |
| | | final SearchRequest request = Requests.newSearchRequest(userDN, SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | final SearchRequest request = Requests.newSearchRequest(userDN, SearchScope.BASE_OBJECT); |
| | | request.setTypesOnly(typesOnly); |
| | | switch (filterType) |
| | | { |
| | |
| | | "cn;lang-fr: Test Usager", |
| | | "userPassword: password"); |
| | | |
| | | SearchRequest request = Requests.newSearchRequest(userDNString, SearchScope.BASE_OBJECT, "(objectClass=*)") |
| | | SearchRequest request = Requests.newSearchRequest(userDN, SearchScope.BASE_OBJECT) |
| | | .addAttribute(requestedAttributes); |
| | | InternalSearchOperation search = getRootConnection().processSearch(request); |
| | | assertEquals(search.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("(objectclass=*)"), |
| | | LDAPFilter.objectClassPresent(), |
| | | attributes); |
| | | |
| | | SearchResultEntryProtocolOp entry = |
| | |
| | | |
| | | assertEquals(err,0); |
| | | |
| | | //Search for the entries. |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | getRootConnection(), nextOperationID(), nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf("dc=example,dc=com"), |
| | | SearchScope.SINGLE_LEVEL, |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | 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.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.protocols.ldap.LDAPAttribute; |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.opends.server.protocols.ldap.LDAPModification; |
| | | import org.opends.server.tools.LDAPDelete; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | @Test |
| | | public void testCollectiveAttributeSubentries() throws Exception |
| | | { |
| | | Set<String> attributes = newSet("collectiveAttributeSubentries"); |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | getRootConnection(), nextOperationID(), nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(testEntry.getName().toString()), |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("(objectclass=*)"), |
| | | attributes, null); |
| | | SearchRequest request = newSearchRequest(testEntry.getName(), SearchScope.BASE_OBJECT) |
| | | .setSizeLimit(Integer.MAX_VALUE) |
| | | .setTimeLimit(Integer.MAX_VALUE) |
| | | .addAttribute("collectiveAttributeSubentries"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | |
| | | searchOperation.run(); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(searchOperation.getEntriesSent(), 1); |
| | | AttributeType attrType = DirectoryServer.getAttributeType("collectiveattributesubentries"); |
| | |
| | | import java.util.ArrayList; |
| | | |
| | | 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.TestCaseUtils; |
| | | import org.opends.server.api.Backend; |
| | |
| | | import org.opends.server.core.networkgroups.NetworkGroup; |
| | | 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.LDAPFilter; |
| | | import org.opends.server.protocols.ldap.LDAPModification; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.RawModification; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.opends.server.util.UtilTestCase; |
| | | import org.opends.server.workflowelement.localbackend.LocalBackendWorkflowElement; |
| | | 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.opends.server.util.StaticUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | * With the manual configuration mode, all the network groups, workflows |
| | | * and workflow elements must be defined in the configuration file. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | public class WorkflowConfigurationTest extends UtilTestCase |
| | | { |
| | | // The base DN of the config backend |
| | |
| | | * @throws Exception if the environment could not be set up. |
| | | */ |
| | | @BeforeClass |
| | | public void setUp() |
| | | throws Exception |
| | | public void setUp() throws Exception |
| | | { |
| | | // Start the server so that we can update the configuration and execute |
| | | // some LDAP operations |
| | |
| | | ResultCode expectedResultCode |
| | | ) throws Exception |
| | | { |
| | | InternalSearchOperation searchOperation = new InternalSearchOperation( |
| | | InternalClientConnection.getRootConnection(), |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(baseDN), |
| | | scope, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("(objectClass=*)"), |
| | | null, null); |
| | | |
| | | searchOperation.run(); |
| | | SearchRequest request = newSearchRequest(DN.valueOf(baseDN), scope) |
| | | .setSizeLimit(Integer.MAX_VALUE) |
| | | .setTimeLimit(Integer.MAX_VALUE); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), expectedResultCode); |
| | | |
| | | return searchOperation; |
| | | } |
| | | |
| | |
| | | throws Exception |
| | | { |
| | | // Get the backend |
| | | Backend backend = DirectoryServer.getBackend(backendID); |
| | | Backend<?> backend = DirectoryServer.getBackend(backendID); |
| | | assertNotNull(backend); |
| | | |
| | | // Create the workflow element that wraps the local backend |
| | |
| | | * Create a base entry for a new suffix. |
| | | * |
| | | * @param baseDN the DN of the new base entry |
| | | * @param backendID the identifier of the backend |
| | | */ |
| | | private void createBaseEntry(String baseDN, String backendID) |
| | | throws Exception |
| | | private void createBaseEntry(String baseDN) throws Exception |
| | | { |
| | | Entry entry = StaticUtils.createEntry(DN.valueOf(baseDN)); |
| | | |
| | |
| | | * @return the newly created backend |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | private static Backend dsconfigCreateMemoryBackend( |
| | | private static Backend<?> dsconfigCreateMemoryBackend( |
| | | String backendID, |
| | | String baseDN, |
| | | boolean createBaseEntry |
| | |
| | | "--set", "writability-mode:enabled", |
| | | "--set", "enabled:true"); |
| | | |
| | | Backend backend = DirectoryServer.getBackend(backendID); |
| | | Backend<?> backend = DirectoryServer.getBackend(backendID); |
| | | if (createBaseEntry) |
| | | { |
| | | Entry e = createEntry(DN.valueOf(baseDN)); |
| | |
| | | // Add a new suffix to the test backend and check that the new |
| | | // suffix is accessible (we are in auto mode). |
| | | addSuffix(testBaseDN2, testBackendID2); |
| | | createBaseEntry(testBaseDN2, testBackendID2); |
| | | createBaseEntry(testBaseDN2); |
| | | checkBackendIsAccessible(testBaseDN2); |
| | | |
| | | // Remove the suffix and check that the removed suffix is no |
| | |
| | | // the workflow is automatically created when a new suffix is added. |
| | | addSuffix(testBaseDN3, testBackendID2); |
| | | createWorkflow(testBaseDN3, testBackendID2); |
| | | createBaseEntry(testBaseDN3, testBackendID2); |
| | | createBaseEntry(testBaseDN3); |
| | | checkBackendIsAccessible(testBaseDN3); |
| | | |
| | | // Finally remove the new workflow and suffix and check that the suffix |
| | |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.core.*; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.opends.server.workflowelement.WorkflowElement; |
| | |
| | | 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.protocols.internal.Requests.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | int expectedNamingContexts |
| | | ) throws Exception |
| | | { |
| | | SearchOperation search = connection.processSearch("", SearchScope.SINGLE_LEVEL, "(objectClass=*)"); |
| | | SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.SINGLE_LEVEL); |
| | | SearchOperation search = connection.processSearch(request); |
| | | |
| | | // Check the number of found naming context |
| | | assertEquals(search.getResultCode(), shouldExist ? ResultCode.SUCCESS : ResultCode.NO_SUCH_OBJECT); |
| | |
| | | */ |
| | | private void searchEntry(String baseDN, boolean shouldExist) throws Exception |
| | | { |
| | | SearchOperation search = getRootConnection().processSearch(baseDN, SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | SearchRequest request = newSearchRequest(DN.valueOf(baseDN), SearchScope.BASE_OBJECT); |
| | | SearchOperation search = getRootConnection().processSearch(request); |
| | | |
| | | // Compare the result code with the expected one |
| | | assertEquals(search.getResultCode(), shouldExist ? ResultCode.SUCCESS : ResultCode.NO_SUCH_OBJECT); |
| | |
| | | import static org.forgerock.opendj.ldap.SearchScope.*; |
| | | import static org.opends.server.admin.std.meta.RequestFilteringQOSPolicyCfgDefn.AllowedOperations.*; |
| | | import static org.opends.server.admin.std.meta.RequestFilteringQOSPolicyCfgDefn.AllowedSearchScopes.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | |
| | | |
| | | }); |
| | | |
| | | InternalClientConnection conn = new InternalClientConnection(DN.NULL_DN); |
| | | InternalSearchOperation search = conn.processSearch("dc=example,dc=com", BASE_OBJECT, searchFilter); |
| | | InternalClientConnection conn = new InternalClientConnection(DN.rootDN()); |
| | | InternalSearchOperation search = |
| | | conn.processSearch(newSearchRequest("dc=example,dc=com", BASE_OBJECT, searchFilter)); |
| | | assertEquals(policy.isAllowed(search, messages), success); |
| | | } |
| | | |
| | |
| | | |
| | | }); |
| | | |
| | | InternalClientConnection conn = new InternalClientConnection(DN.NULL_DN); |
| | | InternalSearchOperation search = conn.processSearch("dc=example,dc=com", BASE_OBJECT, searchFilter); |
| | | InternalClientConnection conn = new InternalClientConnection(DN.rootDN()); |
| | | InternalSearchOperation search = |
| | | conn.processSearch(newSearchRequest("dc=example,dc=com", BASE_OBJECT, searchFilter)); |
| | | assertEquals(policy.isAllowed(search, messages), success); |
| | | } |
| | | |
| | |
| | | |
| | | }); |
| | | |
| | | InternalClientConnection conn = new InternalClientConnection(DN.NULL_DN); |
| | | InternalSearchOperation search = conn.processSearch("dc=example,dc=com", searchScope, "objectclass=*"); |
| | | InternalClientConnection conn = new InternalClientConnection(DN.rootDN()); |
| | | InternalSearchOperation search = conn.processSearch(newSearchRequest(DN.valueOf("dc=example,dc=com"), searchScope)); |
| | | assertEquals(policy.isAllowed(search, messages), success); |
| | | } |
| | | |
| | |
| | | |
| | | }); |
| | | |
| | | InternalClientConnection conn = new InternalClientConnection(DN.NULL_DN); |
| | | InternalSearchOperation search = conn.processSearch(searchSubtree, WHOLE_SUBTREE, "objectclass=*"); |
| | | InternalClientConnection conn = new InternalClientConnection(DN.rootDN()); |
| | | InternalSearchOperation search = conn.processSearch(newSearchRequest(DN.valueOf(searchSubtree), WHOLE_SUBTREE)); |
| | | assertEquals(policy.isAllowed(search, messages), success); |
| | | } |
| | | |
| | |
| | | |
| | | }); |
| | | |
| | | InternalClientConnection conn = new InternalClientConnection(DN.NULL_DN); |
| | | InternalSearchOperation search = conn.processSearch(searchSubtree, WHOLE_SUBTREE, "objectclass=*"); |
| | | InternalClientConnection conn = new InternalClientConnection(DN.rootDN()); |
| | | InternalSearchOperation search = conn.processSearch(newSearchRequest(DN.valueOf(searchSubtree), WHOLE_SUBTREE)); |
| | | assertEquals(policy.isAllowed(search, messages), success); |
| | | } |
| | | |
| | |
| | | |
| | | }); |
| | | |
| | | InternalClientConnection conn = new InternalClientConnection(DN.NULL_DN); |
| | | InternalSearchOperation search = conn.processSearch(searchSubtree, WHOLE_SUBTREE, "objectclass=*"); |
| | | InternalClientConnection conn = new InternalClientConnection(DN.rootDN()); |
| | | InternalSearchOperation search = conn.processSearch(newSearchRequest(DN.valueOf(searchSubtree), WHOLE_SUBTREE)); |
| | | assertEquals(policy.isAllowed(search, messages), success); |
| | | } |
| | | |
| | |
| | | |
| | | }); |
| | | |
| | | InternalClientConnection conn = new InternalClientConnection(DN.NULL_DN); |
| | | InternalClientConnection conn = new InternalClientConnection(DN.rootDN()); |
| | | PreParseOperation op = null; |
| | | |
| | | switch (type) { |
| | |
| | | "uid=usr.1,ou=people,dc=example,dc=com", true); |
| | | break; |
| | | case SEARCH: |
| | | op = conn.processSearch("dc=example,dc=com", WHOLE_SUBTREE, "uid>=user.1"); |
| | | op = conn.processSearch(newSearchRequest("dc=example,dc=com", WHOLE_SUBTREE, "uid>=user.1")); |
| | | break; |
| | | case UNBIND: |
| | | return; |
| | |
| | | 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.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.mockito.Mockito.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | InternalClientConnection conn = new InternalClientConnection(DN.NULL_DN); |
| | | limits.addConnection(conn); |
| | | |
| | | final SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.BASE_OBJECT, "(objectclass=*)"); |
| | | final SearchRequest request = newSearchRequest(DN.valueOf("dc=example,dc=com"), SearchScope.BASE_OBJECT); |
| | | final InternalSearchOperation search1 = conn.processSearch(request); |
| | | assertOperationIsAllowed(limits, conn, search1, true, |
| | | "First operation should be allowed"); |
| | |
| | | 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; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.RawAttribute; |
| | | import org.opends.server.types.RawModification; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.opends.server.types.VirtualAttributeRule; |
| | | import org.opends.server.util.StaticUtils; |
| | |
| | | |
| | | import static java.util.Collections.*; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | public void testOptimisticConcurrency() throws Exception |
| | | { |
| | | // Use an internal connection. |
| | | String userDN = "uid=test.user,ou=People,o=test"; |
| | | InternalClientConnection conn = InternalClientConnection |
| | | .getRootConnection(); |
| | | DN userDN = DN.valueOf("uid=test.user,ou=People,o=test"); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | |
| | | // Create a test backend containing the user entry to be modified. |
| | | TestCaseUtils.initializeTestBackend(true); |
| | |
| | | // @formatter:on |
| | | |
| | | // Read the user entry and get the etag. |
| | | Entry e1 = readEntry(conn, userDN); |
| | | Entry e1 = readEntry(userDN); |
| | | String etag1 = e1.parseAttribute(ETAG).asString(); |
| | | assertNotNull(etag1); |
| | | |
| | | // Apply a change using the assertion control for optimistic concurrency. |
| | | List<RawModification> mods = Collections |
| | | .<RawModification> singletonList(new LDAPModification( |
| | | ModificationType.REPLACE, RawAttribute.create(DESCRIPTION, |
| | | "first modify"))); |
| | | Attribute attr = Attributes.create(DESCRIPTION, "first modify"); |
| | | List<Modification> mods = newArrayList(new Modification(ModificationType.REPLACE, attr)); |
| | | List<Control> ctrls = Collections |
| | | .<Control> singletonList(new LDAPAssertionRequestControl(true, |
| | | LDAPFilter.createEqualityFilter(ETAG, ByteString.valueOf(etag1)))); |
| | |
| | | |
| | | // Reread the entry and check that the description has been added and that |
| | | // the etag has changed. |
| | | Entry e2 = readEntry(conn, userDN); |
| | | Entry e2 = readEntry(userDN); |
| | | |
| | | String etag2 = e2.parseAttribute(ETAG).asString(); |
| | | assertNotNull(etag2); |
| | |
| | | assertEquals(description2, "first modify"); |
| | | |
| | | // Simulate a concurrent update: perform another update using the old etag. |
| | | mods = Collections.<RawModification> singletonList(new LDAPModification( |
| | | ModificationType.REPLACE, RawAttribute.create(DESCRIPTION, |
| | | "second modify"))); |
| | | Attribute attr2 = Attributes.create(DESCRIPTION, "second modify"); |
| | | mods = newArrayList(new Modification(ModificationType.REPLACE, attr2)); |
| | | modifyOperation = conn.processModify(userDN, mods, ctrls); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.ASSERTION_FAILED); |
| | | |
| | | // Reread the entry and check that the description and etag have not |
| | | // changed. |
| | | Entry e3 = readEntry(conn, userDN); |
| | | // Reread the entry and check that the description and etag have not changed |
| | | Entry e3 = readEntry(userDN); |
| | | |
| | | String etag3 = e3.parseAttribute(ETAG).asString(); |
| | | assertNotNull(etag3); |
| | |
| | | @Test |
| | | public void testPreReadControl() throws Exception |
| | | { |
| | | String userDN = "uid=test.user,ou=People,o=test"; |
| | | |
| | | // Use an internal connection. |
| | | InternalClientConnection conn = InternalClientConnection |
| | | .getRootConnection(); |
| | | DN userDN = DN.valueOf("uid=test.user,ou=People,o=test"); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | |
| | | // Create a test backend containing the user entry to be modified. |
| | | TestCaseUtils.initializeTestBackend(true); |
| | |
| | | // @formatter:on |
| | | |
| | | // Read the user entry and get the etag. |
| | | Entry e1 = readEntry(conn, userDN); |
| | | Entry e1 = readEntry(userDN); |
| | | String etag1 = e1.parseAttribute(ETAG).asString(); |
| | | assertNotNull(etag1); |
| | | |
| | | // Apply a change using the pre and post read controls. |
| | | List<RawModification> mods = Collections |
| | | .<RawModification> singletonList(new LDAPModification( |
| | | ModificationType.REPLACE, RawAttribute.create(DESCRIPTION, |
| | | "modified value"))); |
| | | List<Control> ctrls = singletonList((Control) new LDAPPreReadRequestControl( |
| | | true, singleton(ETAG))); |
| | | Attribute attr = Attributes.create(DESCRIPTION, "modified value"); |
| | | List<Modification> mods = newArrayList(new Modification(ModificationType.REPLACE, attr)); |
| | | List<Control> ctrls = singletonList((Control) new LDAPPreReadRequestControl(true, singleton(ETAG))); |
| | | ModifyOperation modifyOperation = conn.processModify(userDN, mods, ctrls); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | // Reread the entry and check that the description has been added and that |
| | | // the etag has changed. |
| | | Entry e2 = readEntry(conn, userDN); |
| | | Entry e2 = readEntry(userDN); |
| | | |
| | | String etag2 = e2.parseAttribute(ETAG).asString(); |
| | | assertNotNull(etag2); |
| | |
| | | @Test |
| | | public void testPostReadControl() throws Exception |
| | | { |
| | | String userDN = "uid=test.user,ou=People,o=test"; |
| | | |
| | | // Use an internal connection. |
| | | InternalClientConnection conn = InternalClientConnection |
| | | .getRootConnection(); |
| | | DN userDN = DN.valueOf("uid=test.user,ou=People,o=test"); |
| | | InternalClientConnection conn = getRootConnection(); |
| | | |
| | | // Create a test backend containing the user entry to be modified. |
| | | TestCaseUtils.initializeTestBackend(true); |
| | |
| | | // @formatter:on |
| | | |
| | | // Read the user entry and get the etag. |
| | | Entry e1 = readEntry(conn, userDN); |
| | | Entry e1 = readEntry(userDN); |
| | | String etag1 = e1.parseAttribute(ETAG).asString(); |
| | | assertNotNull(etag1); |
| | | |
| | | // Apply a change using the pre and post read controls. |
| | | List<RawModification> mods = Collections |
| | | .<RawModification> singletonList(new LDAPModification( |
| | | ModificationType.REPLACE, RawAttribute.create(DESCRIPTION, |
| | | "modified value"))); |
| | | List<Control> ctrls = singletonList((Control) new LDAPPostReadRequestControl( |
| | | true, singleton(ETAG))); |
| | | Attribute attr = Attributes.create(DESCRIPTION, "modified value"); |
| | | List<Modification> mods = newArrayList(new Modification(ModificationType.REPLACE, attr)); |
| | | List<Control> ctrls = singletonList((Control) new LDAPPostReadRequestControl(true, singleton(ETAG))); |
| | | ModifyOperation modifyOperation = conn.processModify(userDN, mods, ctrls); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | |
| | | // Reread the entry and check that the description has been added and that |
| | | // the etag has changed. |
| | | Entry e2 = readEntry(conn, userDN); |
| | | Entry e2 = readEntry(userDN); |
| | | |
| | | String etag2 = e2.parseAttribute(ETAG).asString(); |
| | | assertNotNull(etag2); |
| | |
| | | assertEquals(description2, "modified value"); |
| | | |
| | | // Now check that the post-read is the same as the initial etag. |
| | | LDAPPostReadResponseControl postReadControl = null; |
| | | for (Control control : modifyOperation.getResponseControls()) |
| | | { |
| | | if (control instanceof LDAPPostReadResponseControl) |
| | | { |
| | | postReadControl = (LDAPPostReadResponseControl) control; |
| | | break; |
| | | } |
| | | } |
| | | assertNotNull(postReadControl); |
| | | LDAPPostReadResponseControl postReadControl = getLDAPPostReadResponseControl(modifyOperation); |
| | | String etagPostRead = |
| | | postReadControl.getSearchEntry().parseAttribute(ETAG).asString(); |
| | | assertEquals(etagPostRead, etag2); |
| | | } |
| | | |
| | | |
| | | |
| | | private Entry readEntry(InternalClientConnection conn, String userDN) |
| | | throws DirectoryException |
| | | private LDAPPostReadResponseControl getLDAPPostReadResponseControl(ModifyOperation modifyOperation) |
| | | { |
| | | SearchRequest request = Requests.newSearchRequest(userDN, SearchScope.BASE_OBJECT, "(objectClass=*)", "*", ETAG); |
| | | InternalSearchOperation searchOperation = conn.processSearch(request); |
| | | for (Control control : modifyOperation.getResponseControls()) |
| | | { |
| | | if (control instanceof LDAPPostReadResponseControl) |
| | | { |
| | | return (LDAPPostReadResponseControl) control; |
| | | } |
| | | } |
| | | fail("Expected the ModifyOperation to have a LDAPPostReadResponseControl"); |
| | | return null; |
| | | } |
| | | |
| | | private Entry readEntry(DN userDN) throws DirectoryException |
| | | { |
| | | SearchRequest request = Requests.newSearchRequest(userDN, SearchScope.BASE_OBJECT).addAttribute("*", ETAG); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | |
| | | public void testSearchEntryDNAttrRealAttrsOnly(DN entryDN) |
| | | throws Exception |
| | | { |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(objectClass=*)") |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT) |
| | | .addAttribute("entrydn") |
| | | .addControl(new LDAPControl(OID_REAL_ATTRS_ONLY, true)); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | |
| | | public void testSearchEntryDNAttrVirtualAttrsOnly(DN entryDN) |
| | | throws Exception |
| | | { |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(objectClass=*)") |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT) |
| | | .addAttribute("entrydn") |
| | | .addControl(new LDAPControl(OID_VIRTUAL_ATTRS_ONLY, true)); |
| | | |
| | |
| | | package org.opends.server.extensions; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | 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.*; |
| | | 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.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.testng.Assert.*; |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test(dataProvider = "testEntryDNs") |
| | | public void testSearchEntryUUIDAttrRealAttrsOnly(DN entryDN) |
| | | throws Exception |
| | | public void testSearchEntryUUIDAttrRealAttrsOnly(DN entryDN) throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("entryuuid"); |
| | | |
| | | 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) |
| | | .addAttribute("entryuuid") |
| | | .addControl(new LDAPControl(OID_REAL_ATTRS_ONLY, true)); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test(dataProvider = "testEntryDNs") |
| | | public void testSearchEntryUUIDAttrVirtualAttrsOnly(DN entryDN) |
| | | throws Exception |
| | | public void testSearchEntryUUIDAttrVirtualAttrsOnly(DN entryDN) throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("entryuuid"); |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT) |
| | | .addAttribute("entryuuid") |
| | | .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); |
| | |
| | | /** |
| | | * Tests the {@code isMultiValued} method. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testIsMultiValued() |
| | | { |
| | | EntryUUIDVirtualAttributeProvider provider = |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testGetValues() |
| | | throws Exception |
| | | @Test |
| | | public void testGetValues() throws Exception |
| | | { |
| | | String uuidString = UUID.nameUUIDFromBytes(getBytes("o=test")).toString(); |
| | | |
| | | EntryUUIDVirtualAttributeProvider provider = |
| | | new EntryUUIDVirtualAttributeProvider(); |
| | | |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: o=test", |
| | | "objectClass: top", |
| | | "objectClass: organization", |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(entryUUIDType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | Entry entry = makeEntry(); |
| | | VirtualAttributeRule rule = getRule(provider); |
| | | |
| | | Attribute values = provider.getValues(entry, rule); |
| | | assertNotNull(values); |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasAnyValue() |
| | | throws Exception |
| | | @Test |
| | | public void testHasAnyValue() throws Exception |
| | | { |
| | | EntryUUIDVirtualAttributeProvider provider = |
| | | new EntryUUIDVirtualAttributeProvider(); |
| | | |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: o=test", |
| | | "objectClass: top", |
| | | "objectClass: organization", |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(entryUUIDType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | Entry entry = makeEntry(); |
| | | VirtualAttributeRule rule = getRule(provider); |
| | | assertTrue(provider.hasValue(entry, rule)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasValue} method variant that takes a specific value when |
| | | * the provided value is a match. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasMatchingValue() |
| | | throws Exception |
| | | @Test |
| | | public void testHasMatchingValue() throws Exception |
| | | { |
| | | String uuidString = UUID.nameUUIDFromBytes(getBytes("o=test")).toString(); |
| | | |
| | | EntryUUIDVirtualAttributeProvider provider = |
| | | new EntryUUIDVirtualAttributeProvider(); |
| | | |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: o=test", |
| | | "objectClass: top", |
| | | "objectClass: organization", |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(entryUUIDType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | Entry entry = makeEntry(); |
| | | VirtualAttributeRule rule = getRule(provider); |
| | | assertTrue(provider.hasValue(entry, rule, ByteString.valueOf(uuidString))); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code hasValue} method variant that takes a specific value when |
| | | * the provided value is not a match. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasNonMatchingValue() |
| | | throws Exception |
| | | @Test |
| | | public void testHasNonMatchingValue() throws Exception |
| | | { |
| | | EntryUUIDVirtualAttributeProvider provider = |
| | | new EntryUUIDVirtualAttributeProvider(); |
| | | |
| | | Entry entry = makeEntry(); |
| | | VirtualAttributeRule rule = getRule(provider); |
| | | assertFalse(provider.hasValue(entry, rule, ByteString.valueOf("wrong"))); |
| | | } |
| | | |
| | | private Entry makeEntry() throws Exception |
| | | { |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: o=test", |
| | | "objectClass: top", |
| | | "objectClass: organization", |
| | | "o: test"); |
| | | entry.processVirtualAttributes(); |
| | | return entry; |
| | | } |
| | | |
| | | VirtualAttributeRule rule = |
| | | new VirtualAttributeRule(entryUUIDType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior. |
| | | VIRTUAL_OVERRIDES_REAL); |
| | | |
| | | assertFalse(provider.hasValue(entry, rule, ByteString.valueOf("wrong"))); |
| | | private VirtualAttributeRule getRule(EntryUUIDVirtualAttributeProvider provider) |
| | | { |
| | | return new VirtualAttributeRule(entryUUIDType, provider, |
| | | Collections.<DN>emptySet(), SearchScope.WHOLE_SUBTREE, |
| | | Collections.<DN>emptySet(), |
| | | Collections.<SearchFilter>emptySet(), |
| | | VirtualAttributeCfgDefn.ConflictBehavior.VIRTUAL_OVERRIDES_REAL); |
| | | } |
| | | } |
| | |
| | | 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.opends.server.types.Entry; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | public static void testSearchEmptyAttrs(DN entryDN, |
| | | AttributeType attributeType) throws Exception |
| | | { |
| | | 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); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(attributeType)); |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT); |
| | | assertAttributeFound(request, attributeType, false); |
| | | } |
| | | |
| | | public static void testSearchNoAttrs(DN entryDN, AttributeType attributeType) |
| | | throws Exception |
| | | { |
| | | 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); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(attributeType)); |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT) |
| | | .addAttribute(SchemaConstants.NO_ATTRIBUTES); |
| | | assertAttributeFound(request, attributeType, false); |
| | | } |
| | | |
| | | public static void testSearchAllUserAttrs(DN entryDN, |
| | | AttributeType attributeType) throws Exception |
| | | { |
| | | 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); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(attributeType)); |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT).addAttribute("*"); |
| | | assertAttributeFound(request, attributeType, false); |
| | | } |
| | | |
| | | public static void testSearchAllOperationalAttrs(DN entryDN, |
| | | AttributeType attributeType) throws Exception |
| | | { |
| | | 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); |
| | | assertNotNull(e); |
| | | assertTrue(e.hasAttribute(attributeType)); |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT).addAttribute("+"); |
| | | assertAttributeFound(request, attributeType, true); |
| | | } |
| | | |
| | | public static void testSearchAttr(DN entryDN, String attrName, |
| | | AttributeType attributeType) throws Exception |
| | | { |
| | | 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); |
| | | assertNotNull(e); |
| | | assertTrue(e.hasAttribute(attributeType)); |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT).addAttribute(attrName); |
| | | assertAttributeFound(request, attributeType, true); |
| | | } |
| | | |
| | | public static void testSearchExcludeAttr(DN entryDN, |
| | | AttributeType attributeType) throws Exception |
| | | { |
| | | final SearchRequest request = |
| | | newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(objectClass=*)").addAttribute("objectClass"); |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT).addAttribute("objectClass"); |
| | | assertAttributeFound(request, attributeType, false); |
| | | } |
| | | |
| | | private static void assertAttributeFound(final SearchRequest request, AttributeType attributeType, boolean expected) |
| | | { |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(attributeType)); |
| | | assertEquals(e.hasAttribute(attributeType), expected); |
| | | } |
| | | |
| | | } |
| | |
| | | package org.opends.server.extensions; |
| | | |
| | | 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.Requests; |
| | | 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.opends.server.types.Control; |
| | | 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.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | public void testSearchGovStructRuleAttrRealAttrsOnly(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("governingStructureRuleType"); |
| | | |
| | | 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 = Requests.newSearchRequest(entryDN, SearchScope.BASE_OBJECT) |
| | | .addAttribute("governingStructureRuleType") |
| | | .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 testSearchGovStructRuleAttrVirtualAttrsOnly(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("governingStructureRule"); |
| | | |
| | | 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 = Requests.newSearchRequest(entryDN, SearchScope.BASE_OBJECT) |
| | | .addAttribute("governingStructureRule") |
| | | .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 testSearchhasSubordinatesAttrRealAttrsOnly(DN entryDN, boolean hasSubs) |
| | | throws Exception |
| | | { |
| | | SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(objectClass=*)") |
| | | SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT) |
| | | .addAttribute("hasSubordinates") |
| | | .addControl(new LDAPControl(OID_REAL_ATTRS_ONLY, true)); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | |
| | | public void testSearchhasSubordinatesAttrVirtualAttrsOnly(DN entryDN, boolean hasSubs) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | SearchFilter filter = SearchFilter.objectClassPresent(); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("hasSubordinates"); |
| | | |
| | |
| | | try |
| | | { |
| | | connection = factory.getConnection(); |
| | | connection.search(searchBindDN, SearchScope.WHOLE_SUBTREE, |
| | | SearchFilter.createFilterFromString("(objectClass=*)")); |
| | | connection.search(searchBindDN, SearchScope.WHOLE_SUBTREE, SearchFilter.objectClassPresent()); |
| | | fail("Search attempt should have timed out"); |
| | | } |
| | | catch (final DirectoryException e) |
| | |
| | | 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.protocols.ldap.LDAPControl; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | 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.*; |
| | | |
| | |
| | | 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); |
| | | assertNotNull(e); |
| | | assertTrue(e.hasAttribute(numSubordinatesType)); |
| | | assertNumSubordinatesAttributeFound(request, true); |
| | | } |
| | | |
| | | /** |
| | |
| | | public void testSearchnumSubordinatesAttrRealAttrsOnly(DN entryDN, int count) |
| | | throws Exception |
| | | { |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(objectClass=*)") |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT) |
| | | .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); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(numSubordinatesType)); |
| | | assertNumSubordinatesAttributeFound(request, false); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Performs an internal search to retrieve the specified entry, ensuring that |
| | | * the numSubordinates attribute is included when that attribute is specifically |
| | |
| | | public void testSearchnumSubordinatesAttrVirtualAttrsOnly(DN entryDN, int count) |
| | | throws Exception |
| | | { |
| | | 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); |
| | | assertNotNull(e); |
| | | assertTrue(e.hasAttribute(numSubordinatesType)); |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT) |
| | | .addAttribute("numSubordinates") |
| | | .addControl(new LDAPControl(OID_VIRTUAL_ATTRS_ONLY, true)); |
| | | assertNumSubordinatesAttributeFound(request, true); |
| | | } |
| | | |
| | | /** |
| | |
| | | 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); |
| | | assertNotNull(e); |
| | | assertTrue(e.hasAttribute(numSubordinatesType)); |
| | | assertNumSubordinatesAttributeFound(request, true); |
| | | } |
| | | |
| | | /** |
| | |
| | | final SearchRequest request = |
| | | newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(numSubordinates<=" + count + ")") |
| | | .addAttribute("numSubordinates"); |
| | | assertNumSubordinatesAttributeFound(request, true); |
| | | } |
| | | |
| | | private void assertNumSubordinatesAttributeFound(final SearchRequest request, boolean expected) |
| | | { |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertTrue(e.hasAttribute(numSubordinatesType)); |
| | | assertEquals(e.hasAttribute(numSubordinatesType), expected); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code isMultiValued} method. |
| | | */ |
| | | @Test() |
| | | /** Tests the {@code isMultiValued} method. */ |
| | | @Test |
| | | public void testIsMultiValued() |
| | | { |
| | | assertFalse(new NumSubordinatesVirtualAttributeProvider().isMultiValued()); |
| | |
| | | throws Exception |
| | | { |
| | | // Process the search request |
| | | SearchRequest request = newSearchRequest(notExpired.getName(), SearchScope.BASE_OBJECT, "(objectclass=*)") |
| | | SearchRequest request = newSearchRequest(notExpired.getName(), SearchScope.BASE_OBJECT) |
| | | .addAttribute(attributeName, "pwdpolicysubentry"); |
| | | InternalSearchOperation search = getRootConnection().processSearch(request); |
| | | assertEquals(search.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | public void testSearchStructuralOCAttrRealAttrsOnly(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | SearchFilter filter = SearchFilter.objectClassPresent(); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("structuralObjectClass"); |
| | | |
| | |
| | | public void testSearchStructuralOCAttrVirtualAttrsOnly(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | SearchFilter filter = SearchFilter.objectClassPresent(); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("structuralObjectClass"); |
| | | |
| | |
| | | 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.protocols.ldap.LDAPControl; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | |
| | | 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.*; |
| | | |
| | |
| | | public void testSearchSubschemaSubentryAttrRealAttrsOnly(DN entryDN) |
| | | throws Exception |
| | | { |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(objectClass=*)") |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT) |
| | | .addAttribute("subschemaSubentry") |
| | | .addControl(new LDAPControl(OID_REAL_ATTRS_ONLY, true)); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | |
| | | public void testSearchSubschemaSubentryAttrVirtualAttrsOnly(DN entryDN) |
| | | throws Exception |
| | | { |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(objectClass=*)") |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT) |
| | | .addAttribute("subschemaSubentry") |
| | | .addControl(new LDAPControl(OID_VIRTUAL_ATTRS_ONLY, true)); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | |
| | | /** |
| | | * Tests the {@code isMultiValued} method. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testIsMultiValued() |
| | | { |
| | | assertFalse(new SubschemaSubentryVirtualAttributeProvider().isMultiValued()); |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testGetValues() |
| | | throws Exception |
| | | { |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testHasAnyValue() |
| | | throws Exception |
| | | { |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testHasMatchingValue() |
| | | throws Exception |
| | | { |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testHasNonMatchingValue() |
| | | throws Exception |
| | | @Test |
| | | public void testHasNonMatchingValue() throws Exception |
| | | { |
| | | SubschemaSubentryVirtualAttributeProvider provider = |
| | | new SubschemaSubentryVirtualAttributeProvider(); |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | List<Control> requestControls = |
| | | DelayPreOpPlugin.createDelayControlList(5000); |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | List<Control> requestControls = DelayPreOpPlugin.createDelayControlList(5000); |
| | | SearchFilter filter = SearchFilter.objectClassPresent(); |
| | | LinkedHashSet<String> attrs = new LinkedHashSet<String>(); |
| | | |
| | | InternalClientConnection conn = |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | List<Control> requestControls = |
| | | DelayPreOpPlugin.createDelayControlList(5000); |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | List<Control> requestControls = DelayPreOpPlugin.createDelayControlList(5000); |
| | | SearchFilter filter = SearchFilter.objectClassPresent(); |
| | | LinkedHashSet<String> attrs = new LinkedHashSet<String>(); |
| | | |
| | | InternalClientConnection conn = |
| | |
| | | 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.opends.server.protocols.internal.Requests.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | .nextMessageID(), null, DN.valueOf(ruleDN), |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.createFilterFromString("(objectClass=*)"), |
| | | SearchFilter.objectClassPresent(), |
| | | null, null); |
| | | |
| | | for (VirtualAttributeRule rule : DirectoryServer |
| | |
| | | .nextMessageID(), null, DN.valueOf(ruleDN), |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.createFilterFromString("(objectClass=*)"), |
| | | SearchFilter.objectClassPresent(), |
| | | null, null); |
| | | |
| | | for (VirtualAttributeRule rule : DirectoryServer |
| | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | try |
| | | { |
| | | final SearchRequest request = newSearchRequest(userDN, SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | final SearchRequest request = newSearchRequest(DN.valueOf(userDN), SearchScope.BASE_OBJECT); |
| | | InternalSearchOperation searchOperation = conn.processSearch(request); |
| | | |
| | | List<Attribute> attrList = |
| | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | try |
| | | { |
| | | final SearchRequest request = newSearchRequest(userDN, SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | final SearchRequest request = newSearchRequest(DN.valueOf(userDN), SearchScope.BASE_OBJECT); |
| | | InternalSearchOperation searchOperation = conn.processSearch(request); |
| | | |
| | | List<Attribute> attrList = |
| | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | try |
| | | { |
| | | final SearchRequest request = newSearchRequest(userDN, SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | final SearchRequest request = newSearchRequest(DN.valueOf(userDN), SearchScope.BASE_OBJECT); |
| | | InternalSearchOperation searchOperation = conn.processSearch(request); |
| | | |
| | | List<Attribute> attrList = |
| | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | try |
| | | { |
| | | final SearchRequest request = newSearchRequest(userDN, SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | final SearchRequest request = newSearchRequest(DN.valueOf(userDN), SearchScope.BASE_OBJECT); |
| | | InternalSearchOperation searchOperation = conn.processSearch(request); |
| | | |
| | | List<Attribute> attrList = |
| | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | try |
| | | { |
| | | final SearchRequest request = newSearchRequest(userDN, SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | final SearchRequest request = newSearchRequest(DN.valueOf(userDN), SearchScope.BASE_OBJECT); |
| | | InternalSearchOperation searchOperation = conn.processSearch(request); |
| | | |
| | | List<Attribute> attrList = |
| | |
| | | "userPassword: test", |
| | | "description: " + realValue); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | try |
| | | { |
| | | final SearchRequest request = |
| | | newSearchRequest(userDN, SearchScope.BASE_OBJECT, "(objectClass=*)").addAttribute("description"); |
| | | newSearchRequest(DN.valueOf(userDN), SearchScope.BASE_OBJECT).addAttribute("description"); |
| | | InternalSearchOperation searchOperation = conn.processSearch(request); |
| | | |
| | | List<Attribute> attrList = searchOperation.getSearchEntries().get(0).getAttribute(descriptionType); |
| | |
| | | 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.opends.server.protocols.internal.Requests.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | */ |
| | | private void cleanUp() throws Exception |
| | | { |
| | | final SearchRequest request = |
| | | newSearchRequest("ou=Groups,dc=example,dc=com", SearchScope.SINGLE_LEVEL, "(objectClass=*)"); |
| | | DN dn = DN.valueOf("ou=Groups,dc=example,dc=com"); |
| | | final SearchRequest request = newSearchRequest(dn, SearchScope.SINGLE_LEVEL); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | for (Entry e : searchOperation.getSearchEntries()) |
| | | { |
| | |
| | | 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.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.protocols.internal.Requests.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | @Test |
| | | public void testWithSubtreeMonitorSearch() throws Exception |
| | | { |
| | | InternalSearchOperation op = getRootConnection().processSearch( |
| | | "cn=monitor", WHOLE_SUBTREE, "(objectClass=*)"); |
| | | SearchRequest request = newSearchRequest(DN.valueOf("cn=monitor"), WHOLE_SUBTREE); |
| | | InternalSearchOperation op = getRootConnection().processSearch(request); |
| | | assertEquals(op.getResultCode(), ResultCode.SUCCESS, |
| | | "Failed to search cn=monitor subtree. Got error message: " + op.getErrorMessage()); |
| | | } |
| | |
| | | public void testWithBaseObjectMonitorSearch(String monitorName) throws Exception |
| | | { |
| | | // could be more than one level |
| | | final String monitorDN = "cn="+monitorName+",cn=monitor"; |
| | | InternalSearchOperation op = getRootConnection().processSearch( |
| | | monitorDN, BASE_OBJECT, "(objectClass=*)"); |
| | | final DN monitorDN = DN.valueOf("cn=" + monitorName + ",cn=monitor"); |
| | | InternalSearchOperation op = getRootConnection().processSearch(newSearchRequest(monitorDN, BASE_OBJECT)); |
| | | assertEquals(op.getResultCode(), ResultCode.SUCCESS, |
| | | "Failed to read " + monitorDN + " entry. Got error message: " + op.getErrorMessage()); |
| | | } |
| | |
| | | public void testWithSubtreeAndBaseMonitorSearch() throws Exception |
| | | { |
| | | final InternalClientConnection conn = getRootConnection(); |
| | | InternalSearchOperation op = conn.processSearch( |
| | | "cn=monitor", WHOLE_SUBTREE, "(objectClass=*)"); |
| | | final SearchRequest request = newSearchRequest(DN.valueOf("cn=monitor"), WHOLE_SUBTREE); |
| | | InternalSearchOperation op = getRootConnection().processSearch(request); |
| | | assertEquals(op.getResultCode(), ResultCode.SUCCESS, |
| | | "Failed to search cn=monitor subtree. Got error message: " + op.getErrorMessage()); |
| | | |
| | | for (SearchResultEntry sre : op.getSearchEntries()) |
| | | { |
| | | 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()); |
| | | final SearchRequest request2 = newSearchRequest(sre.getName(), BASE_OBJECT); |
| | | final InternalSearchOperation op2 = conn.processSearch(request2); |
| | | assertEquals(op2.getResultCode(), ResultCode.SUCCESS, |
| | | "Failed to read " + sre.getName() + " entry. Got error message: " + op2.getErrorMessage()); |
| | | } |
| | | } |
| | | |
| | |
| | | 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.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @DataProvider(name = "invalidConfigs") |
| | | public Object[][] getInvalidConfigs() |
| | | throws Exception |
| | | public Object[][] getInvalidConfigs() throws Exception |
| | | { |
| | | ArrayList<Entry> entries = new ArrayList<Entry>(); |
| | | Entry e = TestCaseUtils.makeEntry( |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | final SearchRequest request = newSearchRequest("o=test", SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertFalse(searchOperation.getSearchEntries().isEmpty()); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e.getAttribute("o")); |
| | | final SearchRequest request = newSearchRequest(DN.valueOf("o=test"), SearchScope.BASE_OBJECT); |
| | | assertAttributeOExists(request); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | SearchRequest request = newSearchRequest("o=test", SearchScope.BASE_OBJECT, "(objectClass=*)") |
| | | SearchRequest request = newSearchRequest(DN.valueOf("o=test"), SearchScope.BASE_OBJECT) |
| | | .addAttribute("o"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertFalse(searchOperation.getSearchEntries().isEmpty()); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e.getAttribute("o")); |
| | | assertAttributeOExists(request); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | final SearchRequest request = newSearchRequest("o=test", SearchScope.BASE_OBJECT, "(objectClass=*)") |
| | | final SearchRequest request = newSearchRequest(DN.valueOf("o=test"), SearchScope.BASE_OBJECT) |
| | | .addAttribute("@organization"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertFalse(searchOperation.getSearchEntries().isEmpty()); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e.getAttribute("o")); |
| | | assertAttributeOExists(request); |
| | | } |
| | | |
| | | |
| | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | final SearchRequest request = |
| | | newSearchRequest("o=test", SearchScope.BASE_OBJECT, "(objectClass=*)").addAttribute("@undefined"); |
| | | newSearchRequest(DN.valueOf("o=test"), SearchScope.BASE_OBJECT).addAttribute("@undefined"); |
| | | assertAttributeOExists(request); |
| | | } |
| | | |
| | | private void assertAttributeOExists(final SearchRequest request) |
| | | { |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertFalse(searchOperation.getSearchEntries().isEmpty()); |
| | |
| | | @Test |
| | | public void testProcessSearch1() throws Exception |
| | | { |
| | | SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertFalse(searchOperation.getSearchEntries().isEmpty()); |
| | |
| | | @Test |
| | | public void testProcessSearch2() throws Exception |
| | | { |
| | | SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertFalse(searchOperation.getSearchEntries().isEmpty()); |
| | |
| | | { |
| | | TestInternalSearchListener searchListener = new TestInternalSearchListener(); |
| | | |
| | | SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request, searchListener); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertFalse(searchListener.getSearchEntries().isEmpty()); |
| | |
| | | @Test |
| | | public void testProcessSearch4() throws Exception |
| | | { |
| | | final SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | final SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertFalse(searchOperation.getSearchEntries().isEmpty()); |
| | |
| | | @Test |
| | | public void testProcessSearch5() throws Exception |
| | | { |
| | | final SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | final SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertFalse(searchOperation.getSearchEntries().isEmpty()); |
| | |
| | | TestInternalSearchListener searchListener = |
| | | new TestInternalSearchListener(); |
| | | |
| | | final SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | final SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request, searchListener); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertFalse(searchListener.getSearchEntries().isEmpty()); |
| | |
| | | throws Exception |
| | | { |
| | | InternalClientConnection conn = getRootConnection(); |
| | | InternalSearchOperation searchOperation = conn.processSearch("", SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT)); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertFalse(searchOperation.getSearchEntries().isEmpty()); |
| | | assertTrue(searchOperation.getSearchReferences().isEmpty()); |
| | |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | 0, 0, false, |
| | | LDAPFilter.decode("(objectClass=*)"), |
| | | LDAPFilter.objectClassPresent(), |
| | | new LinkedHashSet<String>()); |
| | | writer.writeMessage(new LDAPMessage(2, searchRequest)); |
| | | |
| | |
| | | nextMessageID(), new ArrayList<Control>(), |
| | | ByteString.empty(), SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, |
| | | false, LDAPFilter.decode("(objectClass=*)"), |
| | | false, LDAPFilter.objectClassPresent(), |
| | | new LinkedHashSet<String>(), null); |
| | | } |
| | | |
| | |
| | | nextMessageID(), new ArrayList<Control>(), |
| | | ByteString.empty(), SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, |
| | | false, LDAPFilter.decode("(objectClass=*)"), |
| | | false, LDAPFilter.objectClassPresent(), |
| | | new LinkedHashSet<String>(), |
| | | new TestInternalSearchListener()); |
| | | } |
| | |
| | | public void testConstructor2WithoutListener() |
| | | throws Exception |
| | | { |
| | | SearchFilter searchFilter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | new InternalSearchOperation(conn, nextOperationID(), |
| | | nextMessageID(), new ArrayList<Control>(), |
| | | DN.rootDN(), SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, |
| | | false, searchFilter, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.objectClassPresent(), |
| | | new LinkedHashSet<String>(), null); |
| | | } |
| | | |
| | |
| | | public void testConstructor2WithListener() |
| | | throws Exception |
| | | { |
| | | SearchFilter searchFilter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | new InternalSearchOperation(conn, nextOperationID(), |
| | | nextMessageID(), new ArrayList<Control>(), |
| | | DN.rootDN(), SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, |
| | | false, searchFilter, |
| | | false, SearchFilter.objectClassPresent(), |
| | | new LinkedHashSet<String>(), |
| | | new TestInternalSearchListener()); |
| | | } |
| | |
| | | @Test() |
| | | public void testGetSearchEntriesAndReferences() throws Exception |
| | | { |
| | | SearchRequest request = Requests.newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | SearchRequest request = Requests.newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertFalse(searchOperation.getSearchEntries().isEmpty()); |
| | |
| | | new ArrayList<Control>(), |
| | | ByteString.empty(), |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, |
| | | 0, false, |
| | | LDAPFilter.decode("(objectClass=*)"), |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | LDAPFilter.objectClassPresent(), |
| | | new LinkedHashSet<String>(), null); |
| | | |
| | | Entry e = TestCaseUtils.makeEntry("dn: ", |
| | |
| | | new ArrayList<Control>(), |
| | | ByteString.empty(), |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, |
| | | 0, false, |
| | | LDAPFilter.decode("(objectClass=*)"), |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | LDAPFilter.objectClassPresent(), |
| | | new LinkedHashSet<String>(), |
| | | new TestInternalSearchListener()); |
| | | |
| | |
| | | new ArrayList<Control>(), |
| | | ByteString.empty(), |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, |
| | | 0, false, |
| | | LDAPFilter.decode("(objectClass=*)"), |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | LDAPFilter.objectClassPresent(), |
| | | new LinkedHashSet<String>(), null); |
| | | |
| | | SearchResultReference reference = |
| | |
| | | new ArrayList<Control>(), |
| | | ByteString.empty(), |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, |
| | | 0, false, |
| | | LDAPFilter.decode("(objectClass=*)"), |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | LDAPFilter.objectClassPresent(), |
| | | new LinkedHashSet<String>(), |
| | | new TestInternalSearchListener()); |
| | | |
| | |
| | | assertEquals(conn.hasPrivilege(Privilege.JMX_READ, null), hasPrivilege); |
| | | |
| | | ByteString dn = ByteString.valueOf("cn=config"); |
| | | LDAPFilter filter = new LDAPFilter(SearchFilter |
| | | .createFilterFromString("(objectClass=*)")); |
| | | InternalSearchOperation searchOperation = conn.processSearch(dn, |
| | | SearchScope.BASE_OBJECT, filter); |
| | | LDAPFilter filter = LDAPFilter.objectClassPresent(); |
| | | InternalSearchOperation searchOperation = conn.processSearch(dn, SearchScope.BASE_OBJECT, filter); |
| | | if (hasPrivilege) |
| | | { |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | conn.nextMessageID(), controls, targetDN, |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.createFilterFromString("(objectClass=*)"), null, |
| | | SearchFilter.objectClassPresent(), null, |
| | | null); |
| | | searchOperation.run(); |
| | | |
| | |
| | | conn.nextMessageID(), controls, targetDN, |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.createFilterFromString("(objectClass=*)"), null, |
| | | SearchFilter.objectClassPresent(), null, |
| | | null); |
| | | searchOperation.run(); |
| | | |
| | |
| | | new SearchRequestProtocolOp(ByteString.empty(), |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | LDAPFilter.decode("(objectClass=*)"), null); |
| | | LDAPFilter.objectClassPresent(), null); |
| | | ArrayList<Control> controls = new ArrayList<Control>(1); |
| | | controls.add(new LDAPControl(OID_MANAGE_DSAIT_CONTROL, true)); |
| | | message = new LDAPMessage(2, searchRequest, controls); |
| | |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.testng.annotations.Test; |
| | | |
| | |
| | | private int sizeLimit = Integer.MAX_VALUE; |
| | | private int timeLimit = Integer.MAX_VALUE; |
| | | private boolean typesOnly = true; |
| | | private LDAPFilter filter; |
| | | private LDAPFilter filter = LDAPFilter.objectClassPresent(); |
| | | private LinkedHashSet<String> attributes = new LinkedHashSet<String>( |
| | | Arrays.asList("description", "cn", "cn;optionA")); |
| | | |
| | | public TestSearchProtocolOp() throws Exception |
| | | { |
| | | filter = LDAPFilter.decode("(objectClass=*)"); |
| | | } |
| | | |
| | | /** |
| | | * Create a test search request protocol op. |
| | | * @return A test search request protocol op. |
| | |
| | | long startMillisecs = System.currentTimeMillis(); |
| | | do |
| | | { |
| | | final SearchRequest request = newSearchRequest(taskEntry.getName(), SearchScope.BASE_OBJECT, "(objectclass=*)"); |
| | | final SearchRequest request = newSearchRequest(taskEntry.getName(), SearchScope.BASE_OBJECT); |
| | | InternalSearchOperation searchOperation = connection.processSearch(request); |
| | | Entry resultEntry = searchOperation.getSearchEntries().getFirst(); |
| | | |
| | |
| | | package org.opends.server.replication; |
| | | |
| | | import java.net.SocketTimeoutException; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import java.util.List; |
| | | import java.util.NoSuchElementException; |
| | | |
| | | import org.assertj.core.api.Assertions; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DeleteOperation; |
| | |
| | | import org.opends.server.replication.server.ReplServerFakeConfiguration; |
| | | import org.opends.server.replication.server.ReplicationServer; |
| | | import org.opends.server.replication.service.ReplicationBroker; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.Operation; |
| | | import org.opends.server.types.OperationType; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.forgerock.opendj.ldap.SearchScope.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | |
| | | private int searchNbMonitorEntries(String filterString) throws Exception |
| | | { |
| | | InternalSearchOperation op = connection.processSearch("cn=monitor", WHOLE_SUBTREE, filterString); |
| | | InternalSearchOperation op = connection.processSearch(newSearchRequest("cn=monitor", WHOLE_SUBTREE, filterString)); |
| | | assertEquals(op.getResultCode(), ResultCode.SUCCESS); |
| | | return op.getEntriesSent(); |
| | | } |
| | |
| | | throws Exception |
| | | { |
| | | // Search for matching entries in config backend |
| | | InternalSearchOperation op = connection.processSearch("cn=config", WHOLE_SUBTREE, filter); |
| | | InternalSearchOperation op = connection.processSearch(newSearchRequest("cn=config", WHOLE_SUBTREE, filter)); |
| | | assertEquals(op.getResultCode(), ResultCode.SUCCESS, op.getErrorMessage() .toString()); |
| | | |
| | | // Check that no entries have been found |
| | |
| | | { |
| | | if (count++>0) |
| | | Thread.sleep(100); |
| | | op = connection.processSearch("cn=replication,cn=monitor", WHOLE_SUBTREE, monitorFilter); |
| | | op = connection.processSearch(newSearchRequest("cn=replication,cn=monitor", WHOLE_SUBTREE, monitorFilter)); |
| | | } |
| | | while (op.getSearchEntries().isEmpty() && (count<100)); |
| | | assertFalse(op.getSearchEntries().isEmpty(), "Could not read monitoring information"); |
| | |
| | | long startMillisecs = System.currentTimeMillis(); |
| | | do |
| | | { |
| | | final SearchRequest request = newSearchRequest(taskEntry.getName(), SearchScope.BASE_OBJECT, "(objectclass=*)"); |
| | | final SearchRequest request = newSearchRequest(taskEntry.getName(), SearchScope.BASE_OBJECT); |
| | | InternalSearchOperation searchOperation = connection.processSearch(request); |
| | | if (searchOperation.getSearchEntries().isEmpty()) |
| | | { |
| | |
| | | TaskState taskState = null; |
| | | do |
| | | { |
| | | final SearchRequest request = newSearchRequest(taskEntry.getName(), SearchScope.BASE_OBJECT, "(objectclass=*)"); |
| | | final SearchRequest request = newSearchRequest(taskEntry.getName(), SearchScope.BASE_OBJECT); |
| | | InternalSearchOperation searchOperation = connection.processSearch(request); |
| | | resultEntry = searchOperation.getSearchEntries().getFirst(); |
| | | |
| | |
| | | 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 static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | "Add of the task definition was not successful"); |
| | | |
| | | // Wait until the task completes. |
| | | final SearchRequest request = newSearchRequest(taskEntry.getName(), SearchScope.BASE_OBJECT, "(objectclass=*)"); |
| | | final SearchRequest request = newSearchRequest(taskEntry.getName(), SearchScope.BASE_OBJECT); |
| | | Entry resultEntry = null; |
| | | String completionTime = null; |
| | | long startMillisecs = System.currentTimeMillis(); |
| | |
| | | import org.opends.server.core.SchemaConfigManager; |
| | | 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.BindRequestProtocolOp; |
| | | import org.opends.server.protocols.ldap.BindResponseProtocolOp; |
| | | import org.opends.server.protocols.ldap.LDAPMessage; |
| | |
| | | |
| | | import static org.forgerock.opendj.ldap.ResultCode.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | { |
| | | assertEquals(conn.hasPrivilege(Privilege.CONFIG_READ, null), hasPrivilege); |
| | | |
| | | InternalSearchOperation searchOperation = conn.processSearch( |
| | | "cn=config", SearchScope.BASE_OBJECT, "(objectClass=*)"); |
| | | SearchRequest request = Requests.newSearchRequest(DN.valueOf("cn=config"), SearchScope.BASE_OBJECT); |
| | | InternalSearchOperation searchOperation = conn.processSearch(request); |
| | | assertPrivilege(searchOperation.getResultCode(), hasPrivilege); |
| | | } |
| | | |
| | |
| | | { |
| | | assertEquals(conn.hasPrivilege(Privilege.UNINDEXED_SEARCH, null), hasPrivilege); |
| | | |
| | | InternalSearchOperation searchOperation = conn.processSearch( |
| | | "dc=unindexed,dc=jeb", SearchScope.WHOLE_SUBTREE, "(carLicense=test*)"); |
| | | SearchRequest request = newSearchRequest("dc=unindexed,dc=jeb", SearchScope.WHOLE_SUBTREE, "(carLicense=test*)"); |
| | | InternalSearchOperation searchOperation = conn.processSearch(request); |
| | | assertPrivilege(searchOperation.getResultCode(), hasPrivilege); |
| | | } |
| | | |
| | |
| | | nextOperationID(), nextMessageID(), controls, targetDN, |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.createFilterFromString("(objectClass=*)"), null, |
| | | SearchFilter.objectClassPresent(), null, |
| | | null); |
| | | searchOperation.run(); |
| | | assertProxyPrivilege(searchOperation.getResultCode(), hasProxyPrivilege); |
| | |
| | | nextMessageID(), controls, targetDN, |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | SearchFilter.createFilterFromString("(objectClass=*)"), null, |
| | | SearchFilter.objectClassPresent(), null, |
| | | null); |
| | | searchOperation.run(); |
| | | assertProxyPrivilege(searchOperation.getResultCode(), hasProxyPrivilege); |
| | |
| | | |
| | | |
| | | LinkedHashSet<SearchFilter> filterSet1 = new LinkedHashSet<SearchFilter>(1); |
| | | filterSet1.add(SearchFilter.createFilterFromString("(objectClass=*)")); |
| | | filterSet1.add(SearchFilter.objectClassPresent()); |
| | | |
| | | LinkedHashSet<SearchFilter> filterSet2 = new LinkedHashSet<SearchFilter>(1); |
| | | filterSet2.add(SearchFilter.createFilterFromString("(o=test)")); |