Package org.jivesoftware.openfire.net
Class StanzaHandler
- java.lang.Object
-
- org.jivesoftware.openfire.net.StanzaHandler
-
- Direct Known Subclasses:
ClientStanzaHandler
,ComponentStanzaHandler
,MultiplexerStanzaHandler
,ServerStanzaHandler
public abstract class StanzaHandler extends Object
A StanzaHandler is the main responsible for handling incoming stanzas. Some stanzas like startTLS are totally managed by this class. The rest of the stanzas are just forwarded to the router.- Author:
- Gaston Dombiak
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
CHARSET
The utf-8 charset for decoding and encoding Jabber packet streams.protected Connection
connection
static SystemProperty<Boolean>
PROPERTY_OVERWRITE_EMPTY_TO
protected LocalSession
session
Session associated with the socket reader.
-
Constructor Summary
Constructors Constructor Description StanzaHandler(PacketRouter router, String serverName, Connection connection)
Deprecated.StanzaHandler(PacketRouter router, Connection connection)
Creates a dedicated reader for a socket.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
createSession(org.xmlpull.v1.XmlPullParser xpp)
Uses the XPP to grab the opening stream tag and create an active session object.org.xmpp.packet.JID
getAddress()
Obtain the address of the XMPP entity for which this StanzaHandler handles stanzas.void
process(String stanza, XMPPPacketReader reader)
protected void
processIQ(org.xmpp.packet.IQ packet)
Process the received IQ packet.protected void
processMessage(org.xmpp.packet.Message packet)
Process the received Message packet.protected void
processPresence(org.xmpp.packet.Presence packet)
Process the received Presence packet.void
setSession(LocalSession session)
-
-
-
Field Detail
-
PROPERTY_OVERWRITE_EMPTY_TO
public static final SystemProperty<Boolean> PROPERTY_OVERWRITE_EMPTY_TO
-
CHARSET
protected static String CHARSET
The utf-8 charset for decoding and encoding Jabber packet streams.
-
connection
protected Connection connection
-
session
protected LocalSession session
Session associated with the socket reader.
-
-
Constructor Detail
-
StanzaHandler
public StanzaHandler(PacketRouter router, Connection connection)
Creates a dedicated reader for a socket.- Parameters:
router
- the router for sending packets that were read.connection
- the connection being read.
-
StanzaHandler
@Deprecated public StanzaHandler(PacketRouter router, String serverName, Connection connection)
Deprecated.
-
-
Method Detail
-
setSession
public void setSession(LocalSession session)
-
process
public void process(String stanza, XMPPPacketReader reader) throws Exception
- Throws:
Exception
-
processIQ
protected void processIQ(org.xmpp.packet.IQ packet) throws UnauthorizedException
Process the received IQ packet. RegisteredPacketInterceptor
will be invoked before and after the packet was routed.Subclasses may redefine this method for different reasons such as modifying the sender of the packet to avoid spoofing, rejecting the packet or even process the packet in another thread.
- Parameters:
packet
- the received packet.- Throws:
UnauthorizedException
- if service is not available to sender.
-
processPresence
protected void processPresence(org.xmpp.packet.Presence packet) throws UnauthorizedException
Process the received Presence packet. RegisteredPacketInterceptor
will be invoked before and after the packet was routed.Subclasses may redefine this method for different reasons such as modifying the sender of the packet to avoid spoofing, rejecting the packet or even process the packet in another thread.
- Parameters:
packet
- the received packet.- Throws:
UnauthorizedException
- if service is not available to sender.
-
processMessage
protected void processMessage(org.xmpp.packet.Message packet) throws UnauthorizedException
Process the received Message packet. RegisteredPacketInterceptor
will be invoked before and after the packet was routed.Subclasses may redefine this method for different reasons such as modifying the sender of the packet to avoid spoofing, rejecting the packet or even process the packet in another thread.
- Parameters:
packet
- the received packet.- Throws:
UnauthorizedException
- if service is not available to sender.
-
createSession
protected void createSession(org.xmlpull.v1.XmlPullParser xpp) throws org.xmlpull.v1.XmlPullParserException, IOException
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.- 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
-
getAddress
public org.xmpp.packet.JID getAddress()
Obtain the address of the XMPP entity for which this StanzaHandler handles stanzas. Note that the value that is returned for this method can change over time. For example, if no session has been established yet, this method will returnnull
, or, if resource binding occurs, the returned value might change. Values obtained from this method are therefore best not cached.- Returns:
- The address of the XMPP entity for.
-
-