Search in sources :

Example 11 with ConnectionManagerImpl

use of org.jivesoftware.openfire.spi.ConnectionManagerImpl in project Openfire by igniterealtime.

the class LocalConnectionMultiplexerSession method sendClientOptions.

/**
 * Send to the Connection Manager the connection options available for clients. The info
 * to send includes:
 * <ul>
 *  <li>if TLS is available, optional or required
 *  <li>SASL mechanisms available before TLS is negotiated
 *  <li>if compression is available
 *  <li>if Non-SASL authentication is available
 *  <li>if In-Band Registration is available
 * </ul
 */
private void sendClientOptions() {
    final ConnectionManagerImpl connectionManager = ((ConnectionManagerImpl) XMPPServer.getInstance().getConnectionManager());
    final ConnectionConfiguration configuration = connectionManager.getListener(ConnectionType.SOCKET_C2S, false).generateConnectionConfiguration();
    IQ options = new IQ(IQ.Type.set);
    Element child = options.setChildElement("configuration", "http://jabber.org/protocol/connectionmanager");
    // Add info about TLS
    if (configuration.getTlsPolicy() != Connection.TLSPolicy.disabled) {
        Element tls = child.addElement("starttls", "urn:ietf:params:xml:ns:xmpp-tls");
        if (configuration.getTlsPolicy() == Connection.TLSPolicy.required) {
            tls.addElement("required");
        }
    }
    // Add info about SASL mechanisms
    Collection<String> mechanisms = SASLAuthentication.getSupportedMechanisms();
    if (!mechanisms.isEmpty()) {
        Element sasl = child.addElement("mechanisms", "urn:ietf:params:xml:ns:xmpp-sasl");
        for (String mechanism : mechanisms) {
            sasl.addElement("mechanism").setText(mechanism);
        }
    }
    // Add info about Stream Compression
    if (configuration.getCompressionPolicy() == Connection.CompressionPolicy.optional) {
        Element comp = child.addElement("compression", "http://jabber.org/features/compress");
        comp.addElement("method").setText("zlib");
    }
    // Add info about Non-SASL authentication
    if (XMPPServer.getInstance().getIQRouter().supports("jabber:iq:auth")) {
        child.addElement("auth", "http://jabber.org/features/iq-auth");
    }
    // Add info about In-Band Registration
    if (XMPPServer.getInstance().getIQRegisterHandler().isInbandRegEnabled()) {
        child.addElement("register", "http://jabber.org/features/iq-register");
    }
    // Send the options
    process(options);
}
Also used : ConnectionManagerImpl(org.jivesoftware.openfire.spi.ConnectionManagerImpl) ConnectionConfiguration(org.jivesoftware.openfire.spi.ConnectionConfiguration) Element(org.dom4j.Element) IQ(org.xmpp.packet.IQ)

Aggregations

ConnectionManagerImpl (org.jivesoftware.openfire.spi.ConnectionManagerImpl)11 ConnectionConfiguration (org.jivesoftware.openfire.spi.ConnectionConfiguration)4 Element (org.dom4j.Element)2 ContextHandlerCollection (org.eclipse.jetty.server.handler.ContextHandlerCollection)2 SslContextFactory (org.eclipse.jetty.util.ssl.SslContextFactory)2 IdentityStore (org.jivesoftware.openfire.keystore.IdentityStore)2 ConnectionListener (org.jivesoftware.openfire.spi.ConnectionListener)2 EncryptionArtifactFactory (org.jivesoftware.openfire.spi.EncryptionArtifactFactory)2 EmailScheduler (com.ifsoft.jmxweb.plugin.EmailScheduler)1 CoreThreadPool (com.javamonitor.openfire.mbeans.CoreThreadPool)1 DatabasePool (com.javamonitor.openfire.mbeans.DatabasePool)1 Openfire (com.javamonitor.openfire.mbeans.Openfire)1 PacketCounter (com.javamonitor.openfire.mbeans.PacketCounter)1 IOException (java.io.IOException)1 ServletException (javax.servlet.ServletException)1 JasperInitializer (org.apache.jasper.servlet.JasperInitializer)1 InstanceManager (org.apache.tomcat.InstanceManager)1 SimpleInstanceManager (org.apache.tomcat.SimpleInstanceManager)1 Document (org.dom4j.Document)1 DocumentException (org.dom4j.DocumentException)1