Commit 75e0dd64 authored by Tom Evans's avatar Tom Evans Committed by tevans

OF-657: Handle JID escaping; group cache optimization

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13623 b35dd754-fafc-0310-a699-88a17e54d16e
parent fd6696b5
......@@ -86,12 +86,8 @@ public class CrowdAuthProvider implements AuthProvider {
}
}
// Un-escape username.
username = JID.unescapeNode(username);
try {
manager.authenticate(username, password);
LOG.info("authenticated user:" + username);
} catch (RemoteException re) {
throw new UnauthorizedException();
}
......
......@@ -81,8 +81,8 @@ public class CrowdGroupProvider extends AbstractGroupProvider {
userMembershipCache.setMaxLifetime(ttl * 1000); // msecs instead of sec - see Cache API
Cache<String, org.jivesoftware.openfire.crowd.jaxb.Group> groupCache = CacheFactory.createLocalCache(GROUP_CACHE_NAME);
userMembershipCache.setMaxCacheSize(-1);
userMembershipCache.setMaxLifetime(ttl * 1000); // msecs instead of sec - see Cache API
groupCache.setMaxCacheSize(-1);
groupCache.setMaxLifetime(ttl * 1000); // msecs instead of sec - see Cache API
}
public Group getGroup(String name) throws GroupNotFoundException {
......@@ -116,7 +116,7 @@ public class CrowdGroupProvider extends AbstractGroupProvider {
Collection<JID> results = new ArrayList<JID>();
for (String username : users) {
results.add(server.createJID(JID.escapeNode(username), null));
results.add(server.createJID(username, null));
}
groupMembershipCache.put(groupName, results);
......
......@@ -28,6 +28,7 @@ import javax.xml.bind.JAXB;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xmpp.packet.JID;
import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
......@@ -136,6 +137,7 @@ public class CrowdManager {
* @throws UnsupportedEncodingException
*/
public void authenticate(String username, String password) throws RemoteException {
username = JID.unescapeNode(username);
if (LOG.isDebugEnabled()) LOG.debug("authenticate '" + String.valueOf(username) + "'");
PostMethod post = new PostMethod(crowdServer.resolve("authentication?username=" + urlEncode(username)).toString());
......@@ -157,6 +159,8 @@ public class CrowdManager {
} finally {
post.releaseConnection();
}
LOG.info("authenticated user:" + username);
}
......@@ -192,6 +196,7 @@ public class CrowdManager {
if (users != null && users.user != null) {
for (User user : users.user) {
user.name = JID.escapeNode(user.name);
results.add(user);
}
......@@ -273,6 +278,7 @@ public class CrowdManager {
* @throws RemoteException
*/
public List<String> getUserGroups(String username) throws RemoteException {
username = JID.unescapeNode(username);
if (LOG.isDebugEnabled()) LOG.debug("fetch all crowd groups for user:" + username);
int maxResults = 100;
......@@ -383,7 +389,7 @@ public class CrowdManager {
if (users != null && users.user != null) {
for (org.jivesoftware.openfire.crowd.jaxb.User user : users.user) {
results.add(user.name);
results.add(JID.escapeNode(user.name));
}
if (users.user.size() != maxResults) {
......
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