Openfire 3.5.0 Javadoc

org.jivesoftware.openfire.session
Class LocalIncomingServerSession

java.lang.Object
  extended by org.jivesoftware.openfire.session.LocalSession
      extended by org.jivesoftware.openfire.session.LocalIncomingServerSession
All Implemented Interfaces:
ChannelHandler, RoutableChannelHandler, IncomingServerSession, Session

public class LocalIncomingServerSession
extends LocalSession
implements IncomingServerSession

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 IncomingServerSession represents the connection to a remote server that will only be used for receiving packets.

Currently only the Server Dialback method is being used for authenticating the remote server. Once the remote server has been authenticated incoming packets will be processed by this server. It is also possible for remote servers to authenticate more domains once the session has been established. For optimization reasons the existing connection is used between the servers. Therefore, the incoming server session holds the list of authenticated domains which are allowed to send packets to this server.

Using the Server Dialback method it is possible that this server may also act as the Authoritative Server. This implies that an incoming connection will be established with this server for authenticating a domain. This incoming connection will only last for a brief moment and after the domain has been authenticated the connection will be closed and no session will exist.

Author:
Gaston Dombiak

Field Summary
 
Fields inherited from class org.jivesoftware.openfire.session.LocalSession
CHARSET, conn, sessionManager, status
 
Fields inherited from interface org.jivesoftware.openfire.session.Session
MAJOR_VERSION, MINOR_VERSION, STATUS_AUTHENTICATED, STATUS_CLOSED, STATUS_CONNECTED
 
Constructor Summary
LocalIncomingServerSession(String serverName, Connection connection, StreamID streamID)
           
 
Method Summary
 void addValidatedDomain(String domain)
          Adds a new validated domain, subdomain or virtual host to the list of validated domains for the remote server.
static LocalIncomingServerSession createSession(String serverName, org.dom4j.io.XMPPPacketReader reader, SocketConnection connection)
          Creates a new session that will receive packets.
 String getAvailableStreamFeatures()
          Returns a text with the available stream features.
 String getLocalDomain()
          Returns the domain or subdomain of the local server used by the remote server when validating the session.
 Collection<String> getValidatedDomains()
          Returns a collection with all the domains, subdomains and virtual hosts that where validated.
 boolean isValidDomain(String domain)
          Returns true if the specified domain has been validated for this session.
 void removeValidatedDomain(String domain)
          Removes the previously validated domain from the list of validated domains.
 void setLocalDomain(String domain)
          Sets the domain or subdomain of the local server used by the remote server when asking to validate the session.
 boolean validateSubsequentDomain(org.dom4j.Element dbResult)
          Returns true if the request of a new domain was valid.
 void verifyReceivedKey(org.dom4j.Element doc)
          Verifies the received key sent by the remote server.
 
Methods inherited from class org.jivesoftware.openfire.session.LocalSession
close, decodeVersion, deliverRawText, getAddress, getConnection, getCreationDate, getHostAddress, getHostName, getLastActiveDate, getNumClientPackets, getNumServerPackets, getServerName, getSessionData, getStatus, getStreamID, incrementClientPacketCount, incrementServerPacketCount, isClosed, isSecure, process, removeSessionData, setAddress, setSessionData, setStatus, toString, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jivesoftware.openfire.session.Session
close, deliverRawText, getAddress, getCreationDate, getHostAddress, getHostName, getLastActiveDate, getNumClientPackets, getNumServerPackets, getServerName, getStatus, getStreamID, isClosed, isSecure, process, validate
 

Constructor Detail

LocalIncomingServerSession

public LocalIncomingServerSession(String serverName,
                                  Connection connection,
                                  StreamID streamID)
Method Detail

createSession

public static LocalIncomingServerSession createSession(String serverName,
                                                       org.dom4j.io.XMPPPacketReader reader,
                                                       SocketConnection connection)
                                                throws org.xmlpull.v1.XmlPullParserException,
                                                       IOException
Creates a new session that will receive packets. The new session will be authenticated before being returned. If the authentication process fails then the answer will be null.

Currently the Server Dialback method is the only way to authenticate a remote server. Since Server Dialback requires an Authoritative Server, it is possible for this server to receive an incoming connection that will only exist until the requested domain has been validated. In this case, this method will return null since the connection is closed after the domain was validated. See ServerDialback.createIncomingSession(org.dom4j.io.XMPPPacketReader) for more information.

Parameters:
serverName - hostname of this server.
reader - reader on the new established connection with the remote server.
connection - the new established connection with the remote server.
Returns:
a new session that will receive packets or null if a problem occured while authenticating the remote server or when acting as the Authoritative Server during a Server Dialback authentication process.
Throws:
org.xmlpull.v1.XmlPullParserException - if an error occurs while parsing the XML.
IOException - if an input/output error occurs while using the connection.

validateSubsequentDomain

public boolean validateSubsequentDomain(org.dom4j.Element dbResult)
Returns true if the request of a new domain was valid. Sessions may receive subsequent domain validation request. If the validation of the new domain fails then the session and the underlying TCP connection will be closed.

For optimization reasons, the same session may be servicing several domains of a remote server.

Parameters:
dbResult - the DOM stanza requesting the domain validation.
Returns:
true if the requested domain was valid.

isValidDomain

public boolean isValidDomain(String domain)
Returns true if the specified domain has been validated for this session. The remote server should send a "db:result" packet for registering new subdomains or even virtual hosts.

In the spirit of being flexible we allow remote servers to not register subdomains and even so consider subdomains that include the server domain in their domain part as valid domains.

Parameters:
domain - the domain to validate.
Returns:
true if the specified domain has been validated for this session.

getValidatedDomains

public Collection<String> getValidatedDomains()
Returns a collection with all the domains, subdomains and virtual hosts that where validated. The remote server is allowed to send packets from any of these domains, subdomains and virtual hosts.

Specified by:
getValidatedDomains in interface IncomingServerSession
Returns:
domains, subdomains and virtual hosts that where validated.

addValidatedDomain

public void addValidatedDomain(String domain)
Adds a new validated domain, subdomain or virtual host to the list of validated domains for the remote server.

Parameters:
domain - the new validated domain, subdomain or virtual host to add.

removeValidatedDomain

public void removeValidatedDomain(String domain)
Removes the previously validated domain from the list of validated domains. The remote server will no longer be able to send packets from the removed domain, subdomain or virtual host.

Parameters:
domain - the domain, subdomain or virtual host to remove from the list of validated domains.

getLocalDomain

public String getLocalDomain()
Returns the domain or subdomain of the local server used by the remote server when validating the session. This information is only used to prevent many connections from the same remote server to the same domain or subdomain of the local server.

Specified by:
getLocalDomain in interface IncomingServerSession
Returns:
the domain or subdomain of the local server used by the remote server when validating the session.

setLocalDomain

public void setLocalDomain(String domain)
Sets the domain or subdomain of the local server used by the remote server when asking to validate the session. This information is only used to prevent many connections from the same remote server to the same domain or subdomain of the local server.

Parameters:
domain - the domain or subdomain of the local server used when validating the session.

verifyReceivedKey

public void verifyReceivedKey(org.dom4j.Element doc)
Verifies the received key sent by the remote server. This server is trying to generate an outgoing connection to the remote server and the remote server is reusing an incoming connection for validating the key.

Parameters:
doc - the received Element that contains the key to verify.

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.

Specified by:
getAvailableStreamFeatures in class LocalSession
Returns:
a text with the available stream features or null to add nothing.

Openfire 3.5.0 Javadoc

Copyright © 2003-2007 Jive Software.