Commit bb9d52c0 authored by Dele Olajide's avatar Dele Olajide Committed by Guus der Kinderen

websocket plugin has been broken since Openfire 4.1.4. This PR implements the...

websocket plugin has been broken since Openfire 4.1.4. This PR implements the missing code and fixes the issue

    @Override
   public ConnectionConfiguration getConfiguration()
   {
       // TODO Here we run into an issue with the ConnectionConfiguration introduced in Openfire 4:
       //      it is not extensible in the sense that unforeseen connection types can be added.
       //      For now, null is returned, as this object is likely to be unused (its lifecycle is
       //      not managed by a ConnectionListener instance).
       return null;
   }
parent 4f5179c7
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
<name>Openfire WebSocket</name> <name>Openfire WebSocket</name>
<description>Provides WebSocket support for Openfire.</description> <description>Provides WebSocket support for Openfire.</description>
<author>Tom Evans</author> <author>Tom Evans</author>
<version>1.2.0</version> <version>1.2.1</version>
<date>05/08/2017</date> <date>06/30/2017</date>
<url>https://tools.ietf.org/html/rfc7395</url> <url>https://tools.ietf.org/html/rfc7395</url>
<minServerVersion>4.2.0 Alpha</minServerVersion> <minServerVersion>4.1.5</minServerVersion>
</plugin> </plugin>
\ No newline at end of file
...@@ -18,11 +18,14 @@ package org.jivesoftware.openfire.websocket; ...@@ -18,11 +18,14 @@ package org.jivesoftware.openfire.websocket;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import org.dom4j.Namespace; import org.dom4j.Namespace;
import org.jivesoftware.openfire.*;
import org.jivesoftware.openfire.PacketDeliverer; import org.jivesoftware.openfire.PacketDeliverer;
import org.jivesoftware.openfire.auth.UnauthorizedException; import org.jivesoftware.openfire.auth.UnauthorizedException;
import org.jivesoftware.openfire.net.VirtualConnection; import org.jivesoftware.openfire.net.VirtualConnection;
import org.jivesoftware.openfire.nio.OfflinePacketDeliverer; import org.jivesoftware.openfire.nio.OfflinePacketDeliverer;
import org.jivesoftware.openfire.spi.ConnectionConfiguration; import org.jivesoftware.openfire.spi.ConnectionConfiguration;
import org.jivesoftware.openfire.spi.ConnectionManagerImpl;
import org.jivesoftware.openfire.spi.ConnectionType;
import org.xmpp.packet.Packet; import org.xmpp.packet.Packet;
import org.xmpp.packet.StreamError; import org.xmpp.packet.StreamError;
...@@ -35,10 +38,13 @@ public class WebSocketConnection extends VirtualConnection ...@@ -35,10 +38,13 @@ public class WebSocketConnection extends VirtualConnection
private InetSocketAddress remotePeer; private InetSocketAddress remotePeer;
private XmppWebSocket socket; private XmppWebSocket socket;
private PacketDeliverer backupDeliverer; private PacketDeliverer backupDeliverer;
private ConnectionConfiguration configuration;
private ConnectionType connectionType;
public WebSocketConnection(XmppWebSocket socket, InetSocketAddress remotePeer) { public WebSocketConnection(XmppWebSocket socket, InetSocketAddress remotePeer) {
this.socket = socket; this.socket = socket;
this.remotePeer = remotePeer; this.remotePeer = remotePeer;
this.connectionType = ConnectionType.SOCKET_C2S;
} }
@Override @Override
...@@ -67,7 +73,7 @@ public class WebSocketConnection extends VirtualConnection ...@@ -67,7 +73,7 @@ public class WebSocketConnection extends VirtualConnection
deliverRawText(new StreamError(StreamError.Condition.system_shutdown).toXML()); deliverRawText(new StreamError(StreamError.Condition.system_shutdown).toXML());
close(); close();
} }
@Override @Override
public void deliver(Packet packet) throws UnauthorizedException public void deliver(Packet packet) throws UnauthorizedException
{ {
...@@ -112,15 +118,14 @@ public class WebSocketConnection extends VirtualConnection ...@@ -112,15 +118,14 @@ public class WebSocketConnection extends VirtualConnection
return backupDeliverer; return backupDeliverer;
} }
@Override @Override
public ConnectionConfiguration getConfiguration() public ConnectionConfiguration getConfiguration() {
{ if (configuration == null) {
// TODO Here we run into an issue with the ConnectionConfiguration introduced in Openfire 4: final ConnectionManagerImpl connectionManager = ((ConnectionManagerImpl) XMPPServer.getInstance().getConnectionManager());
// it is not extensible in the sense that unforeseen connection types can be added. configuration = connectionManager.getListener( connectionType, true ).generateConnectionConfiguration();
// For now, null is returned, as this object is likely to be unused (its lifecycle is }
// not managed by a ConnectionListener instance). return configuration;
return null; }
}
@Override @Override
public boolean isCompressed() { public boolean isCompressed() {
......
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