Commit fd4033f6 authored by Matt Tucker's avatar Matt Tucker Committed by matt

Initial support for JID escaping (JM-230).


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1302 b35dd754-fafc-0310-a699-88a17e54d16e
parent bf11ac8f
......@@ -15,6 +15,7 @@ import org.jivesoftware.messenger.user.*;
import org.jivesoftware.util.JiveConstants;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.xmpp.packet.JID;
import javax.naming.NamingEnumeration;
import javax.naming.directory.*;
......@@ -61,6 +62,8 @@ public class LdapUserProvider implements UserProvider {
}
public User loadUser(String username) throws UserNotFoundException {
// Un-escape username.
username = JID.unescapeNode(username);
DirContext ctx = null;
try {
String userDN = manager.findUserDN(username);
......@@ -153,10 +156,10 @@ public class LdapUserProvider implements UserProvider {
NamingEnumeration answer = ctx.search("", filter, constraints);
while (answer.hasMoreElements()) {
// Get the next userID.
usernames.add(
(String)((SearchResult)answer.next()).getAttributes().get(
manager.getUsernameField()).get()
);
String username = (String)((SearchResult)answer.next()).getAttributes().get(
manager.getUsernameField()).get();
// Escape username and add to results.
usernames.add(JID.escapeNode(username));
}
}
catch (Exception e) {
......@@ -208,10 +211,10 @@ public class LdapUserProvider implements UserProvider {
{
while (answer.hasMoreElements()) {
// Get the next userID.
usernames.add(
(String)((SearchResult)answer.next()).getAttributes().get(
manager.getUsernameField()).get()
);
String username = (String)((SearchResult)answer.next()).getAttributes().get(
manager.getUsernameField()).get();
// Escape username and add to results.
usernames.add(JID.escapeNode(username));
}
Collections.sort(usernames);
usernames = usernames.subList(startIndex, startIndex+numResults);
......@@ -230,10 +233,10 @@ public class LdapUserProvider implements UserProvider {
for (int i = 0; i < numResults; i++) {
if (answer.hasMoreElements()) {
// Get the next userID.
usernames.add(
(String)((SearchResult)answer.next()).getAttributes().get(
manager.getUsernameField()).get()
);
String username = (String)((SearchResult)answer.next()).getAttributes().get(
manager.getUsernameField()).get();
// Escape username and add to results.
usernames.add(JID.escapeNode(username));
}
else {
break;
......@@ -323,10 +326,10 @@ public class LdapUserProvider implements UserProvider {
NamingEnumeration answer = ctx.search("", filter.toString(), constraints);
while (answer.hasMoreElements()) {
// Get the next userID.
usernames.add(
(String)((SearchResult)answer.next()).getAttributes().get(
manager.getUsernameField()).get()
);
String username = (String)((SearchResult)answer.next()).getAttributes().get(
manager.getUsernameField()).get();
// Escape username and add to results.
usernames.add(JID.escapeNode(username));
}
// If client-side sorting is enabled, sort.
if (Boolean.valueOf(JiveGlobals.getXMLProperty(
......@@ -398,10 +401,10 @@ public class LdapUserProvider implements UserProvider {
for (int i = 0; i < numResults; i++) {
if (answer.hasMoreElements()) {
// Get the next userID.
usernames.add(
(String)((SearchResult)answer.next()).getAttributes().get(
manager.getUsernameField()).get()
);
String username = (String)((SearchResult)answer.next()).getAttributes().get(
manager.getUsernameField()).get();
// Escape username and add to results.
usernames.add(JID.escapeNode(username));
}
else {
break;
......
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