Class AdminManager


  • public class AdminManager
    extends Object
    The AdminManager manages the AdminProvider configured for this server, caches knowledge of accounts with admin permissions, and provides a single point of entry for handling getting and setting administrative accounts. The provider can be specified using the system property:
    • provider.admin.className = my.admin.provider
    Author:
    Daniel Henninger
    • Method Detail

      • getAdminProvider

        public static AdminProvider getAdminProvider()
        Returns the currently-installed AdminProvider. Warning: in virtually all cases the admin provider should not be used directly. Instead, the appropriate methods in AdminManager should be called. Direct access to the admin provider is only provided for special-case logic.
        Returns:
        the current AdminProvider.
      • getInstance

        public static AdminManager getInstance()
        Returns a singleton instance of AdminManager.
        Returns:
        a AdminManager instance.
      • refreshAdminAccounts

        public void refreshAdminAccounts()
        Refreshs the list of admin users from the provider.
      • getAdminAccounts

        public List<org.xmpp.packet.JID> getAdminAccounts()
        Returns the list of admin users from the provider.
        Returns:
        The list of users with admin status.
      • addAdminAccount

        public void addAdminAccount​(String username)
        Adds a new account to the list of Admin accounts, based off a username, which will be converted into a JID.
        Parameters:
        username - Username of account to add to list of admins.
      • addAdminAccount

        public void addAdminAccount​(org.xmpp.packet.JID jid)
        Adds a new account to the list of Admin accounts, based off a JID.
        Parameters:
        jid - JID of account to add to list of admins.
      • removeAdminAccount

        public void removeAdminAccount​(String username)
        Removes an account from the list of Admin accounts, based off username, which will be converted to a JID.
        Parameters:
        username - Username of user to remove from admin list.
      • removeAdminAccount

        public void removeAdminAccount​(org.xmpp.packet.JID jid)
        Removes an account from the list of Admin accounts, based off JID.
        Parameters:
        jid - JID of user to remove from admin list.
      • isUserAdmin

        public boolean isUserAdmin​(String username,
                                   boolean allowAdminIfEmpty)
        Returns true if the user is an admin.
        Parameters:
        username - Username of user to check whether they are an admin or not.
        allowAdminIfEmpty - Allows the "admin" user to log in if the adminList is empty.
        Returns:
        True or false if user is an admin.
      • isUserAdmin

        public boolean isUserAdmin​(org.xmpp.packet.JID jid,
                                   boolean allowAdminIfEmpty)
        Returns true if the user is an admin.
        Parameters:
        jid - JID of user to check whether they are an admin or not.
        allowAdminIfEmpty - Allows the "admin" user to log in if the adminList is empty.
        Returns:
        True or false if user is an admin.
      • clearAdminUsers

        public void clearAdminUsers()
        Clears the list of admin users.
      • setAdminUsers

        public void setAdminUsers​(List<String> usernames)
        Sets the list of admin users based off of a list of usernames. Clears list first.
        Parameters:
        usernames - List of usernames to set as admins.
      • setAdminJIDs

        public void setAdminJIDs​(List<org.xmpp.packet.JID> jids)
        Sets the list of admin users based off of a list of jids. Clears list first.
        Parameters:
        jids - List of jids to set as admins.