Commit 0a94812d authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Return service_unavailable when IQ packet is blocked.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3428 b35dd754-fafc-0310-a699-88a17e54d16e
parent 316114f2
......@@ -717,21 +717,32 @@ public class ClientSession extends Session {
conflictCount++;
}
public void process(Packet packet) {
/**
* Returns true if the specified packet must be blocked based on the active or default
* privacy list rules. The active list will be tried first. If none was found then the
* default list is going to be used. If no default list was defined for this user then
* allow the packet to flow.
*
* @param packet the packet to analyze if it must be blocked.
* @return true if the specified packet must be blocked.
*/
public boolean shouldBlockPacket(Packet packet) {
if (activeList != null) {
// If a privacy list is active then make sure that the packet is not blocked
if (activeList.shouldBlockPacket(packet)) {
// Communication is blocked. Drop packet.
return;
}
return activeList.shouldBlockPacket(packet);
}
else if (defaultList != null) {
// There is no active list so check if there exists a default list and make
// sure that the packet is not blocked
if (defaultList.shouldBlockPacket(packet)) {
// Communication is blocked. Drop packet.
return;
}
return defaultList.shouldBlockPacket(packet);
}
return false;
}
public void process(Packet packet) {
if (shouldBlockPacket(packet)) {
// Communication is blocked. Drop packet.
return;
}
// Deliver packet to the client
deliver(packet);
......
......@@ -12,13 +12,13 @@
package org.jivesoftware.wildfire;
import org.dom4j.Element;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.wildfire.auth.UnauthorizedException;
import org.jivesoftware.wildfire.container.BasicModule;
import org.jivesoftware.wildfire.handler.IQHandler;
import org.jivesoftware.wildfire.privacy.PrivacyList;
import org.jivesoftware.wildfire.privacy.PrivacyListManager;
import org.jivesoftware.wildfire.auth.UnauthorizedException;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.xmpp.packet.IQ;
import org.xmpp.packet.JID;
import org.xmpp.packet.PacketError;
......@@ -270,10 +270,12 @@ public class IQRouter extends BasicModule {
// So if the target address belongs to this server then use the sessionManager
// instead of the routingTable since unavailable clients won't have a route to them
if (XMPPServer.getInstance().isLocal(recipientJID)) {
Session session = sessionManager.getBestRoute(recipientJID);
ClientSession session = sessionManager.getBestRoute(recipientJID);
if (session != null) {
session.process(packet);
handlerFound = true;
if (!session.shouldBlockPacket(packet)) {
session.process(packet);
handlerFound = true;
}
}
else {
Log.info("Packet sent to unreachable address " + packet);
......
......@@ -11,9 +11,15 @@
package org.jivesoftware.wildfire;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.wildfire.audit.AuditStreamIDFactory;
import org.jivesoftware.wildfire.auth.UnauthorizedException;
import org.jivesoftware.wildfire.component.ComponentSession;
import org.jivesoftware.wildfire.component.InternalComponentManager;
import org.jivesoftware.wildfire.container.BasicModule;
import org.jivesoftware.wildfire.event.SessionEventDispatcher;
import org.jivesoftware.wildfire.handler.PresenceUpdateHandler;
import org.jivesoftware.wildfire.server.IncomingServerSession;
import org.jivesoftware.wildfire.server.OutgoingServerSession;
......@@ -21,12 +27,6 @@ import org.jivesoftware.wildfire.server.OutgoingSessionPromise;
import org.jivesoftware.wildfire.spi.BasicStreamIDFactory;
import org.jivesoftware.wildfire.user.UserManager;
import org.jivesoftware.wildfire.user.UserNotFoundException;
import org.jivesoftware.wildfire.component.ComponentSession;
import org.jivesoftware.wildfire.component.InternalComponentManager;
import org.jivesoftware.wildfire.event.SessionEventDispatcher;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.xmpp.packet.JID;
import org.xmpp.packet.Message;
import org.xmpp.packet.Packet;
......@@ -711,7 +711,7 @@ public class SessionManager extends BasicModule {
* @param recipient The recipient ID to deliver packets to
* @return The XMPPAddress best suited to use for delivery to the recipient
*/
public Session getBestRoute(JID recipient) {
public ClientSession getBestRoute(JID recipient) {
// Return null if the JID belongs to a foreign server
if (serverName == null || !serverName.equals(recipient.getDomain())) {
return null;
......
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