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