Commit 6ba555d8 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Avoid string prep operations when possible. JM-1210

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@9642 b35dd754-fafc-0310-a699-88a17e54d16e
parent daa618d8
......@@ -243,6 +243,19 @@ public class XMPPServer {
return new JID(username, name, resource);
}
/**
* Creates an XMPPAddress local to this server. The construction of the new JID
* can be optimized by skipping stringprep operations.
*
* @param username the user name portion of the id or null to indicate none is needed.
* @param resource the resource portion of the id or null to indicate none is needed.
* @param skipStringprep true if stringprep should not be applied.
* @return an XMPPAddress for the server.
*/
public JID createJID(String username, String resource, boolean skipStringprep) {
return new JID(username, name, resource, skipStringprep);
}
/**
* Returns a collection with the JIDs of the server's admins. The collection may include
* JIDs of local users and users of remote servers.
......
......@@ -332,7 +332,7 @@ public class EntityCapabilitiesManager implements IQResultListener, UserEventLis
public void userDeleting(User user, Map<String, Object> params) {
// Delete this user's association in entityCapabilitiesUserMap.
JID jid = XMPPServer.getInstance().createJID(user.getUsername(), null);
JID jid = XMPPServer.getInstance().createJID(user.getUsername(), null, true);
String verHashOfUser = entityCapabilitiesUserMap.remove(jid);
// If there are no other references to the deleted user's 'ver' hash,
......
......@@ -263,7 +263,7 @@ public class Group implements Cacheable, Externalizable {
*/
public boolean isUser(String username) {
if (username != null) {
return isUser(XMPPServer.getInstance().createJID(username, null));
return isUser(XMPPServer.getInstance().createJID(username, null, true));
}
else {
return false;
......
......@@ -11,15 +11,18 @@
package org.jivesoftware.openfire.group;
import org.jivesoftware.util.*;
import org.jivesoftware.util.cache.Cache;
import org.jivesoftware.util.cache.CacheFactory;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.event.GroupEventDispatcher;
import org.jivesoftware.openfire.event.GroupEventListener;
import org.jivesoftware.openfire.user.User;
import org.jivesoftware.openfire.user.UserManager;
import org.jivesoftware.openfire.user.UserNotFoundException;
import org.jivesoftware.util.ClassUtils;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.TaskEngine;
import org.jivesoftware.util.cache.Cache;
import org.jivesoftware.util.cache.CacheFactory;
import org.xmpp.packet.JID;
import java.util.Collection;
......@@ -340,7 +343,7 @@ public class GroupManager {
* @return all groups the user belongs to.
*/
public Collection<Group> getGroups(User user) {
return getGroups(XMPPServer.getInstance().createJID(user.getUsername(), null));
return getGroups(XMPPServer.getInstance().createJID(user.getUsername(), null, true));
}
/**
......
......@@ -208,7 +208,7 @@ public class IQAuthHandler extends IQHandler implements IQAuthInfo {
// Verify if there is a resource conflict between new resource and existing one.
// Check if a session already exists with the requested full JID and verify if
// we should kick it off or refuse the new connection
ClientSession oldSession = routingTable.getClientRoute(new JID(username, serverName, resource));
ClientSession oldSession = routingTable.getClientRoute(new JID(username, serverName, resource, true));
if (oldSession != null) {
try {
oldSession.incrementConflictCount();
......
......@@ -104,7 +104,7 @@ public class IQBindHandler extends IQHandler {
String username = authToken.getUsername().toLowerCase();
// If a session already exists with the requested JID, then check to see
// if we should kick it off or refuse the new connection
ClientSession oldSession = routingTable.getClientRoute(new JID(username, serverName, resource));
ClientSession oldSession = routingTable.getClientRoute(new JID(username, serverName, resource, true));
if (oldSession != null) {
try {
oldSession.incrementConflictCount();
......
......@@ -83,7 +83,7 @@ public class PrivacyList implements Cacheable, Externalizable {
}
public PrivacyList(String username, String name, boolean isDefault, Element listElement) {
this.userJID = XMPPServer.getInstance().createJID(username, null);
this.userJID = XMPPServer.getInstance().createJID(username, null, true);
this.name = name;
this.isDefault = isDefault;
// Set the new list items
......
......@@ -650,7 +650,7 @@ public class Roster implements Cacheable, Externalizable {
}
private void broadcast(org.xmpp.packet.Roster roster) {
JID recipient = server.createJID(username, null);
JID recipient = server.createJID(username, null, true);
roster.setTo(recipient);
if (sessionManager == null) {
sessionManager = SessionManager.getInstance();
......@@ -1098,7 +1098,7 @@ public class Roster implements Cacheable, Externalizable {
}
private JID getUserJID() {
return XMPPServer.getInstance().createJID(getUsername(), null);
return XMPPServer.getInstance().createJID(getUsername(), null, true);
}
public void writeExternal(ObjectOutput out) throws IOException {
......
......@@ -805,7 +805,7 @@ public class RosterManager extends BasicModule implements GroupEventListener, Us
if ("everybody".equals(showInRoster)) {
// Add all users in the system
for (String username : UserManager.getInstance().getUsernames()) {
users.add(server.createJID(username, null));
users.add(server.createJID(username, null, true));
}
// Add all logged users. We don't need to add all users in the system since only the
// logged ones will be affected.
......@@ -842,7 +842,7 @@ public class RosterManager extends BasicModule implements GroupEventListener, Us
if ("everybody".equals(showInRoster)) {
// Add all users in the system
for (String username : UserManager.getInstance().getUsernames()) {
users.add(server.createJID(username, null));
users.add(server.createJID(username, null, true));
}
}
else {
......
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