Class LocalIncomingServerSession
- java.lang.Object
-
- org.jivesoftware.openfire.session.LocalSession
-
- org.jivesoftware.openfire.session.LocalServerSession
-
- org.jivesoftware.openfire.session.LocalIncomingServerSession
-
- All Implemented Interfaces:
ChannelHandler<org.xmpp.packet.Packet>
,RoutableChannelHandler
,IncomingServerSession
,ServerSession
,Session
public class LocalIncomingServerSession extends LocalServerSession 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. TheIncomingServerSession
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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jivesoftware.openfire.session.ServerSession
ServerSession.AuthenticationMethod
-
Nested classes/interfaces inherited from interface org.jivesoftware.openfire.session.Session
Session.Status
-
-
Field Summary
-
Fields inherited from class org.jivesoftware.openfire.session.LocalServerSession
authenticationMethod
-
Fields inherited from class org.jivesoftware.openfire.session.LocalSession
address, conn, serverName, sessionManager, startDate, status, streamID, streamManager
-
Fields inherited from interface org.jivesoftware.openfire.session.Session
MAJOR_VERSION, MINOR_VERSION
-
-
Constructor Summary
Constructors Constructor Description LocalIncomingServerSession(String serverName, Connection connection, StreamID streamID, String fromDomain)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.xmlpull.v1.XmlPullParser xpp, Connection connection, boolean directTLS, boolean doNotSendXMPPStream)
Creates a new session that will receive packets.List<org.dom4j.Element>
getAvailableStreamFeatures()
Returns a text with the available stream features.String
getDefaultIdentity()
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.String
toString()
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.LocalServerSession
getAuthenticationMethod, getConnection, reattach, setAuthenticationMethod, setDetached, setStatus
-
Methods inherited from class org.jivesoftware.openfire.session.LocalSession
close, deliverRawText, getAddress, getCipherSuiteName, getCreationDate, getHostAddress, getHostName, getLanguage, getLastActiveDate, getNumClientPackets, getNumServerPackets, getPeerCertificates, getServerName, getSessionData, getSoftwareVersion, getStatus, getStreamID, getStreamManager, getTLSProtocolName, incrementClientPacketCount, incrementServerPacketCount, isClosed, isDetached, isEncrypted, isUsingSelfSignedCertificate, process, removeSessionData, setAddress, setSessionData, setSoftwareVersionData, 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.ServerSession
getAuthenticationMethod, isUsingSaslExternal, isUsingServerDialback
-
Methods inherited from interface org.jivesoftware.openfire.session.Session
close, deliverRawText, getAddress, getCipherSuiteName, getCreationDate, getHostAddress, getHostName, getLanguage, getLastActiveDate, getNumClientPackets, getNumServerPackets, getPeerCertificates, getServerName, getSoftwareVersion, getStatus, getStreamID, getTLSProtocolName, isAuthenticated, isClosed, isEncrypted, process, validate
-
-
-
-
Constructor Detail
-
LocalIncomingServerSession
public LocalIncomingServerSession(String serverName, Connection connection, StreamID streamID, String fromDomain)
-
-
Method Detail
-
createSession
public static LocalIncomingServerSession createSession(String serverName, org.xmlpull.v1.XmlPullParser xpp, Connection connection, boolean directTLS, boolean doNotSendXMPPStream) 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 benull
.- Parameters:
serverName
- hostname of this server.xpp
- XML parse that is providing data from the new established connection with the remote server.connection
- the new established connection with the remote server.directTLS
- true of connections are immediately encrypted (as opposed to plain text / startls).- 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.
-
getDefaultIdentity
public String getDefaultIdentity()
-
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 interfaceIncomingServerSession
- 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 interfaceIncomingServerSession
- 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 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 classLocalSession
- Returns:
- a text with the available stream features or
null
to add nothing.
-
toString
public String toString()
- Overrides:
toString
in classLocalServerSession
-
-