Commit 821dc9d8 authored by Christian Schudt's avatar Christian Schudt

OF-810 RFC 6121 Routing Compliance Fix

This fix fixes the routing, which is described in RFC 6121 8.5.3.2.1. Message

Misbehavior before: Every message addressed to a full JID, whose resource was not available was routed to the bare JID (as fallback). 8.5.3.2.1 specifies, that only chat messages should be routed to bare JID and other message types should either be ignored or bounced with an error.

Behavior now: non-chat messages are delegated to the offline message strategy, which decides, if the message should be ignored or bounced with an error, depending on the settings in offline-messages.jsp.
parent a811a1f8
......@@ -250,7 +250,13 @@ public class MessageRouter extends BasicModule {
// If message was sent to an unavailable full JID of a user then retry using the bare JID
if (serverName.equals(recipient.getDomain()) && recipient.getResource() != null &&
userManager.isRegisteredUser(recipient.getNode())) {
routingTable.routePacket(recipient.asBareJID(), packet, false);
Message msg = (Message)packet;
if (msg.getType().equals(Message.Type.chat)) {
routingTable.routePacket(recipient.asBareJID(), packet, false);
} else {
// Delegate to offline message strategy, which will either bounce or ignore the message depending on user settings.
messageStrategy.storeOffline((Message) packet);
}
} else {
// Just store the message offline
messageStrategy.storeOffline((Message) packet);
......
......@@ -86,12 +86,7 @@ public class OfflineMessageStrategy extends BasicModule {
!UserManager.getInstance().isRegisteredUser(recipientJID.getNode())) {
return;
}
// Do not store messages of type groupchat, error or headline as specified in JEP-160
if (Message.Type.groupchat == message.getType() ||
Message.Type.error == message.getType() ||
Message.Type.headline == message.getType()) {
return;
}
// Do not store messages if communication is blocked
PrivacyList list =
PrivacyListManager.getInstance().getDefaultPrivacyList(recipientJID.getNode());
......@@ -103,6 +98,38 @@ public class OfflineMessageStrategy extends BasicModule {
return;
}
// 8.5.2. localpart@domainpart
// 8.5.2.2. No Available or Connected Resources
if (recipientJID.getResource() == null) {
if (message.getType() == Message.Type.headline || message.getType() == Message.Type.error) {
// For a message stanza of type "headline" or "error", the server MUST silently ignore the message.
return;
}
// // For a message stanza of type "groupchat", the server MUST return an error to the sender, which SHOULD be <service-unavailable/>.
else if (message.getType() == Message.Type.groupchat) {
bounce(message);
return;
}
} else {
// 8.5.3. localpart@domainpart/resourcepart
// 8.5.3.2.1. Message
// For a message stanza of type "normal", "groupchat", or "headline", the server MUST either (a) silently ignore the stanza
// or (b) return an error stanza to the sender, which SHOULD be <service-unavailable/>.
if (message.getType() == Message.Type.normal || message.getType() == Message.Type.groupchat || message.getType() == Message.Type.headline) {
if (type == Type.bounce) {
bounce(message);
return;
} else {
return;
}
}
// For a message stanza of type "error", the server MUST silently ignore the stanza.
else if (message.getType() == Message.Type.error) {
return;
}
}
if (type == Type.bounce) {
bounce(message);
}
......@@ -168,8 +195,8 @@ public class OfflineMessageStrategy extends BasicModule {
try {
// Generate a rejection response to the sender
Message errorResponse = message.createCopy();
errorResponse.setError(new PacketError(PacketError.Condition.item_not_found,
PacketError.Type.continue_processing));
// return an error stanza to the sender, which SHOULD be <service-unavailable/>
errorResponse.setError(PacketError.Condition.service_unavailable);
errorResponse.setFrom(message.getTo());
errorResponse.setTo(message.getFrom());
// Send the response
......
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