Class IQRosterHandler

  • All Implemented Interfaces:
    ChannelHandler, Module, ServerFeaturesProvider

    public class IQRosterHandler
    extends IQHandler
    implements ServerFeaturesProvider
    Implements the TYPE_IQ jabber:iq:roster protocol. Clients use this protocol to retrieve, update, and rosterMonitor roster entries (buddy lists). The server manages the basics of roster subscriptions and roster updates based on presence and iq:roster packets, while the client maintains the user interface aspects of rosters such as organizing roster entries into groups.

    A 'get' query retrieves a snapshot of the roster. A 'set' query updates the roster (typically with new group info). The server sends 'set' updates asynchronously when roster entries change status.

    Currently an empty implementation to allow usage with normal clients. Future implementation needed.

    Assumptions

    This handler assumes that the request is addressed to the server. An appropriate TYPE_IQ tag matcher should be placed in front of this one to route TYPE_IQ requests not addressed to the server to another channel (probably for direct delivery to the recipient).

    Warning

    There should be a way of determining whether a session has authorization to access this feature. I'm not sure it is a good idea to do authorization in each handler. It would be nice if the framework could assert authorization policies across channels.
    Author:
    Iain Shigeoka
    • Constructor Detail

      • IQRosterHandler

        public IQRosterHandler()
    • Method Detail

      • handleIQ

        public org.xmpp.packet.IQ handleIQ​(org.xmpp.packet.IQ packet)
                                    throws UnauthorizedException,
                                           PacketException
        Handles all roster queries. There are two major types of queries:
        • Roster remove - A forced removal of items from a roster. Roster removals are the only roster queries allowed to directly affect the roster from another user.
        • Roster management - A local user looking up or updating their roster.
        Specified by:
        handleIQ in class IQHandler
        Parameters:
        packet - The update packet
        Returns:
        The reply or null if no reply
        Throws:
        UnauthorizedException - if the user that sent the packet is not authorized to request the given operation.
        PacketException
      • initialize

        public void initialize​(XMPPServer server)
        Description copied from class: BasicModule

        Initializes the basic module.

        Inheriting classes that choose to override this method MUST call this initialize() method before accessing BasicModule resources.

        Specified by:
        initialize in interface Module
        Overrides:
        initialize in class IQHandler
        Parameters:
        server - the server hosting this module.
      • getInfo

        public IQHandlerInfo getInfo()
        Description copied from class: IQHandler
        Returns the handler information to help generically handle IQ packets. IQHandlers that aren't local server iq handlers (e.g. chatbots, transports, etc) return null.
        Specified by:
        getInfo in class IQHandler
        Returns:
        The IQHandlerInfo for this handler
      • getFeatures

        public Iterator<String> getFeatures()
        Description copied from interface: ServerFeaturesProvider
        Returns an Iterator (of String) with the supported features by the server. The features to include are the features offered and supported protocols by the SERVER. The idea is that different modules may provide their features that will ultimately be part of the features offered by the server.
        Specified by:
        getFeatures in interface ServerFeaturesProvider
        Returns:
        an Iterator (of String) with the supported features by the server.