Commit 78e84947 authored by Greg Thomas's avatar Greg Thomas

Allow remotely connected servers to subscribe to local pubsub nodes

parent d44eb157
......@@ -21,6 +21,7 @@ import org.dom4j.Element;
import org.dom4j.QName;
import org.jivesoftware.openfire.PacketRouter;
import org.jivesoftware.openfire.RoutingTable;
import org.jivesoftware.openfire.SessionManager;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.XMPPServerListener;
import org.jivesoftware.openfire.component.InternalComponentManager;
......@@ -572,7 +573,7 @@ public class PubSubEngine {
private void subscribeNodeAsync(final IQ iq, final JID subscriberJID, final Node node, final JID owner, final PubSubService service, final JID from, final Element childElement, final AccessModel accessModel) {
// Check if the subscriber is an anonymous user
if (!isComponent(subscriberJID) && !UserManager.getInstance().isRegisteredUser(subscriberJID)) {
if (!isComponent(subscriberJID) && !isRemoteServer(subscriberJID) && !UserManager.getInstance().isRegisteredUser(subscriberJID)) {
// Anonymous users cannot subscribe to the node. Return forbidden error
sendErrorPacket(iq, PacketError.Condition.forbidden, null);
return;
......@@ -1934,4 +1935,25 @@ public class PubSubEngine {
}
return false;
}
/**
* Checks to see if the supplied JID is that of a connected remote server
* @param jid the JID representing the remote server
* @return true if the supplied JID is a connected server session
*/
private boolean isRemoteServer(final JID jid) {
final String jidString = jid.toString();
final SessionManager sessionManager = SessionManager.getInstance();
for (final String incomingServer : sessionManager.getIncomingServers()) {
if(incomingServer.equals(jidString)) {
return true;
}
}
for (final String outgoingServer : sessionManager.getOutgoingServers()) {
if(outgoingServer.equals(jidString)) {
return true;
}
}
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