use of org.jivesoftware.openfire.XMPPServer in project Openfire by igniterealtime.
the class PresenceAccess method canSubscribe.
@Override
public boolean canSubscribe(Node node, JID owner, JID subscriber) {
// Let node owners and sysadmins always subcribe to the node
if (node.isAdmin(owner)) {
return true;
}
XMPPServer server = XMPPServer.getInstance();
for (JID nodeOwner : node.getOwners()) {
// Give access to the owner of the roster :)
if (nodeOwner.equals(owner)) {
return true;
}
// 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
return item != null && (RosterItem.SUB_BOTH == item.getSubStatus() || RosterItem.SUB_FROM == item.getSubStatus());
} catch (UserNotFoundException e) {
// 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.getUniqueIdentifier());
}
}
return false;
}
use of org.jivesoftware.openfire.XMPPServer in project Openfire by igniterealtime.
the class GetClusteredVersions method run.
@Override
public void run() {
final XMPPServer xmppServer = XMPPServer.getInstance();
openfireVersion = xmppServer.getServerInfo().getVersion().toString();
pluginVersions = new HashMap<>();
pluginVersions = xmppServer.getPluginManager().getMetadataExtractedPlugins().values().stream().filter(pluginMetadata -> !pluginMetadata.getCanonicalName().equals("admin")).collect(Collectors.toMap(PluginMetadata::getName, pluginMetadata -> pluginMetadata.getVersion().toString()));
}
Aggregations