Mercurial > eldonilo > lightstring
annotate plugins/ANONYMOUS.js @ 82:06495f77a74c
Fix a problem with dataforms.
author | Sonny Piers <sonny.piers@gmail.com> |
---|---|
date | Tue, 07 Feb 2012 18:46:04 +0100 |
parents | e1ccfb580228 |
children |
rev | line source |
---|---|
65 | 1 'use strict'; |
2 | |
3 /** | |
4 Copyright (c) 2012, Sonny Piers <sonny at fastmail dot net> | |
5 | |
6 Permission to use, copy, modify, and/or distribute this software for any | |
7 purpose with or without fee is hereby granted, provided that the above | |
8 copyright notice and this permission notice appear in all copies. | |
9 | |
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
13 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
17 */ | |
18 | |
66
fa184759fc41
Adds references to ANONYMOUS/DIGEST-MD5/PLAIN plugins.
Sonny Piers <sonny.piers@gmail.com>
parents:
65
diff
changeset
|
19 /* |
fa184759fc41
Adds references to ANONYMOUS/DIGEST-MD5/PLAIN plugins.
Sonny Piers <sonny.piers@gmail.com>
parents:
65
diff
changeset
|
20 References: |
fa184759fc41
Adds references to ANONYMOUS/DIGEST-MD5/PLAIN plugins.
Sonny Piers <sonny.piers@gmail.com>
parents:
65
diff
changeset
|
21 Extensible Messaging and Presence Protocol (XMPP): Core - SASL Negotiation |
fa184759fc41
Adds references to ANONYMOUS/DIGEST-MD5/PLAIN plugins.
Sonny Piers <sonny.piers@gmail.com>
parents:
65
diff
changeset
|
22 http://xmpp.org/rfcs/rfc6120.html#sasl |
fa184759fc41
Adds references to ANONYMOUS/DIGEST-MD5/PLAIN plugins.
Sonny Piers <sonny.piers@gmail.com>
parents:
65
diff
changeset
|
23 Simple Authentication and Security Layer (SASL) |
fa184759fc41
Adds references to ANONYMOUS/DIGEST-MD5/PLAIN plugins.
Sonny Piers <sonny.piers@gmail.com>
parents:
65
diff
changeset
|
24 http://tools.ietf.org/html/rfc4422 |
fa184759fc41
Adds references to ANONYMOUS/DIGEST-MD5/PLAIN plugins.
Sonny Piers <sonny.piers@gmail.com>
parents:
65
diff
changeset
|
25 Anonymous Simple Authentication and Security Layer (SASL) Mechanism |
fa184759fc41
Adds references to ANONYMOUS/DIGEST-MD5/PLAIN plugins.
Sonny Piers <sonny.piers@gmail.com>
parents:
65
diff
changeset
|
26 http://tools.ietf.org/html/rfc4505 |
fa184759fc41
Adds references to ANONYMOUS/DIGEST-MD5/PLAIN plugins.
Sonny Piers <sonny.piers@gmail.com>
parents:
65
diff
changeset
|
27 Best Practices for Use of SASL ANONYMOUS |
fa184759fc41
Adds references to ANONYMOUS/DIGEST-MD5/PLAIN plugins.
Sonny Piers <sonny.piers@gmail.com>
parents:
65
diff
changeset
|
28 http://xmpp.org/extensions/xep-0175.html |
fa184759fc41
Adds references to ANONYMOUS/DIGEST-MD5/PLAIN plugins.
Sonny Piers <sonny.piers@gmail.com>
parents:
65
diff
changeset
|
29 */ |
fa184759fc41
Adds references to ANONYMOUS/DIGEST-MD5/PLAIN plugins.
Sonny Piers <sonny.piers@gmail.com>
parents:
65
diff
changeset
|
30 |
65 | 31 Lightstring.plugins['ANONYMOUS'] = { |
32 handlers: { | |
33 'mechanisms': function (stanza) { | |
34 if(stanza.mechanisms.indexOf('ANONYMOUS') === -1) | |
35 return; | |
36 | |
37 this.send( | |
38 "<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl'" + | |
39 " mechanism='ANONYMOUS'/>" | |
40 ); | |
41 }, | |
42 'success': function (stanza) { | |
43 this.send( | |
44 "<stream:stream to='" + this.jid.domain + "'" + | |
45 " xmlns='jabber:client'" + | |
46 " xmlns:stream='http://etherx.jabber.org/streams'" + | |
47 " version='1.0'/>" | |
48 ); | |
49 }, | |
50 'features': function (stanza) { | |
68 | 51 var Conn = this; |
65 | 52 //TODO check if bind supported |
53 var bind = | |
54 "<iq type='set' id='"+Lightstring.newId('sendiq:')+"'>" + | |
55 "<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/>" + | |
56 "</iq>"; | |
57 | |
58 this.send( | |
59 bind, | |
60 //Success | |
61 function(stanza) { | |
62 //Session http://xmpp.org/rfcs/rfc3921.html#session | |
68 | 63 Conn.jid = new Lightstring.JID(stanza.DOM.textContent); |
65 | 64 |
68 | 65 Conn.send( |
65 | 66 "<iq type='set' id='"+Lightstring.newId('sendiq:')+"'>" + |
67 "<session xmlns='urn:ietf:params:xml:ns:xmpp-session'/>" + | |
68 "</iq>", | |
69 function() { | |
68 | 70 Conn.emit('connected'); |
65 | 71 } |
72 ); | |
73 }, | |
74 //Error | |
75 function(stanza) { | |
76 //TODO: Error? | |
77 } | |
78 ); | |
79 } | |
80 } | |
81 }; |