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