Commit 75494821 authored by Guus der Kinderen's avatar Guus der Kinderen

Compression policies should be defined in Connection Configuration.

parent 690d43e1
......@@ -132,13 +132,6 @@ public final class HttpBindManager {
private static HttpBindManager instance = new HttpBindManager();
// Compression "optional" by default; use "disabled" to disable compression (restart required)
// When enabled, http response will be compressed if the http request includes an
// "Accept" header with a value of "gzip" and/or "deflate"
private static boolean isCompressionEnabled = !(JiveGlobals.getProperty(
ConnectionSettings.Client.COMPRESSION_SETTINGS, Connection.CompressionPolicy.optional.toString())
.equalsIgnoreCase(Connection.CompressionPolicy.disabled.toString()));
private Server httpBindServer;
private int bindPort;
......@@ -573,7 +566,9 @@ public final class HttpBindManager {
// NOTE: enabled by default
private boolean isHttpCompressionEnabled() {
return isCompressionEnabled;
final ConnectionManagerImpl connectionManager = ((ConnectionManagerImpl) XMPPServer.getInstance().getConnectionManager());
final ConnectionConfiguration configuration = connectionManager.getListener( ConnectionType.BOSH_C2S, true ).generateConnectionConfiguration();
return configuration.getCompressionPolicy() == null || configuration.getCompressionPolicy().equals( Connection.CompressionPolicy.optional );
}
private void createCrossDomainHandler(ContextHandlerCollection contexts, String crossPath)
......
......@@ -83,5 +83,6 @@ public final class ConnectionSettings {
public static final String MAX_THREADS_SSL = "xmpp.component.ssl.processing.threads";
public static final String AUTH_PER_CLIENTCERT_POLICY = "xmpp.component.cert.policy";
public static final String TLS_POLICY = "xmpp.component.tls.policy";
public static final String COMPRESSION_SETTINGS = "xmpp.component.compression.policy";
}
}
......@@ -38,6 +38,7 @@ import org.jivesoftware.openfire.net.SASLAuthentication;
import org.jivesoftware.openfire.net.SocketConnection;
import org.jivesoftware.openfire.privacy.PrivacyList;
import org.jivesoftware.openfire.privacy.PrivacyListManager;
import org.jivesoftware.openfire.spi.ConnectionConfiguration;
import org.jivesoftware.openfire.streammanagement.StreamManager;
import org.jivesoftware.openfire.user.PresenceEventDispatcher;
import org.jivesoftware.openfire.user.UserNotFoundException;
......@@ -250,16 +251,18 @@ public class LocalClientSession extends LocalSession implements ClientSession {
connection.setLanaguage(language);
connection.setXMPPVersion(majorVersion, minorVersion);
final ConnectionConfiguration connectionConfiguration = connection.getConfiguration();
// Indicate the TLS policy to use for this connection
if (!connection.isSecure()) {
boolean hasCertificates = false;
try {
hasCertificates = connection.getConfiguration().getIdentityStore().getAllCertificates().size() > 0;
hasCertificates = connectionConfiguration.getIdentityStore().getAllCertificates().size() > 0;
}
catch (Exception e) {
Log.error(e.getMessage(), e);
}
Connection.TLSPolicy tlsPolicy = connection.getConfiguration().getTlsPolicy();
Connection.TLSPolicy tlsPolicy = connectionConfiguration.getTlsPolicy();
if (Connection.TLSPolicy.required == tlsPolicy && !hasCertificates) {
Log.error("Client session rejected. TLS is required but no certificates " +
"were created.");
......@@ -273,7 +276,7 @@ public class LocalClientSession extends LocalSession implements ClientSession {
}
// Indicate the compression policy to use for this connection
connection.setCompressionPolicy(getCompressionPolicy());
connection.setCompressionPolicy( connectionConfiguration.getCompressionPolicy() );
// Create a ClientSession for this user.
LocalClientSession session = SessionManager.getInstance().createClientSession(connection);
......@@ -410,27 +413,6 @@ public class LocalClientSession extends LocalSession implements ClientSession {
}
}
/**
* Returns whether compression is optional or is disabled for clients.
*
* @return whether compression is optional or is disabled.
*/
// TODO Move this to ConnectionConfiguration.
public static SocketConnection.CompressionPolicy getCompressionPolicy() {
// Set the Compression policy stored as a system property
String policyName = JiveGlobals
.getProperty(ConnectionSettings.Client.COMPRESSION_SETTINGS, Connection.CompressionPolicy.optional.toString());
SocketConnection.CompressionPolicy compressionPolicy;
try {
compressionPolicy = Connection.CompressionPolicy.valueOf(policyName);
} catch (IllegalArgumentException e) {
Log.error("Error parsing xmpp.client.compression.policy: " + policyName, e);
compressionPolicy = Connection.CompressionPolicy.optional;
}
return compressionPolicy;
}
/**
* Sets whether compression is optional or is disabled for clients.
*
......
......@@ -62,21 +62,6 @@ public class LocalConnectionMultiplexerSession extends LocalSession implements C
private static final Logger Log = LoggerFactory.getLogger(LocalConnectionMultiplexerSession.class);
private static Connection.TLSPolicy tlsPolicy;
private static Connection.CompressionPolicy compressionPolicy;
static {
// Set the TLS policy stored as a system property
String policyName = JiveGlobals.getProperty(ConnectionSettings.Multiplex.TLS_POLICY,
Connection.TLSPolicy.disabled.toString());
tlsPolicy = Connection.TLSPolicy.valueOf(policyName);
// Set the Compression policy stored as a system property
policyName = JiveGlobals.getProperty(ConnectionSettings.Multiplex.COMPRESSION_SETTINGS,
Connection.CompressionPolicy.disabled.toString());
compressionPolicy = Connection.CompressionPolicy.valueOf(policyName);
}
public static LocalConnectionMultiplexerSession createSession(String serverName, XmlPullParser xpp, Connection connection)
throws XmlPullParserException {
String domain = xpp.getAttributeValue("", "to");
......@@ -134,10 +119,10 @@ public class LocalConnectionMultiplexerSession extends LocalSession implements C
}
// Indicate the TLS policy to use for this connection
connection.setTlsPolicy(tlsPolicy);
connection.setTlsPolicy( connection.getConfiguration().getTlsPolicy() );
// Indicate the compression policy to use for this connection
connection.setCompressionPolicy(compressionPolicy);
connection.setCompressionPolicy( connection.getConfiguration().getCompressionPolicy() );
// Set the connection manager domain to use delivering a packet fails
((MultiplexerPacketDeliverer) connection.getPacketDeliverer())
......@@ -173,9 +158,9 @@ public class LocalConnectionMultiplexerSession extends LocalSession implements C
sb = new StringBuilder(490);
sb.append("<stream:features>");
if (tlsPolicy != Connection.TLSPolicy.disabled) {
if (connection.getTlsPolicy() != Connection.TLSPolicy.disabled) {
sb.append("<starttls xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\">");
if (tlsPolicy == Connection.TLSPolicy.required) {
if (connection.getTlsPolicy() == Connection.TLSPolicy.required) {
sb.append("<required/>");
}
sb.append("</starttls>");
......@@ -288,7 +273,7 @@ public class LocalConnectionMultiplexerSession extends LocalSession implements C
}
}
// Add info about Stream Compression
if (LocalClientSession.getCompressionPolicy() == Connection.CompressionPolicy.optional) {
if (configuration.getCompressionPolicy() == Connection.CompressionPolicy.optional) {
Element comp = child.addElement("compression", "http://jabber.org/features/compress");
comp.addElement("method").setText("zlib");
}
......@@ -313,51 +298,4 @@ public class LocalConnectionMultiplexerSession extends LocalSession implements C
conn.deliver(packet);
}
}
/**
* Returns whether TLS is mandatory, optional or is disabled for clients. When TLS is
* mandatory clients are required to secure their connections or otherwise their connections
* will be closed. On the other hand, when TLS is disabled clients are not allowed to secure
* their connections using TLS. Their connections will be closed if they try to secure the
* connection. in this last case.
*
* @return whether TLS is mandatory, optional or is disabled.
*/
public static SocketConnection.TLSPolicy getTLSPolicy() {
return tlsPolicy;
}
/**
* Sets whether TLS is mandatory, optional or is disabled for clients. When TLS is
* mandatory clients are required to secure their connections or otherwise their connections
* will be closed. On the other hand, when TLS is disabled clients are not allowed to secure
* their connections using TLS. Their connections will be closed if they try to secure the
* connection. in this last case.
*
* @param policy whether TLS is mandatory, optional or is disabled.
*/
public static void setTLSPolicy(SocketConnection.TLSPolicy policy) {
tlsPolicy = policy;
JiveGlobals.setProperty(ConnectionSettings.Multiplex.TLS_POLICY, tlsPolicy.toString());
}
/**
* Returns whether compression is optional or is disabled for clients.
*
* @return whether compression is optional or is disabled.
*/
public static SocketConnection.CompressionPolicy getCompressionPolicy() {
return compressionPolicy;
}
/**
* Sets whether compression is optional or is disabled for clients.
*
* @param policy whether compression is optional or is disabled.
*/
public static void setCompressionPolicy(SocketConnection.CompressionPolicy policy) {
compressionPolicy = policy;
JiveGlobals.setProperty(ConnectionSettings.Multiplex.COMPRESSION_SETTINGS, compressionPolicy.toString());
}
}
......@@ -168,11 +168,7 @@ public class LocalIncomingServerSession extends LocalServerSession implements In
}
// Indicate the compression policy to use for this connection
String policyName = JiveGlobals.getProperty(ConnectionSettings.Server.COMPRESSION_SETTINGS,
Connection.CompressionPolicy.disabled.toString());
Connection.CompressionPolicy compressionPolicy =
Connection.CompressionPolicy.valueOf(policyName);
connection.setCompressionPolicy(compressionPolicy);
connection.setCompressionPolicy( connection.getConfiguration().getCompressionPolicy() );
StringBuilder sb = new StringBuilder();
......
......@@ -413,8 +413,7 @@ public class LocalOutgoingServerSession extends LocalServerSession implements Ou
features = reader.parseDocument().getRootElement();
if (features != null) {
// Check if we can use stream compression
String policyName = JiveGlobals.getProperty(ConnectionSettings.Server.COMPRESSION_SETTINGS, Connection.CompressionPolicy.disabled.toString());
Connection.CompressionPolicy compressionPolicy = Connection.CompressionPolicy.valueOf(policyName);
final Connection.CompressionPolicy compressionPolicy = connection.getConfiguration().getCompressionPolicy();
if (Connection.CompressionPolicy.optional == compressionPolicy) {
// Verify if the remote server supports stream compression
Element compression = features.element("compression");
......
......@@ -38,6 +38,7 @@ public class ConnectionConfiguration
private final Set<String> encryptionProtocolsDisabled;
private final Set<String> cipherSuitesEnabled;
private final Set<String> cipherSuitesDisabled;
private final Connection.CompressionPolicy compressionPolicy;
// derived
private final IdentityStore identityStore;
......@@ -54,7 +55,7 @@ public class ConnectionConfiguration
* @param tlsPolicy The TLS policy that is applied to connections (cannot be null).
*/
// TODO input validation
public ConnectionConfiguration( ConnectionType type, boolean enabled, int maxThreadPoolSize, int maxBufferSize, Connection.ClientAuth clientAuth, InetAddress bindAddress, int port, Connection.TLSPolicy tlsPolicy, CertificateStoreConfiguration identityStoreConfiguration, CertificateStoreConfiguration trustStoreConfiguration, boolean acceptSelfSignedCertificates, boolean verifyCertificateValidity, Set<String> encryptionProtocolsEnabled, Set<String> encryptionProtocolsDisabled, Set<String> cipherSuitesEnabled, Set<String> cipherSuitesDisabled )
public ConnectionConfiguration( ConnectionType type, boolean enabled, int maxThreadPoolSize, int maxBufferSize, Connection.ClientAuth clientAuth, InetAddress bindAddress, int port, Connection.TLSPolicy tlsPolicy, CertificateStoreConfiguration identityStoreConfiguration, CertificateStoreConfiguration trustStoreConfiguration, boolean acceptSelfSignedCertificates, boolean verifyCertificateValidity, Set<String> encryptionProtocolsEnabled, Set<String> encryptionProtocolsDisabled, Set<String> cipherSuitesEnabled, Set<String> cipherSuitesDisabled, Connection.CompressionPolicy compressionPolicy )
{
if ( maxThreadPoolSize <= 0 ) {
throw new IllegalArgumentException( "Argument 'maxThreadPoolSize' must be equal to or greater than one." );
......@@ -90,6 +91,8 @@ public class ConnectionConfiguration
this.cipherSuitesEnabled = Collections.unmodifiableSet( suitesEnabled );
this.cipherSuitesDisabled = Collections.unmodifiableSet( cipherSuitesDisabled );
this.compressionPolicy = compressionPolicy;
final CertificateStoreManager certificateStoreManager = XMPPServer.getInstance().getCertificateStoreManager();
this.identityStore = certificateStoreManager.getIdentityStore( type );
this.trustStore = certificateStoreManager.getTrustStore( type );
......@@ -100,6 +103,11 @@ public class ConnectionConfiguration
return tlsPolicy;
}
public Connection.CompressionPolicy getCompressionPolicy()
{
return compressionPolicy;
}
public ConnectionType getType()
{
return type;
......
......@@ -64,6 +64,12 @@ public class ConnectionListener
*/
private final String tlsPolicyPropertyName;
/**
* Name of property that configures the policy regarding compression (eg: ZLIB) that's applicable to this listener.
* 'null' causes an implementation default to be used.
*/
private final String compressionPolicyPropertyName;
/**
* Name of property that configures the policy regarding mutual authentication that's applicable to this listener.
* 'null' indicates that this policy cannot be configured and 'disabled' should be used as a default.
......@@ -88,7 +94,7 @@ public class ConnectionListener
* @param tlsPolicyPropertyName Property name (of a string) that defines the applicable TLS Policy. Or, the value {@link org.jivesoftware.openfire.Connection.TLSPolicy} to indicate unconfigurable TLS Policy. Cannot be null.
* @param clientAuthPolicyPropertyName Property name (of an string) that defines maximum IO processing threads. Null causes a unconfigurabel value of 'wanted' to be used.
*/
public ConnectionListener( ConnectionType type, String tcpPortPropertyName, int defaultPort, String isEnabledPropertyName, String maxPoolSizePropertyName, String maxReadBufferPropertyName, String tlsPolicyPropertyName, String clientAuthPolicyPropertyName, InetAddress bindAddress, CertificateStoreConfiguration identityStoreConfiguration, CertificateStoreConfiguration trustStoreConfiguration )
public ConnectionListener( ConnectionType type, String tcpPortPropertyName, int defaultPort, String isEnabledPropertyName, String maxPoolSizePropertyName, String maxReadBufferPropertyName, String tlsPolicyPropertyName, String clientAuthPolicyPropertyName, InetAddress bindAddress, CertificateStoreConfiguration identityStoreConfiguration, CertificateStoreConfiguration trustStoreConfiguration, String compressionPolicyPropertyName )
{
this.type = type;
this.tcpPortPropertyName = tcpPortPropertyName;
......@@ -101,6 +107,7 @@ public class ConnectionListener
this.bindAddress = bindAddress;
this.identityStoreConfiguration = identityStoreConfiguration;
this.trustStoreConfiguration = trustStoreConfiguration;
this.compressionPolicyPropertyName = compressionPolicyPropertyName;
// A listener cannot be changed into or from legacy mode. That fact is safe to use in the name of the logger..
final String name = getType().toString().toLowerCase() + ( getTLSPolicy().equals( Connection.TLSPolicy.legacyMode ) ? "-legacyMode" : "" );
......@@ -248,7 +255,8 @@ public class ConnectionListener
getEncryptionProtocolsEnabled(),
getEncryptionProtocolsDisabled(),
getCipherSuitesEnabled(),
getCipherSuitesDisabled()
getCipherSuitesDisabled(),
getCompressionPolicy()
);
}
......@@ -522,6 +530,76 @@ public class ConnectionListener
restart();
}
/**
* Returns whether compression is optional or disabled for new connections.
*
* @return A compression policy (never null)
*/
public Connection.CompressionPolicy getCompressionPolicy()
{
// Depending on the connection type, define a good default value.
final Connection.CompressionPolicy defaultPolicy;
switch ( getType() )
{
// More likely to have good bandwidth. Compression on high-volume data gobbles CPU.
case COMPONENT:
case CONNECTION_MANAGER:
case SOCKET_S2S:
defaultPolicy = Connection.CompressionPolicy.disabled;
break;
// At least *offer* compression functionality.
case SOCKET_C2S:
case BOSH_C2S:
case WEBADMIN:
default:
defaultPolicy = Connection.CompressionPolicy.optional;
break;
}
if ( compressionPolicyPropertyName == null )
{
return defaultPolicy;
}
else
{
final String policyName = JiveGlobals.getProperty( compressionPolicyPropertyName, defaultPolicy.toString() );
try
{
return Connection.CompressionPolicy.valueOf( policyName );
}
catch ( IllegalArgumentException e )
{
Log.error( "Error parsing property value of '{}' into a valid Compression Policy. Offending value: '{}'.", tlsPolicyPropertyName, policyName, e );
return defaultPolicy;
}
}
}
/**
* Sets whether compression is optional or disabled for new connections. This configuration change is persisted.
*
* If the listener is currently enabled, this configuration change will be applied immediately (which will cause a
* restart of the underlying connection acceptor).
*
* An invocation of this method has no effect if the new policy value is equal to the existing value.
*
* @param policy a compression policy (not null).
*/
public void setCompressionPolicy( Connection.CompressionPolicy policy )
{
final Connection.CompressionPolicy oldPolicy = getCompressionPolicy();
if ( oldPolicy.equals( policy ) )
{
Log.debug( "Ignoring Compression Policy change request (to '{}'): listener already in this state.", policy );
return;
}
Log.debug( "Changing Compression Policy from '{}' to '{}'.", oldPolicy, policy );
JiveGlobals.setProperty( compressionPolicyPropertyName, policy.toString() );
restart();
}
/**
* Returns the configuration for the identity store that identifies this instance of Openfire to the peer
* on connections created by this listener.
......
......@@ -99,7 +99,8 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
ConnectionSettings.Client.AUTH_PER_CLIENTCERT_POLICY,
bindAddress,
certificateStoreManager.getIdentityStoreConfiguration( ConnectionType.SOCKET_C2S ),
certificateStoreManager.getTrustStoreConfiguration( ConnectionType.SOCKET_C2S )
certificateStoreManager.getTrustStoreConfiguration( ConnectionType.SOCKET_C2S ),
ConnectionSettings.Client.COMPRESSION_SETTINGS
);
clientSslListener = new ConnectionListener(
ConnectionType.SOCKET_C2S,
......@@ -112,7 +113,8 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
ConnectionSettings.Client.AUTH_PER_CLIENTCERT_POLICY,
bindAddress,
certificateStoreManager.getIdentityStoreConfiguration( ConnectionType.SOCKET_C2S ),
certificateStoreManager.getTrustStoreConfiguration( ConnectionType.SOCKET_C2S )
certificateStoreManager.getTrustStoreConfiguration( ConnectionType.SOCKET_C2S ),
ConnectionSettings.Client.COMPRESSION_SETTINGS
);
// BOSH / HTTP-bind
boshListener = new ConnectionListener(
......@@ -126,7 +128,8 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
HttpBindManager.HTTP_BIND_AUTH_PER_CLIENTCERT_POLICY,
bindAddress,
certificateStoreManager.getIdentityStoreConfiguration( ConnectionType.BOSH_C2S ),
certificateStoreManager.getTrustStoreConfiguration( ConnectionType.BOSH_C2S )
certificateStoreManager.getTrustStoreConfiguration( ConnectionType.BOSH_C2S ),
ConnectionSettings.Client.COMPRESSION_SETTINGS // Existing code re-used the generic client compression property. Should we have a BOSH-specific one?
);
boshSslListener = new ConnectionListener(
ConnectionType.BOSH_C2S,
......@@ -139,7 +142,8 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
HttpBindManager.HTTP_BIND_AUTH_PER_CLIENTCERT_POLICY,
bindAddress,
certificateStoreManager.getIdentityStoreConfiguration( ConnectionType.BOSH_C2S ),
certificateStoreManager.getTrustStoreConfiguration( ConnectionType.BOSH_C2S )
certificateStoreManager.getTrustStoreConfiguration( ConnectionType.BOSH_C2S ),
ConnectionSettings.Client.COMPRESSION_SETTINGS // Existing code re-used the generic client compression property. Should we have a BOSH-specific one?
);
// server-to-server (federation)
serverListener = new ConnectionListener(
......@@ -153,7 +157,8 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
ConnectionSettings.Server.AUTH_PER_CLIENTCERT_POLICY,
bindAddress,
certificateStoreManager.getIdentityStoreConfiguration( ConnectionType.SOCKET_S2S ),
certificateStoreManager.getTrustStoreConfiguration( ConnectionType.SOCKET_S2S )
certificateStoreManager.getTrustStoreConfiguration( ConnectionType.SOCKET_S2S ),
ConnectionSettings.Server.COMPRESSION_SETTINGS
);
// external components (XEP 0114)
componentListener = new ConnectionListener(
......@@ -167,7 +172,8 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
ConnectionSettings.Component.AUTH_PER_CLIENTCERT_POLICY,
bindAddress,
certificateStoreManager.getIdentityStoreConfiguration( ConnectionType.COMPONENT ),
certificateStoreManager.getTrustStoreConfiguration( ConnectionType.COMPONENT )
certificateStoreManager.getTrustStoreConfiguration( ConnectionType.COMPONENT ),
ConnectionSettings.Component.COMPRESSION_SETTINGS
);
componentSslListener = new ConnectionListener(
ConnectionType.COMPONENT,
......@@ -180,7 +186,8 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
ConnectionSettings.Component.AUTH_PER_CLIENTCERT_POLICY,
bindAddress,
certificateStoreManager.getIdentityStoreConfiguration( ConnectionType.COMPONENT ),
certificateStoreManager.getTrustStoreConfiguration( ConnectionType.COMPONENT )
certificateStoreManager.getTrustStoreConfiguration( ConnectionType.COMPONENT ),
ConnectionSettings.Component.COMPRESSION_SETTINGS
);
// Multiplexers (our propertietary connection manager implementation)
......@@ -195,7 +202,8 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
ConnectionSettings.Multiplex.AUTH_PER_CLIENTCERT_POLICY,
bindAddress,
certificateStoreManager.getIdentityStoreConfiguration( ConnectionType.CONNECTION_MANAGER ),
certificateStoreManager.getTrustStoreConfiguration( ConnectionType.CONNECTION_MANAGER )
certificateStoreManager.getTrustStoreConfiguration( ConnectionType.CONNECTION_MANAGER ),
ConnectionSettings.Multiplex.COMPRESSION_SETTINGS
);
connectionManagerSslListener = new ConnectionListener(
ConnectionType.CONNECTION_MANAGER,
......@@ -208,7 +216,8 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
ConnectionSettings.Multiplex.AUTH_PER_CLIENTCERT_POLICY,
bindAddress,
certificateStoreManager.getIdentityStoreConfiguration( ConnectionType.CONNECTION_MANAGER ),
certificateStoreManager.getTrustStoreConfiguration( ConnectionType.CONNECTION_MANAGER )
certificateStoreManager.getTrustStoreConfiguration( ConnectionType.CONNECTION_MANAGER ),
ConnectionSettings.Multiplex.COMPRESSION_SETTINGS
);
// Admin console (the Openfire web-admin) // TODO these use the XML properties instead of normal properties!
......@@ -223,7 +232,8 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
null,
bindAddress,
certificateStoreManager.getIdentityStoreConfiguration( ConnectionType.WEBADMIN ),
certificateStoreManager.getTrustStoreConfiguration( ConnectionType.WEBADMIN )
certificateStoreManager.getTrustStoreConfiguration( ConnectionType.WEBADMIN ),
null // Should we have compression on the admin console?
);
webAdminSslListener = new ConnectionListener(
......@@ -237,7 +247,8 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
null,
bindAddress,
certificateStoreManager.getIdentityStoreConfiguration( ConnectionType.WEBADMIN ),
certificateStoreManager.getTrustStoreConfiguration( ConnectionType.WEBADMIN )
certificateStoreManager.getTrustStoreConfiguration( ConnectionType.WEBADMIN ),
null // Should we have compression on the admin console?
);
}
......
......@@ -18,11 +18,11 @@
- limitations under the License.
--%>
<%@ page import="org.jivesoftware.openfire.Connection,
org.jivesoftware.openfire.session.LocalClientSession,
org.jivesoftware.util.JiveGlobals"
errorPage="error.jsp"
%>
<%@ page errorPage="error.jsp" %>
<%@ page import="org.jivesoftware.openfire.Connection" %>
<%@ page import="org.jivesoftware.openfire.spi.ConnectionManagerImpl" %>
<%@ page import="org.jivesoftware.openfire.XMPPServer" %>
<%@ page import="org.jivesoftware.openfire.spi.ConnectionType" %>
<%@ page import="org.jivesoftware.util.ParamUtils" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
......@@ -42,13 +42,21 @@
boolean clientEnabled = ParamUtils.getBooleanParameter(request, "clientEnabled");
boolean serverEnabled = ParamUtils.getBooleanParameter(request, "serverEnabled");
final ConnectionManagerImpl connectionManager = (ConnectionManagerImpl) XMPPServer.getInstance().getConnectionManager();
if (update) {
// Update c2s compression policy
LocalClientSession.setCompressionPolicy(
clientEnabled ? Connection.CompressionPolicy.optional : Connection.CompressionPolicy.disabled);
final Connection.CompressionPolicy newClientPolicy = clientEnabled ? Connection.CompressionPolicy.optional : Connection.CompressionPolicy.disabled;
connectionManager.getListener( ConnectionType.SOCKET_C2S, false ).setCompressionPolicy( newClientPolicy );
connectionManager.getListener( ConnectionType.SOCKET_C2S, true ).setCompressionPolicy( newClientPolicy );
connectionManager.getListener( ConnectionType.BOSH_C2S, false ).setCompressionPolicy( newClientPolicy );
connectionManager.getListener( ConnectionType.BOSH_C2S, true ).setCompressionPolicy( newClientPolicy );
// Update s2s compression policy
JiveGlobals.setProperty("xmpp.server.compression.policy", serverEnabled ?
Connection.CompressionPolicy.optional.toString() : Connection.CompressionPolicy.disabled.toString());
final Connection.CompressionPolicy newServerPolicy = serverEnabled ? Connection.CompressionPolicy.optional : Connection.CompressionPolicy.disabled;
connectionManager.getListener( ConnectionType.SOCKET_S2S, false ).setCompressionPolicy( newServerPolicy );
// TODO Add components, connection managers
// Log the event
webManager.logEvent("set compression policy", "c2s compression = "+clientEnabled+"\ns2s compression = "+serverEnabled);
%>
......@@ -67,8 +75,8 @@
}
// Set page vars
clientEnabled = Connection.CompressionPolicy.optional == LocalClientSession.getCompressionPolicy();
serverEnabled = Connection.CompressionPolicy.optional.toString().equals(JiveGlobals.getProperty("xmpp.server.compression.policy", Connection.CompressionPolicy.disabled.toString()));
clientEnabled = Connection.CompressionPolicy.optional.equals( connectionManager.getListener( ConnectionType.SOCKET_C2S, false ).getCompressionPolicy() );
serverEnabled = Connection.CompressionPolicy.optional.equals( connectionManager.getListener( ConnectionType.SOCKET_S2S, false ).getCompressionPolicy() );
%>
<p>
......
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