Commit c31976a8 authored by Guus der Kinderen's avatar Guus der Kinderen Committed by akrherz

OF-1174: MUC should always respond to IQ requests.

IQ requests must always be responded to, if only with an error reply. For good
measure, IQ-Ping support was added too.
parent 362bba6b
...@@ -29,6 +29,7 @@ import java.util.Map; ...@@ -29,6 +29,7 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import org.dom4j.Element; import org.dom4j.Element;
import org.dom4j.QName;
import org.jivesoftware.openfire.PacketException; import org.jivesoftware.openfire.PacketException;
import org.jivesoftware.openfire.PacketRouter; import org.jivesoftware.openfire.PacketRouter;
import org.jivesoftware.openfire.auth.UnauthorizedException; import org.jivesoftware.openfire.auth.UnauthorizedException;
...@@ -223,10 +224,8 @@ public class LocalMUCUser implements MUCUser { ...@@ -223,10 +224,8 @@ public class LocalMUCUser implements MUCUser {
JID recipient = packet.getTo(); JID recipient = packet.getTo();
String group = recipient.getNode(); String group = recipient.getNode();
if (group == null) { if (group == null) {
// Ignore packets to the groupchat server // Packets to the groupchat server. This should not occur (should be handled by MultiUserChatServiceImpl instead)
// In the future, we'll need to support TYPE_IQ queries to the server for MUC Log.warn( LocaleUtils.getLocalizedString( "muc.error.not-supported" ) + " " + packet.toString() );
Log.info(LocaleUtils.getLocalizedString("muc.error.not-supported") + " "
+ packet.toString());
} }
else { else {
MUCRole role = roles.get(group); MUCRole role = roles.get(group);
...@@ -371,13 +370,18 @@ public class LocalMUCUser implements MUCUser { ...@@ -371,13 +370,18 @@ public class LocalMUCUser implements MUCUser {
lastPacketTime = System.currentTimeMillis(); lastPacketTime = System.currentTimeMillis();
JID recipient = packet.getTo(); JID recipient = packet.getTo();
String group = recipient.getNode(); String group = recipient.getNode();
if (group == null) { if (group == null)
// Ignore packets to the groupchat server {
// In the future, we'll need to support TYPE_IQ queries to the server for MUC // Packets to the groupchat server. This should not occur (should be handled by MultiUserChatServiceImpl instead)
Log.info(LocaleUtils.getLocalizedString("muc.error.not-supported") + " " if ( packet.isRequest() )
+ packet.toString()); {
sendErrorPacket( packet, PacketError.Condition.feature_not_implemented );
}
Log.warn( LocaleUtils.getLocalizedString( "muc.error.not-supported" ) + " " + packet.toString() );
} }
else { else
{
// Packets to a specific node/group/room
MUCRole role = roles.get(group); MUCRole role = roles.get(group);
if (role == null) { if (role == null) {
// If a non-occupant sends a disco to an address of the form <room@service/nick>, // If a non-occupant sends a disco to an address of the form <room@service/nick>,
...@@ -599,6 +603,9 @@ public class LocalMUCUser implements MUCUser { ...@@ -599,6 +603,9 @@ public class LocalMUCUser implements MUCUser {
} }
} }
} }
} else {
// Packets to the groupchat server. This should not occur (should be handled by MultiUserChatServiceImpl instead)
Log.warn( LocaleUtils.getLocalizedString( "muc.error.not-supported" ) + " " + packet.toString() );
} }
} }
......
...@@ -80,11 +80,7 @@ import org.xmpp.component.ComponentManager; ...@@ -80,11 +80,7 @@ import org.xmpp.component.ComponentManager;
import org.xmpp.forms.DataForm; import org.xmpp.forms.DataForm;
import org.xmpp.forms.DataForm.Type; import org.xmpp.forms.DataForm.Type;
import org.xmpp.forms.FormField; import org.xmpp.forms.FormField;
import org.xmpp.packet.IQ; import org.xmpp.packet.*;
import org.xmpp.packet.JID;
import org.xmpp.packet.Message;
import org.xmpp.packet.Packet;
import org.xmpp.packet.Presence;
import org.xmpp.resultsetmanagement.ResultSet; import org.xmpp.resultsetmanagement.ResultSet;
/** /**
...@@ -335,10 +331,26 @@ public class MultiUserChatServiceImpl implements Component, MultiUserChatService ...@@ -335,10 +331,26 @@ public class MultiUserChatServiceImpl implements Component, MultiUserChatService
return; return;
} }
} }
// The packet is a normal packet that should possibly be sent to the room
JID recipient = packet.getTo(); if ( packet.getTo().getNode() == null )
String roomName = recipient != null ? recipient.getNode() : null; {
getChatUser(packet.getFrom(), roomName).process(packet); // This was addressed at the service itself, which by now should have been handled.
if ( packet instanceof IQ && ((IQ) packet).isRequest() )
{
final IQ reply = IQ.createResultIQ( (IQ) packet );
reply.setChildElement( ((IQ) packet).getChildElement().createCopy() );
reply.setError( PacketError.Condition.feature_not_implemented );
router.route( reply );
}
Log.debug( "Ignoring stanza addressed at conference service: {}", packet.toXML() );
}
else
{
// The packet is a normal packet that should possibly be sent to the room
JID recipient = packet.getTo();
String roomName = recipient != null ? recipient.getNode() : null;
getChatUser( packet.getFrom(), roomName ).process( packet );
}
} }
catch (Exception e) { catch (Exception e) {
Log.error(LocaleUtils.getLocalizedString("admin.error"), e); Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
...@@ -386,6 +398,9 @@ public class MultiUserChatServiceImpl implements Component, MultiUserChatService ...@@ -386,6 +398,9 @@ public class MultiUserChatServiceImpl implements Component, MultiUserChatService
IQ reply = XMPPServer.getInstance().getIQDiscoItemsHandler().handleIQ(iq); IQ reply = XMPPServer.getInstance().getIQDiscoItemsHandler().handleIQ(iq);
router.route(reply); router.route(reply);
} }
else if ("urn:xmpp:ping".equals(namespace)) {
router.route( IQ.createResultIQ(iq) );
}
else { else {
return false; return false;
} }
......
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