Commit 1dbe2e49 authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

[JM-1217] Couple more improvements to multiple connection support.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@9777 b35dd754-fafc-0310-a699-88a17e54d16e
parent 8cb0cdad
......@@ -1150,8 +1150,12 @@ public class SessionManager extends BasicModule implements ClusterEventListener
finally {
// Remove the session
localSessionManager.getComponentsSessions().remove(session);
// Remove track of the cluster node hosting the external component
componentSessionsCache.remove(session.getAddress().toString());
// if no more components are handling it.
if (!InternalComponentManager.getInstance().hasComponent(session.getAddress())) {
componentSessionsCache.remove(session.getAddress().toString());
}
}
}
}
......
......@@ -111,11 +111,11 @@ public class ComponentSocketReader extends SocketReader {
return false;
}
boolean createSession(String namespace, Boolean allowMultiple) throws UnauthorizedException, XmlPullParserException,
boolean createSession(String namespace) throws UnauthorizedException, XmlPullParserException,
IOException {
if ("jabber:component:accept".equals(namespace)) {
// The connected client is a component so create a ComponentSession
session = LocalComponentSession.createSession(serverName, reader, connection, allowMultiple);
session = LocalComponentSession.createSession(serverName, reader, connection);
return true;
}
return false;
......
......@@ -204,9 +204,8 @@ public class ServerSocketReader extends SocketReader {
threadPool.shutdown();
}
boolean createSession(String namespace, Boolean allowMultiple) throws UnauthorizedException, XmlPullParserException,
boolean createSession(String namespace) throws UnauthorizedException, XmlPullParserException,
IOException {
// TODO: Should we ever consider allowing multiple of this?
if ("jabber:server".equals(namespace)) {
// The connected client is a server so create an IncomingServerSession
session = LocalIncomingServerSession.createSession(serverName, reader, connection);
......
......@@ -231,6 +231,7 @@ public abstract class SocketReader implements Runnable {
* another thread.
*
* @param packet the received packet.
* @throws UnauthorizedException if the connection required security but was not secured.
*/
protected void processIQ(IQ packet) throws UnauthorizedException {
// Ensure that connection was secured if TLS was required
......@@ -253,6 +254,7 @@ public abstract class SocketReader implements Runnable {
* another thread.
*
* @param packet the received packet.
* @throws UnauthorizedException if the connection required security but was not secured.
*/
protected void processPresence(Presence packet) throws UnauthorizedException {
// Ensure that connection was secured if TLS was required
......@@ -275,6 +277,7 @@ public abstract class SocketReader implements Runnable {
* another thread.
*
* @param packet the received packet.
* @throws UnauthorizedException if the connection required security but was not secured.
*/
protected void processMessage(Message packet) throws UnauthorizedException {
// Ensure that connection was secured if TLS was required
......@@ -348,6 +351,10 @@ public abstract class SocketReader implements Runnable {
* 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.
*
* @throws UnauthorizedException if the connection required security but was not secured.
* @throws XmlPullParserException if there was an XML error while creating the session.
* @throws IOException if an IO error occured while creating the session.
*/
protected void createSession()
throws UnauthorizedException, XmlPullParserException, IOException {
......@@ -360,7 +367,6 @@ public abstract class SocketReader implements Runnable {
// subdomain. If the value of the 'to' attribute is not valid then return a host-unknown
// error and close the underlying connection.
String host = reader.getXPPParser().getAttributeValue("", "to");
String allowMultiple = reader.getXPPParser().getAttributeValue("", "allowMultiple");
if (validateHost() && isHostUnknown(host)) {
StringBuilder sb = new StringBuilder(250);
sb.append("<?xml version='1.0' encoding='");
......@@ -388,7 +394,7 @@ public abstract class SocketReader implements Runnable {
// Create the correct session based on the sent namespace. At this point the server
// may offer the client to secure the connection. If the client decides to secure
// the connection then a <starttls> stanza should be received
else if (!createSession(xpp.getNamespace(null), allowMultiple != null)) {
else if (!createSession(xpp.getNamespace(null))) {
// No session was created because of an invalid namespace prefix so answer a stream
// error and close the underlying connection
StringBuilder sb = new StringBuilder(250);
......@@ -457,12 +463,11 @@ public abstract class SocketReader implements Runnable {
* Creates the appropriate {@link org.jivesoftware.openfire.session.Session} subclass based on the specified namespace.
*
* @param namespace the namespace sent in the stream element. eg. jabber:client.
* @param allowMultiple Allow multiple bindings to the specified domain.
* @return the created session or null.
* @throws UnauthorizedException
* @throws XmlPullParserException
* @throws IOException
* @throws UnauthorizedException if the connection required security but was not secured.
* @throws XmlPullParserException if there was an XML error while creating the session.
* @throws IOException if an IO error occured while creating the session.
*/
abstract boolean createSession(String namespace, Boolean allowMultiple) throws UnauthorizedException,
abstract boolean createSession(String namespace) throws UnauthorizedException,
XmlPullParserException, IOException;
}
......@@ -55,15 +55,18 @@ public class LocalComponentSession extends LocalSession implements ComponentSess
* @param serverName the name of the server where the session is connecting to.
* @param reader the reader that is reading the provided XML through the connection.
* @param connection the connection with the component.
* @param allowMultiple the specified domain is allowed to be connected to multiple times.
* @return a newly created session between the server and a component.
* @throws UnauthorizedException if the connection required security but was not secured.
* @throws XmlPullParserException if there was an XML error while creating the session.
* @throws IOException if an IO error occured while creating the session.
*/
public static LocalComponentSession createSession(String serverName, XMPPPacketReader reader,
SocketConnection connection, Boolean allowMultiple) throws UnauthorizedException, IOException,
SocketConnection connection) throws UnauthorizedException, IOException,
XmlPullParserException
{
XmlPullParser xpp = reader.getXPPParser();
String domain = xpp.getAttributeValue("", "to");
Boolean allowMultiple = reader.getXPPParser().getAttributeValue("", "allowMultiple") != null;
Log.debug("LocalComponentSession: [ExComp] Starting registration of new external component for domain: " + domain);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment