annotate libpurple/protocols/jabber/auth.c @ 31988:b6defcebfe4b

Steps toward hiding PurpleXfer. To convert prpls as they are now, lot of new accessors are needed (for stuff that maybe shouldn't be exposed directly). To convert prpls so that they don't keep re-implementing the same type of stuff, a lot of error-prone changes are needed.
author Daniel Atallah <daniel.atallah@gmail.com>
date Mon, 29 Aug 2011 22:55:51 +0000
parents a5b556ac1de5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /*
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
2 * purple - Jabber Protocol Plugin
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
28048
c585572e80dd Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents: 27381
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: 27381
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: 27381
diff changeset
6 * source distribution.
15373
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
19681
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19675
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15373
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
15889
87ea711b9781 Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents: 15822
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: 15822
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: 15822
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"
15889
87ea711b9781 Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents: 15822
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: 15822
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: 15822
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: 15822
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: 15822
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: 15822
diff changeset
34
26460
680b54e417c1 Make the last one compile (add disco.h) and alphabetize.
Paul Aurich <paul@darkrain42.org>
parents: 26458
diff changeset
35 #include "auth.h"
680b54e417c1 Make the last one compile (add disco.h) and alphabetize.
Paul Aurich <paul@darkrain42.org>
parents: 26458
diff changeset
36 #include "disco.h"
680b54e417c1 Make the last one compile (add disco.h) and alphabetize.
Paul Aurich <paul@darkrain42.org>
parents: 26458
diff changeset
37 #include "jabber.h"
15373
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: 15889
diff changeset
40 #include "notify.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
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: 28520
diff changeset
43
26465
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 25952
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: 25952
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: 25952
diff changeset
46 xmlnode *packet, gpointer data);
15373
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 {
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
50 JabberIq *iq;
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
51 xmlnode *query, *x;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
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: 28520
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: 28520
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: 28520
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: 28520
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: 28520
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: 28520
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: 28520
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: 28520
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: 28520
diff changeset
62 jabber_iq_send(iq);
15373
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
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
65 static void allow_plaintext_auth(PurpleAccount *account)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 {
28697
de8565bc63fe jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents: 28696
diff changeset
67 PurpleConnection *gc;
de8565bc63fe jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents: 28696
diff changeset
68 JabberStream *js;
de8565bc63fe jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents: 28696
diff changeset
69
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
70 purple_account_set_bool(account, "auth_plain_in_clear", TRUE);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71
28697
de8565bc63fe jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents: 28696
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: 28696
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: 28696
diff changeset
74
de8565bc63fe jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents: 28696
diff changeset
75 finish_plaintext_authentication(js);
15373
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
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
78 static void disallow_plaintext_auth(PurpleAccount *account)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 {
31872
a5b556ac1de5 Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <mark@kingant.net>
parents: 30892
diff changeset
80 purple_connection_error(purple_account_get_connection(account),
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
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"));
15373
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
28715
cea22db36ffc jabber: Use NS_XMPP_SASL
Paul Aurich <paul@darkrain42.org>
parents: 28707
diff changeset
85 #ifdef HAVE_CYRUS_SASL
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
86 static void
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
87 auth_old_pass_cb(PurpleConnection *gc, PurpleRequestFields *fields)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88 {
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
89 PurpleAccount *account;
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
90 JabberStream *js;
16068
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
91 const char *entry;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
92 gboolean remember;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
93
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
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: 28520
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: 28520
diff changeset
96 return;
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
97
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
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: 28520
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: 28520
diff changeset
100
16068
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
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: 15889
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: 15889
diff changeset
103
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
104 if (!entry || !*entry)
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
105 {
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
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: 28520
diff changeset
107 return;
16068
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
108 }
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
109
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
110 if (remember)
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
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: 15889
diff changeset
112
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
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: 15889
diff changeset
115 /* Restart our connection */
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
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: 15889
diff changeset
117 }
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
118
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
119 static void
28697
de8565bc63fe jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents: 28696
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: 15889
diff changeset
121 {
19675
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 */
28697
de8565bc63fe jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents: 28696
diff changeset
123 if (!PURPLE_CONNECTION_IS_VALID(gc))
19675
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
30432
1cdae196aac8 Standardize on "cancelled".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30108
diff changeset
126 /* Disable the account as the user has cancelled connecting */
28697
de8565bc63fe jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents: 28696
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: 15889
diff changeset
128 }
28715
cea22db36ffc jabber: Use NS_XMPP_SASL
Paul Aurich <paul@darkrain42.org>
parents: 28707
diff changeset
129 #endif
16068
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
130
15373
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 {
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
134 GSList *mechanisms = NULL;
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
135 GSList *l;
28725
4f45aae3ace1 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents: 28715
diff changeset
136 xmlnode *response = NULL;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 xmlnode *mechs, *mechnode;
28725
4f45aae3ace1 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents: 28715
diff changeset
138 JabberSaslState state;
28754
b94fd073187c jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents: 28725
diff changeset
139 char *msg = NULL;
15373
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) {
31872
a5b556ac1de5 Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <mark@kingant.net>
parents: 30892
diff changeset
148 purple_connection_error(js->gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
149 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
150 _("Invalid response from server"));
15373
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);
23075
9d331ad0a8dc Skip the X-GOOGLE-TOKEN mech (given us by Google Talk when connecting with
Evan Schoenberg <evan.s@dreskin.net>
parents: 22819
diff changeset
158
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
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: 28520
diff changeset
160 mechanisms = g_slist_prepend(mechanisms, mech_name);
30108
c79748e14499 Remove unnecessary check
Mark Doliner <mark@kingant.net>
parents: 29861
diff changeset
161 else
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
162 g_free(mech_name);
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
163
15373
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
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
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: 28520
diff changeset
167 JabberSaslMech *possible = l->data;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
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: 28520
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: 28520
diff changeset
171 js->auth_mech = possible;
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
172 break;
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
173 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
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: 28520
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: 28520
diff changeset
177 js->auth_mech = possible;
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
178 break;
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
179 }
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
180 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181
29755
9134be6baaef jabber: --more leaks
Paul Aurich <paul@darkrain42.org>
parents: 29630
diff changeset
182 while (mechanisms) {
9134be6baaef jabber: --more leaks
Paul Aurich <paul@darkrain42.org>
parents: 29630
diff changeset
183 g_free(mechanisms->data);
9134be6baaef jabber: --more leaks
Paul Aurich <paul@darkrain42.org>
parents: 29630
diff changeset
184 mechanisms = g_slist_delete_link(mechanisms, mechanisms);
9134be6baaef jabber: --more leaks
Paul Aurich <paul@darkrain42.org>
parents: 29630
diff changeset
185 }
9134be6baaef jabber: --more leaks
Paul Aurich <paul@darkrain42.org>
parents: 29630
diff changeset
186
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
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: 28520
diff changeset
188 /* Found no good mechanisms... */
31872
a5b556ac1de5 Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <mark@kingant.net>
parents: 30892
diff changeset
189 purple_connection_error(js->gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
190 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
15373
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"));
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
192 return;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 }
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
194
28725
4f45aae3ace1 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents: 28715
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: 28715
diff changeset
196 if (state == JABBER_SASL_STATE_FAIL) {
31872
a5b556ac1de5 Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <mark@kingant.net>
parents: 30892
diff changeset
197 purple_connection_error(js->gc,
28725
4f45aae3ace1 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents: 28715
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: 28715
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: 28715
diff changeset
200 } else if (response) {
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
201 jabber_send(js, response);
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
202 xmlnode_free(response);
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
203 }
28754
b94fd073187c jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents: 28725
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: 28725
diff changeset
205 g_free(msg);
15373
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
26465
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 25952
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: 25952
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: 25952
diff changeset
210 xmlnode *packet, gpointer data)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211 {
26465
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 25952
diff changeset
212 if (type == JABBER_IQ_RESULT) {
28096
b357216b7b79 jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <paul@darkrain42.org>
parents: 28048
diff changeset
213 jabber_stream_set_state(js, JABBER_STREAM_POST_AUTH);
26458
f25410b0827c Fix login process for older servers using IQ-auth.
Paul Aurich <paul@darkrain42.org>
parents: 26272
diff changeset
214 jabber_disco_items_server(js);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 } else {
28697
de8565bc63fe jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents: 28696
diff changeset
216 PurpleAccount *account;
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
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);
15373
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
28699
673ed3740cd7 Speilling!
Paul Aurich <paul@darkrain42.org>
parents: 28698
diff changeset
222 account = purple_connection_get_account(js->gc);
28697
de8565bc63fe jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents: 28696
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? */
15373
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")) &&
28514
5328e205d3fb jabber: Use purple_strequal to simplify some auth code
Paul Aurich <paul@darkrain42.org>
parents: 28513
diff changeset
227 g_str_equal(err_code, "401")) {
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
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: 19681
diff changeset
229 /* Clear the pasword if it isn't being saved */
28697
de8565bc63fe jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents: 28696
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: 28696
diff changeset
231 purple_account_set_password(account, NULL);
15373
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
31872
a5b556ac1de5 Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <mark@kingant.net>
parents: 30892
diff changeset
234 purple_connection_error(js->gc, reason, msg);
15373
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
26465
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 25952
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: 25952
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: 25952
diff changeset
241 xmlnode *packet, gpointer data)
15373
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;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
245 const char *pw = purple_connection_get_password(js->gc);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246
26465
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 25952
diff changeset
247 if (type == JABBER_IQ_ERROR) {
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
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);
31872
a5b556ac1de5 Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <mark@kingant.net>
parents: 30892
diff changeset
250 purple_connection_error(js->gc, reason, msg);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251 g_free(msg);
26465
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 25952
diff changeset
252 } else if (type == JABBER_IQ_RESULT) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253 query = xmlnode_get_child(packet, "query");
30463
4072761e3454 jabber: Slight improvements to the stream ID fix
Paul Aurich <paul@darkrain42.org>
parents: 30462
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: 30462
diff changeset
255 xmlnode_get_child(query, "digest")) {
24693
61e0924de04a Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents: 24565
diff changeset
256 char *s, *hash;
15373
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);
29630
9f59abd49def jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <ml@update.uu.se>
parents: 28878
diff changeset
267 hash = jabber_calculate_data_hash(s, strlen(s), "sha1");
24693
61e0924de04a Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents: 24565
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: 24565
diff changeset
269 g_free(hash);
15373
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);
30463
4072761e3454 jabber: Slight improvements to the stream ID fix
Paul Aurich <paul@darkrain42.org>
parents: 30462
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: 30462
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: 30462
diff changeset
275 * to non-SASL authentication.
4072761e3454 jabber: Slight improvements to the stream ID fix
Paul Aurich <paul@darkrain42.org>
parents: 30462
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;
23264
2b997b690500 A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23256
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: 23256
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
23264
2b997b690500 A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23256
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: 23256
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: 23256
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: 23256
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: 23256
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: 23256
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: 23256
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: 23256
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
23264
2b997b690500 A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23256
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
15373
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")) {
28697
de8565bc63fe jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents: 28696
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: 28696
diff changeset
308 if(!jabber_stream_is_ssl(js) && !purple_account_get_bool(account,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
309 "auth_plain_in_clear", FALSE)) {
22672
fa7e07c74a59 The warning string for plaintext auth over an unencrypted connection is found
Evan Schoenberg <evan.s@dreskin.net>
parents: 22659
diff changeset
310 char *msg = g_strdup_printf(_("%s requires plaintext authentication over an unencrypted connection. Allow this and continue authentication?"),
28697
de8565bc63fe jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents: 28696
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"),
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
313 _("Plaintext Authentication"),
22672
fa7e07c74a59 The warning string for plaintext auth over an unencrypted connection is found
Evan Schoenberg <evan.s@dreskin.net>
parents: 22659
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,
28697
de8565bc63fe jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents: 28696
diff changeset
316 account, NULL, NULL,
de8565bc63fe jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents: 28696
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);
22672
fa7e07c74a59 The warning string for plaintext auth over an unencrypted connection is found
Evan Schoenberg <evan.s@dreskin.net>
parents: 22659
diff changeset
319 g_free(msg);
15373
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 {
31872
a5b556ac1de5 Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <mark@kingant.net>
parents: 30892
diff changeset
324 purple_connection_error(js->gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
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"));
15373
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 {
28697
de8565bc63fe jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents: 28696
diff changeset
334 PurpleAccount *account;
15373
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
28697
de8565bc63fe jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents: 28696
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: 28696
diff changeset
339
28292
fa77b70c8ca6 jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents: 28096
diff changeset
340 /*
fa77b70c8ca6 jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents: 28096
diff changeset
341 * We can end up here without encryption if the server doesn't support
26947
131e41a24d95 Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <paul@darkrain42.org>
parents: 26487
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: 26487
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: 26487
diff changeset
344 */
131e41a24d95 Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <paul@darkrain42.org>
parents: 26487
diff changeset
345 if (!jabber_stream_is_ssl(js) &&
30462
8084631e2e84 jabber: Unify "Require TLS" and "Use old-style (port 5223) SSL" settings
Paul Aurich <paul@darkrain42.org>
parents: 30432
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: 30432
diff changeset
347 purple_account_get_string(account, "connection_security", JABBER_DEFAULT_REQUIRE_TLS))) {
31872
a5b556ac1de5 Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <mark@kingant.net>
parents: 30892
diff changeset
348 purple_connection_error(js->gc,
26947
131e41a24d95 Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <paul@darkrain42.org>
parents: 26487
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: 26487
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: 26487
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: 26487
diff changeset
352 }
131e41a24d95 Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <paul@darkrain42.org>
parents: 26487
diff changeset
353
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
354 if (js->registration) {
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
355 jabber_register_start(js);
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
356 return;
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
357 }
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
358
28292
fa77b70c8ca6 jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents: 28096
diff changeset
359 /*
fa77b70c8ca6 jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents: 28096
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: 28096
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: 28096
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: 28096
diff changeset
363 */
fa77b70c8ca6 jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents: 28096
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: 28096
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: 28096
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: 28096
diff changeset
367 }
fa77b70c8ca6 jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents: 28096
diff changeset
368
16068
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
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: 15889
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: 15889
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: 15889
diff changeset
372 * password prompting here
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
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
28697
de8565bc63fe jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents: 28696
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: 28696
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: 15889
diff changeset
377 return;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
378 }
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
379 #endif
15373
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
28715
cea22db36ffc jabber: Use NS_XMPP_SASL
Paul Aurich <paul@darkrain42.org>
parents: 28707
diff changeset
396 if (!purple_strequal(ns, NS_XMPP_SASL)) {
31872
a5b556ac1de5 Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <mark@kingant.net>
parents: 30892
diff changeset
397 purple_connection_error(js->gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
398 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
399 _("Invalid response from server"));
15373
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
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
403 if (js->auth_mech && js->auth_mech->handle_challenge) {
28725
4f45aae3ace1 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents: 28715
diff changeset
404 xmlnode *response = NULL;
28754
b94fd073187c jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents: 28725
diff changeset
405 char *msg = NULL;
28725
4f45aae3ace1 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents: 28715
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: 28715
diff changeset
407 if (state == JABBER_SASL_STATE_FAIL) {
31872
a5b556ac1de5 Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <mark@kingant.net>
parents: 30892
diff changeset
408 purple_connection_error(js->gc,
28725
4f45aae3ace1 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents: 28715
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: 28715
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: 28715
diff changeset
411 } else if (response) {
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
412 jabber_send(js, response);
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
413 xmlnode_free(response);
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
414 }
28754
b94fd073187c jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents: 28725
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: 28725
diff changeset
416 g_free(msg);
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
417 } else
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
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: 28520
diff changeset
419 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
420
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
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: 28520
diff changeset
422 {
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
423 const char *ns = xmlnode_get_namespace(packet);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
424
28715
cea22db36ffc jabber: Use NS_XMPP_SASL
Paul Aurich <paul@darkrain42.org>
parents: 28707
diff changeset
425 if (!purple_strequal(ns, NS_XMPP_SASL)) {
31872
a5b556ac1de5 Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <mark@kingant.net>
parents: 30892
diff changeset
426 purple_connection_error(js->gc,
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
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: 28520
diff changeset
428 _("Invalid response from server"));
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
429 return;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
430 }
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
431
28725
4f45aae3ace1 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents: 28715
diff changeset
432 if (js->auth_mech && js->auth_mech->handle_success) {
28754
b94fd073187c jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents: 28725
diff changeset
433 char *msg = NULL;
28725
4f45aae3ace1 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents: 28715
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: 28715
diff changeset
435
4f45aae3ace1 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents: 28715
diff changeset
436 if (state == JABBER_SASL_STATE_FAIL) {
31872
a5b556ac1de5 Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <mark@kingant.net>
parents: 30892
diff changeset
437 purple_connection_error(js->gc,
28725
4f45aae3ace1 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents: 28715
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: 28715
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: 28715
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: 28715
diff changeset
441 } else if (state == JABBER_SASL_STATE_CONTINUE) {
31872
a5b556ac1de5 Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <mark@kingant.net>
parents: 30892
diff changeset
442 purple_connection_error(js->gc,
28725
4f45aae3ace1 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents: 28715
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: 28715
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: 28715
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: 28715
diff changeset
446 }
28754
b94fd073187c jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents: 28725
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: 28725
diff changeset
448 g_free(msg);
15373
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
28096
b357216b7b79 jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <paul@darkrain42.org>
parents: 28048
diff changeset
451 /*
b357216b7b79 jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <paul@darkrain42.org>
parents: 28048
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: 28048
diff changeset
453 * jabber_bosh_connection_send.
b357216b7b79 jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <paul@darkrain42.org>
parents: 28048
diff changeset
454 */
b357216b7b79 jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <paul@darkrain42.org>
parents: 28048
diff changeset
455 js->reinit = TRUE;
b357216b7b79 jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <paul@darkrain42.org>
parents: 28048
diff changeset
456 jabber_stream_set_state(js, JABBER_STREAM_POST_AUTH);
15373
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
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
461 PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
28754
b94fd073187c jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents: 28725
diff changeset
462 char *msg = NULL;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
463
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
464 if (js->auth_mech && js->auth_mech->handle_failure) {
28725
4f45aae3ace1 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents: 28715
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: 28715
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: 28715
diff changeset
467
28878
c64b22932ffa Cyrus may not have anything (yet) if it's waiting for a callback or something.
Paul Aurich <paul@darkrain42.org>
parents: 28754
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: 28754
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: 28754
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: 28754
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: 28754
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: 28754
diff changeset
473
22767
d5b3afea8764 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evan.s@dreskin.net>
parents: 22672
diff changeset
474 return;
d5b3afea8764 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evan.s@dreskin.net>
parents: 22672
diff changeset
475 }
22657
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: 22532
diff changeset
476 }
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
477
28754
b94fd073187c jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents: 28725
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: 28725
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: 28725
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: 28725
diff changeset
481 if (!msg) {
31872
a5b556ac1de5 Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <mark@kingant.net>
parents: 30892
diff changeset
482 purple_connection_error(js->gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
483 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
484 _("Invalid response from server"));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
485 } else {
31872
a5b556ac1de5 Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <mark@kingant.net>
parents: 30892
diff changeset
486 purple_connection_error(js->gc, reason, msg);
15373
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 }
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
490
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
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: 28520
diff changeset
492 {
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
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: 28520
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: 28520
diff changeset
495
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
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: 28520
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: 28520
diff changeset
498 return -1;
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
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: 28520
diff changeset
500 return 1;
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
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: 28520
diff changeset
502 return 0;
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
503 }
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
504
30892
cea7e713ef07 jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
eion@robbmob.com
parents: 30463
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: 30463
diff changeset
506 {
cea7e713ef07 jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
eion@robbmob.com
parents: 30463
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: 30463
diff changeset
508 }
cea7e713ef07 jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
eion@robbmob.com
parents: 30463
diff changeset
509
cea7e713ef07 jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
eion@robbmob.com
parents: 30463
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: 30463
diff changeset
511 {
cea7e713ef07 jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
eion@robbmob.com
parents: 30463
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: 30463
diff changeset
513 }
cea7e713ef07 jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
eion@robbmob.com
parents: 30463
diff changeset
514
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
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: 28520
diff changeset
516 {
28707
c1d41b7484ff jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents: 28699
diff changeset
517 JabberSaslMech **tmp;
c1d41b7484ff jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents: 28699
diff changeset
518 gint count, i;
c1d41b7484ff jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents: 28699
diff changeset
519
30892
cea7e713ef07 jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
eion@robbmob.com
parents: 30463
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: 30463
diff changeset
521 jabber_auth_add_mech(jabber_auth_get_digest_md5_mech());
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
522 #ifdef HAVE_CYRUS_SASL
30892
cea7e713ef07 jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
eion@robbmob.com
parents: 30463
diff changeset
523 jabber_auth_add_mech(jabber_auth_get_cyrus_mech());
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
524 #endif
28707
c1d41b7484ff jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents: 28699
diff changeset
525
c1d41b7484ff jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents: 28699
diff changeset
526 tmp = jabber_auth_get_scram_mechs(&count);
c1d41b7484ff jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents: 28699
diff changeset
527 for (i = 0; i < count; ++i)
30892
cea7e713ef07 jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
eion@robbmob.com
parents: 30463
diff changeset
528 jabber_auth_add_mech(tmp[i]);
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
529 }
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
530
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
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: 28520
diff changeset
532 {
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
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: 28520
diff changeset
534 auth_mechs = NULL;
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
535 }