Commit 498c7be7 authored by guus's avatar guus

Allow components to create nodes for pubsub (OF-80)

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@11499 b35dd754-fafc-0310-a699-88a17e54d16e
parent 3c0bd7d6
...@@ -35,8 +35,10 @@ import org.dom4j.DocumentHelper; ...@@ -35,8 +35,10 @@ import org.dom4j.DocumentHelper;
import org.dom4j.Element; import org.dom4j.Element;
import org.dom4j.QName; import org.dom4j.QName;
import org.jivesoftware.openfire.PacketRouter; import org.jivesoftware.openfire.PacketRouter;
import org.jivesoftware.openfire.RoutingTable;
import org.jivesoftware.openfire.XMPPServer; import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.XMPPServerListener; import org.jivesoftware.openfire.XMPPServerListener;
import org.jivesoftware.openfire.component.InternalComponentManager;
import org.jivesoftware.openfire.pubsub.models.AccessModel; import org.jivesoftware.openfire.pubsub.models.AccessModel;
import org.jivesoftware.openfire.user.UserManager; import org.jivesoftware.openfire.user.UserManager;
import org.jivesoftware.util.StringUtils; import org.jivesoftware.util.StringUtils;
...@@ -1083,7 +1085,7 @@ public class PubSubEngine { ...@@ -1083,7 +1085,7 @@ public class PubSubEngine {
// Get sender of the IQ packet // Get sender of the IQ packet
JID from = iq.getFrom(); JID from = iq.getFrom();
// Verify that sender has permissions to create nodes // Verify that sender has permissions to create nodes
if (!service.canCreateNode(from) || !UserManager.getInstance().isRegisteredUser(from)) { if (!service.canCreateNode(from) || (!UserManager.getInstance().isRegisteredUser(from) && !isComponent(from)) ) {
// The user is not allowed to create nodes so return an error // The user is not allowed to create nodes so return an error
sendErrorPacket(iq, PacketError.Condition.forbidden, null); sendErrorPacket(iq, PacketError.Condition.forbidden, null);
return; return;
...@@ -1912,4 +1914,18 @@ public class PubSubEngine { ...@@ -1912,4 +1914,18 @@ public class PubSubEngine {
} }
} }
/**
* Checks to see if the jid given is a component by looking at the routing
* table. Similar to {@link InternalComponentManager#hasComponent(JID)}.
*
* @param jid
* @return <tt>true</tt> if the JID is a component, <tt>false<.tt> if not.
*/
private boolean isComponent(JID jid) {
final RoutingTable routingTable = XMPPServer.getInstance().getRoutingTable();
if (routingTable != null) {
return routingTable.hasComponentRoute(jid);
}
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