XML Stream Flow

User registration and user authorization are two processes that take place at the start of an XML stream, immediately following the XML stream header exchange. The Jabber server is designed to check for and process any user registration request or authentication request before anything else.

This makes sense, as outside of a session (a session is created for a user when the authentication completes successfully) any other element - a <message/> packet, a <presence/> packet or an <iq/> packet that's not in the jabber:iq:register or jabber:iq:auth namespaces - is invalid. So if any of these other elements are sent before authentication has taken place, that is, before a session has been created for that connection, they are queued, and processed after authentication.

Figure 6-1 shows the general flow within an XML stream, with regard to where the registration and / or authentication steps happen.

Figure 6-1. XML Stream flow showing registration and authentication

          +----------------------------+
 time     | XML Stream Header exchange |
  |       +----------------------------+
  |                     |
  v         +-----------------------+    step 1
            | any non-registration  |
            | or non-authorization  |
            | packets occurring at  |
            | this stage are queued |
            +-----------------------+
                        |
            +-----------------------+    step 2
            | user registration or  |
            | user authorization    | 
            | takes place           |
            +-----------------------+
                       |
            +-----------------------+    step 3
            | user session is       |
            | created on successful |
            | authentication        |
            +-----------------------+
                       |
            +-----------------------+    step 4
            | any queued packets    |
            | are processed at this |
            | stage                 |
            +-----------------------+
                       |
            +-----------------------+ 
            | normal user session   |
            | activity              |
            :                       :
            :                       :
            :                       :
            |                       |
            +-----------------------+
                       |
         +-----------------------------+
         | XML stream is ended by the  |
         | server or the client        |
         +-----------------------------+