Mercurial > pidgin.yaz
annotate libpurple/protocols/jabber/auth.c @ 31449:1c660ba17ba1
propagate from branch 'im.pidgin.pidgin' (head 6f879669a6513a5c40335bbaefe842389a92b39e)
to branch 'im.pidgin.cpw.qulogic.cairo' (head 4ab0199887f74442673fd46dcbb662bc7f070bc4)
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Sun, 21 Nov 2010 20:30:12 +0000 |
parents | cea7e713ef07 |
children | a5b556ac1de5 |
rev | line source |
---|---|
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /* |
15823 | 2 * purple - Jabber Protocol Plugin |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3 * |
28398
c585572e80dd
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents:
27463
diff
changeset
|
4 * Purple is the legal property of its developers, whose names are too numerous |
c585572e80dd
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents:
27463
diff
changeset
|
5 * to list here. Please refer to the COPYRIGHT file distributed with this |
c585572e80dd
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents:
27463
diff
changeset
|
6 * source distribution. |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
7 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
8 * This program is free software; you can redistribute it and/or modify |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
11 * (at your option) any later version. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
12 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
16 * GNU General Public License for more details. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
17 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
19 * along with this program; if not, write to the Free Software |
19680
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19674
diff
changeset
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
21 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
22 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
23 #include "internal.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
24 |
15891
87ea711b9781
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents:
15823
diff
changeset
|
25 #include "account.h" |
87ea711b9781
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents:
15823
diff
changeset
|
26 #include "debug.h" |
87ea711b9781
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents:
15823
diff
changeset
|
27 #include "cipher.h" |
20152
0cb113dfb096
Disable the account when the user cancels entering the password so the account isn't stuck in a weird unconnected state. Fixes #1791
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19999
diff
changeset
|
28 #include "core.h" |
15891
87ea711b9781
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents:
15823
diff
changeset
|
29 #include "conversation.h" |
87ea711b9781
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents:
15823
diff
changeset
|
30 #include "request.h" |
87ea711b9781
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents:
15823
diff
changeset
|
31 #include "sslconn.h" |
87ea711b9781
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents:
15823
diff
changeset
|
32 #include "util.h" |
87ea711b9781
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents:
15823
diff
changeset
|
33 #include "xmlnode.h" |
87ea711b9781
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents:
15823
diff
changeset
|
34 |
26542
680b54e417c1
Make the last one compile (add disco.h) and alphabetize.
Paul Aurich <paul@darkrain42.org>
parents:
26540
diff
changeset
|
35 #include "auth.h" |
680b54e417c1
Make the last one compile (add disco.h) and alphabetize.
Paul Aurich <paul@darkrain42.org>
parents:
26540
diff
changeset
|
36 #include "disco.h" |
680b54e417c1
Make the last one compile (add disco.h) and alphabetize.
Paul Aurich <paul@darkrain42.org>
parents:
26540
diff
changeset
|
37 #include "jabber.h" |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
38 #include "jutil.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
39 #include "iq.h" |
16068
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15891
diff
changeset
|
40 #include "notify.h" |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
41 |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
42 static GSList *auth_mechs = NULL; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
43 |
26547
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
44 static void auth_old_result_cb(JabberStream *js, const char *from, |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
45 JabberIqType type, const char *id, |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
46 xmlnode *packet, gpointer data); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
47 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
48 static void finish_plaintext_authentication(JabberStream *js) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
49 { |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
50 JabberIq *iq; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
51 xmlnode *query, *x; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
52 |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
53 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:auth"); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
54 query = xmlnode_get_child(iq->node, "query"); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
55 x = xmlnode_new_child(query, "username"); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
56 xmlnode_insert_data(x, js->user->node, -1); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
57 x = xmlnode_new_child(query, "resource"); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
58 xmlnode_insert_data(x, js->user->resource, -1); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
59 x = xmlnode_new_child(query, "password"); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
60 xmlnode_insert_data(x, purple_connection_get_password(js->gc), -1); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
61 jabber_iq_set_callback(iq, auth_old_result_cb, NULL); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
62 jabber_iq_send(iq); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
63 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
64 |
15823 | 65 static void allow_plaintext_auth(PurpleAccount *account) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
66 { |
29079
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
29078
diff
changeset
|
67 PurpleConnection *gc; |
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
29078
diff
changeset
|
68 JabberStream *js; |
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
29078
diff
changeset
|
69 |
15823 | 70 purple_account_set_bool(account, "auth_plain_in_clear", TRUE); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
71 |
29079
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
29078
diff
changeset
|
72 gc = purple_account_get_connection(account); |
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
29078
diff
changeset
|
73 js = purple_connection_get_protocol_data(gc); |
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
29078
diff
changeset
|
74 |
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
29078
diff
changeset
|
75 finish_plaintext_authentication(js); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
76 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
77 |
15823 | 78 static void disallow_plaintext_auth(PurpleAccount *account) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
79 { |
29079
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
29078
diff
changeset
|
80 purple_connection_error_reason(purple_account_get_connection(account), |
21358 | 81 PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR, |
20117
f24a2cacacd1
Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <will.thompson@collabora.co.uk>
parents:
19999
diff
changeset
|
82 _("Server requires plaintext authentication over an unencrypted stream")); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
83 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
84 |
29097
cea22db36ffc
jabber: Use NS_XMPP_SASL
Paul Aurich <paul@darkrain42.org>
parents:
29089
diff
changeset
|
85 #ifdef HAVE_CYRUS_SASL |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
86 static void |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
87 auth_old_pass_cb(PurpleConnection *gc, PurpleRequestFields *fields) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
88 { |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
89 PurpleAccount *account; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
90 JabberStream *js; |
16068
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15891
diff
changeset
|
91 const char *entry; |
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15891
diff
changeset
|
92 gboolean remember; |
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15891
diff
changeset
|
93 |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
94 /* The password prompt dialog doesn't get disposed if the account disconnects */ |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
95 if (!PURPLE_CONNECTION_IS_VALID(gc)) |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
96 return; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
97 |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
98 account = purple_connection_get_account(gc); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
99 js = purple_connection_get_protocol_data(gc); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
100 |
16068
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15891
diff
changeset
|
101 entry = purple_request_fields_get_string(fields, "password"); |
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15891
diff
changeset
|
102 remember = purple_request_fields_get_bool(fields, "remember"); |
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15891
diff
changeset
|
103 |
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15891
diff
changeset
|
104 if (!entry || !*entry) |
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15891
diff
changeset
|
105 { |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
106 purple_notify_error(account, NULL, _("Password is required to sign on."), NULL); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
107 return; |
16068
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15891
diff
changeset
|
108 } |
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15891
diff
changeset
|
109 |
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15891
diff
changeset
|
110 if (remember) |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
111 purple_account_set_remember_password(account, TRUE); |
16068
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15891
diff
changeset
|
112 |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
113 purple_account_set_password(account, entry); |
20152
0cb113dfb096
Disable the account when the user cancels entering the password so the account isn't stuck in a weird unconnected state. Fixes #1791
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19999
diff
changeset
|
114 |
16068
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15891
diff
changeset
|
115 /* Restart our connection */ |
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15891
diff
changeset
|
116 jabber_auth_start_old(js); |
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15891
diff
changeset
|
117 } |
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15891
diff
changeset
|
118 |
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15891
diff
changeset
|
119 static void |
29079
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
29078
diff
changeset
|
120 auth_no_pass_cb(PurpleConnection *gc, PurpleRequestFields *fields) |
16068
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15891
diff
changeset
|
121 { |
19674
55c47f7ab2a2
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19197
diff
changeset
|
122 /* The password prompt dialog doesn't get disposed if the account disconnects */ |
29079
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
29078
diff
changeset
|
123 if (!PURPLE_CONNECTION_IS_VALID(gc)) |
19674
55c47f7ab2a2
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19197
diff
changeset
|
124 return; |
55c47f7ab2a2
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19197
diff
changeset
|
125 |
30865
1cdae196aac8
Standardize on "cancelled".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30532
diff
changeset
|
126 /* Disable the account as the user has cancelled connecting */ |
29079
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
29078
diff
changeset
|
127 purple_account_set_enabled(purple_connection_get_account(gc), purple_core_get_ui(), FALSE); |
16068
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15891
diff
changeset
|
128 } |
29097
cea22db36ffc
jabber: Use NS_XMPP_SASL
Paul Aurich <paul@darkrain42.org>
parents:
29089
diff
changeset
|
129 #endif |
16068
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15891
diff
changeset
|
130 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
131 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
132 jabber_auth_start(JabberStream *js, xmlnode *packet) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
133 { |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
134 GSList *mechanisms = NULL; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
135 GSList *l; |
29107
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
136 xmlnode *response = NULL; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
137 xmlnode *mechs, *mechnode; |
29107
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
138 JabberSaslState state; |
29136
b94fd073187c
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents:
29107
diff
changeset
|
139 char *msg = NULL; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
140 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
141 if(js->registration) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
142 jabber_register_start(js); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
143 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
144 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
145 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
146 mechs = xmlnode_get_child(packet, "mechanisms"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
147 if(!mechs) { |
27463
f541583e31bd
More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents:
27461
diff
changeset
|
148 purple_connection_error_reason(js->gc, |
21358 | 149 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
27463
f541583e31bd
More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents:
27461
diff
changeset
|
150 _("Invalid response from server")); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
151 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
152 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
153 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
154 for(mechnode = xmlnode_get_child(mechs, "mechanism"); mechnode; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
155 mechnode = xmlnode_get_next_twin(mechnode)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
156 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
157 char *mech_name = xmlnode_get_data(mechnode); |
23077
9d331ad0a8dc
Skip the X-GOOGLE-TOKEN mech (given us by Google Talk when connecting with
Evan Schoenberg <evan.s@dreskin.net>
parents:
22795
diff
changeset
|
158 |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
159 if (mech_name && *mech_name) |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
160 mechanisms = g_slist_prepend(mechanisms, mech_name); |
30532 | 161 else |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
162 g_free(mech_name); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
163 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
164 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
165 |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
166 for (l = auth_mechs; l; l = l->next) { |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
167 JabberSaslMech *possible = l->data; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
168 |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
169 /* Is this the Cyrus SASL mechanism? */ |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
170 if (g_str_equal(possible->name, "*")) { |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
171 js->auth_mech = possible; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
172 break; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
173 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
174 |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
175 /* Can we find this mechanism in the server's list? */ |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
176 if (g_slist_find_custom(mechanisms, possible->name, (GCompareFunc)strcmp)) { |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
177 js->auth_mech = possible; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
178 break; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
179 } |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
180 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
181 |
30167 | 182 while (mechanisms) { |
183 g_free(mechanisms->data); | |
184 mechanisms = g_slist_delete_link(mechanisms, mechanisms); | |
185 } | |
186 | |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
187 if (js->auth_mech == NULL) { |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
188 /* Found no good mechanisms... */ |
27463
f541583e31bd
More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents:
27461
diff
changeset
|
189 purple_connection_error_reason(js->gc, |
21358 | 190 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
191 _("Server does not use any supported authentication method")); |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
192 return; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
193 } |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
194 |
29107
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
195 state = js->auth_mech->start(js, mechs, &response, &msg); |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
196 if (state == JABBER_SASL_STATE_FAIL) { |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
197 purple_connection_error_reason(js->gc, |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
198 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
199 msg ? msg : _("Unknown Error")); |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
200 } else if (response) { |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
201 jabber_send(js, response); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
202 xmlnode_free(response); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
203 } |
29136
b94fd073187c
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents:
29107
diff
changeset
|
204 |
b94fd073187c
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents:
29107
diff
changeset
|
205 g_free(msg); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
206 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
207 |
26547
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
208 static void auth_old_result_cb(JabberStream *js, const char *from, |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
209 JabberIqType type, const char *id, |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
210 xmlnode *packet, gpointer data) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
211 { |
26547
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
212 if (type == JABBER_IQ_RESULT) { |
28447
b357216b7b79
jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
213 jabber_stream_set_state(js, JABBER_STREAM_POST_AUTH); |
26540
f25410b0827c
Fix login process for older servers using IQ-auth.
Paul Aurich <paul@darkrain42.org>
parents:
26354
diff
changeset
|
214 jabber_disco_items_server(js); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
215 } else { |
29079
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
29078
diff
changeset
|
216 PurpleAccount *account; |
21358 | 217 PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR; |
20814
bde477ec6a71
Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <will.thompson@collabora.co.uk>
parents:
20792
diff
changeset
|
218 char *msg = jabber_parse_error(js, packet, &reason); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
219 xmlnode *error; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
220 const char *err_code; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
221 |
29081 | 222 account = purple_connection_get_account(js->gc); |
29079
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
29078
diff
changeset
|
223 |
20814
bde477ec6a71
Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <will.thompson@collabora.co.uk>
parents:
20792
diff
changeset
|
224 /* FIXME: Why is this not in jabber_parse_error? */ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
225 if((error = xmlnode_get_child(packet, "error")) && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
226 (err_code = xmlnode_get_attrib(error, "code")) && |
28890
5328e205d3fb
jabber: Use purple_strequal to simplify some auth code
Paul Aurich <paul@darkrain42.org>
parents:
28889
diff
changeset
|
227 g_str_equal(err_code, "401")) { |
21358 | 228 reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED; |
19999
da29f5c7dc1a
Clear the password when we get an auth. error and we're not saving passwords so that you don't need to go into the account settings to reset it. Fix #3083.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19680
diff
changeset
|
229 /* Clear the pasword if it isn't being saved */ |
29079
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
29078
diff
changeset
|
230 if (!purple_account_get_remember_password(account)) |
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
29078
diff
changeset
|
231 purple_account_set_password(account, NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
232 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
233 |
27463
f541583e31bd
More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents:
27461
diff
changeset
|
234 purple_connection_error_reason(js->gc, reason, msg); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
235 g_free(msg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
236 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
237 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
238 |
26547
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
239 static void auth_old_cb(JabberStream *js, const char *from, |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
240 JabberIqType type, const char *id, |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
241 xmlnode *packet, gpointer data) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
242 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
243 JabberIq *iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
244 xmlnode *query, *x; |
15823 | 245 const char *pw = purple_connection_get_password(js->gc); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
246 |
26547
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
247 if (type == JABBER_IQ_ERROR) { |
21358 | 248 PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR; |
20814
bde477ec6a71
Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <will.thompson@collabora.co.uk>
parents:
20792
diff
changeset
|
249 char *msg = jabber_parse_error(js, packet, &reason); |
27463
f541583e31bd
More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents:
27461
diff
changeset
|
250 purple_connection_error_reason(js->gc, reason, msg); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
251 g_free(msg); |
26547
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25443
diff
changeset
|
252 } else if (type == JABBER_IQ_RESULT) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
253 query = xmlnode_get_child(packet, "query"); |
30896
4072761e3454
jabber: Slight improvements to the stream ID fix
Paul Aurich <paul@darkrain42.org>
parents:
30895
diff
changeset
|
254 if (js->stream_id && *js->stream_id && |
4072761e3454
jabber: Slight improvements to the stream ID fix
Paul Aurich <paul@darkrain42.org>
parents:
30895
diff
changeset
|
255 xmlnode_get_child(query, "digest")) { |
24641
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
24511
diff
changeset
|
256 char *s, *hash; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
257 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
258 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:auth"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
259 query = xmlnode_get_child(iq->node, "query"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
260 x = xmlnode_new_child(query, "username"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
261 xmlnode_insert_data(x, js->user->node, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
262 x = xmlnode_new_child(query, "resource"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
263 xmlnode_insert_data(x, js->user->resource, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
264 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
265 x = xmlnode_new_child(query, "digest"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
266 s = g_strdup_printf("%s%s", js->stream_id, pw); |
30031
9f59abd49def
jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <ml@update.uu.se>
parents:
29264
diff
changeset
|
267 hash = jabber_calculate_data_hash(s, strlen(s), "sha1"); |
24641
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
24511
diff
changeset
|
268 xmlnode_insert_data(x, hash, -1); |
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
24511
diff
changeset
|
269 g_free(hash); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
270 g_free(s); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
271 jabber_iq_set_callback(iq, auth_old_result_cb, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
272 jabber_iq_send(iq); |
30896
4072761e3454
jabber: Slight improvements to the stream ID fix
Paul Aurich <paul@darkrain42.org>
parents:
30895
diff
changeset
|
273 } else if ((x = xmlnode_get_child(query, "crammd5"))) { |
4072761e3454
jabber: Slight improvements to the stream ID fix
Paul Aurich <paul@darkrain42.org>
parents:
30895
diff
changeset
|
274 /* For future reference, this appears to be a custom OS X extension |
4072761e3454
jabber: Slight improvements to the stream ID fix
Paul Aurich <paul@darkrain42.org>
parents:
30895
diff
changeset
|
275 * to non-SASL authentication. |
4072761e3454
jabber: Slight improvements to the stream ID fix
Paul Aurich <paul@darkrain42.org>
parents:
30895
diff
changeset
|
276 */ |
21854
cb715de60eb2
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents:
21853
diff
changeset
|
277 const char *challenge; |
23266
2b997b690500
A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23258
diff
changeset
|
278 gchar digest[33]; |
2b997b690500
A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23258
diff
changeset
|
279 PurpleCipherContext *hmac; |
21854
cb715de60eb2
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents:
21853
diff
changeset
|
280 |
23266
2b997b690500
A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23258
diff
changeset
|
281 /* Calculate the MHAC-MD5 digest */ |
2b997b690500
A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23258
diff
changeset
|
282 challenge = xmlnode_get_attrib(x, "challenge"); |
2b997b690500
A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23258
diff
changeset
|
283 hmac = purple_cipher_context_new_by_name("hmac", NULL); |
2b997b690500
A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23258
diff
changeset
|
284 purple_cipher_context_set_option(hmac, "hash", "md5"); |
2b997b690500
A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23258
diff
changeset
|
285 purple_cipher_context_set_key(hmac, (guchar *)pw); |
2b997b690500
A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23258
diff
changeset
|
286 purple_cipher_context_append(hmac, (guchar *)challenge, strlen(challenge)); |
2b997b690500
A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23258
diff
changeset
|
287 purple_cipher_context_digest_to_str(hmac, 33, digest, NULL); |
2b997b690500
A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23258
diff
changeset
|
288 purple_cipher_context_destroy(hmac); |
21856
2e899bbbf14c
Last minute 'cleanup' actually resulted in breakage on my cram-md5 commit. Fixed it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
21854
diff
changeset
|
289 |
2e899bbbf14c
Last minute 'cleanup' actually resulted in breakage on my cram-md5 commit. Fixed it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
21854
diff
changeset
|
290 /* Create the response query */ |
21854
cb715de60eb2
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents:
21853
diff
changeset
|
291 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:auth"); |
cb715de60eb2
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents:
21853
diff
changeset
|
292 query = xmlnode_get_child(iq->node, "query"); |
cb715de60eb2
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents:
21853
diff
changeset
|
293 |
cb715de60eb2
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents:
21853
diff
changeset
|
294 x = xmlnode_new_child(query, "username"); |
cb715de60eb2
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents:
21853
diff
changeset
|
295 xmlnode_insert_data(x, js->user->node, -1); |
cb715de60eb2
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents:
21853
diff
changeset
|
296 x = xmlnode_new_child(query, "resource"); |
cb715de60eb2
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents:
21853
diff
changeset
|
297 xmlnode_insert_data(x, js->user->resource, -1); |
cb715de60eb2
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents:
21853
diff
changeset
|
298 |
cb715de60eb2
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents:
21853
diff
changeset
|
299 x = xmlnode_new_child(query, "crammd5"); |
cb715de60eb2
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents:
21853
diff
changeset
|
300 |
23266
2b997b690500
A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23258
diff
changeset
|
301 xmlnode_insert_data(x, digest, 32); |
21854
cb715de60eb2
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents:
21853
diff
changeset
|
302 |
cb715de60eb2
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents:
21853
diff
changeset
|
303 jabber_iq_set_callback(iq, auth_old_result_cb, NULL); |
cb715de60eb2
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents:
21853
diff
changeset
|
304 jabber_iq_send(iq); |
cb715de60eb2
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents:
21853
diff
changeset
|
305 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
306 } else if(xmlnode_get_child(query, "password")) { |
29079
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
29078
diff
changeset
|
307 PurpleAccount *account = purple_connection_get_account(js->gc); |
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
29078
diff
changeset
|
308 if(!jabber_stream_is_ssl(js) && !purple_account_get_bool(account, |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
309 "auth_plain_in_clear", FALSE)) { |
22655
fa7e07c74a59
The warning string for plaintext auth over an unencrypted connection is found
Evan Schoenberg <evan.s@dreskin.net>
parents:
22642
diff
changeset
|
310 char *msg = g_strdup_printf(_("%s requires plaintext authentication over an unencrypted connection. Allow this and continue authentication?"), |
29079
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
29078
diff
changeset
|
311 purple_account_get_username(account)); |
21099
51cf02dbdb0e
disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents:
21095
diff
changeset
|
312 purple_request_yes_no(js->gc, _("Plaintext Authentication"), |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
313 _("Plaintext Authentication"), |
22655
fa7e07c74a59
The warning string for plaintext auth over an unencrypted connection is found
Evan Schoenberg <evan.s@dreskin.net>
parents:
22642
diff
changeset
|
314 msg, |
22143
70fc60344317
A few more of those "default_action" fixes
Mark Doliner <mark@kingant.net>
parents:
21949
diff
changeset
|
315 1, |
29079
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
29078
diff
changeset
|
316 account, NULL, NULL, |
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
29078
diff
changeset
|
317 account, allow_plaintext_auth, |
21099
51cf02dbdb0e
disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents:
21095
diff
changeset
|
318 disallow_plaintext_auth); |
22655
fa7e07c74a59
The warning string for plaintext auth over an unencrypted connection is found
Evan Schoenberg <evan.s@dreskin.net>
parents:
22642
diff
changeset
|
319 g_free(msg); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
320 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
321 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
322 finish_plaintext_authentication(js); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
323 } else { |
27463
f541583e31bd
More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents:
27461
diff
changeset
|
324 purple_connection_error_reason(js->gc, |
21358 | 325 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
20117
f24a2cacacd1
Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <will.thompson@collabora.co.uk>
parents:
19999
diff
changeset
|
326 _("Server does not use any supported authentication method")); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
327 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
328 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
329 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
330 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
331 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
332 void jabber_auth_start_old(JabberStream *js) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
333 { |
29079
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
29078
diff
changeset
|
334 PurpleAccount *account; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
335 JabberIq *iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
336 xmlnode *query, *username; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
337 |
29079
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
29078
diff
changeset
|
338 account = purple_connection_get_account(js->gc); |
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
29078
diff
changeset
|
339 |
28658
fa77b70c8ca6
jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents:
28447
diff
changeset
|
340 /* |
fa77b70c8ca6
jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents:
28447
diff
changeset
|
341 * We can end up here without encryption if the server doesn't support |
27029
131e41a24d95
Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <paul@darkrain42.org>
parents:
26569
diff
changeset
|
342 * <stream:features/> and we're not using old-style SSL. If the user |
131e41a24d95
Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <paul@darkrain42.org>
parents:
26569
diff
changeset
|
343 * is requiring SSL/TLS, we need to enforce it. |
131e41a24d95
Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <paul@darkrain42.org>
parents:
26569
diff
changeset
|
344 */ |
131e41a24d95
Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <paul@darkrain42.org>
parents:
26569
diff
changeset
|
345 if (!jabber_stream_is_ssl(js) && |
30895
8084631e2e84
jabber: Unify "Require TLS" and "Use old-style (port 5223) SSL" settings
Paul Aurich <paul@darkrain42.org>
parents:
30865
diff
changeset
|
346 g_str_equal("require_tls", |
8084631e2e84
jabber: Unify "Require TLS" and "Use old-style (port 5223) SSL" settings
Paul Aurich <paul@darkrain42.org>
parents:
30865
diff
changeset
|
347 purple_account_get_string(account, "connection_security", JABBER_DEFAULT_REQUIRE_TLS))) { |
27463
f541583e31bd
More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents:
27461
diff
changeset
|
348 purple_connection_error_reason(js->gc, |
27029
131e41a24d95
Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <paul@darkrain42.org>
parents:
26569
diff
changeset
|
349 PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR, |
131e41a24d95
Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <paul@darkrain42.org>
parents:
26569
diff
changeset
|
350 _("You require encryption, but it is not available on this server.")); |
131e41a24d95
Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <paul@darkrain42.org>
parents:
26569
diff
changeset
|
351 return; |
131e41a24d95
Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <paul@darkrain42.org>
parents:
26569
diff
changeset
|
352 } |
131e41a24d95
Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <paul@darkrain42.org>
parents:
26569
diff
changeset
|
353 |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
354 if (js->registration) { |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
355 jabber_register_start(js); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
356 return; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
357 } |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
358 |
28658
fa77b70c8ca6
jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents:
28447
diff
changeset
|
359 /* |
fa77b70c8ca6
jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents:
28447
diff
changeset
|
360 * IQ Auth doesn't have support for resource binding, so we need to pick a |
fa77b70c8ca6
jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents:
28447
diff
changeset
|
361 * default resource so it will work properly. jabberd14 throws an error and |
fa77b70c8ca6
jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents:
28447
diff
changeset
|
362 * iChat server just fails silently. |
fa77b70c8ca6
jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents:
28447
diff
changeset
|
363 */ |
fa77b70c8ca6
jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents:
28447
diff
changeset
|
364 if (!js->user->resource || *js->user->resource == '\0') { |
fa77b70c8ca6
jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents:
28447
diff
changeset
|
365 g_free(js->user->resource); |
fa77b70c8ca6
jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents:
28447
diff
changeset
|
366 js->user->resource = g_strdup("Home"); |
fa77b70c8ca6
jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents:
28447
diff
changeset
|
367 } |
fa77b70c8ca6
jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents:
28447
diff
changeset
|
368 |
16068
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15891
diff
changeset
|
369 #ifdef HAVE_CYRUS_SASL |
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15891
diff
changeset
|
370 /* If we have Cyrus SASL, then passwords will have been set |
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15891
diff
changeset
|
371 * to OPTIONAL for this protocol. So, we need to do our own |
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15891
diff
changeset
|
372 * password prompting here |
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15891
diff
changeset
|
373 */ |
20152
0cb113dfb096
Disable the account when the user cancels entering the password so the account isn't stuck in a weird unconnected state. Fixes #1791
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19999
diff
changeset
|
374 |
29079
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
29078
diff
changeset
|
375 if (!purple_account_get_password(account)) { |
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
29078
diff
changeset
|
376 purple_account_request_password(account, G_CALLBACK(auth_old_pass_cb), G_CALLBACK(auth_no_pass_cb), js->gc); |
16068
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15891
diff
changeset
|
377 return; |
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15891
diff
changeset
|
378 } |
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15891
diff
changeset
|
379 #endif |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
380 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:auth"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
381 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
382 query = xmlnode_get_child(iq->node, "query"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
383 username = xmlnode_new_child(query, "username"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
384 xmlnode_insert_data(username, js->user->node, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
385 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
386 jabber_iq_set_callback(iq, auth_old_cb, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
387 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
388 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
389 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
390 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
391 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
392 jabber_auth_handle_challenge(JabberStream *js, xmlnode *packet) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
393 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
394 const char *ns = xmlnode_get_namespace(packet); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
395 |
29097
cea22db36ffc
jabber: Use NS_XMPP_SASL
Paul Aurich <paul@darkrain42.org>
parents:
29089
diff
changeset
|
396 if (!purple_strequal(ns, NS_XMPP_SASL)) { |
27463
f541583e31bd
More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents:
27461
diff
changeset
|
397 purple_connection_error_reason(js->gc, |
21358 | 398 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
27463
f541583e31bd
More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents:
27461
diff
changeset
|
399 _("Invalid response from server")); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
400 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
401 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
402 |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
403 if (js->auth_mech && js->auth_mech->handle_challenge) { |
29107
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
404 xmlnode *response = NULL; |
29136
b94fd073187c
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents:
29107
diff
changeset
|
405 char *msg = NULL; |
29107
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
406 JabberSaslState state = js->auth_mech->handle_challenge(js, packet, &response, &msg); |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
407 if (state == JABBER_SASL_STATE_FAIL) { |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
408 purple_connection_error_reason(js->gc, |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
409 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
410 msg ? msg : _("Invalid challenge from server")); |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
411 } else if (response) { |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
412 jabber_send(js, response); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
413 xmlnode_free(response); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
414 } |
29136
b94fd073187c
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents:
29107
diff
changeset
|
415 |
b94fd073187c
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents:
29107
diff
changeset
|
416 g_free(msg); |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
417 } else |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
418 purple_debug_warning("jabber", "Received unexpected (and unhandled) <challenge/>\n"); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
419 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
420 |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
421 void jabber_auth_handle_success(JabberStream *js, xmlnode *packet) |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
422 { |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
423 const char *ns = xmlnode_get_namespace(packet); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
424 |
29097
cea22db36ffc
jabber: Use NS_XMPP_SASL
Paul Aurich <paul@darkrain42.org>
parents:
29089
diff
changeset
|
425 if (!purple_strequal(ns, NS_XMPP_SASL)) { |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
426 purple_connection_error_reason(js->gc, |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
427 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
428 _("Invalid response from server")); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
429 return; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
430 } |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
431 |
29107
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
432 if (js->auth_mech && js->auth_mech->handle_success) { |
29136
b94fd073187c
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents:
29107
diff
changeset
|
433 char *msg = NULL; |
29107
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
434 JabberSaslState state = js->auth_mech->handle_success(js, packet, &msg); |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
435 |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
436 if (state == JABBER_SASL_STATE_FAIL) { |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
437 purple_connection_error_reason(js->gc, |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
438 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
439 msg ? msg : _("Invalid response from server")); |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
440 return; |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
441 } else if (state == JABBER_SASL_STATE_CONTINUE) { |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
442 purple_connection_error_reason(js->gc, |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
443 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
444 msg ? msg : _("Server thinks authentication is complete, but client does not")); |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
445 return; |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
446 } |
29136
b94fd073187c
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents:
29107
diff
changeset
|
447 |
b94fd073187c
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents:
29107
diff
changeset
|
448 g_free(msg); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
449 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
450 |
28447
b357216b7b79
jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
451 /* |
b357216b7b79
jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
452 * The stream will be reinitialized later in jabber_recv_cb_ssl() or |
b357216b7b79
jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
453 * jabber_bosh_connection_send. |
b357216b7b79
jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
454 */ |
b357216b7b79
jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
455 js->reinit = TRUE; |
b357216b7b79
jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
456 jabber_stream_set_state(js, JABBER_STREAM_POST_AUTH); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
457 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
458 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
459 void jabber_auth_handle_failure(JabberStream *js, xmlnode *packet) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
460 { |
21358 | 461 PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR; |
29136
b94fd073187c
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents:
29107
diff
changeset
|
462 char *msg = NULL; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
463 |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
464 if (js->auth_mech && js->auth_mech->handle_failure) { |
29107
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
465 xmlnode *stanza = NULL; |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
466 JabberSaslState state = js->auth_mech->handle_failure(js, packet, &stanza, &msg); |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
29097
diff
changeset
|
467 |
29264
c64b22932ffa
Cyrus may not have anything (yet) if it's waiting for a callback or something.
Paul Aurich <paul@darkrain42.org>
parents:
29136
diff
changeset
|
468 if (state != JABBER_SASL_STATE_FAIL) { |
c64b22932ffa
Cyrus may not have anything (yet) if it's waiting for a callback or something.
Paul Aurich <paul@darkrain42.org>
parents:
29136
diff
changeset
|
469 if (stanza) { |
c64b22932ffa
Cyrus may not have anything (yet) if it's waiting for a callback or something.
Paul Aurich <paul@darkrain42.org>
parents:
29136
diff
changeset
|
470 jabber_send(js, stanza); |
c64b22932ffa
Cyrus may not have anything (yet) if it's waiting for a callback or something.
Paul Aurich <paul@darkrain42.org>
parents:
29136
diff
changeset
|
471 xmlnode_free(stanza); |
c64b22932ffa
Cyrus may not have anything (yet) if it's waiting for a callback or something.
Paul Aurich <paul@darkrain42.org>
parents:
29136
diff
changeset
|
472 } |
c64b22932ffa
Cyrus may not have anything (yet) if it's waiting for a callback or something.
Paul Aurich <paul@darkrain42.org>
parents:
29136
diff
changeset
|
473 |
22750
d5b3afea8764
After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evan.s@dreskin.net>
parents:
22655
diff
changeset
|
474 return; |
d5b3afea8764
After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evan.s@dreskin.net>
parents:
22655
diff
changeset
|
475 } |
22640
23fe481afccf
The next version of RFC 3920, the draft of which can be found at http://www.xmpp.org/internet-drafts/draft-saintandre-rfc3920bis-04.html, and subsequent email clarifications with Peter Saint-Andre and Alexey Melnikov indicate that we should be trying the next mechanism in line after one mechanism fails. We should also be ensuring that the mech list is sorted in order of descending security, which we don't do yet; however, servers are supposed to send us a sorted list, as well, so this isn't a major issue.
Stu Tomlinson <stu@nosnilmot.com>
parents:
22515
diff
changeset
|
476 } |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
477 |
29136
b94fd073187c
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents:
29107
diff
changeset
|
478 if (!msg) |
b94fd073187c
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents:
29107
diff
changeset
|
479 msg = jabber_parse_error(js, packet, &reason); |
b94fd073187c
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents:
29107
diff
changeset
|
480 |
b94fd073187c
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents:
29107
diff
changeset
|
481 if (!msg) { |
27463
f541583e31bd
More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents:
27461
diff
changeset
|
482 purple_connection_error_reason(js->gc, |
21358 | 483 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
27463
f541583e31bd
More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents:
27461
diff
changeset
|
484 _("Invalid response from server")); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
485 } else { |
27463
f541583e31bd
More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents:
27461
diff
changeset
|
486 purple_connection_error_reason(js->gc, reason, msg); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
487 g_free(msg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
488 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
489 } |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
490 |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
491 static gint compare_mech(gconstpointer a, gconstpointer b) |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
492 { |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
493 const JabberSaslMech *mech_a = a; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
494 const JabberSaslMech *mech_b = b; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
495 |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
496 /* higher priority comes *before* lower priority in the list */ |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
497 if (mech_a->priority > mech_b->priority) |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
498 return -1; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
499 else if (mech_a->priority < mech_b->priority) |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
500 return 1; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
501 /* This really shouldn't happen */ |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
502 return 0; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
503 } |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
504 |
31330
cea7e713ef07
jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
eion@robbmob.com
parents:
30896
diff
changeset
|
505 void jabber_auth_add_mech(JabberSaslMech *mech) |
cea7e713ef07
jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
eion@robbmob.com
parents:
30896
diff
changeset
|
506 { |
cea7e713ef07
jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
eion@robbmob.com
parents:
30896
diff
changeset
|
507 auth_mechs = g_slist_insert_sorted(auth_mechs, mech, compare_mech); |
cea7e713ef07
jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
eion@robbmob.com
parents:
30896
diff
changeset
|
508 } |
cea7e713ef07
jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
eion@robbmob.com
parents:
30896
diff
changeset
|
509 |
cea7e713ef07
jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
eion@robbmob.com
parents:
30896
diff
changeset
|
510 void jabber_auth_remove_mech(JabberSaslMech *mech) |
cea7e713ef07
jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
eion@robbmob.com
parents:
30896
diff
changeset
|
511 { |
cea7e713ef07
jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
eion@robbmob.com
parents:
30896
diff
changeset
|
512 auth_mechs = g_slist_remove(auth_mechs, mech); |
cea7e713ef07
jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
eion@robbmob.com
parents:
30896
diff
changeset
|
513 } |
cea7e713ef07
jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
eion@robbmob.com
parents:
30896
diff
changeset
|
514 |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
515 void jabber_auth_init(void) |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
516 { |
29089
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29081
diff
changeset
|
517 JabberSaslMech **tmp; |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29081
diff
changeset
|
518 gint count, i; |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29081
diff
changeset
|
519 |
31330
cea7e713ef07
jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
eion@robbmob.com
parents:
30896
diff
changeset
|
520 jabber_auth_add_mech(jabber_auth_get_plain_mech()); |
cea7e713ef07
jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
eion@robbmob.com
parents:
30896
diff
changeset
|
521 jabber_auth_add_mech(jabber_auth_get_digest_md5_mech()); |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
522 #ifdef HAVE_CYRUS_SASL |
31330
cea7e713ef07
jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
eion@robbmob.com
parents:
30896
diff
changeset
|
523 jabber_auth_add_mech(jabber_auth_get_cyrus_mech()); |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
524 #endif |
29089
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29081
diff
changeset
|
525 |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29081
diff
changeset
|
526 tmp = jabber_auth_get_scram_mechs(&count); |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
29081
diff
changeset
|
527 for (i = 0; i < count; ++i) |
31330
cea7e713ef07
jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
eion@robbmob.com
parents:
30896
diff
changeset
|
528 jabber_auth_add_mech(tmp[i]); |
29078
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
529 } |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
530 |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
531 void jabber_auth_uninit(void) |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
532 { |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
533 g_slist_free(auth_mechs); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
534 auth_mechs = NULL; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28896
diff
changeset
|
535 } |