Class ServerStanzaHandler

java.lang.Object
org.jivesoftware.openfire.net.StanzaHandler
org.jivesoftware.openfire.net.ServerStanzaHandler

public class ServerStanzaHandler extends StanzaHandler
Handler of XML stanzas sent by remote servers. Remote servers that send stanzas with no TO or FROM will get their connections closed. Moreover, remote servers that try to send stanzas from a not validated domain will also get their connections closed.

Server-to-server communication requires two TCP connections between the servers where one is used for sending packets whilst the other connection is used for receiving packets. The connection used for receiving packets will use a ServerStanzaHandler since the other connection will not receive packets.

Author:
Gaston Dombiak, Alex Gidman, Matthew Vivian
  • Field Details

    • SKIP_JID_VALIDATION

      public static final SystemProperty<Boolean> SKIP_JID_VALIDATION
      Controls if JIDs that are in the addresses of stanzas supplied by remote domains are validated.
    • VALIDATE_HOST

      public static final SystemProperty<Boolean> VALIDATE_HOST
      Controls if the 'to' attribute of stream headers sent by remote servers is validated. When enabled, a stream that names a domain that is not serviced by the local XMPP service (the service that this Openfire instance provides, alone or together with the other nodes of its cluster) is refused with a host-unknown stream error.
      See Also:
  • Constructor Details

    • ServerStanzaHandler

      public ServerStanzaHandler(PacketRouter router, Connection connection, boolean directTLS)
  • Method Details

    • isLocallyServiced

      public static boolean isLocallyServiced(@Nonnull String domain)
      Checks if a domain that a remote server addresses is serviced by the local XMPP service. That is the case for the XMPP domain of the service, for subdomains of it that have a component route, and for domains for which trunking is enabled.
      Parameters:
      domain - the domain to check.
      Returns:
      true if the domain is serviced by the local XMPP service, otherwise false (including when the value is not a valid domain name).
    • isHostUnknown

      protected boolean isHostUnknown(String host)
      Overrides:
      isHostUnknown in class StanzaHandler
    • createSession

      protected void createSession(org.xmlpull.v1.XmlPullParser xpp) throws org.xmlpull.v1.XmlPullParserException, IOException
      Description copied from class: StanzaHandler
      Uses the XPP to grab the opening stream tag and create an active session object. The session to create will depend on the sent namespace. In all cases, the method obtains the opening stream tag, checks for errors, and either creates a session or returns an error and kills the connection. If the connection remains open, the XPP will be set to be ready for the first packet. A call to next() should result in an START_TAG state with the first packet in the stream.
      Overrides:
      createSession in class StanzaHandler
      Parameters:
      xpp - the pull parser
      Throws:
      org.xmlpull.v1.XmlPullParserException - if an exception occurs reading from the pull parser
      IOException - if an IO exception occurs reading from the pull parser
    • getStreamHeader

      protected org.dom4j.Document getStreamHeader()
      Overrides:
      getStreamHeader in class StanzaHandler
    • tlsNegotiated

      protected void tlsNegotiated(org.xmlpull.v1.XmlPullParser xpp) throws org.xmlpull.v1.XmlPullParserException, IOException
      Description copied from class: StanzaHandler
      TLS negotiation was successful so open a new stream and offer the new stream features. The new stream features will include available SASL mechanisms and specific features depending on the session type such as auth for Non-SASL authentication and register for in-band registration.
      Overrides:
      tlsNegotiated in class StanzaHandler
      Throws:
      org.xmlpull.v1.XmlPullParserException
      IOException
    • processIQ

      protected void processIQ(org.xmpp.packet.IQ packet) throws UnauthorizedException
      Description copied from class: StanzaHandler
      Process the received IQ packet. Registered PacketInterceptor will be invoked before and after the packet was routed.

      Subclasses may redefine this method for different reasons such as modifying the sender of the packet to avoid spoofing, rejecting the packet or even process the packet in another thread.

      Overrides:
      processIQ in class StanzaHandler
      Parameters:
      packet - the received packet.
      Throws:
      UnauthorizedException - if service is not available to sender.
    • processPresence

      protected void processPresence(org.xmpp.packet.Presence packet) throws UnauthorizedException
      Description copied from class: StanzaHandler
      Process the received Presence packet. Registered PacketInterceptor will be invoked before and after the packet was routed.

      Subclasses may redefine this method for different reasons such as modifying the sender of the packet to avoid spoofing, rejecting the packet or even process the packet in another thread.

      Overrides:
      processPresence in class StanzaHandler
      Parameters:
      packet - the received packet.
      Throws:
      UnauthorizedException - if service is not available to sender.
    • processMessage

      protected void processMessage(org.xmpp.packet.Message packet) throws UnauthorizedException
      Description copied from class: StanzaHandler
      Process the received Message packet. Registered PacketInterceptor will be invoked before and after the packet was routed.

      Subclasses may redefine this method for different reasons such as modifying the sender of the packet to avoid spoofing, rejecting the packet or even process the packet in another thread.

      Overrides:
      processMessage in class StanzaHandler
      Parameters:
      packet - the received packet.
      Throws:
      UnauthorizedException - if service is not available to sender.