Commit be100f1f authored by Tom Evans's avatar Tom Evans Committed by Dave Cridland

OF-830: Do not use JID-escaping for group names

Fixes roster group sharing when using the LDAP provider for users and
groups, by reverting part of an earlier fix (OF-779).
parent af77674e
......@@ -972,6 +972,7 @@ public class LdapManager {
}
constraints.setReturningAttributes(new String[] { usernameField });
// NOTE: this assumes that the username has already been JID-unescaped
NamingEnumeration<SearchResult> answer = ctx.search("", getSearchFilter(),
new String[] {sanitizeSearchFilter(username)},
constraints);
......@@ -1117,7 +1118,7 @@ public class LdapManager {
}
constraints.setReturningAttributes(new String[] { groupNameField });
String filter = MessageFormat.format(getGroupSearchFilter(), sanitizeSearchFilter(JID.unescapeNode(groupname)));
String filter = MessageFormat.format(getGroupSearchFilter(), sanitizeSearchFilter(groupname));
NamingEnumeration<SearchResult> answer = ctx.search("", filter, constraints);
if (debug) {
......@@ -1841,6 +1842,28 @@ public class LdapManager {
* @return A simple list of strings (that should be sorted) of the results.
*/
public List<String> retrieveList(String attribute, String searchFilter, int startIndex, int numResults, String suffixToTrim) {
return retrieveList(attribute, searchFilter, startIndex, numResults, suffixToTrim, false);
}
/**
* Generic routine for retrieving a list of results from the LDAP server. It's meant to be very
* flexible so that just about any query for a list of results can make use of it without having
* to reimplement their own calls to LDAP. This routine also accounts for sorting settings,
* paging settings, any other global settings, and alternate DNs.
*
* The passed in filter string needs to be pre-prepared! In other words, nothing will be changed
* in the string before it is used as a string.
*
* @param attribute LDAP attribute to be pulled from each result and placed in the return results.
* Typically pulled from this manager.
* @param searchFilter Filter to use to perform the search. Typically pulled from this manager.
* @param startIndex Number/index of first result to include in results. (-1 for no limit)
* @param numResults Number of results to include. (-1 for no limit)
* @param suffixToTrim An arbitrary string to trim from the end of every attribute returned. null to disable.
* @param escapeJIDs Use JID-escaping for returned results (e.g. usernames)
* @return A simple list of strings (that should be sorted) of the results.
*/
public List<String> retrieveList(String attribute, String searchFilter, int startIndex, int numResults, String suffixToTrim, boolean escapeJIDs) {
List<String> results = new ArrayList<String>();
int pageSize = -1;
String pageSizeStr = properties.get("ldap.pagedResultsSize");
......@@ -1923,7 +1946,7 @@ public class LdapManager {
result = result.substring(0,result.length()-suffixToTrim.length());
}
// Add this to the result.
results.add(JID.escapeNode(result));
results.add(escapeJIDs ? JID.escapeNode(result) : result);
}
// Examine the paged results control response
Control[] controls = ctx.getResponseControls();
......@@ -1980,7 +2003,7 @@ public class LdapManager {
result = result.substring(0,result.length()-suffixToTrim.length());
}
// Add this to the result.
results.add(JID.escapeNode(result));
results.add(escapeJIDs ? JID.escapeNode(result) : result);
}
// Examine the paged results control response
Control[] controls = ctx2.getResponseControls();
......
......@@ -179,7 +179,8 @@ public class LdapUserProvider implements UserProvider {
MessageFormat.format(manager.getSearchFilter(), "*"),
-1,
-1,
null
null,
true
);
}
......@@ -193,7 +194,8 @@ public class LdapUserProvider implements UserProvider {
MessageFormat.format(manager.getSearchFilter(), "*"),
startIndex,
numResults,
manager.getUsernameSuffix()
manager.getUsernameSuffix(),
true
);
return new UserCollection(userlist.toArray(new String[userlist.size()]));
}
......@@ -280,7 +282,8 @@ public class LdapUserProvider implements UserProvider {
filter.toString(),
startIndex,
numResults,
manager.getUsernameSuffix()
manager.getUsernameSuffix(),
true
);
return new UserCollection(userlist.toArray(new String[userlist.size()]));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment