Commit 49db6756 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Make sure to return an IQ error if an unhandled exception occurs. JM-638

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3760 b35dd754-fafc-0310-a699-88a17e54d16e
parent 16ba5ac1
......@@ -83,7 +83,6 @@ public class IQAuthHandler extends IQHandler implements IQAuthInfo {
}
public IQ handleIQ(IQ packet) throws UnauthorizedException, PacketException {
try {
ClientSession session = sessionManager.getSession(packet.getFrom());
// If no session was found then answer an error (if possible)
if (session == null) {
......@@ -159,10 +158,6 @@ public class IQAuthHandler extends IQHandler implements IQAuthInfo {
// to the correct session. Any other session of the same user but with different
// resource is incorrect.
session.process(response);
}
catch (Exception e) {
Log.error("Error handling authentication IQ packet", e);
}
return null;
}
......@@ -189,7 +184,7 @@ public class IQAuthHandler extends IQHandler implements IQAuthInfo {
// If a session already exists with the requested JID, then check to see
// if we should kick it off or refuse the new connection
if (sessionManager.isActiveRoute(username, resource)) {
ClientSession oldSession = null;
ClientSession oldSession;
try {
String domain = localServer.getServerInfo().getName();
oldSession = sessionManager.getSession(username, domain, resource);
......@@ -260,7 +255,7 @@ public class IQAuthHandler extends IQHandler implements IQAuthInfo {
}
private IQ anonymousLogin(ClientSession session, IQ packet) {
IQ response = IQ.createResultIQ(packet);;
IQ response = IQ.createResultIQ(packet);
if (anonymousAllowed) {
session.setAnonymousAuth();
response.setTo(session.getAddress());
......
......@@ -11,11 +11,11 @@
package org.jivesoftware.wildfire.handler;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.wildfire.*;
import org.jivesoftware.wildfire.auth.UnauthorizedException;
import org.jivesoftware.wildfire.container.BasicModule;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.xmpp.packet.IQ;
import org.xmpp.packet.Packet;
import org.xmpp.packet.PacketError;
......@@ -45,9 +45,9 @@ public abstract class IQHandler extends BasicModule implements ChannelHandler {
public void process(Packet packet) throws PacketException {
IQ iq = (IQ) packet;
try {
iq = handleIQ(iq);
if (iq != null) {
deliverer.deliver(iq);
IQ reply = handleIQ(iq);
if (reply != null) {
deliverer.deliver(reply);
}
}
catch (org.jivesoftware.wildfire.auth.UnauthorizedException e) {
......@@ -56,10 +56,7 @@ public abstract class IQHandler extends BasicModule implements ChannelHandler {
IQ response = IQ.createResultIQ(iq);
response.setChildElement(iq.getChildElement().createCopy());
response.setError(PacketError.Condition.not_authorized);
Session session = sessionManager.getSession(iq.getFrom());
if (!session.getConnection().isClosed()) {
session.process(response);
}
sessionManager.getSession(iq.getFrom()).process(response);
}
catch (Exception de) {
Log.error(LocaleUtils.getLocalizedString("admin.error"), de);
......@@ -69,6 +66,15 @@ public abstract class IQHandler extends BasicModule implements ChannelHandler {
}
catch (Exception e) {
Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
try {
IQ response = IQ.createResultIQ(iq);
response.setChildElement(iq.getChildElement().createCopy());
response.setError(PacketError.Condition.internal_server_error);
sessionManager.getSession(iq.getFrom()).process(response);
}
catch (Exception e1) {
// Do nothing
}
}
}
......
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