Commit 9ee2a4b9 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Added support for s2s communication. JM-6


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1378 b35dd754-fafc-0310-a699-88a17e54d16e
parent a40b4613
......@@ -24,20 +24,24 @@ import java.util.ArrayList;
public class ServerPort {
private int port;
private String interfaceName;
private ArrayList names;
private String address;
private boolean secure;
private String algorithm;
private Type type;
public ServerPort(int port, String name, String address, boolean isSecure,
String algorithm)
public ServerPort(int port, String interfaceName, String name, String address,
boolean isSecure, String algorithm, Type type)
{
this.port = port;
this.interfaceName = interfaceName;
this.names = new ArrayList(1);
this.names.add(name);
this.address = address;
this.secure = isSecure;
this.algorithm = algorithm;
this.type = type;
}
/**
......@@ -49,6 +53,10 @@ public class ServerPort {
return port;
}
public String getInterfaceName() {
return interfaceName;
}
/**
* Returns the logical domains for this server port. As multiple
* domains may point to the same server, this helps to define what
......@@ -87,4 +95,39 @@ public class ServerPort {
public String getSecurityType() {
return algorithm;
}
/**
* Returns true if other servers can connect to this port for s2s communication.
*
* @return true if other servers can connect to this port for s2s communication.
*/
public boolean isServerPort() {
return type == Type.server;
}
/**
* Returns true if clients can connect to this port.
*
* @return true if clients can connect to this port.
*/
public boolean isClientPort() {
return type == Type.client;
}
/**
* Returns true if external components can connect to this port.
*
* @return true if external components can connect to this port.
*/
public boolean isComponentPort() {
return type == Type.component;
}
public static enum Type {
client,
server,
component;
}
}
......@@ -11,16 +11,17 @@
package org.jivesoftware.messenger.net;
import org.jivesoftware.messenger.ConnectionManager;
import org.jivesoftware.messenger.ServerPort;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.messenger.ConnectionManager;
import org.jivesoftware.util.JiveGlobals;
import javax.net.ssl.SSLException;
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.UnknownHostException;
import javax.net.ssl.SSLException;
/**
* Implements a network front end with a dedicated thread reading
......@@ -38,6 +39,11 @@ public class SSLSocketAcceptThread extends Thread {
*/
private InetAddress bindInterface;
/**
* Holds information about the port on which the server will listen for connections.
*/
private ServerPort serverPort;
/**
* True while this thread should continue running.
*/
......@@ -66,12 +72,13 @@ public class SSLSocketAcceptThread extends Thread {
* generated by this thread
* @throws IOException if there was trouble initializing the SSL configuration.
*/
public SSLSocketAcceptThread(ConnectionManager connManager) throws IOException {
public SSLSocketAcceptThread(ConnectionManager connManager, ServerPort serverPort)
throws IOException {
super("Secure Socket Listener");
this.connManager = connManager;
int port = JiveGlobals.getIntProperty("xmpp.socket.ssl.port", DEFAULT_PORT);
String interfaceName = JiveGlobals.getProperty("xmpp.socket.ssl.interface");
this.serverPort = serverPort;
int port = serverPort.getPort();
String interfaceName = serverPort.getInterfaceName();
bindInterface = null;
if (interfaceName != null) {
try {
......@@ -126,7 +133,7 @@ public class SSLSocketAcceptThread extends Thread {
try {
Socket sock = serverSocket.accept();
Log.debug("SSL Connect " + sock.toString());
connManager.addSocket(sock, true);
connManager.addSocket(sock, true, serverPort);
}
catch (SSLException se) {
long exceptionTime = System.currentTimeMillis();
......
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