Class LocalOutgoingServerSession

All Implemented Interfaces:
ChannelHandler<org.xmpp.packet.Packet>, RoutableChannelHandler, OutgoingServerSession, ServerSession, Session

public class LocalOutgoingServerSession extends LocalServerSession implements OutgoingServerSession
Server-to-server communication is done using two TCP connections between the servers. One connection is used for sending packets while the other connection is used for receiving packets. The OutgoingServerSession represents the connection to a remote server that will only be used for sending packets.

Currently only the Server Dialback method is being used for authenticating with the remote server. Use authenticateDomain(DomainPair) to create a new connection to a remote server that will be used for sending packets to the remote server from the specified domain. Only the authenticated domains with the remote server will be able to effectively send packets to the remote server. The remote server will reject and close the connection if a non-authenticated domain tries to send a packet through this connection.

Once the connection has been established with the remote server and at least a domain has been authenticated then a new route will be added to the routing table for this connection. For optimization reasons the same outgoing connection will be used even if the remote server has several hostnames. However, different routes will be created in the routing table for each hostname of the remote server.

Author:
Gaston Dombiak
  • Field Details

    • INITIALISE_TIMEOUT_SECONDS

      public static final SystemProperty<Duration> INITIALISE_TIMEOUT_SECONDS
      Controls the S2S outgoing session initialise timeout time in seconds
  • Constructor Details

  • Method Details

    • authenticateDomain

      public static boolean authenticateDomain(DomainPair domainPair)
      Authenticates the local domain to the remote domain. Once authenticated the remote domain can be expected to start accepting data from the local domain. This implementation will attempt to re-use an existing connection. An connection is deemed re-usable when it is either:
      • authenticated to the remote domain itself, or:
      • authenticated to a sub- or superdomain of the remote domain AND offers dialback.
      When no re-usable connection exists, a new connection will be created. DNS will be used to find hosts for the remote domain. When DNS records do not specify a port, port 5269 will be used unless this default is overridden by the xmpp.server.socket.remotePort property.
      Parameters:
      domainPair - the local and remote domain for which authentication is to be established.
      Returns:
      True if the domain was authenticated by the remote server.
    • authenticateSubdomain

      public boolean authenticateSubdomain(@Nonnull DomainPair domainPair)
      Description copied from interface: OutgoingServerSession
      Authenticates a subdomain of this server with the specified remote server over an existing outgoing connection. If the existing session was using server dialback then a new db:result is going to be sent to the remote server. But if the existing session was TLS+SASL based then just assume that the subdomain was authenticated by the remote server.
      Specified by:
      authenticateSubdomain in interface OutgoingServerSession
      Parameters:
      domainPair - the local (sub) and remote domain for which authentication is to be established.
      Returns:
      True if the domain was authenticated by the remote server.
    • getAvailableStreamFeatures

      public List<org.dom4j.Element> getAvailableStreamFeatures()
      Description copied from class: LocalSession
      Returns a text with the available stream features. Each subclass may return different values depending whether the session has been authenticated or not.
      Specified by:
      getAvailableStreamFeatures in class LocalSession
      Returns:
      a text with the available stream features or null to add nothing.
    • addOutgoingDomainPair

      public void addOutgoingDomainPair(@Nonnull DomainPair domainPair)
      Description copied from interface: OutgoingServerSession
      Marks a domain pair as being authenticated.
      Specified by:
      addOutgoingDomainPair in interface OutgoingServerSession
      Parameters:
      domainPair - the local and remote domain for which authentication has been established.
    • checkOutgoingDomainPair

      public boolean checkOutgoingDomainPair(@Nonnull DomainPair domainPair)
      Description copied from interface: OutgoingServerSession
      Checks to see if a pair of domains has previously been authenticated. Since domains are authenticated as pairs, authenticating A->B does not imply anything about A-->C or D->B.
      Specified by:
      checkOutgoingDomainPair in interface OutgoingServerSession
      Parameters:
      domainPair - the local and remote domain for which the check is executed.
      Returns:
      True if the pair of domains has been authenticated.
    • getOutgoingDomainPairs

      public Collection<DomainPair> getOutgoingDomainPairs()
      Description copied from interface: OutgoingServerSession
      Obtains all authenticated domain pairs. Most callers should avoid accessing this and use a simple check as above.
      Specified by:
      getOutgoingDomainPairs in interface OutgoingServerSession
      Returns:
      collection of authenticated DomainPairs
    • toString

      public String toString()
      Overrides:
      toString in class LocalServerSession