Class WebSocketClientStanzaHandler
- java.lang.Object
-
- org.jivesoftware.openfire.net.StanzaHandler
-
- org.jivesoftware.openfire.net.ClientStanzaHandler
-
- org.jivesoftware.openfire.websocket.WebSocketClientStanzaHandler
-
public class WebSocketClientStanzaHandler extends ClientStanzaHandler
AStanzaHandler
that is able to process the specific framing that is used by clients connecting via websockets.- Author:
- Guus der Kinderen, guus@goodbytes.nl
- See Also:
- RFC 7395: An Extensible Messaging and Presence Protocol (XMPP) Subprotocol for WebSocket
-
-
Field Summary
Fields Modifier and Type Field Description static String
FRAMING_NAMESPACE
static String
STREAM_FOOTER
static String
STREAM_HEADER
-
Fields inherited from class org.jivesoftware.openfire.net.StanzaHandler
connection, PROPERTY_OVERWRITE_EMPTY_TO, router, saslStatus, session, sessionCreated, startedSASL, startedTLS, waitingCompressionACK
-
-
Constructor Summary
Constructors Constructor Description WebSocketClientStanzaHandler(PacketRouter router, WebSocketConnection connection)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
createSession(String serverName, org.xmlpull.v1.XmlPullParser xpp, Connection connection)
protected void
createSession(org.xmlpull.v1.XmlPullParser xpp)
Uses the XPP to grab the opening stream tag and create an active session object.protected org.dom4j.Document
getStreamHeader()
protected void
initiateSession(String stanza, XMPPPacketReader reader)
protected boolean
isEndOfStream(String xml)
Checks if the provided XML data represents the end / closing of an XMPP stream.protected boolean
isStartOfStream(String xml)
Checks if the provided XML data represents the beginning of a new XMPP stream.protected void
saslSuccessful()
After SASL authentication was successful we should open a new stream and offer new stream features such as resource binding and session establishment.static String
withoutDeclaration(org.dom4j.Document document)
-
Methods inherited from class org.jivesoftware.openfire.net.ClientStanzaHandler
getNamespace, processIQ, processMessage, processPresence, processUnknowPacket, startTLS, validateHost, validateJIDs
-
Methods inherited from class org.jivesoftware.openfire.net.StanzaHandler
closeNeverEncryptedConnection, closeNeverSecuredConnection, compressClient, compressionSuccessful, getAddress, isHostUnknown, isStreamManagementStanza, negotiateTLS, process, processStanza, setSession, tlsNegotiated
-
-
-
-
Field Detail
-
STREAM_HEADER
public static final String STREAM_HEADER
- See Also:
- Constant Field Values
-
STREAM_FOOTER
public static final String STREAM_FOOTER
- See Also:
- Constant Field Values
-
FRAMING_NAMESPACE
public static final String FRAMING_NAMESPACE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
WebSocketClientStanzaHandler
public WebSocketClientStanzaHandler(PacketRouter router, WebSocketConnection connection)
-
-
Method Detail
-
initiateSession
protected void initiateSession(String stanza, XMPPPacketReader reader) throws Exception
- Overrides:
initiateSession
in classStanzaHandler
- Throws:
Exception
-
createSession
protected void createSession(org.xmlpull.v1.XmlPullParser xpp) throws org.xmlpull.v1.XmlPullParserException, IOException
Description copied from class:StanzaHandler
Uses the XPP to grab the opening stream tag and create an active session object. The session to create will depend on the sent namespace. In all cases, the method obtains the opening stream tag, checks for errors, and either creates a session or returns an error and kills the connection. If the connection remains open, the XPP will be set to be ready for the first packet. A call to next() should result in an START_TAG state with the first packet in the stream.- Overrides:
createSession
in classStanzaHandler
- Parameters:
xpp
- the pull parser- Throws:
org.xmlpull.v1.XmlPullParserException
- if an exception occurs reading from the pull parserIOException
- if an IO exception occurs reading from the pull parser
-
createSession
protected void createSession(String serverName, org.xmlpull.v1.XmlPullParser xpp, Connection connection) throws org.xmlpull.v1.XmlPullParserException
- Overrides:
createSession
in classClientStanzaHandler
- Throws:
org.xmlpull.v1.XmlPullParserException
-
getStreamHeader
protected org.dom4j.Document getStreamHeader()
- Overrides:
getStreamHeader
in classStanzaHandler
-
saslSuccessful
protected void saslSuccessful()
After SASL authentication was successful we should open a new stream and offer new stream features such as resource binding and session establishment. Notice that resource binding and session establishment should only be offered to clients (i.e. not to servers or external components)- Overrides:
saslSuccessful
in classStanzaHandler
-
isStartOfStream
protected boolean isStartOfStream(String xml)
Description copied from class:StanzaHandler
Checks if the provided XML data represents the beginning of a new XMPP stream.- Overrides:
isStartOfStream
in classStanzaHandler
- Parameters:
xml
- The XML to verify- Returns:
- 'true' if the provided data represents the beginning of an XMPP stream.
-
isEndOfStream
protected boolean isEndOfStream(String xml)
Description copied from class:StanzaHandler
Checks if the provided XML data represents the end / closing of an XMPP stream.- Overrides:
isEndOfStream
in classStanzaHandler
- Parameters:
xml
- The XML to verify- Returns:
- 'true' if the provided data represents the end of an XMPP stream.
-
withoutDeclaration
public static String withoutDeclaration(org.dom4j.Document document)
-
-