Commit 37c43c81 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Optimization - do not load User when not needed.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@6364 b35dd754-fafc-0310-a699-88a17e54d16e
parent ec5e51fa
......@@ -23,8 +23,6 @@ import org.jivesoftware.wildfire.net.SocketConnection;
import org.jivesoftware.wildfire.privacy.PrivacyList;
import org.jivesoftware.wildfire.privacy.PrivacyListManager;
import org.jivesoftware.wildfire.user.PresenceEventDispatcher;
import org.jivesoftware.wildfire.user.User;
import org.jivesoftware.wildfire.user.UserManager;
import org.jivesoftware.wildfire.user.UserNotFoundException;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
......@@ -526,20 +524,16 @@ public class ClientSession extends Session {
*
* @param auth the authentication token obtained from the AuthFactory.
* @param resource the resource this session authenticated under.
* @param userManager the user manager this authentication occured under.
*/
public void setAuthToken(AuthToken auth, UserManager userManager, String resource)
throws UserNotFoundException
{
User user = userManager.getUser(auth.getUsername());
setAddress(new JID(user.getUsername(), getServerName(), resource));
public void setAuthToken(AuthToken auth, String resource) {
setAddress(new JID(auth.getUsername(), getServerName(), resource));
authToken = auth;
sessionManager.addSession(this);
setStatus(Session.STATUS_AUTHENTICATED);
// Set default privacy list for this session
setDefaultList(PrivacyListManager.getInstance().getDefaultPrivacyList(user.getUsername()));
setDefaultList(PrivacyListManager.getInstance().getDefaultPrivacyList(auth.getUsername()));
}
/**
......
......@@ -222,7 +222,7 @@ public class IQAuthHandler extends IQHandler implements IQAuthInfo {
}
}
// Set that the new session has been authenticated successfully
session.setAuthToken(token, userManager, resource);
session.setAuthToken(token, resource);
packet.setFrom(session.getAddress());
return IQ.createResultIQ(packet);
}
......
......@@ -18,8 +18,6 @@ import org.jivesoftware.util.Log;
import org.jivesoftware.wildfire.*;
import org.jivesoftware.wildfire.auth.AuthToken;
import org.jivesoftware.wildfire.auth.UnauthorizedException;
import org.jivesoftware.wildfire.user.UserManager;
import org.jivesoftware.wildfire.user.UserNotFoundException;
import org.xmpp.packet.IQ;
import org.xmpp.packet.PacketError;
import org.xmpp.packet.StreamError;
......@@ -39,7 +37,6 @@ import org.xmpp.packet.StreamError;
public class IQBindHandler extends IQHandler {
private IQHandlerInfo info;
private UserManager userManager;
private XMPPServer localServer;
public IQBindHandler() {
......@@ -83,7 +80,6 @@ public class IQBindHandler extends IQHandler {
return null;
}
}
try {
// Get the token that was generated during the SASL authentication
AuthToken authToken = session.getAuthToken();
if (authToken.isAnonymous()) {
......@@ -124,18 +120,9 @@ public class IQBindHandler extends IQHandler {
}
}
// If the connection was not refused due to conflict, log the user in
session.setAuthToken(authToken, userManager, resource);
}
}
catch (UserNotFoundException e) {
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(PacketError.Condition.not_authorized);
// Send the error directly since a route does not exist at this point.
session.process(reply);
return null;
session.setAuthToken(authToken, resource);
}
child.addElement("jid").setText(session.getAddress().toString());
// Send the response directly since a route does not exist at this point.
session.process(reply);
......@@ -145,7 +132,6 @@ public class IQBindHandler extends IQHandler {
public void initialize(XMPPServer server) {
super.initialize(server);
localServer = server;
userManager = server.getUserManager();
}
public IQHandlerInfo getInfo() {
......
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