Commit dc47dd47 authored by Tom Evans's avatar Tom Evans Committed by tevans

OF-587: Allow multiple node owners for Roster/Presence access models

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13346 b35dd754-fafc-0310-a699-88a17e54d16e
parent a38803fd
......@@ -51,14 +51,12 @@ public class PresenceAccess extends AccessModel {
if (node.isAdmin(owner)) {
return true;
}
// Get the only owner of the node
JID nodeOwner = node.getOwners().iterator().next();
XMPPServer server = XMPPServer.getInstance();
for (JID nodeOwner : node.getOwners()) {
// Give access to the owner of the roster :)
if (nodeOwner.toBareJID().equals(owner.toBareJID())) {
if (nodeOwner.equals(owner.toBareJID())) {
return true;
}
// Get the roster of the node owner
XMPPServer server = XMPPServer.getInstance();
// Check that the node owner is a local user
if (server.isLocal(nodeOwner)) {
try {
......@@ -69,16 +67,17 @@ public class PresenceAccess extends AccessModel {
RosterItem.SUB_FROM == item.getSubStatus());
}
catch (UserNotFoundException e) {
return false;
// Do nothing
}
}
else {
// Owner of the node is a remote user. This should never happen.
Log.warn("Node with access model Presence has a remote user as owner: " +
node.getNodeID());
return false;
}
}
return false;
}
@Override
public boolean canAccessItems(Node node, JID owner, JID subscriber) {
......
......@@ -55,20 +55,18 @@ public class RosterAccess extends AccessModel {
if (node.isAdmin(owner)) {
return true;
}
// Get the only owner of the node
JID nodeOwner = node.getOwners().iterator().next();
XMPPServer server = XMPPServer.getInstance();
for (JID nodeOwner : node.getOwners()) {
// Give access to the owner of the roster :)
if (nodeOwner.toBareJID().equals(owner.toBareJID())) {
if (nodeOwner.equals(owner.toBareJID())) {
return true;
}
// Get the roster of the node owner
XMPPServer server = XMPPServer.getInstance();
// Check that the node owner is a local user
if (server.isLocal(nodeOwner)) {
try {
Roster roster = server.getRosterManager().getRoster(nodeOwner.getNode());
RosterItem item = roster.getRosterItem(owner);
// Check that the subscriber is subscribe to the node owner's presence
// Check that the subscriber is subscribed to the node owner's presence
boolean isSubscribed = item != null && (
RosterItem.SUB_BOTH == item.getSubStatus() ||
RosterItem.SUB_FROM == item.getSubStatus());
......@@ -94,6 +92,7 @@ public class RosterAccess extends AccessModel {
Log.warn("Node with access model Roster has a remote user as owner: " +
node.getNodeID());
}
}
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