XMPP Presentation 160108105545 PDF
XMPP Presentation 160108105545 PDF
XMPP Presentation 160108105545 PDF
2
Requirements of RFC 2779
1. Scalability
2. Access Control
3. Message Encryption & Authentication
4. Presence Lookup & Notification
5. Presence Caching & Replication
6. Reliability
7. Performance
3
XMPP Core Overview
4
Addressing Scheme
5
• Domain Identifier –
• Node Identifier –
7
XML Streams and Stanzas
XML Streams
container for the exchange of XML elements between
any two entities over a network.
The start and end of the XML stream is denoted by
<stream> tag and </ stream> tag.
An XML stream is unidirectional.
XML Stanza
is a discrete semantic unit of structured information.
is at a depth=1 of the XML stream.
8
XML Stanzas
• Message Stanza
– include single messages, <stream>
– Types of messages are chat, error, group chat, <presence>
headline, normal. <show/>
– Child elements are <subject/> and <body/>. </presence>
<message
<message to='foo'>
to='[email protected]'
from='[email protected]/balcony' <body/>
xml:lang='en'> </message>
<subject>I implore you!</subject> <iq to='bar'>
<subject xml:lang=‘en'> <query/>
</subject>
</iq>
<body>Where are you, Romeo?</body>
<body xml:lang=‘en'> </stream>
</body>
</message>
9
•Presence Stanza
– to express an entity's current availability status.
– Types of Presence are unavailable, subscribe etc.
– Child elements are <show/>, <status/>, <priority/>.
<presence>
<show>dnd</show>
</presence>
•IQ Stanza
– is a request-response mechanism
– Types of IQ are get(request roaster), set(add item on roaster), result, error.
– Client requests current roster from server:
<iq type='get' id='roster_1'>
<query xmlns='jabber:iq:roster'/>
</iq>
10
::
A Basic Session:
C: <?xml version='1.0'?>
<stream:stream
to='shakespeare.lit'
xmlns='jabber:client'
xmlns:stream='http://etherx.jabber.org/streams'
version='1.0'>
S: <?xml version='1.0'?>
<stream:stream
from='shakespeare.lit'
id='id_123456789'
xmlns='jabber:client'
xmlns:stream='http://etherx.jabber.org/streams‘
version='1.0'>
….authentication ...
C: <message from='[email protected]'
to='[email protected]'
xml:lang='en'>
C: <body>Hi Romeo</body>
C: </message>
S: <message from='[email protected]'
to='[email protected]'
xml:lang='en'>
S: <body>Hi Juliet.</body>
S: </message>
C: </stream:stream> 11
S: </stream:stream>
Stream Encryption & Authentication
XMPP includes a method for securing the stream from tampering and
eavesdropping. This channel encryption method makes use of the
Transport Layer Security (TLS) protocol, along with a "STARTTLS“.
Example
Step 1: Client initiates stream to server:
<stream:stream
xmlns='jabber:client'
xmlns:stream='http://etherx.jabber.org/streams'
to='capulet.com'
version='1.0'>
Step 2: Server responds by sending a stream tag to client:
<stream:stream
xmlns='jabber:client'
xmlns:stream='http://etherx.jabber.org/streams'
id='12345678'
from='capulet.com'
version='1.0'>
12
Step 3: Server sends the STARTTLS extension to client along with
authentication mechanisms and any other stream features:
<stream:features>
<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'>
<required/>
</starttls>
<mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
<mechanism>DIGEST-MD5</mechanism>
<mechanism>PLAIN</mechanism>
</mechanisms> </stream:features>
Step 4: Client sends the STARTTLS command to server:
<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
Step 5: Server informs client to proceed:
<proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
Step 6: Client and server attempt to complete TLS negotiation over the
existing TCP connection.
Step 7: If TLS negotiation is successful, client initiates a new stream to
server: <stream:stream
xmlns='jabber:client'
xmlns:stream='http://etherx.jabber.org/streams'
to='capulet.com'
version='1.0'> 13
Step 8: Server responds by sending a stream header to client along with
any remaining negotiable stream features:
<stream:stream
xmlns='jabber:client'
xmlns:stream='http://etherx.jabber.org/streams'
from='capulet.com'
id='12345678'
version='1.0'>
<stream:features>
<mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
<mechanism>DIGEST-MD5</mechanism>
<mechanism>PLAIN</mechanism>
<mechanism>EXTERNAL</mechanism>
</mechanisms>
</stream:features>
Step 9: Client selects an authentication mechanism:
<auth
xmlns='urn:ietf:params:xml:ns:xmpp-sasl‘
mechanism='DIGEST-MD5'/>
Step 10: Server sends a base64-encoded challenge to client: The decoded challenge
is:
nonce="gx0P01RRVoOfJVrIJ6aNkFlinh9nM/Up9dazVTFTq1c=",\
realm="capulet.com",qop="auth,auth-int,auth-conf",\
cipher="rc4-40,rc4-56,rc4,des,3des",maxbuf=2048,\
charset=utf-8,algorithm=md5-sess 14
Step 11: Client responds to the challenge: The decoded response is:
username="juliet",realm="capulet.com",\ authzid="[email protected]/balcony",\
nonce="gx0P01RRVoOfJVrIJ6aNkFlinh9nM/Up9dazVTFTq1c=",\
cnonce="bdi7U/Duhd97ffXpS9mNhhK3ciY0FGO9xuqIlapBK4o=",\
nc=00000001,qop=auth-conf,cipher="rc4",maxbuf=2048,\
digest-uri="xmpp/capulet.com",\ response=8e0ac6010833b1224fcc4742afbdb352
Step 12: Server informs client of successful authentication:
<success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>
Step 13: Client initiates a new stream to server and the rest of the message
passing happens.
15
Order of Layers
16
Summary of XMPP- IM
• Establishing a Session
• Exchanging Messages
• Exchanging Presence Information
• Managing One's Roster
17