Commit e4fe9424 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

HTTPS binding is back again working. JM-1496

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@10909 b35dd754-fafc-0310-a699-88a17e54d16e
parent bbad2da4
...@@ -23,7 +23,6 @@ import org.jivesoftware.openfire.IQResultListener; ...@@ -23,7 +23,6 @@ import org.jivesoftware.openfire.IQResultListener;
import org.jivesoftware.openfire.IQRouter; import org.jivesoftware.openfire.IQRouter;
import org.jivesoftware.openfire.XMPPServer; import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.XMPPServerInfo; import org.jivesoftware.openfire.XMPPServerInfo;
import org.jivesoftware.openfire.http.HttpBindManager;
import org.jivesoftware.openfire.auth.AuthFactory; import org.jivesoftware.openfire.auth.AuthFactory;
import org.jivesoftware.openfire.auth.UnauthorizedException; import org.jivesoftware.openfire.auth.UnauthorizedException;
import static org.jivesoftware.openfire.clearspace.ClearspaceManager.HttpType.GET; import static org.jivesoftware.openfire.clearspace.ClearspaceManager.HttpType.GET;
...@@ -31,9 +30,9 @@ import static org.jivesoftware.openfire.clearspace.ClearspaceManager.HttpType.PO ...@@ -31,9 +30,9 @@ import static org.jivesoftware.openfire.clearspace.ClearspaceManager.HttpType.PO
import org.jivesoftware.openfire.component.*; import org.jivesoftware.openfire.component.*;
import org.jivesoftware.openfire.container.BasicModule; import org.jivesoftware.openfire.container.BasicModule;
import org.jivesoftware.openfire.group.GroupNotFoundException; import org.jivesoftware.openfire.group.GroupNotFoundException;
import org.jivesoftware.openfire.http.HttpBindManager;
import org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl; import org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl;
import org.jivesoftware.openfire.net.MXParser; import org.jivesoftware.openfire.net.MXParser;
import org.jivesoftware.openfire.net.SSLConfig;
import org.jivesoftware.openfire.session.ComponentSession; import org.jivesoftware.openfire.session.ComponentSession;
import org.jivesoftware.openfire.session.LocalClientSession; import org.jivesoftware.openfire.session.LocalClientSession;
import org.jivesoftware.openfire.user.UserNotFoundException; import org.jivesoftware.openfire.user.UserNotFoundException;
...@@ -49,11 +48,11 @@ import org.xmpp.packet.JID; ...@@ -49,11 +48,11 @@ import org.xmpp.packet.JID;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.net.*; import java.net.*;
import java.security.KeyStore;
import java.security.cert.X509Certificate;
import java.util.*; import java.util.*;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.security.KeyStore;
import java.security.cert.X509Certificate;
/** /**
...@@ -714,7 +713,7 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM ...@@ -714,7 +713,7 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM
int boshSslPort = HttpBindManager.getInstance().getHttpBindSecurePort(); int boshSslPort = HttpBindManager.getInstance().getHttpBindSecurePort();
int boshPort = HttpBindManager.getInstance().getHttpBindUnsecurePort(); int boshPort = HttpBindManager.getInstance().getHttpBindUnsecurePort();
try { try {
if (CertificateManager.isRSACertificate(SSLConfig.getKeyStore(), XMPPServer.getInstance().getServerInfo().getXMPPDomain()) && LocalClientSession.getTLSPolicy() != org.jivesoftware.openfire.Connection.TLSPolicy.disabled && boshSslPort > 0) { if (HttpBindManager.getInstance().isHttpsBindActive() && LocalClientSession.getTLSPolicy() != org.jivesoftware.openfire.Connection.TLSPolicy.disabled) {
xmppBoshSslPort = String.valueOf(boshSslPort); xmppBoshSslPort = String.valueOf(boshSslPort);
} }
} }
...@@ -722,7 +721,7 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM ...@@ -722,7 +721,7 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM
// Exception while working with certificate // Exception while working with certificate
Log.debug("Error while checking SSL certificate. Instructing Clearspace not to use SSL port."); Log.debug("Error while checking SSL certificate. Instructing Clearspace not to use SSL port.");
} }
if (boshPort > 0) { if (HttpBindManager.getInstance().isHttpBindActive() && boshPort > 0) {
xmppBoshPort = String.valueOf(boshPort); xmppBoshPort = String.valueOf(boshPort);
} }
} }
......
...@@ -78,8 +78,8 @@ public class FlashCrossDomainServlet extends HttpServlet { ...@@ -78,8 +78,8 @@ public class FlashCrossDomainServlet extends HttpServlet {
builder.append(HttpBindManager.getInstance().getHttpBindUnsecurePort()); builder.append(HttpBindManager.getInstance().getHttpBindUnsecurePort());
multiple = true; multiple = true;
} }
if(HttpBindManager.getInstance().getHttpBindSecurePort() > 0) { if (HttpBindManager.getInstance().isHttpsBindActive()) {
if(multiple) { if (multiple) {
builder.append(","); builder.append(",");
} }
builder.append(HttpBindManager.getInstance().getHttpBindSecurePort()); builder.append(HttpBindManager.getInstance().getHttpBindSecurePort());
......
...@@ -58,7 +58,8 @@ public final class HttpBindManager { ...@@ -58,7 +58,8 @@ public final class HttpBindManager {
private int bindSecurePort; private int bindSecurePort;
private boolean sslEnabled = false; private Connector httpConnector;
private Connector httpsConnector;
private CertificateListener certificateListener; private CertificateListener certificateListener;
...@@ -121,18 +122,19 @@ public final class HttpBindManager { ...@@ -121,18 +122,19 @@ public final class HttpBindManager {
return JiveGlobals.getBooleanProperty(HTTP_BIND_ENABLED, HTTP_BIND_ENABLED_DEFAULT); return JiveGlobals.getBooleanProperty(HTTP_BIND_ENABLED, HTTP_BIND_ENABLED_DEFAULT);
} }
private Connector createConnector(int port) { private void createConnector(int port) {
httpConnector = null;
if (port > 0) { if (port > 0) {
SelectChannelConnector connector = new SelectChannelConnector(); SelectChannelConnector connector = new SelectChannelConnector();
// Listen on a specific network interface if it has been set. // Listen on a specific network interface if it has been set.
connector.setHost(getBindInterface()); connector.setHost(getBindInterface());
connector.setPort(port); connector.setPort(port);
return connector; httpConnector = connector;
} }
return null;
} }
private Connector createSSLConnector(int securePort) { private void createSSLConnector(int securePort) {
httpsConnector = null;
try { try {
if (securePort > 0 && CertificateManager.isRSACertificate(SSLConfig.getKeyStore(), "*")) { if (securePort > 0 && CertificateManager.isRSACertificate(SSLConfig.getKeyStore(), "*")) {
if (!CertificateManager.isRSACertificate(SSLConfig.getKeyStore(), if (!CertificateManager.isRSACertificate(SSLConfig.getKeyStore(),
...@@ -165,13 +167,12 @@ public final class HttpBindManager { ...@@ -165,13 +167,12 @@ public final class HttpBindManager {
sslConnector.setKeyPassword(SSLConfig.getKeyPassword()); sslConnector.setKeyPassword(SSLConfig.getKeyPassword());
sslConnector.setKeystoreType(SSLConfig.getStoreType()); sslConnector.setKeystoreType(SSLConfig.getStoreType());
sslConnector.setKeystore(SSLConfig.getKeystoreLocation()); sslConnector.setKeystore(SSLConfig.getKeystoreLocation());
return sslConnector; httpsConnector = sslConnector;
} }
} }
catch (Exception e) { catch (Exception e) {
Log.error("Error creating SSL connector for Http bind", e); Log.error("Error creating SSL connector for Http bind", e);
} }
return null;
} }
private String getBindInterface() { private String getBindInterface() {
...@@ -194,6 +195,24 @@ public final class HttpBindManager { ...@@ -194,6 +195,24 @@ public final class HttpBindManager {
return httpBindServer != null && httpBindServer.isRunning(); return httpBindServer != null && httpBindServer.isRunning();
} }
/**
* Returns true if a listener on the HTTP binding port is running.
*
* @return true if a listener on the HTTP binding port is running.
*/
public boolean isHttpBindActive() {
return httpConnector != null && httpConnector.isRunning();
}
/**
* Returns true if a listener on the HTTPS binding port is running.
*
* @return true if a listener on the HTTPS binding port is running.
*/
public boolean isHttpsBindActive() {
return httpsConnector != null && httpsConnector.isRunning();
}
public String getHttpBindUnsecureAddress() { public String getHttpBindUnsecureAddress() {
return "http://" + XMPPServer.getInstance().getServerInfo().getXMPPDomain() + ":" + return "http://" + XMPPServer.getInstance().getServerInfo().getXMPPDomain() + ":" +
bindPort + "/http-bind/"; bindPort + "/http-bind/";
...@@ -268,8 +287,8 @@ public final class HttpBindManager { ...@@ -268,8 +287,8 @@ public final class HttpBindManager {
*/ */
private synchronized void configureHttpBindServer(int port, int securePort) { private synchronized void configureHttpBindServer(int port, int securePort) {
httpBindServer = new Server(); httpBindServer = new Server();
Connector httpConnector = createConnector(port); createConnector(port);
Connector httpsConnector = createSSLConnector(securePort); createSSLConnector(securePort);
if (httpConnector == null && httpsConnector == null) { if (httpConnector == null && httpsConnector == null) {
httpBindServer = null; httpBindServer = null;
return; return;
...@@ -278,12 +297,8 @@ public final class HttpBindManager { ...@@ -278,12 +297,8 @@ public final class HttpBindManager {
httpBindServer.addConnector(httpConnector); httpBindServer.addConnector(httpConnector);
} }
if (httpsConnector != null) { if (httpsConnector != null) {
sslEnabled = true;
httpBindServer.addConnector(httpsConnector); httpBindServer.addConnector(httpsConnector);
} }
else {
sslEnabled = false;
}
createBoshHandler(contexts, "/http-bind"); createBoshHandler(contexts, "/http-bind");
createCrossDomainHandler(contexts, "/"); createCrossDomainHandler(contexts, "/");
...@@ -363,9 +378,6 @@ public final class HttpBindManager { ...@@ -363,9 +378,6 @@ public final class HttpBindManager {
* @return the HTTP binding port which uses SSL. * @return the HTTP binding port which uses SSL.
*/ */
public int getHttpBindSecurePort() { public int getHttpBindSecurePort() {
if (!sslEnabled) {
return 0;
}
return JiveGlobals.getIntProperty(HTTP_BIND_SECURE_PORT, HTTP_BIND_SECURE_PORT_DEFAULT); return JiveGlobals.getIntProperty(HTTP_BIND_SECURE_PORT, HTTP_BIND_SECURE_PORT_DEFAULT);
} }
......
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