Search in sources :

Example 26 with XMPPServer

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;
}
Also used : UserNotFoundException(org.jivesoftware.openfire.user.UserNotFoundException) RosterItem(org.jivesoftware.openfire.roster.RosterItem) XMPPServer(org.jivesoftware.openfire.XMPPServer) JID(org.xmpp.packet.JID) Roster(org.jivesoftware.openfire.roster.Roster)

Example 27 with XMPPServer

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()));
}
Also used : XMPPServer(org.jivesoftware.openfire.XMPPServer) PluginMetadata(org.jivesoftware.openfire.container.PluginMetadata)

Aggregations

XMPPServer (org.jivesoftware.openfire.XMPPServer)27 JID (org.xmpp.packet.JID)11 UserNotFoundException (org.jivesoftware.openfire.user.UserNotFoundException)8 GroupNotFoundException (org.jivesoftware.openfire.group.GroupNotFoundException)5 NamingException (javax.naming.NamingException)3 LdapName (javax.naming.ldap.LdapName)3 Group (org.jivesoftware.openfire.group.Group)3 User (org.jivesoftware.openfire.user.User)3 Presence (org.xmpp.packet.Presence)3 PrintWriter (java.io.PrintWriter)2 Locale (java.util.Locale)2 TreeSet (java.util.TreeSet)2 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 NamingEnumeration (javax.naming.NamingEnumeration)2 Attribute (javax.naming.directory.Attribute)2 Attributes (javax.naming.directory.Attributes)2 SearchControls (javax.naming.directory.SearchControls)2 SearchResult (javax.naming.directory.SearchResult)2 Plugin (org.jivesoftware.openfire.container.Plugin)2