Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add utility methods to LdapOperations with LdapQuery and DirContextProcessor #818

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1508,6 +1508,53 @@ boolean authenticate(String base, String filter, String password, AuthenticatedL
*/
<T> List<T> search(LdapQuery query, AttributesMapper<T> mapper);

/**
* Perform a search with parameters from the specified LdapQuery. All found objects
* will be supplied to the <code>NameClassPairCallbackHandler</code> for processing.
* @param query the LDAP query specification.
* @param callbackHandler the <code>NameClassPairCallbackHandler</code> to supply all
* found entries to.
* @param processor <code>DirContextProcessor</code> for custom pre- and
* post-processing.
* @throws NamingException if any error occurs.
* @since 2.0
* @see org.springframework.ldap.query.LdapQueryBuilder
* @see org.springframework.ldap.core.support.CountNameClassPairCallbackHandler
*/
void search(LdapQuery query, NameClassPairCallbackHandler callbackHandler, DirContextProcessor processor);

/**
* Perform a search with parameters from the specified LdapQuery. All found objects
* will be supplied to the <code>ContextMapper</code> for processing, and all returned
* objects will be collected in a list to be returned.
* @param query the LDAP query specification.
* @param mapper the <code>ContextMapper</code> to supply all found entries to.
* @param processor <code>DirContextProcessor</code> for custom pre- and
* post-processing.
* @return a <code>List</code> containing all entries received from the
* <code>ContextMapper</code>.
* @throws NamingException if any error occurs.
* @since 2.0
* @see org.springframework.ldap.query.LdapQueryBuilder
*/
<T> List<T> search(LdapQuery query, ContextMapper<T> mapper, DirContextProcessor processor);

/**
* Perform a search with parameters from the specified LdapQuery. The Attributes of
* the found entries will be supplied to the <code>AttributesMapper</code> for
* processing, and all returned objects will be collected in a list to be returned.
* @param query the LDAP query specification.
* @param mapper the <code>Attributes</code> to supply all found Attributes to.
* @param processor <code>DirContextProcessor</code> for custom pre- and
* post-processing.
* @return a <code>List</code> containing all entries received from the
* <code>Attributes</code>.
* @throws NamingException if any error occurs.
* @since 2.0
* @see org.springframework.ldap.query.LdapQueryBuilder
*/
<T> List<T> search(LdapQuery query, AttributesMapper<T> mapper, DirContextProcessor processor);

/**
* Perform a search for a unique entry matching the specified LDAP query and return
* the found entry as a DirContextOperation instance. If no entry is found or if there
Expand Down
21 changes: 21 additions & 0 deletions core/src/main/java/org/springframework/ldap/core/LdapTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,27 @@ public <T> List<T> search(LdapQuery query, AttributesMapper<T> mapper) {
return search(query.base(), query.filter().encode(), searchControls, mapper);
}

@Override
public void search(LdapQuery query, NameClassPairCallbackHandler callbackHandler, DirContextProcessor processor) {
SearchControls searchControls = searchControlsForQuery(query, DONT_RETURN_OBJ_FLAG);

search(query.base(), query.filter().encode(), searchControls, callbackHandler, processor);
}

@Override
public <T> List<T> search(LdapQuery query, ContextMapper<T> mapper, DirContextProcessor processor) {
SearchControls searchControls = searchControlsForQuery(query, DONT_RETURN_OBJ_FLAG);

return search(query.base(), query.filter().encode(), searchControls, mapper, processor);
}

@Override
public <T> List<T> search(LdapQuery query, AttributesMapper<T> mapper, DirContextProcessor processor) {
SearchControls searchControls = searchControlsForQuery(query, DONT_RETURN_OBJ_FLAG);

return search(query.base(), query.filter().encode(), searchControls, mapper, processor);
}

/**
* {@inheritDoc}
*/
Expand Down