Class SessionPacketRouter

  • All Implemented Interfaces:
    PacketRouter
    Direct Known Subclasses:
    StreamManagementPacketRouter

    public class SessionPacketRouter
    extends Object
    implements PacketRouter
    Handles the routing of packets to a particular session. It will invoke all of the appropriate interceptors, before and after having the server process the message.
    Author:
    Alexander Wenckus
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean isInvalidStanzaSentPriorToResourceBinding​(org.xmpp.packet.Packet stanza, ClientSession session)
      Determines if a peer that is sending a stanza in violation of RFC 6120, section 7.1: If, before completing the resource binding step, the client attempts to send an XML stanza to an entity other than the server itself or the client's account, the server MUST NOT process the stanza and MUST close the stream with a <not-authorized/> stream error. When this method returns 'true', the stream should be closed.
      void route​(org.dom4j.Element wrappedElement)  
      void route​(org.xmpp.packet.IQ packet)
      Routes the given IQ packet.
      void route​(org.xmpp.packet.Message packet)
      Routes the given Message packet.
      void route​(org.xmpp.packet.Packet packet)
      Routes the given packet based on its type.
      void route​(org.xmpp.packet.Presence packet)
      Routes the given Presence packet.
      void setSkipJIDValidation​(boolean skipJIDValidation)
      Sets if TO addresses of Elements being routed should be validated.
    • Constructor Detail

    • Method Detail

      • setSkipJIDValidation

        public void setSkipJIDValidation​(boolean skipJIDValidation)
        Sets if TO addresses of Elements being routed should be validated. Doing stringprep operations is very expensive and sometimes we already validated the TO address so there is no need to validate again the address. For instance, when using Connection Managers the validation is done by the Connection Manager so we can just trust the TO address. On the other hand, the FROM address is set by the server so there is no need to validate it.

        By default validation is enabled.

        Parameters:
        skipJIDValidation - true if validation of TO address is enabled.
      • route

        public void route​(org.xmpp.packet.Packet packet)
        Description copied from interface: PacketRouter
        Routes the given packet based on its type.
        Specified by:
        route in interface PacketRouter
        Parameters:
        packet - The packet to route.
      • route

        public void route​(org.xmpp.packet.IQ packet)
        Description copied from interface: PacketRouter
        Routes the given IQ packet.
        Specified by:
        route in interface PacketRouter
        Parameters:
        packet - The packet to route.
      • route

        public void route​(org.xmpp.packet.Message packet)
        Description copied from interface: PacketRouter
        Routes the given Message packet.
        Specified by:
        route in interface PacketRouter
        Parameters:
        packet - The packet to route.
      • route

        public void route​(org.xmpp.packet.Presence packet)
        Description copied from interface: PacketRouter
        Routes the given Presence packet.
        Specified by:
        route in interface PacketRouter
        Parameters:
        packet - The packet to route.
      • isInvalidStanzaSentPriorToResourceBinding

        public static boolean isInvalidStanzaSentPriorToResourceBinding​(org.xmpp.packet.Packet stanza,
                                                                        ClientSession session)
        Determines if a peer that is sending a stanza in violation of RFC 6120, section 7.1:
        If, before completing the resource binding step, the client attempts to send an XML stanza to an entity other than the server itself or the client's account, the server MUST NOT process the stanza and MUST close the stream with a <not-authorized/> stream error.
        When this method returns 'true', the stream should be closed. This method does not close the stream.
        Parameters:
        session - The session over which the stanza is sent to Openfire.
        stanza - The stanza that is sent to Openfire.
        Returns:
        true if the peer is in violation (and the stream should be closed), otherwise false.
        See Also:
        RFC 6120, section 7.1, issue OF-2565