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(String, String) 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
    • Method Detail

      • authenticateDomain

        public static boolean authenticateDomain​(String localDomain,
                                                 String remoteDomain)
        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:
        localDomain - the local domain to authenticate with the remote server.
        remoteDomain - the remote server, to which the local domain intends to send data.
        Returns:
        True if the domain was authenticated by the remote server.
      • authenticateSubdomain

        public boolean authenticateSubdomain​(String localDomain,
                                             String remoteDomain)
        Description copied from interface: OutgoingServerSession
        Authenticates a subdomain of this server with the specified remote server over an exsiting 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:
        localDomain - the locally domain to authenticate with the remote server.
        remoteDomain - the domain of the remote server.
        Returns:
        True if the domain was authenticated by the remote server.
      • getAvailableStreamFeatures

        public String 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.
        Overrides:
        getAvailableStreamFeatures in class LocalServerSession
        Returns:
        a text with the available stream features or null to add nothing.
      • checkOutgoingDomainPair

        public boolean checkOutgoingDomainPair​(String localDomain,
                                               String remoteDomain)
        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:
        localDomain - the local domain (previously: authenticated domain)
        remoteDomain - the remote domain (previous: hostname)
        Returns:
        True if the pair of domains has been authenticated.